'ID', 'mall_id' => 'Mall ID', 'is_enable' => 'Is Enable', 'goods_id' => 'Goods ID', 'give_num' => 'Give Num', 'settlement_method' => 'Settlement Method', 'status' => 'Status', 'created_at' => 'Created At', 'is_enable_promote_reward_type' => 'Updated At', 'is_enable_promote_reward_prize' => 'Updated At', ]; } public static function getGoodSetting($params) { // 后台页面组件展示 if ($params['type'] == 'show_component') { return [ 'component' => 'com-write-off', 'path' => Yii::$app->basePath . '/../addons/WriteOff/backend/views/goods', ]; } else { try { if (empty($params['setting'][WriteOffEnum::ADDONS_NAME])) return true; $setting = $params['setting'][WriteOffEnum::ADDONS_NAME]; $setting['mall_id'] = $params['mall_id']; $setting['goods_id'] = $params['goods_id']; // 数据保存 $res = self::setData($setting); if ($res === false) throw new \Exception(self::getStaticError()); return true; } catch (\Exception $e) { self::setStaticError($e->getMessage()); return false; } } } public static function setData(array $params) { try { $model = self::findOne(['mall_id' => $params['mall_id'], 'goods_id' => $params['goods_id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }