request->isAjax) { $service = (new SettingService()); if (Yii::$app->request->isPost) { $data = Yii::$app->request->post(); $valid = Yii::$app->services->validate->validate($data, [ [['is_enable', 'is_default', 'auto_update_price'], 'integer'], [['app_key', 'token', 'public_key', 'contact_image'], 'string'], [['market_price_rate', 'price_rate', 'min_balance'], 'number'], [['price', 'mobile'], 'safe'], ]); if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $data['price'] = !empty($data['price']) ? Json::encode($data['price']) : '[]'; if (!empty($data['is_default']) && $this->admin->admin_type == StatusEnum::ENABLED) { // 需要将其他的更新为非默认 foreach (Mall::getAllMallIds() as $mallId) { if ($mallId != $this->mall_id) { $config = $service->get($mallId); $config['is_default'] = StatusEnum::DISABLED; $service->save($mallId, $config); } } } if (!empty($data['auto_update_price'])) { $ret = $service->get($this->mall_id); // 判断订单是否更改 if (!empty($ret['price']) && (md5($ret['price']) != md5($data['price']))) { // 需要更新商品价格 try { (new GoodsService())->changePrice($this->mall_id); } catch (\Exception $e) { return $this->error($e->getMessage()); } } } return $service->save($this->mall_id, $data) ? $this->success("保存成功", $data) : $this->error('保存失败'); } else { $ret = $service->get($this->mall_id); if (!empty($ret['price'])) { $ret['price'] = Json::decode($ret['price']); if (!is_array($ret['price']['price']['rate'])) $ret['price'] = null; } return $this->success('success', $ret); } } $get_system_setting = PlatformSetting::getConfByGroup('system', true); return $this->render('index',['order_callback_url' => "{$get_system_setting['api_url']['value']}/qi-ding-dong/v1/order/event", 'goods_callback_url' => "{$get_system_setting['api_url']['value']}/qi-ding-dong/v1/goods/event", 'admin_type' => $this->admin->admin_type]); } }