|
|
@@ -12,7 +12,7 @@ class StatItemClass extends BaseClass
|
|
|
public static $baseFile = '\biz\stat\models\StatItem';
|
|
|
|
|
|
//每日花材统计 shish 2021012
|
|
|
- public static function replace($item, $isRefund, $date = null)
|
|
|
+ public static function replace($item, $date = null)
|
|
|
{
|
|
|
$sjId = $item->sjId ?? 0;
|
|
|
$shopId = $item->shopId ?? 0;
|
|
|
@@ -25,26 +25,44 @@ class StatItemClass extends BaseClass
|
|
|
$id = $stat->id;
|
|
|
$unique = self::getLockById($id);
|
|
|
|
|
|
- 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;
|
|
|
+
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+
|
|
|
+ //退款花材
|
|
|
+ public static function refundReplace($item, $date = null)
|
|
|
+ {
|
|
|
+ $sjId = $item['sjId'] ?? 0;
|
|
|
+ $shopId = $item['shopId'] ?? 0;
|
|
|
+ $productId = $item['productId'] ?? 0;
|
|
|
+ $time = $date == null ? date('Ymd') : $date;
|
|
|
+ $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'itemId' => $productId, 'time' => $time], true);
|
|
|
+ if (empty($stat)) {
|
|
|
+ $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'itemId' => $productId, 'time' => $time], true);
|
|
|
}
|
|
|
+ $id = $stat->id;
|
|
|
+ $unique = self::getLockById($id);
|
|
|
+
|
|
|
+ $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;
|
|
|
$unique->save();
|
|
|
- StatItemMonthClass::replace($item, $isRefund, $time);
|
|
|
+
|
|
|
+ StatItemMonthClass::refundReplace($item, $time);
|
|
|
}
|
|
|
|
|
|
}
|