|
@@ -62,86 +62,7 @@ class Recharge extends Api
|
|
|
$this->success('success',$user_info);
|
|
|
}
|
|
|
|
|
|
- //创建订单,公众号
|
|
|
- public function recharge(){
|
|
|
|
|
|
- $rc_id = input('rc_id',0);
|
|
|
- $pay_type = input('pay_type','wechat');
|
|
|
- $username = input('username',0);
|
|
|
-
|
|
|
-
|
|
|
- if(!$rc_id){
|
|
|
- $this->error('请选择充值金额');
|
|
|
- }
|
|
|
-
|
|
|
- if(!$username){
|
|
|
- $this->error('请输入用户手机号并选择');
|
|
|
- }
|
|
|
-
|
|
|
- //查找用户
|
|
|
- $user_info = Db::name('user')->field('id')->where('username',$username)->find();
|
|
|
- if (empty($user_info)) {
|
|
|
- $this->error('用户信息不存在');
|
|
|
- }
|
|
|
-
|
|
|
- //赋值money
|
|
|
- $recharge_config = Db::name('paygold_webcon')->where('id',$rc_id)->find();
|
|
|
- $money = $recharge_config['money'];
|
|
|
- $gold = $recharge_config['gold'];
|
|
|
-
|
|
|
- //创建订单
|
|
|
- $data = [];
|
|
|
- $data['status'] = 0;
|
|
|
- $pay_no = createUniqueNo('P',$user_info['id']);
|
|
|
- $data['pay_no'] = $pay_no;
|
|
|
- $data['money'] = $money;
|
|
|
- $data['payment_class'] = $pay_type;
|
|
|
- $data['user_id'] = $user_info['id'];
|
|
|
- $data['ext_info'] = json_encode(['subject'=>'充值金币支付']);
|
|
|
- $data['memo'] = '充值金币支付';
|
|
|
- $data['createtime'] = time();
|
|
|
- $data['payment'] = 'mp';
|
|
|
- $orderid = Db::name('pay_order')->insertGetId($data);
|
|
|
-
|
|
|
- //创建回调
|
|
|
- $data = [];
|
|
|
- $data['event'] = 'success';
|
|
|
- $data['class'] = 'app\common\model\Recharge';
|
|
|
- $data['method'] = 'rechargepaysucc';
|
|
|
- $data['args'] = json_encode(['user_id'=>$user_info['id'],'gold'=>$gold,'money'=>$money,'pg_id'=>$rc_id]);
|
|
|
- $data['pay_no'] = $pay_no;
|
|
|
- Db::name('pay_event')->insertGetId($data);
|
|
|
-
|
|
|
- $return = [
|
|
|
- 'pay_no'=>$pay_no,
|
|
|
- 'title' => '充值金币支付',
|
|
|
- ];
|
|
|
-
|
|
|
- $this->success('success',$return);
|
|
|
- }
|
|
|
-
|
|
|
- //公众号
|
|
|
- public function topay(){
|
|
|
-
|
|
|
- $openid = input('openid');
|
|
|
- $pay_no = input('pay_no');
|
|
|
- $pay_type = input_post('pay_type','wechat');
|
|
|
- $orderInfo = Db::name('pay_order')->where('pay_no',$pay_no)->find();
|
|
|
- //下单
|
|
|
- $params = [
|
|
|
- 'type' => $pay_type,
|
|
|
- 'orderid' => $pay_no,
|
|
|
- 'title' => $orderInfo['memo'],
|
|
|
- 'amount' => $orderInfo['money'],
|
|
|
- // 'amount' => 0.01,
|
|
|
- 'method' => 'mp',
|
|
|
- 'openid' => $openid,
|
|
|
- 'notifyurl' => $this->request->root(true) . '/notify.php',
|
|
|
- //'returnurl' => $this->request->root(true) . '/location.php',
|
|
|
- ];
|
|
|
- $res = Service::submitOrder($params);
|
|
|
- $this->success('请求成功',json_decode($res,true));
|
|
|
- }
|
|
|
|
|
|
//兑换金币
|
|
|
public function exchangegold() {
|
|
@@ -191,13 +112,6 @@ class Recharge extends Api
|
|
|
$this->error($wallet_rs['msg']);
|
|
|
}
|
|
|
|
|
|
- //tag任务赠送金币
|
|
|
- //开通VIP 50金币
|
|
|
-// $task_rs = \app\common\model\TaskLog::tofinish($uid,9);
|
|
|
-// if($task_rs === false){
|
|
|
-// Db::rollback();
|
|
|
-// $this->error('完成任务赠送奖励失败');
|
|
|
-// }
|
|
|
Db::commit();
|
|
|
|
|
|
$this->success('兑换成功');
|