From 5aeec2b48b5c3f1ed9d9ecf8b95a8ddc2031d43d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 06 三月 2019 14:15:56 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java | 116 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 91 insertions(+), 25 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java index b6e6e90..d8312b1 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java @@ -31,7 +31,6 @@ import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail; import com.yeshi.fanli.entity.bus.user.HongBao; import com.yeshi.fanli.entity.bus.user.HongBaoV2; -import com.yeshi.fanli.entity.bus.user.Order; import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.order.CommonOrder; @@ -56,6 +55,8 @@ import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserNotificationService; import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService; +import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService; +import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.StringUtil; @@ -124,6 +125,12 @@ @Resource private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; + + @Resource + private UserSystemCouponService userSystemCouponService; + + @Resource + private UserSystemCouponRecordService userSystemCouponRecordService; @Override public int insert(HongBaoV2 record) { @@ -505,6 +512,20 @@ if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚� BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime()); + // 鍏嶅崟澶勭悊 + boolean mianDan = false; + List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO, + commonOrder.getOrderNo()); + if (orderList != null && orderList.size() == 1) {// 鍙湁1涓鍗曟墠鍙備笌鍏嶅崟 + BigDecimal payMent = commonOrder.getPayment(); + if (commonOrder.getState() == CommonOrder.STATE_JS) + payMent = commonOrder.getSettlement(); + + if (payMent.compareTo(new BigDecimal(10)) < 0) { + mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getOrderNo()); + } + } + HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId()); hongBao.setUpdateTime(new Date()); // 鏇存敼鐘舵�佷笌璧勯噾 @@ -512,14 +533,27 @@ hongBao.setState(HongBaoV2.STATE_BUKELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100)))); + if (mianDan) + hongBao.setMoney(commonOrder.getPayment()); } else if (commonOrder.getState() == CommonOrder.STATE_JS) { hongBao.setState(HongBaoV2.STATE_KELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100)))); hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L)); + if (mianDan) + hongBao.setMoney(commonOrder.getSettlement().compareTo(commonOrder.getPayment()) <= 0 + ? commonOrder.getSettlement() : commonOrder.getPayment());//杩斿埄缁撶畻涓庝粯娆捐緝灏忕殑閲戦 } else if (commonOrder.getState() == CommonOrder.STATE_SX) { hongBao.setState(HongBaoV2.STATE_SHIXIAO); hongBao.setMoney(new BigDecimal(0)); + if (mianDan) { + try { + userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo()); + } catch (Exception e) { + e.printStackTrace(); + throw new HongBaoException(12, "鍏嶅崟鍒搁��娆惧嚭閿�"); + } + } } hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao); @@ -574,34 +608,31 @@ hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate); // 鍔犲叆閫氱煡 - if (notificationMap.get(type) == null) { + if (notificationMap.get(child.getType()) == null) { HongBaoV2 tempHongBao = new HongBaoV2(child.getId()); tempHongBao.setUserInfo(child.getUserInfo()); tempHongBao.setMoney(child.getMoney()); CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId()); tempCommonOrder.setPayment(commonOrder.getPayment()); - notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao)); + notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao)); } else { // 澧炲姞浠樻閲戦涓庤祫閲� - HongBaoOrder tempHongBaoOrder = notificationMap.get(type); + HongBaoOrder tempHongBaoOrder = notificationMap.get(child.getType()); tempHongBaoOrder.getCommonOrder().setPayment( tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment())); tempHongBaoOrder.getHongBaoV2() .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(child.getMoney())); - notificationMap.put(type, tempHongBaoOrder); + notificationMap.put(child.getType(), tempHongBaoOrder); } } } else if (type == HongBaoV2.TYPE_SHARE_GOODS) { BigDecimal fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime()); - Order order = orderMapper.selectOrderByOrderId(commonOrder.getOrderNo()); - if (order != null) { - List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService - .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), order.getId()); - if (list != null && list.size() > 0) { - fanliRate = list.get(0).getShareRate(); - } + List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService + .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo()); + if (list != null && list.size() > 0) { + fanliRate = list.get(0).getShareRate(); } HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId()); @@ -628,7 +659,7 @@ // 閫氱煡 if (notificationMap.get(type) == null) { HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId()); - tempHongBao.setUserInfo(hongBao.getUserInfo()); + tempHongBao.setUserInfo(hongBaoOrder.getHongBaoV2().getUserInfo()); tempHongBao.setMoney(hongBao.getMoney()); CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId()); tempCommonOrder.setPayment(commonOrder.getPayment()); @@ -688,6 +719,40 @@ throws HongBaoException { if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚� BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime()); + // 鏌ヨ鏄惁鏈夊厤鍗曡鍒� + BigDecimal mianDanMoney = null; + if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) { + List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO, + commonOrder.getOrderNo()); + if (orderList != null && orderList.size() == 1) {// 鍙湁1涓鍗曟墠鍙備笌鍏嶅崟 + BigDecimal payMent = commonOrder.getPayment(); + if (commonOrder.getState() == CommonOrder.STATE_JS) + payMent = commonOrder.getSettlement(); + + CommonOrderGoods goods = commonOrderGoodsMapper + .selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId()); + if (goods != null) { + + try { + if (userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(), + commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId()))) + mianDanMoney = payMent; + } catch (NumberFormatException e) { + throw new HongBaoException(10, "鍏嶅崟鍟嗗搧澶勭悊鍑洪敊"); + } catch (Exception e) { + e.printStackTrace(); + throw new HongBaoException(11, "鍏嶅崟鍟嗗搧澶勭悊鍑洪敊"); + } + } + } + } else if (commonOrder.getState() == CommonOrder.STATE_SX) {// 璁剧疆鍏嶅崟鍒稿け鏁� + try { + userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo()); + } catch (Exception e) { + e.printStackTrace(); + } + } + HongBaoV2 hongBao = new HongBaoV2(); hongBao.setUserInfo(commonOrder.getUserInfo()); hongBao.setCreateTime(new Date()); @@ -708,6 +773,10 @@ } else { throw new HongBaoException(3, "缁存潈璁㈠崟涓嶈兘鍒涘缓绾㈠寘"); } + + if (mianDanMoney != null) + hongBao.setMoney(mianDanMoney); + UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId()); hongBao.setUrank(user.getRank()); hongBaoV2Mapper.insertSelective(hongBao); @@ -736,7 +805,7 @@ } UserInfo boss = threeSaleSerivce.getBoss(user.getId()); - if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO) {// 1绾OSS瀛樺湪涓旂孩鍖呮湭澶辨晥 + if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO && mianDanMoney == null) {// 1绾OSS瀛樺湪涓旂孩鍖呮湭澶辨晥,鍏嶅崟涓嶆敮鎸佸绾у垎閿� // 鎻掑叆涓�绾у瓙绾㈠寘 BigDecimal firstRate = hongBaoManageService @@ -855,18 +924,15 @@ if (taoBaoOrderList != null && taoBaoOrderList.size() > 0 && !StringUtil.isNullOrEmpty(taoBaoOrderList.get(0).getRelationId())) { if (shareGoodsActivityOrderService.listByUid(commonOrder.getUserInfo().getId()).size() < 1) { - Order order = orderMapper.selectOrderByOrderId(commonOrder.getOrderNo()); - if (order != null) { - shareRate = new BigDecimal(hongBaoManageService.get("share_activity_proportion")); + shareRate = new BigDecimal(hongBaoManageService.get("share_activity_proportion")); + try { + shareGoodsActivityOrderService.addShareGoodsActivityOrder( + commonOrder.getUserInfo().getId(), shareRate, commonOrder.getOrderNo()); + } catch (ShareGoodsActivityOrderException e) { try { - shareGoodsActivityOrderService.addShareGoodsActivityOrder( - commonOrder.getUserInfo().getId(), shareRate, order); - } catch (ShareGoodsActivityOrderException e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); } } } -- Gitblit v1.8.0