更新若干功能
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Service\business;
|
||||
|
||||
use App\Models\business\ListItemModel;
|
||||
use App\Models\business\ListModel;
|
||||
use App\Service\business\PackageQuoteService;
|
||||
use App\Models\business\OrderDeliveryModel;
|
||||
use App\Models\business\OrderItemModel;
|
||||
use App\Models\business\OrderModel;
|
||||
@@ -118,6 +119,16 @@ class OrderCoreService
|
||||
if (empty($rows)) {
|
||||
UtilsService::getInstance()->errorThrow('清单里没有可下单的商品');
|
||||
}
|
||||
// 套餐清单:总额用套餐价 + 变更差价,明细行仍按当前规格单价快照
|
||||
if ((int) ($list['package_id'] ?? 0) > 0) {
|
||||
$payable = PackageQuoteService::getInstance()->listPayable(
|
||||
(int) $list['package_id'],
|
||||
(int) ($list['package_amount'] ?? 0),
|
||||
(int) ($list['original_amount'] ?? 0),
|
||||
$rows
|
||||
);
|
||||
$total = (int) $payable['payable_amount'];
|
||||
}
|
||||
|
||||
$orderId = 0;
|
||||
DB::connection('business')->transaction(function () use (&$orderId, $list, $userId, $user, $params, $rows, $total) {
|
||||
@@ -163,6 +174,20 @@ class OrderCoreService
|
||||
UtilsService::getInstance()->errorThrow('订单不存在');
|
||||
}
|
||||
$order = $order->toArray();
|
||||
$sourceList = ListModel::where('id', (int) ($order['list_id'] ?? 0))->first();
|
||||
if (!empty($sourceList) && (int) ($sourceList['package_id'] ?? 0) > 0) {
|
||||
$quote = PackageQuoteService::getInstance();
|
||||
$order['package_id'] = (int) $sourceList['package_id'];
|
||||
$order['package_amount'] = (int) $sourceList['package_amount'];
|
||||
$order['original_amount'] = (int) $sourceList['original_amount'];
|
||||
$order['diff_amount'] = (int) $order['total_amount'] - (int) $sourceList['package_amount'];
|
||||
$order = array_merge($order, $quote->withText([
|
||||
'package_amount' => $order['package_amount'],
|
||||
'original_amount' => $order['original_amount'],
|
||||
'diff_amount' => $order['diff_amount'],
|
||||
'payable_amount' => (int) $order['total_amount'],
|
||||
]));
|
||||
}
|
||||
$order['voucher_list'] = [];
|
||||
foreach ($order['payments'] ?? [] as $payment) {
|
||||
foreach (array_filter(explode(',', (string) $payment['voucher'])) as $image) {
|
||||
|
||||
Reference in New Issue
Block a user