增加失败码功能
This commit is contained in:
@@ -9,10 +9,10 @@ import java.util.List;
|
||||
* TMS freight quote / bill calc service (shared by console trial and upstream bill).
|
||||
*
|
||||
* Match order:
|
||||
* 1) Customer binds (not stopped), bind_priority ASC
|
||||
* 2) Active package version at bill-time end-of-day (effective_time / expire_time)
|
||||
* 1) Customer binds (package not stopped), bind_priority ASC; bind date range is not used for billing
|
||||
* 2) Active package version at bill-time end-of-day (version effective_time / expire_time)
|
||||
* 3) FIXED detail override, else DISCOUNT on that version
|
||||
* 4) Else bms_product_country default
|
||||
* 4) Else product default only when a version existed but detail missed
|
||||
* Package hit uses version surcharge snapshot when present; else product library.
|
||||
*
|
||||
* @author bms
|
||||
|
||||
+11
-1
@@ -17,6 +17,7 @@ import com.bms.price.domain.PrcOrderBill;
|
||||
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.BillTaskFailCode;
|
||||
import com.bms.price.enums.BillTaskSuccessStatus;
|
||||
import com.bms.price.enums.BillTaskType;
|
||||
import com.bms.price.mapper.PrcBillingTaskMapper;
|
||||
@@ -351,6 +352,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
reset.setTaskId(taskId);
|
||||
reset.setSuccessStatus(BillTaskSuccessStatus.WAITING.getCode());
|
||||
reset.setBillId(null);
|
||||
reset.setFailCode(null);
|
||||
reset.setErrorMessage(null);
|
||||
billingTaskMapper.updateBillingResult(reset);
|
||||
|
||||
@@ -382,7 +384,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
return existed == null ? BillTaskType.PENDING : BillTaskType.REBILL;
|
||||
}
|
||||
|
||||
/** Write back status/billId/error only; keep inbound transfer/tracking/order/billTime untouched. */
|
||||
/** Write back status/billId/failCode/error only; keep inbound transfer/tracking/order/billTime untouched. */
|
||||
private void writeback(PrcBillingTask task, BillTaskSuccessStatus status, String billId,
|
||||
String errorMessage)
|
||||
{
|
||||
@@ -390,6 +392,14 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
upd.setTaskId(task.getTaskId());
|
||||
upd.setSuccessStatus(status.getCode());
|
||||
upd.setBillId(billId);
|
||||
if (BillTaskSuccessStatus.FAILED == status)
|
||||
{
|
||||
upd.setFailCode(BillTaskFailCode.resolveCode(errorMessage));
|
||||
}
|
||||
else
|
||||
{
|
||||
upd.setFailCode(null);
|
||||
}
|
||||
upd.setErrorMessage(errorMessage);
|
||||
billingTaskMapper.updateBillingResult(upd);
|
||||
}
|
||||
|
||||
+23
-14
@@ -56,9 +56,9 @@ import com.bms.price.search.IBillSearchStore;
|
||||
import com.bms.price.service.ITmsPriceQuoteService;
|
||||
|
||||
/**
|
||||
* Shared quote/bill calc: bound set + active version by bizDate.
|
||||
* No customer package bind: quote and bill both fail hard (no PRODUCT_DEFAULT).
|
||||
* Bill path: no persist; billing task marked FAILED (abnormal order).
|
||||
* Shared quote/bill calc: customer bind + package version by bizDate (version effective_time).
|
||||
* Bind pr_begindate/pr_enddate is not used for billing time gate.
|
||||
* No bind / no active version at bill time: quote and bill both fail hard (no PRODUCT_DEFAULT).
|
||||
*
|
||||
* @author bms
|
||||
*/
|
||||
@@ -261,15 +261,14 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
List<PrcCustomerPriceSet> binds;
|
||||
if (StringUtils.isNotEmpty(request.getCustomerCode()))
|
||||
{
|
||||
binds = customerPriceSetMapper.selectEffectiveByCustomerCode(
|
||||
request.getCustomerCode(), bizDate);
|
||||
binds = customerPriceSetMapper.selectEffectiveByCustomerCode(request.getCustomerCode());
|
||||
}
|
||||
else
|
||||
{
|
||||
binds = customerPriceSetMapper.selectEffectiveByCustomer(
|
||||
request.getCustomerId(), bizDate);
|
||||
binds = customerPriceSetMapper.selectEffectiveByCustomer(request.getCustomerId());
|
||||
}
|
||||
|
||||
boolean anyActiveVersion = false;
|
||||
if (binds != null)
|
||||
{
|
||||
Date asOf = endOfDay(bizDate);
|
||||
@@ -280,12 +279,13 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Temporal gate: prc_price_set_version.effective_time / expire_time (not bind pr_begindate)
|
||||
PrcPriceSetVersion version = versionMapper.selectActiveByPriceSetAt(set.getPriceSetId(), asOf);
|
||||
if (version == null || version.getPsvId() == null)
|
||||
{
|
||||
// Bound package but no version effective at bill time -> try next bind / default
|
||||
continue;
|
||||
}
|
||||
anyActiveVersion = true;
|
||||
String setType = StringUtils.isEmpty(set.getSetType()) ? TYPE_FIXED : set.getSetType();
|
||||
if (TYPE_FIXED.equals(setType))
|
||||
{
|
||||
@@ -308,13 +308,22 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
}
|
||||
|
||||
// No customer package bind: do not use PRODUCT_DEFAULT (quote and bill).
|
||||
// Bill: no persist; billing task catches and writes success_status=FAILED.
|
||||
if (binds == null || binds.isEmpty())
|
||||
// No bind, or bind exists but no version effective at bill time.
|
||||
if (binds == null || binds.isEmpty() || !anyActiveVersion)
|
||||
{
|
||||
String msgKey = request instanceof TmsPriceBillRequest
|
||||
? "price.bill.noCustomerPackage"
|
||||
: "price.quote.noCustomerPackage";
|
||||
String msgKey;
|
||||
if (binds == null || binds.isEmpty())
|
||||
{
|
||||
msgKey = request instanceof TmsPriceBillRequest
|
||||
? "price.bill.noCustomerPackage"
|
||||
: "price.quote.noCustomerPackage";
|
||||
}
|
||||
else
|
||||
{
|
||||
msgKey = request instanceof TmsPriceBillRequest
|
||||
? "price.bill.noActivePackageVersion"
|
||||
: "price.quote.noActivePackageVersion";
|
||||
}
|
||||
throw new ServiceException(MessageUtils.message(msgKey));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user