| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\modules\admin\models\q_and_a;
- use app\models\IntegralRecharge;
- use yii\base\Model;
- /**
- * @property \app\models\IntegralRecharge $model;
- */
- class IntegralRechargeListForm extends Model
- {
- public $id;
- public $name;
- public $sort;
- public $state;
- public $store_id;
- public $dateTime;
- public function rules()
- {
- return [
- [['name', 'sort','state'], 'required'],
- [['id'], 'integer'],
- [['name', 'dateTime'], 'string', 'max' => 255],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'name' => '充值名称',
- 'state' => '是否启用',
- ];
- }
- public function search()
- {
- $query = IntegralRecharge::find()->alias('ro')->where([
- 'ro.is_delete' => 0,
- 'ro.store_id' => $this->store_id,
- ])->orderBy('ro.id DESC');
- if ($this->name) {
- $query->andWhere(['like', 'ro.name', $this->name]);
- }
- if ($this->state >= 0) {
- $query->andWhere(['ro.state' => $this->state]);
- }
- if ($this->dateTime) {
- $query->andWhere(['>=', 'ro.created_at', strtotime($this->dateTime[0])]);
- $query->andWhere(['<=', 'ro.created_at', strtotime($this->dateTime[1])]);
- }
- $data = pagination_make($query);
- foreach ($data['list'] as &$item) {
- $item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
- }
- return [
- 'code' => 0,
- 'data' => [
- 'data' => $data['list'],
- 'pageNo' => $data['pageNo'],
- 'totalCount' => $data['totalCount']
- ],
- 'sql' => $query->createCommand()->getRawSql(),
- ];
- }
- }
|