| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace ghs\controllers;
- use bizGhs\order\classes\NextDayRefundClass;
- use bizGhs\shop\classes\ShopAdminClass;
- use bizGhs\stat\classes\StatKdClass;
- use common\components\dateUtil;
- use common\components\util;
- use Yii;
- class StatKdController extends BaseController
- {
- /**
- * 各渠道收入:ghsApp kdIncome、PC ghs /assets/kdIncome 共用。
- * timeType=bill 按账单日 payTime(默认);=send 按发货 sendTime(仅已付款)。
- */
- public function actionProfile()
- {
- ini_set('memory_limit', '5045M');
- set_time_limit(0);
- //查看财务的权限
- $lookMoney = ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
- if ($lookMoney == 0) {
- util::fail('无法查看');
- }
- //惠雅鲜花员工不能看收入情况
- $shopAdmin = $this->shopAdmin;
- $adminId = $shopAdmin->adminId ?? 0;
- if (in_array($adminId, [2366, 2812, 4004, 3405, 3407])) {
- util::fail('暂无权限');
- }
- $get = Yii::$app->request->get();
- $contain = $get['contain'] ?? 0;
- $return = StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
- $incomeList = $return['incomeList'];
- $staffAmountList = $return['staffAmountList'];
- $payCodeIncome = $return['payCodeIncome'];
- $lsAfterSale = $return['lsAfterSale'];
- $totalIncome = 0;
- if (!empty($incomeList)) {
- foreach ($incomeList as $item) {
- $amount = $item['amount'] ?? 0;
- $totalIncome = bcadd($totalIncome, $amount, 2);
- $totalIncome = floatval($totalIncome);
- }
- }
- util::success(['list' => $incomeList, 'totalIncome' => $totalIncome, 'staffAmountList' => $staffAmountList, 'payCodeIncome' => $payCodeIncome]);
- }
- /**
- * 跨天售后影响:筛售后创建时间,按原单账单日汇总日/月金额。
- * PC /assets/nextDayAffect 使用;只计挂上 xhGhsOrder 的已通过跨天售后。
- */
- public function actionNextDayAffect()
- {
- $lookMoney = ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
- if ($lookMoney == 0) {
- util::fail('无法查看');
- }
- $get = Yii::$app->request->get();
- $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- // 自系统升级以来:跨天售后从 2026-08-18 起算,结束用当前时刻
- if ($searchTime === 'sinceUpgrade') {
- $period = [
- 'startTime' => '2026-08-18 00:00:00',
- 'endTime' => date('Y-m-d H:i:s'),
- ];
- } else {
- // 售后 addTime 用完整时分秒,不能走统计页的 Ymd
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime, false);
- }
- $data = NextDayRefundClass::affectByOrderPayTime(
- $this->mainId,
- $period['startTime'],
- $period['endTime']
- );
- util::success($data);
- }
- }
|