| | |
| | | package com.yeshi.fanli.service.impl.order; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.entity.dy.DYOrder; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.order.TeamRewardManager; |
| | | import com.yeshi.fanli.util.goods.douyin.DYUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | |
| | | @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的位置ID |
| | | || pid.equalsIgnoreCase(specialRelationId)) {// 设置渠道ID当做会员运营ID的位置ID |
| | | return false; |
| | | } else if (!StringUtil.isNullOrEmpty(order.getRelationId())) { |
| | | return true; |
| | |
| | | } |
| | | } |
| | | |
| | | //获取推广位类型 |
| | | 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); |
| | |
| | | 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 ("口碑".equalsIgnoreCase(list.get(0).getOrderType()) |
| | | && pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_KOUBEI_PID)) {// 口碑自购 |
| | | fanliOrderMap.put(orderId, list); |
| | | } else { |
| | | if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId()) |
| | | || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 设置渠道ID当做会员运营ID的位置ID |
| | | 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的位置ID |
| | | 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 ("口碑".equalsIgnoreCase(list.get(0).getOrderType()) |
| | | && pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_KOUBEI_PID)) {// 口碑自购 |
| | | fanliOrderMap.put(orderId, list); |
| | | } else { |
| | | fanliOrderMap.put(orderId, list); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void fanliShare(Date maxTime) { |
| | | public int fanliShare(Date maxTime) { |
| | | // 查出邀请赚的用户ID |
| | | List<Integer> typeList = new ArrayList<>(); |
| | | typeList.add(HongBaoV2.TYPE_SHARE_GOODS); |
| | |
| | | } |
| | | } |
| | | |
| | | return uidSets.size(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | try { |
| | | orderMoneySettleService.inviteSettleSuning(uid, maxPreGetTime); |
| | | } catch (OrderMoneySettleException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | try { |
| | | orderMoneySettleService.inviteSettleDY(uid, maxPreGetTime); |
| | | } catch (OrderMoneySettleException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } catch (OrderMoneySettleException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | try { |
| | | orderMoneySettleService.shareSettleDY(uid, maxPreGetTime); |
| | | } catch (OrderMoneySettleException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
| | |
| | | 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())) {// 处理饿了么,口碑的订单 |
| | | 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(); |
| | | } |
| | |
| | | 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; |
| | |
| | | public void processJDOrder(JDOrder order) { |
| | | if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0) |
| | | return; |
| | | // 拆单的不做处理 |
| | | if (order.getValidCode() == 2) |
| | | return; |
| | | |
| | | // 拆单且不在commonorder中的不做处理 |
| | | if (order.getValidCode() == 2) { |
| | | List<CommonOrder> list= commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_JD,order.getOrderId()+""); |
| | | if(list==null||list.size()==0) { |
| | | return; |
| | | } |
| | | } |
| | | // 根据ext1与subUnionId跟单 |
| | | String uidStr = order.getExt1(); |
| | | if (StringUtil.isNullOrEmpty(uidStr)) |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | */ |
| | | 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; |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 处理京东返利订单 |
| | | * 处理唯品会返利订单 |
| | | * |
| | | * @param vipShopOrder |
| | | * @param uid |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理拼多多自购返利订单 |
| | | * 处理苏宁自购返利订单 |
| | | * |
| | | * @param suningOrder |
| | | * @param uid |
| | |
| | | } |
| | | |
| | | /** |
| | | * 处理拼多多分享订单 |
| | | * 处理苏宁分享订单 |
| | | * |
| | | * @param suningOrder |
| | | * @param uid |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void processDYOrder(DYOrder order) { |
| | | if (order == null) |
| | | return; |
| | | |
| | | |
| | | // 根据ext1与subUnionId跟单 |
| | | String extra_info = order.getExternal_info(); |
| | | |
| | | Long uid = DYUtil.getUid(extra_info); |
| | | String type = DYUtil.getTypeFromExtraInfo(extra_info); |
| | | if ("buy".equalsIgnoreCase(type))// 返利订单 |
| | | { |
| | | processFanLiDYOrder(order, uid); |
| | | lostOrderService.processSuceess(order.getOrder_id() + "", Constant.SOURCE_TYPE_DY); |
| | | } else if ("share".equalsIgnoreCase(type)) {// 分享订单 |
| | | if (uid == null)// 分享订单不允许找回 |
| | | return; |
| | | processShareDYOrder(order, uid); |
| | | } else {// 处理是否有订单找回的状态 |
| | | processFanLiDYOrder(order, null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理抖音返利订单 |
| | | * |
| | | * @param dyOrder |
| | | * @param uid |
| | | */ |
| | | private void processFanLiDYOrder(DYOrder dyOrder, Long uid) { |
| | | |
| | | BigDecimal totalMoney = new BigDecimal(dyOrder.getTotal_pay_amount()).divide(new BigDecimal(100),2, RoundingMode.FLOOR); |
| | | |
| | | // 加入订单 |
| | | Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(dyOrder.getOrder_id() + "", |
| | | Constant.SOURCE_TYPE_DY); |
| | | if (uid == null && oldOrder != null && oldOrder.getBeizhu() != null && oldOrder.getBeizhu().contains("补单")) |
| | | uid = oldOrder.getUserInfo().getId(); |
| | | |
| | | if (uid == null) |
| | | return; |
| | | |
| | | if (oldOrder == null)// 新增 |
| | | { |
| | | Order order = new Order(); |
| | | order.setBeizhu("抖音返利订单"); |
| | | order.setCreatetime(System.currentTimeMillis()); |
| | | order.setOrderId(dyOrder.getOrder_id() + ""); |
| | | order.setOrderType(Constant.SOURCE_TYPE_DY); |
| | | order.setState( |
| | | (dyOrder.getFlow_point().equalsIgnoreCase(DYOrder.FLOW_POINT_REFUND)) ? Order.STATE_SHIXIAO : Order.STATE_YIZHIFU); |
| | | order.setUserInfo(new UserInfo(uid)); |
| | | order.setVersion(2); |
| | | order.setThirdCreateTime(new Date(TimeUtil.convertToTimeTemp(dyOrder.getPay_success_time(),"yyyy-MM-dd HH:mm:ss"))); |
| | | order.setMoney(totalMoney); |
| | | // 加入到订单表 |
| | | orderMapper.insertSelective(order); |
| | | } else { |
| | | Order updateOrder = new Order(); |
| | | updateOrder.setId(oldOrder.getId()); |
| | | updateOrder.setMoney(totalMoney); |
| | | orderMapper.updateByPrimaryKeySelective(updateOrder); |
| | | } |
| | | |
| | | try { |
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addDYOrder(dyOrder, uid); |
| | | addHongBaoWithMQ(commonOrderList, dyOrder.getOrder_id() + "", uid, Constant.SOURCE_TYPE_DY, |
| | | HongBaoV2.TYPE_ZIGOU); |
| | | |
| | | if (isCommonOrderAllAdd(commonOrderList)) { |
| | | Order order = new Order(); |
| | | order.setOrderId(dyOrder.getOrder_id()); |
| | | order.setOrderType(Constant.SOURCE_TYPE_DY); |
| | | order.setUserInfo(new UserInfo(uid)); |
| | | try { |
| | | if (Constant.ENABLE_MQ) |
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } catch (CommonOrderException e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, "addDYOrder或addHongBao出错", "订单号:" + dyOrder.getOrder_id()); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理抖音分享订单 |
| | | * |
| | | * @param dyOrder |
| | | * @param uid |
| | | */ |
| | | private void processShareDYOrder(DYOrder dyOrder, Long uid) { |
| | | try { |
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addDYOrder(dyOrder, uid); |
| | | addHongBaoWithMQ(commonOrderList, dyOrder.getOrder_id() + "", uid, Constant.SOURCE_TYPE_DY, |
| | | HongBaoV2.TYPE_SHARE_GOODS); |
| | | if (isCommonOrderAllAdd(commonOrderList)) { |
| | | Order order = new Order(); |
| | | order.setOrderId(dyOrder.getOrder_id()); |
| | | order.setOrderType(Constant.SOURCE_TYPE_DY); |
| | | order.setUserInfo(new UserInfo(uid)); |
| | | try { |
| | | if (Constant.ENABLE_MQ) |
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } catch (CommonOrderException e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, "addDYOrder或addHongBao出错", "订单号:" + dyOrder.getOrder_id()); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void repairCommonOrderByByTaoBaoOrder(String orderId) { |
| | | // 根据订单号查询淘宝订单 |
| | |
| | | |
| | | @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: |
| | |
| | | else |
| | | result = hongBaoV2AddManager.addHongBao(coList, hongBaoType); |
| | | } catch (HongBaoException e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + orderId); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | if (e.getCode() != HongBaoException.CODE_ORDER_WEIQUAN) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + orderId); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } catch (UserAccountException e) { |
| | | |
| | | } |
| | | if (result == null) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | if (!Constant.IS_TEST) |
| | | if (result.getResultCode() == HongBaoAddResult.CODE_ADD) {// 只发送新增消息 |
| | | OrderMQMsg mqMsg = new OrderMQMsg(orderId, sourceType, uid, OrderMQMsg.HANDLE_TYPE_ADD, |