| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\client\models\v1;
- use app\models\Cash;
- use yii\base\Model;
- use yii\data\Pagination;
- class CashListForm extends Model
- {
- public $store_id;
- public $user_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],
- [['cash_type'], 'safe'],
- ];
- }
- public function getList()
- {
- if (!$this->validate()) {
- return [
- 'code' => 1,
- 'msg' => $this->getErrorSummary(false)[0],
- ];
- }
- $query = Cash::find()->where([
- 'is_delete'=>0,
- 'store_id'=>$this->store_id,
- 'user_id'=>$this->user_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,4,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)[
- 'type_name' => Cash::getTypeName($value),
- 'price' => number_format(($value->price - ($value->price * ($value->service_charge / 100))), 2),
- 'addtime' => date('Y-m-d H:i:s', $value->created_at),
- 'wx_cash_status'=> $value->wx_cash_status,
- 'wx_cash_error'=> $value->wx_cash_error,
- 'status_no'=> $value->status,
- 'status'=> Cash::$status[$value->status],
- 'id' => $value->id
- ];
- }
- $data = [
- 'row_count' => $count,//总数
- 'page_count' => $pagination->pageCount,//总页数
- 'list' => $new_list,
- ];
- return ['code' => 0, 'msg' => 'success', 'data' => $data];
- }
- }
|