|
|
@@ -221,24 +221,32 @@ class StatSaleClass extends BaseClass
|
|
|
foreach ($cgList as $cgKey => $cgItem) {
|
|
|
$actPrice = $cgItem['actPrice'] ?? 0;
|
|
|
$paidPrice = $cgItem['paidPrice'] ?? 0;
|
|
|
- $total = bcadd($actPrice, $paidPrice, 2);
|
|
|
- //物流费用不算成本
|
|
|
- if (isset($cgItem['isCost']) && $cgItem['isCost'] == 0) {
|
|
|
- $shortCharge = $cgItem['shortCharge'] ?? 0;
|
|
|
- $longCharge = $cgItem['longCharge'] ?? 0;
|
|
|
- $pickCharge = $cgItem['pickCharge'] ?? 0;
|
|
|
- $localCharge = $cgItem['localCharge'] ?? 0;
|
|
|
- $a1 = bcadd($shortCharge, $longCharge, 2);
|
|
|
- $a2 = bcadd($pickCharge, $localCharge, 2);
|
|
|
- $a = bcadd($a1, $a2, 2);
|
|
|
- $total = bcsub($total, $a, 2);
|
|
|
+ if ($actPrice <= 0) {
|
|
|
+ // 如果$actPrice=0,表示这个采购单已经全部退款,不需要再统计成本,本来$paidPrice要同步清零,但没有,这个问题由徐州邂逅花坊马总,提出的需求发现
|
|
|
+ $cg = bcadd($cg, 0, 2);
|
|
|
+ } else {
|
|
|
+ $total = bcadd($actPrice, $paidPrice, 2);
|
|
|
+ //物流费用不算成本。意思是说,长短途运费+提货费+本地运费,这四项和打包费一起,参与到平摊花材运费成本的计算,但那四项不参与总的采购成本登记,因为,有另外地方会独立登记运费成本。
|
|
|
+ //$paidPrice 字段说明,此字段表示收货方已付款金额,包括 $localCharge本地运费、 $pickCharge提货费、 $shortCharge短途运费(到付时算,如果不是到付,不算在$paidPrice里)、$longCharge长途运费(到付时算,如果不是到付,不算在$paidPrice里)
|
|
|
+ //请搜索关键词 cg_item_cost ,有多处相似情况要考虑
|
|
|
+ if (isset($cgItem['isCost']) && $cgItem['isCost'] == 0) {
|
|
|
+ $shortCharge = $cgItem['shortCharge'] ?? 0;
|
|
|
+ $longCharge = $cgItem['longCharge'] ?? 0;
|
|
|
+ $pickCharge = $cgItem['pickCharge'] ?? 0;
|
|
|
+ $localCharge = $cgItem['localCharge'] ?? 0;
|
|
|
+ $a1 = bcadd($shortCharge, $longCharge, 2);
|
|
|
+ $a2 = bcadd($pickCharge, $localCharge, 2);
|
|
|
+ $a = bcadd($a1, $a2, 2);
|
|
|
+ //注意下面是减号 bcsub
|
|
|
+ $total = bcsub($total, $a, 2);
|
|
|
+ }
|
|
|
+ $cg = bcadd($cg, $total, 2);
|
|
|
}
|
|
|
- $cg = bcadd($cg, $total, 2);
|
|
|
}
|
|
|
}
|
|
|
$cg = floatval($cg);
|
|
|
|
|
|
- $lsCgWhere = ['mainId' => $mainId, 'status' => 4,'belongCost'=>1];
|
|
|
+ $lsCgWhere = ['mainId' => $mainId, 'status' => 4, 'belongCost' => 1];
|
|
|
$lsCgWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
$lsCgList = PurchaseClass::getAllByCondition($lsCgWhere, null, '*');
|
|
|
$lsCgAmount = 0;
|