正在显示
1 个修改的文件
包含
43 行增加
和
0 行删除
@@ -439,4 +439,47 @@ class UsersController extends HomeBaseController{ | @@ -439,4 +439,47 @@ class UsersController extends HomeBaseController{ | ||
439 | $return['fee']=\db('users')->where('id',$user_id)->value('fee'); | 439 | $return['fee']=\db('users')->where('id',$user_id)->value('fee'); |
440 | $this->apiResponse(200,'success',$return); | 440 | $this->apiResponse(200,'success',$return); |
441 | } | 441 | } |
442 | + | ||
443 | + | ||
444 | + /** | ||
445 | + * @title 用户提现 | ||
446 | + * @description | ||
447 | + * @author panhaowen | ||
448 | + * @url /portal/users/withdraw | ||
449 | + * @method GET | ||
450 | + * @param name:user_id type:String require:1 default:无 other: desc:用户id | ||
451 | + * @param name:fee type:int require:1 default:无 other: desc:用户id | ||
452 | + */ | ||
453 | + public function withdraw(){ | ||
454 | + $user_id=input('user_id'); | ||
455 | + $fee=$this->request->param('fee'); | ||
456 | + $user=Db::name('users')->where('id',$user_id)->find(); | ||
457 | + if ($user['fee']>=$fee) { | ||
458 | + $order_sn=cmf_get_order_sn(); | ||
459 | + Db::name('users')->setDec('fee', $fee); | ||
460 | + Db::name('withdraw')->insert([ | ||
461 | + 'user_id'=>$user_id, | ||
462 | + 'money'=>$fee, | ||
463 | + 'create_time'=>time(), | ||
464 | + 'order_sn'=>$order_sn | ||
465 | + ]); | ||
466 | + $app = new Application($this->options); | ||
467 | + $merchantPay = $app->merchant_pay; | ||
468 | + $merchantPayData = [ | ||
469 | + 'partner_trade_no' => $order_sn, //随机字符串作为订单号,跟红包和支付一个概念。 | ||
470 | + 'openid' => $user['open_id'], //收款人的openid | ||
471 | + 'check_name' => 'NO_CHECK', //文档中有三种校验实名的方法 NO_CHECK OPTION_CHECK FORCE_CHECK | ||
472 | +// 're_user_name'=>'张三', //OPTION_CHECK FORCE_CHECK 校验实名的时候必须提交 | ||
473 | + 'amount' => $fee * 100, //单位为分 | ||
474 | +// 'amount' => 100, //单位为分 | ||
475 | + 'desc' => '企业付款', | ||
476 | + 'spbill_create_ip' => get_client_ip(0, true), //发起交易的IP地址 | ||
477 | + ]; | ||
478 | + $re = $merchantPay->send($merchantPayData); | ||
479 | + $this->apiResponse(200,'success',$re); | ||
480 | + }else{ | ||
481 | + $this->apiResponse(300,'余额不足提现失败'); | ||
482 | + } | ||
483 | + | ||
484 | + } | ||
442 | } | 485 | } |
-
请 注册 或 登录 后发表评论