| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- use Yii;
- /**
- * This is the model class for table "{{%bonus_pool}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $start_time
- * @property integer $end_time
- * @property integer $created_at
- */
- class ReportPool extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%report_pool}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
- ]
- ]
- ];
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['store_id', 'start_time', 'end_time', 'created_at','is_send','send_time','commit_time' ,'number'], 'integer'],
- [[ 'reward_amount'], 'number'],
- [['created_at'], 'safe']
- ];
- }
- public static function getBonusPool($store_id, $params = [], $field = '*') {
- $query = self::find()->where(['store_id' => $store_id]);
- if ($params) {
- $query->andWhere($params);
- }
- $data = $query->select($field)->orderBy('id desc')->asArray()->all();
- foreach ($data as &$item) {
- if (isset($item['start_time']) && isset($item['end_time'])) {
- $item['instalments'] = date("Y-m-d", $item['start_time']) . '~' . date("Y-m-d", $item['end_time']);
- }
- }
- return $data;
- }
- }
|