Commit 7bc0cadf authored by Smile's avatar Smile Committed by wux

会员积分规则匹配,当有两个不相冲突的积分规则,只匹配一个问题修改

parent 141ac79e
......@@ -16,6 +16,8 @@ import cn.iocoder.yudao.module.customer.vo.customer.customerContacts.CustomerCon
import cn.iocoder.yudao.module.customer.vo.customer.customerContacts.CustomerContactsPageReqVO;
import cn.iocoder.yudao.module.customer.vo.customer.customerContacts.CustomerContactsUpdateReqVO;
import cn.iocoder.yudao.module.ecw.service.paramValid.ParamValidatorService;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.commons.lang3.StringUtils;
......@@ -44,6 +46,8 @@ public class CustomerContactsServiceImpl extends AbstractService<CustomerContact
private CustomerContactsMapper customerContactsMapper;
@Resource
private ParamValidatorService paramValidatorService;
@Resource
private MemberUserApi memberUserApi;
@Override
public Long createCustomerContacts(CustomerContactsCreateReqVO createReqVO) {
......@@ -124,7 +128,14 @@ public class CustomerContactsServiceImpl extends AbstractService<CustomerContact
@Override
public List<CustomerContactsDO> getCustomerContactsListByCustomerId(Long customerId) {
return customerContactsMapper.selectList(new LambdaQueryWrapperX<CustomerContactsDO>().eqIfPresent(CustomerContactsDO::getCustomerId, customerId));
List<CustomerContactsDO> customerContactsDOS = customerContactsMapper.selectList(new LambdaQueryWrapperX<CustomerContactsDO>().eqIfPresent(CustomerContactsDO::getCustomerId, customerId));
customerContactsDOS.forEach(customerContactsDO -> {
if (customerContactsDO.getUserid()!=null) {
UserRespDTO user = memberUserApi.getUser(customerContactsDO.getUserid());
customerContactsDO.setUsername(user.getNickname());
}
});
return customerContactsDOS;
}
@Override
......
......@@ -35,6 +35,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.module.member.enums.TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT;
......@@ -97,13 +98,15 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
consigneeId = order.getOrderConsigneeDO().getCustomerId();
}
// 获取订单规则
ScoreRuleDO scoreRuleDO = this.getMatchRule(order, consigneeId);
if (Objects.isNull(scoreRuleDO)) {
List<ScoreRuleDO> scoreRuleDOList = this.getMatchRule(order, consigneeId);
if (Objects.isNull(scoreRuleDOList)) {
log.info("Order in shipping listener: No score rule match,orderID:{}", orderId);
orderOperateLogDTO.setBody(JSONObject.toJSONString(logBody.append("无匹配积分规则;")));
orderApi.createOrderOperateLog(orderOperateLogDTO);
return;
}
for (int i = 0; i < scoreRuleDOList.size(); i++) {
ScoreRuleDO scoreRuleDO = scoreRuleDOList.get(i);
orderOperateLogDTO.setCreator(scoreRuleDO.getCode());
ScoreRuleOrderVExtraVO extraInfo = JSONUtil.toBean(scoreRuleDO.getExtra(), ScoreRuleOrderVExtraVO.class);
String lockKey1;
......@@ -164,6 +167,8 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
} finally {
multiLock.unlock();
}
}
orderOperateLogDTO.setBody(JSONObject.toJSONString(logBody.append("获取积分成功")));
orderApi.createOrderOperateLog(orderOperateLogDTO);
}
......@@ -213,7 +218,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
boolean hasConsignor =ArrayUtil.contains(customerSideArray, String.valueOf(CustomerSideEnum.CONSIGNOR.getValue()));
// 发货人和收货人都要判断给分
boolean isBackendOrder = userId <= 0;
logNote.append("此订单为").append(isBackendOrder ? "后台" : "客户端").append("下单;");
logNote.append("匹配规则"+scoreRuleDO.getCode()+" 此订单为").append(isBackendOrder ? "后台" : "客户端").append("下单;");
// 如果是后台下单,重新获取发货人用户ID
if (isBackendOrder) {
CustomerContactsDO contactsDO = getCustomerMemberId(consignorId);
......@@ -224,7 +229,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
if (!hasConsignor&&customerSideArray.length!=0){
logNote.append("发货人绑定会员:").append(contactsDO.getUsername()).append(",会员ID:").append(userId).append(";");
userId = 0L;
logNote.append("积分规则客户方不包含发货人");
logNote.append("积分规则客户方不包含发货人 ");
}
if (hasConsignor||customerSideArray.length==0){
userId = contactsDO.getUserid();
......@@ -269,7 +274,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
log.info("Order in shipping listener: The consignee has reached the maximum score, userId:{}, scoreRuleId:{}", consigneeMemberId, scoreRuleDO.getId());
} else {
if (!hasConsignee&&customerSideArray.length!=0){
logNote.append("积分规则客户方不包含收货人");
logNote.append("积分规则客户方不包含收货人 ");
}
if (hasConsignee||customerSideArray.length==0){
users.add(consigneeMemberId);
......@@ -303,7 +308,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
* @param consigneeId
* @return
*/
private ScoreRuleDO getMatchRule(OrderRespDTO order, long consigneeId) {
private List<ScoreRuleDO> getMatchRule(OrderRespDTO order, long consigneeId) {
List<ScoreRuleDO> scoreRuleDOs = scoreRuleService.getEnableOrderVRule();
if (CollectionUtil.isEmpty(scoreRuleDOs)) {
return null;
......@@ -341,7 +346,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
}
}
return true;
}).findFirst().orElse(null);
}).collect(Collectors.toList());
}
/**
......
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