...
|
...
|
@@ -542,6 +542,21 @@ class UsersController extends HomeBaseController{ |
|
|
if ($user['fee']>=$fee) {
|
|
|
//生成订单号
|
|
|
$order_sn=cmf_get_order_sn();
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
Db::name('users')->where('id',$user_id)->setDec('fee', $fee);
|
|
|
Db::name('withdraw')->insert([
|
|
|
'user_id'=>$user_id,
|
|
|
'money'=>$fee,
|
|
|
'create_time'=>time(),
|
|
|
'order_sn'=>$order_sn
|
|
|
]);
|
|
|
Db::commit();
|
|
|
}catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
$this->apiResponse(301,'提现失败');
|
|
|
}
|
|
|
//进行提现
|
|
|
$app = new Application($this->options);
|
|
|
$merchantPay = $app->merchant_pay;
|
...
|
...
|
@@ -557,23 +572,12 @@ class UsersController extends HomeBaseController{ |
|
|
];
|
|
|
$re = $merchantPay->send($merchantPayData);
|
|
|
if ($re['return_code']=='SUCCESS' && $re['result_code']=='SUCCESS'){
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
Db::name('users')->where('id',$user_id)->setDec('fee', $fee);
|
|
|
Db::name('withdraw')->insert([
|
|
|
'user_id'=>$user_id,
|
|
|
'money'=>$fee,
|
|
|
'create_time'=>time(),
|
|
|
'order_sn'=>$order_sn
|
|
|
]);
|
|
|
Db::commit();
|
|
|
}catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
$this->apiResponse(301,'提现失败');
|
|
|
}
|
|
|
$this->apiResponse(200,'success');
|
|
|
}else{
|
|
|
Db::name('users')->where('id',$user_id)->setInc('fee', $fee);
|
|
|
Db::name('withdraw')->where([
|
|
|
'order_sn'=>$order_sn
|
|
|
])->delete();
|
|
|
$this->apiResponse(301,'提现失败');
|
|
|
}
|
|
|
}else{
|
...
|
...
|
|