|
|
@@ -12,7 +12,7 @@ class StatItemClass extends BaseClass
|
|
|
public static $baseFile = '\biz\stat\models\StatItem';
|
|
|
|
|
|
//每日花材统计 shish 2021012
|
|
|
- public static function replace($item, $date = null)
|
|
|
+ public static function replace($item, $isRefund, $date = null)
|
|
|
{
|
|
|
$sjId = $item->sjId ?? 0;
|
|
|
$shopId = $item->shopId ?? 0;
|
|
|
@@ -25,17 +25,26 @@ class StatItemClass extends BaseClass
|
|
|
$id = $stat->id;
|
|
|
$unique = self::getLockById($id);
|
|
|
|
|
|
- $amount = $item->price ?? 0;
|
|
|
- $num = $item->num ?? 0;
|
|
|
-
|
|
|
- $currentNum = bcadd($unique->num, $num, 2);
|
|
|
- $unique->num = $currentNum;
|
|
|
-
|
|
|
- $currentAmount = bcadd($unique->amount, $amount, 2);
|
|
|
- $unique->amount = $currentAmount;
|
|
|
+ if ($isRefund == 1) {
|
|
|
+ $num = $item->itemNum ?? 0;
|
|
|
+ $unitePrice = $item->itemPrice ?? 0;
|
|
|
+ $price = bcmul($unitePrice, $num, 2);
|
|
|
+
|
|
|
+ $currentRefundNum = bcadd($unique->refundNum, $num, 2);
|
|
|
+ $currentRefundAmount = bcadd($unique->refundAmount, $price, 2);
|
|
|
+ $unique->refundNum = $currentRefundNum;
|
|
|
+ $unique->refundAmount = $currentRefundAmount;
|
|
|
+ } else {
|
|
|
+ $amount = $item->price ?? 0;
|
|
|
+ $num = $item->num ?? 0;
|
|
|
+ $currentNum = bcadd($unique->num, $num, 2);
|
|
|
+ $unique->num = $currentNum;
|
|
|
+ $currentAmount = bcadd($unique->amount, $amount, 2);
|
|
|
+ $unique->amount = $currentAmount;
|
|
|
+ }
|
|
|
|
|
|
$unique->save();
|
|
|
- StatItemMonthClass::replace($item, $time);
|
|
|
+ StatItemMonthClass::replace($item, $isRefund, $time);
|
|
|
}
|
|
|
|
|
|
}
|