正在显示
1 个修改的文件
包含
20 行增加
和
25 行删除
@@ -1058,32 +1058,27 @@ class Store extends Api | @@ -1058,32 +1058,27 @@ class Store extends Api | ||
1058 | $deposit = $this->deposit_model->findOrFail(['id'=>$param['deposit_id']]); | 1058 | $deposit = $this->deposit_model->findOrFail(['id'=>$param['deposit_id']]); |
1059 | $order_sn = $param['order_sn'] = get_order_sn(); | 1059 | $order_sn = $param['order_sn'] = get_order_sn(); |
1060 | $pay_data = []; | 1060 | $pay_data = []; |
1061 | - if($this->auth->end_time > time()) { | ||
1062 | - $param['status'] = 2; | 1061 | + // 获取小程序配置 |
1062 | + $options = \config('miniprogram.basic'); | ||
1063 | + $app = new Application($options); | ||
1064 | + $payment = $app->payment; | ||
1065 | + // 获取支付参数 | ||
1066 | + $attributes = [ | ||
1067 | + 'body' => '板币充值', | ||
1068 | + 'out_trade_no' => $order_sn, | ||
1069 | + 'total_fee' => 1, // $param['money'] * 100 | ||
1070 | + 'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址 | ||
1071 | + 'notify_url' => url('index/ajax/notify',[],true,true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址 | ||
1072 | + 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型 | ||
1073 | + 'openid' => Db::name('third')->where('user_id',$this->auth->id)->value('openid'), | ||
1074 | + ]; | ||
1075 | + $order = new Order($attributes); | ||
1076 | + $order_result = $payment->pay($order); | ||
1077 | + if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') { | ||
1078 | + $prepayId = $order_result->prepay_id; | ||
1079 | + $pay_data = $payment->configForJSSDKPayment($prepayId); // 返回数组 | ||
1063 | } else { | 1080 | } else { |
1064 | - $param['status'] = 1; | ||
1065 | - // 获取小程序配置 | ||
1066 | - $options = \config('miniprogram.basic'); | ||
1067 | - $app = new Application($options); | ||
1068 | - $payment = $app->payment; | ||
1069 | - // 获取支付参数 | ||
1070 | - $attributes = [ | ||
1071 | - 'body' => '板币充值', | ||
1072 | - 'out_trade_no' => $order_sn, | ||
1073 | - 'total_fee' => 1, // $param['money'] * 100 | ||
1074 | - 'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址 | ||
1075 | - 'notify_url' => url('index/ajax/notify',[],true,true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址 | ||
1076 | - 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型 | ||
1077 | - 'openid' => Db::name('third')->where('user_id',$this->auth->id)->value('openid'), | ||
1078 | - ]; | ||
1079 | - $order = new Order($attributes); | ||
1080 | - $order_result = $payment->pay($order); | ||
1081 | - if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') { | ||
1082 | - $prepayId = $order_result->prepay_id; | ||
1083 | - $pay_data = $payment->configForJSSDKPayment($prepayId); // 返回数组 | ||
1084 | - } else { | ||
1085 | - $this->error($order_result['return_msg']); | ||
1086 | - } | 1081 | + $this->error($order_result['return_msg']); |
1087 | } | 1082 | } |
1088 | $model = $this->deposit_order_model; | 1083 | $model = $this->deposit_order_model; |
1089 | Db::startTrans(); | 1084 | Db::startTrans(); |
-
请 注册 或 登录 后发表评论