Merge pull request 'fix: 订单费用pdf部分失效' (#438) from fix_record_fee_print into @hera/dev
Reviewed-on: daoyoucloud/tachycode#438 Reviewed-by: sealday <zhanglin@daoyoucloud.com>
This commit is contained in:
commit
9f16f5acea
@ -118,15 +118,6 @@ export class RecordPdfService {
|
|||||||
.sort((a, b) => a.category_id - b.category_id);
|
.sort((a, b) => a.category_id - b.category_id);
|
||||||
|
|
||||||
// 计算费用数据,包括有产品关联跟无产品关联
|
// 计算费用数据,包括有产品关联跟无产品关联
|
||||||
fee_data = fee_data.map((item) => {
|
|
||||||
const data = {
|
|
||||||
...item,
|
|
||||||
};
|
|
||||||
if (item.weight_rules) {
|
|
||||||
data['weight_rules'] = JSON.parse(item.weight_rules.join(','));
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
// 关联产品的赔偿(人工录入/全部)
|
// 关联产品的赔偿(人工录入/全部)
|
||||||
const product_fee =
|
const product_fee =
|
||||||
printSetup === PrintSetup.Manual
|
printSetup === PrintSetup.Manual
|
||||||
@ -167,10 +158,10 @@ export class RecordPdfService {
|
|||||||
} else if (item.conversion_logic_id === ConversionLogics.ActualWeight) {
|
} else if (item.conversion_logic_id === ConversionLogics.ActualWeight) {
|
||||||
data['total'] = item.actual_weight || item.record_weight;
|
data['total'] = item.actual_weight || item.record_weight;
|
||||||
} else {
|
} else {
|
||||||
if (item.wr.conversion_logic_id === ConversionLogics.Keep) {
|
if (item.weight_rules?.conversion_logic_id === ConversionLogics.Keep) {
|
||||||
data['total'] = data.count * item.wr.weight;
|
data['total'] = data.count * item.weight_rules.weight;
|
||||||
} else if (item.wr.conversion_logic_id === ConversionLogics.Product) {
|
} else if (item.weight_rules?.conversion_logic_id === ConversionLogics.Product) {
|
||||||
data['total'] = data.count * item.wr.weight * item.product_ratio;
|
data['total'] = data.count * item.weight_rules.weight * item.product_ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果 printSetup === PrintSetup.DisplayAndPrice 要计算费用产生的价格
|
// 如果 printSetup === PrintSetup.DisplayAndPrice 要计算费用产生的价格
|
||||||
@ -220,7 +211,7 @@ export class RecordPdfService {
|
|||||||
// 计算有误,需要检查
|
// 计算有误,需要检查
|
||||||
data['count'] = lease_data.reduce((a, b) => {
|
data['count'] = lease_data.reduce((a, b) => {
|
||||||
const weight_rule = item.weight_rules.find(
|
const weight_rule = item.weight_rules.find(
|
||||||
(l) => l.product_id === b.product_id || l.product === b.category_id + RulesNumber,
|
(l) => l.product_id === b.product_id || l.product - RulesNumber === b.category_id,
|
||||||
);
|
);
|
||||||
if (weight_rule && weight_rule.conversion_logic_id === ConversionLogics.Keep) {
|
if (weight_rule && weight_rule.conversion_logic_id === ConversionLogics.Keep) {
|
||||||
return a + b.count * weight_rule.weight;
|
return a + b.count * weight_rule.weight;
|
||||||
|
@ -18,7 +18,14 @@ SELECT
|
|||||||
cpfi.count_source,
|
cpfi.count_source,
|
||||||
cpfi."comment",
|
cpfi."comment",
|
||||||
cpfi.id,
|
cpfi.id,
|
||||||
STRING_TO_ARRAY(JSONB_AGG(wr)::TEXT, ',') AS weight_rules
|
(
|
||||||
|
SELECT
|
||||||
|
JSONB_AGG(wr)
|
||||||
|
FROM
|
||||||
|
weight_rules wr
|
||||||
|
WHERE
|
||||||
|
wr.logic_id = cpfi.conversion_logic_id
|
||||||
|
) AS weight_rules
|
||||||
FROM
|
FROM
|
||||||
records r
|
records r
|
||||||
LEFT JOIN contracts c ON r.contract_id = c.id
|
LEFT JOIN contracts c ON r.contract_id = c.id
|
||||||
@ -31,7 +38,6 @@ FROM
|
|||||||
LEFT JOIN product_category pc3 ON p.category_id = pc3.id
|
LEFT JOIN product_category pc3 ON p.category_id = pc3.id
|
||||||
JOIN product_category pc ON pc.id = p.category_id
|
JOIN product_category pc ON pc.id = p.category_id
|
||||||
JOIN unit_conversion_logics ucl ON ucl.id = cpfi.conversion_logic_id
|
JOIN unit_conversion_logics ucl ON ucl.id = cpfi.conversion_logic_id
|
||||||
LEFT JOIN weight_rules wr ON ucl.id = wr.logic_id
|
|
||||||
WHERE
|
WHERE
|
||||||
r.id = :recordId
|
r.id = :recordId
|
||||||
GROUP BY
|
GROUP BY
|
||||||
@ -59,7 +65,18 @@ SELECT
|
|||||||
cpfi2.count_source,
|
cpfi2.count_source,
|
||||||
cpfi2."comment",
|
cpfi2."comment",
|
||||||
cpfi2.id,
|
cpfi2.id,
|
||||||
STRING_TO_ARRAY(wr2::TEXT, ',') AS weight_rules
|
(
|
||||||
|
SELECT
|
||||||
|
TO_JSONB(wr)
|
||||||
|
FROM
|
||||||
|
weight_rules wr
|
||||||
|
WHERE
|
||||||
|
ucl2.id > 4
|
||||||
|
AND wr.logic_id = ucl2.id
|
||||||
|
AND wr.product_id = ri.product_id
|
||||||
|
LIMIT
|
||||||
|
1
|
||||||
|
) AS weight_rules
|
||||||
FROM
|
FROM
|
||||||
records r2
|
records r2
|
||||||
LEFT JOIN contracts c2 ON r2.contract_id = c2.id
|
LEFT JOIN contracts c2 ON r2.contract_id = c2.id
|
||||||
@ -72,9 +89,6 @@ FROM
|
|||||||
JOIN contract_plan_fee_items cpfi2 ON cpfi2.lease_item_id = cpli.id
|
JOIN contract_plan_fee_items cpfi2 ON cpfi2.lease_item_id = cpli.id
|
||||||
AND cpfi2.count_source = '0' -- 查费用
|
AND cpfi2.count_source = '0' -- 查费用
|
||||||
JOIN unit_conversion_logics ucl2 ON ucl2.id = cpfi2.conversion_logic_id -- 查计算规则
|
JOIN unit_conversion_logics ucl2 ON ucl2.id = cpfi2.conversion_logic_id -- 查计算规则
|
||||||
LEFT JOIN weight_rules wr2 ON ucl2.id = wr2.logic_id -- 查重量规则
|
|
||||||
AND ucl2.id > 4
|
|
||||||
AND wr2.product_id = cplip.product_id
|
|
||||||
JOIN record_items ri ON ri.record_id = r2.id
|
JOIN record_items ri ON ri.record_id = r2.id
|
||||||
AND (
|
AND (
|
||||||
ri.product_id = cplip.product_id
|
ri.product_id = cplip.product_id
|
||||||
|
Loading…
Reference in New Issue
Block a user