ソースを参照

新增接口:上门最低消费设置 -- 针对批发商客户进行批量修改

shizhongqi 9 ヶ月 前
コミット
db5ea36911
1 ファイル変更37 行追加0 行削除
  1. 37 0
      app-ghs/controllers/CustomController.php

+ 37 - 0
app-ghs/controllers/CustomController.php

@@ -835,6 +835,9 @@ class CustomController extends BaseController
         util::complete();
     }
 
+    /**
+     * 上门最低消费设置 -- 单个修改
+     */
     public function actionModifyHomeAmount()
     {
         $get = Yii::$app->request->get();
@@ -862,6 +865,40 @@ class CustomController extends BaseController
         util::complete('修改成功');
     }
 
+    /**
+     * 上门最低消费设置 -- 针对批发商客户进行批量修改
+     */
+    public function actionModifyAllHomeAmount()
+    {
+        $get = Yii::$app->request->get();
+        $homeAmount = $get['homeAmount'] ?? 0;
+        $homeType = $get['homeType'] ?? 0;
+
+        // 批量更新客户信息
+        CustomClass::updateByCondition(
+            ['ownMainId' => $this->mainId],
+            ['homeAmount' => $homeAmount, 'homeType' => $homeType]
+        );
+
+        // 获取需要更新的供货商 ID
+        $customs = CustomClass::getAllList('ghsId', ['ownMainId' => $this->mainId]);
+        $ghsIds = [];
+        foreach ($customs as $custom) {
+            if (!empty($custom['ghsId'])) {
+                $ghsIds[] = $custom['ghsId'];
+            }
+        }
+        // 批量更新供货商信息
+        if (!empty($ghsIds)) {
+            GhsClass::updateByCondition(
+                ['id' => ['in', array_unique($ghsIds)]],
+                ['homeAmount' => $homeAmount, 'homeType' => $homeType]
+            );
+        }
+
+        util::complete('修改成功');
+    }
+
     //允许月结开关 ssh 2021.1.8
     public function actionDebt()
     {