|
@@ -301,7 +301,66 @@ class Intro extends Api
|
|
|
|
|
|
}
|
|
|
|
|
|
- //
|
|
|
+ //转余额。减少intromoney ,充值到 money,走一遍notify
|
|
|
+ public function transform(){
|
|
|
+ $freemoney = input('freemoney',0);
|
|
|
+ if(!$freemoney){
|
|
|
+ $this->error('请填写金额');
|
|
|
+ }
|
|
|
+
|
|
|
+ $money = floatval($freemoney);
|
|
|
+
|
|
|
+ $min = 1;
|
|
|
+ if($money < $min){
|
|
|
+ $this->error('转换金额不能小于'.$min);
|
|
|
+ }
|
|
|
+
|
|
|
+ $user_money = model('wallet')->getwallet($this->auth->id,'intromoney');
|
|
|
+ if($money > $user_money){
|
|
|
+ $this->error('转换金额不能大于可提现余额');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
+ //扣除money
|
|
|
+ $rs_wallet = model('Wallet')->lockChangeAccountRemain($this->auth->id,'intromoney',-$money,115,'转为充值余额');
|
|
|
+ if($rs_wallet['status']===false)
|
|
|
+ {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建充值订单
|
|
|
+ $data = [];
|
|
|
+ $data['user_id'] = $this->auth->id;
|
|
|
+ $data['out_trade_no'] = createUniqueNo('TP',$this->auth->id); // 数据库订单号加密
|
|
|
+ $data['order_amount'] = $money;
|
|
|
+ $data['createtime'] = time();
|
|
|
+
|
|
|
+ $data['pay_type'] = 'transform'; //区别正常充值,唯一字段
|
|
|
+ $data['platform'] = '';
|
|
|
+ $data['order_status'] = 0;
|
|
|
+ $data['table_name'] = 'money_recharge';
|
|
|
+ $data['table_id'] = 0;
|
|
|
+ $data['args'] = '';
|
|
|
+
|
|
|
+ $orderid = Db::name('pay_order')->insertGetId($data);
|
|
|
+ if(!$orderid){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('转入失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+ //立刻开始回调
|
|
|
+ $notify = controller('Notify')->recharge_notify_do($data['out_trade_no'],15,'佣金转入充值');
|
|
|
+ if(!$notify){
|
|
|
+ $this->error('充值失败,请联系客服');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('操作成功');
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|