request->get(); $shopId = $get['id'] ?? 0; $shop = ShopClass::getById($shopId, true); if (empty($shop)) { util::fail('没有找到门店43'); } $old = $shop->needRenew; $new = $old == 0 ? 1 : 0; $shop->needRenew = $new; $shop->save(); util::complete('修改成功'); } //添加员工 ssh 2023429 public function actionAddStaff() { $post = Yii::$app->request->post(); $mobile = $post['mobile'] ?? ''; $shopId = $post['shopId'] ?? 0; $super = $post['super'] ?? 0; $nickName = $post['nickName'] ?? ''; $nickName = empty($nickName) ? substr($mobile, 7, 4) : $nickName; $shop = ShopClass::getById($shopId, true); if (empty($shop)) { util::fail('没有找到门店44'); } $ptStyle = $shop->ptStyle ?? 1; $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $mainId = $shop->mainId ?? 0; $adminInfo = ['name' => $nickName, 'mobile' => $mobile, 'style' => $ptStyle, 'currentGhsShopId' => $shopId]; $fromApp = dict::getDict('userSourceGetId', 'app', 'id'); $admin = \bizGhs\admin\classes\AdminClass::replaceAdmin($adminInfo, $fromApp); $role = AdminRoleClass::getByCondition(['mainId' => $mainId], true); if (empty($role)) { util::fail('没有找到角色...'); } $roleId = $role->id ?? 0; $addData = ['shopId' => $shopId, 'mobile' => $mobile, 'super' => $super, 'remind' => 1, 'roleId' => $roleId]; $respond = []; if ($ptStyle == 2) { $respond = ShopAdminClass::appGenerateStaff($addData, $admin); } elseif ($ptStyle == 1) { $respond = StaffClass::appGenerateStaff($addData, $admin); } else { util::fail('不存在的平台'); } $transaction->commit(); util::success($respond); } catch (\Exception $exception) { $transaction->rollBack(); Yii::info("失败原因:" . $exception->getMessage()); util::fail('添加失败'); } } //调整仅采购功能,允许零售使用所有功能 ssh 20220919 public function actionChangeOnlyCg() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $shop = ShopClass::getById($id, true); if (empty($shop)) { util::fail('没有找到门店45'); } if ($shop->ptStyle != 1) { util::fail('只能给零售店操作'); } $shop->onlyCg = $shop->onlyCg == 0 ? 1 : 0; $shop->save(); 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 (is_numeric($name)) { $where['mobile'] = ['like', $name]; } elseif (stringUtil::isLetter($name)) { $where['py'] = ['like', $name]; } else { $where['merchantName'] = ['like', $name]; } } $list = ShopService::getShopList($where); util::success($list); } }