From d4588f4e43336b26b356b869c29d0c76390167d5 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 15 四月 2020 10:22:51 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java | 236 ++++++++++------------------------------------------------ 1 files changed, 41 insertions(+), 195 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java index 03cc71b..215087f 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java @@ -58,14 +58,12 @@ import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.account.UserUtil; import com.yeshi.fanli.util.user.UserLevelUtil; -import com.yeshi.fanli.vo.msg.ClientTextStyleVO; 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; import com.yeshi.fanli.vo.order.OrderRebateVO; -import com.yeshi.fanli.vo.order.TeamBonusVO; import com.yeshi.fanli.vo.user.UserInfoExtraVO; import com.yeshi.fanli.vo.user.UserSettingsVO; @@ -299,7 +297,6 @@ data.put("count", count); data.put("result_list", JsonUtil.getApiCommonGson().toJson(list)); data.put("helpUrl", configService.get(ConfigKeyEnum.orderListHelp.getKey())); - data.put("bonusLink", configService.get(ConfigKeyEnum.orderBonusLink.getKey())); data.put("validMoney", "楼 " + validMoney); data.put("invalidMoney", "楼 " + invalidMoney); data.put("findOrderHelpUrl", orderFindUrl); @@ -483,173 +480,8 @@ dividend = new BigDecimal(0); // 鎬诲洟闃熷鍔� teamMoney = bonus.add(subsidy).add(dividend); - - JSONObject paramsFanli = new JSONObject(); - paramsFanli.put("type", "1"); - data.put("paramsFanli", paramsFanli); - data.put("jumpFanli", jumpDetailV2Service.getByTypeCache("fanli_share_statistics", - Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion()))); - - JSONObject paramsShare = new JSONObject(); - paramsShare.put("type", "2"); - data.put("paramsShare", paramsShare); - data.put("jumpShare", jumpDetailV2Service.getByTypeCache("fanli_share_statistics", - Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion()))); - - JSONObject paramsTeam = new JSONObject(); - paramsTeam.put("type", "3"); - data.put("paramsTeam", paramsTeam); - data.put("jumpTeam", jumpDetailV2Service.getByTypeCache("team_statistics", - Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion()))); } data.put("inviteMoney", teamMoney.setScale(2, BigDecimal.ROUND_DOWN).toString()); - out.print(JsonUtil.loadTrueResult(data)); - } - - /** - * 鍥㈤槦鏀剁泭缁熻 缁熻宸插埌璐︽湭鍒拌处 锛� 绱鍙粺璁″凡鍒拌处 - * @param acceptData - * @param uid - * @param type 1-鍥㈤槦琛ヨ创 2-鍥㈤槦濂栧姳 3-瀵煎笀娲ヨ创 - */ - @RequestMapping(value = "getTeamBonus", method = RequestMethod.POST) - public void getTeamBonus(AcceptData acceptData, Long uid, Integer type, PrintWriter out) { - if (uid == null) { - out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); - return; - } - - UserInfo user = userInfoService.selectByPKey(uid); - if (user == null) { - out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛涓嶅瓨鍦�")); - return; - } - - if (type == null || type < 1 || type > 3) { - type = 1; - } - - if (type == 1) { - // 琛ヨ创 - sumTeamSubsidy(out, user); - } else if (type == 2) { - // 濂栧姳 - //TODO 鍥㈤槦濂栧姳宸茬粡鍒犻櫎 - } else { - // 瀵煎笀娲ヨ创 - JSONObject data = new JSONObject(); - data.put("exist", false); - data.put("link", configService.get(ConfigKeyEnum.tutorSubsidyLink.getKey())); - out.print(JsonUtil.loadTrueResult(data)); - } - } - - /** - * 缁熻琛ヨ创 - * @param out - * @param user - */ - private void sumTeamSubsidy(PrintWriter out, UserInfo user) { - Long uid = user.getId(); - // 鏄惁VIP - boolean vip = userVIPInfoService.isVIP(uid); - - JSONObject data = new JSONObject(); - data.put("link", configService.get(ConfigKeyEnum.orderTeamSubsidyLink.getKey())); - if (!vip) { - data.put("exist", false); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - - data.put("exist", true); - data.put("portrait", user.getPortrait()); - - // 浠婃棩缁熻 - BigDecimal todayDirect = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, 1, - InviteOrderSubsidy.LEVEL_ONE); - if (todayDirect == null) { - todayDirect = new BigDecimal(0); - } - BigDecimal todayIndirect = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, 1, - InviteOrderSubsidy.LEVEL_TWO); - if (todayIndirect == null) { - todayIndirect = new BigDecimal(0); - } - TeamBonusVO today = new TeamBonusVO(); - today.setDirect(todayDirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); - today.setIndirect(todayIndirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); - today.setTotal( - MoneyBigDecimalUtil.add(todayDirect, todayIndirect).setScale(2, BigDecimal.ROUND_DOWN).toString()); - - // 鏄ㄦ棩缁熻 - BigDecimal yesterdayDirect = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, 2, - InviteOrderSubsidy.LEVEL_ONE); - if (yesterdayDirect == null) { - yesterdayDirect = new BigDecimal(0); - } - BigDecimal yesterdayIndirect = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, 2, - InviteOrderSubsidy.LEVEL_TWO); - if (yesterdayIndirect == null) { - yesterdayIndirect = new BigDecimal(0); - } - TeamBonusVO yesterday = new TeamBonusVO(); - yesterday.setDirect(yesterdayDirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); - yesterday.setIndirect(yesterdayIndirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); - yesterday.setTotal(MoneyBigDecimalUtil.add(yesterdayDirect, yesterdayIndirect) - .setScale(2, BigDecimal.ROUND_DOWN).toString()); - - // 鏈湀缁熻 - BigDecimal thisMonthDirect = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, 3, - InviteOrderSubsidy.LEVEL_ONE); - if (thisMonthDirect == null) { - thisMonthDirect = new BigDecimal(0); - } - BigDecimal thisMonthIndirect = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, 3, - InviteOrderSubsidy.LEVEL_TWO); - if (thisMonthIndirect == null) { - thisMonthIndirect = new BigDecimal(0); - } - TeamBonusVO thisMonth = new TeamBonusVO(); - thisMonth.setDirect(thisMonthDirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); - thisMonth.setIndirect(thisMonthIndirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); - thisMonth.setTotal(MoneyBigDecimalUtil.add(thisMonthDirect, thisMonthIndirect) - .setScale(2, BigDecimal.ROUND_DOWN).toString()); - - // 鏈湀缁熻 - BigDecimal lastMonthDirect = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, 4, - InviteOrderSubsidy.LEVEL_ONE); - if (lastMonthDirect == null) { - lastMonthDirect = new BigDecimal(0); - } - BigDecimal lastMonthIndirect = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, 4, - InviteOrderSubsidy.LEVEL_TWO); - if (lastMonthIndirect == null) { - lastMonthIndirect = new BigDecimal(0); - } - TeamBonusVO lastMonth = new TeamBonusVO(); - lastMonth.setDirect(lastMonthDirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); - lastMonth.setIndirect(lastMonthIndirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); - lastMonth.setTotal(MoneyBigDecimalUtil.add(lastMonthDirect, lastMonthIndirect) - .setScale(2, BigDecimal.ROUND_DOWN).toString()); - - BigDecimal direct = inviteOrderSubsidyServiceV2.sumRecievedMoneyByUid(uid, InviteOrderSubsidy.LEVEL_ONE); - if (direct == null) { - direct = new BigDecimal(0); - } - BigDecimal indirect = inviteOrderSubsidyServiceV2.sumRecievedMoneyByUid(uid, InviteOrderSubsidy.LEVEL_TWO); - if (indirect == null) { - indirect = new BigDecimal(0); - } - BigDecimal total = MoneyBigDecimalUtil.add(direct, indirect); - - data.put("today", today); - data.put("yesterday", yesterday); - data.put("thisMonth", thisMonth); - data.put("lastMonth", lastMonth); - data.put("total", total.setScale(2, BigDecimal.ROUND_DOWN).toString()); - data.put("direct", direct.setScale(2, BigDecimal.ROUND_DOWN).toString()); - data.put("indirect", indirect.setScale(2, BigDecimal.ROUND_DOWN).toString()); out.print(JsonUtil.loadTrueResult(data)); } @@ -741,8 +573,7 @@ hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney); } } - orderRebateVO.setFanLiDesc(predictDesc + typeName); - orderRebateVO.setFanLi("楼" + hongBao.setScale(2, BigDecimal.ROUND_DOWN)); + HongBaoV2 hongBaoV2 = hoList.get(0).getHongBaoV2(); UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(hongBaoV2.getUrank()); @@ -790,10 +621,17 @@ } voList.add(goodsVO); - - upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel)); + + if (type == 1 ) { + upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel)); + } else if (type == 2) { + upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, upperLevel)); + } } + CommonOrder commonOrder = hoList.get(0).getCommonOrder(); + Date downTime = commonOrder.getThirdCreateTime(); + // 鍥㈤槦琛ヨ创 if (type == 3) { BigDecimal teamSubsidy = null; @@ -801,16 +639,27 @@ 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); + + // 璁$畻杈句汉琛ヨ创 if (userLevel != UserLevelEnum.daRen) { - CommonOrder commonOrder = hoList.get(0).getCommonOrder(); - 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; - } - // 璁$畻涓婁竴绾цˉ璐� - lowerSubsidy = getLowerSubsidy(inviteOrderSubsidy.getMoney(), commonOrder.getThirdCreateTime(), buyerUserLevel, userLevel, direct); + BigDecimal daRenRate = orderHongBaoMoneyComputeService.getTeamSubsidyRate(downTime, buyerUserLevel, + UserLevelEnum.daRen, direct); + lowerSubsidy = MoneyBigDecimalUtil.div(teamSubsidy.multiply(daRenRate), originRate); + } + + if (userLevel != UserLevelEnum.superVIP && userLevel != UserLevelEnum.superVIP) { + 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); @@ -822,15 +671,25 @@ } orderRebateVO.setSubsidyDesc("鍥㈤槦琛ヨ创"); orderRebateVO.setSubsidy("楼" + teamSubsidy.setScale(2, BigDecimal.ROUND_DOWN) +""); + + hongBao = hongBao.add(teamSubsidy); } + + orderRebateVO.setFanLiDesc(predictDesc + typeName); + orderRebateVO.setFanLi("楼" + hongBao.setScale(2, BigDecimal.ROUND_DOWN)); orderRebateVO.setType(type); orderRebateVO.setStateDesc(stateDesc); orderRebateVO.setListGoods(voList); - orderRebateVO.setUserLevel(userLevel.name()); + if (downTime.getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME) { + orderRebateVO.setUserLevel(UserLevelEnum.superVIP.name()); // 闅愯棌 + } else { + orderRebateVO.setUserLevel(userLevel.name()); + } // 涓婄骇杩斿埄 if (upperLevel != null) { + upperTotalMoney = upperTotalMoney.add(hongBao); orderRebateVO.setUpperFanLi("楼" + upperTotalMoney); orderRebateVO.setJumpLink(upperLevel.getDetailLink()); } @@ -852,7 +711,6 @@ freeState = state; break; } - } } @@ -908,18 +766,6 @@ JSONObject data = new JSONObject(); data.put("result", orderRebateVO); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } - - - private BigDecimal getLowerSubsidy(BigDecimal money, Date downTime, UserLevelEnum buyerUserLevel, UserLevelEnum userLevel, boolean direct) { - // 鍘熷姣斾緥 - BigDecimal originRate = orderHongBaoMoneyComputeService.getTeamSubsidyRate(downTime, - buyerUserLevel, userLevel, direct); - - // 灏忎竴绾ф瘮渚� - BigDecimal darenRate = orderHongBaoMoneyComputeService.getTeamSubsidyRate(downTime, buyerUserLevel, UserLevelEnum.daRen, direct); - - return MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.div(money,originRate), darenRate); } -- Gitblit v1.8.0