shish před 2 měsíci
rodič
revize
055529755d

+ 21 - 0
app-ghs/controllers/ItemController.php

@@ -81,6 +81,27 @@ class ItemController extends BaseController
         util::complete('清除成功');
     }
 
+    //取消限购:将 limitBuy 置为 0
+    public function actionCancelLimitBuy()
+    {
+        $get = Yii::$app->request->get();
+        $id = intval($get['id'] ?? 0);
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        $oldLimitBuy = intval($item->limitBuy ?? 0);
+        if ($oldLimitBuy <= 0) {
+            util::complete('已取消限购');
+        }
+        ProductClass::clearLimitBuyByProductId($id, $oldLimitBuy);
+        ProductClass::clearLimitBuyCache($id);
+        util::complete('取消限购成功');
+    }
+
     public function actionModifyWeight()
     {
         $shop = $this->shop;

+ 1 - 0
app-ghs/controllers/PurchaseOrderItemController.php

@@ -133,6 +133,7 @@ class PurchaseOrderItemController extends BaseController
                 $list[$key]['beforeModifyPrice'] = $beforeModifyPrice;
                 $beforeModifyStock = $current['stock'] ?? 0;
                 $list[$key]['beforeModifyStock'] = $beforeModifyStock;
+                $list[$key]['limitBuy'] = intval($current['limitBuy'] ?? 0);
             }
         }
         util::success(['list' => $list]);