sjId ?? 0; $mainId = $cgInfo->mainId ?? 0; $ghsId = $cgInfo->ghsId ?? 0; $time = $date == null ? date('Ymd') : $date; $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'ghsId' => $ghsId, 'time' => $time], true); if (empty($stat)) { $stat = self::add(['mainId' => $mainId, 'sjId' => $sjId, 'ghsId' => $ghsId, 'time' => $time], true); } $id = $stat->id; $unique = self::getLockById($id); if ($add) { $currentAmount = bcadd($unique->amount, $amount, 2); $unique->amount = $currentAmount; } else { $currentAmount = bcsub($unique->refundAmount, $amount, 2); $unique->refundAmount = $currentAmount; } $unique->num = bcadd($unique->num, $num); $unique->save(); StatCgGhsMonthClass::hdCgGhsReplace($add, $cgInfo, $amount, $num, $time); } //城市批发商采购统计 ssh 2021012 public static function ghsReplace($cgInfo, $date = null) { $sjId = $cgInfo->sjId ?? 0; $mainId = $cgInfo->mainId ?? 0; $ghsId = $cgInfo->ghsId ?? 0; $time = $date == null ? date('Ymd') : $date; $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'ghsId' => $ghsId, 'time' => $time], true); if (empty($stat)) { $stat = self::add(['mainId' => $mainId, 'sjId' => $sjId, 'ghsId' => $ghsId, 'time' => $time], true); } $id = $stat->id; $amount = $cgInfo->price ?? 0; $totalFreight = $cgInfo->totalFreight ?? 0; if ($totalFreight > 0) { $amount = bcadd($totalFreight, $amount, 2); } $unique = self::getLockById($id); $num = $cgInfo->itemNum ?? 0; $currentNum = bcadd($unique->num, $num, 2); $unique->num = $currentNum; $currentAmount = bcadd($unique->amount, $amount, 2); $unique->amount = $currentAmount; $unique->save(); StatCgGhsMonthClass::ghsReplace($cgInfo, $time); } //退款统计 public static function ghsRefundReplace($cgInfo, $date = null) { $sjId = $cgInfo->sjId ?? 0; $shopId = $cgInfo->shopId ?? 0; $ghsId = $cgInfo->ghsId ?? 0; $time = $date == null ? date('Ymd') : $date; $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'ghsId' => $ghsId, 'time' => $time], true); if (empty($stat)) { $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'ghsId' => $ghsId, 'time' => $time], true); } $id = $stat->id; $unique = self::getLockById($id); $num = $cgInfo->itemNum ?? 0; $refundPrice = $cgInfo->refundPrice ?? 0; $currentRefundNum = bcadd($unique->refundNum, $num, 2); $currentRefundAmount = bcadd($unique->refundAmount, $refundPrice, 2); $unique->refundNum = $currentRefundNum; $unique->refundAmount = $currentRefundAmount; $unique->save(); StatCgGhsMonthClass::ghsRefundReplace($cgInfo, $time); } }