| | |
| | | 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.ThreeSale;
|
| | | 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.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.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 ThreeSaleSerivce threeSaleSerivce;
|
| | | |
| | | @Resource
|
| | | private OrderHongBaoMapService orderHongBaoMapService;
|
| | | |
| | | @Resource
|
| | | private PreviewInfoService previewInfoService;
|
| | | |
| | |
|
| | | /**
|
| | | * 订单列表
|
| | |
| | | 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);
|
| | |
| | | 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);
|
| | | |
| | | 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));
|
| | | }
|
| | |
|
| | |
| | | hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
|
| | | }
|
| | | }
|
| | | orderRebateVO.setFanLiDesc(predictDesc + typeName);
|
| | | orderRebateVO.setFanLi("¥" + hongBao.setScale(2));
|
| | |
|
| | | // 红包获得者
|
| | | 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();
|
| | | UserLevelEnum buyer = UserLevelUtil.getByOrderRank(commonOrder1.getUrank());
|
| | | if (buyer == null) {
|
| | | buyer = UserLevelEnum.daRen;
|
| | | }
|
| | | |
| | | BigDecimal upperTotalMoney = new BigDecimal(0);
|
| | | List<GoodsRebateVO> voList = new ArrayList<>();
|
| | | for (HongBaoOrder hongBaoOrder : hoList) {
|
| | |
| | |
|
| | | // 实付款
|
| | | 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);
|
| | | goodsVO.setActualPay("¥" + payment.setScale(2));
|
| | |
|
| | | goodsVO.setActualPay("¥" + payment.setScale(2, BigDecimal.ROUND_DOWN));
|
| | |
|
| | | BigDecimal fanli = hongBaoOrder.getHongBaoV2().getMoney();
|
| | | // 基础佣金
|
| | | BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder);
|
| | | if (type == 3) { // 奖金
|
| | | goodsVO.setBonus("¥" + hongBaoOrder.getHongBaoV2().getMoney() +"");
|
| | | } else { // 佣金
|
| | | goodsVO.setCommision("¥" +commission);
|
| | | }
|
| | | |
| | | // 平台补贴
|
| | | BigDecimal vipFanli = hongBaoOrder.getHongBaoV2().getMoney();
|
| | | goodsVO.setSubsidy("¥" + vipFanli.subtract(commission).setScale(2));
|
| | | goodsVO.setCommision("¥" +commission.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | |
| | | // 平台补贴 = 返利 - 基础佣金
|
| | | goodsVO.setSubsidy("¥" + fanli.subtract(commission).setScale(2, BigDecimal.ROUND_DOWN));
|
| | | // 达人补贴
|
| | | if (userLevel != UserLevelEnum.daRen) {
|
| | | BigDecimal darenFanli = orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, UserLevelEnum.daRen);
|
| | | goodsVO.setOriginSubsidy("¥" + darenFanli.subtract(commission).setScale(2) + "");
|
| | | goodsVO.setOriginSubsidy("¥" + darenFanli.subtract(commission).setScale(2, BigDecimal.ROUND_DOWN) + "");
|
| | | }
|
| | | |
| | | if (type == 3) { // 奖金
|
| | | goodsVO.setBonus("¥" + fanli.setScale(2, BigDecimal.ROUND_DOWN) +"");
|
| | | }
|
| | |
|
| | | voList.add(goodsVO);
|
| | | |
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel));
|
| | | }
|
| | |
|
| | | // 团队补贴
|
| | | if (type == 3) {
|
| | | BigDecimal teamSubsidy = null;
|
| | | BigDecimal lowerSubsidy = null;
|
| | | InviteOrderSubsidy inviteOrderSubsidy = inviteOrderSubsidyServiceV2.getByOrderNoAndType(uid, orderNo, sourceType);
|
| | | if (inviteOrderSubsidy != null) {
|
| | | teamSubsidy = inviteOrderSubsidy.getMoney();
|
| | | 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;
|
| | | if (type == 1 ) {
|
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel));
|
| | | } else if (type == 2) {
|
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, upperLevel));
|
| | | } else if (type == 3) {
|
| | | 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;
|
| | | }
|
| | | // 计算上一级补贴
|
| | | lowerSubsidy = getLowerSubsidy(inviteOrderSubsidy.getMoney(), commonOrder.getThirdCreateTime(), buyerUserLevel, userLevel, direct);
|
| | | bossLevelList.add(new UserTeamLevel(null, directBoss));
|
| | | bossLevelList.add(new UserTeamLevel(null, UserLevelEnum.superVIP));
|
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService.computeSecondInviteMoney(commonOrder,
|
| | | buyer, bossLevelList));
|
| | | }
|
| | | } else {
|
| | | teamSubsidy = BigDecimal.valueOf(0.00);
|
| | | lowerSubsidy = BigDecimal.valueOf(0.00);
|
| | | }
|
| | | |
| | | if (userLevel != UserLevelEnum.daRen) {
|
| | | orderRebateVO.setOriginSubsidy("¥" + lowerSubsidy.setScale(2));
|
| | | }
|
| | | orderRebateVO.setSubsidyDesc("团队补贴");
|
| | | orderRebateVO.setSubsidy("¥" + teamSubsidy.setScale(2) +"");
|
| | | }
|
| | |
|
| | | |
| | | orderRebateVO.setFanLiDesc(predictDesc + typeName);
|
| | | orderRebateVO.setFanLi("¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | orderRebateVO.setType(type);
|
| | | orderRebateVO.setStateDesc(stateDesc);
|
| | | orderRebateVO.setListGoods(voList);
|
| | | if (downTime.getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME) {
|
| | | orderRebateVO.setUserLevel(UserLevelEnum.superVIP.name()); // 隐藏
|
| | | } else {
|
| | | orderRebateVO.setUserLevel(userLevel.name());
|
| | | }
|
| | |
|
| | | // 上级返利
|
| | | // 超级会员返利
|
| | | if (upperLevel != null) {
|
| | | orderRebateVO.setUpperFanLi("¥" + upperTotalMoney);
|
| | | orderRebateVO.setUserLevel(upperLevel.name());
|
| | | orderRebateVO.setJumpLink(upperLevel.getDetailLink());
|
| | | }
|
| | |
|
| | | |
| | | int freeState = 0;
|
| | | boolean rewardSuccess = false;
|
| | | List<String> listNo = new ArrayList<String>();
|
| | | listNo.add(orderNo);
|
| | | List<UserSystemCouponRecord> useRecord = userSystemCouponRecordService.getRecordByOrderNoList(sourceType, listNo);
|
| | | if (useRecord != null && useRecord.size() > 0) {
|
| | | for (UserSystemCouponRecord couponRecord : useRecord) {
|
| | | int goodSource = couponRecord.getGoodSource();
|
| | | if (goodSource == 0)
|
| | | goodSource = 1;
|
| | |
|
| | | Integer state = couponRecord.getState();
|
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
|
| | | && UserSystemCouponRecord.STATE_SUCCESS == state) {
|
| | | String cType = couponRecord.getCouponType();
|
| | | if (CouponTypeEnum.rebatePercentCoupon.name().equals(cType) && UserSystemCouponRecord.STATE_SUCCESS == state) {
|
| | | rewardSuccess = true;
|
| | | break;
|
| | | } else if (CouponTypeEnum.freeCoupon.name().equals(cType) || CouponTypeEnum.welfareFreeCoupon.name().equals(cType)
|
| | | || CouponTypeEnum.freeCouponBuy.name().equals(cType)) {
|
| | | freeState = state;
|
| | | break;
|
| | | }
|
| | | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | if (rewardSuccess) { // 已使用奖励券
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", orderNo);
|
| | | jumpLink.put("goodsType", sourceType + "");
|
| | | orderRebateVO.setCouponSuccess(true);
|
| | | orderRebateVO.setCouponParams(jumpLink.toString());
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("orderNo", orderNo);
|
| | | params.put("goodsType", sourceType + "");
|
| | | BigDecimal couponMoney = orderHongBaoMapService.getCouponHongbaoByOrderNo(orderNo, uid);
|
| | | if (couponMoney == null) {
|
| | | couponMoney = new BigDecimal(0);
|
| | | }
|
| | | orderRebateVO.setCouponType(1);
|
| | | orderRebateVO.setCouponUse(true);
|
| | | orderRebateVO.setCouponText("奖励成功");
|
| | | orderRebateVO.setCouponDesc("已再返¥" +couponMoney.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | orderRebateVO.setCouponParams(params.toString());
|
| | | orderRebateVO.setCouponJumpDetail(jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
|
| | | } else { // 可使用奖励券
|
| | | Date accountTime = hongBaoCountVO.getAccountTime();
|
| | | if (accountTime != null) { |
| | | } else if (freeState > 0) { // 已使用免单券
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("orderNo", orderNo);
|
| | | params.put("goodsType", sourceType + "");
|
| | | orderRebateVO.setCouponType(2);
|
| | | orderRebateVO.setCouponUse(true);
|
| | | orderRebateVO.setCouponParams(params.toString());
|
| | | orderRebateVO.setCouponJumpDetail(jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
|
| | | if (UserSystemCouponRecord.STATE_FREE_ON == freeState) {
|
| | | orderRebateVO.setCouponText("免单中");
|
| | | } else if (UserSystemCouponRecord.STATE_SUCCESS == freeState) {
|
| | | orderRebateVO.setCouponText("免单成功");
|
| | | } else if (UserSystemCouponRecord.STATE_FAIL_RULE == freeState
|
| | | || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == freeState) {
|
| | | orderRebateVO.setCouponText("免单失败");
|
| | | }
|
| | | } else {
|
| | | Date accountTime = hongBaoV2.getGetTime();
|
| | | // 到账时间 -红包金额限制
|
| | | 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("立即使用");
|
| | | orderRebateVO.setCouponDesc("返利再返");
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | 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);
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 数据统计
|
| | | * @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));
|
| | | }
|
| | |
|
| | | }
|