| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace ghs\controllers;
- use biz\stat\classes\StatKdClass;
- use biz\stat\classes\StatRefundClass;
- use common\components\dateUtil;
- use Yii;
- use common\components\util;
- class StatKdController extends BaseController
- {
- //开单收入统计 ssh 20211017
- public function actionProfile()
- {
- $get = Yii::$app->request->get();
- $where = [];
- $where['mainId'] = $this->mainId;
- $searchTime = $get['searchTime'] ?? 'today';
- if (!empty($searchTime)) {
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
- $where['time'] = ['between', [$period['startTime'], $period['endTime']]];
- }
- $kdList = StatKdClass::getAllByCondition($where, null, '*');
- $kd = ['wx' => 0, 'alipay' => 0, 'balance' => 0, 'cash' => 0, 'bank' => 0, 'debt' => 0, 'amount' => 0];
- if (!empty($kdList)) {
- foreach ($kdList as $key => $item) {
- $kd['wx'] = bcadd($kd['wx'], $item['wx']);
- $kd['alipay'] = bcadd($kd['alipay'], $item['alipay']);
- $kd['balance'] = bcadd($kd['balance'], $item['balance']);
- $kd['cash'] = bcadd($kd['cash'], $item['cash']);
- $kd['bank'] = bcadd($kd['bank'], $item['bank']);
- $kd['debt'] = bcadd($kd['debt'], $item['debt']);
- $kd['amount'] = bcadd($kd['amount'], $item['amount']);
- }
- }
- $refund = ['wx' => 0, 'alipay' => 0, 'balance' => 0, 'cash' => 0, 'bank' => 0, 'debt' => 0, 'amount' => 0];
- $refundList = StatRefundClass::getAllByCondition($where, null, '*');
- if (!empty($refundList)) {
- foreach ($refundList as $key => $item) {
- $refund['wx'] = bcadd($refund['wx'], $item['wx']);
- $refund['alipay'] = bcadd($refund['alipay'], $item['alipay']);
- $refund['balance'] = bcadd($refund['balance'], $item['balance']);
- $refund['cash'] = bcadd($refund['cash'], $item['cash']);
- $refund['bank'] = bcadd($refund['bank'], $item['bank']);
- $refund['debt'] = bcadd($refund['debt'], $item['debt']);
- $refund['amount'] = bcadd($refund['amount'], $item['amount']);
- }
- }
- $arr = [
- ['name' => '微信支付', 'kd' => $kd['wx'], 'refund' => $refund['wx']],
- ['name' => '支付宝', 'kd' => $kd['alipay'], 'refund' => $refund['alipay']],
- ['name' => '欠账', 'kd' => $kd['debt'], 'refund' => $refund['debt']],
- ['name' => '余额', 'kd' => $kd['balance'], 'refund' => $refund['balance']],
- ['name' => '现金', 'kd' => $kd['cash'], 'refund' => $refund['cash']],
- ['name' => '银行卡', 'kd' => $kd['bank'], 'refund' => $refund['bank']],
- ['name' => '总计', 'kd' => $kd['amount'], 'refund' => $refund['amount']],
- ];
- $income = floatval(bcsub($kd['amount'], $refund['amount'], 2));
- util::success(['list' => $arr, 'income' => $income]);
- }
- }
|