...
|
...
|
@@ -36,7 +36,7 @@ class UsersController extends HomeBaseController{ |
|
|
* @author sgj
|
|
|
* @url /portal/users/changeorder
|
|
|
* @method GET
|
|
|
*
|
|
|
* @group 用户相关接口2
|
|
|
* @param name:id type:String require:1 default:无 other: desc:订单id
|
|
|
*
|
|
|
*/
|
...
|
...
|
@@ -439,4 +439,55 @@ class UsersController extends HomeBaseController{ |
|
|
$return['fee']=\db('users')->where('id',$user_id)->value('fee');
|
|
|
$this->apiResponse(200,'success',$return);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 用户提现
|
|
|
* @description
|
|
|
* @author panhaowen
|
|
|
* @url /portal/users/withdraw
|
|
|
* @method GET
|
|
|
* @param name:user_id type:String require:1 default:无 other: desc:用户id
|
|
|
* @param name:fee type:int require:1 default:无 other: desc:用户id
|
|
|
*/
|
|
|
public function withdraw(){
|
|
|
$user_id=input('user_id');
|
|
|
$fee=$this->request->param('fee');
|
|
|
$user=Db::name('users')->where('id',$user_id)->find();
|
|
|
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;
|
|
|
$merchantPayData = [
|
|
|
'partner_trade_no' => $order_sn, //随机字符串作为订单号,跟红包和支付一个概念。
|
|
|
'openid' => $user['open_id'], //收款人的openid
|
|
|
'check_name' => 'NO_CHECK', //文档中有三种校验实名的方法 NO_CHECK OPTION_CHECK FORCE_CHECK
|
|
|
// 're_user_name'=>'张三', //OPTION_CHECK FORCE_CHECK 校验实名的时候必须提交
|
|
|
'amount' => $fee * 100, //单位为分
|
|
|
// 'amount' => 100, //单位为分
|
|
|
'desc' => '企业付款',
|
|
|
'spbill_create_ip' => get_client_ip(0, true), //发起交易的IP地址
|
|
|
];
|
|
|
$re = $merchantPay->send($merchantPayData);
|
|
|
$this->apiResponse(200,'success',$re);
|
|
|
}else{
|
|
|
$this->apiResponse(300,'余额不足提现失败');
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|