sjId; $mainId = $main->id ?? 0; $time = date('Ymd'); $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'time' => $time], true); if (empty($stat)) { $stat = self::add(['sjId' => $sjId, 'time' => $time, 'mainId' => $mainId], true); } $id = $stat->id; $unique = self::getLockById($id); if (empty($unique)) { util::fail('没有记录'); } $currentAmount = bcadd($unique->amount, $amount, 2); $unique->amount = $currentAmount; $unique->totalAmount = $main->totalStockOut; $unique->save(); //当月 StatStockOutMonthClass::replace($main, $shop, $amount); } //今天出库金额 ssh 20210526 public static function getTodayAmount($shop) { if (empty($shop)) { return 0; } $today = date("Ymd"); $shopId = $shop->id; $sjId = $shop->sjId; $out = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $today], true); return $out->amount ?? 0; } }