增加订单主表

This commit is contained in:
wuweihua
2026-10-16 17:27:11 +08:00
parent e227c6a80f
commit db396458c5
25 changed files with 1326 additions and 302 deletions
@@ -0,0 +1,116 @@
package com.bms.web.controller.monitor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bms.common.annotation.Log;
import com.bms.common.core.controller.BaseController;
import com.bms.common.core.domain.AjaxResult;
import com.bms.common.core.page.TableDataInfo;
import com.bms.common.enums.BusinessType;
import com.bms.price.domain.PrcOrder;
import com.bms.price.enums.BillTaskSuccessStatus;
import com.bms.price.service.IPrcBillingTaskService;
import com.bms.price.service.IPrcOrderService;
/**
* Monitor: prc_order billing status list and manual resync (replaces task-queue view after upsert).
* Reuses monitor:billingTask:* perms so menu/roles stay stable.
*/
@RestController
@RequestMapping("/monitor/prcOrder")
public class PrcOrderMonitorController extends BaseController
{
@Autowired
private IPrcOrderService prcOrderService;
@Autowired
private IPrcBillingTaskService billingTaskService;
/** Default list = FAILED. */
@PreAuthorize("@ss.hasPermi('monitor:billingTask:list')")
@GetMapping("/list")
public TableDataInfo list(PrcOrder query)
{
if (query.getSuccessStatus() == null || query.getSuccessStatus().isEmpty())
{
query.setSuccessStatus(BillTaskSuccessStatus.FAILED.getCode());
}
else if ("ALL".equalsIgnoreCase(query.getSuccessStatus()))
{
query.setSuccessStatus(null);
}
startPage();
List<PrcOrder> list = prcOrderService.selectPrcOrderList(query);
return getDataTable(list);
}
@PreAuthorize("@ss.hasPermi('monitor:billingTask:list')")
@GetMapping("/{orderId}")
public AjaxResult getInfo(@PathVariable("orderId") String orderId)
{
return success(prcOrderService.selectPrcOrderById(orderId));
}
@PreAuthorize("@ss.hasPermi('monitor:billingTask:retry')")
@Log(title = "prc_order retry", businessType = BusinessType.UPDATE)
@PostMapping("/retry/{orderId}")
public AjaxResult retry(@PathVariable("orderId") String orderId)
{
return success(billingTaskService.retryByOrderId(orderId));
}
@PreAuthorize("@ss.hasPermi('monitor:billingTask:retry')")
@Log(title = "prc_order batch retry", businessType = BusinessType.UPDATE)
@PostMapping("/retry")
public AjaxResult retryBatch(@RequestBody String[] orderIds)
{
if (orderIds == null || orderIds.length == 0)
{
return error("orderIds required");
}
int ok = 0;
int fail = 0;
List<Map<String, Object>> details = new ArrayList<Map<String, Object>>();
for (String orderId : orderIds)
{
Map<String, Object> row = new HashMap<String, Object>();
row.put("orderId", orderId);
try
{
PrcOrder order = billingTaskService.retryByOrderId(orderId);
row.put("successStatus", order == null ? null : order.getSuccessStatus());
row.put("failCode", order == null ? null : order.getFailCode());
if (order != null && BillTaskSuccessStatus.SUCCESS.getCode().equals(order.getSuccessStatus()))
{
ok++;
}
else
{
fail++;
}
}
catch (RuntimeException e)
{
fail++;
row.put("successStatus", BillTaskSuccessStatus.FAILED.getCode());
row.put("failCode", e.getMessage());
}
details.add(row);
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("ok", Integer.valueOf(ok));
data.put("fail", Integer.valueOf(fail));
data.put("details", details);
return success(data);
}
}
@@ -0,0 +1,66 @@
package com.bms.price.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bms.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/** Order master prc_order (upstream TAB_ORDER core + billing status) */
@Data
@EqualsAndHashCode(callSuper = true)
public class PrcOrder extends BaseEntity
{
private static final long serialVersionUID = 1L;
private String orderId;
private String orderNo;
private List<String> orderNos;
private String trackingNo;
private List<String> trackingNos;
private String transferNo;
private List<String> transferNos;
private String trackId;
private String belongSaler;
private String belongSalerCode;
private String settlementMan;
private String settlementManCode;
private String serviceMan;
private String serviceManCode;
private String customerCode;
private String customerName;
private List<String> customerCodes;
private Integer pieces;
private BigDecimal actualWeight;
private BigDecimal weight;
private BigDecimal dimensionalWeightFactor;
private BigDecimal volume;
private BigDecimal volumeWeight;
private BigDecimal pkgLength;
private BigDecimal pkgWidth;
private BigDecimal pkgHeight;
private String shipperName;
private String consigneeName;
private String consigneePostcode;
private String warehouseCode;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date orderTime;
private String orderRemark;
private String productCode;
private String productName;
private List<String> productCodes;
private String productFloorCode;
private String countryCode;
private String countryName;
private Integer orderStatus;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date pickupDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date bizDate;
/** WAITING / SUCCESS / FAILED */
private String successStatus;
private String failCode;
private List<String> failCodes;
}
@@ -17,6 +17,8 @@ public class PrcOrderBill extends BaseEntity
private static final long serialVersionUID = 1L;
private String billId;
/** FK to prc_order.order_id (wired by parent). */
private String orderId;
/** 批量查询:多个账单ID精确匹配(仅查询用,非表字段) */
private List<String> billIds;
private String billKey;
@@ -62,7 +64,7 @@ public class PrcOrderBill extends BaseEntity
private String warehouseCode;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date orderTime;
/** 应收来源查询专用:从 prc_order_bill_ext.pickup_date 读取的收件时间。 */
/** 应收来源查询专用:从 prc_order.pickup_date 读取的收件时间。 */
@JsonIgnore
private Date pickupDate;
private String orderRemark;
@@ -6,13 +6,13 @@ import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/** 计费订单扩展表:TAB_ORDER 剩余字段 + 同步请求快照 */
/** Order ext leftover TAB_ORDER fields on prc_order_ext */
@Data
public class PrcOrderBillExt implements Serializable
public class PrcOrderExt implements Serializable
{
private static final long serialVersionUID = 1L;
private String billId;
private String orderId;
private String orderNo;
private String upstreamId;
private String lineNo;
@@ -70,7 +70,6 @@ public class PrcOrderBillExt implements Serializable
private String importState;
private String importCountry;
private String buyerid;
private Integer orderStatus;
private String createAt;
private Integer payType;
private String lineCode;
@@ -78,7 +77,6 @@ public class PrcOrderBillExt implements Serializable
private String productType;
private String lineType;
private String cargoName;
private String productFloorCode;
private BigDecimal orderInsurance;
private BigDecimal productSumPrice;
private BigDecimal productSum;
@@ -88,8 +86,6 @@ public class PrcOrderBillExt implements Serializable
private String productFloor;
private String latestTrajectory;
private String wayBill;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date pickupDate;
private Integer blBaging;
private Integer blPickup;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@@ -174,7 +170,6 @@ public class PrcOrderBillExt implements Serializable
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date airConfirmTime;
private Integer packageType;
private BigDecimal dimensionalWeightFactor;
private String updateBy;
private String customerPickupSite;
private String barcodeNumber;
@@ -20,6 +20,9 @@ public class TmsPriceBillRequest extends TmsPriceQuoteRequest
@NotBlank(message = "orderNo is required")
private String orderNo;
/** FK to prc_order.order_id when order master already upserted */
private String orderId;
private String trackingNo;
/** transfer order no */
private String transferNo;
@@ -51,7 +54,7 @@ public class TmsPriceBillRequest extends TmsPriceQuoteRequest
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date orderTime;
private String orderRemark;
/** 上游 TAB_ORDER 整行,用于写入 prc_order_bill_ext 扩展字段 */
/** 上游 TAB_ORDER 整行,用于写入 prc_order_ext 扩展字段 */
private Map<String, Object> upstreamRow;
@JsonIgnore
@@ -12,6 +12,9 @@ public interface PrcBillingTaskMapper
int insertPrcBillingTask(PrcBillingTask task);
/** Delete queue rows by unique transfer_no after prc_order upsert. */
int deleteByTransferNo(@Param("transferNo") String transferNo);
int updatePrcBillingTask(PrcBillingTask task);
/** CAS: WAITING -> processing claim not needed; writeback SUCCESS/FAILED */
@@ -1,15 +0,0 @@
package com.bms.price.mapper;
import com.bms.price.domain.PrcOrderBillExt;
/** prc_order_bill_ext mapper */
public interface PrcOrderBillExtMapper
{
public PrcOrderBillExt selectByBillId(String billId);
public PrcOrderBillExt selectByOrderNo(String orderNo);
public int insertPrcOrderBillExt(PrcOrderBillExt ext);
public int upsertPrcOrderBillExt(PrcOrderBillExt ext);
}
@@ -0,0 +1,15 @@
package com.bms.price.mapper;
import com.bms.price.domain.PrcOrderExt;
/** prc_order_ext mapper */
public interface PrcOrderExtMapper
{
public PrcOrderExt selectByOrderId(String orderId);
public PrcOrderExt selectByOrderNo(String orderNo);
public int insertPrcOrderExt(PrcOrderExt ext);
public int upsertPrcOrderExt(PrcOrderExt ext);
}
@@ -0,0 +1,28 @@
package com.bms.price.mapper;
import java.util.List;
import com.bms.price.domain.PrcOrder;
import org.apache.ibatis.annotations.Param;
/** prc_order mapper */
public interface PrcOrderMapper
{
PrcOrder selectPrcOrderById(String orderId);
PrcOrder selectPrcOrderByTransferNo(String transferNo);
PrcOrder selectPrcOrderByOrderNo(String orderNo);
List<PrcOrder> selectPrcOrderList(PrcOrder query);
int insertPrcOrder(PrcOrder order);
int updatePrcOrder(PrcOrder order);
int upsertPrcOrderByTransferNo(PrcOrder order);
int updateBillingStatus(@Param("orderId") String orderId,
@Param("successStatus") String successStatus,
@Param("failCode") String failCode,
@Param("updateBy") String updateBy);
}
@@ -5,16 +5,16 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import com.bms.price.domain.PrcOrderBillExt;
import com.bms.price.domain.PrcOrderExt;
/**
* 从 Oracle TAB_ORDER 行填充 prc_order_bill_ext(仅包含未落在 prc_order_bill 的字段)。
* 从 Oracle TAB_ORDER 行填充 prc_order_ext(仅包含未落在 prc_order_bill 的字段)。
*/
public final class OracleOrderBillExtFiller
public final class OracleOrderExtFiller
{
private OracleOrderBillExtFiller() {}
private OracleOrderExtFiller() {}
public static void fillFromRow(PrcOrderBillExt ext, Map<String, Object> row)
public static void fillFromRow(PrcOrderExt ext, Map<String, Object> row)
{
if (ext == null || row == null || row.isEmpty())
{
@@ -76,7 +76,6 @@ public final class OracleOrderBillExtFiller
ext.setImportState(str(row, "IMPORT_STATE"));
ext.setImportCountry(str(row, "IMPORT_COUNTRY"));
ext.setBuyerid(str(row, "BUYERID"));
ext.setOrderStatus(integer(row, "ORDER_STATUS"));
ext.setCreateAt(str(row, "CREATE_AT"));
ext.setPayType(integer(row, "PAY_TYPE"));
ext.setLineCode(str(row, "LINE_CODE"));
@@ -84,7 +83,6 @@ public final class OracleOrderBillExtFiller
ext.setProductType(str(row, "PRODUCT_TYPE"));
ext.setLineType(str(row, "LINE_TYPE"));
ext.setCargoName(str(row, "CARGO_NAME"));
ext.setProductFloorCode(str(row, "PRODUCT_FLOOR_CODE"));
ext.setOrderInsurance(decimal(row, "ORDER_INSURANCE"));
ext.setProductSumPrice(decimal(row, "PRODUCT_SUM_PRICE"));
ext.setProductSum(decimal(row, "PRODUCT_SUM"));
@@ -94,7 +92,6 @@ public final class OracleOrderBillExtFiller
ext.setProductFloor(str(row, "PRODUCT_FLOOR"));
ext.setLatestTrajectory(str(row, "LATEST_TRAJECTORY"));
ext.setWayBill(str(row, "WAY_BILL"));
ext.setPickupDate(date(row, "PICKUP_DATE"));
ext.setBlBaging(integer(row, "BL_BAGING"));
ext.setBlPickup(integer(row, "BL_PICKUP"));
ext.setBagDate(date(row, "BAG_DATE"));
@@ -162,7 +159,6 @@ public final class OracleOrderBillExtFiller
ext.setTrackQueryTime(date(row, "TRACK_QUERY_TIME"));
ext.setAirConfirmTime(date(row, "AIR_CONFIRM_TIME"));
ext.setPackageType(integer(row, "PACKAGE_TYPE"));
ext.setDimensionalWeightFactor(decimal(row, "DIMENSIONAL_WEIGHT_FACTOR"));
ext.setUpdateBy(str(row, "UPDATE_BY"));
ext.setCustomerPickupSite(str(row, "CUSTOMER_PICKUP_SITE"));
ext.setBarcodeNumber(str(row, "BARCODE_NUMBER"));
@@ -0,0 +1,201 @@
package com.bms.price.oracle;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import com.bms.common.utils.StringUtils;
import com.bms.price.domain.PrcOrder;
import com.bms.price.domain.vo.TmsPriceBillRequest;
import com.bms.price.enums.BillTaskSuccessStatus;
/**
* Fill prc_order core fields from upstream TAB_ORDER row (+ bill request overlay).
*/
public final class OracleOrderFiller
{
private OracleOrderFiller() {}
public static void fillFromRow(PrcOrder order, Map<String, Object> row, TmsPriceBillRequest req, Date bizDate)
{
if (order == null || row == null || row.isEmpty())
{
return;
}
if (req != null)
{
if (StringUtils.isNotEmpty(req.getOrderNo()))
{
order.setOrderNo(req.getOrderNo());
}
if (StringUtils.isNotEmpty(req.getTrackingNo()))
{
order.setTrackingNo(req.getTrackingNo());
}
if (StringUtils.isNotEmpty(req.getTransferNo()))
{
order.setTransferNo(req.getTransferNo());
}
order.setBelongSaler(req.getBelongSaler());
order.setBelongSalerCode(req.getBelongSalerCode());
order.setSettlementMan(req.getSettlementMan());
order.setSettlementManCode(req.getSettlementManCode());
order.setServiceMan(req.getServiceMan());
order.setServiceManCode(req.getServiceManCode());
order.setCustomerCode(req.getCustomerCode());
order.setCustomerName(req.getCustomerName());
order.setPieces(req.getPieces());
order.setActualWeight(req.getActualWeight());
order.setWeight(req.getReceiveWeight());
order.setDimensionalWeightFactor(req.getWeight());
order.setVolume(req.getVolume());
order.setVolumeWeight(req.getVolumeWeight());
order.setPkgLength(req.getPkgLength());
order.setPkgWidth(req.getPkgWidth());
order.setPkgHeight(req.getPkgHeight());
order.setShipperName(req.getShipperName());
order.setConsigneeName(req.getConsigneeName());
order.setConsigneePostcode(req.getDestPostcode());
order.setWarehouseCode(req.getWarehouseCode());
order.setOrderTime(req.getOrderTime());
order.setOrderRemark(req.getOrderRemark());
order.setProductCode(req.getProductCode());
order.setCountryCode(req.getCountryCode());
order.setCountryName(req.getCountryName());
}
if (StringUtils.isEmpty(order.getOrderNo()))
{
order.setOrderNo(str(row, "ORDER_ID"));
}
if (StringUtils.isEmpty(order.getTrackingNo()))
{
order.setTrackingNo(str(row, "ORG_ORDER_ID"));
}
if (StringUtils.isEmpty(order.getTransferNo()))
{
order.setTransferNo(str(row, "TRANSFER_ORDER_ID"));
}
order.setTrackId(str(row, "TRACK_ID"));
order.setProductFloorCode(str(row, "PRODUCT_FLOOR_CODE"));
if (StringUtils.isEmpty(order.getProductName()))
{
order.setProductName(str(row, "PRODUCT_NAME"));
}
order.setOrderStatus(integer(row, "ORDER_STATUS"));
order.setPickupDate(date(row, "PICKUP_DATE"));
if (order.getDimensionalWeightFactor() == null)
{
order.setDimensionalWeightFactor(decimal(row, "DIMENSIONAL_WEIGHT_FACTOR"));
}
if (order.getWeight() == null)
{
order.setWeight(decimal(row, "WEIGHT"));
}
if (order.getVolumeWeight() == null)
{
order.setVolumeWeight(decimal(row, "VOLUME_WEIGHT"));
}
if (order.getConsigneePostcode() == null)
{
order.setConsigneePostcode(str(row, "CONSIGNEE_POSTCODE"));
}
order.setBizDate(bizDate);
if (StringUtils.isEmpty(order.getSuccessStatus()))
{
order.setSuccessStatus(BillTaskSuccessStatus.WAITING.getCode());
}
}
private static String str(Map<String, Object> row, String key)
{
Object v = get(row, key);
if (v == null)
{
return null;
}
String s = String.valueOf(v).trim();
return s.isEmpty() ? null : s;
}
private static Integer integer(Map<String, Object> row, String key)
{
BigDecimal d = decimal(row, key);
return d == null ? null : Integer.valueOf(d.intValue());
}
private static BigDecimal decimal(Map<String, Object> row, String key)
{
Object v = get(row, key);
if (v == null || "".equals(String.valueOf(v).trim()))
{
return null;
}
if (v instanceof BigDecimal)
{
return (BigDecimal) v;
}
if (v instanceof Number)
{
return BigDecimal.valueOf(((Number) v).doubleValue());
}
try
{
return new BigDecimal(String.valueOf(v).trim());
}
catch (Exception e)
{
return null;
}
}
private static Date date(Map<String, Object> row, String key)
{
Object v = get(row, key);
if (v == null)
{
return null;
}
if (v instanceof Date)
{
return (Date) v;
}
String s = String.valueOf(v).trim();
String[] formats = {
"dd/MM/yyyy HH:mm:ss", "dd/MM/yyyy HH:mm", "yyyy-MM-dd HH:mm:ss",
"yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd"
};
for (String fmt : formats)
{
try
{
return new SimpleDateFormat(fmt, Locale.ENGLISH).parse(s);
}
catch (Exception ignored)
{
}
}
return null;
}
private static Object get(Map<String, Object> row, String key)
{
if (row.containsKey(key))
{
return row.get(key);
}
String upper = key.toUpperCase(Locale.ROOT);
if (row.containsKey(upper))
{
return row.get(upper);
}
for (Map.Entry<String, Object> e : row.entrySet())
{
if (e.getKey() != null && e.getKey().equalsIgnoreCase(key))
{
return e.getValue();
}
}
return null;
}
}
@@ -35,6 +35,12 @@ public interface IPrcBillingTaskService
*/
PrcBillingTask retryTask(Long taskId);
/**
* Manual resync by prc_order.order_id (task queue row may already be deleted).
* @return order after retry
*/
com.bms.price.domain.PrcOrder retryByOrderId(String orderId);
/**
* Start async filter retry (customer + bill_time). Returns async task id for progress poll.
*/
@@ -0,0 +1,25 @@
package com.bms.price.service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.bms.price.domain.PrcOrder;
import com.bms.price.domain.vo.TmsPriceBillRequest;
/** prc_order service */
public interface IPrcOrderService
{
PrcOrder selectPrcOrderById(String orderId);
PrcOrder selectPrcOrderByTransferNo(String transferNo);
List<PrcOrder> selectPrcOrderList(PrcOrder query);
/**
* Upsert prc_order + prc_order_ext by transfer_no (overwrite upstream fields when exists).
* @return persisted order (stable orderId)
*/
PrcOrder upsertFromUpstream(Map<String, Object> upstreamRow, TmsPriceBillRequest billReq, Date bizDate);
void updateBillingStatus(String orderId, String successStatus, String failCode);
}
@@ -15,6 +15,7 @@ import com.bms.common.utils.StringUtils;
import com.bms.price.config.BillingProperties;
import com.bms.price.domain.PrcBillingTask;
import com.bms.price.domain.PrcBillingTaskRetryTask;
import com.bms.price.domain.PrcOrder;
import com.bms.price.domain.PrcOrderBill;
import com.bms.price.domain.vo.BillingTaskRetryByFilterRequest;
import com.bms.price.domain.vo.BillingTaskSubmitRequest;
@@ -32,6 +33,7 @@ import com.bms.price.oracle.OracleOrderBillMapper;
import com.bms.price.oracle.OracleUpstreamOrderService;
import com.bms.price.service.IPrcBillingTaskService;
import com.bms.price.service.IPrcOrderBillService;
import com.bms.price.service.IPrcOrderService;
import com.bms.price.task.PrcBillingTaskRetryAsyncRunner;
@Service
@@ -57,6 +59,9 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
@Autowired
private IPrcOrderBillService prcOrderBillService;
@Autowired
private IPrcOrderService prcOrderService;
@Autowired
private BillingProperties billingProperties;
@@ -249,29 +254,17 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
}
/**
* 用上游 Oracle 全行数据映射并计费(公共逻辑:MQ 处理与订单列表同步复用)。
* 订单列表同步时行数据已由分页查询拉回,避免每单再走 findMainOrder 的公网往返。
* Map upstream row -> upsert prc_order(+ext) -> delete billing task by transfer_no -> bill
* -> write success_status/fail_code onto prc_order (task is already gone).
*/
private void billFromUpstreamRow(PrcBillingTask task, Map<String, Object> row)
{
Long taskId = task.getTaskId();
TmsPriceBillRequest billReq = oracleOrderBillMapper.toBillRequest(row,
billingProperties.getOracle().getDefaultProductCode());
if (billReq == null || StringUtils.isEmpty(billReq.getOrderNo()))
if (billReq == null)
{
throw new ServiceException("Oracle order mapped orderNo empty");
}
if (StringUtils.isEmpty(billReq.getCustomerCode()))
{
throw new ServiceException("Oracle order mapped customerCode empty");
}
if (StringUtils.isEmpty(billReq.getProductCode()))
{
throw new ServiceException("Oracle order mapped productCode empty");
}
if (billReq.getWeight() == null || billReq.getWeight().signum() <= 0)
{
throw new ServiceException("Oracle order mapped weight invalid");
throw new ServiceException("Oracle order mapped empty");
}
// Identity keys from mobile inbound are source of truth; do not replace with Oracle remap.
if (StringUtils.isNotEmpty(task.getTransferNo()))
@@ -290,21 +283,55 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
billReq.setBizDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(task.getBillTime()));
task.setCustomerCode(billReq.getCustomerCode());
TmsPriceQuoteResult result = billWithDbRetry(taskId, billReq);
// Soft-fail (product/country/weight miss): order bill already persisted with zero amounts;
// still mark task FAILED so it appears in abnormal-task list for retry/ops.
if (result != null && BillBillingFailStatus.isFail(result.getBillingFailStatus()))
// Always persist upstream onto prc_order first (even if later billing validation fails).
PrcOrder order = prcOrderService.upsertFromUpstream(row, billReq, task.getBillTime());
billReq.setOrderId(order.getOrderId());
String transferNo = order.getTransferNo();
if (StringUtils.isNotEmpty(transferNo))
{
String err = StringUtils.isNotEmpty(result.getMatchMessage())
? result.getMatchMessage()
: ("billingFailStatus=" + result.getBillingFailStatus());
writeback(task, BillTaskSuccessStatus.FAILED, result.getBillId(), cut(err, 900),
BillBillingFailStatus.toTaskFailCode(result.getBillingFailStatus()));
billingTaskMapper.deleteByTransferNo(transferNo);
}
else
try
{
writeback(task, BillTaskSuccessStatus.SUCCESS, result == null ? null : result.getBillId(),
null, null);
if (StringUtils.isEmpty(billReq.getOrderNo()))
{
throw new ServiceException("Oracle order mapped orderNo empty");
}
if (StringUtils.isEmpty(billReq.getCustomerCode()))
{
throw new ServiceException("Oracle order mapped customerCode empty");
}
if (StringUtils.isEmpty(billReq.getProductCode()))
{
throw new ServiceException("Oracle order mapped productCode empty");
}
if (billReq.getWeight() == null || billReq.getWeight().signum() <= 0)
{
throw new ServiceException("Oracle order mapped weight invalid");
}
TmsPriceQuoteResult result = billWithDbRetry(taskId, billReq);
if (result != null && BillBillingFailStatus.isFail(result.getBillingFailStatus()))
{
String failCode = BillBillingFailStatus.toTaskFailCode(result.getBillingFailStatus());
prcOrderService.updateBillingStatus(order.getOrderId(),
BillTaskSuccessStatus.FAILED.getCode(), failCode);
}
else
{
prcOrderService.updateBillingStatus(order.getOrderId(),
BillTaskSuccessStatus.SUCCESS.getCode(), null);
}
}
catch (RuntimeException e)
{
// Task row already deleted; persist fail on prc_order only (do not rethrow for writeback).
String failCode = BillTaskFailCode.resolveCode(e.getMessage());
prcOrderService.updateBillingStatus(order.getOrderId(),
BillTaskSuccessStatus.FAILED.getCode(), failCode);
log.error("billing failed after prc_order upsert orderId={} transferNo={}",
order.getOrderId(), transferNo, e);
}
}
@@ -451,6 +478,41 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
return billingTaskMapper.selectPrcBillingTaskList(query);
}
@Override
public PrcOrder retryByOrderId(String orderId)
{
if (StringUtils.isEmpty(orderId))
{
throw new ServiceException("orderId required");
}
PrcOrder order = prcOrderService.selectPrcOrderById(orderId.trim());
if (order == null)
{
throw new ServiceException("prc_order not found");
}
if (order.getBizDate() == null)
{
throw new ServiceException("prc_order bizDate empty (billing time required)");
}
Map<String, Object> row = oracleUpstreamOrderService.findMainOrder(
order.getTransferNo(), order.getOrderNo(), order.getTrackingNo());
if (row == null || row.isEmpty())
{
prcOrderService.updateBillingStatus(order.getOrderId(),
BillTaskSuccessStatus.FAILED.getCode(), BillTaskFailCode.ORACLE_ORDER_NOT_FOUND.getCode());
return prcOrderService.selectPrcOrderById(order.getOrderId());
}
PrcBillingTask transientTask = new PrcBillingTask();
transientTask.setTransferNo(order.getTransferNo());
transientTask.setTrackingNo(order.getTrackingNo());
transientTask.setOrderNo(order.getOrderNo());
transientTask.setCustomerCode(order.getCustomerCode());
transientTask.setBillTime(order.getBizDate());
transientTask.setBillType(BillTaskType.REBILL.getCode());
billFromUpstreamRow(transientTask, row);
return prcOrderService.selectPrcOrderById(order.getOrderId());
}
@Override
public PrcBillingTask retryTask(Long taskId)
{
@@ -39,7 +39,7 @@ import com.bms.system.service.IBmsBizRuleService;
import com.bms.price.domain.PrcIncomeBill;
import com.bms.price.domain.PrcIncomeBillFee;
import com.bms.price.domain.PrcOrderBill;
import com.bms.price.domain.PrcOrderBillExt;
import com.bms.price.domain.PrcOrderExt;
import com.bms.price.domain.PrcPayBill;
import com.bms.price.domain.PrcPayBillFee;
import com.bms.price.domain.PrcSurcharge;
@@ -67,11 +67,11 @@ import com.bms.price.enums.BillBillingFailStatus;
import com.bms.price.enums.TmsOrderBillMatchType;
import com.bms.price.mapper.PrcIncomeBillFeeMapper;
import com.bms.price.mapper.PrcIncomeBillMapper;
import com.bms.price.mapper.PrcOrderBillExtMapper;
import com.bms.price.mapper.PrcOrderExtMapper;
import com.bms.price.mapper.PrcOrderBillMapper;
import com.bms.price.mapper.PrcPayBillFeeMapper;
import com.bms.price.mapper.PrcPayBillMapper;
import com.bms.price.oracle.OracleOrderBillExtFiller;
import com.bms.price.oracle.OracleOrderExtFiller;
import com.bms.price.search.EsBizLogSupport;
import com.bms.price.search.EsLogType;
import com.bms.price.search.IBillSearchStore;
@@ -108,7 +108,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
private SysUserMapper sysUserMapper;
@Autowired
private PrcOrderBillExtMapper orderBillExtMapper;
private PrcOrderExtMapper orderExtMapper;
@Autowired
private PrcIncomeBillFeeMapper incomeBillFeeMapper;
@@ -1255,6 +1255,10 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
}
bill.setBillKey(billKey);
bill.setOrderNo(orderNo);
if (StringUtils.isNotEmpty(request.getOrderId()))
{
bill.setOrderId(request.getOrderId());
}
Long customerId = request.getCustomerId();
if (customerId == null && result != null)
{
@@ -1873,22 +1877,23 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
return r;
}
/** 仅在存在上游 TAB_ORDER 行时写入 prc_order_bill_ext。 */
/** Persist prc_order_ext when upstream TAB_ORDER row exists. Requires bill.orderId (parent wires prc_order first). */
private void persistBillExt(PrcOrderBill bill, java.util.Map<String, Object> upstreamRow)
{
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
if (bill == null || StringUtils.isEmpty(bill.getOrderId()))
{
// skip ext persist until orderId is set (parent will wire order first)
return;
}
if (upstreamRow == null || upstreamRow.isEmpty())
{
return;
}
PrcOrderBillExt ext = new PrcOrderBillExt();
ext.setBillId(bill.getBillId());
PrcOrderExt ext = new PrcOrderExt();
ext.setOrderId(bill.getOrderId());
ext.setOrderNo(bill.getOrderNo());
OracleOrderBillExtFiller.fillFromRow(ext, upstreamRow);
orderBillExtMapper.upsertPrcOrderBillExt(ext);
OracleOrderExtFiller.fillFromRow(ext, upstreamRow);
orderExtMapper.upsertPrcOrderExt(ext);
}
private List<TmsPriceQuoteFeeLine> toIncomeFeeLines(List<PrcIncomeBillFee> fees)
@@ -0,0 +1,108 @@
package com.bms.price.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bms.common.exception.ServiceException;
import com.bms.common.utils.DateUtils;
import com.bms.common.utils.StringUtils;
import com.bms.price.domain.PrcOrder;
import com.bms.price.domain.PrcOrderExt;
import com.bms.price.domain.vo.TmsPriceBillRequest;
import com.bms.price.enums.BillTaskSuccessStatus;
import com.bms.price.mapper.PrcOrderExtMapper;
import com.bms.price.mapper.PrcOrderMapper;
import com.bms.price.oracle.OracleOrderExtFiller;
import com.bms.price.oracle.OracleOrderFiller;
import com.bms.price.service.IPrcOrderService;
@Service
public class PrcOrderServiceImpl implements IPrcOrderService
{
@Autowired
private PrcOrderMapper prcOrderMapper;
@Autowired
private PrcOrderExtMapper prcOrderExtMapper;
@Override
public PrcOrder selectPrcOrderById(String orderId)
{
return prcOrderMapper.selectPrcOrderById(orderId);
}
@Override
public PrcOrder selectPrcOrderByTransferNo(String transferNo)
{
return prcOrderMapper.selectPrcOrderByTransferNo(transferNo);
}
@Override
public List<PrcOrder> selectPrcOrderList(PrcOrder query)
{
return prcOrderMapper.selectPrcOrderList(query);
}
@Override
@Transactional(rollbackFor = Exception.class)
public PrcOrder upsertFromUpstream(Map<String, Object> upstreamRow, TmsPriceBillRequest billReq, Date bizDate)
{
if (upstreamRow == null || upstreamRow.isEmpty())
{
throw new ServiceException("upstream order row required");
}
PrcOrder order = new PrcOrder();
OracleOrderFiller.fillFromRow(order, upstreamRow, billReq, bizDate);
if (StringUtils.isEmpty(order.getTransferNo()))
{
throw new ServiceException("transferNo required for prc_order upsert");
}
if (StringUtils.isEmpty(order.getOrderNo()))
{
throw new ServiceException("orderNo required for prc_order upsert");
}
Date now = DateUtils.getNowDate();
PrcOrder existing = prcOrderMapper.selectPrcOrderByTransferNo(order.getTransferNo());
if (existing != null && StringUtils.isNotEmpty(existing.getOrderId()))
{
order.setOrderId(existing.getOrderId());
order.setUpdateTime(now);
// keep prior status unless caller resets; default WAITING on re-sync before bill
order.setSuccessStatus(BillTaskSuccessStatus.WAITING.getCode());
order.setFailCode(null);
prcOrderMapper.updatePrcOrder(order);
}
else
{
order.setOrderId(UUID.randomUUID().toString());
order.setSuccessStatus(BillTaskSuccessStatus.WAITING.getCode());
order.setFailCode(null);
order.setCreateTime(now);
order.setUpdateTime(now);
prcOrderMapper.insertPrcOrder(order);
}
PrcOrderExt ext = new PrcOrderExt();
ext.setOrderId(order.getOrderId());
ext.setOrderNo(order.getOrderNo());
OracleOrderExtFiller.fillFromRow(ext, upstreamRow);
ext.setCreateTime(now);
ext.setUpdateTime(now);
prcOrderExtMapper.upsertPrcOrderExt(ext);
return order;
}
@Override
public void updateBillingStatus(String orderId, String successStatus, String failCode)
{
if (StringUtils.isEmpty(orderId))
{
return;
}
prcOrderMapper.updateBillingStatus(orderId, successStatus, failCode, null);
}
}
@@ -108,6 +108,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
limit #{limit}
</select>
<delete id="deleteByTransferNo" parameterType="String">
delete from prc_billing_task where transfer_no = #{transferNo}
</delete>
<insert id="insertPrcBillingTask" parameterType="PrcBillingTask" useGeneratedKeys="true" keyProperty="taskId">
insert into prc_billing_task (
transfer_no, tracking_no, order_no, customer_code, bill_type, success_status,
@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="PrcOrderBill" id="PrcOrderBillResult">
<id property="billId" column="bill_id" />
<result property="orderId" column="order_id" />
<result property="billKey" column="bill_key" />
<result property="orderNo" column="order_no" />
<result property="trackingNo" column="tracking_no" />
@@ -84,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectPrcOrderBillVo">
select bill_id, bill_key, order_no, tracking_no, transfer_no,
select bill_id, order_id, bill_key, order_no, tracking_no, transfer_no,
belong_saler, belong_saler_code, settlement_man, settlement_man_code, service_man, service_man_code,
customer_id, customer_code, customer_name,
pieces, actual_weight, receive_weight, volume, volume_weight, pkg_length, pkg_width, pkg_height,
@@ -102,11 +103,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 应收生成专用来源快照:income_total 只汇总当前仍未出账的费用。 -->
<sql id="selectArBillSourceVo">
select p.bill_id, p.bill_key, p.order_no, p.tracking_no, p.transfer_no,
select p.bill_id, p.order_id, p.bill_key, p.order_no, p.tracking_no, p.transfer_no,
p.belong_saler, p.belong_saler_code, p.settlement_man, p.settlement_man_code, p.service_man, p.service_man_code,
p.customer_id, p.customer_code, p.customer_name,
p.pieces, p.actual_weight, p.receive_weight, p.volume, p.volume_weight, p.pkg_length, p.pkg_width, p.pkg_height,
p.shipper_name, p.consignee_name, p.dest_postcode, p.warehouse_code, p.order_time, e.pickup_date, p.order_remark,
p.shipper_name, p.consignee_name, p.dest_postcode, p.warehouse_code, p.order_time, o.pickup_date, p.order_remark,
p.product_code, p.product_name, p.country_code, p.country_name, p.weight, p.biz_date, p.tms_id,
p.match_source, p.match_message, p.price_set_id, p.price_set_code, p.price_set_name,
p.set_type, p.bind_priority, p.customer_priceset_id, p.psv_id, p.psd_id, p.product_country_id,
@@ -121,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.customer_active_status, p.credit_arrears_status, p.refund_status, p.billing_fail_status, p.round_mode,
p.created_by, p.create_time, p.updated_by, p.update_time
from prc_order_bill p
left join prc_order_bill_ext e on e.bill_id = p.bill_id
left join prc_order o on o.order_id = p.order_id
</sql>
<select id="selectPrcOrderBillByOrderNo" parameterType="String" resultMap="PrcOrderBillResult">
@@ -540,7 +541,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertPrcOrderBill" parameterType="PrcOrderBill">
insert into prc_order_bill (
bill_id, bill_key, order_no, tracking_no, transfer_no,
bill_id, order_id, bill_key, order_no, tracking_no, transfer_no,
belong_saler, belong_saler_code, settlement_man, settlement_man_code, service_man, service_man_code,
customer_id, customer_code, customer_name,
pieces, actual_weight, receive_weight, volume, volume_weight, pkg_length, pkg_width, pkg_height,
@@ -554,7 +555,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
customer_active_status, credit_arrears_status, refund_status, billing_fail_status, round_mode,
create_time
) values (
#{billId}, #{billKey}, #{orderNo}, #{trackingNo}, #{transferNo},
#{billId}, #{orderId}, #{billKey}, #{orderNo}, #{trackingNo}, #{transferNo},
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode}, #{serviceMan}, #{serviceManCode},
#{customerId}, #{customerCode}, #{customerName},
#{pieces}, #{actualWeight}, #{receiveWeight}, #{volume}, #{volumeWeight}, #{pkgLength}, #{pkgWidth}, #{pkgHeight},
@@ -573,6 +574,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updatePrcOrderBill" parameterType="PrcOrderBill">
update prc_order_bill
set bill_key = #{billKey},
order_id = #{orderId},
tracking_no = #{trackingNo},
transfer_no = #{transferNo},
belong_saler = #{belongSaler},
@@ -2,10 +2,10 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bms.price.mapper.PrcOrderBillExtMapper">
<mapper namespace="com.bms.price.mapper.PrcOrderExtMapper">
<resultMap type="PrcOrderBillExt" id="PrcOrderBillExtResult">
<id property="billId" column="bill_id" />
<resultMap type="PrcOrderExt" id="PrcOrderExtResult">
<id property="orderId" column="order_id" />
<result property="orderNo" column="order_no" />
<result property="upstreamId" column="upstream_id" />
<result property="lineNo" column="line_no" />
@@ -63,7 +63,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="importState" column="import_state" />
<result property="importCountry" column="import_country" />
<result property="buyerid" column="buyerid" />
<result property="orderStatus" column="order_status" />
<result property="createAt" column="create_at" />
<result property="payType" column="pay_type" />
<result property="lineCode" column="line_code" />
@@ -71,7 +70,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="productType" column="product_type" />
<result property="lineType" column="line_type" />
<result property="cargoName" column="cargo_name" />
<result property="productFloorCode" column="product_floor_code" />
<result property="orderInsurance" column="order_insurance" />
<result property="productSumPrice" column="product_sum_price" />
<result property="productSum" column="product_sum" />
@@ -81,7 +79,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="productFloor" column="product_floor" />
<result property="latestTrajectory" column="latest_trajectory" />
<result property="wayBill" column="way_bill" />
<result property="pickupDate" column="pickup_date" />
<result property="blBaging" column="bl_baging" />
<result property="blPickup" column="bl_pickup" />
<result property="bagDate" column="bag_date" />
@@ -149,7 +146,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="trackQueryTime" column="track_query_time" />
<result property="airConfirmTime" column="air_confirm_time" />
<result property="packageType" column="package_type" />
<result property="dimensionalWeightFactor" column="dimensional_weight_factor" />
<result property="updateBy" column="update_by" />
<result property="customerPickupSite" column="customer_pickup_site" />
<result property="barcodeNumber" column="barcode_number" />
@@ -181,26 +177,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectPrcOrderBillExtVo">
select bill_id, order_no, upstream_id, line_no, package_num, actual_volume, cp_type, consignee_mobile, order_returnsign, trade_type, duty_type, battery_type, consignee_companyname, consignee_address, consignee_telephone, consignee_state, consignee_city, consignee_suburb, consignee_passportno, consignee_email, consignee_taxno, consignee_taxnotype, consignee_taxnocountry, consignee_streetno, consignee_doorno, shipper_taxnotype, shipper_taxno, shipper_taxnocountry, customer_id, product_imagepath, order_transactionurl, order_cargoamount, cargo_type, shipper_companyname, shipper_address1, shipper_address2, shipper_address3, shipper_city, shipper_state, shipper_postcode, shipper_country, shipper_telephone, shipper_suburb, shipper_email, shipper_passportno, import_code, import_name, import_companyname, import_address, import_address2, import_address3, import_telephone, import_email, import_postcode, import_city, import_state, import_country, buyerid, order_status, create_at, pay_type, line_code, line_name, product_type, line_type, cargo_name, product_floor_code, order_insurance, product_sum_price, product_sum, shipper_doorno, tariff_payment_account, topayment, product_floor, latest_trajectory, way_bill, pickup_date, bl_baging, bl_pickup, bag_date, org_order_status, status_description, zz_date, shipping_date, order_type, receiving_photo, freight, is_receivable, is_meet, bill_no_receivable, bill_no_meet, country_eingth_name, is_receivable_fee, settlement_fee, product_id, service_freight, is_pay_fee, has_added_surcharge, yf_fee, yf_totail_fee, trajectory_status, cargo_type_name, service_code, three_code, volume_height_old, volume_length_old, volume_width_old, register_man_old, bag_no_old, air_no_old, box_sizi_old, baging_man_old, retrieval_man_old, invoice_amount_old, invoice_title_old, invoice_weight_old, sku_old, hs_code_old, register_date_old, invoice_currency_old, trajectory_sub_state, sign_in_time, warehouse_time, declaration_time, release_time, station_time, takeoff_time, landing_time, clearance_and_delivery_time, supplier_name, credit_code, other_id, platform_code, sync_shipment_status, update_weight, other_bag_no, bag_flag, online_time, outbound_time, air_confirm_date, shipment_type, track_query_time, air_confirm_time, package_type, dimensional_weight_factor, update_by, customer_pickup_site, barcode_number, tracking_reflect_status, remote_postcode, clearance_time, arrive_stock_time, departure_time, first_deliver_time, hs_code_tax_count, hs_code_tax_amount, hs_code_tax_currency, invoice_url, clearance_no, push_weight, internal_check_time, air_delay_time, first_landing_time, second_takeoff_time, des_port_check_time, stay_remark, miss_box_remark, product_channel_id, customer_track_id, register_site, package_type_financial, mrn, create_time, update_time
from prc_order_bill_ext
<sql id="selectPrcOrderExtVo">
select order_id, order_no, upstream_id, line_no, package_num, actual_volume, cp_type, consignee_mobile, order_returnsign, trade_type, duty_type, battery_type, consignee_companyname, consignee_address, consignee_telephone, consignee_state, consignee_city, consignee_suburb, consignee_passportno, consignee_email, consignee_taxno, consignee_taxnotype, consignee_taxnocountry, consignee_streetno, consignee_doorno, shipper_taxnotype, shipper_taxno, shipper_taxnocountry, customer_id, product_imagepath, order_transactionurl, order_cargoamount, cargo_type, shipper_companyname, shipper_address1, shipper_address2, shipper_address3, shipper_city, shipper_state, shipper_postcode, shipper_country, shipper_telephone, shipper_suburb, shipper_email, shipper_passportno, import_code, import_name, import_companyname, import_address, import_address2, import_address3, import_telephone, import_email, import_postcode, import_city, import_state, import_country, buyerid, create_at, pay_type, line_code, line_name, product_type, line_type, cargo_name, order_insurance, product_sum_price, product_sum, shipper_doorno, tariff_payment_account, topayment, product_floor, latest_trajectory, way_bill, bl_baging, bl_pickup, bag_date, org_order_status, status_description, zz_date, shipping_date, order_type, receiving_photo, freight, is_receivable, is_meet, bill_no_receivable, bill_no_meet, country_eingth_name, is_receivable_fee, settlement_fee, product_id, service_freight, is_pay_fee, has_added_surcharge, yf_fee, yf_totail_fee, trajectory_status, cargo_type_name, service_code, three_code, volume_height_old, volume_length_old, volume_width_old, register_man_old, bag_no_old, air_no_old, box_sizi_old, baging_man_old, retrieval_man_old, invoice_amount_old, invoice_title_old, invoice_weight_old, sku_old, hs_code_old, register_date_old, invoice_currency_old, trajectory_sub_state, sign_in_time, warehouse_time, declaration_time, release_time, station_time, takeoff_time, landing_time, clearance_and_delivery_time, supplier_name, credit_code, other_id, platform_code, sync_shipment_status, update_weight, other_bag_no, bag_flag, online_time, outbound_time, air_confirm_date, shipment_type, track_query_time, air_confirm_time, package_type, update_by, customer_pickup_site, barcode_number, tracking_reflect_status, remote_postcode, clearance_time, arrive_stock_time, departure_time, first_deliver_time, hs_code_tax_count, hs_code_tax_amount, hs_code_tax_currency, invoice_url, clearance_no, push_weight, internal_check_time, air_delay_time, first_landing_time, second_takeoff_time, des_port_check_time, stay_remark, miss_box_remark, product_channel_id, customer_track_id, register_site, package_type_financial, mrn, create_time, update_time
from prc_order_ext
</sql>
<select id="selectByBillId" parameterType="String" resultMap="PrcOrderBillExtResult">
<include refid="selectPrcOrderBillExtVo"/>
where bill_id = #{billId}
<select id="selectByOrderId" parameterType="String" resultMap="PrcOrderExtResult">
<include refid="selectPrcOrderExtVo"/>
where order_id = #{orderId}
</select>
<select id="selectByOrderNo" parameterType="String" resultMap="PrcOrderBillExtResult">
<include refid="selectPrcOrderBillExtVo"/>
<select id="selectByOrderNo" parameterType="String" resultMap="PrcOrderExtResult">
<include refid="selectPrcOrderExtVo"/>
where order_no = #{orderNo}
</select>
<insert id="insertPrcOrderBillExt" parameterType="PrcOrderBillExt">
insert into prc_order_bill_ext (
bill_id, order_no, upstream_id, line_no, package_num, actual_volume, cp_type, consignee_mobile, order_returnsign, trade_type, duty_type, battery_type, consignee_companyname, consignee_address, consignee_telephone, consignee_state, consignee_city, consignee_suburb, consignee_passportno, consignee_email, consignee_taxno, consignee_taxnotype, consignee_taxnocountry, consignee_streetno, consignee_doorno, shipper_taxnotype, shipper_taxno, shipper_taxnocountry, customer_id, product_imagepath, order_transactionurl, order_cargoamount, cargo_type, shipper_companyname, shipper_address1, shipper_address2, shipper_address3, shipper_city, shipper_state, shipper_postcode, shipper_country, shipper_telephone, shipper_suburb, shipper_email, shipper_passportno, import_code, import_name, import_companyname, import_address, import_address2, import_address3, import_telephone, import_email, import_postcode, import_city, import_state, import_country, buyerid, order_status, create_at, pay_type, line_code, line_name, product_type, line_type, cargo_name, product_floor_code, order_insurance, product_sum_price, product_sum, shipper_doorno, tariff_payment_account, topayment, product_floor, latest_trajectory, way_bill, pickup_date, bl_baging, bl_pickup, bag_date, org_order_status, status_description, zz_date, shipping_date, order_type, receiving_photo, freight, is_receivable, is_meet, bill_no_receivable, bill_no_meet, country_eingth_name, is_receivable_fee, settlement_fee, product_id, service_freight, is_pay_fee, has_added_surcharge, yf_fee, yf_totail_fee, trajectory_status, cargo_type_name, service_code, three_code, volume_height_old, volume_length_old, volume_width_old, register_man_old, bag_no_old, air_no_old, box_sizi_old, baging_man_old, retrieval_man_old, invoice_amount_old, invoice_title_old, invoice_weight_old, sku_old, hs_code_old, register_date_old, invoice_currency_old, trajectory_sub_state, sign_in_time, warehouse_time, declaration_time, release_time, station_time, takeoff_time, landing_time, clearance_and_delivery_time, supplier_name, credit_code, other_id, platform_code, sync_shipment_status, update_weight, other_bag_no, bag_flag, online_time, outbound_time, air_confirm_date, shipment_type, track_query_time, air_confirm_time, package_type, dimensional_weight_factor, update_by, customer_pickup_site, barcode_number, tracking_reflect_status, remote_postcode, clearance_time, arrive_stock_time, departure_time, first_deliver_time, hs_code_tax_count, hs_code_tax_amount, hs_code_tax_currency, invoice_url, clearance_no, push_weight, internal_check_time, air_delay_time, first_landing_time, second_takeoff_time, des_port_check_time, stay_remark, miss_box_remark, product_channel_id, customer_track_id, register_site, package_type_financial, mrn, create_time
<insert id="insertPrcOrderExt" parameterType="PrcOrderExt">
insert into prc_order_ext (
order_id, order_no, upstream_id, line_no, package_num, actual_volume, cp_type, consignee_mobile, order_returnsign, trade_type, duty_type, battery_type, consignee_companyname, consignee_address, consignee_telephone, consignee_state, consignee_city, consignee_suburb, consignee_passportno, consignee_email, consignee_taxno, consignee_taxnotype, consignee_taxnocountry, consignee_streetno, consignee_doorno, shipper_taxnotype, shipper_taxno, shipper_taxnocountry, customer_id, product_imagepath, order_transactionurl, order_cargoamount, cargo_type, shipper_companyname, shipper_address1, shipper_address2, shipper_address3, shipper_city, shipper_state, shipper_postcode, shipper_country, shipper_telephone, shipper_suburb, shipper_email, shipper_passportno, import_code, import_name, import_companyname, import_address, import_address2, import_address3, import_telephone, import_email, import_postcode, import_city, import_state, import_country, buyerid, create_at, pay_type, line_code, line_name, product_type, line_type, cargo_name, order_insurance, product_sum_price, product_sum, shipper_doorno, tariff_payment_account, topayment, product_floor, latest_trajectory, way_bill, bl_baging, bl_pickup, bag_date, org_order_status, status_description, zz_date, shipping_date, order_type, receiving_photo, freight, is_receivable, is_meet, bill_no_receivable, bill_no_meet, country_eingth_name, is_receivable_fee, settlement_fee, product_id, service_freight, is_pay_fee, has_added_surcharge, yf_fee, yf_totail_fee, trajectory_status, cargo_type_name, service_code, three_code, volume_height_old, volume_length_old, volume_width_old, register_man_old, bag_no_old, air_no_old, box_sizi_old, baging_man_old, retrieval_man_old, invoice_amount_old, invoice_title_old, invoice_weight_old, sku_old, hs_code_old, register_date_old, invoice_currency_old, trajectory_sub_state, sign_in_time, warehouse_time, declaration_time, release_time, station_time, takeoff_time, landing_time, clearance_and_delivery_time, supplier_name, credit_code, other_id, platform_code, sync_shipment_status, update_weight, other_bag_no, bag_flag, online_time, outbound_time, air_confirm_date, shipment_type, track_query_time, air_confirm_time, package_type, update_by, customer_pickup_site, barcode_number, tracking_reflect_status, remote_postcode, clearance_time, arrive_stock_time, departure_time, first_deliver_time, hs_code_tax_count, hs_code_tax_amount, hs_code_tax_currency, invoice_url, clearance_no, push_weight, internal_check_time, air_delay_time, first_landing_time, second_takeoff_time, des_port_check_time, stay_remark, miss_box_remark, product_channel_id, customer_track_id, register_site, package_type_financial, mrn, create_time
) values (
#{billId},
#{orderId},
#{orderNo},
#{upstreamId},
#{lineNo},
@@ -258,7 +254,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{importState},
#{importCountry},
#{buyerid},
#{orderStatus},
#{createAt},
#{payType},
#{lineCode},
@@ -266,7 +261,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{productType},
#{lineType},
#{cargoName},
#{productFloorCode},
#{orderInsurance},
#{productSumPrice},
#{productSum},
@@ -276,7 +270,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{productFloor},
#{latestTrajectory},
#{wayBill},
#{pickupDate},
#{blBaging},
#{blPickup},
#{bagDate},
@@ -344,7 +337,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{trackQueryTime},
#{airConfirmTime},
#{packageType},
#{dimensionalWeightFactor},
#{updateBy},
#{customerPickupSite},
#{barcodeNumber},
@@ -376,11 +368,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</insert>
<insert id="upsertPrcOrderBillExt" parameterType="PrcOrderBillExt">
insert into prc_order_bill_ext (
bill_id, order_no, upstream_id, line_no, package_num, actual_volume, cp_type, consignee_mobile, order_returnsign, trade_type, duty_type, battery_type, consignee_companyname, consignee_address, consignee_telephone, consignee_state, consignee_city, consignee_suburb, consignee_passportno, consignee_email, consignee_taxno, consignee_taxnotype, consignee_taxnocountry, consignee_streetno, consignee_doorno, shipper_taxnotype, shipper_taxno, shipper_taxnocountry, customer_id, product_imagepath, order_transactionurl, order_cargoamount, cargo_type, shipper_companyname, shipper_address1, shipper_address2, shipper_address3, shipper_city, shipper_state, shipper_postcode, shipper_country, shipper_telephone, shipper_suburb, shipper_email, shipper_passportno, import_code, import_name, import_companyname, import_address, import_address2, import_address3, import_telephone, import_email, import_postcode, import_city, import_state, import_country, buyerid, order_status, create_at, pay_type, line_code, line_name, product_type, line_type, cargo_name, product_floor_code, order_insurance, product_sum_price, product_sum, shipper_doorno, tariff_payment_account, topayment, product_floor, latest_trajectory, way_bill, pickup_date, bl_baging, bl_pickup, bag_date, org_order_status, status_description, zz_date, shipping_date, order_type, receiving_photo, freight, is_receivable, is_meet, bill_no_receivable, bill_no_meet, country_eingth_name, is_receivable_fee, settlement_fee, product_id, service_freight, is_pay_fee, has_added_surcharge, yf_fee, yf_totail_fee, trajectory_status, cargo_type_name, service_code, three_code, volume_height_old, volume_length_old, volume_width_old, register_man_old, bag_no_old, air_no_old, box_sizi_old, baging_man_old, retrieval_man_old, invoice_amount_old, invoice_title_old, invoice_weight_old, sku_old, hs_code_old, register_date_old, invoice_currency_old, trajectory_sub_state, sign_in_time, warehouse_time, declaration_time, release_time, station_time, takeoff_time, landing_time, clearance_and_delivery_time, supplier_name, credit_code, other_id, platform_code, sync_shipment_status, update_weight, other_bag_no, bag_flag, online_time, outbound_time, air_confirm_date, shipment_type, track_query_time, air_confirm_time, package_type, dimensional_weight_factor, update_by, customer_pickup_site, barcode_number, tracking_reflect_status, remote_postcode, clearance_time, arrive_stock_time, departure_time, first_deliver_time, hs_code_tax_count, hs_code_tax_amount, hs_code_tax_currency, invoice_url, clearance_no, push_weight, internal_check_time, air_delay_time, first_landing_time, second_takeoff_time, des_port_check_time, stay_remark, miss_box_remark, product_channel_id, customer_track_id, register_site, package_type_financial, mrn, create_time
<insert id="upsertPrcOrderExt" parameterType="PrcOrderExt">
insert into prc_order_ext (
order_id, order_no, upstream_id, line_no, package_num, actual_volume, cp_type, consignee_mobile, order_returnsign, trade_type, duty_type, battery_type, consignee_companyname, consignee_address, consignee_telephone, consignee_state, consignee_city, consignee_suburb, consignee_passportno, consignee_email, consignee_taxno, consignee_taxnotype, consignee_taxnocountry, consignee_streetno, consignee_doorno, shipper_taxnotype, shipper_taxno, shipper_taxnocountry, customer_id, product_imagepath, order_transactionurl, order_cargoamount, cargo_type, shipper_companyname, shipper_address1, shipper_address2, shipper_address3, shipper_city, shipper_state, shipper_postcode, shipper_country, shipper_telephone, shipper_suburb, shipper_email, shipper_passportno, import_code, import_name, import_companyname, import_address, import_address2, import_address3, import_telephone, import_email, import_postcode, import_city, import_state, import_country, buyerid, create_at, pay_type, line_code, line_name, product_type, line_type, cargo_name, order_insurance, product_sum_price, product_sum, shipper_doorno, tariff_payment_account, topayment, product_floor, latest_trajectory, way_bill, bl_baging, bl_pickup, bag_date, org_order_status, status_description, zz_date, shipping_date, order_type, receiving_photo, freight, is_receivable, is_meet, bill_no_receivable, bill_no_meet, country_eingth_name, is_receivable_fee, settlement_fee, product_id, service_freight, is_pay_fee, has_added_surcharge, yf_fee, yf_totail_fee, trajectory_status, cargo_type_name, service_code, three_code, volume_height_old, volume_length_old, volume_width_old, register_man_old, bag_no_old, air_no_old, box_sizi_old, baging_man_old, retrieval_man_old, invoice_amount_old, invoice_title_old, invoice_weight_old, sku_old, hs_code_old, register_date_old, invoice_currency_old, trajectory_sub_state, sign_in_time, warehouse_time, declaration_time, release_time, station_time, takeoff_time, landing_time, clearance_and_delivery_time, supplier_name, credit_code, other_id, platform_code, sync_shipment_status, update_weight, other_bag_no, bag_flag, online_time, outbound_time, air_confirm_date, shipment_type, track_query_time, air_confirm_time, package_type, update_by, customer_pickup_site, barcode_number, tracking_reflect_status, remote_postcode, clearance_time, arrive_stock_time, departure_time, first_deliver_time, hs_code_tax_count, hs_code_tax_amount, hs_code_tax_currency, invoice_url, clearance_no, push_weight, internal_check_time, air_delay_time, first_landing_time, second_takeoff_time, des_port_check_time, stay_remark, miss_box_remark, product_channel_id, customer_track_id, register_site, package_type_financial, mrn, create_time
) values (
#{billId},
#{orderId},
#{orderNo},
#{upstreamId},
#{lineNo},
@@ -438,7 +430,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{importState},
#{importCountry},
#{buyerid},
#{orderStatus},
#{createAt},
#{payType},
#{lineCode},
@@ -446,7 +437,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{productType},
#{lineType},
#{cargoName},
#{productFloorCode},
#{orderInsurance},
#{productSumPrice},
#{productSum},
@@ -456,7 +446,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{productFloor},
#{latestTrajectory},
#{wayBill},
#{pickupDate},
#{blBaging},
#{blPickup},
#{bagDate},
@@ -524,7 +513,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{trackQueryTime},
#{airConfirmTime},
#{packageType},
#{dimensionalWeightFactor},
#{updateBy},
#{customerPickupSite},
#{barcodeNumber},
@@ -612,7 +600,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
import_state = values(import_state),
import_country = values(import_country),
buyerid = values(buyerid),
order_status = values(order_status),
create_at = values(create_at),
pay_type = values(pay_type),
line_code = values(line_code),
@@ -620,7 +607,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
product_type = values(product_type),
line_type = values(line_type),
cargo_name = values(cargo_name),
product_floor_code = values(product_floor_code),
order_insurance = values(order_insurance),
product_sum_price = values(product_sum_price),
product_sum = values(product_sum),
@@ -630,7 +616,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
product_floor = values(product_floor),
latest_trajectory = values(latest_trajectory),
way_bill = values(way_bill),
pickup_date = values(pickup_date),
bl_baging = values(bl_baging),
bl_pickup = values(bl_pickup),
bag_date = values(bag_date),
@@ -698,7 +683,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
track_query_time = values(track_query_time),
air_confirm_time = values(air_confirm_time),
package_type = values(package_type),
dimensional_weight_factor = values(dimensional_weight_factor),
update_by = values(update_by),
customer_pickup_site = values(customer_pickup_site),
barcode_number = values(barcode_number),
@@ -0,0 +1,256 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bms.price.mapper.PrcOrderMapper">
<resultMap type="PrcOrder" id="PrcOrderResult">
<id property="orderId" column="order_id" />
<result property="orderNo" column="order_no" />
<result property="trackingNo" column="tracking_no" />
<result property="transferNo" column="transfer_no" />
<result property="trackId" column="track_id" />
<result property="belongSaler" column="belong_saler" />
<result property="belongSalerCode" column="belong_saler_code" />
<result property="settlementMan" column="settlement_man" />
<result property="settlementManCode" column="settlement_man_code" />
<result property="serviceMan" column="service_man" />
<result property="serviceManCode" column="service_man_code" />
<result property="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
<result property="pieces" column="pieces" />
<result property="actualWeight" column="actual_weight" />
<result property="weight" column="weight" />
<result property="dimensionalWeightFactor" column="dimensional_weight_factor" />
<result property="volume" column="volume" />
<result property="volumeWeight" column="volume_weight" />
<result property="pkgLength" column="pkg_length" />
<result property="pkgWidth" column="pkg_width" />
<result property="pkgHeight" column="pkg_height" />
<result property="shipperName" column="shipper_name" />
<result property="consigneeName" column="consignee_name" />
<result property="consigneePostcode" column="consignee_postcode" />
<result property="warehouseCode" column="warehouse_code" />
<result property="orderTime" column="order_time" />
<result property="orderRemark" column="order_remark" />
<result property="productCode" column="product_code" />
<result property="productName" column="product_name" />
<result property="productFloorCode" column="product_floor_code" />
<result property="countryCode" column="country_code" />
<result property="countryName" column="country_name" />
<result property="orderStatus" column="order_status" />
<result property="pickupDate" column="pickup_date" />
<result property="bizDate" column="biz_date" />
<result property="successStatus" column="success_status" />
<result property="failCode" column="fail_code" />
<result property="createBy" column="created_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="updated_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectPrcOrderVo">
select order_id, order_no, tracking_no, transfer_no, track_id,
belong_saler, belong_saler_code, settlement_man, settlement_man_code, service_man, service_man_code,
customer_code, customer_name, pieces, actual_weight, weight, dimensional_weight_factor,
volume, volume_weight, pkg_length, pkg_width, pkg_height,
shipper_name, consignee_name, consignee_postcode, warehouse_code,
order_time, order_remark, product_code, product_name, product_floor_code,
country_code, country_name, order_status, pickup_date, biz_date,
success_status, fail_code, created_by, create_time, updated_by, update_time
from prc_order
</sql>
<select id="selectPrcOrderById" parameterType="String" resultMap="PrcOrderResult">
<include refid="selectPrcOrderVo"/>
where order_id = #{orderId}
</select>
<select id="selectPrcOrderByTransferNo" parameterType="String" resultMap="PrcOrderResult">
<include refid="selectPrcOrderVo"/>
where transfer_no = #{transferNo}
</select>
<select id="selectPrcOrderByOrderNo" parameterType="String" resultMap="PrcOrderResult">
<include refid="selectPrcOrderVo"/>
where order_no = #{orderNo}
</select>
<select id="selectPrcOrderList" parameterType="PrcOrder" resultMap="PrcOrderResult">
<include refid="selectPrcOrderVo"/>
<where>
<if test="transferNo != null and transferNo != ''">
AND transfer_no like concat('%', #{transferNo}, '%')
</if>
<if test="transferNos != null and transferNos.size() &gt; 0">
AND transfer_no in
<foreach collection="transferNos" item="n" open="(" separator="," close=")">#{n}</foreach>
</if>
<if test="trackingNo != null and trackingNo != ''">
AND tracking_no like concat('%', #{trackingNo}, '%')
</if>
<if test="orderNo != null and orderNo != ''">
AND order_no like concat('%', #{orderNo}, '%')
</if>
<if test="customerCode != null and customerCode != ''">
AND customer_code like concat('%', #{customerCode}, '%')
</if>
<if test="successStatus != null and successStatus != ''">
AND success_status = #{successStatus}
</if>
<if test="failCode != null and failCode != ''">
AND fail_code = #{failCode}
</if>
<if test="failCodes != null and failCodes.size() &gt; 0">
AND fail_code in
<foreach collection="failCodes" item="c" open="(" separator="," close=")">#{c}</foreach>
</if>
<if test="params.beginTime != null and params.beginTime != ''">
AND date_format(biz_date,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''">
AND date_format(biz_date,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</if>
</where>
order by create_time desc, order_id desc
</select>
<insert id="insertPrcOrder" parameterType="PrcOrder">
insert into prc_order (
order_id, order_no, tracking_no, transfer_no, track_id,
belong_saler, belong_saler_code, settlement_man, settlement_man_code, service_man, service_man_code,
customer_code, customer_name, pieces, actual_weight, weight, dimensional_weight_factor,
volume, volume_weight, pkg_length, pkg_width, pkg_height,
shipper_name, consignee_name, consignee_postcode, warehouse_code,
order_time, order_remark, product_code, product_name, product_floor_code,
country_code, country_name, order_status, pickup_date, biz_date,
success_status, fail_code, created_by, create_time, updated_by, update_time
) values (
#{orderId}, #{orderNo}, #{trackingNo}, #{transferNo}, #{trackId},
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode}, #{serviceMan}, #{serviceManCode},
#{customerCode}, #{customerName}, #{pieces}, #{actualWeight}, #{weight}, #{dimensionalWeightFactor},
#{volume}, #{volumeWeight}, #{pkgLength}, #{pkgWidth}, #{pkgHeight},
#{shipperName}, #{consigneeName}, #{consigneePostcode}, #{warehouseCode},
#{orderTime}, #{orderRemark}, #{productCode}, #{productName}, #{productFloorCode},
#{countryCode}, #{countryName}, #{orderStatus}, #{pickupDate}, #{bizDate},
#{successStatus}, #{failCode}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}
)
</insert>
<update id="updatePrcOrder" parameterType="PrcOrder">
update prc_order
<set>
order_no = #{orderNo},
tracking_no = #{trackingNo},
track_id = #{trackId},
belong_saler = #{belongSaler},
belong_saler_code = #{belongSalerCode},
settlement_man = #{settlementMan},
settlement_man_code = #{settlementManCode},
service_man = #{serviceMan},
service_man_code = #{serviceManCode},
customer_code = #{customerCode},
customer_name = #{customerName},
pieces = #{pieces},
actual_weight = #{actualWeight},
weight = #{weight},
dimensional_weight_factor = #{dimensionalWeightFactor},
volume = #{volume},
volume_weight = #{volumeWeight},
pkg_length = #{pkgLength},
pkg_width = #{pkgWidth},
pkg_height = #{pkgHeight},
shipper_name = #{shipperName},
consignee_name = #{consigneeName},
consignee_postcode = #{consigneePostcode},
warehouse_code = #{warehouseCode},
order_time = #{orderTime},
order_remark = #{orderRemark},
product_code = #{productCode},
product_name = #{productName},
product_floor_code = #{productFloorCode},
country_code = #{countryCode},
country_name = #{countryName},
order_status = #{orderStatus},
pickup_date = #{pickupDate},
biz_date = #{bizDate},
success_status = #{successStatus},
fail_code = #{failCode},
updated_by = #{updateBy},
update_time = #{updateTime}
</set>
where order_id = #{orderId}
</update>
<!-- Upsert by unique transfer_no: insert new UUID or overwrite all upstream fields -->
<insert id="upsertPrcOrderByTransferNo" parameterType="PrcOrder">
insert into prc_order (
order_id, order_no, tracking_no, transfer_no, track_id,
belong_saler, belong_saler_code, settlement_man, settlement_man_code, service_man, service_man_code,
customer_code, customer_name, pieces, actual_weight, weight, dimensional_weight_factor,
volume, volume_weight, pkg_length, pkg_width, pkg_height,
shipper_name, consignee_name, consignee_postcode, warehouse_code,
order_time, order_remark, product_code, product_name, product_floor_code,
country_code, country_name, order_status, pickup_date, biz_date,
success_status, fail_code, created_by, create_time, updated_by, update_time
) values (
#{orderId}, #{orderNo}, #{trackingNo}, #{transferNo}, #{trackId},
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode}, #{serviceMan}, #{serviceManCode},
#{customerCode}, #{customerName}, #{pieces}, #{actualWeight}, #{weight}, #{dimensionalWeightFactor},
#{volume}, #{volumeWeight}, #{pkgLength}, #{pkgWidth}, #{pkgHeight},
#{shipperName}, #{consigneeName}, #{consigneePostcode}, #{warehouseCode},
#{orderTime}, #{orderRemark}, #{productCode}, #{productName}, #{productFloorCode},
#{countryCode}, #{countryName}, #{orderStatus}, #{pickupDate}, #{bizDate},
#{successStatus}, #{failCode}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}
)
on duplicate key update
order_id = values(order_id),
order_no = values(order_no),
tracking_no = values(tracking_no),
track_id = values(track_id),
belong_saler = values(belong_saler),
belong_saler_code = values(belong_saler_code),
settlement_man = values(settlement_man),
settlement_man_code = values(settlement_man_code),
service_man = values(service_man),
service_man_code = values(service_man_code),
customer_code = values(customer_code),
customer_name = values(customer_name),
pieces = values(pieces),
actual_weight = values(actual_weight),
weight = values(weight),
dimensional_weight_factor = values(dimensional_weight_factor),
volume = values(volume),
volume_weight = values(volume_weight),
pkg_length = values(pkg_length),
pkg_width = values(pkg_width),
pkg_height = values(pkg_height),
shipper_name = values(shipper_name),
consignee_name = values(consignee_name),
consignee_postcode = values(consignee_postcode),
warehouse_code = values(warehouse_code),
order_time = values(order_time),
order_remark = values(order_remark),
product_code = values(product_code),
product_name = values(product_name),
product_floor_code = values(product_floor_code),
country_code = values(country_code),
country_name = values(country_name),
order_status = values(order_status),
pickup_date = values(pickup_date),
biz_date = values(biz_date),
success_status = values(success_status),
fail_code = values(fail_code),
updated_by = values(updated_by),
update_time = values(update_time)
</insert>
<update id="updateBillingStatus">
update prc_order
set success_status = #{successStatus},
fail_code = #{failCode},
updated_by = #{updateBy},
update_time = now()
where order_id = #{orderId}
</update>
</mapper>
+267
View File
@@ -0,0 +1,267 @@
-- ------------------------------------------------------------
-- REVIEW DRAFT: prc_order + rename ext -> prc_order_ext
-- Confirm schema before app code changes.
--
-- Target model:
-- prc_billing_task --transfer_no--> TAB_ORDER
-- -> upsert prc_order (UK transfer_no), delete task by transfer_no
-- -> prc_order 1:1 prc_order_ext (PK/FK = order_id)
-- -> prc_order_bill keeps bill_id; adds order_id + transfer_no
--
-- Naming:
-- order_id = BMS UUID PK (same rule as bill_id)
-- old prc_order_bill_ext renamed to prc_order_ext
-- columns moved to prc_order are DROPped from prc_order_ext
-- ------------------------------------------------------------
SET NAMES utf8mb4;
-- ============================================================
-- 1) New table: prc_order
-- ============================================================
-- TAB_ORDER mapping (core):
-- ORDER_ID -> order_no
-- ORG_ORDER_ID -> tracking_no
-- TRANSFER_ORDER_ID -> transfer_no
-- TRACK_ID -> track_id
-- CUSTOMER_CODE/NAME -> customer_code/name
-- PRODUCT_CODE/NAME -> product_code/name
-- PRODUCT_FLOOR_CODE -> product_floor_code
-- COUNTRY / COUNTRY_NAME -> country_code / country_name
-- CONSIGNEE_POSTCODE -> consignee_postcode
-- CONSIGNEE_NAME -> consignee_name
-- SHIPPER_NAME -> shipper_name
-- REGISTER_SITE_CODE -> warehouse_code
-- ORDER_PIECE/PACKAGE_NUM -> pieces
-- ACTUAL_WEIGHT -> actual_weight
-- VOLUME -> volume
-- VOLUME_WEIGHT -> volume_weight
-- LENGTH/WIDTH/HEIGHT -> pkg_length/width/height
-- DIMENSIONAL_WEIGHT_FACTOR -> dimensional_weight_factor
-- WEIGHT -> weight
-- BELONG_SALER* -> belong_saler / belong_saler_code
-- SETTLEMENT_MAN* -> settlement_man / settlement_man_code
-- SERVICE_MAN* -> service_man / service_man_code
-- TRACK_REMARK/... -> order_remark
-- ORDER_STATUS -> order_status
-- PICKUP_DATE -> pickup_date
-- CREATE_DATE -> order_time
-- (task.bill_time) -> biz_date
-- ============================================================
CREATE TABLE IF NOT EXISTS `prc_order` (
`order_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单ID(BMS主键,规则同 bill_id:UUID)',
`order_no` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户订单号(TAB_ORDER.ORDER_ID)',
`tracking_no` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '运单号(TAB_ORDER.ORG_ORDER_ID)',
`transfer_no` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '转单号(TAB_ORDER.TRANSFER_ORDER_ID,唯一)',
`track_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '轨迹ID(TAB_ORDER.TRACK_ID)',
`belong_saler` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属销售员(TAB_ORDER.BELONG_SALER*)',
`belong_saler_code` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '销售员编码(TAB_ORDER.BELONG_SALER_CODE)',
`settlement_man` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '结算员(TAB_ORDER.SETTLEMENT_MAN*)',
`settlement_man_code` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '结算员编码(TAB_ORDER.SETTLEMENT_MAN_CODE)',
`service_man` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '客服员(TAB_ORDER.SERVICE_MAN*)',
`service_man_code` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '客服员编码',
`customer_code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '客户代码(TAB_ORDER.CUSTOMER_CODE)',
`customer_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '客户名称(TAB_ORDER.CUSTOMER_NAME)',
`pieces` int(11) DEFAULT NULL COMMENT '件数(TAB_ORDER.ORDER_PIECE/PACKAGE_NUM)',
`actual_weight` decimal(10,3) DEFAULT NULL COMMENT '实际重量KG(TAB_ORDER.ACTUAL_WEIGHT)',
`weight` decimal(10,3) DEFAULT NULL COMMENT '实重/收货重KG(TAB_ORDER.WEIGHT)',
`dimensional_weight_factor` decimal(10,3) DEFAULT NULL COMMENT '计费重KG(TAB_ORDER.DIMENSIONAL_WEIGHT_FACTOR)',
`volume` decimal(12,4) DEFAULT NULL COMMENT '体积m3(TAB_ORDER.VOLUME)',
`volume_weight` decimal(10,3) DEFAULT NULL COMMENT '体积重KG(TAB_ORDER.VOLUME_WEIGHT)',
`pkg_length` decimal(10,2) DEFAULT NULL COMMENT '长CM(TAB_ORDER.LENGTH)',
`pkg_width` decimal(10,2) DEFAULT NULL COMMENT '宽CM(TAB_ORDER.WIDTH)',
`pkg_height` decimal(10,2) DEFAULT NULL COMMENT '高CM(TAB_ORDER.HEIGHT)',
`shipper_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '发件人(TAB_ORDER.SHIPPER_NAME)',
`consignee_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '收件人(TAB_ORDER.CONSIGNEE_NAME)',
`consignee_postcode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '收件人邮编(TAB_ORDER.CONSIGNEE_POSTCODE)',
`warehouse_code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '仓库(TAB_ORDER.REGISTER_SITE_CODE)',
`order_time` datetime DEFAULT NULL COMMENT '下单时间(TAB_ORDER.CREATE_DATE)',
`order_remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '订单备注(TAB_ORDER.TRACK_REMARK/等)',
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '产品代码(TAB_ORDER.PRODUCT_CODE)',
`product_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '产品名称(TAB_ORDER.PRODUCT_NAME)',
`product_floor_code` text COLLATE utf8mb4_unicode_ci COMMENT '产品底级/渠道编码(TAB_ORDER.PRODUCT_FLOOR_CODE)',
`country_code` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '国家二字码(TAB_ORDER.COUNTRY)',
`country_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '国家名称(TAB_ORDER.COUNTRY_NAME)',
`order_status` tinyint(4) DEFAULT NULL COMMENT '订单状态(TAB_ORDER.ORDER_STATUS)',
`pickup_date` datetime DEFAULT NULL COMMENT '提货/收件时间(TAB_ORDER.PICKUP_DATE)',
`biz_date` datetime DEFAULT NULL COMMENT '计费时间(任务bill_time,非上游字段)',
`success_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'WAITING' COMMENT '计费成功状态:WAITING待处理 SUCCESS成功 FAILED失败',
`fail_code` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '计费失败码(同 prc_billing_task.fail_code / BillTaskFailCode)',
`created_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`updated_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`order_id`),
UNIQUE KEY `uk_prc_order_transfer_no` (`transfer_no`),
KEY `idx_prc_order_order_no` (`order_no`),
KEY `idx_prc_order_tracking_no` (`tracking_no`),
KEY `idx_prc_order_track_id` (`track_id`),
KEY `idx_prc_order_customer` (`customer_code`,`biz_date`),
KEY `idx_prc_order_pickup_date` (`pickup_date`),
KEY `idx_prc_order_success_status` (`success_status`,`create_time`),
KEY `idx_prc_order_fail_code` (`fail_code`),
KEY `idx_prc_order_product` (`product_code`,`country_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单主表(上游TAB_ORDER核心字段+计费状态)';
-- ============================================================
-- 2) prc_order_bill: add order_id (keep bill_id; keep transfer_no)
-- ============================================================
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_bill'
AND COLUMN_NAME = 'order_id'
LIMIT 1
);
SET @sql := IF(
@col IS NULL,
'ALTER TABLE prc_order_bill ADD COLUMN order_id varchar(36) DEFAULT NULL COMMENT \'订单ID,对应 prc_order.order_id\' AFTER bill_id, ADD KEY idx_order_bill_order_id (order_id)',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- Optional FK (enable after data backfill):
-- ALTER TABLE prc_order_bill
-- ADD CONSTRAINT fk_order_bill_order
-- FOREIGN KEY (order_id) REFERENCES prc_order(order_id);
-- ============================================================
-- 3) prc_order_bill_ext -> prc_order_ext, rebind to prc_order
-- WARNING: prefer empty/dev env; production needs data migration.
-- ============================================================
-- 3.1 Drop old FK to prc_order_bill (table may still be old name)
SET @fk := (
SELECT CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_bill_ext'
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
AND CONSTRAINT_NAME = 'fk_order_bill_ext_bill'
LIMIT 1
);
SET @sql := IF(
@fk IS NOT NULL,
'ALTER TABLE prc_order_bill_ext DROP FOREIGN KEY fk_order_bill_ext_bill',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- 3.2 Rename table bill_ext -> order_ext
SET @tbl := (
SELECT TABLE_NAME FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_bill_ext'
LIMIT 1
);
SET @sql := IF(
@tbl IS NOT NULL,
'RENAME TABLE prc_order_bill_ext TO prc_order_ext',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- 3.3 Rename PK column bill_id -> order_id
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_ext'
AND COLUMN_NAME = 'bill_id'
LIMIT 1
);
SET @sql := IF(
@col IS NOT NULL,
'ALTER TABLE prc_order_ext CHANGE COLUMN bill_id order_id varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT \'订单ID,对应 prc_order.order_id\'',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- 3.4 Drop columns moved onto prc_order
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_ext'
AND COLUMN_NAME = 'product_floor_code'
LIMIT 1
);
SET @sql := IF(
@col IS NOT NULL,
'ALTER TABLE prc_order_ext DROP COLUMN `product_floor_code`',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_ext'
AND COLUMN_NAME = 'order_status'
LIMIT 1
);
SET @sql := IF(
@col IS NOT NULL,
'ALTER TABLE prc_order_ext DROP COLUMN `order_status`',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_ext'
AND COLUMN_NAME = 'pickup_date'
LIMIT 1
);
SET @sql := IF(
@col IS NOT NULL,
'ALTER TABLE prc_order_ext DROP COLUMN `pickup_date`',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_ext'
AND COLUMN_NAME = 'dimensional_weight_factor'
LIMIT 1
);
SET @sql := IF(
@col IS NOT NULL,
'ALTER TABLE prc_order_ext DROP COLUMN `dimensional_weight_factor`',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- 3.5 MUST empty ext before FK (old order_id values are former bill_id)
-- Run these 3 statements even if the rest of the script already succeeded.
TRUNCATE TABLE prc_order_ext;
-- 3.6 Add FK to prc_order (skip if already exists)
SET @fk := (
SELECT CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_ext'
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
AND CONSTRAINT_NAME = 'fk_order_ext_order'
LIMIT 1
);
SET @sql := IF(
@fk IS NULL,
'ALTER TABLE prc_order_ext ADD CONSTRAINT fk_order_ext_order FOREIGN KEY (order_id) REFERENCES prc_order (order_id) ON DELETE CASCADE',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- 3.7 Refresh table comment
ALTER TABLE prc_order_ext COMMENT = '订单扩展表(上游TAB_ORDER非主表字段,挂 prc_order)';
-- ============================================================
-- Review checklist
-- ------------------------------------------------------------
-- prc_order: identity + L/W/H + weights + staff + billing status
-- prc_order_ext: leftover TAB_ORDER only (no dup of moved cols)
-- prc_order_bill: pricing result; +order_id; still has bill_id
-- Dropped from ext (now on prc_order):
-- product_floor_code, order_status, pickup_date, dimensional_weight_factor
-- ============================================================
@@ -0,0 +1,30 @@
-- Fix 1452: empty orphan prc_order_ext then add FK to prc_order
-- Confirm DB = bms, then run in order.
SELECT DATABASE() AS current_db;
SELECT COUNT(*) AS ext_rows_before FROM prc_order_ext;
SELECT COUNT(*) AS order_rows FROM prc_order;
TRUNCATE TABLE prc_order_ext;
SELECT COUNT(*) AS ext_rows_after FROM prc_order_ext;
-- Drop failed/partial FK name if present (ignore error if missing)
SET @fk := (
SELECT CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_ext'
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
AND CONSTRAINT_NAME = 'fk_order_ext_order'
LIMIT 1
);
SET @sql := IF(
@fk IS NOT NULL,
'ALTER TABLE prc_order_ext DROP FOREIGN KEY fk_order_ext_order',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
ALTER TABLE prc_order_ext
ADD CONSTRAINT fk_order_ext_order
FOREIGN KEY (order_id) REFERENCES prc_order (order_id) ON DELETE CASCADE;
+31
View File
@@ -0,0 +1,31 @@
import request from '@/utils/request'
export function listPrcOrder(query) {
return request({
url: '/monitor/prcOrder/list',
method: 'get',
params: query
})
}
export function getPrcOrder(orderId) {
return request({
url: '/monitor/prcOrder/' + orderId,
method: 'get'
})
}
export function retryPrcOrder(orderId) {
return request({
url: '/monitor/prcOrder/retry/' + orderId,
method: 'post'
})
}
export function retryPrcOrderBatch(orderIds) {
return request({
url: '/monitor/prcOrder/retry',
method: 'post',
data: orderIds
})
}
@@ -5,65 +5,47 @@
<template v-else>
<div class="detail-header">
<el-tag :type="statusTag(detail.successStatus)" effect="light">{{ statusLabel(detail.successStatus) }}</el-tag>
<span class="detail-header-type">{{ billTypeLabel(detail.billType) }}</span>
<span class="detail-header-time">计费时间:{{ detail.billTime || '-' }}</span>
<span class="detail-header-time">计费时间:{{ detail.bizDate || '-' }}</span>
</div>
<el-descriptions :column="1" border size="small" class="detail-desc">
<el-descriptions-item label="任务ID">{{ detail.taskId }}</el-descriptions-item>
<el-descriptions-item label="订单ID">{{ detail.orderId }}</el-descriptions-item>
<el-descriptions-item label="客户代码">{{ detail.customerCode || '-' }}</el-descriptions-item>
<el-descriptions-item label="订单号">{{ detail.orderNo || '-' }}</el-descriptions-item>
<el-descriptions-item label="运单号">{{ detail.trackingNo || '-' }}</el-descriptions-item>
<el-descriptions-item label="转单号">{{ detail.transferNo || '-' }}</el-descriptions-item>
<el-descriptions-item label="计费订单ID">{{ detail.billId || '-' }}</el-descriptions-item>
<el-descriptions-item label="产品代码">{{ detail.productCode || '-' }}</el-descriptions-item>
<el-descriptions-item label="失败码">{{ detail.failCode || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detail.createTime || '-' }}</el-descriptions-item>
<el-descriptions-item label="更新时间">{{ detail.updateTime || '-' }}</el-descriptions-item>
</el-descriptions>
<div v-if="detail.errorMessage" class="err-block">
<div class="err-block-head">
<span class="err-block-title">失败原因</span>
<el-button link type="primary" size="small" icon="CopyDocument" @click="copyError">复制</el-button>
</div>
<div class="err-block-body">{{ detail.errorMessage }}</div>
</div>
</template>
</div>
</el-drawer>
</template>
<script setup>
import { getBillingTask } from '@/api/monitor/billingTask'
import { billTypeLabel, statusLabel, statusTag } from './billingTaskOptions'
import { getPrcOrder } from '@/api/monitor/prcOrder'
import { statusLabel, statusTag } from './billingTaskOptions'
const { proxy } = getCurrentInstance()
const open = ref(false)
const loading = ref(false)
const detail = ref(null)
const drawerTitle = ref('计费任务详情')
const drawerTitle = ref('订单计费详情')
function openDrawer(row) {
if (!row || !row.taskId) return
drawerTitle.value = '计费任务 #' + row.taskId
if (!row || !row.orderId) return
drawerTitle.value = '订单 ' + (row.transferNo || row.orderId)
open.value = true
loading.value = true
detail.value = null
getBillingTask(row.taskId).then(res => {
getPrcOrder(row.orderId).then(res => {
detail.value = res.data || row
}).finally(() => {
loading.value = false
})
}
function copyError() {
const text = detail.value?.errorMessage || ''
if (!text) return
navigator.clipboard.writeText(text).then(() => {
proxy.$modal.msgSuccess('已复制')
}).catch(() => {
proxy.$modal.msgError('复制失败')
})
}
defineExpose({ open: openDrawer })
</script>
+14 -162
View File
@@ -1,38 +1,15 @@
<template>
<div class="app-container billing-task-page">
<div v-if="retryFloatVisible" class="retry-status-float">
<el-tooltip :content="retryFloatTooltip" placement="bottom">
<el-button class="retry-status-button" type="primary" plain size="small" @click="filterRetryRef.open()">
<span class="retry-progress-ring" :style="{ '--retry-progress': retryProgressDegree + 'deg' }" aria-hidden="true">
<span class="retry-progress-value">{{ retryProgressText }}</span>
</span>
<span class="retry-status-text">
<strong>{{ retryFloatTitle }}</strong>
<small>{{ retryFloatSummary }}</small>
</span>
</el-button>
</el-tooltip>
</div>
<basic-table
ref="tableRef"
:columns="columns"
:search-columns="searchColumns"
:query="queryList"
:default-params="defaultParams"
row-key="taskId"
row-key="orderId"
selection
>
<template #toolbar="{ ids }">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Refresh"
v-hasPermi="['monitor:billingTask:retry']"
@click="filterRetryRef.open()"
>批量重新同步</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
@@ -45,22 +22,16 @@
>同步选中</el-button>
</el-col>
</template>
<template #col-billType="{ row }">
<el-tag size="small">{{ billTypeLabel(row.billType) }}</el-tag>
</template>
<template #col-successStatus="{ row }">
<el-tag size="small" :type="statusTag(row.successStatus)">{{ statusLabel(row.successStatus) }}</el-tag>
</template>
<template #col-errorMessage="{ row }">
<span class="err-text" :title="row.errorMessage || ''">{{ row.errorMessage || '-' }}</span>
</template>
<template #col-action="{ row }">
<el-button link type="primary" icon="View" @click="detailRef.open(row)" v-hasPermi="['monitor:billingTask:list']">查看</el-button>
<el-button
link
type="warning"
icon="Refresh"
:loading="retryingId === row.taskId"
:loading="retryingId === row.orderId"
v-hasPermi="['monitor:billingTask:retry']"
@click="handleRetry(row)"
>重新同步</el-button>
@@ -68,23 +39,15 @@
</basic-table>
<billing-task-detail-drawer ref="detailRef" />
<billing-task-filter-retry-dialog
ref="filterRetryRef"
@progress="onFilterRetryProgress"
@success="onFilterRetrySuccess"
/>
</div>
</template>
<script setup name="BillingTaskMonitor">
import { listBillingTask, retryBillingTask, retryBillingTaskBatch } from '@/api/monitor/billingTask'
import { listPrcOrder, retryPrcOrder, retryPrcOrderBatch } from '@/api/monitor/prcOrder'
import BillingTaskDetailDrawer from './components/BillingTaskDetailDrawer.vue'
import BillingTaskFilterRetryDialog from './components/BillingTaskFilterRetryDialog.vue'
import {
statusOptions,
billTypeOptions,
failCodeOptions,
billTypeLabel,
statusLabel,
statusTag
} from './components/billingTaskOptions'
@@ -92,16 +55,13 @@ import {
const { proxy } = getCurrentInstance()
const tableRef = ref()
const detailRef = ref()
const filterRetryRef = ref()
const retryingId = ref(null)
const batchLoading = ref(false)
const retryFloat = ref(null)
const defaultParams = { successStatus: 'FAILED' }
const searchColumns = [
{ label: '状态', prop: 'successStatus', component: 'select', options: statusOptions, placeholder: '请选择状态', width: '140px', props: { clearable: true } },
{ label: '计费类型', prop: 'billType', component: 'select', options: billTypeOptions, placeholder: '请选择类型', width: '140px', props: { clearable: true } },
{ label: '失败码', prop: 'failCode', component: 'select', options: failCodeOptions, placeholder: '请选择失败码', width: '220px', props: { clearable: true, filterable: true } },
{ label: '客户代码', prop: 'customerCode', component: 'input', placeholder: '客户代码', width: '160px' },
{ label: '订单号', prop: 'orderNo', component: 'input', placeholder: '订单号', width: '180px' },
@@ -111,70 +71,34 @@ const searchColumns = [
]
const columns = [
{ label: '任务ID', prop: 'taskId', align: 'center', width: 100 },
{ label: '客户代码', prop: 'customerCode', minWidth: 120, showOverflowTooltip: true },
{ label: '订单号', prop: 'orderNo', minWidth: 160, showOverflowTooltip: true },
{ label: '运单号', prop: 'trackingNo', minWidth: 150, showOverflowTooltip: true },
{ label: '转单号', prop: 'transferNo', minWidth: 160, showOverflowTooltip: true },
{ label: '计费类型', prop: 'billType', align: 'center', width: 100, slot: 'billType' },
{ label: '产品', prop: 'productCode', minWidth: 120, showOverflowTooltip: true },
{ label: '状态', prop: 'successStatus', align: 'center', width: 100, slot: 'successStatus' },
{ label: '计费时间', prop: 'billTime', align: 'center', width: 170 },
{ label: '失败原因', prop: 'errorMessage', minWidth: 220, slot: 'errorMessage', showOverflowTooltip: true },
{ label: '计费时间', prop: 'bizDate', align: 'center', width: 170 },
{ label: '失败码', prop: 'failCode', align: 'center', width: 180, showOverflowTooltip: true },
{ label: '创建时间', prop: 'createTime', align: 'center', width: 170 },
{ label: '操作', prop: 'action', align: 'center', width: 180, fixed: 'right', slot: 'action', showInToolbar: false }
]
const retryFloatVisible = computed(() => {
const p = retryFloat.value
return !!(p && (p.loading || p.finished))
})
const retryProgressDegree = computed(() => Math.round(((retryFloat.value?.percent || 0) / 100) * 360))
const retryProgressText = computed(() => (retryFloat.value?.percent || 0) + '%')
const retryFloatTitle = computed(() => {
const st = (retryFloat.value?.status || '').toUpperCase()
if (retryFloat.value?.loading) return '异步重新计费中'
if (st === 'SUCCESS') return '重新计费完成'
if (st === 'FAIL') return '重新计费失败'
return '异步重新计费'
})
const retryFloatSummary = computed(() => {
const p = retryFloat.value || {}
return '成功 ' + (p.ok || 0) + ' / 失败 ' + (p.fail || 0) + ' / 总数 ' + (p.total || 0)
})
const retryFloatTooltip = computed(() => retryFloat.value?.message || '点击查看详情')
function queryList(params) {
const p = proxy.addDateRange({ ...params }, params.dateRange)
delete p.dateRange
return listBillingTask(p)
}
function onFilterRetryProgress(payload) {
retryFloat.value = payload
if (payload && payload.finished && !payload.loading) {
window.setTimeout(() => {
if (retryFloat.value && retryFloat.value.finished && !retryFloat.value.loading) {
retryFloat.value = null
}
}, 8000)
}
}
function onFilterRetrySuccess() {
tableRef.value?.refresh()
return listPrcOrder(p)
}
function handleRetry(row) {
proxy.$modal.confirm('确认重新同步任务 #' + row.taskId + ' ?').then(() => {
retryingId.value = row.taskId
return retryBillingTask(row.taskId)
proxy.$modal.confirm('确认重新同步转单号 ' + (row.transferNo || row.orderId) + ' ?').then(() => {
retryingId.value = row.orderId
return retryPrcOrder(row.orderId)
}).then(res => {
const task = res.data || {}
if (task.successStatus === 'SUCCESS') {
const order = res.data || {}
if (order.successStatus === 'SUCCESS') {
proxy.$modal.msgSuccess('同步成功')
} else {
proxy.$modal.msgError(task.errorMessage || '同步失败')
proxy.$modal.msgError(order.failCode || '同步失败')
}
tableRef.value.refresh()
}).catch(() => {}).finally(() => {
@@ -184,9 +108,9 @@ function handleRetry(row) {
function handleBatchRetry(ids) {
if (!ids || !ids.length) return
proxy.$modal.confirm('确认同步选中的 ' + ids.length + ' 条任务?').then(() => {
proxy.$modal.confirm('确认同步选中的 ' + ids.length + ' 条订单?').then(() => {
batchLoading.value = true
return retryBillingTaskBatch(ids)
return retryPrcOrderBatch(ids)
}).then(res => {
const data = res.data || {}
proxy.$modal.msgSuccess('完成:成功 ' + (data.ok || 0) + ' / 失败 ' + (data.fail || 0))
@@ -198,76 +122,4 @@ function handleBatchRetry(ids) {
</script>
<style scoped>
.err-text {
color: #f56c6c;
word-break: break-all;
}
.billing-task-page .retry-status-float {
position: fixed;
top: 92px;
right: 24px;
z-index: 3001;
}
.billing-task-page .retry-status-button {
display: inline-flex;
align-items: center;
gap: 10px;
min-width: 200px;
min-height: 68px;
padding: 6px 16px 6px 7px;
border-radius: 36px;
}
.billing-task-page .retry-progress-ring {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
flex: 0 0 54px;
width: 54px;
height: 54px;
border-radius: 50%;
background: conic-gradient(
var(--el-color-primary) 0deg var(--retry-progress, 45deg),
var(--el-color-primary-light-8) var(--retry-progress, 45deg) 360deg
);
}
.billing-task-page .retry-progress-ring::after {
position: absolute;
inset: 5px;
content: '';
border-radius: 50%;
background: var(--el-bg-color);
}
.billing-task-page .retry-progress-value {
position: relative;
z-index: 1;
color: var(--el-color-primary);
font-size: 12px;
font-weight: 600;
line-height: 1;
}
.billing-task-page .retry-status-text {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 3px;
line-height: 1.2;
white-space: nowrap;
}
.billing-task-page .retry-status-text strong {
font-size: 14px;
font-weight: 600;
}
.billing-task-page .retry-status-text small {
color: var(--el-text-color-secondary);
font-size: 11px;
}
</style>