| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- /**
- * MdGroupActivities.php
- * todo 文件描述
- * Created on 2024/3/19 11:08
- * @author: hankaige
- */
- namespace app\models;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%md}}".
- * @property integer $id
- * @property integer $store_id
- * @property string $name
- * @property integer $start_time
- * @property integer $end_time
- * @property integer $type
- * @property integer $rules
- * @property integer $status
- * @property integer $jobs_id
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_delete
- */
- class MdGroupActivities extends \yii\db\ActiveRecord
- {
- public static function tableName()
- {
- return "{{%md_group_activities}}";
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
- ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
- ]
- ]
- ];
- }
- public function rules()
- {
- return [
- [
- [
- 'store_id',
- 'start_time',
- 'end_time',
- 'name'
- ],
- 'required'
- ],
- [
- [
- 'store_id',
- 'start_time',
- 'end_time',
- 'type',
- 'rules',
- 'jobs_id'
- ],
- 'integer'
- ],
- [
- [
- 'name'
- ],
- 'string'
- ],
- [
- [
- 'type',
- 'rules'
- ],
- 'default',
- 'value' => 0
- ],
- [
- ['status'],
- 'default',
- 'value' => 1
- ],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'store_id' => '商城ID',
- 'name' => '活动名称',
- 'start_time' => '活动开始时间',
- 'end_time' => '活动结束时间',
- 'type' => '活动规则',
- 'rules' => '规则限制',
- 'status' => '活动状态'
- ];
- }
- public function getGoods()
- {
- return $this->hasMany(MdGroupActivitiesGoods::className(), ['activities_id' => 'id'])->where(['is_delete' => 0]);
- }
- public function getactivityStatus()
- {
- if ($this->start_time > time()) {
- $activityStatus = 1;
- } elseif ($this->end_time < time()) {
- $activityStatus = 3;
- } else {
- $activityStatus = 2;
- }
- return $activityStatus;
- }
- }
|