|
|
@@ -4,6 +4,7 @@ namespace ghs\controllers;
|
|
|
|
|
|
use biz\stat\classes\StatKhCgClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
+use bizGhs\stat\classes\StatSaleClass;
|
|
|
use common\components\arrayUtil;
|
|
|
use common\components\dateUtil;
|
|
|
use Yii;
|
|
|
@@ -15,83 +16,13 @@ class StatKhCgController 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'];
|
|
|
- }
|
|
|
- $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']]];
|
|
|
- }
|
|
|
- $list = StatKhCgClass::getAllByCondition($where, null, '*');
|
|
|
- $customIds = [];
|
|
|
- $arr = [];
|
|
|
- if (!empty($list)) {
|
|
|
- foreach ($list as $ke => $item) {
|
|
|
- $customId = $item['customId'] ?? 0;
|
|
|
- $num = $item['num'] ?? 0;
|
|
|
- $refundNum = $item['refundNum'] ?? 0;
|
|
|
- $amount = $item['amount'] ?? 0;
|
|
|
- $refundAmount = $item['refundAmount'] ?? 0;
|
|
|
- $customIds[$customId] = 1;
|
|
|
|
|
|
- if (isset($arr[$customId]['num'])) {
|
|
|
- $arr[$customId]['num'] = bcadd($arr[$customId]['num'], $num, 2);
|
|
|
- } else {
|
|
|
- $arr[$customId]['num'] = $num;
|
|
|
- }
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
|
|
|
- if (isset($arr[$customId]['refundNum'])) {
|
|
|
- $arr[$customId]['refundNum'] = bcadd($arr[$customId]['refundNum'], $refundNum, 2);
|
|
|
- } else {
|
|
|
- $arr[$customId]['refundNum'] = $refundNum;
|
|
|
- }
|
|
|
-
|
|
|
- if (isset($arr[$customId]['amount'])) {
|
|
|
- $arr[$customId]['amount'] = bcadd($arr[$customId]['amount'], $amount, 2);
|
|
|
- } else {
|
|
|
- $arr[$customId]['amount'] = $amount;
|
|
|
- }
|
|
|
-
|
|
|
- if (isset($arr[$customId]['refundAmount'])) {
|
|
|
- $arr[$customId]['refundAmount'] = bcadd($arr[$customId]['refundAmount'], $refundAmount, 2);
|
|
|
- } else {
|
|
|
- $arr[$customId]['refundAmount'] = $refundAmount;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- $customIds = array_keys($customIds);
|
|
|
- $customData = CustomClass::getByIds($customIds);
|
|
|
- $map = CustomClass::$levelMap;
|
|
|
- $cg = [];
|
|
|
- foreach ($customData as $custom) {
|
|
|
- $customId = $custom['id'] ?? 0;
|
|
|
- $customName = $custom['name'] ?? '';
|
|
|
- $customPy = $custom['py'] ?? '';
|
|
|
- $num = $arr[$customId]['num'] ?? 0;
|
|
|
- $refundNum = $arr[$customId]['refundNum'] ?? 0;
|
|
|
- $amount = $arr[$customId]['amount'] ?? 0;
|
|
|
- $refundAmount = $arr[$customId]['refundAmount'] ?? 0;
|
|
|
- $lastAmount = bcsub($amount, $refundAmount, 2);
|
|
|
- $lastNum = bcsub($num, $refundNum, 2);
|
|
|
- $level = $custom['level'] ?? 0;
|
|
|
- $levelName = $map[$level] ?? '';
|
|
|
- $cg[] = [
|
|
|
- 'customId' => $customId,
|
|
|
- 'customName' => $customName,
|
|
|
- 'py' => $customPy,
|
|
|
- 'num' => $lastNum,
|
|
|
- 'amount' => $lastAmount,
|
|
|
- 'levelName' => $levelName,
|
|
|
- ];
|
|
|
- }
|
|
|
- $cg = arrayUtil::arraySort($cg, 'num');
|
|
|
+ $mainId = $this->mainId;
|
|
|
+ $respond = StatSaleClass::statCustomCg($mainId);
|
|
|
+ $cg = arrayUtil::arraySort($respond, 'num');
|
|
|
util::success(['list' => $cg]);
|
|
|
}
|
|
|
|