| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- namespace addons\UpgradeGift\common\models;
- use common\enums\StatusEnum;
- use common\models\user\User;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "{{%addons_upgrade_gift_grant_log}}".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property int $gift_type 礼包类型
- * @property int $user_id 用户id
- * @property int $level 等级id
- * @property string|null $coupon 优惠券详细
- * @property int|null $coupon_num 优惠券数量
- * @property float|null $score 积分
- * @property float|null $balance 余额
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $goods_id 商品id
- * @property int $goods_name 商品名称
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- */
- class UpgradeGiftGrantLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_upgrade_gift_grant_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id'], 'required'],
- [['mall_id', 'user_id', 'level', 'coupon_num', 'status', 'created_at', 'updated_at', 'goods_id', 'attr_id'], 'integer'],
- [['score', 'balance'], 'number'],
- [['gift_type'], 'string', 'max' => 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;
- }
- }
- }
|