| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace addons\IssueCoupons\common\models;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "{{%addons_issue_coupons_rule}}".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property string $name 规则名称
- * @property int $grant_object 发放对象:1:全部会员 2:会员等级 3:会员标签 4:会员id 5:指定区域
- * @property string $grant_object_content 对象内容
- * @property int|null $timing_time 定时发送时间
- * @property int|null $grant_time 上一次发放券的时间
- * @property int $grant_type 发放类型:1:手动发放 2:自动发放 3:失效
- * @property int $grant_status 发放状态:1:未发放 2:已发放 3:发放中
- * @property int|null $is_grant 是否发放:0:未发放 1:已发放
- * @property string|null $redpack_remark 红包备注
- * @property string|null $score_remark 积分备注
- * @property string|null $balance_remark 余额备注
- * @property int $admin_id 管理员id
- * @property string|null $remark 备注
- * @property int $created_at
- * @property int $updated_at
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property float|null $e_coupon 电子券数量
- * @property float|null $coupon 优惠卷数量
- * @property float|null $redpack 红包统计
- * @property float|null $balance 金额统计
- * @property float|null $score 积分统计
- */
- class IssueCouponsRule extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_issue_coupons_rule}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'grant_object_content'], 'required'],
- [['mall_id', 'grant_object', 'timing_time', 'grant_time', 'grant_type', 'grant_status', 'is_grant', 'admin_id', 'created_at', 'updated_at', 'status'], 'integer'],
- [['e_coupon', 'coupon','grant_object_content'], 'string'],
- [['redpack', 'balance', 'score'], 'number'],
- [['name'], 'string', 'max' => 200],
- [['redpack_remark', 'score_remark', 'balance_remark'], 'string', 'max' => 300],
- [['remark'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城id',
- 'name' => '规则名称',
- 'grant_object' => '发放对象:1:全部会员 2:会员等级 3:会员标签 4:会员id 5:指定区域',
- 'grant_object_content' => '对象内容',
- 'timing_time' => '定时发送时间',
- 'grant_time' => '上一次发放券的时间',
- 'grant_type' => '发放类型:1:手动发放 2:自动发放 3:失效',
- 'grant_status' => '发放状态:1:未发放 2:已发放 3:发放中',
- 'is_grant' => '是否发放:0:未发放 1:已发放',
- 'redpack_remark' => '红包备注',
- 'score_remark' => '积分备注',
- 'balance_remark' => '余额备注',
- 'admin_id' => '管理员id',
- 'remark' => '备注',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'e_coupon' => '电子券数量',
- 'coupon' => '优惠卷数量',
- 'redpack' => '红包统计',
- 'balance' => '金额统计',
- 'score' => '积分统计',
- ];
- }
-
- /**
- * 保存数据
- * @Author: ltm
- * @DateTime: 2022/6/28 0015 9:26
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $mall_id
- * @param array $params
- * @return Rebate|bool
- */
- public static function setData(array $params){
- try{
- $mall_id = $params['mall_id'];
- $model = self::findOne(['id'=>$params['id'],'mall_id' => $mall_id]);
- if(empty($model)){
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $mall_id;
- }
- // 将内容转为json字符串
- if(!$model->load($params,'') || !$model->save()) throw new Exception($model->getErrorMessage());
- return $model;
- }catch(\Exception $e){
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|