浏览代码

unishop的支付与回调

lizhen_gitee 10 月之前
父节点
当前提交
003d373564
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      application/api/controller/Unishop.php

+ 8 - 6
application/api/controller/Unishop.php

@@ -17,10 +17,13 @@ class Unishop extends Api
     protected $noNeedRight = ['*'];
 
     //支付订单
-    //微信小程序、微信app下单使用。
     public function pay_order(){
+        $apilimit = $this->apiLimit();
+        if(!$apilimit){
+            $this->error('操作过于频繁');
+        }
         $pay_type = input('pay_type','alipay');
-        $platform = input('platform','wap');
+        $platform = input('platform','app');
         $orderid = input('order_id',0);
 
         if(empty($orderid)){
@@ -33,7 +36,6 @@ class Unishop extends Api
         }
 
         $uid = $this->auth->id;
-
         $map = [
             'id'       => $orderid,
             'user_id'  => $uid,
@@ -50,16 +52,16 @@ class Unishop extends Api
             Db::startTrans();
 
             //扣钱
-            $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,'money',$orderinfo['total_price'],31,'购物','unishop_order',$orderid);
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,'money',$orderinfo['total_price'],31,'商城购物','unishop_order',$orderid);
             if($rs_wallet['status'] == false){
                 Db::rollback();
                 $this->error($rs_wallet['msg']);
             }
 
             //订单改为已支付
-            $order_update['pay_type'] = 'wallet';
+            $order_update['pay_type'] = 2;
             $order_update['have_paid'] = time();
-            $update_rs = Db::name('unishop_order')->where('id',$orderid)->where('have_paid',0)->update($order_update);
+            $update_rs = Db::name('unishop_order')->where($map)->update($order_update);
             if(!$update_rs){
                 Db::rollback();
                 $this->error('支付失败,重试一下吧');