From c6b718c3cadf5e5fff4c2a47fd1247842439f8c7 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期三, 15 四月 2020 10:45:18 +0800 Subject: [PATCH] 团队消息 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java | 124 ++++++++++++++++++++++++++++++----------- 1 files changed, 91 insertions(+), 33 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 c4ad622..a08b0fe 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 @@ -60,6 +60,7 @@ import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException; import com.yeshi.fanli.exception.user.UserAccountException; import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.log.OrderLogHelper; import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService; import com.yeshi.fanli.service.inter.elme.ElmeOrderProcessService; import com.yeshi.fanli.service.inter.elme.ElmeOrderService; @@ -79,7 +80,7 @@ import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; -import com.yeshi.fanli.service.manger.HongBaoV2AddManager; +import com.yeshi.fanli.service.manger.order.HongBaoV2AddManager; import com.yeshi.fanli.util.CMQManager; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; @@ -213,11 +214,14 @@ 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())) { - // 澶勭悊楗夸簡涔堣鍗� - elmeOrderMap.put(orderId, list); - } - - else { + // 楗夸簡涔堣鍗曞紑濮嬪綊鍏ュ埌娣樺疂璁㈠崟 + 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()) || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 璁剧疆娓犻亾ID褰撳仛浼氬憳杩愯惀ID鐨勪綅缃甀D fanliOrderMap.put(orderId, list); @@ -402,7 +406,8 @@ || hb.getPreGetTime().getTime() > System.currentTimeMillis()) continue; try { - CMQManager.getInstance().addFanLiMsgNew(hb); + if (Constant.ENABLE_MQ) + CMQManager.getInstance().addFanLiMsgNew(hb); } catch (Exception e) { try { LogHelper.errorDetailInfo(e); @@ -493,11 +498,12 @@ hongBaoOrder.getCommonOrder().getSourceType(), key); return TransactionStatus.CommitTransaction; } catch (Exception e) { + e.printStackTrace(); return TransactionStatus.RollbackTransaction; } } }, null); - else{ + else { try { orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(), hongBaoOrder.getCommonOrder().getSourceType(), key); @@ -515,7 +521,8 @@ for (TaoBaoWeiQuanOrder order : orderList) { try { if (order.getState().contains("缁存潈鎴愬姛")) { - CMQManager.getInstance().addWeiQuanOrderMsg(order); + if (Constant.ENABLE_MQ) + CMQManager.getInstance().addWeiQuanOrderMsg(order); } } catch (Exception e) { LogHelper.error("缁存潈璁㈠崟鍔犲叆鍒伴槦鍒楀嚭閿�:" + order != null ? new Gson().toJson(order) : null); @@ -532,13 +539,8 @@ if (orderList != null && orderList.size() > 0 & !StringUtil.isNullOrEmpty(orderList.get(0).getSettlementTime())) order.setJieSuanTime( new Date(TimeUtil.convertToTimeTemp(orderList.get(0).getSettlementTime(), "yyyy-MM-dd HH:mm:ss"))); - // if (order.getJieSuanTime().getTime() >= - // TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) { - // return; - // } - // TODO 澶勭悊缁存潈鎴愬姛浣嗘槸宸插埌璐︾殑璁㈠崟 - + // 澶勭悊缁存潈鎴愬姛浣嗘槸宸插埌璐︾殑璁㈠崟 if (order.getJieSuanTime().getTime() > TimeUtil.convertToTimeTemp("2019-01-01", "yyyy-MM-dd")) {// 缁撶畻鏃堕棿鍦�2鏈�1鍙风殑寮�濮嬪鐞嗗凡鍒拌处浣嗘槸缁存潈鐨� CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO, order.getOrderItemId()); @@ -549,15 +551,34 @@ TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackService .selectByOrderItemId(order.getOrderItemId()); if (drawBack == null) {// 杩樻湭鎵f + OrderLogHelper.taoBaoWeiQuan("宸插埌璐︽湭鎵f澶勭悊:瀛愯鍗曞彿:" + order.getOrderItemId()); try { - taoBaoWeiQuanDrawBackService.doWeiQuanFanli(order.getOrderId()); + taoBaoWeiQuanDrawBackService.doWeiQuanFanli(order.getOrderId(), true); taoBaoWeiQuanDrawBackService.doWeiQuanShare(order.getOrderId()); taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId()); } catch (TaoBaoWeiQuanException e) { try { - LogHelper.errorDetailInfo(e, null, "璁㈠崟鍙�:" + order.getOrderId()); + LogHelper.errorDetailInfo(e, "鍒拌处鍚庡鐞嗙淮鏉冩墸娆惧嚭閿�", "璁㈠崟鍙�:" + order.getOrderId()); } catch (Exception e1) { e1.printStackTrace(); + } + } + } else { + // 鏌ヨ瀛愮孩鍖呮槸鍚﹀凡鍒拌处 + List<HongBaoV2> children = hongBaoV2Service + .listChildrenById(hongBaoOrder.getHongBaoV2().getId()); + for (HongBaoV2 hongBaoV2 : children) { + if (hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU) { + try { + taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId()); + } catch (TaoBaoWeiQuanException e) { + try { + LogHelper.errorDetailInfo(e, "鍒拌处鍚庡鐞嗙淮鏉冩墸娆惧嚭閿�", "璁㈠崟鍙�:" + order.getOrderId()); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + break; } } } @@ -581,7 +602,8 @@ while (its.hasNext()) { Long uid = its.next(); try { - CMQManager.getInstance().addFanLiTiChengMsg(uid); + if (Constant.ENABLE_MQ) + CMQManager.getInstance().addFanLiTiChengMsg(uid); } catch (Exception e) { e.printStackTrace(); LogHelper.error(e); @@ -593,20 +615,21 @@ @Transactional(rollbackFor = Exception.class) public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException { // 閭�璇疯禋鍒拌处 + Date now = new Date(); try { - orderMoneySettleService.inviteSettleTB(uid); + orderMoneySettleService.inviteSettleTB(uid, now); } catch (OrderMoneySettleException e) { e.printStackTrace(); } try { - orderMoneySettleService.inviteSettleJD(uid); + orderMoneySettleService.inviteSettleJD(uid, now); } catch (OrderMoneySettleException e) { e.printStackTrace(); } // try { - orderMoneySettleService.inviteSettlePDD(uid); + orderMoneySettleService.inviteSettlePDD(uid, now); } catch (OrderMoneySettleException e) { e.printStackTrace(); } @@ -626,6 +649,29 @@ // try { orderMoneySettleService.shareSettlePDD(uid); + } catch (OrderMoneySettleException e) { + e.printStackTrace(); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void fanliPreInvaite(Long uid, Date maxPreGetTime) { + // 閭�璇疯禋鍒拌处 + try { + orderMoneySettleService.inviteSettleTB(uid, maxPreGetTime); + } catch (OrderMoneySettleException e) { + e.printStackTrace(); + } + + try { + orderMoneySettleService.inviteSettleJD(uid, maxPreGetTime); + } catch (OrderMoneySettleException e) { + e.printStackTrace(); + } + + try { + orderMoneySettleService.inviteSettlePDD(uid, maxPreGetTime); } catch (OrderMoneySettleException e) { e.printStackTrace(); } @@ -652,9 +698,16 @@ if (oldOrder == null) { Long targetUid = null; if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID) - && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) { + && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 澶勭悊闈炶繑鍒╁晢鍝佸簱鐨勫晢鍝� targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId()); + } else if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_ELEME_PID) + && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 澶勭悊楗夸簡涔堢殑璁㈠崟 + UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService + .getByRelationId(orderList.get(0).getRelationId()); + if (extraInfo != null) { + targetUid = extraInfo.getUser().getId(); + } } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) { UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService .getBySpecialId(orderList.get(0).getSpecialId()); @@ -723,7 +776,8 @@ order.setOrderType(Constant.SOURCE_TYPE_TAOBAO); order.setUserInfo(new UserInfo(uid)); try { - PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); + if (Constant.ENABLE_MQ) + PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); } catch (Exception e) { } } @@ -773,7 +827,8 @@ order.setOrderType(Constant.SOURCE_TYPE_TAOBAO); order.setUserInfo(new UserInfo(uid)); try { - PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); + if (Constant.ENABLE_MQ) + PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); } catch (Exception e) { } } @@ -895,7 +950,8 @@ order.setOrderType(Constant.SOURCE_TYPE_JD); order.setUserInfo(new UserInfo(uid)); try { - PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); + if (Constant.ENABLE_MQ) + PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); } catch (Exception e) { } } @@ -926,7 +982,8 @@ order.setOrderType(Constant.SOURCE_TYPE_JD); order.setUserInfo(new UserInfo(uid)); try { - PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); + if (Constant.ENABLE_MQ) + PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); } catch (Exception e) { } } @@ -1035,7 +1092,8 @@ order.setOrderType(Constant.SOURCE_TYPE_PDD); order.setUserInfo(new UserInfo(uid)); try { - PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); + if (Constant.ENABLE_MQ) + PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); } catch (Exception e) { } } @@ -1068,7 +1126,8 @@ order.setOrderType(Constant.SOURCE_TYPE_PDD); order.setUserInfo(new UserInfo(uid)); try { - PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); + if (Constant.ENABLE_MQ) + PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order); } catch (Exception e) { } } @@ -1166,7 +1225,9 @@ update.setUpdateTime(new Date()); hongBaoV2Service.updateByPrimaryKeySelective(update); } - userSystemCouponService.systemGiveRewardCoupon(uid, 1, orderId, sourceType, "鍥犲晢瀹惰繚绾︽湭鑳界粨绠楄繑鍒╂垨鍟嗗宸茬粡鍏冲簵"); + // TODO 鍟嗗鍏冲簵璺戣矾闇�瑕佽禒閫侀噾甯� + // userSystemCouponService.systemGiveRewardCoupon(uid, 1, orderId, + // sourceType, "鍥犲晢瀹惰繚绾︽湭鑳界粨绠楄繑鍒╂垨鍟嗗宸茬粡鍏冲簵"); } @Transactional @@ -1221,7 +1282,7 @@ public List<HongBaoV2> getCanBalanceElmeFanliHongBao() { List<Integer> list = new ArrayList<>(); list.add(HongBaoV2.TYPE_ELME); - return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, null, 0, 1000); + return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, null, new Date(), 0, 1000); } @Override @@ -1258,9 +1319,6 @@ } userMoneyService.addUserMoney(hongBao.getUserInfo().getId(), hongBao.getMoney(), detail); BigDecimal balance = userInfoMapper.selectByPrimaryKey(hongBao.getUserInfo().getId()).getMyHongBao(); - // 娣诲姞娑堟伅 - userMoneyMsgNotificationService.elmeFanli(hongBao.getUserInfo().getId(), order.getOrderId(), - hongBao.getMoney(), balance); } // 杩斿埄鍒拌处 } -- Gitblit v1.8.0