From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 20 五月 2020 17:25:08 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java | 247 +++++++++++++++++++++++++++---------------------- 1 files changed, 135 insertions(+), 112 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 0e3f9b7..7303b65 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 @@ -26,18 +26,22 @@ import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper; import com.yeshi.fanli.dto.HongBao; import com.yeshi.fanli.dto.HongBaoDTO; +import com.yeshi.fanli.dto.order.HongBaoAddResult; import com.yeshi.fanli.entity.bus.user.HongBaoV2; import com.yeshi.fanli.entity.bus.user.ThreeSale; import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; import com.yeshi.fanli.entity.order.CommonOrder; import com.yeshi.fanli.entity.order.CommonOrderGoods; import com.yeshi.fanli.entity.order.HongBaoOrder; import com.yeshi.fanli.entity.order.ShareGoodsActivityOrder; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.entity.taobao.TaoBaoOrder; import com.yeshi.fanli.exception.order.HongBaoException; import com.yeshi.fanli.exception.order.ShareGoodsActivityOrderException; import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; +import com.yeshi.fanli.exception.user.UserAccountException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.order.CommonOrderService; @@ -145,13 +149,15 @@ return hongBaoV2Mapper.selectByPrimaryKey(id); } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override - public int addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException { + public HongBaoAddResult addHongBao(List<CommonOrder> commonOrderList, int type) + throws HongBaoException, UserAccountException { Set<Integer> stateSet = new HashSet<>();// 璁㈠崟鐘舵�丼et if (commonOrderList != null && commonOrderList.size() > 0) { int orderType = commonOrderList.get(0).getSourceType(); + boolean miandan = false; Map<Integer, HongBaoOrder> notificationMap = new HashMap<>(); int goodsCount = 0; boolean hasAdd = false; @@ -163,7 +169,7 @@ throw new HongBaoException(1, "璁㈠崟淇℃伅涓嶅畬鏁�"); HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId()); if (hongBaoOrder == null) { - saveHongBao(commonOrder, type, notificationMap); + miandan = saveHongBao(commonOrder, type, notificationMap); hasAdd = true; } else { boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap); @@ -171,7 +177,7 @@ hasUpdate = true; } } - + /** * 閫氱煡鐢ㄦ埛鐨勮繑鍒╂儏鍐� */ @@ -188,77 +194,52 @@ switch (t) { case HongBaoV2.TYPE_ZIGOU: userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType, - commonOrder.getPayment(), money, goodsCount, state); + commonOrder.getPayment(), money, goodsCount, commonOrder.getState(), + commonOrder.getThirdCreateTime()); + break; case HongBaoV2.TYPE_SHARE_GOODS: userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType, - commonOrder.getPayment(), money, goodsCount, state); + commonOrder.getPayment(), money, goodsCount, commonOrder.getState(), + commonOrder.getThirdCreateTime()); + break; case HongBaoV2.TYPE_YIJI: - userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, - commonOrder.getPayment(), money, goodsCount, state); + commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(), + commonOrder.getThirdCreateTime()); break; case HongBaoV2.TYPE_ERJI: - userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, - commonOrder.getPayment(), money, goodsCount, state); + commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(), + commonOrder.getThirdCreateTime()); break; case HongBaoV2.TYPE_SHARE_YIJI: - userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId, orderType, - commonOrder.getPayment(), money, goodsCount, state, notify.getBeizhu()); - break; - } - } - } + userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, + commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(), + commonOrder.getThirdCreateTime()); - // 娣诲姞鏂扮増鏈�氱煡 - - if (!hasAdd) { - Iterator<Integer> its = notificationMap.keySet().iterator(); - while (its.hasNext()) { - Integer t = its.next(); - HongBaoV2 notify = notificationMap.get(t).getHongBaoV2(); - CommonOrder commonOrder = notificationMap.get(t).getCommonOrder(); - String orderId = commonOrderList.get(0).getOrderNo(); - Long uid = notify.getUserInfo().getId(); - BigDecimal money = notify.getMoney(); - switch (t) { - case HongBaoV2.TYPE_ZIGOU: - userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId, orderType, - commonOrder.getPayment(), money, state); + case HongBaoV2.TYPE_SHARE_ERJI: + userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, + commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(), + commonOrder.getThirdCreateTime()); break; - case HongBaoV2.TYPE_SHARE_GOODS: - userOrderMsgNotificationService.orderShareStateChanged(uid, orderId, orderType, - commonOrder.getPayment(), money, state); - break; - case HongBaoV2.TYPE_YIJI: - userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, orderType, - commonOrder.getPayment(), money, state); - break; - case HongBaoV2.TYPE_ERJI: - userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, orderType, - commonOrder.getPayment(), money, state); - break; - case HongBaoV2.TYPE_SHARE_YIJI: - userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId, orderType, - commonOrder.getPayment(), money, state); } } } int resultCode = 0; if (hasAdd && hasUpdate) - return 12; + return new HongBaoAddResult(HongBaoAddResult.CODE_ADD_AND_UPDATE, miandan); else if (hasAdd) - return 1; + return new HongBaoAddResult(HongBaoAddResult.CODE_ADD, miandan); else if (hasUpdate) - return 2; - return resultCode; + return new HongBaoAddResult(HongBaoAddResult.CODE_UPDATE, miandan); + return new HongBaoAddResult(resultCode, miandan); } - return 0; + return new HongBaoAddResult(0, false); } private int getOrderState(Set<Integer> states) { @@ -275,9 +256,9 @@ return CommonOrder.STATE_SX; } - @Transactional + @Transactional(rollbackFor = Exception.class) private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type, - Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException { + Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException, UserAccountException { System.out.println(commonOrder.getOrderNo()); // 閿佽 HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoOrder.getHongBaoV2().getId()); @@ -288,7 +269,8 @@ return false; if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚� - BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime()); + BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen, + commonOrder.getCreateTime().getTime()); // 鍏嶅崟澶勭悊 boolean mianDan = false; List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO, @@ -313,7 +295,8 @@ MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100)))); if (mianDan) hongBao.setMoney(commonOrder.getPayment()); - } else if (commonOrder.getState() == CommonOrder.STATE_JS) { + } else if (commonOrder.getState() == CommonOrder.STATE_JS + || commonOrder.getState() == CommonOrder.STATE_WQ) { hongBao.setState(HongBaoV2.STATE_KELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100)))); @@ -369,6 +352,9 @@ List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId()); if (children != null && children.size() > 0) for (HongBaoV2 child : children) { + if (child.getState() == HongBaoV2.STATE_YILINGQU) + continue; + HongBaoV2 childUpdate = new HongBaoV2(child.getId()); childUpdate.setState(hongBao.getState()); childUpdate.setUpdateTime(new Date()); @@ -449,24 +435,31 @@ } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) { firstHongbao.setMoney( MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100)))); + } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) { + firstHongbao.setMoney(new BigDecimal(0)); } - hongBaoV2Mapper.insertSelective(firstHongbao); - // 鐢ㄦ埛閫氱煡 - if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) { - HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId()); - tempHongBao.setUserInfo(firstHongbao.getUserInfo()); - tempHongBao.setMoney(firstHongbao.getMoney()); - CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId()); - tempCommonOrder.setPayment(commonOrder.getPayment()); - notificationMap.put(HongBaoV2.TYPE_YIJI, new HongBaoOrder(tempCommonOrder, tempHongBao)); - } else { - // 澧炲姞浠樻閲戦涓庤祫閲� - HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI); - tempHongBaoOrder.getCommonOrder().setPayment( - tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment())); - tempHongBaoOrder.getHongBaoV2() - .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney())); - notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder); + + if (firstHongbao.getMoney() != null + && firstHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) { + hongBaoV2Mapper.insertSelective(firstHongbao); + // 鐢ㄦ埛閫氱煡 + if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) { + HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId()); + tempHongBao.setUserInfo(firstHongbao.getUserInfo()); + tempHongBao.setMoney(firstHongbao.getMoney()); + CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId()); + tempCommonOrder.setPayment(commonOrder.getPayment()); + notificationMap.put(HongBaoV2.TYPE_YIJI, + new HongBaoOrder(tempCommonOrder, tempHongBao)); + } else { + // 澧炲姞浠樻閲戦涓庤祫閲� + HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI); + tempHongBaoOrder.getCommonOrder().setPayment( + tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment())); + tempHongBaoOrder.getHongBaoV2().setMoney( + tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney())); + notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder); + } } // 鎻掑叆浜岀骇瀛愮孩鍖� @@ -497,26 +490,29 @@ } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) { secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100)))); - } - hongBaoV2Mapper.insertSelective(secondHongbao); - - // 鐢ㄦ埛閫氱煡 - if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) { - HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId()); - tempHongBao.setUserInfo(secondHongbao.getUserInfo()); - tempHongBao.setMoney(secondHongbao.getMoney()); - CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId()); - tempCommonOrder.setPayment(commonOrder.getPayment()); - notificationMap.put(HongBaoV2.TYPE_ERJI, - new HongBaoOrder(tempCommonOrder, tempHongBao)); - } else { - // 澧炲姞浠樻閲戦涓庤祫閲� - HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI); - tempHongBaoOrder.getCommonOrder().setPayment( - tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment())); - tempHongBaoOrder.getHongBaoV2().setMoney( - tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney())); - notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder); + } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) + secondHongbao.setMoney(new BigDecimal(0)); + if (secondHongbao.getMoney() != null + && secondHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) { + hongBaoV2Mapper.insertSelective(secondHongbao); + // 鐢ㄦ埛閫氱煡 + if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) { + HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId()); + tempHongBao.setUserInfo(secondHongbao.getUserInfo()); + tempHongBao.setMoney(secondHongbao.getMoney()); + CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId()); + tempCommonOrder.setPayment(commonOrder.getPayment()); + notificationMap.put(HongBaoV2.TYPE_ERJI, + new HongBaoOrder(tempCommonOrder, tempHongBao)); + } else { + // 澧炲姞浠樻閲戦涓庤祫閲� + HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI); + tempHongBaoOrder.getCommonOrder().setPayment(tempHongBaoOrder.getCommonOrder() + .getPayment().add(commonOrder.getPayment())); + tempHongBaoOrder.getHongBaoV2().setMoney( + tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney())); + notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder); + } } } } @@ -528,7 +524,8 @@ && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT)) fanliRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime()); else - fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime()); + fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen, + commonOrder.getCreateTime().getTime()); List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo()); @@ -543,7 +540,8 @@ hongBao.setState(HongBaoV2.STATE_BUKELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100)))); - } else if (commonOrder.getState() == CommonOrder.STATE_JS) { + } else if (commonOrder.getState() == CommonOrder.STATE_JS + || commonOrder.getState() == CommonOrder.STATE_WQ) { hongBao.setState(HongBaoV2.STATE_KELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100)))); @@ -579,6 +577,9 @@ List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId()); if (children != null) for (HongBaoV2 child : children) { + if (child.getState() == HongBaoV2.STATE_YILINGQU) + continue; + HongBaoV2 childUpdate = new HongBaoV2(child.getId()); // 缁熶竴璁剧疆鐘舵�� childUpdate.setState(hongBao.getState()); @@ -591,7 +592,8 @@ } // 浠ュ疄闄呮敹鍏ヤ负鍑嗚绠楅浼版敹鐩� - if (CommonOrder.STATE_JS == commonOrder.getState()) { + if (CommonOrder.STATE_JS == commonOrder.getState() + || CommonOrder.STATE_WQ == commonOrder.getState()) { childUpdate.setMoney( MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100)))); if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16", @@ -643,11 +645,12 @@ return true; } - @Transactional - private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap) - throws HongBaoException { + @Transactional(rollbackFor = Exception.class) + private boolean saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap) + throws HongBaoException, UserAccountException { if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚� - BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime()); + BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen, + commonOrder.getCreateTime().getTime()); // 鏌ヨ鏄惁鏈夊厤鍗曡鍒� BigDecimal mianDanMoney = null; if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) { @@ -691,7 +694,8 @@ hongBao.setState(HongBaoV2.STATE_BUKELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100)))); - } else if (commonOrder.getState() == CommonOrder.STATE_JS) { + } else if (commonOrder.getState() == CommonOrder.STATE_JS + || CommonOrder.STATE_WQ == commonOrder.getState()) { hongBao.setState(HongBaoV2.STATE_KELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100)))); @@ -711,6 +715,8 @@ hongBao.setMoney(mianDanMoney); UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId()); + if (user == null) + throw new UserAccountException(1001, "鐢ㄦ埛涓嶅瓨鍦�/琚皝绂�"); hongBao.setUrank(user.getRank()); hongBao.setOrderType(commonOrder.getSourceType()); hongBaoV2Mapper.insertSelective(hongBao); @@ -745,7 +751,7 @@ BigDecimal firstRate = hongBaoManageService .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank()); if (firstRate.compareTo(new BigDecimal(0)) <= 0) - return; + return mianDanMoney != null; HongBaoV2 firstHongbao = new HongBaoV2(); firstHongbao.setUserInfo(boss); firstHongbao.setUrank(boss.getRank()); @@ -771,7 +777,7 @@ } // 杩斿埄涓�0鐨勪笉閫氱煡 if (firstHongbao.getMoney() == null || firstHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0) - return; + return mianDanMoney != null; hongBaoV2Mapper.insertSelective(firstHongbao); // 鐢ㄦ埛閫氱煡 @@ -798,7 +804,7 @@ BigDecimal secondRate = hongBaoManageService .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank()); if (secondRate.compareTo(new BigDecimal(0)) <= 0) - return; + return mianDanMoney != null; HongBaoV2 secondHongbao = new HongBaoV2(); secondHongbao.setUserInfo(boss); secondHongbao.setUrank(boss.getRank()); @@ -824,7 +830,7 @@ // 杩斿埄涓�0鐨勪笉缁熻 if (secondHongbao.getMoney() == null || secondHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0) - return; + return mianDanMoney != null; hongBaoV2Mapper.insertSelective(secondHongbao); @@ -848,21 +854,22 @@ } } - + return mianDanMoney != null; } else if (type == HongBaoV2.TYPE_SHARE_GOODS) { // 鍒嗕韩璧氫笉鍔犲叆澶辨晥鐨勮鍗� if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ) - return; + return false; // 鍒嗕韩璧� BigDecimal shareRate = null; if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))// 鏉ヨ嚜浜庢窐绀奸噾鐨勫垎浜� shareRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime()); else - shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime()); + shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen, + commonOrder.getCreateTime().getTime()); // 鍒ゆ柇璁㈠崟鍒嗕韩娲诲姩鏄惁寮�鍚� - if ("1".equalsIgnoreCase(configService.get("share_goods_activity_open"))) { + if ("1".equalsIgnoreCase(configService.get(ConfigKeyEnum.shareGoodsActivityOpen.getKey()))) { // 娌℃湁璁㈠崟锛屽苟涓旀槸娓犻亾ID鏉ョ殑锛屽苟涓� UserExtraTaoBaoInfo taoBaoExtraInfo = userExtraTaoBaoInfoService .getByUid(commonOrder.getUserInfo().getId()); @@ -898,7 +905,8 @@ hongBao.setState(HongBaoV2.STATE_BUKELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100)))); - } else if (commonOrder.getState() == CommonOrder.STATE_JS) { + } else if (commonOrder.getState() == CommonOrder.STATE_JS + || commonOrder.getState() == CommonOrder.STATE_WQ) { hongBao.setState(HongBaoV2.STATE_KELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), shareRate.divide(new BigDecimal(100)))); @@ -909,6 +917,8 @@ calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd"))); } UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId()); + if (user == null) + throw new UserAccountException(1001, "鐢ㄦ埛涓嶅瓨鍦�/琚皝绂�"); hongBao.setUrank(user.getRank()); hongBao.setUserInfo(user); hongBao.setOrderType(commonOrder.getSourceType()); @@ -950,7 +960,8 @@ child.setState(HongBaoV2.STATE_BUKELINGQU); child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), firstLevelRate.divide(new BigDecimal(100)))); - } else if (commonOrder.getState() == CommonOrder.STATE_JS) { + } else if (commonOrder.getState() == CommonOrder.STATE_JS + || commonOrder.getState() == CommonOrder.STATE_WQ) { child.setState(HongBaoV2.STATE_KELINGQU); child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), firstLevelRate.divide(new BigDecimal(100)))); @@ -966,7 +977,7 @@ child.setVersion(2); child.setCreateTime(new Date()); child.setOrderType(commonOrder.getSourceType()); - if (child.getMoney().compareTo(new BigDecimal(0)) > 0) { + if (child.getMoney() != null && child.getMoney().compareTo(new BigDecimal(0)) > 0) { hongBaoV2Mapper.insertSelective(child); // 娣诲姞閫氱煡 if (notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI) == null) { @@ -1011,9 +1022,10 @@ e1.printStackTrace(); } } - } else throw new HongBaoException(2, "type閿欒"); + + return false; } @Override @@ -1151,4 +1163,15 @@ return hongBaoV2Mapper.listByIds(idList); } + @Override + public List<HongBaoDTO> listByOrderTradeId(String tradeId) { + return hongBaoV2Mapper.listByOrderTradeId(tradeId); + } + + @Override + public Integer getDirectBossUrankByPid(Long pid) { + return hongBaoV2Mapper.getDirectBossUrankByPid(pid); + } + + } -- Gitblit v1.8.0