修改订单列表重新计费
This commit is contained in:
+85
-8
@@ -28,11 +28,14 @@ import com.bms.price.config.BillingProperties;
|
||||
import com.bms.price.domain.BatchAddIncomeBillFeeTask;
|
||||
import com.bms.price.domain.PrcOrderBill;
|
||||
import com.bms.price.domain.vo.LocalRebillRequest;
|
||||
import com.bms.price.domain.vo.TmsPriceQuoteResult;
|
||||
import com.bms.price.enums.BillBillingFailStatus;
|
||||
import com.bms.price.mapper.PrcOrderBillMapper;
|
||||
import com.bms.price.search.EsBizLogSupport;
|
||||
import com.bms.price.search.IBillSearchStore;
|
||||
import com.bms.price.search.TabOrderSyncEsLog;
|
||||
import com.bms.price.service.IPrcOrderBillService;
|
||||
import com.bms.price.service.support.OrderBillExportSupport;
|
||||
|
||||
/**
|
||||
* Async local rebill from prc_order_bill only (no Oracle / MQ).
|
||||
@@ -122,16 +125,33 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
String one = ids.get(i);
|
||||
try
|
||||
{
|
||||
orderBillService.rebillLocalByBillId(one);
|
||||
success.incrementAndGet();
|
||||
TmsPriceQuoteResult result = orderBillService.rebillLocalByBillId(one);
|
||||
// Soft-fail still persists the order bill; count as fail in progress.
|
||||
if (BillBillingFailStatus.isFail(result == null ? null : result.getBillingFailStatus()))
|
||||
{
|
||||
fail.incrementAndGet();
|
||||
String tip = softFailMessage(result);
|
||||
String transferLabel = failTransferLabel(one,
|
||||
result == null ? null : result.getTransferNo());
|
||||
appendFail(failTips, transferLabel, tip);
|
||||
collectFailDetail(failDetails, one, tip);
|
||||
log.warn("local rebill soft-fail taskId={} billId={} transferNo={} status={} msg={}",
|
||||
taskId, one, transferLabel,
|
||||
result == null ? null : result.getBillingFailStatus(), tip);
|
||||
}
|
||||
else
|
||||
{
|
||||
success.incrementAndGet();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail.incrementAndGet();
|
||||
appendFail(failTips, one, e);
|
||||
String transferLabel = failTransferLabel(one, null);
|
||||
appendFail(failTips, transferLabel, e);
|
||||
collectFailDetail(failDetails, one, e);
|
||||
log.warn("local rebill failed taskId={} billId={} msg={}",
|
||||
taskId, one, e.getMessage());
|
||||
log.warn("local rebill failed taskId={} billId={} transferNo={} msg={}",
|
||||
taskId, one, transferLabel, e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -250,6 +270,11 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
}
|
||||
|
||||
private void collectFailDetail(List<Map<String, Object>> failDetails, String billId, Exception e)
|
||||
{
|
||||
collectFailDetail(failDetails, billId, errorMessage(e));
|
||||
}
|
||||
|
||||
private void collectFailDetail(List<Map<String, Object>> failDetails, String billId, String message)
|
||||
{
|
||||
if (failDetails == null)
|
||||
{
|
||||
@@ -284,7 +309,7 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
item.put("orderId", StringUtils.isEmpty(orderNo) ? billId : orderNo);
|
||||
item.put("transferOrderId", transferNo);
|
||||
item.put("trackingNo", trackingNo);
|
||||
item.put("errorMessage", errorMessage(e));
|
||||
item.put("errorMessage", StringUtils.isEmpty(message) ? "fail" : message);
|
||||
failDetails.add(item);
|
||||
}
|
||||
}
|
||||
@@ -427,7 +452,12 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
return v;
|
||||
}
|
||||
|
||||
private static void appendFail(StringBuilder failTips, String billId, Exception e)
|
||||
private static void appendFail(StringBuilder failTips, String orderLabel, Exception e)
|
||||
{
|
||||
appendFail(failTips, orderLabel, errorMessage(e));
|
||||
}
|
||||
|
||||
private static void appendFail(StringBuilder failTips, String orderLabel, String message)
|
||||
{
|
||||
synchronized (failTips)
|
||||
{
|
||||
@@ -439,10 +469,57 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
{
|
||||
failTips.append("; ");
|
||||
}
|
||||
failTips.append(billId).append(":").append(errorMessage(e));
|
||||
failTips.append(StringUtils.isEmpty(orderLabel) ? "-" : orderLabel)
|
||||
.append(":").append(StringUtils.isEmpty(message) ? "fail" : message);
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer transferNo in UI tips; fall back to orderNo, then billId. */
|
||||
private String failTransferLabel(String billId, String transferNoHint)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(transferNoHint))
|
||||
{
|
||||
return transferNoHint.trim();
|
||||
}
|
||||
if (StringUtils.isEmpty(billId) || orderBillMapper == null)
|
||||
{
|
||||
return billId;
|
||||
}
|
||||
try
|
||||
{
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
if (bill != null)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(bill.getTransferNo()))
|
||||
{
|
||||
return bill.getTransferNo().trim();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(bill.getOrderNo()))
|
||||
{
|
||||
return bill.getOrderNo().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ignore)
|
||||
{
|
||||
// tip label is best-effort
|
||||
}
|
||||
return billId;
|
||||
}
|
||||
|
||||
private static String softFailMessage(TmsPriceQuoteResult result)
|
||||
{
|
||||
if (result == null)
|
||||
{
|
||||
return "billing fail";
|
||||
}
|
||||
if (StringUtils.isNotEmpty(result.getMatchMessage()))
|
||||
{
|
||||
return result.getMatchMessage();
|
||||
}
|
||||
return OrderBillExportSupport.billingFailStatusLabel(result.getBillingFailStatus());
|
||||
}
|
||||
|
||||
private static String errorMessage(Exception e)
|
||||
{
|
||||
return StringUtils.isEmpty(e.getMessage()) ? e.getClass().getSimpleName() : e.getMessage();
|
||||
|
||||
Reference in New Issue
Block a user