| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\alliance\models;
- use app\models\Cash;
- use yii\base\Model;
- use yii\data\Pagination;
- class CashListForm extends Model
- {
- public $store_id;
- public $user_id;
- public $saas_id;
- public $status;
- public $page;
- public $limit;
- public $cash_type = -1;
- public function rules()
- {
- return [
- [['page', 'limit', 'status',], 'integer'],
- [['page',], 'default', 'value' => 1],
- [['limit',], 'default', 'value' => 10],
- ];
- }
- public function getList()
- {
- if (!$this->validate()) {
- return [
- 'code' => 1,
- 'msg' => $this->getErrorSummary(false)[0],
- ];
- }
- $query = Cash::find()->where([
- 'is_delete'=>0,
- 'saas_id'=>$this->saas_id
- ]);
- if ($this->cash_type > -1) {
- $query->andWhere([
- 'cash_type' => $this->cash_type
- ]);
- }
- if ($this->status == 0 && $this->status != null) { //待审核
- $query->andWhere(['status'=>0]);
- }
- if ($this->status == 1) {//待打款
- $query->andWhere(['status'=>1]);
- }
- if ($this->status == 2) {//已打款
- $query->andWhere(['in','status',[2,5]]);
- }
- if ($this->status == 3) {//无效
- $query->andWhere(['status'=>3]);
- }
- $count = $query->count();
- $pagination = new Pagination(['totalCount' => $count, 'page' => $this->page - 1, 'pageSize' => $this->limit]);
- $list = $query->limit($pagination->limit)->offset($pagination->offset)->orderBy('status ASC,created_at DESC')->all();
- $new_list = [];
- /* @var Cash[] $list */
- foreach ($list as $index => $value) {
- $new_list[] = (object)[
- 'price' => $value->price,
- 'addtime' => date('Y-m-d H:i:s', $value->created_at),
- 'status'=> Cash::$status[$value->status],
- 'type'=> $value->type
- ];
- }
- $data = [
- 'row_count' => $count,//总数
- 'page_count' => $pagination->pageCount,//总页数
- 'list' => $new_list,
- ];
- return ['code' => 0, 'msg' => 'success', 'data' => $data];
- }
- }
|