Commit ef6c09cc authored by zhangfeng's avatar zhangfeng

订单V值触发

parent d6811845
...@@ -54,5 +54,10 @@ ...@@ -54,5 +54,10 @@
<artifactId>yudao-module-order-api</artifactId> <artifactId>yudao-module-order-api</artifactId>
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-customer-core</artifactId>
<version>${revision}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
package cn.iocoder.yudao.module.member.listener; package cn.iocoder.yudao.module.member.listener;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil; 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;
...@@ -8,6 +9,8 @@ import cn.iocoder.boot.module.order.api.dto.OrderObjectiveApiDO; ...@@ -8,6 +9,8 @@ import cn.iocoder.boot.module.order.api.dto.OrderObjectiveApiDO;
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.framework.apollo.core.event.OrderInShippingEvent; import cn.iocoder.yudao.framework.apollo.core.event.OrderInShippingEvent;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerContacts.CustomerContactsDO;
import cn.iocoder.yudao.module.customer.service.customerContacts.CustomerContactsService;
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.scoreLog.MemberUserScoreLogDO; import cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO;
...@@ -23,6 +26,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -23,6 +26,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -46,6 +50,8 @@ public class OrderInShippingListener { ...@@ -46,6 +50,8 @@ public class OrderInShippingListener {
private MemberUserScoreApi memberUserScoreApi; private MemberUserScoreApi memberUserScoreApi;
@Resource @Resource
private MemberUserScoreLogService memberUserScoreLogService; private MemberUserScoreLogService memberUserScoreLogService;
@Resource
private CustomerContactsService customerContactsService;
@EventListener(OrderInShippingEvent.class) @EventListener(OrderInShippingEvent.class)
public void listen(OrderInShippingEvent event) { public void listen(OrderInShippingEvent event) {
...@@ -107,6 +113,9 @@ public class OrderInShippingListener { ...@@ -107,6 +113,9 @@ public class OrderInShippingListener {
} }
if (scoreCount > scoreRuleDO.getGetScoreOnce()) { if (scoreCount > scoreRuleDO.getGetScoreOnce()) {
scoreCount = scoreRuleDO.getGetScoreOnce(); scoreCount = scoreRuleDO.getGetScoreOnce();
} else if (scoreCount <= 0) {
log.info("Order in shipping listener: The score count is less than or equal to 0,orderId:{}", orderId);
return;
} }
// 会员id // 会员id
...@@ -118,14 +127,27 @@ public class OrderInShippingListener { ...@@ -118,14 +127,27 @@ public class OrderInShippingListener {
return; return;
} }
String[] orderEntry = orderEntryString.split(","); String[] orderEntry = orderEntryString.split(",");
// TODO:后台下单会员获取待确认
if (userId <= 0) { if (userId <= 0) {
// 后台下单 // 后台下单
if (!ArrayUtil.contains(orderEntry, String.valueOf(PlatformTypeEnum.BACKEND.getValue()))) { if (!ArrayUtil.contains(orderEntry, String.valueOf(PlatformTypeEnum.BACKEND.getValue()))) {
log.info("Order in shipping listener: The order is placed by the background, userId:{}", userId); log.info("Order in shipping listener: The order is placed by the background, userId:{}", userId);
return; return;
} }
//userId = order.getCustomerId(); // 查询客户绑定会员
List<CustomerContactsDO> customerContacts = customerContactsService.getCustomerContactsListByCustomerId(order.getCustomerId());
if (CollectionUtil.isEmpty(customerContacts)) {
log.info("Order in shipping listener: The customer is not bound to the member, customerId:{}", order.getCustomerId());
return;
}
for (CustomerContactsDO customerContact : customerContacts) {
if (customerContact.getIsDefault() == 1 && customerContact.getUserid() != null) {
userId = customerContact.getUserid();
}
}
if (userId <= 0) {
log.info("Order in shipping listener: The customer is not have default userId, customerId:{}", order.getCustomerId());
return;
}
} else if (!ArrayUtil.contains(orderEntry, String.valueOf(PlatformTypeEnum.APP.getValue())) && !ArrayUtil.contains(orderEntry, String.valueOf(PlatformTypeEnum.WEB.getValue()))) { } else if (!ArrayUtil.contains(orderEntry, String.valueOf(PlatformTypeEnum.APP.getValue())) && !ArrayUtil.contains(orderEntry, String.valueOf(PlatformTypeEnum.WEB.getValue()))) {
log.info("Order in shipping listener: The order is placed by the app or web, userId:{}", userId); log.info("Order in shipping listener: The order is placed by the app or web, userId:{}", userId);
return; return;
...@@ -183,13 +205,13 @@ public class OrderInShippingListener { ...@@ -183,13 +205,13 @@ public class OrderInShippingListener {
private Integer computeScoreCount(BigDecimal weightOrVolume, List<ScoreRuleOrderVExtraVO.OrderVRule> orderVRules) { private Integer computeScoreCount(BigDecimal weightOrVolume, List<ScoreRuleOrderVExtraVO.OrderVRule> orderVRules) {
Integer scoreCount = 0; Integer scoreCount = 0;
int w = weightOrVolume.setScale(0, RoundingMode.HALF_UP).intValue(); int w = weightOrVolume.setScale(0, RoundingMode.HALF_UP).intValue();
ScoreRuleOrderVExtraVO.OrderVRule lastRule = orderVRules.get(orderVRules.size() - 1);
if (w >= lastRule.getHigh()) {
scoreCount = lastRule.getScore();
}
for (int i = orderVRules.size() - 1; i >= 0; i--) { for (int i = orderVRules.size() - 1; i >= 0; i--) {
ScoreRuleOrderVExtraVO.OrderVRule orderVRule = orderVRules.get(i); ScoreRuleOrderVExtraVO.OrderVRule orderVRule = orderVRules.get(i);
if (w > orderVRule.getHigh()) { if (orderVRule.getLow() <= w && orderVRule.getHigh() >= w) {
scoreCount = orderVRule.getScore();
break;
}
if (orderVRule.getLow() <= w && orderVRule.getHigh() > w) {
scoreCount = orderVRule.getScore(); scoreCount = orderVRule.getScore();
break; break;
} }
......
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