| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%activity_cut_price}}".
- *
- * @property integer $id
- */
- class ActivityCutPrice extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%activity_cut_price}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- ]
- ];
- }
- 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;
- }
- //店铺进行中活动
- public static function activityAt($id) {
- $query = self::find();
- $query->andWhere([
- 'and',
- ['id' => $id, 'is_delete' => 0, 'status' => 1],
- ['<', 'start_time', time()],
- ['>', 'end_time', time()],
- ]);
- $info = $query->one();
- return $info;
- }
- //店铺进行中活动
- public static function activityAtList($store_id = 0, $asArray = false) {
- $query = self::find();
- $query->andWhere([
- 'and',
- ['is_delete' => 0, 'status' => 1],
- ['<', 'start_time', time()],
- ['>', 'end_time', time()],
- ]);
- if($store_id > -1){
- $query->andWhere(['store_id' => $store_id]);
- }
- $asArray && $query->asArray();
- $list = $query->all();
- return $list;
- }
- }
|