Commit 0b755e3b authored by zhangfeng's avatar zhangfeng

bugfix-488: 订单v值兼容无收货人订单

parent 8d08d0eb
...@@ -100,7 +100,14 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -100,7 +100,14 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
} else { } else {
lockKey1 = "score:rule:order:lock:" + order.getOrderConsignorDO().getCustomerId(); lockKey1 = "score:rule:order:lock:" + order.getOrderConsignorDO().getCustomerId();
} }
String lockKey2 = "score:rule:order:lock:" + order.getOrderConsigneeDO().getCustomerId(); // 增加订单无收货人时校验
long consigneeId = 0;
if (Objects.isNull(order.getOrderConsigneeDO()) || Objects.isNull(order.getOrderConsigneeDO().getCustomerId())) {
log.info("Order in shipping listener: The order consignee is empty,orderID:{}", orderId);
} else {
consigneeId = order.getOrderConsigneeDO().getCustomerId();
}
String lockKey2 = "score:rule:order:lock:" + consigneeId;
RLock lock1 = redissonClient.getLock(lockKey1); RLock lock1 = redissonClient.getLock(lockKey1);
RLock lock2 = redissonClient.getLock(lockKey2); RLock lock2 = redissonClient.getLock(lockKey2);
RedissonMultiLock multiLock = new RedissonMultiLock(lock1, lock2); RedissonMultiLock multiLock = new RedissonMultiLock(lock1, lock2);
...@@ -110,7 +117,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -110,7 +117,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
log.error("Order in shipping listener: get lock error, orderId:{}", orderId); log.error("Order in shipping listener: get lock error, orderId:{}", orderId);
} }
// 获取需要添加积分的用户 发货人 // 获取需要添加积分的用户 发货人
List<Long> userIds = getAddScoreUser(order, extraInfo, scoreRuleDO); List<Long> userIds = getAddScoreUser(order.getUserId(), order.getOrderConsignorDO().getCustomerId(), consigneeId, extraInfo, scoreRuleDO);
if (CollectionUtil.isEmpty(userIds)) { if (CollectionUtil.isEmpty(userIds)) {
log.info("Order in shipping listener: consignor and consignee are not bound to the member, orderId:{}", orderId); log.info("Order in shipping listener: consignor and consignee are not bound to the member, orderId:{}", orderId);
return; return;
...@@ -190,18 +197,10 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -190,18 +197,10 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
/** /**
* 获取需要加分的用户 * 获取需要加分的用户
*
* @param order
* @param extraInfo
* @param scoreRuleDO
* @return
*/ */
private List<Long> getAddScoreUser(OrderRespDTO order, ScoreRuleOrderVExtraVO extraInfo, ScoreRuleDO scoreRuleDO) { private List<Long> getAddScoreUser(Long userId, Long consignorId, Long consigneeId, ScoreRuleOrderVExtraVO extraInfo, ScoreRuleDO scoreRuleDO) {
ArrayList<Long> users = new ArrayList<>(); ArrayList<Long> users = new ArrayList<>();
// 发货人和收货人都要判断给分 // 发货人和收货人都要判断给分
Long userId = order.getUserId();
Long consigneeId = order.getOrderConsigneeDO().getCustomerId();
Long consigneeMemberId;
boolean isBackendOrder = userId <= 0; boolean isBackendOrder = userId <= 0;
// 校验订单入口 // 校验订单入口
if (!isOrderEntryValid(extraInfo.getOrderEntry(), isBackendOrder)) { if (!isOrderEntryValid(extraInfo.getOrderEntry(), isBackendOrder)) {
...@@ -209,7 +208,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -209,7 +208,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
} }
// 如果是后台下单,重新获取发货人用户ID // 如果是后台下单,重新获取发货人用户ID
if (isBackendOrder) { if (isBackendOrder) {
userId = getCustomerMemberId(order.getOrderConsignorDO().getCustomerId()); userId = getCustomerMemberId(consignorId);
if (userId == null) { if (userId == null) {
userId = 0L; userId = 0L;
} }
...@@ -224,7 +223,12 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -224,7 +223,12 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
} else { } else {
addValidUser(users, userId); addValidUser(users, userId);
} }
consigneeMemberId = getCustomerMemberId(consigneeId);
// 判断收货人
if (consigneeId == null || consigneeId <= 0) {
return users;
}
Long consigneeMemberId = getCustomerMemberId(consigneeId);
if (consigneeMemberId != null && consigneeMemberId > 0) { if (consigneeMemberId != null && consigneeMemberId > 0) {
if (consigneeMemberId.equals(userId)) { if (consigneeMemberId.equals(userId)) {
log.info("Order in shipping listener: The consignee is the same as the sender, userId:{}", userId); log.info("Order in shipping listener: The consignee is the same as the sender, userId:{}", userId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment