| | |
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | | import com.yeshi.fanli.vo.order.CurrentBonusVO;
|
| | | import com.yeshi.fanli.vo.order.GoodsRebateVO;
|
| | | import com.yeshi.fanli.vo.order.HongBaoCountVO;
|
| | | import com.yeshi.fanli.vo.order.OrderCountVO;
|
| | |
| | | userLevel = UserLevelEnum.daRen;
|
| | | UserLevelEnum upperLevel = UserLevelEnum.superVIP;
|
| | |
|
| | | CommonOrder commonOrder1 = hoList.get(0).getCommonOrder();
|
| | | Date downTime = commonOrder1.getThirdCreateTime();
|
| | | Integer urank = commonOrder1.getUrank();
|
| | | UserLevelEnum buyerUserLevel = UserLevelUtil.getByOrderRank(urank);
|
| | | boolean direct = false;
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
|
| | | direct = true;
|
| | | }
|
| | | |
| | | BigDecimal upperTotalMoney = new BigDecimal(0);
|
| | | List<GoodsRebateVO> voList = new ArrayList<>();
|
| | | for (HongBaoOrder hongBaoOrder : hoList) {
|
| | |
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel));
|
| | | } else if (type == 2) {
|
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, upperLevel));
|
| | | } else if (type == 3) {
|
| | | upperTotalMoney = upperTotalMoney.add(hongBao);
|
| | | }
|
| | | }
|
| | |
|
| | | CommonOrder commonOrder = hoList.get(0).getCommonOrder();
|
| | | Date downTime = commonOrder.getThirdCreateTime();
|
| | |
|
| | | // 团队补贴
|
| | | if (type == 3) {
|
| | |
| | | InviteOrderSubsidy inviteOrderSubsidy = inviteOrderSubsidyServiceV2.getByOrderNoAndType(uid, orderNo, sourceType);
|
| | | if (inviteOrderSubsidy != null) {
|
| | | teamSubsidy = inviteOrderSubsidy.getMoney();
|
| | | Integer urank = commonOrder.getUrank();
|
| | | UserLevelEnum buyerUserLevel = UserLevelUtil.getByOrderRank(urank);
|
| | | boolean direct = false;
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
|
| | | direct = true;
|
| | | }
|
| | | |
| | | // 计算原比例
|
| | | BigDecimal originRate = orderHongBaoMoneyComputeService.getTeamSubsidyRate(downTime,buyerUserLevel, userLevel, direct);
|
| | |
|
| | | // 计算达人补贴
|
| | |
| | | lowerSubsidy = MoneyBigDecimalUtil.div(teamSubsidy.multiply(daRenRate), originRate);
|
| | | }
|
| | |
|
| | | if (userLevel != UserLevelEnum.superVIP && userLevel != UserLevelEnum.superVIP) {
|
| | | // 计算超级会员补贴
|
| | | if (userLevel != UserLevelEnum.superVIP && userLevel != UserLevelEnum.tearcher) {
|
| | | BigDecimal vipRate = orderHongBaoMoneyComputeService.getTeamSubsidyRate(downTime, buyerUserLevel,
|
| | | UserLevelEnum.superVIP, direct);
|
| | | upperTotalMoney = upperTotalMoney.add(MoneyBigDecimalUtil.div(teamSubsidy.multiply(vipRate), originRate));
|
| | | System.out.println(upperTotalMoney);
|
| | | }
|
| | | |
| | | } else {
|
| | | teamSubsidy = BigDecimal.valueOf(0.00);
|
| | | lowerSubsidy = BigDecimal.valueOf(0.00);
|
| | |
| | | orderRebateVO.setUserLevel(userLevel.name());
|
| | | }
|
| | |
|
| | | // 上级返利
|
| | | // 超级会员返利
|
| | | if (upperLevel != null) {
|
| | | upperTotalMoney = upperTotalMoney.add(hongBao);
|
| | | orderRebateVO.setUpperFanLi("¥" + upperTotalMoney);
|
| | | orderRebateVO.setJumpLink(upperLevel.getDetailLink());
|
| | | }
|
| | |
| | | }
|
| | | } else {
|
| | | Date accountTime = hongBaoV2.getGetTime();
|
| | | if (accountTime != null) { |
| | | // 到账时间 -红包金额限制
|
| | | if (accountTime != null && hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) <= 0) { |
| | | boolean vip = userInviteService.verifyVIP(uid);
|
| | | Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
|
| | | long currentTime = java.lang.System.currentTimeMillis();
|
| | | if (endDay.getTime() > currentTime && !vip) {
|
| | | UserSystemCouponRecord couponRecord = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null);
|
| | | if (couponRecord == null |
| | | || (couponRecord.getCouponType() == CouponTypeEnum.rebatePercentCoupon.name() && couponRecord.getState() != UserSystemCouponRecord.STATE_SUCCESS)) {
|
| | | if (couponRecord == null) {
|
| | | orderRebateVO.setCoupon(true);
|
| | | orderRebateVO.setCouponType(1);
|
| | | orderRebateVO.setCouponText("立即使用");
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 数据统计
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param type 1自购 2分享 3团队
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getCurrentBonus", method = RequestMethod.POST)
|
| | | public void getCurrentBonus(AcceptData acceptData, Long uid, Integer type, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | if (type == 1 || type == 2) {
|
| | | CurrentBonusVO bonus = new CurrentBonusVO();
|
| | | bonus.setToday(hongBaoV2CountService.geBonusByuid(uid, 1, type, 2).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonus.setYesterday(hongBaoV2CountService.geBonusByuid(uid, 2, type, 2).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonus.setThisMonth(hongBaoV2CountService.geBonusByuid(uid, 3, type, 2).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonus.setLastMonth(hongBaoV2CountService.geBonusByuid(uid, 4, type, 2).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | |
|
| | | CurrentBonusVO bonusNot = new CurrentBonusVO();
|
| | | bonusNot.setToday(hongBaoV2CountService.geBonusByuid(uid, 1, type, 1).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonusNot.setYesterday(hongBaoV2CountService.geBonusByuid(uid, 2, type, 1).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonusNot.setThisMonth(hongBaoV2CountService.geBonusByuid(uid, 3, type, 1).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonusNot.setLastMonth(hongBaoV2CountService.geBonusByuid(uid, 4, type, 1).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | |
| | | |
| | | data.put("bonus",bonus);
|
| | | data.put("bonusNot",bonusNot);
|
| | | data.put("total", hongBaoV2CountService.geBonusByuid(uid, null, type, 2).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | data.put("totalNot", hongBaoV2CountService.geBonusByuid(uid, null, type, 1).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | } else {
|
| | | CurrentBonusVO bonus = new CurrentBonusVO();
|
| | | bonus.setToday(hongBaoV2CountService.geBonusByuid(uid, 1, type, 4).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonus.setYesterday(hongBaoV2CountService.geBonusByuid(uid, 2, type, 4).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonus.setThisMonth(hongBaoV2CountService.geBonusByuid(uid, 3, type, 4).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | bonus.setLastMonth(hongBaoV2CountService.geBonusByuid(uid, 4, type, 2).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | |
| | |
|
| | | CurrentBonusVO subsidy = new CurrentBonusVO();
|
| | | subsidy.setToday(inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid,1,null).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | subsidy.setYesterday(inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid,2,null).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | subsidy.setThisMonth(inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid,3,null).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | subsidy.setLastMonth(inviteOrderSubsidyServiceV2.sumMoneyByUidAndDateAndState(uid,4,null,3).setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | |
| | | // TODO 分红统计
|
| | | CurrentBonusVO dividend = new CurrentBonusVO();
|
| | | dividend.setThisMonth("0.00");
|
| | | dividend.setLastMonth("0.00");
|
| | | |
| | | BigDecimal totalBonus = hongBaoV2CountService.geBonusByuid(uid, null, type, 2);
|
| | | BigDecimal totalubsidy = inviteOrderSubsidyServiceV2.sumRecievedMoneyByUid(uid,null);
|
| | | BigDecimal totalDividend = new BigDecimal(0);
|
| | | |
| | | BigDecimal total = totalDividend.add(totalBonus).add(totalubsidy);
|
| | | |
| | | |
| | | data.put("bonus",bonus);
|
| | | data.put("subsidy",subsidy);
|
| | | data.put("dividend",dividend);
|
| | | data.put("subsidy",subsidy);
|
| | | data.put("total", total.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | data.put("totalBonus", totalBonus.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | data.put("totalubsidy", totalubsidy.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | data.put("totalDividend", totalDividend.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | }
|
| | | |
| | | String key = null;
|
| | | if (type == 1) {
|
| | | key = ConfigKeyEnum.bonusCountLinkFanli.getKey();
|
| | | } else if (type == 2) {
|
| | | key = ConfigKeyEnum.bonusCountLinkShare.getKey();
|
| | | } else {
|
| | | key = ConfigKeyEnum.bonusCountLinkTeam.getKey();
|
| | | }
|
| | | |
| | | data.put("link",configService.get(key));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | }
|