| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.order.UserTeamLevel;
|
| | | import com.yeshi.fanli.dto.user.UserInviteLevelEnum;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.PreviewInfo.PreviewEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | |
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.order.ESOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.ESOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.PreviewInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | |
| | | 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;
|
| | | import com.yeshi.fanli.vo.order.OrderRebateVO;
|
| | | import com.yeshi.fanli.vo.user.MineInfoVO;
|
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
|
| | |
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyServiceV2;
|
| | |
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | | |
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMapService orderHongBaoMapService;
|
| | | |
| | | @Resource
|
| | | private PreviewInfoService previewInfoService;
|
| | | |
| | |
|
| | | /**
|
| | | * 订单列表
|
| | |
| | | show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0;
|
| | | }
|
| | |
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1, null);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, null);
|
| | | BigDecimal selfMoney = null;
|
| | | BigDecimal shareMoney = null;
|
| | | BigDecimal teamMoney = null;
|
| | | // VIP预览信息
|
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | String redisContent = previewInfoService.getRedisContent(uid, PreviewEnum.mineInfo);
|
| | | if (!StringUtil.isNullOrEmpty(redisContent)) {
|
| | | MineInfoVO vo = new Gson().fromJson(redisContent, MineInfoVO.class);
|
| | | if (vo != null) {
|
| | | if (!StringUtil.isNullOrEmpty(vo.getSelfRebate()))
|
| | | selfMoney = new BigDecimal(vo.getSelfRebate());
|
| | | if (!StringUtil.isNullOrEmpty(vo.getShareBonus()))
|
| | | shareMoney = new BigDecimal(vo.getShareBonus());
|
| | | if (!StringUtil.isNullOrEmpty(vo.getTeamBonus()))
|
| | | teamMoney = new BigDecimal(vo.getTeamBonus());
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (selfMoney == null) {
|
| | | selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1, null);
|
| | | shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, null);
|
| | | teamMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, null);
|
| | | }
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("show", show);
|
| | | data.put("selfMoney", selfMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | data.put("shareMoney", shareMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | |
| | | |
| | | BigDecimal teamMoney = new BigDecimal(0);
|
| | | if (!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | teamMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, null);
|
| | | } else {
|
| | | BigDecimal bonus = null;
|
| | | BigDecimal subsidy = null;
|
| | | BigDecimal dividend = null; // TODO 分红统计
|
| | | if (dateType == 4) { // 已到账
|
| | | dividend = new BigDecimal(0);
|
| | | bonus = hongBaoV2CountService.geBonusByuid(uid, dateType, 3, 2);
|
| | | subsidy = inviteOrderSubsidyServiceV2.sumMoneyByUidAndDateAndState(uid,dateType,null,3);
|
| | | } else { // 未失效
|
| | | bonus = hongBaoV2CountService.geBonusByuid(uid, dateType, 3, 4);
|
| | | subsidy = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid,dateType,null);
|
| | | }
|
| | | |
| | | dividend = new BigDecimal(0);
|
| | | // 总团队奖励
|
| | | teamMoney = bonus.add(subsidy).add(dividend);
|
| | | }
|
| | | data.put("inviteMoney", teamMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | // 红包获得者
|
| | | HongBaoV2 hongBaoV2 = hoList.get(0).getHongBaoV2();
|
| | | UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(hongBaoV2.getUrank());
|
| | | if (userLevel == null)
|
| | | 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;
|
| | | UserLevelEnum buyer = UserLevelUtil.getByOrderRank(commonOrder1.getUrank());
|
| | | if (buyer == null) {
|
| | | buyer = UserLevelEnum.daRen;
|
| | | }
|
| | |
|
| | | BigDecimal upperTotalMoney = new BigDecimal(0);
|
| | |
| | |
|
| | | // 实付款
|
| | | BigDecimal payment = hongBaoOrder.getCommonOrder().getPayment();
|
| | | if (hongBaoOrder.getCommonOrder().getSettlement() != null)
|
| | | // 若已结算 -显示结算金额
|
| | | Integer orderState = hongBaoOrder.getCommonOrder().getState();
|
| | | if (hongBaoOrder.getCommonOrder().getSettlement() != null |
| | | && (orderState == CommonOrder.STATE_JS || orderState == CommonOrder.STATE_WQ))
|
| | | payment = hongBaoOrder.getCommonOrder().getSettlement();
|
| | | if (payment == null)
|
| | | payment = new BigDecimal(0);
|
| | |
| | | // 基础佣金
|
| | | BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder);
|
| | | goodsVO.setCommision("¥" +commission.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | |
| | | // 平台补贴 = 返利 - 基础佣金
|
| | | goodsVO.setSubsidy("¥" + fanli.subtract(commission).setScale(2, BigDecimal.ROUND_DOWN));
|
| | | // 达人补贴
|
| | |
| | | } else if (type == 2) {
|
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, upperLevel));
|
| | | } else if (type == 3) {
|
| | | upperTotalMoney = upperTotalMoney.add(hongBao);
|
| | | List<UserTeamLevel> bossLevelList = new ArrayList<>();
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
|
| | | bossLevelList.add(new UserTeamLevel(null, UserLevelEnum.superVIP));
|
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder,
|
| | | buyer, bossLevelList));
|
| | | } else {
|
| | | Integer bRank = hongBaoV2Service.getDirectBossUrankByPid(hongBaoOrder.getHongBaoV2().getParent().getId());
|
| | | UserLevelEnum directBoss = UserLevelUtil.getByOrderRank(bRank);
|
| | | if (directBoss == null) {
|
| | | directBoss = UserLevelEnum.daRen;
|
| | | }
|
| | | bossLevelList.add(new UserTeamLevel(null, directBoss));
|
| | | bossLevelList.add(new UserTeamLevel(null, UserLevelEnum.superVIP));
|
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder,
|
| | | buyer, bossLevelList));
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // 团队补贴
|
| | | if (type == 3) {
|
| | | BigDecimal teamSubsidy = null;
|
| | | BigDecimal lowerSubsidy = null;
|
| | | InviteOrderSubsidy inviteOrderSubsidy = inviteOrderSubsidyServiceV2.getByOrderNoAndType(uid, orderNo, sourceType);
|
| | | if (inviteOrderSubsidy != null) {
|
| | | teamSubsidy = inviteOrderSubsidy.getMoney();
|
| | | // 计算原比例
|
| | | BigDecimal originRate = orderHongBaoMoneyComputeService.getTeamSubsidyRate(downTime,buyerUserLevel, userLevel, direct);
|
| | | |
| | | // 计算达人补贴
|
| | | if (userLevel != UserLevelEnum.daRen) {
|
| | | BigDecimal daRenRate = orderHongBaoMoneyComputeService.getTeamSubsidyRate(downTime, buyerUserLevel, |
| | | UserLevelEnum.daRen, direct);
|
| | | lowerSubsidy = MoneyBigDecimalUtil.div(teamSubsidy.multiply(daRenRate), originRate);
|
| | | }
|
| | | |
| | | // 计算超级会员补贴
|
| | | 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));
|
| | | }
|
| | | |
| | | } else {
|
| | | teamSubsidy = BigDecimal.valueOf(0.00);
|
| | | lowerSubsidy = BigDecimal.valueOf(0.00);
|
| | | }
|
| | | |
| | | if (userLevel != UserLevelEnum.daRen) {
|
| | | orderRebateVO.setOriginSubsidy("¥" + lowerSubsidy.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | }
|
| | | 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);
|
| | |
| | | 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));
|
| | | }
|
| | |
|
| | | }
|