['name' => '普店', 'num' => 0, 'amount' => 0, 'key' => ''], 'hj' => ['name' => '银店', 'num' => 0, 'amount' => 0, 'key' => 'hj'], 'zs' => ['name' => '金店', 'num' => 0, 'amount' => 0, 'key' => 'zs'], ]; //添加虚拟的供货商 ssh 20230305 public function actionAddGhs() { $post = Yii::$app->request->post(); $name = $post['name'] ?? ''; if (empty($name)) { util::fail('请填写名称'); } if (stringUtil::getWordNum($name) > 8) { util::fail('名称不能超过8个汉字'); } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $shopId = $this->shopId; $has = GhsClass::getByCondition(['ownShopId' => $shopId, 'name' => $name], true); if (!empty($has)) { util::fail($name . ' 已经存在了'); } \bizHd\ghs\services\GhsService::addVirtualGhs($post, $this->shop); $transaction->commit(); util::complete('添加成功'); } catch (\Exception $e) { $transaction->rollBack(); Yii::error("添加失败原因:" . $e->getMessage()); util::fail('添加失败'); } } //是否屏蔽 ssh 20230226 public function actionChangeDelStatus() { $get = Yii::$app->request->get(); $ghsId = $get['ghsId'] ?? 0; $delStatus = $get['delStatus'] ?? 0; $ghs = GhsClass::getById($ghsId, true); if (empty($ghs)) { util::fail('没有找到供货商'); } $ownMainId = $ghs->ownMainId ?? 0; if ($ownMainId != $this->mainId) { util::fail('没有权限操作'); } $ghs->delStatus = $delStatus; $ghs->save(); util::complete('操作成功'); } //获取供货商物流 ssh 20230105 public function actionGetAllWl() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $ghs = GhsClass::getById($id, true); if (empty($ghs) || $ghs->ownMainId != $this->mainId) { util::success(['list' => []]); } $ghsMainId = $ghs->mainId ?? 0; $list = \bizGhs\merchant\classes\WlClass::getAllByCondition(['mainId' => $ghsMainId, 'delStatus' => 0], 'inTurn DESC', 'id,name'); util::success(['list' => $list]); } //采购选分类有变化通知 public function actionGetClassRemind() { $cacheKey = 'class_change_remind_' . $this->shopAdminId; $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]); $hasStatus = !empty($has) ? 1 : 0; util::success(['hasRemind' => $hasStatus]); } //采购选分类有变化通知 public function actionHasClassRemind() { $cacheKey = 'class_change_remind_' . $this->shopAdminId; Yii::$app->redis->executeCommand('SET', [$cacheKey, 'has']); util::complete(); } //供货商列表 ssh 2021.1.24 public function actionList() { $get = Yii::$app->request->get(); $delStatus = isset($get['delStatus']) && is_numeric($get['delStatus']) ? $get['delStatus'] : 0; $where = []; $where['ownShopId'] = $this->shopId; $where['delStatus'] = $delStatus; $respond = GhsClass::getGhsList($where); //广告列表 $apiHost = Yii::$app->params['hdImgHost']; //$ad = [['banner' => $apiHost . '/ljh/banner2.jpg', 'url' => '/admin/ljh/info']]; $ad = []; $respond['ad'] = $ad; util::success($respond); } //详情 ssh 2021.4.11 public function actionDetail() { $id = Yii::$app->request->get('id'); $info = GhsClass::getGhsInfo($id); $giveLevel = $info['giveLevel'] ?? 0; $levelMap = CustomClass::$nickNameMap; $giveLevelName = $levelMap[$giveLevel] ?? '散客'; $info['giveLevelName'] = $giveLevelName; GhsClass::valid($info, $this->shopId); //是否有充值送红包活动 $ghsShopId = $info['shopId'] ?? 0; $ghsShop = ShopClass::getById($ghsShopId, true); $info['hasRechargeHb'] = $ghsShop->recharge ?? 0; $hb = RechargeHbClass::getByCondition(['shopId' => $ghsShopId, 'delStatus' => 0], true, 'totalHb DESC'); $info['hasRechargeHbAmount'] = $hb->totalHb ?? 0; $info['xrFl'] = $ghsShop->xrFl ?? 0; $info['xrFlAmount'] = $ghsShop->xrFlAmount ?? 0; $info['tjFl'] = $ghsShop->tjFl ?? 0; $info['tjFlAmount'] = $ghsShop->tjFlAmount ?? 0; $info['packCost'] = $ghsShop->packCost ?? 0; $info['buyNotice'] = $ghsShop->buyNotice ?? 0; //预订单的最低公斤数和每公斤服务费 $info['kiloFee'] = $ghsShop->kiloFee ?? 0; $info['miniKilo'] = $ghsShop->miniKilo ?? 0; //杭州斗南鲜花批发 免运费活动 if (isset($info['shopId']) && $info['shopId'] == 4608) { $current = time(); if ($current < strtotime('2023-4-8 00:00:00')) { $info['hasAct'] = 1; } } util::success($info); } //根据门店获取供货商信息 ssh 2021.4.14 public function actionInfo() { $shopId = Yii::$app->request->get('shopId'); if (isset($this->shopId) && !empty($this->shopId)) { $current = ShopClass::getById($shopId, true); if (isset($current->ptStyle) == false || $current->ptStyle != dict::getDict('ptStyle', 'ghs')) { util::fail('没有找到批发店'); } $ghs = GhsClass::build($shopId, $this->shopId); //是否有充值送红包活动 $ghsShopId = $ghs['shopId'] ?? 0; $ghsShop = ShopClass::getById($ghsShopId, true); $ghs['hasRechargeHb'] = $ghsShop->recharge ?? 0; $hb = RechargeHbClass::getByCondition(['shopId' => $ghsShopId, 'delStatus' => 0], true, 'totalHb DESC'); $ghs['hasRechargeHbAmount'] = $hb->totalHb ?? 0; $avatar = $ghs['avatar'] ?? ''; $ghs['avatar'] = imgUtil::groupImg($avatar); $map = CustomClass::$nickNameMap; $giveLevel = $ghs['giveLevel'] ?? 0; $ghs['giveLevelName'] = $map[$giveLevel] ?? ''; $ghs['buyNotice'] = $ghsShop->buyNotice ?? 0; $ghs['xrFl'] = $ghsShop->xrFl ?? 0; $ghs['xrFlAmount'] = $ghsShop->xrFlAmount ?? 0; $ghs['tjFl'] = $ghsShop->tjFl ?? 0; $ghs['tjFlAmount'] = $ghsShop->tjFlAmount ?? 0; } else { //没有开店也给显示供货商信息 $shop = ShopClass::getShopInfo($shopId); $shopName = $shop['shopName'] ?? ''; $sjName = $shop['merchantName'] ?? ''; $avatar = $shop['avatar'] ?? ''; $default = $shop['default'] ?? 0; $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName; $ghs = [ 'id' => 0, 'name' => $name, 'debtAmount' => 0.00, 'expendAmount' => 0.00, 'giveLevel' => 0, 'giveLevelName' => '普通', 'xrFl' => 0, 'xrFlAmount' => 0, 'tjFl' => 0, 'tjFlAmount' => 0, 'avatar' => $avatar, 'buyNotice' => 0, ]; } util::success($ghs); } //获取客户等级 ssh 20211016 public function actionGetCustomLevel() { $id = Yii::$app->request->get('id'); $info = GhsClass::getById($id, true); GhsClass::valid($info, $this->shopId); $ghsShopId = $info->shopId ?? 0; $info = CustomLevelClass::getByCondition(['shopId' => $ghsShopId]); $map = self::$levelMap; foreach ($map as $key => $val) { $flag = $val['key'] ?? ''; if (empty($flag)) { $map[$key]['num'] = $info["num"] ?? 0; $map[$key]['amount'] = $info["amount"] ?? 0; } else { $map[$key]['num'] = $info[$flag . "Num"] ?? 0; $map[$key]['amount'] = $info[$flag . "Amount"] ?? 0; } } util::success(['list' => $map]); } //访问供货商的商城 ssh 20211022 public function actionVisitMall() { $id = Yii::$app->request->get('id'); $info = GhsClass::getById($id, true); GhsClass::valid($info, $this->shopId); $customId = $info->customId ?? 0; $custom = CustomClass::getById($customId, true); if (empty($custom)) { util::fail('没有找到客户'); } StatVisitClass::addGhsCustomVisit($info, $custom); util::complete(); } //补充缺失的供货商 ssh 20211027 public function actionBcGhs() { util::fail('过几天再试'); GhsClass::bcGhs($this->shopId); util::complete('载入成功'); } }