| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace hd\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['shopId'] = $this->shopId;
- if (isset($get['shopId']) && !empty($get['shopId'])) {
- $where['shopId'] = $get['shopId'];
- }
- //惠雅鲜花员工不能看利润表
- $shopAdmin = $this->shopAdmin;
- $adminId = $shopAdmin->adminId ?? 0;
- if (in_array($adminId, [3405, 2812, 4004,2812])) {
- util::fail('暂无权限');
- }
- $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]);
- }
- }
|