From 16f3c0a66181095ff4d353ebe78fbaa30a36a3d3 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 22 十月 2019 14:32:42 +0800 Subject: [PATCH] rocketmq修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java index 25d557f..4ce8b28 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java @@ -145,7 +145,7 @@ @Transactional @Override - public void addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException { + public int addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException { Set<Integer> stateSet = new HashSet<>();// 璁㈠崟鐘舵�丼et if (commonOrderList != null && commonOrderList.size() > 0) { int orderType = commonOrderList.get(0).getSourceType(); @@ -153,6 +153,7 @@ Map<Integer, HongBaoOrder> notificationMap = new HashMap<>(); int goodsCount = 0; boolean hasAdd = false; + boolean hasUpdate = false; for (CommonOrder commonOrder : commonOrderList) { stateSet.add(commonOrder.getState()); goodsCount += commonOrder.getCount(); @@ -163,7 +164,9 @@ saveHongBao(commonOrder, type, notificationMap); hasAdd = true; } else { - updateHongBao(hongBaoOrder, commonOrder, type, notificationMap); + boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap); + if (update) + hasUpdate = true; } } /** @@ -242,8 +245,17 @@ } } } - } + int resultCode = 0; + if (hasAdd && hasUpdate) + return 12; + else if (hasAdd) + return 1; + else if (hasUpdate) + return 2; + return resultCode; + } + return 0; } private int getOrderState(Set<Integer> states) { @@ -261,7 +273,7 @@ } @Transactional - private void updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type, + private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException { System.out.println(commonOrder.getOrderNo()); // 閿佽 @@ -270,7 +282,7 @@ throw new HongBaoException(10, "绾㈠寘瀵硅薄涓嶅瓨鍦�"); // 宸茬粡澶辨晥锛屽凡缁忛鍙栵紝鏂拌�佺姸鎬佷竴鑷寸殑绾㈠寘涓嶅仛澶勭悊 if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU) - return; + return false; if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚� BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime()); @@ -317,7 +329,7 @@ // 鏂拌�佺孩鍖呯姸鎬佷竴鑷翠笉澶勭悊 if (oldHongBao.getState().intValue() == hongBao.getState()) - return; + return false; if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) { if (mianDan) { @@ -411,7 +423,7 @@ BigDecimal firstRate = hongBaoManageService .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank()); if (firstRate.compareTo(new BigDecimal(0)) <= 0) - return; + return true; HongBaoV2 firstHongbao = new HongBaoV2(); firstHongbao.setUserInfo(boss); firstHongbao.setUrank(boss.getRank()); @@ -459,7 +471,7 @@ BigDecimal secondRate = hongBaoManageService .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank()); if (secondRate.compareTo(new BigDecimal(0)) <= 0) - return; + return true; HongBaoV2 secondHongbao = new HongBaoV2(); secondHongbao.setUserInfo(boss); secondHongbao.setUrank(boss.getRank()); @@ -622,6 +634,8 @@ } } else throw new HongBaoException(2, "type閿欒"); + + return true; } @Transactional @@ -642,7 +656,6 @@ CommonOrderGoods goods = commonOrderGoodsMapper .selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId()); if (goods != null) { - try { if (userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId()))) -- Gitblit v1.8.0