| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace addons\Store\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "{{%addons_store_boss_agent_commission_setting_log}}".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $store_id
- * @property string $source_table 来源表
- * @property int $source_table_id 来源表id
- * @property string|null $basic_config 基础配置
- * @property string|null $level_config 等级配置
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class StoreBossAgentCommissionSettingLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_store_boss_agent_commission_setting_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'store_id', 'source_table_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['basic_config', 'level_config'], 'string'],
- [['source_table'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'store_id' => 'Store ID',
- 'source_table' => 'Source Table',
- 'source_table_id' => 'Source Table ID',
- 'basic_config' => 'Basic Config',
- 'level_config' => 'Level Config',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * @desc:保存数据
- * @Author: hua
- * @Date: 2021/11/18
- * @Time: 10:54
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param array $params
- * @return AgentCommissionBasisLog|false|null
- */
- public static function setData(array $params)
- {
- try {
- $model = self::findOne(['mall_id' => $params['mall_id'],
- 'source_table_id' => $params['source_table_id'],
- 'source_table' => $params['source_table'],
- 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if(!empty($model)) return $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;
- }
- }
- }
|