'ID', 'mall_id' => '商城ID', 'store_id' => '店铺ID', 'percent' => '设置比例,单位:百分比', 'status' => '状态【-1删除 0发放中,1正常】', 'created_at' => '创建时间', 'updated_at' => '更新数据时间', ]; } /** * 关联店铺表 * @Author: lun * @DateTime: 2022/8/23 0023 18:30 * @Copyright: copyright (c) 2021 广东七件事集团 * @return \yii\db\ActiveQuery */ public function getStore() { return $this->hasOne(Store::class, ['id' => 'store_id'])->select('id,store_name,logo_img,user_id'); } /** * 保存数据 * @Author: lun * @DateTime: 2022/8/23 0023 17:29 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $params * @return array|bool */ public static function setData($params) { try { $model = self::findOne(['store_id' => $params['store_id'], 'status' => StatusEnum::ENABLED]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model->toArray(); } catch (\Exception $e) { self::setStaticError($e->getMessage()); return false; } } }