|
@@ -93,5 +93,61 @@ class PhOrders extends Base
|
|
|
HelpHander::success($ret,'成功');
|
|
|
}
|
|
|
|
|
|
+ public function pay2(){
|
|
|
+ $payId = input('payId/d',0);
|
|
|
+ $info = Db::name('ph_order_pay')->where('id',$payId)->where('status',0)->find();
|
|
|
+ if(!$info){
|
|
|
+ HelpHander::error('订单不存在');
|
|
|
+ }
|
|
|
+ if ($this->orgId == 100){
|
|
|
+ $config = config('app.wx_mini_config_ph_px');
|
|
|
+ $notify = config("app.app_host").'/api/h5/notify/phOrderPx2';
|
|
|
+ }else{
|
|
|
+ $config = config('app.wx_mini_config_ph');
|
|
|
+ $notify = config("app.app_host").'/api/h5/notify/phorder2';
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ $openid = Db::name('wxuser')->where('id',$this->userId)->where('type',3)->value('openid');
|
|
|
+ $app = Factory::payment($config);
|
|
|
+ $title = "预付款";
|
|
|
+ if($info['bus_type'] == 1){
|
|
|
+ $title = "服务费";
|
|
|
+ }
|
|
|
+ $result = $app->order->unify([
|
|
|
+ 'body' => $title,
|
|
|
+ 'out_trade_no' => $info['sn'],
|
|
|
+ 'total_fee' => $info['money']*100,
|
|
|
+ 'notify_url' => $notify, // 支付结果通知网址,如果不设置则会使用配置里的默认地址
|
|
|
+ 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
|
|
|
+ 'openid' => $openid,
|
|
|
+ ]);
|
|
|
+ if($result['return_code'] != 'SUCCESS' || $result['result_code'] != 'SUCCESS'){
|
|
|
+ \exception(json_encode($result));
|
|
|
+ }
|
|
|
+
|
|
|
+ $jssdk = $app->jssdk;
|
|
|
+ $ret = $jssdk->sdkConfig($result['prepay_id']); // 返回数组
|
|
|
+ $ret['sn'] = $info['sn'];
|
|
|
+ $ret['money'] = $info['money'];
|
|
|
+ trace($ret);
|
|
|
+ }catch (\Exception $e){
|
|
|
+ trace($e->getMessage());
|
|
|
+ HelpHander::error($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ HelpHander::success($ret,'成功');
|
|
|
+ }
|
|
|
+ public function temps(){
|
|
|
+ $temps = [
|
|
|
+// 'COP22f3d6KAFhCHpZQQC9xx8y4GJcxunfbjfiHKlRAY',
|
|
|
+// 'j6ZzH3cgDUU57mKEpcJzVNa3VbwR0mrznuOmkBoPwd0',
|
|
|
+// 'wfDNG2rNhVcdOd5L3XHMT-mcbrwLAN8IUBBeCvpdTrw'
|
|
|
+ ];
|
|
|
+ $data = [
|
|
|
+ 'tips' => '为更好地服务您,小程序需要在订单变化时向您发送消息',
|
|
|
+ 'temps' => $temps
|
|
|
+ ];
|
|
|
+ HelpHander::success($data);
|
|
|
+ }
|
|
|
|
|
|
}
|