| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- /*
- * @Descripttion:
- * @copyright: Copyright (c) 2021 广东七件事集团
- * @Author: lun
- * @Date: 2022-01-01 01:10:32
- */
- namespace addons\Rebate\common\models;
- use common\models\user\User;
- use yii\db\Exception;
- /**
- * This is the model class for table "qimall_addons_rebate_reward_log".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property int $r_id 对应qimall_addons_rebate.id
- * @property int $user_id 用户id
- * @property string|null $reward_title 奖励名称
- * @property string|null $content 奖励内容
- * @property string|null $setting 结算时的配置
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- * @property int $is_frozen 是否冻结
- */
- class RebateRewardLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_rebate_reward_log';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id'], 'required'],
- [['mall_id', 'r_id', 'user_id', 'status', 'created_at', 'updated_at', 'is_frozen'], 'integer'],
- [['reward_title'], 'string', 'max' => 50],
- [['content', 'setting'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'r_id' => 'R ID',
- 'user_id' => 'User ID',
- 'reward_title' => '奖励名称',
- 'content' => 'Content',
- 'setting' => 'Setting',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'is_frozen' => 'Is Frozen',
- ];
- }
- /***
- * 关联用户
- */
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- /**
- * 保存数据
- * @Author: lun
- * @DateTime: 2022/1/15 0015 9:36
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $mall_id
- * @param array $params
- * @return array|bool
- */
- public static function setData($mall_id, array $params){
- try{
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $mall_id;
- if(!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
- return $model->toArray();
- }catch(\Exception $e){
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|