services->setting->addons->get($mall_id, QiShangTongEnums::ADDONS_NAME, 'basic') ?? []; } /** * 设置配置信息 * @param int $mall_id * @param array $data * @return bool */ public function save(int $mall_id, array $data) :bool { return \Yii::$app->services->setting->addons->set($mall_id, QiShangTongEnums::ADDONS_NAME, ['basic' => $data]); } public static function getPrices(int $mall_id) { $price = \Yii::$app->services->setting->addons->get($mall_id, QiShangTongEnums::ADDONS_NAME, 'basic.price') ?? '[]'; return Json::decode($price); } const PRICE = 'price'; const COST_PRICE = 'cost_price'; const ORIGINAL_PRICE = 'original_price'; /** * 获取价格 * @param int $mall_id * @param string $field * @param array $third_prices * @param array|null $prices * @return string */ public static function getPrice(int $mall_id, string $field, array $third_prices, array $prices = null) { $prices === null && self::getPrices($mall_id); $tmp = $prices[$field]; // type, rate return bcmul(bcmul(bcmul($third_prices[$tmp['type']], $tmp['rate'][$tmp['type']], 2), 0.01, 2), MallService::rate($mall_id), 2); } public static function basicPrice(int $mall_id, string $price) { return bcmul(MallService::rate($mall_id), $price, 2); } /** * @return mixed|null */ public static function getMasterMall() { foreach (Mall::getAllMallIds() as $mallId) { if (MallAddons::isInstall($mallId, AddonsEnum::ADDONS_NAME_QI_SHANG_TONG)) { $config = (new SettingService())->get($mallId); if (!empty($config['is_default'])) { return $mallId; } } } return null; } /** * 判断是否为主商城 * @param int $mall_id * @return bool */ public static function isMasterMall(int $mall_id) { return $mall_id == self::getMasterMall(); } }