修改计费逻辑仅 billing_fail_status = 0 才写 prc_income_bill

This commit is contained in:
wuweihua
2026-11-11 09:49:59 +08:00
parent a211f06663
commit a58de9bb7e
11 changed files with 38 additions and 15 deletions
@@ -122,7 +122,7 @@ public class PrcOrderBill extends BaseEntity
private String creditArrearsStatus;
/** NONE / REFUNDED */
private String refundStatus;
/** Billing fail: 0 ok; 1/2/3 sales miss; 23/24/25 catalog miss; soft-fail amount=0, no fee rows */
/** Billing fail: 0 ok writes income bill+fee; non-0 amount=0, no income bill/fee */
private Integer billingFailStatus;
/** 失败原因 */
private String errorMessage;
@@ -103,7 +103,7 @@ public class TmsPriceQuoteResult implements Serializable
private String creditArrearsStatus;
/** NONE / REFUNDED */
private String refundStatus;
/** Billing fail: 0 ok; 1/2/3 sales; 23/24/25 catalog (soft-fail on bill sync) */
/** Billing fail: 0 ok (income bill+fee); 1/2/3 sales; 23/24/25 catalog */
private Integer billingFailStatus;
private Integer pieces;
private BigDecimal actualWeight;
@@ -6,7 +6,8 @@ package com.bms.price.enums;
* 1/2/3 sales-price (package) miss: product / country / weight;
* 23/24/25 product-catalog price miss: product / country / weight;
* 4+ map to prc_billing_task.fail_code.
* Soft-fail income bill: 0/1/2/3/23/24/25; fee rows only for 0.
* 26 not billed yet (order-source sync only).
* Income bill + fee rows: only status 0.
*/
public enum BillBillingFailStatus
{
@@ -38,7 +39,9 @@ public enum BillBillingFailStatus
/** Product catalog miss: product hit but country/zone miss. */
CATALOG_COUNTRY(24),
/** Product catalog miss: product+country hit but weight band miss. */
CATALOG_WEIGHT(25);
CATALOG_WEIGHT(25),
/** Order landed from upstream but not billed yet. */
NOT_BILLED(26);
private final int code;
@@ -70,16 +73,23 @@ public enum BillBillingFailStatus
public static boolean isFail(Integer code)
{
return code != null && code.intValue() > SUCCESS.code;
if (code == null)
{
return false;
}
int value = code.intValue();
return value != SUCCESS.code && value != NOT_BILLED.code;
}
/** Soft-fail sales/catalog misses also persist prc_income_bill. */
public static boolean isNotBilled(Integer code)
{
return code != null && code.intValue() == NOT_BILLED.code;
}
/** Only success (0) persists prc_income_bill. */
public static boolean storesIncomeBill(Integer code)
{
int value = code == null ? SUCCESS.code : code.intValue();
return value == SUCCESS.code
|| value == PRODUCT.code || value == COUNTRY.code || value == WEIGHT.code
|| value == CATALOG_PRODUCT.code || value == CATALOG_COUNTRY.code || value == CATALOG_WEIGHT.code;
return code == null || code.intValue() == SUCCESS.code;
}
/** 仅 0 落 prc_income_bill_fee。 */
@@ -96,7 +106,7 @@ public enum BillBillingFailStatus
}
for (BillBillingFailStatus status : values())
{
if (status == SUCCESS)
if (status == SUCCESS || status == NOT_BILLED)
{
continue;
}
@@ -113,6 +123,7 @@ public enum BillBillingFailStatus
switch (this)
{
case SUCCESS:
case NOT_BILLED:
return null;
case PRODUCT:
return BillTaskFailCode.PRODUCT_NOT_HIT.getCode();
@@ -3089,7 +3089,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
bill.setBillId(UUID.randomUUID().toString());
bill.setArBillStatus(ArOrderBillStatus.UNBILLED.getCode());
bill.setRefundStatus(BillRefundStatus.NONE.getCode());
bill.setBillingFailStatus(Integer.valueOf(BillBillingFailStatus.SUCCESS.getCode()));
// Order-source sync only: mark not billed until quote/bill runs.
bill.setBillingFailStatus(Integer.valueOf(BillBillingFailStatus.NOT_BILLED.getCode()));
bill.setFreightRate(BigDecimal.ZERO);
bill.setBaseFreightRate(BigDecimal.ZERO);
bill.setRegistrationFee(BigDecimal.ZERO);
@@ -265,6 +265,7 @@ public final class OrderBillExportSupport
case 20: return "客户已停用";
case 21: return "运费为空";
case 22: return "未知失败";
case 26: return "未计费";
default: return String.valueOf(status);
}
}
@@ -1748,6 +1748,7 @@ public class ArBillServiceImpl implements IArBillService {
}
return switch (status) {
case SUCCESS -> "";
case NOT_BILLED -> "未计费";
case PRODUCT -> "销售价未匹配产品";
case COUNTRY -> "销售价未匹配国家";
case WEIGHT -> "销售价未匹配重量段";
@@ -0,0 +1,3 @@
-- prc_order_bill.billing_fail_status: add 26 NOT_BILLED
ALTER TABLE prc_order_bill
MODIFY COLUMN billing_fail_status tinyint NOT NULL DEFAULT 0 COMMENT '计费失败状态:0成功/1销售价未匹配产品/2销售价未匹配国家/3销售价未匹配重量段/23产品价未匹配产品/24产品价未匹配国家/25产品价未匹配重量段/4未绑定套餐/5无生效套餐版本/6已生成应收账单/7产品档案缺失/8未命中价格/9分区无价格/10邮编必填/11邮编未匹配分区/12上游订单不存在/13上游订单号为空/14上游客户为空/15上游产品为空/16上游重量无效/17计费时间为空/18退费订单无法解析/19客户代码为空/20客户已停用/21运费为空/22未知失败/26未计费。仅0写入应收主表,仅0写入应收费用';
@@ -1098,6 +1098,7 @@ function billingFailLabel(status) {
function billingFailTagType(status) {
const code = status == null ? 0 : Number(status)
if (code === 26) return 'info'
if (code > 0) return 'danger'
return 'success'
}
@@ -254,7 +254,8 @@ function billingFailStatusLabel(code) {
3: '销售价未匹配重量段',
23: '产品价未匹配产品',
24: '产品价未匹配国家',
25: '产品价未匹配重量段'
25: '产品价未匹配重量段',
26: '未计费'
}
const key = Number(code)
return map[key] != null ? map[key] : String(code)
@@ -405,7 +405,8 @@ const billingFailStatusOptions = [
{ label: '客户代码为空', value: 19 },
{ label: '客户已停用', value: 20 },
{ label: '运费为空', value: 21 },
{ label: '未知失败', value: 22 }
{ label: '未知失败', value: 22 },
{ label: '未计费', value: 26 }
]
function billingFailLabel(status) {
@@ -416,6 +417,7 @@ function billingFailLabel(status) {
function billingFailTagType(status) {
const code = status == null ? 0 : Number(status)
if (code === 26) return 'info'
if (code > 0) return 'danger'
return 'success'
}
@@ -494,7 +494,8 @@ const billingFailStatusOptions = [
{ label: '客户代码为空', value: 19 },
{ label: '客户已停用', value: 20 },
{ label: '运费为空', value: 21 },
{ label: '未知失败', value: 22 }
{ label: '未知失败', value: 22 },
{ label: '未计费', value: 26 }
]
const orderStatusAllValues = computed(() => orderStatusOptions.map(o => o.value))
@@ -1003,6 +1004,7 @@ function billingFailLabel(status) {
function billingFailTagType(status) {
const code = status == null ? 0 : Number(status)
if (code === 26) return 'info'
return code > 0 ? 'danger' : 'success'
}