正在显示
1 个修改的文件
包含
40 行增加
和
4 行删除
@@ -670,12 +670,48 @@ class OrderController extends HomeBaseController{ | @@ -670,12 +670,48 @@ class OrderController extends HomeBaseController{ | ||
670 | $insert['type']=2; | 670 | $insert['type']=2; |
671 | $insert['users_id']=$user_id; | 671 | $insert['users_id']=$user_id; |
672 | $result=\db('order')->insert($insert); | 672 | $result=\db('order')->insert($insert); |
673 | - if ($result==1){ | ||
674 | - $reutrn['order_no']=$insert['order_no']; | ||
675 | - $this->apiResponse(200,'success',$reutrn); | ||
676 | - }else{ | 673 | + if ($result!=1){ |
677 | $this->apiResponse(400,'下单失败!'); | 674 | $this->apiResponse(400,'下单失败!'); |
678 | } | 675 | } |
676 | +// $order=Db::name('order')->where(['order_no'=>$order_no,'state'=>2])->find(); | ||
677 | + $openId=Db::name('users')->where('id',$user_id)->find()['open_id']; | ||
678 | + | ||
679 | + $body='支付'; | ||
680 | + $price=$insert['price']*100;//订单价格 | ||
681 | + $notify_url=url('order/notify','','',true);//回调地址 | ||
682 | + $out_trade_no=$insert['order_no']; | ||
683 | + $wxPay=new WeixinPay($openId,$out_trade_no,$body,$price,$notify_url); | ||
684 | + $pay=$wxPay->pay(); | ||
685 | + if (isset($pay['package'])){ | ||
686 | + $data=[ | ||
687 | + 'state'=>1, | ||
688 | + 'pay'=>$pay | ||
689 | + ]; | ||
690 | + $this->apiResponse(200,'success',$data); | ||
691 | + }else{ | ||
692 | + $data=[ | ||
693 | + 'state'=>0, | ||
694 | + 'message'=>'统一下单失败', | ||
695 | + 'error' => $pay | ||
696 | + ]; | ||
697 | + $this->apiResponse(200,'success',$data); | ||
698 | + } | ||
699 | + } | ||
700 | + | ||
701 | + /** | ||
702 | + * @title 充值 | ||
703 | + * @description | ||
704 | + * @author sgj | ||
705 | + * @url /portal/order/chargeOrder | ||
706 | + * @method GET | ||
707 | + * | ||
708 | + * @param name:fee type:String require:1 default:无 other: desc:金额 | ||
709 | + * @param name:user_id type:String require:1 default:无 other: desc:用户id | ||
710 | + * | ||
711 | + * @return order:订单号 | ||
712 | + */ | ||
713 | + public function chargePay($order_no){ | ||
714 | + | ||
679 | } | 715 | } |
680 | 716 | ||
681 | /** | 717 | /** |
-
请 注册 或 登录 后发表评论