From 3a6e476b2f498e876ff10f1328455f58e63ee85a Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 04 四月 2019 09:30:53 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java | 124 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 117 insertions(+), 7 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 28b1cc5..c085968 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 @@ -1,6 +1,7 @@ package com.yeshi.fanli.service.impl.hongbao; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -19,7 +20,6 @@ import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper; import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper; import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper; -import com.yeshi.fanli.dao.mybatis.order.OrderItemMapper; import com.yeshi.fanli.dao.mybatis.order.OrderMapper; import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper; import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper; @@ -27,6 +27,7 @@ import com.yeshi.fanli.dto.HongBaoDTO; import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail; 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.order.CommonOrder; @@ -66,9 +67,6 @@ private TaoBaoOrderMapper taoBaoOrderMapper; @Resource - private OrderItemMapper orderItemMapper; - - @Resource private CommonOrderMapper commonOrderMapper; @Resource @@ -91,7 +89,6 @@ @Resource private UserShareGoodsGroupService userShareGoodsGroupService; - @Resource private HongBaoManageService hongBaoManageService; @@ -149,7 +146,6 @@ public HongBaoV2 selectByPrimaryKey(Long id) { return hongBaoV2Mapper.selectByPrimaryKey(id); } - @Transactional @Override @@ -342,7 +338,7 @@ // 鑾峰彇瀛愮孩鍖� List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId()); - if (children != null) + if (children != null && children.size() > 0) for (HongBaoV2 child : children) { HongBaoV2 childUpdate = new HongBaoV2(child.getId()); childUpdate.setState(hongBao.getState()); @@ -391,7 +387,110 @@ } } + else {// 淇涔嬪墠浜岀骇,涓夌骇璁㈠崟鏈粺璁″埌鐨勬儏鍐� + if (!mianDan) { + ThreeSale threeSale = threeSaleSerivce.selectByWorkerId(commonOrder.getUserInfo().getId()); + if (threeSale != null && threeSale.getSucceedTime() != null + && threeSale.getSucceedTime() <= commonOrder.getThirdCreateTime().getTime()) { + UserInfo boss = threeSaleSerivce.getBoss(commonOrder.getUserInfo().getId()); + // 鎻掑叆涓�绾у瓙绾㈠寘 + BigDecimal firstRate = hongBaoManageService + .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank()); + if (firstRate.compareTo(new BigDecimal(0)) <= 0) + return; + HongBaoV2 firstHongbao = new HongBaoV2(); + firstHongbao.setUserInfo(boss); + firstHongbao.setUrank(boss.getRank()); + firstHongbao.setParent(hongBao); + firstHongbao.setCreateTime(new Date()); + firstHongbao.setType(HongBaoV2.TYPE_YIJI); + firstHongbao.setVersion(2); + firstHongbao.setState(hongBao.getState()); + if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) { + firstHongbao.setMoney( + MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100)))); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(commonOrder.getSettleTime()); + calendar.add(Calendar.MONTH, 1); + firstHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp( + calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", + "yyyy-M-dd"))); + } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) { + firstHongbao.setMoney( + MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100)))); + } + 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); + } + + // 鎻掑叆浜岀骇瀛愮孩鍖� + boss = threeSaleSerivce.getBoss(boss.getId()); + if (boss != null) {// 浜岀骇BOSS瀛樺湪 + BigDecimal secondRate = hongBaoManageService + .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank()); + if (secondRate.compareTo(new BigDecimal(0)) <= 0) + return; + HongBaoV2 secondHongbao = new HongBaoV2(); + secondHongbao.setUserInfo(boss); + secondHongbao.setUrank(boss.getRank()); + secondHongbao.setParent(hongBao); + secondHongbao.setCreateTime(new Date()); + secondHongbao.setType(HongBaoV2.TYPE_ERJI); + secondHongbao.setVersion(2); + secondHongbao.setState(hongBao.getState()); + if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) { + secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(), + secondRate.divide(new BigDecimal(100)))); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(commonOrder.getSettleTime()); + calendar.add(Calendar.MONTH, 1); + secondHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp( + calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", + "yyyy-M-dd"))); + } 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 (type == HongBaoV2.TYPE_SHARE_GOODS) { BigDecimal fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime()); List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService @@ -833,4 +932,15 @@ else return money; } + + @Override + public BigDecimal computeMoneyByUidAndState(Long uid, int state) { + List<Integer> stateList = new ArrayList<>(); + stateList.add(state); + BigDecimal money = hongBaoV2Mapper.computeMoneyByUidAndState(uid, stateList); + if (money == null) + return new BigDecimal(0); + else + return money; + } } -- Gitblit v1.8.0