| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace addons\Store\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_store_reserve_setting".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property int $store_id 门店id
- * @property string|null $setting
- * @property int $status 状态0禁用,-1删除,1正常
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- */
- class StoreReserveSetting extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_store_reserve_setting}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id'], 'required'],
- [['mall_id', 'store_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['setting'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'store_id' => 'Store ID',
- 'setting' => 'Setting',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function setData($params)
- {
- try {
- $where = ['store_id' => $params['store_id'], 'status' => StatusEnum::ENABLED];
- $model = self::findOne($where);
- if (empty($model)){
- $model = new self();
- $model->loadDefaultValues();
- $model->store_id = $params['store_id'];
- $model->mall_id = $params['mall_id'];
- }
- $params['setting'] = json_encode($params['setting'],JSON_UNESCAPED_UNICODE);
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|