$val) { $adminId = $val['adminId']; $sjId = $val['id']; $setId = $val['setId']; $val['adminName'] = isset($admin[$adminId]['name']) ? $admin[$adminId]['name'] : ''; $val['merchantAsset'] = isset($asset[$sjId]) ? $asset[$sjId] : []; $val['setMealName'] = isset($set[$setId]) ? $set[$setId]['name'] : ''; $val['extend'] = isset($ext[$sjId]) ? $ext[$sjId] : []; $list[$key] = business::formatMerchantLogo($val); } $data['list'] = $list; return $data; } //根据id批量取商家 ssh 2019.12.20 public static function getMerchantByIds($ids) { return MerchantClass::getMerchantByIds($ids); } //获取商家 ssh 2019.12.30 public static function getMerchantById($id) { return MerchantClass::getMerchantById($id); } public static function getCurrentSetId($id) { return MerchantClass::getCurrentSetId($id); } //开店公众号授权之后初始化 ssh 2020.2.7 public static function openShopInit($data) { $sjId = $data['sjId']; $merchant = MerchantClass::getMerchantById($sjId); if (empty($merchant)) { return false; } $extend = MerchantExtendClass::getBySjId($sjId); if (isset($extend['init']) && $extend['init'] == 1) { return true; } //事务处理 $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { //初始化微信菜单 $hasMenu = WxMenuService::getByCondition(['sjId' => $sjId]); if (empty($hasMenu)) { xhWxMenuService::applyInit($merchant); } //微信客户初始化 $hasUser = UserService::getByCondition(['sjId' => $sjId]); if (empty($hasUser)) { $return = UserService::syncWxAllUser($sjId); $totalNum = isset($return['total']) ? $return['total'] : 0; MerchantAssetClass::updateByCondition(['sjId' => $sjId], ['totalFans' => $totalNum, 'totalUser' => $totalNum]); } //模板消息 $hasMessage = TMessageService::getByCondition(['sjId' => $sjId]); if (empty($hasMessage)) { xhTMessageService::init($merchant); } //完成初始化标识 MerchantExtendClass::updateByCondition(['sjId' => $sjId], ['init' => 1]); //代理资产 AgentAssetClass::add(['sjId' => $sjId]); $transaction->commit(); return true; } catch (Exception $e) { $transaction->rollBack(); return false; } } //初始化平台的商家 ssh 2020.2.11 public static function initOpenMerchant() { $open = WxOpenClass::getOpen(); if (isset($open['wx_base_id']) && !empty($open['wx_base_id']) && isset($open['wx_mini_base_id']) && !empty($open['wx_mini_base_id'])) { util::stop('已初始化,无需重复操作'); } $env = getenv('YII_ENV'); switch ($env) { case 'local': $name = '花美灵'; break; case 'dev': $name = '花美灵'; break; case 'test': $name = '花掌柜'; break; case 'production': $name = '花卉宝'; break; default: $name = '花卉宝'; } echo $name; } //获取商家的h5商城二维码 ssh 2020.4.30 public static function getH5MallQrCode($id) { return MerchantClass::getH5MallQrCode($id); } }