应付计费邮编和重算调整
This commit is contained in:
@@ -25,6 +25,17 @@ class PayZoneMatcherTest
|
|||||||
assertEquals("UK Mainland\n英国大陆", decision.getZoneName());
|
assertEquals("UK Mainland\n英国大陆", decision.getZoneName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ordinaryUkPostcodeIsMainlandAndNotARemoteZone()
|
||||||
|
{
|
||||||
|
PayZoneMatcher.Decision decision = PayZoneMatcher.resolve(ZONES, evriLines(), "KY4 0DN");
|
||||||
|
assertNull(decision.getMessage());
|
||||||
|
assertEquals("UK Mainland\n英国大陆", decision.getZoneName());
|
||||||
|
PayZoneMatcher.Decision emptyBook = PayZoneMatcher.resolve(ZONES, List.of(), "KY4 0DN");
|
||||||
|
assertNull(emptyBook.getMessage());
|
||||||
|
assertEquals("UK Mainland\n英国大陆", emptyBook.getZoneName());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void northernIrelandAndHighlandsComeFromThePostcodeBook()
|
void northernIrelandAndHighlandsComeFromThePostcodeBook()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public class LoginUser implements UserDetails
|
|||||||
@Override
|
@Override
|
||||||
public String getUsername()
|
public String getUsername()
|
||||||
{
|
{
|
||||||
return user.getUserName();
|
return user == null ? null : user.getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ public class PayOrderRow
|
|||||||
|
|
||||||
private String countryName;
|
private String countryName;
|
||||||
|
|
||||||
|
/** 收件邮编,来自 prc_order_bill.dest_postcode */
|
||||||
|
private String destPostcode;
|
||||||
|
|
||||||
private String channelName;
|
private String channelName;
|
||||||
|
|
||||||
private BigDecimal chargeWeight;
|
private BigDecimal chargeWeight;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import java.math.RoundingMode;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import com.bms.common.core.domain.entity.SysUser;
|
||||||
|
import com.bms.common.core.domain.model.LoginUser;
|
||||||
import com.bms.common.utils.SecurityUtils;
|
import com.bms.common.utils.SecurityUtils;
|
||||||
import com.bms.common.utils.StringUtils;
|
import com.bms.common.utils.StringUtils;
|
||||||
import com.bms.system.domain.BmsExchangeRate;
|
import com.bms.system.domain.BmsExchangeRate;
|
||||||
@@ -24,6 +26,11 @@ public class PayFeeMoney
|
|||||||
/** 汇总金额小数位 */
|
/** 汇总金额小数位 */
|
||||||
public static final int TOTAL_SCALE = 2;
|
public static final int TOTAL_SCALE = 2;
|
||||||
|
|
||||||
|
/** 提交重算的那个人。后台线程没有登录态,用提交时记下的账号。 */
|
||||||
|
private static final ThreadLocal<String> BOUND_NAME = new ThreadLocal<>();
|
||||||
|
|
||||||
|
private static final ThreadLocal<String> BOUND_ID = new ThreadLocal<>();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBmsExchangeRateService exchangeRateService;
|
private IBmsExchangeRateService exchangeRateService;
|
||||||
|
|
||||||
@@ -57,17 +64,107 @@ public class PayFeeMoney
|
|||||||
return value.setScale(TOTAL_SCALE, RoundingMode.HALF_UP);
|
return value.setScale(TOTAL_SCALE, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 当前登录用户的主键。没有登录信息时返回空,费用上不写账号。 */
|
/**
|
||||||
|
* 在还有登录态的线程上取出账号和用户主键。后台重算把这两个值带过去。
|
||||||
|
*
|
||||||
|
* @return 下标 0 是账号,下标 1 是用户主键;取不到时对应位置为空串
|
||||||
|
*/
|
||||||
|
public static String[] capture()
|
||||||
|
{
|
||||||
|
String name = "";
|
||||||
|
String id = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoginUser login = SecurityUtils.getLoginUser();
|
||||||
|
if (login.getUserId() != null)
|
||||||
|
{
|
||||||
|
id = String.valueOf(login.getUserId());
|
||||||
|
}
|
||||||
|
SysUser user = login.getUser();
|
||||||
|
if (user != null && user.getUserName() != null && !user.getUserName().isBlank())
|
||||||
|
{
|
||||||
|
name = user.getUserName().trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ignored)
|
||||||
|
{
|
||||||
|
name = "";
|
||||||
|
id = "";
|
||||||
|
}
|
||||||
|
return new String[] { name, id };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 后台线程开始处理前放上提交人。空值表示这根线程不覆盖登录态。 */
|
||||||
|
public static void bind(String name, String userId)
|
||||||
|
{
|
||||||
|
if (name == null || name.isBlank())
|
||||||
|
{
|
||||||
|
BOUND_NAME.remove();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOUND_NAME.set(name.trim());
|
||||||
|
}
|
||||||
|
if (userId == null || userId.isBlank())
|
||||||
|
{
|
||||||
|
BOUND_ID.remove();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOUND_ID.set(userId.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 线程归还线程池前清掉,避免下一票用到上一个人。 */
|
||||||
|
public static void clear()
|
||||||
|
{
|
||||||
|
BOUND_NAME.remove();
|
||||||
|
BOUND_ID.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 操作人账号。优先用提交重算时记下的账号,没有登录信息时记 system。 */
|
||||||
|
public static String operatorName()
|
||||||
|
{
|
||||||
|
String bound = BOUND_NAME.get();
|
||||||
|
if (bound != null && !bound.isBlank())
|
||||||
|
{
|
||||||
|
return bound;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String name = SecurityUtils.getUsername();
|
||||||
|
if (name != null && !name.isBlank())
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ignored)
|
||||||
|
{
|
||||||
|
return "system";
|
||||||
|
}
|
||||||
|
return "system";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 当前登录用户的主键。订单同步等没有登录信息时记 system,页面回显为系统自动。 */
|
||||||
public static String userId()
|
public static String userId()
|
||||||
{
|
{
|
||||||
|
String bound = BOUND_ID.get();
|
||||||
|
if (bound != null && !bound.isBlank())
|
||||||
|
{
|
||||||
|
return bound;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Long id = SecurityUtils.getUserId();
|
Long id = SecurityUtils.getUserId();
|
||||||
return id == null ? null : String.valueOf(id);
|
if (id != null)
|
||||||
|
{
|
||||||
|
return String.valueOf(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
return null;
|
return "system";
|
||||||
}
|
}
|
||||||
|
return "system";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ public class PayOrderFeeCalculator
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Long> linkedZoneIds = zoneGroupIds(linked, countryCode, countryName);
|
List<Long> linkedZoneIds = zoneGroupIds(linked, countryCode, countryName);
|
||||||
|
addRemoteZoneIds(linkedZoneIds, linked, countryCode, countryName);
|
||||||
if (!linkedZoneIds.isEmpty())
|
if (!linkedZoneIds.isEmpty())
|
||||||
{
|
{
|
||||||
return decideZone(zoneNames, linkedZoneIds, postcode);
|
return decideZone(zoneNames, linkedZoneIds, postcode);
|
||||||
@@ -363,6 +364,11 @@ public class PayOrderFeeCalculator
|
|||||||
}
|
}
|
||||||
if (groups.isEmpty())
|
if (groups.isEmpty())
|
||||||
{
|
{
|
||||||
|
PayZoneMatcher.Decision mainland = PayZoneMatcher.resolve(zoneNames, new ArrayList<>(), postcode);
|
||||||
|
if (mainland.getZoneName() != null)
|
||||||
|
{
|
||||||
|
return mainland.getZoneName();
|
||||||
|
}
|
||||||
throw new ServiceException("产品「" + product.getProductName() + "」有多个地区,没有找到对应的邮编分区");
|
throw new ServiceException("产品「" + product.getProductName() + "」有多个地区,没有找到对应的邮编分区");
|
||||||
}
|
}
|
||||||
List<Long> groupIds = new ArrayList<>();
|
List<Long> groupIds = new ArrayList<>();
|
||||||
@@ -409,7 +415,35 @@ public class PayOrderFeeCalculator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取出用来选派送费的普通分区。偏远、附加费邮编和不可达不参与选区。
|
* 偏远邮编同时用来选价卡地区。对上高地、岛屿这类邮编时走对应价格列,对不上则由大陆列承接。
|
||||||
|
*
|
||||||
|
* @param ids 已经放入的分区组
|
||||||
|
* @param linked 已对上的邮编组
|
||||||
|
* @param countryCode 目的国二字码
|
||||||
|
* @param countryName 目的国名称
|
||||||
|
*/
|
||||||
|
private static void addRemoteZoneIds(List<Long> ids, List<PayPostcodeGroup> linked, String countryCode, String countryName)
|
||||||
|
{
|
||||||
|
if (linked == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (PayPostcodeGroup group : linked)
|
||||||
|
{
|
||||||
|
if (group == null || group.getGroupId() == null || ids.contains(group.getGroupId()) || !PayRemoteBook.remoteGroup(group))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ("FEE".equals(group.getConfigKind()) || !sameCountry(group, countryCode, countryName))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ids.add(group.getGroupId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取出用来选派送费的普通分区。附加费邮编和不可达不参与选区。
|
||||||
*
|
*
|
||||||
* @param linked 已对上的邮编组
|
* @param linked 已对上的邮编组
|
||||||
* @param countryCode 目的国二字码
|
* @param countryCode 目的国二字码
|
||||||
|
|||||||
@@ -110,6 +110,11 @@ public final class PayZoneMatcher
|
|||||||
}
|
}
|
||||||
if (lines == null || lines.isEmpty())
|
if (lines == null || lines.isEmpty())
|
||||||
{
|
{
|
||||||
|
String mainland = mainlandZone(zoneNames);
|
||||||
|
if (mainland != null)
|
||||||
|
{
|
||||||
|
return Decision.zone(mainland);
|
||||||
|
}
|
||||||
return Decision.unknown();
|
return Decision.unknown();
|
||||||
}
|
}
|
||||||
String bestZone = null;
|
String bestZone = null;
|
||||||
|
|||||||
+39
-26
@@ -9,7 +9,6 @@ import org.springframework.transaction.annotation.Propagation;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.bms.common.enums.PaymentMesEnum;
|
import com.bms.common.enums.PaymentMesEnum;
|
||||||
import com.bms.common.exception.ServiceException;
|
import com.bms.common.exception.ServiceException;
|
||||||
import com.bms.common.utils.SecurityUtils;
|
|
||||||
import com.bms.masterdata.domain.ServiceChannel;
|
import com.bms.masterdata.domain.ServiceChannel;
|
||||||
import com.bms.masterdata.mapper.ServiceChannelMapper;
|
import com.bms.masterdata.mapper.ServiceChannelMapper;
|
||||||
import com.bms.price.domain.PayCostLine;
|
import com.bms.price.domain.PayCostLine;
|
||||||
@@ -149,7 +148,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
|||||||
{
|
{
|
||||||
throw new ServiceException(result.getMessage() == null ? PaymentMesEnum.BMS_PAY_NO_COST.getCnMes() : result.getMessage());
|
throw new ServiceException(result.getMessage() == null ? PaymentMesEnum.BMS_PAY_NO_COST.getCnMes() : result.getMessage());
|
||||||
}
|
}
|
||||||
String operator = SecurityUtils.getUsername();
|
String operator = operator();
|
||||||
PrcPayBill payBill = saveBill(bill, result, operator);
|
PrcPayBill payBill = saveBill(bill, result, operator);
|
||||||
saveFees(bill.getBillId(), payBill.getPayBillId(), result);
|
saveFees(bill.getBillId(), payBill.getPayBillId(), result);
|
||||||
String channelName = channel.getChannelName() == null ? channel.getChannelCode() : channel.getChannelName();
|
String channelName = channel.getChannelName() == null ? channel.getChannelCode() : channel.getChannelName();
|
||||||
@@ -180,19 +179,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
|||||||
{
|
{
|
||||||
message = message.substring(0, 100);
|
message = message.substring(0, 100);
|
||||||
}
|
}
|
||||||
String operator = "system";
|
String operator = operator();
|
||||||
try
|
|
||||||
{
|
|
||||||
String name = SecurityUtils.getUsername();
|
|
||||||
if (name != null && !name.isBlank())
|
|
||||||
{
|
|
||||||
operator = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ignored)
|
|
||||||
{
|
|
||||||
operator = "system";
|
|
||||||
}
|
|
||||||
payBillMapper.insertMissingPayBills(List.of(billId), operator);
|
payBillMapper.insertMissingPayBills(List.of(billId), operator);
|
||||||
payBillMapper.markCalcStatus(billId, 2, message, operator);
|
payBillMapper.markCalcStatus(billId, 2, message, operator);
|
||||||
}
|
}
|
||||||
@@ -371,6 +358,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Long> linkedZoneIds = zoneGroupIds(linked, countryCode, countryName);
|
List<Long> linkedZoneIds = zoneGroupIds(linked, countryCode, countryName);
|
||||||
|
addRemoteZoneIds(linkedZoneIds, linked, countryCode, countryName);
|
||||||
if (!linkedZoneIds.isEmpty())
|
if (!linkedZoneIds.isEmpty())
|
||||||
{
|
{
|
||||||
return decideZone(zoneNames, linkedZoneIds, postcode);
|
return decideZone(zoneNames, linkedZoneIds, postcode);
|
||||||
@@ -394,6 +382,11 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
|||||||
}
|
}
|
||||||
if (groups.isEmpty())
|
if (groups.isEmpty())
|
||||||
{
|
{
|
||||||
|
PayZoneMatcher.Decision mainland = PayZoneMatcher.resolve(zoneNames, new ArrayList<>(), postcode);
|
||||||
|
if (mainland.getZoneName() != null)
|
||||||
|
{
|
||||||
|
return mainland.getZoneName();
|
||||||
|
}
|
||||||
throw new ServiceException("产品「" + product.getProductName() + "」有多个地区,没有找到对应的邮编分区");
|
throw new ServiceException("产品「" + product.getProductName() + "」有多个地区,没有找到对应的邮编分区");
|
||||||
}
|
}
|
||||||
List<Long> groupIds = new ArrayList<>();
|
List<Long> groupIds = new ArrayList<>();
|
||||||
@@ -440,7 +433,35 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取出用来选派送费的普通分区。偏远、附加费邮编和不可达不参与选区。
|
* 偏远邮编同时用来选价卡地区。对上高地、岛屿这类邮编时走对应价格列,对不上则由大陆列承接。
|
||||||
|
*
|
||||||
|
* @param ids 已经放入的分区组
|
||||||
|
* @param linked 已对上的邮编组
|
||||||
|
* @param countryCode 目的国二字码
|
||||||
|
* @param countryName 目的国名称
|
||||||
|
*/
|
||||||
|
private static void addRemoteZoneIds(List<Long> ids, List<PayPostcodeGroup> linked, String countryCode, String countryName)
|
||||||
|
{
|
||||||
|
if (linked == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (PayPostcodeGroup group : linked)
|
||||||
|
{
|
||||||
|
if (group == null || group.getGroupId() == null || ids.contains(group.getGroupId()) || !PayRemoteBook.remoteGroup(group))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ("FEE".equals(group.getConfigKind()) || !sameCountry(group, countryCode, countryName))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ids.add(group.getGroupId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取出用来选派送费的普通分区。附加费邮编和不可达不参与选区。
|
||||||
*
|
*
|
||||||
* @param linked 已对上的邮编组
|
* @param linked 已对上的邮编组
|
||||||
* @param countryCode 目的国二字码
|
* @param countryCode 目的国二字码
|
||||||
@@ -732,18 +753,10 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
|||||||
return text.length() <= 100 ? text : text.substring(0, 100);
|
return text.length() <= 100 ? text : text.substring(0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 当前登录人。没有登录信息时记 system。 */
|
/** 当前操作人。后台重算用提交时记下的账号,没有登录信息时记 system。 */
|
||||||
private static String operator()
|
private static String operator()
|
||||||
{
|
{
|
||||||
try
|
return PayFeeMoney.operatorName();
|
||||||
{
|
|
||||||
String name = SecurityUtils.getUsername();
|
|
||||||
return name == null || name.isBlank() ? "system" : name;
|
|
||||||
}
|
|
||||||
catch (Exception ignored)
|
|
||||||
{
|
|
||||||
return "system";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-1
@@ -193,7 +193,8 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
|||||||
task.setTotal(task.getLines().size());
|
task.setTotal(task.getLines().size());
|
||||||
task.setPercent(task.getTotal() == 0 ? 100 : finished * 100 / task.getTotal());
|
task.setPercent(task.getTotal() == 0 ? 100 : finished * 100 / task.getTotal());
|
||||||
payOrderRecalcAsyncRunner.save(task);
|
payOrderRecalcAsyncRunner.save(task);
|
||||||
payOrderRecalcAsyncRunner.run(task.getTaskId(), SecurityContextHolder.getContext().getAuthentication());
|
String[] actor = PayFeeMoney.capture();
|
||||||
|
payOrderRecalcAsyncRunner.run(task.getTaskId(), SecurityContextHolder.getContext().getAuthentication(), actor[0], actor[1]);
|
||||||
return task.getTaskId();
|
return task.getTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -56,6 +56,7 @@ import com.bms.price.domain.PrcPayBill;
|
|||||||
import com.bms.price.domain.PrcPayBillFee;
|
import com.bms.price.domain.PrcPayBillFee;
|
||||||
import com.bms.price.domain.PrcPriceSet;
|
import com.bms.price.domain.PrcPriceSet;
|
||||||
import com.bms.price.domain.PrcSurcharge;
|
import com.bms.price.domain.PrcSurcharge;
|
||||||
|
import com.bms.price.pay.PayFeeMoney;
|
||||||
import com.bms.price.domain.BatchAddIncomeBillFeeTask;
|
import com.bms.price.domain.BatchAddIncomeBillFeeTask;
|
||||||
import com.bms.price.domain.ChargeWeightImportTask;
|
import com.bms.price.domain.ChargeWeightImportTask;
|
||||||
import com.bms.price.domain.vo.AddIncomeBillFeeRequest;
|
import com.bms.price.domain.vo.AddIncomeBillFeeRequest;
|
||||||
@@ -1217,7 +1218,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
|||||||
localRebillAsyncRunner.put(taskId, BatchAddIncomeBillFeeTask.STATUS_PENDING, 0, "queued", null,
|
localRebillAsyncRunner.put(taskId, BatchAddIncomeBillFeeTask.STATUS_PENDING, 0, "queued", null,
|
||||||
billIds.size(), 0, 0);
|
billIds.size(), 0, 0);
|
||||||
// 完成时每批写一条 ES 操作日志(LOCAL_REBILL_DONE);失败订单写入 detail.failDetails。
|
// 完成时每批写一条 ES 操作日志(LOCAL_REBILL_DONE);失败订单写入 detail.failDetails。
|
||||||
localRebillAsyncRunner.run(taskId, billIds, request);
|
String[] actor = PayFeeMoney.capture();
|
||||||
|
localRebillAsyncRunner.run(taskId, billIds, request, actor[0], actor[1]);
|
||||||
return taskId;
|
return taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.bms.price.domain.PayOrderCostResult;
|
|||||||
import com.bms.price.domain.PayOrderRecalcLine;
|
import com.bms.price.domain.PayOrderRecalcLine;
|
||||||
import com.bms.price.domain.PayOrderRecalcTask;
|
import com.bms.price.domain.PayOrderRecalcTask;
|
||||||
import com.bms.price.domain.PrcPayBillFeeLog;
|
import com.bms.price.domain.PrcPayBillFeeLog;
|
||||||
|
import com.bms.price.pay.PayFeeMoney;
|
||||||
import com.bms.price.service.IPayOrderListService;
|
import com.bms.price.service.IPayOrderListService;
|
||||||
import com.bms.price.service.PayBillFeeLogService;
|
import com.bms.price.service.PayBillFeeLogService;
|
||||||
|
|
||||||
@@ -48,11 +49,12 @@ public class PayOrderRecalcAsyncRunner
|
|||||||
private final Map<String, AtomicBoolean> cancelFlags = new ConcurrentHashMap<>();
|
private final Map<String, AtomicBoolean> cancelFlags = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Async("threadPoolTaskExecutor")
|
@Async("threadPoolTaskExecutor")
|
||||||
public void run(String taskId, Authentication authentication)
|
public void run(String taskId, Authentication authentication, String operatorName, String operatorUserId)
|
||||||
{
|
{
|
||||||
SecurityContext previous = SecurityContextHolder.getContext();
|
SecurityContext previous = SecurityContextHolder.getContext();
|
||||||
List<PrcPayBillFeeLog> feeLogs = new ArrayList<>();
|
List<PrcPayBillFeeLog> feeLogs = new ArrayList<>();
|
||||||
boolean drained = false;
|
boolean drained = false;
|
||||||
|
PayFeeMoney.bind(operatorName, operatorUserId);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (authentication != null)
|
if (authentication != null)
|
||||||
@@ -156,6 +158,7 @@ public class PayOrderRecalcAsyncRunner
|
|||||||
{
|
{
|
||||||
drain(feeLogs);
|
drain(feeLogs);
|
||||||
}
|
}
|
||||||
|
PayFeeMoney.clear();
|
||||||
SecurityContextHolder.setContext(previous);
|
SecurityContextHolder.setContext(previous);
|
||||||
cancelFlags.remove(taskId);
|
cancelFlags.remove(taskId);
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-1
@@ -28,6 +28,7 @@ import com.bms.price.config.BillingProperties;
|
|||||||
import com.bms.price.domain.BatchAddIncomeBillFeeTask;
|
import com.bms.price.domain.BatchAddIncomeBillFeeTask;
|
||||||
import com.bms.price.domain.PrcOrderBill;
|
import com.bms.price.domain.PrcOrderBill;
|
||||||
import com.bms.price.domain.vo.LocalRebillRequest;
|
import com.bms.price.domain.vo.LocalRebillRequest;
|
||||||
|
import com.bms.price.pay.PayFeeMoney;
|
||||||
import com.bms.price.domain.vo.TmsPriceQuoteResult;
|
import com.bms.price.domain.vo.TmsPriceQuoteResult;
|
||||||
import com.bms.price.enums.BillBillingFailStatus;
|
import com.bms.price.enums.BillBillingFailStatus;
|
||||||
import com.bms.price.mapper.PrcOrderBillMapper;
|
import com.bms.price.mapper.PrcOrderBillMapper;
|
||||||
@@ -76,11 +77,17 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
|||||||
@Async("threadPoolTaskExecutor")
|
@Async("threadPoolTaskExecutor")
|
||||||
public void run(String taskId, List<Long> billIds)
|
public void run(String taskId, List<Long> billIds)
|
||||||
{
|
{
|
||||||
run(taskId, billIds, null);
|
run(taskId, billIds, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async("threadPoolTaskExecutor")
|
@Async("threadPoolTaskExecutor")
|
||||||
public void run(String taskId, List<Long> billIds, LocalRebillRequest request)
|
public void run(String taskId, List<Long> billIds, LocalRebillRequest request)
|
||||||
|
{
|
||||||
|
run(taskId, billIds, request, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async("threadPoolTaskExecutor")
|
||||||
|
public void run(String taskId, List<Long> billIds, LocalRebillRequest request, String operatorName, String operatorUserId)
|
||||||
{
|
{
|
||||||
int total = billIds == null ? 0 : billIds.size();
|
int total = billIds == null ? 0 : billIds.size();
|
||||||
AtomicInteger success = new AtomicInteger(0);
|
AtomicInteger success = new AtomicInteger(0);
|
||||||
@@ -115,6 +122,9 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
|||||||
for (int w = 0; w < threads; w++)
|
for (int w = 0; w < threads; w++)
|
||||||
{
|
{
|
||||||
workers.add(() -> {
|
workers.add(() -> {
|
||||||
|
PayFeeMoney.bind(operatorName, operatorUserId);
|
||||||
|
try
|
||||||
|
{
|
||||||
while (!isCancelRequested(taskId))
|
while (!isCancelRequested(taskId))
|
||||||
{
|
{
|
||||||
int i = nextIndex.getAndIncrement();
|
int i = nextIndex.getAndIncrement();
|
||||||
@@ -161,6 +171,11 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
PayFeeMoney.clear();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
invokeAllQuiet(pool, workers);
|
invokeAllQuiet(pool, workers);
|
||||||
|
|||||||
@@ -10,13 +10,14 @@
|
|||||||
p.customer_name as customerName,
|
p.customer_name as customerName,
|
||||||
p.product_name as productName,
|
p.product_name as productName,
|
||||||
p.country_name as countryName,
|
p.country_name as countryName,
|
||||||
|
p.dest_postcode as destPostcode,
|
||||||
p.product_floor as channelName,
|
p.product_floor as channelName,
|
||||||
p.charge_weight as chargeWeight,
|
p.charge_weight as chargeWeight,
|
||||||
ifnull(b.pay_total, p.pay_total) as payTotal,
|
ifnull(b.pay_total, p.pay_total) as payTotal,
|
||||||
ifnull(nullif(trim(b.currency), ''), 'CNY') as currency,
|
ifnull(nullif(trim(b.currency), ''), 'CNY') as currency,
|
||||||
b.pay_calc_status as payCalcStatus,
|
b.pay_calc_status as payCalcStatus,
|
||||||
b.pay_calc_msg as payCalcMsg,
|
b.pay_calc_msg as payCalcMsg,
|
||||||
b.update_by as updateBy,
|
case when lower(trim(b.update_by)) = 'system' then '系统自动' else b.update_by end as updateBy,
|
||||||
b.update_time as updateTime,
|
b.update_time as updateTime,
|
||||||
p.biz_date as bizDate
|
p.biz_date as bizDate
|
||||||
from prc_order_bill p
|
from prc_order_bill p
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
select log_id, fee_id, bill_id, fee_name, amount, currency,
|
select log_id, fee_id, bill_id, fee_name, amount, currency,
|
||||||
before_fee_name, before_amount, before_currency,
|
before_fee_name, before_amount, before_currency,
|
||||||
after_fee_name, after_amount, after_currency,
|
after_fee_name, after_amount, after_currency,
|
||||||
operation_type, remark, create_by, create_time
|
operation_type, remark,
|
||||||
|
case when lower(trim(create_by)) = 'system' then '系统自动' else create_by end as create_by,
|
||||||
|
create_time
|
||||||
from prc_pay_bill_fee_log
|
from prc_pay_bill_fee_log
|
||||||
where bill_id = #{billId}
|
where bill_id = #{billId}
|
||||||
order by log_id desc
|
order by log_id desc
|
||||||
|
|||||||
@@ -47,29 +47,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="feeUserName">
|
<sql id="feeActorName">
|
||||||
(
|
case
|
||||||
select case
|
when lower(trim(${column})) = 'system' then '系统自动'
|
||||||
when nullif(trim(u.nick_name), '') is not null then u.nick_name
|
else ifnull((
|
||||||
else u.user_name
|
select case
|
||||||
end
|
when nullif(trim(u.nick_name), '') is not null then u.nick_name
|
||||||
from sys_user u
|
else u.user_name
|
||||||
where u.del_flag = '0'
|
end
|
||||||
and (
|
from sys_user u
|
||||||
(${column} regexp '^[0-9]+$' and u.user_id = cast(${column} as unsigned))
|
where u.del_flag = '0'
|
||||||
or (ifnull(${column}, '') not regexp '^[0-9]+$' and u.user_name = ${column})
|
and (
|
||||||
)
|
(${column} regexp '^[0-9]+$' and u.user_id = cast(${column} as unsigned))
|
||||||
limit 1
|
or (ifnull(${column}, '') not regexp '^[0-9]+$' and u.user_name = ${column})
|
||||||
)
|
)
|
||||||
|
limit 1
|
||||||
|
), ${column})
|
||||||
|
end
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectByBillId" parameterType="Long" resultMap="PrcPayBillFeeResult">
|
<select id="selectByBillId" parameterType="Long" resultMap="PrcPayBillFeeResult">
|
||||||
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
|
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
|
||||||
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
|
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
|
||||||
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
|
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
|
||||||
ifnull(<include refid="feeUserName"><property name="column" value="f.create_by"/></include>, f.create_by) as create_by,
|
<include refid="feeActorName"><property name="column" value="f.create_by"/></include> as create_by,
|
||||||
f.create_time,
|
f.create_time,
|
||||||
ifnull(<include refid="feeUserName"><property name="column" value="f.update_by"/></include>, f.update_by) as update_by,
|
<include refid="feeActorName"><property name="column" value="f.update_by"/></include> as update_by,
|
||||||
f.update_time
|
f.update_time
|
||||||
from prc_pay_bill_fee f
|
from prc_pay_bill_fee f
|
||||||
<include refid="feeItemJoin"/>
|
<include refid="feeItemJoin"/>
|
||||||
@@ -82,9 +85,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
|
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
|
||||||
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
|
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
|
||||||
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
|
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
|
||||||
ifnull(<include refid="feeUserName"><property name="column" value="f.create_by"/></include>, f.create_by) as create_by,
|
<include refid="feeActorName"><property name="column" value="f.create_by"/></include> as create_by,
|
||||||
f.create_time,
|
f.create_time,
|
||||||
ifnull(<include refid="feeUserName"><property name="column" value="f.update_by"/></include>, f.update_by) as update_by,
|
<include refid="feeActorName"><property name="column" value="f.update_by"/></include> as update_by,
|
||||||
f.update_time
|
f.update_time
|
||||||
from prc_pay_bill_fee f
|
from prc_pay_bill_fee f
|
||||||
<include refid="feeItemJoin"/>
|
<include refid="feeItemJoin"/>
|
||||||
|
|||||||
@@ -42,6 +42,9 @@
|
|||||||
<el-table-column prop="customerName" label="客户" min-width="140" show-overflow-tooltip />
|
<el-table-column prop="customerName" label="客户" min-width="140" show-overflow-tooltip />
|
||||||
<el-table-column prop="productName" label="产品" min-width="160" show-overflow-tooltip />
|
<el-table-column prop="productName" label="产品" min-width="160" show-overflow-tooltip />
|
||||||
<el-table-column prop="countryName" label="目的国" width="110" show-overflow-tooltip />
|
<el-table-column prop="countryName" label="目的国" width="110" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="destPostcode" label="邮编" width="120" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">{{ row.destPostcode || '-' }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="channelName" label="渠道" min-width="140" show-overflow-tooltip />
|
<el-table-column prop="channelName" label="渠道" min-width="140" show-overflow-tooltip />
|
||||||
<el-table-column prop="chargeWeight" label="计费重" width="90" align="right" />
|
<el-table-column prop="chargeWeight" label="计费重" width="90" align="right" />
|
||||||
<el-table-column prop="payTotal" label="应付总额" width="110" align="right">
|
<el-table-column prop="payTotal" label="应付总额" width="110" align="right">
|
||||||
@@ -59,7 +62,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="bizDate" label="计费时间" width="170" align="center" />
|
<el-table-column prop="bizDate" label="计费时间" width="170" align="center" />
|
||||||
<el-table-column prop="updateBy" label="更新人" width="110" show-overflow-tooltip>
|
<el-table-column prop="updateBy" label="更新人" width="110" show-overflow-tooltip>
|
||||||
<template #default="{ row }">{{ row.updateBy || '-' }}</template>
|
<template #default="{ row }">{{ actorName(row.updateBy) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="updateTime" label="更新时间" width="170" align="center">
|
<el-table-column prop="updateTime" label="更新时间" width="170" align="center">
|
||||||
<template #default="{ row }">{{ row.updateTime || '-' }}</template>
|
<template #default="{ row }">{{ row.updateTime || '-' }}</template>
|
||||||
@@ -116,10 +119,12 @@
|
|||||||
<template #default="{ row }">{{ sourceText(row.feeSource) }}</template>
|
<template #default="{ row }">{{ sourceText(row.feeSource) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建人" min-width="1" header-align="center" show-overflow-tooltip>
|
<el-table-column label="创建人" min-width="1" header-align="center" show-overflow-tooltip>
|
||||||
<template #default="{ row }">{{ row.createBy || '-' }}</template>
|
<template #default="{ row }">{{ actorName(row.createBy) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="createTime" label="创建时间" min-width="1" header-align="center" show-overflow-tooltip />
|
<el-table-column prop="createTime" label="创建时间" min-width="1" header-align="center" show-overflow-tooltip />
|
||||||
<el-table-column prop="updateBy" label="更新人" min-width="1" header-align="center" show-overflow-tooltip />
|
<el-table-column label="更新人" min-width="1" header-align="center" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">{{ actorName(row.updateBy) }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="updateTime" label="更新时间" min-width="1" header-align="center" show-overflow-tooltip />
|
<el-table-column prop="updateTime" label="更新时间" min-width="1" header-align="center" show-overflow-tooltip />
|
||||||
<el-table-column label="操作" min-width="1" header-align="center" align="center" class-name="fee-op">
|
<el-table-column label="操作" min-width="1" header-align="center" align="center" class-name="fee-op">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@@ -159,7 +164,9 @@
|
|||||||
<dict-tag :options="bms_pay_fee_log_type" :value="row.operationType" />
|
<dict-tag :options="bms_pay_fee_log_type" :value="row.operationType" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="createBy" label="操作人" width="120" header-align="center" show-overflow-tooltip />
|
<el-table-column label="操作人" width="120" header-align="center" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">{{ actorName(row.createBy) }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="createTime" label="操作时间" width="170" header-align="center" align="center" />
|
<el-table-column prop="createTime" label="操作时间" width="170" header-align="center" align="center" />
|
||||||
</el-table>
|
</el-table>
|
||||||
<pagination v-show="logTotal > 0" :total="logTotal" v-model:page="logQuery.pageNum" v-model:limit="logQuery.pageSize" @pagination="loadLogs" />
|
<pagination v-show="logTotal > 0" :total="logTotal" v-model:page="logQuery.pageNum" v-model:limit="logQuery.pageSize" @pagination="loadLogs" />
|
||||||
@@ -338,6 +345,14 @@ function sourceText(value) {
|
|||||||
return sources[value] || value || '-'
|
return sources[value] || value || '-'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function actorName(value) {
|
||||||
|
const text = value == null ? '' : String(value).trim()
|
||||||
|
if (!text) {
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
return text.toLowerCase() === 'system' ? '系统自动' : text
|
||||||
|
}
|
||||||
|
|
||||||
function logLines(row, side) {
|
function logLines(row, side) {
|
||||||
const name = row?.[side + 'FeeName']
|
const name = row?.[side + 'FeeName']
|
||||||
const amount = row?.[side + 'Amount']
|
const amount = row?.[side + 'Amount']
|
||||||
|
|||||||
Reference in New Issue
Block a user