| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- namespace backend\controllers;
- use biz\stat\services\StatIncomeCategoryService;
- use biz\stat\services\StatIncomeService;
- use biz\stat\services\StatIncomeSourceService;
- use biz\stat\services\StatIncomeUsageService;
- use common\components\dateUtil;
- use common\components\page;
- use common\services\xhMerchantCapitalService;
- use common\components\stringUtil;
- use common\services\xhUserUniteService;
- use common\services\xhUserAssetService;
- use common\services\xhUserAlipayService;
- use common\services\xhOrderService;
- use common\components\configDict;
- use common\components\util;
- use common\services\xhUserService;
- use common\models\xhUser;
- use common\services\xhMerchantService;
- use common\services\xhUserIntegralService;
- use Yii;
- use yii\web\Controller;
- use yii\data\Pagination;
- use common\models\xhMerchantCapital;
- use common\models\xhUserCapital;
- class StatController extends BackendController
- {
-
- /**
- * 商家的资金流水
- */
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $query = xhMerchantCapital::find();
- $query->where(['merchantId' => $this->merchantId, 'io' => 1]);
- if (isset($get['payWay']) && $get['payWay'] != -1) {
- $query->andWhere(['payWay' => $get['payWay']]);
- }
- if (isset($get['date']) && !empty($get['date'])) {
- $arrDate = explode(' - ', $get['date']);
- $startTime = strtotime($arrDate[0]);
- $endTime = strtotime($arrDate[1]);
- $query->andWhere(['>=', 'addTime', $startTime]);
- $query->andWhere(['<', 'addTime', $endTime]);
- }
- $countQuery = clone $query;
- //总计
- $totalAmount = $countQuery->sum('amount');
- $totalCount = $countQuery->count();
- $pages = new Pagination(['totalCount' => $totalCount, 'pageSize' => 50]);
- $models = $query->offset($pages->offset)->limit($pages->limit)->orderBy('addTime desc')->all();
- $payWay = configDict::getConfig('payWayName');
- $capitalTypeList = configDict::getConfig('capitalTypeList');
- return $this->render('list', ['models' => $models, 'pages' => $pages, 'payWay' => $payWay, 'capitalTypeList' => $capitalTypeList, 'totalAmount' => $totalAmount]);
- }
-
- /**
- * 收入统计 shish 2019.9.21
- */
- public function actionIndex()
- {
- $date = dateUtil::getTime(1);
- $start = $date[0];
- $end = $date[1];
- /**变化趋势**/
- $latestIncome = StatIncomeService::getLatestIncome($start, $end);
- $latestIncomeDate = array_column($latestIncome, 'time');
- $latestIncomeAmount = array_column($latestIncome, 'amount');
- /** 来源 **/
- $source = StatIncomeSourceService::getLatestSource($start, $end);
- /** 分类 **/
- $category = StatIncomeCategoryService::getLatestIncome($start, $end);
- /** 用途 **/
- $usage = StatIncomeUsageService::getLatestIncome($start, $end);
- return $this->render('index', [
- 'latestIncomeDate' => json_encode($latestIncomeDate),
- 'latestIncomeAmount' => json_encode($latestIncomeAmount),
- 'source' => $source,
- 'category' => $category,
- 'usage' => $usage,
- ]);
- }
-
- public function actionPer()
- {
- return $this->render('per');
- }
-
- public function actionCustomer()
- {
- return $this->render('customer');
- }
-
- public function actionIncome()
- {
- $where = ['merchantId' => $this->merchantId];
- $return = StatIncomeService::getBackendList('*', $where, 'addTime desc');
- $pages = $return['pages'];
- $list = $return['list'];
- $list = [];
- return $this->render('income', ['list' => $list, 'pages' => $pages, 'list' => $list]);
- }
-
- //对帐 shish 2019.9.8
- public function actionCheckUp()
- {
- $this->errorExportJson();
- $id = Yii::$app->request->get('id');
- StatIncomeService::checkUp($id);
- util::ok();
- }
-
- }
|