diff --git a/Application/Sdk/Controller/SpendController.class.php b/Application/Sdk/Controller/SpendController.class.php index 7e9e4e99..09f3949b 100644 --- a/Application/Sdk/Controller/SpendController.class.php +++ b/Application/Sdk/Controller/SpendController.class.php @@ -11,6 +11,8 @@ use Sdk\Model\ValueDetailLogModel; class SpendController extends Controller { + public static $arr_pay_way = ['alipay','wxpay','sqshorcut','shorcut']; + /** * 转发支付url */ @@ -532,5 +534,58 @@ ADD COLUMN `pay_url` varchar(255) NOT NULL DEFAULT '' AFTER `check_sign`; $this->display (); } + + public function addPayChannelIntention() { + $user_token = I('user_token'); + $pay_way = I('payway'); + + if (!$user_token) { + echo "access deny!"; + die(); + } + + $user_info = M('user_token','tab_')->field('user_id,game_id')->where(['user_token'=>$user_token])->find(); + + if (!$user_info) { + echo json_encode(['code'=>0,'msg'=>'用户信息不存在']); + exit; + } + + $pay_info = M('pay_info', 'tab_')->where([ + 'user_id' => $user_info['user_id'], + 'game_id' => $user_info['game_id'] + ])->order("id desc")->find(); + + if (!$pay_info['order_id']) { + echo json_encode(['code'=>0,'msg'=>'error']); + exit; + } + + if (!in_array($pay_way,self::$arr_pay_way)) { + echo json_encode(['code'=>0,'msg'=>'支付方式参数错误']); + exit; + } + +// $user_info = M('user','tab_')->field('account')->where(['id'=>$user_id])->find(); + + $insert['user_id'] = $user_info['user_id']; + $insert['user_account'] = $pay_info['user_account']; + $insert['pay_way'] = $pay_way; + $insert['pay_amount'] = $pay_info['price']; + $insert['pay_order_number'] = $pay_info['order_id']; + $insert['create_time'] = time(); + + $is_success = M('pay_channel_intention','tab_')->add($insert); + + if ($is_success) { + echo json_encode(['code'=>200,'msg'=>"success"]); + die(); + } else { + echo json_encode(['code'=>0,'msg'=>"error"]); + die(); + } + + + } } diff --git a/Application/Sdk/View/default/Spend/pay_way.html b/Application/Sdk/View/default/Spend/pay_way.html index fc595ac5..e0ff6b1f 100644 --- a/Application/Sdk/View/default/Spend/pay_way.html +++ b/Application/Sdk/View/default/Spend/pay_way.html @@ -109,7 +109,7 @@ - +