Browse Source

贵金属销售单无法取消

wufeng 2 years ago
parent
commit
16a329c046
1 changed files with 12 additions and 2 deletions
  1. 12 2
      app/admin/controller/Sale.php

+ 12 - 2
app/admin/controller/Sale.php

@@ -5073,7 +5073,7 @@ class Sale extends Base
     }
 
     //订单取消
-    //未发货状态添加撤销功能  要求1.库存品 未发货 直接撤销 2.除了库存品以外的商品类型,采购单未入库的 可撤销。@刘雪寒 @武锋 @ 
+    //未发货状态添加撤销功能  要求1.库存品 未发货 直接撤销 2.除了库存品以外的商品类型,采购单未入库的 可撤销。
     public function orderCancel()
     {
         $orderCode = $this->request->post('orderCode', '', 'trim');
@@ -5084,13 +5084,22 @@ class Sale extends Base
 
         $list = Db::name('sale')
             ->alias('a')
-            ->field('a.id sale_id,a.order_type,a.status sale_status,a.orderCode,c.id cgd_id,c.status cgd_status')
+            ->field('a.id sale_id,a.order_type,a.status sale_status,a.orderCode,a.cat_id,c.id cgd_id,c.status cgd_status')
             ->leftJoin('order_num b', 'b.orderCode=a.orderCode')
             ->leftJoin('purchease_order c', 'c.cgdNo=b.cgdNo')
             ->where(['a.is_del' => 0, 'a.orderCode' => $orderCode])
             ->select()
             ->toArray();
 
+        //贵金属的所有三级分类
+        $cat_temp = Db::name('cat')
+            ->field('id')
+            ->where(['pid' => 6, 'is_del' => 0])
+            ->buildSql();
+        $cat_id = Db::name('cat')
+            ->where('is_del = 0 AND pid IN ' . $cat_temp)
+            ->column('id');
+
         Db::startTrans();
         try {
 
@@ -5099,6 +5108,7 @@ class Sale extends Base
             foreach ($list as $sale) {
 
                 if ($sale['sale_status'] == 3) throw new \think\Exception($sale['orderCode'] . '已取消,无法重复操作');
+                if (in_array($sale['cat_id'], $cat_id)) throw new \think\Exception($sale['orderCode'] . '为贵金属,无法取消');
 
                 if ($sale['order_type'] == 1) {
                     if (in_array($sale['sale_status'], [0, 1]) == false) throw new \think\Exception($sale['orderCode'] . '未处于待发货状态,无法取消');