更新若干功能
This commit is contained in:
@@ -5,6 +5,8 @@ namespace App\Service\wx;
|
||||
use App\BaseApp\BaseWxService;
|
||||
use App\Models\business\ListItemModel;
|
||||
use App\Models\business\ListModel;
|
||||
use App\Models\business\PriceSheetModel;
|
||||
use App\Service\business\PackageQuoteService;
|
||||
use App\Service\business\PriceService;
|
||||
use App\Service\business\SerialNoService;
|
||||
|
||||
@@ -78,6 +80,7 @@ class WxListService extends BaseWxService
|
||||
$info = ListModel::with([
|
||||
'items' => fn ($query) => $query->where('deleted_at', 0),
|
||||
'items.catalogue',
|
||||
'items.priceSheet',
|
||||
'items.catalogue.priceSheet' => fn ($query) => $query->where('deleted_at', 0),
|
||||
])->where('id', $id)
|
||||
->where('user_id', $this->userId)
|
||||
@@ -93,6 +96,23 @@ class WxListService extends BaseWxService
|
||||
$multiplier = $this->priceMultiplier();
|
||||
foreach ($info['items'] as &$item) {
|
||||
$sheet = $item['catalogue']['price_sheet'] ?? [];
|
||||
$rawRoutine = '';
|
||||
foreach ($sheet as $line) {
|
||||
if ((int) ($line['id'] ?? 0) === (int) ($item['price_sheet_id'] ?? 0)) {
|
||||
$rawRoutine = (string) ($line['routine'] ?? '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($rawRoutine === '') {
|
||||
$rawRoutine = (string) ($item['price_sheet']['routine'] ?? '');
|
||||
}
|
||||
if ((int) ($item['unit_price'] ?? 0) <= 0) {
|
||||
$item['unit_price'] = $price->resolveUnitPrice(
|
||||
$rawRoutine,
|
||||
(string) ($item['material_key'] ?? 'routine'),
|
||||
$multiplier
|
||||
);
|
||||
}
|
||||
if (!empty($sheet)) {
|
||||
$applied = $price->applyToRows($sheet, $showPrice, $multiplier);
|
||||
$item['catalogue']['price_sheet'] = $applied['rows'];
|
||||
@@ -102,6 +122,13 @@ class WxListService extends BaseWxService
|
||||
}
|
||||
unset($item);
|
||||
$info['is_show_price'] = $showPrice;
|
||||
$payable = PackageQuoteService::getInstance()->listPayable(
|
||||
(int) ($info['package_id'] ?? 0),
|
||||
(int) ($info['package_amount'] ?? 0),
|
||||
(int) ($info['original_amount'] ?? 0),
|
||||
$info['items']
|
||||
);
|
||||
$info = array_merge($info, PackageQuoteService::getInstance()->withText($payable, $showPrice));
|
||||
return $info;
|
||||
}
|
||||
|
||||
@@ -210,6 +237,22 @@ class WxListService extends BaseWxService
|
||||
if (array_key_exists('remark', $params)) {
|
||||
$update['remark'] = (string) $params['remark'];
|
||||
}
|
||||
$item = ListItemModel::where('id', $itemId)->whereIn('list_id', $listIds)->first();
|
||||
if (empty($item)) {
|
||||
$this->utils->errorThrow('明细不存在');
|
||||
}
|
||||
$sheetId = (int) ($update['price_sheet_id'] ?? $item['price_sheet_id']);
|
||||
$material = (string) ($update['material_key'] ?? $item['material_key'] ?? 'routine');
|
||||
if ($sheetId > 0) {
|
||||
$sheet = PriceSheetModel::where('id', $sheetId)->where('deleted_at', 0)->first();
|
||||
if (!empty($sheet)) {
|
||||
$update['unit_price'] = PriceService::getInstance()->resolveUnitPrice(
|
||||
(string) ($sheet['routine'] ?? ''),
|
||||
$material,
|
||||
$this->priceMultiplier()
|
||||
);
|
||||
}
|
||||
}
|
||||
return ListItemModel::where('id', $itemId)->whereIn('list_id', $listIds)->update($update);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user