默认重量

This commit is contained in:
liu
2026-09-05 14:37:22 +08:00
parent 364471a086
commit 12cbed411b
10 changed files with 205 additions and 8 deletions
@@ -22,6 +22,7 @@ use App\Services\BillGenerateService;
use App\Services\ItemImageResolver;
use App\Services\PurchaseGenerateService;
use App\Services\PurchaseItemService;
use App\Services\WeightEstimator;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -481,7 +482,10 @@ class PurchaseOrderController extends BaseController
'content' => (string) $product->content,
'shelf_life' => (int) $product->shelf_life,
'quantity' => $quantity,
'weight' => bcadd((string) ($validated['weight'] ?? 0), '0', 3),
// 未传称重时按订货量 × 规格预填参考重量
'weight' => isset($validated['weight'])
? bcadd((string) $validated['weight'], '0', 3)
: WeightEstimator::estimate((string) $product->spec, (string) $product->unit, (string) $quantity),
'amount' => bcmul($price, (string) $quantity, 2),
'cost_price' => (string) $product->cost_price,
'remark' => '',