|
|
@@ -9,6 +9,7 @@ use bizGhs\custom\classes\CustomDebtChangeClass;
|
|
|
use bizGhs\express\classes\GhsDeliveryOrderClass;
|
|
|
use bizGhs\express\services\DadaExpressServices;
|
|
|
use bizGhs\ghs\classes\GhsClass;
|
|
|
+use bizGhs\order\classes\NextDayRefundClass;
|
|
|
use bizGhs\order\classes\OrderItemClass;
|
|
|
use bizGhs\order\classes\RefundOrderClass;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
@@ -2973,7 +2974,10 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //应收款统计 ssh 20240528
|
|
|
+ /**
|
|
|
+ * 应收统计:按支付日汇总。
|
|
|
+ * originAmount=未扣隔天;nextDayAmount=隔天售后;amount=已扣隔天(净额)。
|
|
|
+ */
|
|
|
public function actionAccountList()
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
|
@@ -3000,7 +3004,9 @@ class OrderController extends BaseController
|
|
|
$where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
$orderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
$list = [];
|
|
|
+ $totalOriginAmount = 0;
|
|
|
$totalAmount = 0;
|
|
|
+ $nextDayDeduct = '0.00';
|
|
|
if (!empty($orderList)) {
|
|
|
foreach ($orderList as $orderInfo) {
|
|
|
$actPrice = $orderInfo['actPrice'] ?? 0;
|
|
|
@@ -3014,16 +3020,54 @@ class OrderController extends BaseController
|
|
|
continue;
|
|
|
}
|
|
|
if (isset($list[$customId])) {
|
|
|
+ $list[$customId]['originAmount'] = bcadd($list[$customId]['originAmount'], $actPrice, 2);
|
|
|
$list[$customId]['amount'] = bcadd($list[$customId]['amount'], $actPrice, 2);
|
|
|
$list[$customId]['num'] = bcadd($list[$customId]['num'], 1);
|
|
|
} else {
|
|
|
$name = $customList[$customId] && $customList[$customId]['name'] ? $customList[$customId]['name'] : '未命名';
|
|
|
- $list[$customId] = ['id' => $customId, 'name' => $name, 'amount' => $actPrice, 'num' => 1];
|
|
|
+ $list[$customId] = [
|
|
|
+ 'id' => $customId,
|
|
|
+ 'name' => $name,
|
|
|
+ 'originAmount' => $actPrice,
|
|
|
+ 'amount' => $actPrice,
|
|
|
+ 'num' => 1,
|
|
|
+ 'nextDayAmount' => '0.00',
|
|
|
+ ];
|
|
|
}
|
|
|
+ $totalOriginAmount = bcadd($totalOriginAmount, $actPrice, 2);
|
|
|
$totalAmount = bcadd($totalAmount, $actPrice, 2);
|
|
|
}
|
|
|
- $list = array_values($list);
|
|
|
}
|
|
|
+
|
|
|
+ // 隔天售后:只扣 amount,originAmount 保持未扣口径
|
|
|
+ $fwdMap = NextDayRefundClass::sumAmountGroupByCustom($mainId, $currentStartTime, $currentEndTime);
|
|
|
+ foreach ($fwdMap as $cid => $amt) {
|
|
|
+ if (bccomp((string)$amt, '0', 2) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!isset($list[$cid])) {
|
|
|
+ $list[$cid] = [
|
|
|
+ 'id' => $cid,
|
|
|
+ 'name' => $customList[$cid]['name'] ?? '未命名',
|
|
|
+ 'originAmount' => '0.00',
|
|
|
+ 'amount' => '0.00',
|
|
|
+ 'num' => 0,
|
|
|
+ 'nextDayAmount' => '0.00',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ if (!isset($list[$cid]['originAmount'])) {
|
|
|
+ $list[$cid]['originAmount'] = (string)($list[$cid]['amount'] ?? '0');
|
|
|
+ }
|
|
|
+ if (!isset($list[$cid]['nextDayAmount'])) {
|
|
|
+ $list[$cid]['nextDayAmount'] = '0.00';
|
|
|
+ }
|
|
|
+ $list[$cid]['amount'] = bcsub((string)$list[$cid]['amount'], (string)$amt, 2);
|
|
|
+ $list[$cid]['nextDayAmount'] = bcadd((string)$list[$cid]['nextDayAmount'], (string)$amt, 2);
|
|
|
+ $totalAmount = bcsub((string)$totalAmount, (string)$amt, 2);
|
|
|
+ $nextDayDeduct = bcadd($nextDayDeduct, (string)$amt, 2);
|
|
|
+ }
|
|
|
+ $list = array_values($list);
|
|
|
+
|
|
|
if ($export == 1) {
|
|
|
if (empty($list)) {
|
|
|
util::fail('没有数据需要导出');
|
|
|
@@ -3033,7 +3077,12 @@ class OrderController extends BaseController
|
|
|
OrderClass::exportAccountList($list, $mainId);
|
|
|
util::stop();
|
|
|
}
|
|
|
- util::success(['list' => $list, 'totalAmount' => $totalAmount]);
|
|
|
+ util::success([
|
|
|
+ 'list' => $list,
|
|
|
+ 'totalOriginAmount' => $totalOriginAmount,
|
|
|
+ 'totalAmount' => $totalAmount,
|
|
|
+ 'nextDayDeduct' => floatval($nextDayDeduct),
|
|
|
+ ]);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -3075,7 +3124,10 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
- //客户业绩,有多个地方,需要同步,搜索关键词 customYj ssh 20240628
|
|
|
+ /**
|
|
|
+ * 客户业绩(PC):按支付日汇总开单;隔天售后按通过日扣实际金额并计入退款。
|
|
|
+ * 与小程序 statCustomCg 同步,搜索关键词 customYj。
|
|
|
+ */
|
|
|
public function actionYj()
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
|
@@ -3237,6 +3289,7 @@ class OrderController extends BaseController
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
+ // 有开单时补全无单客户行,便于与隔天负金额行一并展示
|
|
|
foreach ($customList as $key => $custom) {
|
|
|
$customId = $custom['id'] ?? 0;
|
|
|
if (isset($list[$customId]) == false) {
|
|
|
@@ -3247,6 +3300,7 @@ class OrderController extends BaseController
|
|
|
'actPrice' => 0,
|
|
|
'num' => 0,
|
|
|
'carton' => 0,
|
|
|
+ 'cartonNum' => 0,
|
|
|
'pack' => 0,
|
|
|
'freight' => 0,
|
|
|
'tkPrice' => 0,
|
|
|
@@ -3254,8 +3308,45 @@ class OrderController extends BaseController
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
- $list = array_values($list);
|
|
|
}
|
|
|
+
|
|
|
+ // 隔天售后:按通过日扣实际金额、计入退款;无当日开单也建负行;订单笔数不减
|
|
|
+ $fwdMap = NextDayRefundClass::sumAmountGroupByCustom($mainId, $currentStartTime, $currentEndTime);
|
|
|
+ $nextDayDeduct = '0.00';
|
|
|
+ foreach ($fwdMap as $cid => $amt) {
|
|
|
+ if (bccomp((string)$amt, '0', 2) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!isset($list[$cid])) {
|
|
|
+ $list[$cid] = [
|
|
|
+ 'id' => $cid,
|
|
|
+ 'name' => $customList[$cid]['name'] ?? '未命名',
|
|
|
+ 'mobile' => $customList[$cid]['mobile'] ?? '0',
|
|
|
+ 'actPrice' => 0,
|
|
|
+ 'num' => 0,
|
|
|
+ 'carton' => 0,
|
|
|
+ 'cartonNum' => 0,
|
|
|
+ 'pack' => 0,
|
|
|
+ 'freight' => 0,
|
|
|
+ 'tkPrice' => 0,
|
|
|
+ 'orderPrice' => 0,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $list[$cid]['actPrice'] = bcsub((string)$list[$cid]['actPrice'], (string)$amt, 2);
|
|
|
+ // 退款列含隔天通过金额,便于与实际金额对照
|
|
|
+ $list[$cid]['tkPrice'] = bcadd((string)$list[$cid]['tkPrice'], (string)$amt, 2);
|
|
|
+ $totalActPrice = bcsub((string)$totalActPrice, (string)$amt, 2);
|
|
|
+ $totalTkPrice = bcadd((string)$totalTkPrice, (string)$amt, 2);
|
|
|
+ $nextDayDeduct = bcadd($nextDayDeduct, (string)$amt, 2);
|
|
|
+ }
|
|
|
+ // 隔天仅退款并入「仅退款」合计(当天仅退款已在开单循环统计)
|
|
|
+ $totalOnlyTkPrice = bcadd(
|
|
|
+ (string)$totalOnlyTkPrice,
|
|
|
+ NextDayRefundClass::sumMoneyOnlyAmountByMainAndTime($mainId, $currentStartTime, $currentEndTime),
|
|
|
+ 2
|
|
|
+ );
|
|
|
+
|
|
|
+ $list = array_values($list);
|
|
|
if ($export == 1) {
|
|
|
if (empty($list)) {
|
|
|
util::fail('没有数据需要导出');
|
|
|
@@ -3277,6 +3368,7 @@ class OrderController extends BaseController
|
|
|
'totalTkPrice' => $totalTkPrice,
|
|
|
//增加项
|
|
|
'totalOnlyTkPrice' => $totalOnlyTkPrice,
|
|
|
+ 'nextDayDeduct' => floatval($nextDayDeduct),
|
|
|
]);
|
|
|
}
|
|
|
|