20], [['coupon'], 'string', 'max' => 1024], [['goods_name'], 'string', 'max' => 120], [['attr_name'], 'string', 'max' => 500], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城id', 'gift_type' => '礼包类型', 'user_id' => '用户id', 'level' => '等级id', 'coupon' => '优惠券详细', 'coupon_num' => '优惠券数量', 'score' => '积分', 'balance' => '余额', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } /** * 关联用户 * @Author: lun * @DateTime: 2021/12/20 0020 14:37 * @Copyright: copyright (c) 2021 广东七件事集团 * @return \yii\db\ActiveQuery */ public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } /** * 保存数据 * @Author: lun * @DateTime: 2021/12/20 0020 9:30 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $params * @return UpgradeGiftGrantLog|bool */ public static function setData($params) { try{ $model = new self(); $model->loadDefaultValues(); // 保存 if(!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; }catch(\Exception $e){ self::setStaticError($e->getMessage()); return false; } } }