4 Commits

7 changed files with 70 additions and 24 deletions
@@ -28,4 +28,6 @@ public class LocalRebillRequest implements Serializable
private String creditArrearsStatus;
private String beginBizDate;
private String endBizDate;
private String beginPickupDate;
private String endPickupDate;
}
@@ -3,11 +3,14 @@ package com.bms.price.enums;
/**
* Snapshot of prc_order_bill.order_status (aligned with upstream TAB_ORDER).
* Fee refund sets {@link #REFUNDED} (9 / 已退件).
* Upstream 9/10 trigger billType=REFUND when billing pulls Oracle.
*/
public enum BillOrderStatus
{
/** Upstream: returned package; also set after billing-list fee refund. */
REFUNDED(9);
REFUNDED(9),
/** Upstream: cancelled / deleted. */
CANCELLED(10);
private final int code;
@@ -31,6 +34,12 @@ public enum BillOrderStatus
return status != null && status.intValue() == code;
}
/** Upstream ORDER_STATUS 9/10 -> fee refund path. */
public static boolean requiresFeeRefund(Integer status)
{
return REFUNDED.matches(status) || CANCELLED.matches(status);
}
public static BillOrderStatus of(Integer status)
{
if (status == null)
@@ -47,8 +47,8 @@ public class OracleOrderBillMapper
String countryName = firstStr(row, "COUNTRY_NAME", "COUNTRY_EINGTH_NAME", "COUNTRY");
req.setCountryName(countryName);
req.setDestPostcode(firstStr(row, "CONSIGNEE_POSTCODE"));
// TAB_ORDER.DIMENSIONAL_WEIGHT_FACTOR = billing weight -> quote weight / prc_order_bill.weight
BigDecimal weight = firstPositiveDecimal(row, "DIMENSIONAL_WEIGHT_FACTOR");
// Prefer CONFIRM_WEIGHT (customer confirmed); fallback DIMENSIONAL_WEIGHT_FACTOR (charge weight).
BigDecimal weight = firstPositiveDecimal(row, "CONFIRM_WEIGHT", "DIMENSIONAL_WEIGHT_FACTOR");
req.setWeight(weight);
// TAB_ORDER.WEIGHT = receive weight (收货重)
req.setReceiveWeight(firstDecimal(row, "WEIGHT"));
@@ -21,6 +21,7 @@ import com.bms.price.domain.vo.BillingTaskSubmitRequest;
import com.bms.price.domain.vo.TmsPriceBillRequest;
import com.bms.price.domain.vo.TmsPriceQuoteResult;
import com.bms.price.enums.BillBillingFailStatus;
import com.bms.price.enums.BillOrderStatus;
import com.bms.price.enums.BillTaskFailCode;
import com.bms.price.enums.BillTaskSuccessStatus;
import com.bms.price.enums.BillTaskType;
@@ -293,6 +294,20 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
{
throw new ServiceException("Oracle order mapped orderNo empty");
}
// Upstream ORDER_STATUS 9/10 -> REFUND (even if task was submitted as PENDING/REBILL).
if (BillOrderStatus.requiresFeeRefund(billReq.getOrderStatus()))
{
String refundOrderNo = StringUtils.isNotEmpty(billReq.getOrderNo())
? billReq.getOrderNo().trim()
: resolveRefundOrderNo(task);
log.info("billing task upstream status {} -> REFUND path taskId={} orderNo={}",
billReq.getOrderStatus(), taskId, refundOrderNo);
task.setBillType(BillTaskType.REFUND.getCode());
fillCustomerCodeFromBill(task, refundOrderNo);
refundWithDbRetry(taskId, refundOrderNo);
deleteTaskAfterBillSaved(task);
return;
}
if (StringUtils.isEmpty(billReq.getCustomerCode()))
{
throw new ServiceException("Oracle order mapped customerCode empty");
@@ -200,15 +200,16 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
PrcOrderBill existed = orderBillMapper.selectPrcOrderBillByOrderNo(request.getOrderNo());
BigDecimal systemWeight = request.getWeight();
BigDecimal calcWeight = resolveCalcWeight(existed, systemWeight);
// Three-side sum rule disabled: upstream already applies it.
// Manual charge_weight wins; otherwise apply active biz rules (e.g. three-side).
if (!isManualChargeWeight(existed))
{
BigDecimal ruled = bizRuleService.resolveWeightByRule(request, systemWeight);
if (ruled != null)
{
calcWeight = ruled;
}
}
// if (!isManualChargeWeight(existed))
// {
// BigDecimal ruled = bizRuleService.resolveWeightByRule(request, systemWeight);
// if (ruled != null)
// {
// calcWeight = ruled;
// }
// }
request.setWeight(calcWeight);
TmsPriceQuoteResult result = tmsPriceQuoteService.calculate(request);
persistBill(request, systemWeight, bizDate, result);
@@ -1007,16 +1008,24 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
: request.getCountryCode().trim().toUpperCase();
String beginBizDate = StringUtils.isEmpty(request.getBeginBizDate()) ? null : request.getBeginBizDate().trim();
String endBizDate = StringUtils.isEmpty(request.getEndBizDate()) ? null : request.getEndBizDate().trim();
boolean hasFilter = (orderNos != null && !orderNos.isEmpty())
String beginPickupDate = StringUtils.isEmpty(request.getBeginPickupDate()) ? null
: request.getBeginPickupDate().trim();
String endPickupDate = StringUtils.isEmpty(request.getEndPickupDate()) ? null
: request.getEndPickupDate().trim();
boolean hasIdentifier = (orderNos != null && !orderNos.isEmpty())
|| (trackingNos != null && !trackingNos.isEmpty())
|| (transferNos != null && !transferNos.isEmpty())
|| (orderIdentifiers != null && !orderIdentifiers.isEmpty())
|| (customerCodes != null && !customerCodes.isEmpty())
|| (productCodes != null && !productCodes.isEmpty())
|| (orderIdentifiers != null && !orderIdentifiers.isEmpty());
boolean hasCustomer = customerCodes != null && !customerCodes.isEmpty();
boolean hasBizDate = StringUtils.isNotEmpty(beginBizDate) && StringUtils.isNotEmpty(endBizDate);
boolean hasPickupDate = StringUtils.isNotEmpty(beginPickupDate) && StringUtils.isNotEmpty(endPickupDate);
boolean hasOtherFilter = (productCodes != null && !productCodes.isEmpty())
|| StringUtils.isNotEmpty(creditArrearsStatus)
|| StringUtils.isNotEmpty(countryCode)
|| StringUtils.isNotEmpty(beginBizDate)
|| StringUtils.isNotEmpty(endBizDate);
|| StringUtils.isNotEmpty(countryCode);
// Same gate as order-list UI: identifiers, or customer + (bizDate or pickupDate).
boolean hasFilter = hasIdentifier
|| (hasCustomer && (hasBizDate || hasPickupDate))
|| hasOtherFilter;
if (!hasFilter)
{
throw new ServiceException(MessageUtils.message("price.bill.recalc.filterRequired"));
@@ -1039,6 +1048,14 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
{
query.getParams().put("endBizDate", endBizDate);
}
if (beginPickupDate != null)
{
query.getParams().put("beginPickupDate", beginPickupDate);
}
if (endPickupDate != null)
{
query.getParams().put("endPickupDate", endPickupDate);
}
return query;
}
@@ -511,9 +511,9 @@ public class TabOrderSyncAsyncRunner
{
req.setBillType(billType.trim());
}
else if (BillOrderStatus.REFUNDED.matches(row.getOrderStatus()))
else if (BillOrderStatus.requiresFeeRefund(row.getOrderStatus()))
{
// Upstream 已退件 (ORDER_STATUS=9) -> fee refund task
// Upstream 已退件(9) / 已取消(10) -> fee refund task
req.setBillType(BillTaskType.REFUND.getCode());
}
return req;
@@ -410,7 +410,9 @@ function buildRebillFilter() {
orderStatuses: Array.isArray(q.orderStatuses) ? q.orderStatuses : [],
billingFailStatuses: Array.isArray(q.billingFailStatuses) ? q.billingFailStatuses : [],
beginBizDate: q.params?.beginBizDate || null,
endBizDate: q.params?.endBizDate || null
endBizDate: q.params?.endBizDate || null,
beginPickupDate: q.params?.beginPickupDate || null,
endPickupDate: q.params?.endPickupDate || null
}
return filter
}
@@ -420,7 +422,8 @@ function hasRebillFilter(filter) {
if (ids.length) return true
const hasCustomer = Array.isArray(filter.customerCodes) && filter.customerCodes.length > 0
const hasBizDate = !!(filter.beginBizDate && filter.endBizDate)
return hasCustomer && hasBizDate
const hasPickupDate = !!(filter.beginPickupDate && filter.endPickupDate)
return hasCustomer && (hasBizDate || hasPickupDate)
}
function buildCheckQuery() {
@@ -507,7 +510,7 @@ function openFilterRebill() {
const identifiers = filter.orderIdentifiers || []
if (!validateOrderIdentifierLimit(identifiers)) return
if (!hasRebillFilter(filter)) {
ElMessage.warning('请输入单号,或选择客户并选择计费时间后再重新计费;也可勾选订单后点重新计费选中')
ElMessage.warning('请输入单号,或选择客户并选择计费时间或提货时间后再重新计费;也可勾选订单后点重新计费选中')
return
}
if (identifiers.length > MAX_REBILL) {
@@ -518,7 +521,7 @@ function openFilterRebill() {
if (identifiers.length) {
confirmText = '将按 ' + identifiers.length + ' 个单号从本地订单表重新计费(不查上游),确认继续?'
} else {
confirmText = '将按当前列表筛选(客户 + 计费时间等)从本地订单表重新计费(不查上游),确认继续?'
confirmText = '将按当前列表筛选(客户 + 计费时间/提货时间等)从本地订单表重新计费(不查上游),确认继续?'
}
runLocalRebill(filter, confirmText)
}