zhangguidong 2 年之前
父節點
當前提交
abc227ba11
共有 2 個文件被更改,包括 14 次插入0 次删除
  1. 2 0
      app/data/controller/api/Order.php
  2. 12 0
      app/data/service/PaymentService.php

+ 2 - 0
app/data/controller/api/Order.php

@@ -33,6 +33,8 @@ class Order extends Auth
 {
     protected $noNeedLogin=['order_list','text','uploadmore','order_create'];
 
+
+
     /**
      * @Title("商品规格下单")
      * @Method("post")

+ 12 - 0
app/data/service/PaymentService.php

@@ -6,7 +6,9 @@ use app\data\model\BaseUserPayment;
 use app\data\model\DataUser;
 use app\data\model\DataUserPayment;
 use app\data\model\DataUserVipOrder;
+use app\data\model\ShopGoods;
 use app\data\model\ShopOrder;
+use app\data\model\ShopOrderItem;
 use app\data\model\ShopOrderPay;
 use app\data\service\payment\AlipayPaymentService;
 use app\data\service\payment\BalancePaymentService;
@@ -359,7 +361,17 @@ abstract class PaymentService
         $orderNo = $notify['out_trade_no'];
         $order = ShopOrderPay::mk()->where('pay_no',$orderNo)->findOrEmpty();
         if ($order->isEmpty()) return false;
+        $order_nos = ShopOrder::mk()->where(['payment_trade'=>$orderNo])->field('order_no')->select();
+        foreach ($order_nos as &$v){
+            $info = ShopOrderItem::mk()->where('order_no',$v['order_no'])->field('goods_code,goods_sku,stock_sales')->find();
+            $goods = ShopGoods::mk()->where('pay_no',$info['goods_code'])->findOrEmpty();
+            $item = ShopGoods::mk()->where('pay_no',$info['goods_sku'])->findOrEmpty();
+            $goods->stock_total -=$info['stock_sales'];
+            $item->stock_total -=$info['stock_sales'];
+            $goods->save();
+            $item->save();
 
+        }
         ShopOrder::mk()->where(['payment_trade'=>$orderNo])->save(['status'=>4,'payment_datetime'=>date('Y-m-d H:i:s'),'payment_status'=>1]);