From 0912f56a392bdf48315747c64ec0c18bf0aa29a6 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 30 六月 2021 19:07:11 +0800 Subject: [PATCH] 礼金红包兼容 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java | 216 +++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 151 insertions(+), 65 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java index 54323a3..0f15783 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java @@ -13,6 +13,9 @@ import javax.annotation.Resource; +import com.yeshi.fanli.entity.SystemEnum; +import com.yeshi.fanli.entity.SystemPIDInfo; +import com.yeshi.fanli.service.manger.PIDManager; import com.yeshi.fanli.service.manger.order.TeamRewardManager; import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; import org.springframework.stereotype.Service; @@ -167,18 +170,24 @@ @Resource private TeamRewardManager teamRewardManager; + @Resource + private PIDManager pidManager; + /** * 鏄惁鏄垎浜鍗� * * @param order * @return */ - private boolean isShareOrder(TaoBaoOrder order) { + private boolean isShareOrder(SystemEnum system, TaoBaoOrder order) { + + String specialRelationId = pidManager.getPidCache(system, Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanliChannel); + List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID); String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(), order.getSourceMediaId(), order.getAdPositionId()); if (!StringUtil.isNullOrEmpty(order.getSpecialId()) - || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 璁剧疆娓犻亾ID褰撳仛浼氬憳杩愯惀ID鐨勪綅缃甀D + || pid.equalsIgnoreCase(specialRelationId)) {// 璁剧疆娓犻亾ID褰撳仛浼氬憳杩愯惀ID鐨勪綅缃甀D return false; } else if (!StringUtil.isNullOrEmpty(order.getRelationId())) { return true; @@ -198,6 +207,44 @@ } } + //鑾峰彇鎺ㄥ箍浣嶇被鍨� + private SystemPIDInfo.PidType getPidType(int sourceType, String pid) { + List<SystemPIDInfo> pidInfoList = pidManager.listPidInfoByPidCache(pid, sourceType); + if ((pidInfoList == null || pidInfoList.size() == 0) && sourceType == Constant.SOURCE_TYPE_TAOBAO) { + pidInfoList = pidManager.listPidInfoByPidCache(pid, Constant.SOURCE_TYPE_ELME); + } + + SystemPIDInfo.PidType pidType = null; + if (pidInfoList != null && pidInfoList.size() > 0) { + pidType = pidInfoList.get(0).getPidType(); + } + return pidType; + } + + //鏍规嵁PID鑾峰彇绯荤粺 + private List<SystemEnum> getPidSystems(String pid) { + List<SystemEnum> systemList = new ArrayList<>(); + List<SystemPIDInfo> pidInfoList = pidManager.listPidInfoByPidCache(pid, null); + + if (pidInfoList != null) { + for (SystemPIDInfo pidInfo : pidInfoList) { + systemList.add(pidInfo.getSystem()); + } + } + return systemList; + } + + private Set<Integer> getPidSourceTypes(String pid) { + Set<Integer> sourceTypes = new HashSet<>(); + List<SystemPIDInfo> pidInfoList = pidManager.listPidInfoByPidCache(pid, null); + if (pidInfoList != null) { + for (SystemPIDInfo pidInfo : pidInfoList) { + sourceTypes.add(pidInfo.getSourceType()); + } + } + return sourceTypes; + } + @Override public synchronized void processOrder(Map<String, List<TaoBaoOrder>> orders) { List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID); @@ -214,37 +261,48 @@ List<TaoBaoOrder> list = orders.get(orderId); String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(), list.get(0).getSourceMediaId(), list.get(0).getAdPositionId()); - if ("楗夸簡涔�".equalsIgnoreCase(list.get(0).getOrderType()) - && !pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT)) { - // 楗夸簡涔堣鍗曞紑濮嬪綊鍏ュ埌娣樺疂璁㈠崟 - if (TimeUtil.convertToTimeTemp(list.get(0).getCreateTime(), - "yyyy-MM-dd HH:mm:ss") >= Constant.NEW_ORDER_FANLI_RULE_TIME) { - fanliOrderMap.put(orderId, list); - } else { - elmeOrderMap.put(orderId, list); - } - } else if ("鍙g".equalsIgnoreCase(list.get(0).getOrderType()) - && pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_KOUBEI_PID)) {// 鍙g鑷喘 - fanliOrderMap.put(orderId, list); - } else { - if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId()) - || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 璁剧疆娓犻亾ID褰撳仛浼氬憳杩愯惀ID鐨勪綅缃甀D - fanliOrderMap.put(orderId, list); - } else if (!StringUtil.isNullOrEmpty(list.get(0).getRelationId())) { - shareOrderMap.put(orderId, list); - } else { - // 閫氳繃绾㈠寘鏌ヨ - CommonOrder commonOrder = commonOrderService - .selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO, list.get(0).getTradeId()); - if (commonOrder != null) { - HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId()); - if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null - && hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) { - shareOrderMap.put(orderId, list); - continue; - } + + SystemPIDInfo.PidType pidType = getPidType(Constant.SOURCE_TYPE_TAOBAO, pid); + + //--------鍒嗙鑷喘,鍒嗕韩,楗夸簡涔堣鍗曠被鍨�------- + if (pidType != null) { + if ("楗夸簡涔�".equalsIgnoreCase(list.get(0).getOrderType()) + && pidType != SystemPIDInfo.PidType.share) { + // 楗夸簡涔堣鍗曞紑濮嬪綊鍏ュ埌娣樺疂璁㈠崟 + if (TimeUtil.convertToTimeTemp(list.get(0).getCreateTime(), + "yyyy-MM-dd HH:mm:ss") >= Constant.NEW_ORDER_FANLI_RULE_TIME) { + fanliOrderMap.put(orderId, list); + } else { + elmeOrderMap.put(orderId, list); } + } else { + if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId()) + || pidType == SystemPIDInfo.PidType.fanliChannel) {// 璁剧疆娓犻亾ID褰撳仛浼氬憳杩愯惀ID鐨勪綅缃甀D + fanliOrderMap.put(orderId, list); + } else if (!StringUtil.isNullOrEmpty(list.get(0).getRelationId())) { + shareOrderMap.put(orderId, list); + } else { + // 閫氳繃绾㈠寘鏌ヨ + CommonOrder commonOrder = commonOrderService + .selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO, list.get(0).getTradeId()); + + if (commonOrder != null) { + HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId()); + if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null + && hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) { + shareOrderMap.put(orderId, list); + continue; + } + } + fanliOrderMap.put(orderId, list); + } + } + } else { + if ("鍙g".equalsIgnoreCase(list.get(0).getOrderType()) + && pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_KOUBEI_PID)) {// 鍙g鑷喘 + fanliOrderMap.put(orderId, list); + } else { fanliOrderMap.put(orderId, list); } } @@ -746,26 +804,30 @@ String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(), orderList.get(0).getSourceMediaId(), orderList.get(0).getAdPositionId()); + SystemPIDInfo.PidType pidType = getPidType(Constant.SOURCE_TYPE_TAOBAO, pid); + List<SystemEnum> systemList = getPidSystems(pid); + Set<Integer> sourceTypes = getPidSourceTypes(pid); + Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(orderId, Constant.SOURCE_TYPE_TAOBAO); // 鍘熸潵涓嶅瓨鍦ㄨ鍗� Long uid = null; if (oldOrder == null) { Long targetUid = null; - if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID) + if (pidType != null && pidType == SystemPIDInfo.PidType.fanliChannel && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 澶勭悊闈炶繑鍒╁晢鍝佸簱鐨勫晢鍝� targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId()); - } else if ((pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_ELEME_PID) + } else if ((sourceTypes.contains(Constant.SOURCE_TYPE_ELME) || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_KOUBEI_PID)) && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 澶勭悊楗夸簡涔�,鍙g鐨勮鍗� UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService - .getByRelationId(orderList.get(0).getRelationId(), null); + .getByRelationId(orderList.get(0).getRelationId(), systemList); if (extraInfo != null) { targetUid = extraInfo.getUser().getId(); } } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) { UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService - .getBySpecialId(orderList.get(0).getSpecialId(), null); + .getBySpecialId(orderList.get(0).getSpecialId(), systemList); if (info != null && info.getUser() != null) targetUid = info.getUser().getId(); } @@ -903,7 +965,8 @@ if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0) return false; Long positionId = order.getOrderItemList().get(0).getPositionId(); - if (positionId == JDApiUtil.POSITION_SHARE) {// 鍒嗕韩璁㈠崟 + SystemPIDInfo.PidType pidType = getPidType(Constant.SOURCE_TYPE_JD, positionId + ""); + if (pidType != null && pidType == SystemPIDInfo.PidType.share) {// 鍒嗕韩璁㈠崟 return true; } return false; @@ -926,15 +989,21 @@ if (!StringUtil.isNullOrEmpty(uidStr) && NumberUtil.isNumeric(uidStr)) uid = Long.parseLong(uidStr); Long positionId = order.getOrderItemList().get(0).getPositionId(); - if (positionId == JDApiUtil.POSITION_FANLI)// 杩斿埄璁㈠崟 - { - processFanLiJDOrder(order, uid); - lostOrderService.processSuceess(order.getOrderId() + "", Constant.SOURCE_TYPE_JD); - } else if (positionId == JDApiUtil.POSITION_SHARE) {// 鍒嗕韩璁㈠崟 - if (uid == null)// 鍒嗕韩璁㈠崟涓嶅厑璁告壘鍥� - return; - processShareJDOrder(order, uid); - } else {// 澶勭悊鏄惁鏈夎鍗曟壘鍥炵殑鐘舵�� + SystemPIDInfo.PidType pidType = getPidType(Constant.SOURCE_TYPE_JD, positionId + ""); + + if (pidType != null) { + if (pidType == SystemPIDInfo.PidType.fanli)// 杩斿埄璁㈠崟 + { + processFanLiJDOrder(order, uid); + lostOrderService.processSuceess(order.getOrderId() + "", Constant.SOURCE_TYPE_JD); + } else if (pidType == SystemPIDInfo.PidType.share) {// 鍒嗕韩璁㈠崟 + if (uid == null)// 鍒嗕韩璁㈠崟涓嶅厑璁告壘鍥� + return; + processShareJDOrder(order, uid); + } else {// 澶勭悊鏄惁鏈夎鍗曟壘鍥炵殑鐘舵�� + processFanLiJDOrder(order, null); + } + } else { processFanLiJDOrder(order, null); } } @@ -1057,7 +1126,9 @@ */ private boolean isShareOrder(PDDOrder pddOrder) { String positionId = pddOrder.getpId(); - if (PinDuoDuoApiUtil.PID_SHARE.equalsIgnoreCase(positionId)) + SystemPIDInfo.PidType pidType = getPidType(Constant.SOURCE_TYPE_PDD, positionId); + + if (pidType != null && pidType == SystemPIDInfo.PidType.share) return true; else return false; @@ -1075,15 +1146,20 @@ if (!StringUtil.isNullOrEmpty(customParameters)) uid = Long.parseLong(PinDuoDuoUtil.getUidFromCustomParams(customParameters)); String positionId = pddOrder.getpId(); - if (PinDuoDuoApiUtil.PID_FANLI.equalsIgnoreCase(positionId))// 杩斿埄璁㈠崟 - { - processFanLiPDDOrder(pddOrder, uid); - lostOrderService.processSuceess(pddOrder.getOrderSn(), Constant.SOURCE_TYPE_PDD); - } else if (PinDuoDuoApiUtil.PID_SHARE.equalsIgnoreCase(positionId)) {// 鍒嗕韩璁㈠崟 - if (uid == null)// 鍒嗕韩璁㈠崟涓嶅厑璁告壘鍥� - return; - processSharePDDOrder(pddOrder, uid); - } else {// 澶勭悊鏄惁鏈夎鍗曟壘鍥炵殑鐘舵�� + SystemPIDInfo.PidType pidType = getPidType(Constant.SOURCE_TYPE_PDD, positionId); + if (pidType != null) { + if (pidType == SystemPIDInfo.PidType.fanli)// 杩斿埄璁㈠崟 + { + processFanLiPDDOrder(pddOrder, uid); + lostOrderService.processSuceess(pddOrder.getOrderSn(), Constant.SOURCE_TYPE_PDD); + } else if (pidType == SystemPIDInfo.PidType.share) {// 鍒嗕韩璁㈠崟 + if (uid == null)// 鍒嗕韩璁㈠崟涓嶅厑璁告壘鍥� + return; + processSharePDDOrder(pddOrder, uid); + } else {// 澶勭悊鏄惁鏈夎鍗曟壘鍥炵殑鐘舵�� + processFanLiPDDOrder(pddOrder, null); + } + } else { processFanLiPDDOrder(pddOrder, null); } } @@ -1341,15 +1417,22 @@ if (!StringUtil.isNullOrEmpty(uidStr)) uid = Long.parseLong(uidStr); String positionId = suningOrder.getPositionId(); - if (SuningApiUtil.PID_BUY.equalsIgnoreCase(positionId))// 杩斿埄璁㈠崟 - { - processFanLiSuningOrder(suningOrder, uid); - lostOrderService.processSuceess(suningOrder.getOrderCode(), Constant.SOURCE_TYPE_SUNING); - } else if (PinDuoDuoApiUtil.PID_SHARE.equalsIgnoreCase(positionId)) {// 鍒嗕韩璁㈠崟 - if (uid == null)// 鍒嗕韩璁㈠崟涓嶅厑璁告壘鍥� - return; - processShareSuningOrder(suningOrder, uid); - } else {// 澶勭悊鏄惁鏈夎鍗曟壘鍥炵殑鐘舵�� + + SystemPIDInfo.PidType pidType = getPidType(Constant.SOURCE_TYPE_SUNING, positionId); + + if (pidType != null) { + if (pidType == SystemPIDInfo.PidType.fanli)// 杩斿埄璁㈠崟 + { + processFanLiSuningOrder(suningOrder, uid); + lostOrderService.processSuceess(suningOrder.getOrderCode(), Constant.SOURCE_TYPE_SUNING); + } else if (pidType == SystemPIDInfo.PidType.share) {// 鍒嗕韩璁㈠崟 + if (uid == null)// 鍒嗕韩璁㈠崟涓嶅厑璁告壘鍥� + return; + processShareSuningOrder(suningOrder, uid); + } else {// 澶勭悊鏄惁鏈夎鍗曟壘鍥炵殑鐘舵�� + processFanLiSuningOrder(suningOrder, null); + } + } else { processFanLiSuningOrder(suningOrder, null); } } @@ -1485,9 +1568,12 @@ @Override public boolean isShareOrder(CommonOrder commonOrder) { + //鑾峰彇绯荤粺 + UserInfo user = userInfoMapper.selectByPrimaryKey(commonOrder.getUserInfo().getId()); + SystemEnum system = user.getSystem(); switch (commonOrder.getSourceType()) { case Constant.SOURCE_TYPE_TAOBAO: - return isShareOrder(taoBaoOrderService.selectByTradeId(commonOrder.getTradeId())); + return isShareOrder(system, taoBaoOrderService.selectByTradeId(commonOrder.getTradeId())); case Constant.SOURCE_TYPE_JD: return isShareOrder(jdOrderService.selectDetailByOrderId(Long.parseLong(commonOrder.getOrderNo()))); case Constant.SOURCE_TYPE_PDD: -- Gitblit v1.8.0