From 1c9ef349751f42840b695de9143ab91a376cd492 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 12 九月 2019 11:40:53 +0800
Subject: [PATCH] 金币榜
---
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 208 insertions(+), 22 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 45a9165..b485e18 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
@@ -26,6 +26,7 @@
import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.dto.HongBao;
+import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
@@ -41,18 +42,20 @@
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
-import com.yeshi.fanli.exception.HongBaoException;
-import com.yeshi.fanli.exception.OrderItemException;
-import com.yeshi.fanli.exception.TaoBaoWeiQuanException;
import com.yeshi.fanli.exception.money.UserMoneyDetailException;
import com.yeshi.fanli.exception.order.CommonOrderException;
+import com.yeshi.fanli.exception.order.HongBaoException;
+import com.yeshi.fanli.exception.order.OrderItemException;
+import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
+import com.yeshi.fanli.service.inter.jd.JDOrderService;
import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.order.LostOrderService;
import com.yeshi.fanli.service.inter.order.OrderProcessService;
+import com.yeshi.fanli.service.inter.pdd.PDDOrderService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
@@ -67,6 +70,7 @@
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
+import com.yeshi.fanli.util.cmq.PlaceOrderCMQManager;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
@@ -125,6 +129,43 @@
@Resource
private HongBaoV2Service hongBaoV2Service;
+
+ @Resource
+ private JDOrderService jdOrderService;
+
+ @Resource
+ private PDDOrderService pddOrderService;
+
+ /**
+ * 鏄惁鏄垎浜鍗�
+ *
+ * @param order
+ * @return
+ */
+ private boolean isShareOrder(TaoBaoOrder order) {
+ 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
+ return false;
+ } else if (!StringUtil.isNullOrEmpty(order.getRelationId())) {
+ return true;
+ } else {
+ // 閫氳繃绾㈠寘鏌ヨ
+ CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
+ order.getTradeId());
+
+ if (commonOrder != null) {
+ HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
+ if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null
+ && hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
@Override
public synchronized void processOrder(Map<String, List<TaoBaoOrder>> orders) {
@@ -316,6 +357,12 @@
// Constant.SOURCE_TYPE_PDD
return;
}
+
+ // 濡傛灉鏄嫾澶氬/浜笢缁存潈鍒欒繑鍥烇紝涓嶉渶瑕佽繑鍒�
+ if ((hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_PDD
+ || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_JD)
+ && hongBaoOrder.getCommonOrder().getState() == CommonOrder.STATE_WQ)
+ return;
if (hongBaoOrder.getCommonOrder() != null
&& hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_TAOBAO) {
@@ -941,11 +988,21 @@
orderMapper.updateByPrimaryKeySelective(updateOrder);
// 鐢ㄧ涓�涓瓙璁㈠崟閿佸畾鐢ㄦ埛
- List<CommonOrder> commonOrderList = null;
+ List<CommonOrderAddResultDTO> commonOrderList = null;
try {
commonOrderList = commonOrderService.addTaoBaoOrder(orderList, uid);
- hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
+ hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
+ if (isCommonOrderAllAdd(commonOrderList)) {
+ Order order = new Order();
+ order.setOrderId(orderId);
+ order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+ order.setUserInfo(new UserInfo(uid));
+ try {
+ PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
+ } catch (Exception e) {
+ }
+ }
} catch (CommonOrderException e) {
try {
LogHelper.errorDetailInfo(e, "addTaoBaoOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + orderId);
@@ -993,14 +1050,40 @@
// 鐢ㄧ涓�涓瓙璁㈠崟閿佸畾鐢ㄦ埛
try {
- List<CommonOrder> commonOrders = commonOrderService.addTaoBaoOrder(orderList, uid);
- hongBaoV2Service.addHongBao(commonOrders, HongBaoV2.TYPE_SHARE_GOODS);
+ List<CommonOrderAddResultDTO> commonOrders = commonOrderService.addTaoBaoOrder(orderList, uid);
+ hongBaoV2Service.addHongBao(convertCommonOrder(commonOrders), HongBaoV2.TYPE_SHARE_GOODS);
+ if (isCommonOrderAllAdd(commonOrders)) {
+ Order order = new Order();
+ order.setOrderId(orderId);
+ order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+ order.setUserInfo(new UserInfo(uid));
+ try {
+ PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
+ } catch (Exception e) {
+ }
+ }
} catch (CommonOrderException e) {
e.printStackTrace();
} catch (HongBaoException e1) {
e1.printStackTrace();
}
}
+ }
+
+ /**
+ * 鏄惁涓哄垎浜鍗�
+ *
+ * @param order
+ * @return
+ */
+ private boolean isShareOrder(JDOrder order) {
+ if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0)
+ return false;
+ Long positionId = order.getOrderItemList().get(0).getPositionId();
+ if (positionId == JDApiUtil.POSITION_SHARE) {// 鍒嗕韩璁㈠崟
+ return true;
+ }
+ return false;
}
@Override
@@ -1086,8 +1169,18 @@
}
try {
- List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
- hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
+ List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
+ hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
+ if (isCommonOrderAllAdd(commonOrderList)) {
+ Order order = new Order();
+ order.setOrderId(jdOrder.getOrderId() + "");
+ order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+ order.setUserInfo(new UserInfo(uid));
+ try {
+ PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
+ } catch (Exception e) {
+ }
+ }
} catch (CommonOrderException e) {
try {
LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + jdOrder.getOrderId());
@@ -1110,23 +1203,47 @@
* @param uid
*/
@Transactional
- private void processShareJDOrder(JDOrder order, Long uid) {
+ private void processShareJDOrder(JDOrder jdOrder, Long uid) {
try {
- List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(order, uid);
- hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
+ List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
+ hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_SHARE_GOODS);
+ if (isCommonOrderAllAdd(commonOrderList)) {
+ Order order = new Order();
+ order.setOrderId(jdOrder.getOrderId() + "");
+ order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+ order.setUserInfo(new UserInfo(uid));
+ try {
+ PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
+ } catch (Exception e) {
+ }
+ }
} catch (CommonOrderException e) {
try {
- LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + order.getOrderId());
+ LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + jdOrder.getOrderId());
} catch (Exception e1) {
e1.printStackTrace();
}
} catch (HongBaoException e) {
try {
- LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + order.getOrderId());
+ LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + jdOrder.getOrderId());
} catch (Exception e1) {
e1.printStackTrace();
}
}
+ }
+
+ /**
+ * 鏄惁鏄垎浜禋璁㈠崟
+ *
+ * @param order
+ * @return
+ */
+ private boolean isShareOrder(PDDOrder pddOrder) {
+ String positionId = pddOrder.getpId();
+ if (PinDuoDuoApiUtil.PID_SHARE.equalsIgnoreCase(positionId))
+ return true;
+ else
+ return false;
}
/**
@@ -1202,8 +1319,18 @@
try {
List<PDDOrder> pddOrderList = new ArrayList<>();
pddOrderList.add(pddOrder);
- List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
- hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
+ List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
+ hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
+ if (isCommonOrderAllAdd(commonOrderList)) {
+ Order order = new Order();
+ order.setOrderId(pddOrder.getOrderSn());
+ order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+ order.setUserInfo(new UserInfo(uid));
+ try {
+ PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
+ } catch (Exception e) {
+ }
+ }
} catch (CommonOrderException e) {
try {
LogHelper.errorDetailInfo(e, "addPDDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + pddOrder.getOrderSn());
@@ -1226,21 +1353,31 @@
* @param uid
*/
@Transactional
- private void processSharePDDOrder(PDDOrder order, Long uid) {
+ private void processSharePDDOrder(PDDOrder pddOrder, Long uid) {
try {
List<PDDOrder> pddOrderList = new ArrayList<>();
- pddOrderList.add(order);
- List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
- hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
+ pddOrderList.add(pddOrder);
+ List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
+ hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_SHARE_GOODS);
+ if (isCommonOrderAllAdd(commonOrderList)) {
+ Order order = new Order();
+ order.setOrderId(pddOrder.getOrderSn());
+ order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+ order.setUserInfo(new UserInfo(uid));
+ try {
+ PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
+ } catch (Exception e) {
+ }
+ }
} catch (CommonOrderException e) {
try {
- LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + order.getOrderId());
+ LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + pddOrder.getOrderId());
} catch (Exception e1) {
e1.printStackTrace();
}
} catch (HongBaoException e) {
try {
- LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + order.getOrderId());
+ LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + pddOrder.getOrderId());
} catch (Exception e1) {
e1.printStackTrace();
}
@@ -1266,4 +1403,53 @@
}
}
+
+ @Override
+ public boolean isShareOrder(CommonOrder commonOrder) {
+ switch (commonOrder.getSourceType()) {
+ case Constant.SOURCE_TYPE_TAOBAO:
+ return isShareOrder(taoBaoOrderService.selectByTradeId(commonOrder.getTradeId()));
+ case Constant.SOURCE_TYPE_JD:
+ return isShareOrder(jdOrderService.selectDetailByOrderId(Long.parseLong(commonOrder.getOrderNo())));
+ case Constant.SOURCE_TYPE_PDD:
+ return isShareOrder(pddOrderService.selectByOrderSn(commonOrder.getOrderNo()).get(0));
+ }
+ return false;
+ }
+
+ /**
+ * 杞负鏅�氳鍗�
+ *
+ * @param dtoList
+ * @return
+ */
+ private List<CommonOrder> convertCommonOrder(List<CommonOrderAddResultDTO> dtoList) {
+ List<CommonOrder> commonOrderList = new ArrayList<>();
+ if (dtoList != null)
+ for (CommonOrderAddResultDTO dto : dtoList)
+ commonOrderList.add(dto.getCommonOrder());
+ return commonOrderList;
+ }
+
+ /**
+ * 鏄惁鍏ㄦ槸澧炲姞
+ *
+ * @param list
+ * @return
+ */
+ private boolean isCommonOrderAllAdd(List<CommonOrderAddResultDTO> list) {
+ if (list == null || list.size() == 0)
+ return false;
+ int addCount = 0;
+ if (list != null)
+ for (CommonOrderAddResultDTO dto : list) {
+ if (dto.getType() == CommonOrderAddResultDTO.TYPE_ADD)
+ addCount++;
+ }
+ if (addCount == list.size())
+ return true;
+ else
+ return false;
+ }
+
}
--
Gitblit v1.8.0