Commit 75672463 authored by zhangfeng's avatar zhangfeng

feat(601): 订单V值触发修改

parent 6302496a
...@@ -5,7 +5,7 @@ import cn.hutool.core.util.ArrayUtil; ...@@ -5,7 +5,7 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.iocoder.boot.module.order.api.OrderApi; import cn.iocoder.boot.module.order.api.OrderApi;
import cn.iocoder.boot.module.order.api.dto.OrderItemRespDTO; import cn.iocoder.boot.module.order.api.dto.OrderItemRespDTO;
import cn.iocoder.boot.module.order.api.dto.OrderObjectiveApiDO; import cn.iocoder.boot.module.order.api.dto.OrderOperateLogDTO;
import cn.iocoder.boot.module.order.api.dto.OrderRespDTO; import cn.iocoder.boot.module.order.api.dto.OrderRespDTO;
import cn.iocoder.boot.module.order.enums.OrderStatusApiEnum; import cn.iocoder.boot.module.order.enums.OrderStatusApiEnum;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerContacts.CustomerContactsDO; import cn.iocoder.yudao.module.customer.dal.dataobject.customerContacts.CustomerContactsDO;
...@@ -13,12 +13,16 @@ import cn.iocoder.yudao.module.customer.service.customerContacts.CustomerContact ...@@ -13,12 +13,16 @@ import cn.iocoder.yudao.module.customer.service.customerContacts.CustomerContact
import cn.iocoder.yudao.module.member.api.score.MemberUserScoreApi; import cn.iocoder.yudao.module.member.api.score.MemberUserScoreApi;
import cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO; import cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO; import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.enums.*; import cn.iocoder.yudao.module.member.enums.PlatformTypeEnum;
import cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum;
import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum;
import cn.iocoder.yudao.module.member.enums.TransportTypeEnum;
import cn.iocoder.yudao.module.member.mq.message.ScoreMessage; import cn.iocoder.yudao.module.member.mq.message.ScoreMessage;
import cn.iocoder.yudao.module.member.service.scoreLog.MemberUserScoreLogService; import cn.iocoder.yudao.module.member.service.scoreLog.MemberUserScoreLogService;
import cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService; import cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService;
import cn.iocoder.yudao.module.member.service.user.MemberUserService; import cn.iocoder.yudao.module.member.service.user.MemberUserService;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO; import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.redisson.RedissonMultiLock; import org.redisson.RedissonMultiLock;
...@@ -35,6 +39,8 @@ import java.util.List; ...@@ -35,6 +39,8 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static cn.iocoder.yudao.module.member.enums.TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT;
/** /**
* @author zhangfeng * @author zhangfeng
*/ */
...@@ -54,13 +60,12 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -54,13 +60,12 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
@Override @Override
public void addScore(ScoreMessage message) { public void addScore(ScoreMessage message) {
Long orderId = message.getOrderId();
try { try {
Thread.sleep(3000); Thread.sleep(3000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.error("Order in shipping listener: Thread sleep error", e); log.error("Order in shipping listener: Thread sleep error", e);
} }
log.info("Received order V message,orderID:{}", message.getOrderId());
Long orderId = message.getOrderId();
// 获取订单信息 // 获取订单信息
OrderRespDTO order; OrderRespDTO order;
try { try {
...@@ -74,64 +79,72 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -74,64 +79,72 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
return; return;
} }
orderId = order.getOrderId(); orderId = order.getOrderId();
log.info("Received order V message,orderID:{}", orderId);
OrderOperateLogDTO orderOperateLogDTO = new OrderOperateLogDTO();
orderOperateLogDTO.setOrderId(orderId);
orderOperateLogDTO.setCreatorName("订单V值规则");
orderOperateLogDTO.setType("积分操作");
orderOperateLogDTO.setUserType(2);
orderOperateLogDTO.setMsg("订单起航/起运计算积分");
StringBuilder logBody = new StringBuilder();
// 订单状态应为起运 // 订单状态应为起运
if (!Objects.equals(order.getStatus(), OrderStatusApiEnum.IN_SHIPPING.getValue())) { if (!Objects.equals(order.getStatus(), OrderStatusApiEnum.IN_SHIPPING.getValue())) {
log.info("Order in shipping listener: The order status is not in shipping,orderID:{}", orderId); log.info("Order in shipping listener: The order status is not in shipping,orderID:{}", orderId);
return; return;
} }
// 增加订单无收货人时校验
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();
}
// 获取订单规则 // 获取订单规则
Integer transportId = order.getTransportId(); ScoreRuleDO scoreRuleDO = this.getMatchRule(order, consigneeId);
ScoreRuleDO scoreRuleDO = scoreRuleService.getEnableScoreRuleByType(ScoreRuleTypeEnum.ORDER_V, TransportTypeEnum.parseByValue(transportId));
if (Objects.isNull(scoreRuleDO)) { if (Objects.isNull(scoreRuleDO)) {
log.info("Order in shipping listener: No score rule match,orderID:{}", orderId); log.info("Order in shipping listener: No score rule match,orderID:{}", orderId);
orderOperateLogDTO.setBody(JSONObject.toJSONString(logBody.append("无匹配积分规则;")));
orderApi.createOrderOperateLog(orderOperateLogDTO);
return; return;
} }
// 规则是否包含目的地提货点,0代表所有提货点 orderOperateLogDTO.setCreator(scoreRuleDO.getCode());
OrderObjectiveApiDO orderObjectiveDO = order.getOrderObjectiveDO();
ScoreRuleOrderVExtraVO extraInfo = JSONUtil.toBean(scoreRuleDO.getExtra(), ScoreRuleOrderVExtraVO.class); ScoreRuleOrderVExtraVO extraInfo = JSONUtil.toBean(scoreRuleDO.getExtra(), ScoreRuleOrderVExtraVO.class);
String[] warehouseIds = extraInfo.getReceiveAddr().split(",");
if (!Objects.equals(warehouseIds[0], "0") && !ArrayUtil.contains(warehouseIds, orderObjectiveDO.getObjectiveWarehouseId().toString())) {
log.info("Order in shipping listener: The rule does not contain the order destination warehouse,orderID:{},warehouseId:{}", orderId, orderObjectiveDO.getObjectiveWarehouseId().toString());
return;
}
String lockKey1; String lockKey1;
if (order.getUserId() > 0) { if (order.getUserId() > 0) {
lockKey1 = "score:rule:order:lock:" + order.getUserId(); lockKey1 = "score:rule:order:lock:" + order.getUserId();
} else { } else {
lockKey1 = "score:rule:order:lock:" + order.getOrderConsignorDO().getCustomerId(); lockKey1 = "score:rule:order:lock:" + order.getOrderConsignorDO().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; String lockKey2 = "score:rule:order:lock:" + consigneeId;
RLock lock1 = redissonClient.getLock(lockKey1); RLock lock1 = redissonClient.getLock(lockKey1);
RLock lock2 = redissonClient.getLock(lockKey2); RLock lock2 = consigneeId == 0 ? null : redissonClient.getLock(lockKey2);
RedissonMultiLock multiLock = new RedissonMultiLock(lock1, lock2); RedissonMultiLock multiLock = new RedissonMultiLock(lock1, lock2);
try { try {
boolean tryLock = multiLock.tryLock(2, 10, TimeUnit.SECONDS); boolean tryLock = multiLock.tryLock(2, 10, TimeUnit.SECONDS);
if (!tryLock) { if (!tryLock) {
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.getUserId(), order.getOrderConsignorDO().getCustomerId(), consigneeId, extraInfo, scoreRuleDO); List<Long> userIds = getAddScoreUser(order.getUserId(), order.getOrderConsignorDO().getCustomerId(), consigneeId, scoreRuleDO, logBody);
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);
orderOperateLogDTO.setBody(JSONObject.toJSONString(logBody));
orderApi.createOrderOperateLog(orderOperateLogDTO);
return; return;
} }
// 计算积分 // 计算积分
Integer scoreCount = getScoreCount(transportId, order.getChannelId(), extraInfo.getChannel(), extraInfo.getOrderVRule(), orderId); Integer scoreCount = getScoreCount(order.getTransportId(), extraInfo.getOrderVRule(), orderId);
logBody.append("根据").append(scoreRuleDO.getCode()).append("规则计算积分为:").append(scoreCount).append(";");
if (scoreCount == 0) { if (scoreCount == 0) {
log.info("Order in shipping listener: The score count is less than or equal to 0,orderId:{}", orderId); log.info("Order in shipping listener: The score count is less than or equal to 0,orderId:{}", orderId);
orderOperateLogDTO.setBody(JSONObject.toJSONString(logBody));
orderApi.createOrderOperateLog(orderOperateLogDTO);
return; return;
} }
// 增加积分 // 增加积分
for (Long userId : userIds) { for (Long userId : userIds) {
try { try {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>(1);
map.put("orderId", orderId); map.put("orderId", orderId);
memberUserScoreApi.operateScore(MemberUserScoreOperateReqDTO.builder() memberUserScoreApi.operateScore(MemberUserScoreOperateReqDTO.builder()
.memberId(userId) .memberId(userId)
...@@ -144,7 +157,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -144,7 +157,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
.extParam(map) .extParam(map)
.build() .build()
); );
log.info("Order V rule add score success,ruleID:{},orderID:{},userID:{}", scoreRuleDO.getId(), message.getOrderId(), userId); log.info("Order V rule add score success,ruleID:{},orderID:{},userID:{}", scoreRuleDO.getId(), orderId, userId);
} catch (Exception e) { } catch (Exception e) {
log.error("Order in shipping listener: operateScore error", e); log.error("Order in shipping listener: operateScore error", e);
} }
...@@ -154,19 +167,19 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -154,19 +167,19 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
} finally { } finally {
multiLock.unlock(); multiLock.unlock();
} }
orderOperateLogDTO.setBody(JSONObject.toJSONString(logBody.append("获取积分成功")));
orderApi.createOrderOperateLog(orderOperateLogDTO);
} }
/** /**
* 根据规则获得要加多少分 * 根据规则获得要加多少分
* *
* @param transportId * @param transportId
* @param channelId
* @param allowChannels
* @param orderVRules * @param orderVRules
* @param orderId * @param orderId
* @return * @return
*/ */
private Integer getScoreCount(Integer transportId, Long channelId, List<Long> allowChannels, List<ScoreRuleOrderVExtraVO.OrderVRule> orderVRules, Long orderId) { private Integer getScoreCount(Integer transportId, List<ScoreRuleOrderVExtraVO.OrderVRule> orderVRules, Long orderId) {
Integer scoreCount = 0; Integer scoreCount = 0;
List<OrderItemRespDTO> orderItems = orderApi.getOrderItemsByOrderId(orderId); List<OrderItemRespDTO> orderItems = orderApi.getOrderItemsByOrderId(orderId);
if (orderItems == null) { if (orderItems == null) {
...@@ -182,12 +195,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -182,12 +195,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
if (transportId == TransportTypeEnum.OCEAN_LCL.getValue()) { if (transportId == TransportTypeEnum.OCEAN_LCL.getValue()) {
// 海运算体积 // 海运算体积
scoreCount = computeScoreCount(totalVolume, orderVRules); scoreCount = computeScoreCount(totalVolume, orderVRules);
} else if (transportId == TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT.getValue()) { } else if (transportId == SPECIAL_LINE_AIR_FREIGHT.getValue()) {
// 空运校验渠道
// 渠道id
if (!allowChannels.contains(channelId)) {
return 0;
}
// 空运算重量 // 空运算重量
scoreCount = computeScoreCount(totalWeight, orderVRules); scoreCount = computeScoreCount(totalWeight, orderVRules);
} }
...@@ -197,41 +205,46 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -197,41 +205,46 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
/** /**
* 获取需要加分的用户 * 获取需要加分的用户
*/ */
private List<Long> getAddScoreUser(Long userId, Long consignorId, Long consigneeId, ScoreRuleOrderVExtraVO extraInfo, ScoreRuleDO scoreRuleDO) { private List<Long> getAddScoreUser(Long userId, Long consignorId, Long consigneeId, ScoreRuleDO scoreRuleDO, StringBuilder logNote) {
ArrayList<Long> users = new ArrayList<>(); ArrayList<Long> users = new ArrayList<>();
// 发货人和收货人都要判断给分 // 发货人和收货人都要判断给分
boolean isBackendOrder = userId <= 0; boolean isBackendOrder = userId <= 0;
// 校验订单入口 logNote.append("此订单为").append(isBackendOrder ? "后台" : "客户端").append("下单;");
if (!isOrderEntryValid(extraInfo.getOrderEntry(), isBackendOrder)) {
return null;
}
// 如果是后台下单,重新获取发货人用户ID // 如果是后台下单,重新获取发货人用户ID
if (isBackendOrder) { if (isBackendOrder) {
userId = getCustomerMemberId(consignorId); CustomerContactsDO contactsDO = getCustomerMemberId(consignorId);
if (userId == null) { if (contactsDO == null || contactsDO.getUserid() == 0) {
userId = 0L; userId = 0L;
logNote.append("发货人未绑定会员;");
} else {
userId = contactsDO.getUserid();
logNote.append("发货人绑定会员:").append(contactsDO.getUsername()).append(",会员ID:").append(userId).append(";");
} }
} }
// 校验首单:发货和收货都算首单,按客户查,只有发货人收货人都是首单才算首单
if (!isFirstOrderValid(consignorId, consigneeId, extraInfo)) {
return null;
}
// 校验积分上限,添加加分用户列表 // 校验积分上限,添加加分用户列表
if (isBackendOrder && isUserScoreMaxed(userId, scoreRuleDO)) { if (isBackendOrder && isUserScoreMaxed(userId, scoreRuleDO)) {
log.info("Order in shipping listener: The user has reached the maximum score, userId:{}, scoreRuleId:{}", userId, scoreRuleDO.getId()); log.info("Order in shipping listener: The user has reached the maximum score, userId:{}, scoreRuleId:{}", userId, scoreRuleDO.getId());
logNote.append("发货人").append(scoreRuleDO.getCode()).append("规则积分已到上限;");
} else { } else {
addValidUser(users, userId); addValidUser(users, userId);
} }
// 判断收货人 // 判断收货人
if (consigneeId == null || consigneeId <= 0) { if (consigneeId == null || consigneeId <= 0) {
logNote.append("此订单无收货人;");
return users; return users;
} }
Long consigneeMemberId = getCustomerMemberId(consigneeId); CustomerContactsDO consigneeMemberDO = getCustomerMemberId(consigneeId);
if (consigneeMemberId != null && consigneeMemberId > 0) { if (consigneeMemberDO == null) {
logNote.append("收货人未绑定会员;");
}
Long consigneeMemberId = consigneeMemberDO == null ? 0L : consigneeMemberDO.getUserid();
if (consigneeMemberId > 0) {
logNote.append("收货人绑定会员:").append(consigneeMemberDO.getUsername()).append(",会员ID:").append(consigneeMemberId).append(";");
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);
} else if (isBackendOrder && isUserScoreMaxed(consigneeMemberId, scoreRuleDO)) { } else if (isBackendOrder && isUserScoreMaxed(consigneeMemberId, scoreRuleDO)) {
logNote.append("收货人").append(scoreRuleDO.getCode()).append("规则积分已到上限;");
log.info("Order in shipping listener: The consignee has reached the maximum score, userId:{}, scoreRuleId:{}", consigneeMemberId, scoreRuleDO.getId()); log.info("Order in shipping listener: The consignee has reached the maximum score, userId:{}, scoreRuleId:{}", consigneeMemberId, scoreRuleDO.getId());
} else { } else {
users.add(consigneeMemberId); users.add(consigneeMemberId);
...@@ -258,20 +271,67 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -258,20 +271,67 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
} }
/** /**
* 校验是否为首单且首单是否有效 * 获取匹配的规则
*
* @param order
* @param consigneeId
* @return
*/ */
private boolean isFirstOrderValid(Long consignorId, Long consigneeId, ScoreRuleOrderVExtraVO extraInfo) { private ScoreRuleDO getMatchRule(OrderRespDTO order, long consigneeId) {
if (extraInfo.getFirstOrder() == YesOrNoTypeEnum.YES.ordinal()) { List<ScoreRuleDO> scoreRuleDOs = scoreRuleService.getEnableOrderVRule();
if (!orderApi.isFirstOrder(consignorId)) { if (CollectionUtil.isEmpty(scoreRuleDOs)) {
log.info("Order in shipping listener: consignor not first order,consignorId:{}", consignorId); return null;
}
// 运输方式
Integer transportId = order.getTransportId();
// 首单
Integer isFirstOrder = isFirstOrderValid(order.getOrderConsignorDO().getCustomerId(), consigneeId);
// 提货点
String warehouseId = order.getOrderObjectiveDO().getObjectiveWarehouseId().toString();
// 渠道
Long channelId = order.getChannelId();
// 订单入口
boolean isBackendOrder = order.getUserId() <= 0;
return scoreRuleDOs.stream().filter(scoreRuleDO -> {
ScoreRuleOrderVExtraVO extraInfo = JSONUtil.toBean(scoreRuleDO.getExtra(), ScoreRuleOrderVExtraVO.class);
if (!isOrderEntryValid(extraInfo.getOrderEntry(), isBackendOrder)) {
return false;
}
if (!transportId.equals(extraInfo.getTransportType())) {
return false;
}
if (!isFirstOrder.equals(extraInfo.getFirstOrder())) {
return false; return false;
} }
if (!orderApi.isFirstOrder(consigneeId)) { String[] warehouseIds = extraInfo.getReceiveAddr().split(",");
log.info("Order in shipping listener: consignee not first order,consigneeId:{}", consigneeId); // 0代表所有提货点
if (!Objects.equals(warehouseIds[0], "0") && !ArrayUtil.contains(warehouseIds, warehouseId)) {
return false; return false;
} }
if (transportId.equals(SPECIAL_LINE_AIR_FREIGHT.getValue())) {
if (!extraInfo.getChannel().contains(channelId)) {
return false;
}
}
return true;
}).findFirst().orElse(null);
}
/**
* 校验是否为首单
*/
private Integer isFirstOrderValid(Long consignorId, Long consigneeId) {
// 发货和收货都算首单,按客户查,只有发货人收货人都是首单才算首单
if (!orderApi.isFirstOrder(consignorId)) {
log.info("Order in shipping listener: consignor not first order,consignorId:{}", consignorId);
return 1;
} }
return true; if (consigneeId != 0 && !orderApi.isFirstOrder(consigneeId)) {
log.info("Order in shipping listener: consignee not first order,consigneeId:{}", consigneeId);
return 1;
}
return 0;
} }
/** /**
...@@ -295,17 +355,17 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -295,17 +355,17 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
} }
/** /**
* 根据客户id获取会员id * 根据客户id获取会员
* *
* @param customerId * @param customerId
* @return * @return
*/ */
private Long getCustomerMemberId(Long customerId) { private CustomerContactsDO getCustomerMemberId(Long customerId) {
List<CustomerContactsDO> customerContacts = customerContactsService.getCustomerContactsListByCustomerId(customerId); List<CustomerContactsDO> customerContacts = customerContactsService.getCustomerContactsListByCustomerId(customerId);
if (!CollectionUtil.isEmpty(customerContacts)) { if (!CollectionUtil.isEmpty(customerContacts)) {
for (CustomerContactsDO customerContact : customerContacts) { for (CustomerContactsDO customerContact : customerContacts) {
if (customerContact.getIsDefault() == 1 && customerContact.getUserid() != null) { if (customerContact.getIsDefault() == 1 && customerContact.getUserid() != null) {
return customerContact.getUserid(); return customerContact;
} }
} }
} }
......
...@@ -109,20 +109,12 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> { ...@@ -109,20 +109,12 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
ScoreRuleDO getEnabledOrderVScoreRuleByTransportType(Integer transportType); ScoreRuleDO getEnabledOrderVScoreRuleByTransportType(Integer transportType);
/** /**
* 根据类型获取已启用积分规则 * 根据类型获取已启用积分规则(仅推荐和注册)
* @param scoreRuleType * @param scoreRuleType
* @return * @return
*/ */
ScoreRuleDO getEnableScoreRuleByType(ScoreRuleTypeEnum scoreRuleType); ScoreRuleDO getEnableScoreRuleByType(ScoreRuleTypeEnum scoreRuleType);
/**
* 根据类型获取已启用积分规则(带运输类型)
* @param scoreRuleType
* @param transportType
* @return
*/
ScoreRuleDO getEnableScoreRuleByType(ScoreRuleTypeEnum scoreRuleType, TransportTypeEnum transportType);
List<WarehouseTreeRegionSimpleVO> getWarehouseTreeRegionListSimple(); List<WarehouseTreeRegionSimpleVO> getWarehouseTreeRegionListSimple();
/** /**
...@@ -151,4 +143,10 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> { ...@@ -151,4 +143,10 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
* @return * @return
*/ */
Boolean setScoreRuleSwitch(SwitchReqVo switchReqVo); Boolean setScoreRuleSwitch(SwitchReqVo switchReqVo);
/**
* 获取当前时间已启用的订单V值规则
* @return
*/
List<ScoreRuleDO> getEnableOrderVRule();
} }
...@@ -31,6 +31,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraV ...@@ -31,6 +31,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraV
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO; import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO; import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -596,28 +597,6 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -596,28 +597,6 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
return enableScoreRule; return enableScoreRule;
} }
@Override
public ScoreRuleDO getEnableScoreRuleByType(ScoreRuleTypeEnum scoreRuleType, TransportTypeEnum transportType) {
ScoreRuleDO enableScoreRule;
switch (scoreRuleType) {
case ORDER_V:
enableScoreRule = scoreRuleRedisDao.getEnableScoreRule(scoreRuleType, transportType);
if (enableScoreRule == null) {
enableScoreRule = getEnabledOrderVScoreRuleByTransportType(transportType.getValue());
if (enableScoreRule == null) {
return null;
}
scoreRuleRedisDao.setEnableScoreRule(enableScoreRule);
}
return enableScoreRule;
case RECOMMEND:
case REGISTER:
return getEnableScoreRuleByType(scoreRuleType);
default:
return null;
}
}
@Override @Override
public List<WarehouseTreeRegionSimpleVO> getWarehouseTreeRegionListSimple() { public List<WarehouseTreeRegionSimpleVO> getWarehouseTreeRegionListSimple() {
List<WarehouseTreeRegionVO> list = ListUtils.sum( List<WarehouseTreeRegionVO> list = ListUtils.sum(
...@@ -726,4 +705,15 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -726,4 +705,15 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
public Boolean setScoreRuleSwitch(SwitchReqVo switchReqVo) { public Boolean setScoreRuleSwitch(SwitchReqVo switchReqVo) {
return scoreRuleRedisDao.setScoreRuleSwitch(switchReqVo.getSwitchState()); return scoreRuleRedisDao.setScoreRuleSwitch(switchReqVo.getSwitchState());
} }
@Override
public List<ScoreRuleDO> getEnableOrderVRule() {
LambdaQueryWrapper<ScoreRuleDO> queryWrapper = new LambdaQuery<ScoreRuleDO>()
.eq(ScoreRuleDO::getType, ScoreRuleTypeEnum.ORDER_V.getValue())
.eq(ScoreRuleDO::getStatus, ScoreRuleStatusEnum.ENABLED.getValue())
.lt(ScoreRuleDO::getStartTime, LocalDateTime.now())
.gt(ScoreRuleDO::getEndTime, LocalDateTime.now());
List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectList(queryWrapper);
return scoreRuleDOS;
}
} }
package cn.iocoder.boot.module.order.api; package cn.iocoder.boot.module.order.api;
import cn.iocoder.boot.module.order.api.dto.OrderItemRespDTO; import cn.iocoder.boot.module.order.api.dto.OrderItemRespDTO;
import cn.iocoder.boot.module.order.api.dto.OrderOperateLogDTO;
import cn.iocoder.boot.module.order.api.dto.OrderRespDTO; import cn.iocoder.boot.module.order.api.dto.OrderRespDTO;
import java.util.List; import java.util.List;
...@@ -21,6 +22,10 @@ public interface OrderApi { ...@@ -21,6 +22,10 @@ public interface OrderApi {
* 根据订单id获取所有订单项 * 根据订单id获取所有订单项
*/ */
List<OrderItemRespDTO> getOrderItemsByOrderId(Long orderId); List<OrderItemRespDTO> getOrderItemsByOrderId(Long orderId);
/**
* 添加订单操作日志
*/
void createOrderOperateLog(OrderOperateLogDTO orderId);
/** /**
......
package cn.iocoder.boot.module.order.api.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 订单操作日志 DTO
*/
@Data
public class OrderOperateLogDTO {
@ApiModelProperty(value = "订单ID", required = true)
@NotNull(message = "订单ID不能为空")
private Long orderId;
@ApiModelProperty(value = "变更后订单详情数据")
private String body;
@ApiModelProperty(value = "请求地址")
private String requestUrl;
@ApiModelProperty(value = "变更类型")
private String type;
@ApiModelProperty(value = "变更描述")
private String msg;
@ApiModelProperty(value = "备注说明")
private String note;
@ApiModelProperty(value = "操作人类型:1 会员 2 管理员")
private Integer userType;
@ApiModelProperty(value = "创建者")
private String creator;
@ApiModelProperty(value = "创建者名称")
private String creatorName;
}
package cn.iocoder.boot.module.order.api.dto; package cn.iocoder.boot.module.order.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
@Data @Data
......
...@@ -13,6 +13,8 @@ import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO; ...@@ -13,6 +13,8 @@ import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO; import cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO;
import cn.iocoder.yudao.module.order.service.order.*; import cn.iocoder.yudao.module.order.service.order.*;
import cn.iocoder.yudao.module.order.service.order.impl.OrderItemServiceImpl; import cn.iocoder.yudao.module.order.service.order.impl.OrderItemServiceImpl;
import cn.iocoder.yudao.module.order.service.orderOperateLog.OrderOperateLogService;
import cn.iocoder.yudao.module.order.vo.orderOperateLog.OrderOperateLogCreateReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -45,6 +47,8 @@ public class OrderApiImpl implements OrderApi { ...@@ -45,6 +47,8 @@ public class OrderApiImpl implements OrderApi {
private OrderItemServiceImpl orderItemService; private OrderItemServiceImpl orderItemService;
@Resource @Resource
private OrderConsignorService orderConsignorService; private OrderConsignorService orderConsignorService;
@Resource
private OrderOperateLogService orderOperateLogService;
@Override @Override
public OrderRespDTO getOrder(Long id, String orderNo) { public OrderRespDTO getOrder(Long id, String orderNo) {
...@@ -101,6 +105,13 @@ public class OrderApiImpl implements OrderApi { ...@@ -101,6 +105,13 @@ public class OrderApiImpl implements OrderApi {
return null; return null;
} }
@Override
public void createOrderOperateLog(OrderOperateLogDTO orderOperateLogDTO) {
OrderOperateLogCreateReqVO createReqVO = new OrderOperateLogCreateReqVO();
BeanUtils.copyProperties(orderOperateLogDTO, createReqVO);
orderOperateLogService.createOrderAsyncOperateLog(createReqVO);
}
@Override @Override
public boolean mergeOrder(Long customerIdSaved, Long customerIdDeleted) { public boolean mergeOrder(Long customerIdSaved, Long customerIdDeleted) {
......
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