| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use app\jobs\storeSync\DiyCommon;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%seckill_activity}}".
- *
- * @property integer $id
- * @property string $name
- * @property integer $start_time
- * @property integer $end_time
- * @property integer $self_limit_num
- * @property integer $order_limit_num
- * @property integer $is_use_coupon
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_delete
- * @property integer $store_id
- * @property integer $status
- * @property integer $is_platform
- * @property integer $is_platform_audit
- */
- class SeckillActivity extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%seckill_activity}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
- ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
- ]
- ]
- ];
- }
- public function beforeSave($insert)
- {
- if (parent::beforeSave($insert)) {
- //$this->dirtyAttributes 改动的项目
- if (intval($this->is_platform === 1) && !empty($this->dirtyAttributes) && !isset($this->dirtyAttributes['status']) && !in_array($this->dirtyAttributes['is_platform_audit'], [1, 2])) {
- $this->is_platform_audit = 0;
- }
- return true;
- }
- return false;
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['id', 'start_time', 'end_time', 'self_limit_num', 'order_limit_num', 'is_use_coupon', 'is_delete', 'store_id', 'status', 'is_platform', 'is_platform_audit'], 'integer'],
- [['name'], 'string'],
- [['created_at', 'updated_at'], 'safe']
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'name' => '活动名称',
- 'start_time' => '开始时间',
- 'end_time' => '结束时间',
- 'self_limit_num' => '个人限购',
- 'order_limit_num' => '订单限购',
- 'is_use_coupon' => '是否使用优惠券',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- 'is_delete' => 'is_delete',
- 'store_id' => 'Store Id',
- 'status' => '状态'
- ];
- }
- public function afterSave($insert, $changedAttributes)
- {
- parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
- (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_SECKILL, [$this->id]);
- }
- }
|