Przeglądaj źródła

Merge branch 'master' into redesign‌-260706

shish 1 tydzień temu
rodzic
commit
4ae67dc3c3

+ 8 - 0
app-pt/controllers/ApplyController.php

@@ -36,10 +36,18 @@ class ApplyController extends BaseController
     {
         $get = Yii::$app->request->get();
         $status = $get['status'] ?? 0;
+        $name = $get['name'] ?? '';
         $where = [];
         if (!empty($status)) {
             $where['status'] = $status;
         }
+        if (!empty($name)) {
+            if (is_numeric($name)) {
+                $where['mobile'] = ['like', $name];
+            } else {
+                $where['name'] = ['like', $name];
+            }
+        }
         $list = ApplyService::getApplyList($where);
         util::success($list);
     }

+ 71 - 1
app-pt/controllers/ShopController.php

@@ -97,13 +97,83 @@ class ShopController extends BaseController
         util::complete();
     }
 
+    //修改/批量修改门店终端号、到期时间、续费状态等信息
+    public function actionUpdate()
+    {
+        $post = Yii::$app->request->post();
+        $isBatch = $post['isBatch'] ?? 0;
+        $ids = $post['ids'] ?? $post['id'] ?? [];
+        if (is_string($ids)) {
+            $ids = array_filter(array_map('trim', explode(',', $ids)));
+        } elseif (is_numeric($ids)) {
+            $ids = [(int)$ids];
+        }
+        if (empty($ids)) {
+            util::fail('缺少门店ID');
+        }
+
+        $shops = ShopClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
+        if (empty($shops)) {
+            util::fail('没有找到对应门店');
+        }
+
+        foreach ($shops as $shop) {
+            if (!empty($isBatch) || count($ids) > 1) {
+                // 批量修改模式:只更新有传且不为空/不为-1的字段
+                if (isset($post['lklSjNo']) && trim((string)$post['lklSjNo']) !== '') {
+                    $shop->lklSjNo = trim((string)$post['lklSjNo']);
+                }
+                if (isset($post['lklB2BTermNo']) && trim((string)$post['lklB2BTermNo']) !== '') {
+                    $shop->lklB2BTermNo = trim((string)$post['lklB2BTermNo']);
+                }
+                if (isset($post['lklScanTermNo']) && trim((string)$post['lklScanTermNo']) !== '') {
+                    $shop->lklScanTermNo = trim((string)$post['lklScanTermNo']);
+                }
+                if (isset($post['deadline']) && trim((string)$post['deadline']) !== '') {
+                    $shop->deadline = trim((string)$post['deadline']);
+                }
+                if (isset($post['beforeDeadline']) && trim((string)$post['beforeDeadline']) !== '') {
+                    $shop->beforeDeadline = trim((string)$post['beforeDeadline']);
+                }
+                if (isset($post['hasRenew']) && $post['hasRenew'] !== '' && (int)$post['hasRenew'] !== -1) {
+                    $shop->hasRenew = (int)$post['hasRenew'];
+                }
+            } else {
+                // 单个修改模式:全量覆盖提交的字段
+                if (isset($post['lklSjNo'])) {
+                    $shop->lklSjNo = trim((string)$post['lklSjNo']);
+                }
+                if (isset($post['lklB2BTermNo'])) {
+                    $shop->lklB2BTermNo = trim((string)$post['lklB2BTermNo']);
+                }
+                if (isset($post['lklScanTermNo'])) {
+                    $shop->lklScanTermNo = trim((string)$post['lklScanTermNo']);
+                }
+                if (isset($post['deadline'])) {
+                    $shop->deadline = !empty($post['deadline']) ? trim((string)$post['deadline']) : null;
+                }
+                if (isset($post['beforeDeadline'])) {
+                    $shop->beforeDeadline = !empty($post['beforeDeadline']) ? trim((string)$post['beforeDeadline']) : null;
+                }
+                if (isset($post['hasRenew'])) {
+                    $shop->hasRenew = (int)$post['hasRenew'];
+                }
+            }
+            $shop->save();
+        }
+
+        util::complete('修改成功');
+    }
+
     //门店列表 ssh 20210730
     public function actionList()
     {
         $where = [];
         $name = Yii::$app->request->get('name', '');
         if (!empty($name)) {
-            if (stringUtil::isLetter($name)) {
+            if (is_numeric($name)) {
+                $where['mobile'] = ['like', $name];
+            } elseif (stringUtil::isLetter($name)) {
                 $where['py'] = ['like', $name];
             } else {
                 $where['merchantName'] = ['like', $name];