$endTime) { $openShop = 0; } } } return $openShop; } //需要算上包装费 public static function needAddPackCost($ghsShop, $customId, $orderAmount = 0) { if (isset($ghsShop->pfLevel) && $ghsShop->pfLevel == 1) { $current = date("Y_m_d"); $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId; $has = Yii::$app->redis->executeCommand('GET', [$key]); if (!empty($has) && $has == 1) { return false; } else { return true; } } else { $lackExpend = $ghsShop->lackExpend ? floatval($ghsShop->lackExpend) : 0; $packCost = $ghsShop->packCost ? floatval($ghsShop->packCost) : 0; if ($lackExpend <= 0 || $packCost <= 0) { return false; } $current = date("Y_m_d"); $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId; $has = Yii::$app->redis->executeCommand('GET', [$key]); if (!empty($has) && $has == 1) { return false; } if ($orderAmount > 0) { if ($orderAmount < $lackExpend) { return true; } } else { return true; } return false; } } public static function getNewShopList() { $where = ['ptStyle' => dict::getDict('ptStyle', 'hd')]; $respond = self::getList('*', $where, 'addTime DESC'); $list = $respond['list'] ?? []; if (!empty($list)) { foreach ($list as $key => $val) { $shopName = $val['shopName'] ?? ''; $sjName = $val['merchantName'] ?? ''; $default = $val['default'] ?? 0; $showName = $sjName . ' ' . $shopName; if ($default == 1) { $showName = $sjName; } $list[$key]['showName'] = $showName; $list[$key]['cover'] = imgUtil::groupImg(''); } $respond['list'] = $list; } return $respond; } public static function getShopList($where) { $list = self::getList('*', $where, 'addTime DESC'); $list['list'] = self::groupBaseInfo($list['list']); return $list; } //组装门店基本信息 ssh 2019.12.2 public static function groupBaseInfo($list) { foreach ($list as $key => $val) { $list[$key]['img'] = json_decode($val['img'], true); if (isset($list[$key]['img']) && is_array($list[$key]['img'])) { foreach ($list[$key]['img'] as $img) { $list[$key]['imgUrl'][] = imgUtil::groupImg($img); } } else { $list[$key]['img'] = []; $list[$key]['imgUrl'] = []; } $avatar = $val['avatar'] ?? ''; $shortAvatar = $avatar; $smallAvatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_130,w_130"; $list[$key]['smallAvatar'] = $smallAvatar; $list[$key]['shortAvatar'] = $shortAvatar; $superWx = $val['superWx'] ?? ''; $shortSuperWx = $superWx; $list[$key]['shortSuperWx'] = $shortSuperWx; $list[$key]['superWx'] = imgUtil::groupImg($shortSuperWx) . "?x-oss-process=image/resize,m_fill,h_700,w_700"; } return $list; } public static function addMainShop($data, $oldShop, $sj) { if (isset($oldShop->pfShopId) && !empty($oldShop->pfShopId)) { util::fail('请在批发端操作'); } $mobile = $data['mobile'] ?? 0; if (empty($mobile) || stringUtil::isMobile($mobile) == false) { util::fail('请输入正确手机号'); } $hasShop = ShopClass::getByCondition(['mobile' => $mobile], true); if (!empty($hasShop)) { util::fail('手机号已经使用'); } $hasApply = ApplyClass::getByCondition(['mobile' => $mobile], true); if (!empty($hasApply)) { util::fail('手机号已注册过'); } $defaultShopId = $sj['defaultShopId'] ?? 0; $defaultShop = self::getById($defaultShopId, true); if (empty($defaultShop)) { util::fail('没有找到门店50'); } $oldMainId = $defaultShop->mainId ?? 0; if (empty($oldMainId)) { util::fail('没有找到main信息'); } $main = MainClass::addMainCopyItem($oldMainId); $mainId = $main->id ?? 0; $data['mainId'] = $mainId; $newShop = self::addShop($data); return $newShop; } //创建门店 ssh 2020.2.8 public static function addShop($data) { $data['createTime'] = date("Y-m-d H:i:s"); $shopName = isset($data['shopName']) ? $data['shopName'] : ''; $mainId = $data['mainId'] ?? 0; if (empty($shopName)) { util::fail('请填写门店名称'); } if (stringUtil::getWordNum($shopName) > 8) { util::fail('门店名称不能超过8个汉字,2个字母顶一个汉字'); } $exists = self::getByCondition(['sjId' => $data['sjId'], 'shopName' => $shopName]); if (!empty($exists)) { util::fail('门店名称已经存在'); } //补充fullAddress lqh 2021.4.18 $data['fullAddress'] = $data['city'] . $data['address'] . $data['floor']; $data['img'] = isset($data['img']) && !empty($data['img']) ? json_encode($data['img']) : ''; if (isset($data['ptStyle']) == false) { util::fail('请先择平台类型'); } $shop = self::add($data, true); $newShopId = $shop->id; $extData = ['shopId' => $newShopId]; ShopExtClass::add($extData); //商品和分类初始化 CategoryClass::initCategoryGoods($mainId); //商城和门店广告初始化 AdClass::initAdd($mainId); //商品配置信息 $setData = ['mainId' => $mainId, 'riseType' => 0, 'riseAmount' => 0]; GoodsSettingClass::add($setData); //初始化员工和角色 $adminId = $data['adminId'] ?? 0; $mobile = $data['mobile'] ?? 0; $initAdminData = ['mobile' => $mobile, 'adminId' => $adminId]; AdminClass::initAdmin($initAdminData, $mainId, $shop); return $shop; } //获取首店id public static function getDefaultShopId($shop) { $sjId = $shop->sjId ?? 0; $sj = SjClass::getById($sjId, true); $defaultShopId = $sj->defaultShopId ?? 0; return $defaultShopId; } }