Commit cd91b3bb by 查志伟

Merge branch 'feature/订单推送改造' into develop

# Conflicts:
#	order-management/src/main/java/cn/freemud/management/service/handle/PaymentHandle.java
parents 48cf4762 38aafa19
......@@ -17,6 +17,7 @@ import cn.freemud.amqp.Header;
import cn.freemud.amqp.MQAction;
import cn.freemud.amqp.MQMessage;
import cn.freemud.amqp.MQService;
import cn.freemud.config.PushOrderConfig;
import cn.freemud.constant.RedisKeyConstant;
import cn.freemud.entities.dto.OrderExtInfoDto;
import cn.freemud.entities.dto.OrderStatusChangeRequestDto;
......@@ -66,6 +67,9 @@ public class OrderCallBackMQService {
private static final String backOrdersNotifyActivityExchange="program.backorders_notify_activity_exchange";
@Autowired
private LogUtil logUtil;
@Autowired
private PushOrderConfig pushOrderConfig;
public void sendOrderMQ(OrderCallBackRequestVo body) {
OrderInfoReqs orderInfoReqs = getOrderInfoReqs(body);
if (orderInfoReqs == null) {
......@@ -190,7 +194,8 @@ public class OrderCallBackMQService {
if (checkParkingOrders(orderInfoReqs)) {
return false;
}
return true;
//订单推送改造, 过渡期部分聚合层推送, 部分不推送,由基础服务推送
return pushOrderConfig.needPushOrder(orderInfoReqs.getPartnerId(), orderInfoReqs.getStoreId());
}
private OrderInfoReqs getWechatReportOrderInfoReqs(OrderCallBackRequestVo body) {
......
package cn.freemud.config;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.*;
/**
* @author Clover.z
* @version 1.0.0
* @since 1.0.0
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "push-order")
public class PushOrderConfig {
/**
* 不推送开放平台的商户和门店配置
* 格式: 商户号:门店号,门店号,...;商户号:门店号,门店号,...;...
* 如果只配置了商户号, 则表示全门店都不推送
*/
private String config;
/**
* 不推送开放平台的商户门店信息
* key:商户号
*/
private Map<String, List<String>> notPushMap;
public synchronized void initMap() {
if (null == notPushMap) {
notPushMap = new HashMap<>();
if (StringUtils.isBlank(config)) return;
String[] cfgList = config.split(";");
for (String cfg : cfgList) {
//格式必须是 商户号:门店号
String[] s = cfg.split(":");
if (s.length == 1) {
//全商户
notPushMap.put(s[0], new ArrayList<>());
} else {
// 不满足格式直接忽略
if (s.length != 2) continue;
notPushMap.put(s[0], Arrays.asList(s[1].split(",")));
}
}
}
}
/**
* 判断门店的订单 是否需要推送三方
* @param partnerId 商户号
* @param storeCode 门店号
* @return 是否需要推送
*/
public boolean needPushOrder(String partnerId, String storeCode) {
// 未配置, 聚合层全部不推送,由基础服务统一推送开放平台
if (StringUtils.isBlank(config)) return false;
if (null == notPushMap) initMap();
// 商户号是否在推送黑名单配置中
List<String> storeList = notPushMap.get(partnerId);
// 配置了商户,没有配置门店, 表示所有门店都不推送
if (CollectionUtils.isEmpty(storeList)) return false;
return !storeList.contains(storeCode);
}
}
......@@ -2323,7 +2323,7 @@ public class OrderServiceImpl implements Orderservice {
messageTemplateRequest.setMessageEventType(messageEventType);
com.freemud.application.sdk.api.base.BaseResponse baseResponse = this.messageTemplatePushService.sendTemplateMsg(messageTemplateRequest);
if (!Objects.equals(baseResponse.getCode(), ResponseResultEnum.SUCCESS.getCode())) {
AppLogUtil.errorLog("发送支付成功模板消息 失败", orderBean.getOid(), JSON.toJSONString(baseResponse), null);
AppLogUtil.printLog("发送支付成功模板消息 失败", orderBean.getOid(), JSON.toJSONString(baseResponse));
}
} catch (Exception e) {
AppLogUtil.errorLog("sendTemplateMsg_error", JSONObject.toJSONString(orderBean), JSONObject.toJSONString(messageTemplateRequest), e);
......
......@@ -359,7 +359,7 @@ public class CouponServiceImpl implements CouponService {
if (Objects.equals(couponStateVo.getType(), CouponTypeEnum.TYPE_1.getCode())) {
activityCouponBean.setDiscountAmount(couponStateVo.getOriginalPrice() + "");
} else if (Objects.equals(couponStateVo.getType(), CouponTypeEnum.TYPE_3.getCode())) {
// TODO 折扣券 百分值10 乘以10 前端统一除以100作为操作依据
// TODO 折扣券 百分值10 乘以10 前端统一除以100作为操作依据 _> 废弃, 现在默认 不乘10
activityCouponBean.setDiscountAmount(couponStateVo.getDiscount() != null ? couponStateVo.getDiscount() * 10 + "" : "0");
}else if (Objects.equals(couponStateVo.getType(), CouponTypeEnum.TYPE_5.getCode())) {
// 这里需要加入 配送券逻辑 如果为null 表示 配送券金额 全免, 否则就是部分减免
......
......@@ -121,7 +121,7 @@ public class CalculationSharingEquallyService {
Goods find = null;
for (CartGoods product : shoppingCartGoodsResponseVo.getProducts()) {
if (goods!=null) {
find = goods.stream().filter((k) -> k.getCartGoodsUid().equals(product.getCartGoodsUid())).findFirst().get();
find = goods.stream().filter((k) -> k.getCartGoodsUid().equals(product.getCartGoodsUid())).findFirst().orElseGet(null);
}
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = calculationCommonService.convertCartGoods2DetailGoodsList(find, product,shoppingCartInfoRequestVo.getPartnerId());
cartGoodsDetailDtoList.add(cartGoodsDetailDto);
......
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