| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.dto.order.SearchFilterOrder;
|
| | | import com.yeshi.fanli.dto.order.UserTeamLevel;
|
| | | 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.ThreeSaleDetail;
|
| | | 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.CommonOrder;
|
| | | 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.order.OrderTeamReward;
|
| | | import com.yeshi.fanli.entity.order.UserOrderWeiQuanRecord;
|
| | | 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.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderGoodsService;
|
| | | 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.InviteOrderSubsidyServiceV2;
|
| | | 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.OrderTeamRewardService;
|
| | | import com.yeshi.fanli.service.inter.order.UserOrderWeiQuanRecordService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceOrderUserMapService;
|
| | | 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.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | 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.order.CommonOrderVO;
|
| | | 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.order.TeamOrderVO;
|
| | | import com.yeshi.fanli.vo.user.MineInfoVO;
|
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
|
| | |
| | | private ESOrderService esOrderService;
|
| | |
|
| | | @Resource
|
| | | private OrderTeamRewardService orderTeamRewardService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyServiceV2 inviteOrderSubsidyServiceV2;
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
| | | @Resource
|
| | | private CommonOrderGoodsService commonOrderGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponRecordService userSystemCouponRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserInviteService userInviteService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMapService orderHongBaoMapService;
|
| | |
|
| | | @Resource
|
| | | private PreviewInfoService previewInfoService;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceOrderService teamDividentsSourceOrderService;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsSourceOrderUserMapService teamDividentsSourceOrderUserMapService;
|
| | |
|
| | | @Resource
|
| | | private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleDetailService threeSaleDetailService;
|
| | |
|
| | | /**
|
| | | * 订单列表
|
| | | * 处理搜索条件
|
| | | *
|
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | | * @param state
|
| | | * 状态:0全部 1-未到账 2-已到账 3-已失效 4已收货
|
| | | * @param type
|
| | | * 类型:1-返利订单 2-分享订单 3-邀请订单
|
| | | * @param orderState
|
| | | * 1有效订单 2 维权订单 3失效订单
|
| | | * @param orderNo
|
| | | * 订单号
|
| | | * @param startTime
|
| | | * 起始时间
|
| | | * @param endTime
|
| | | * 结束时间
|
| | | * @param slotTime
|
| | | * 时间段:1-最近三天 2-最近七天 3最近半月 4本月 5近三月 6近半年
|
| | | * @param dateType
|
| | | * 1-今日 2-昨天 3-本月 4-上个月 |
|
| | | * @param source |
| | | * 页面来源:welfareCore-福利中心、bonus -奖金统计(我的界面)
|
| | | * @param out
|
| | | * @param filter
|
| | | */
|
| | | @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
|
| | | public void getOrderList(AcceptData acceptData, Integer page, Long uid, Integer state, String type,
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer slotTime, Integer dateType,
|
| | | Integer goodsType, String source, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | private void handleSearchFilter(SearchFilterOrder filter) {
|
| | | Integer goodsType = filter.getGoodsType();
|
| | | if (goodsType != null && goodsType == 0) {
|
| | | goodsType = null;
|
| | | filter.setGoodsType(goodsType);
|
| | | }
|
| | |
|
| | | if (page == null || page < 1)
|
| | | page = 1;
|
| | |
|
| | | // 搜索内容、订单号
|
| | | if (!StringUtil.isNullOrEmpty(orderNo)
|
| | | && VersionUtil.greaterThan_2_0_6(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | searchOrder(acceptData, orderNo, page, uid, out);
|
| | | return;
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (goodsType != null) {
|
| | | listSource.add(goodsType);
|
| | | }
|
| | | filter.setListSource(listSource);
|
| | |
|
| | | // 订单类型
|
| | | String type = filter.getType();
|
| | | Integer orderType = null;
|
| | | if (StringUtil.isNullOrEmpty(type)) {
|
| | | orderType = null;
|
| | | } else if (!"0".equalsIgnoreCase(type)) {
|
| | | orderType = Integer.parseInt(type);
|
| | | }
|
| | | filter.setOrderType(orderType);
|
| | |
|
| | | // 转换状态
|
| | | Integer orderState = filter.getOrderState();
|
| | | Integer state = filter.getState();
|
| | | if (state != null) {
|
| | | if (state == 0) {
|
| | | state = null; // 所有
|
| | |
| | | if (state != null && orderState != null && (orderState == 2 || orderState == 3)) {
|
| | | state = null;
|
| | | }
|
| | |
|
| | | // 订单类型
|
| | | Integer orderType = null;
|
| | | if (StringUtil.isNullOrEmpty(type)) {
|
| | | orderType = null;
|
| | | } else if (!"0".equalsIgnoreCase(type)) {
|
| | | orderType = Integer.parseInt(type);
|
| | | }
|
| | |
|
| | | if (goodsType != null && goodsType == 0)
|
| | | goodsType = null;
|
| | | filter.setState(state);
|
| | | filter.setOrderState(orderState);
|
| | |
|
| | | // 筛选时间
|
| | | Integer dateType = filter.getDateType();
|
| | | String startTime = filter.getStartTime();
|
| | | String endTime = filter.getEndTime();
|
| | | Integer slotTime = filter.getSlotTime();
|
| | | if (slotTime != null) {
|
| | | try {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | filter.setDateType(dateType);
|
| | | filter.setStartTime(startTime);
|
| | |
|
| | | if (endTime != null && endTime.trim().length() > 0) {
|
| | | endTime += " 23:59:59";
|
| | | }
|
| | | filter.setEndTime(endTime);
|
| | |
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (goodsType != null) {
|
| | | listSource.add(goodsType);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 订单列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | | * @param state 状态:0全部 1-未到账 2-已到账 3-已失效 4已收货
|
| | | * @param type 类型:1-返利订单 2-分享订单 3-邀请订单
|
| | | * @param orderState 1有效订单 2 维权订单 3失效订单
|
| | | * @param orderNo 订单号
|
| | | * @param startTime 起始时间
|
| | | * @param endTime 结束时间
|
| | | * @param slotTime 时间段:1-最近三天 2-最近七天 3最近半月 4本月 5近三月 6近半年
|
| | | * @param dateType 1-今日 2-昨天 3-本月 4-上个月 |
|
| | | * @param source 页面来源:welfareCore-福利中心、bonus -奖金统计(我的界面)
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
|
| | | public void getOrderList(AcceptData acceptData, Integer page, SearchFilterOrder filter, PrintWriter out) {
|
| | | Long uid = filter.getUid();
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == null || page < 1)
|
| | | page = 1;
|
| | |
|
| | | handleSearchFilter(filter);
|
| | | String startTime = filter.getStartTime();
|
| | | String endTime = filter.getEndTime();
|
| | | Integer orderType = filter.getOrderType();
|
| | | Integer dateType = filter.getDateType();
|
| | | Integer state = filter.getState();
|
| | | List<Integer> listSource = filter.getListSource();
|
| | | Integer orderState = filter.getOrderState();
|
| | |
|
| | | try {
|
| | | if (!VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (listSource.size() == 0) {
|
| | | listSource.add(Constant.SOURCE_TYPE_TAOBAO);
|
| | | listSource.add(Constant.SOURCE_TYPE_JD);
|
| | | listSource.add(Constant.SOURCE_TYPE_PDD);
|
| | | }
|
| | | }
|
| | | |
| | | // 搜索内容、订单号
|
| | | String orderNo = filter.getOrderNo();
|
| | | if (!StringUtil.isNullOrEmpty(orderNo)
|
| | | && VersionUtil.greaterThan_2_0_6(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | searchOrder(acceptData, orderNo, page, uid, listSource, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 筛选结果顶部统计
|
| | | String validMoney = "0.00";
|
| | | String invalidMoney = "0.00";
|
| | | if (page == 1) {
|
| | | BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 1,
|
| | | orderNo, state, startTime, endTime, listSource);
|
| | | BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, filter.getDateType(),
|
| | | orderType, 1, orderNo, state, startTime, endTime, listSource);
|
| | | if (predictMoney != null)
|
| | | validMoney = predictMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
|
| | |
|
| | | BigDecimal postSaleMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 2,
|
| | | orderNo, state, startTime, endTime, listSource);
|
| | | BigDecimal postSaleMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, filter.getDateType(),
|
| | | orderType, 2, orderNo, state, startTime, endTime, listSource);
|
| | | if (postSaleMoney != null)
|
| | | invalidMoney = postSaleMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 查询列表
|
| | | List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType,
|
| | | orderState, orderNo, startTime, endTime, dateType, listSource);
|
| | | // 统计总数
|
| | | long count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo,
|
| | | startTime, endTime, dateType, listSource);
|
| | | long count = 0L;
|
| | | List<CommonOrderVO> list = null;
|
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | list = commonOrderService.getOrderList(acceptData, page, uid, state, orderType, orderState, orderNo,
|
| | | startTime, endTime, dateType, listSource);
|
| | |
|
| | | count = commonOrderService.countOrderList(uid, state, orderType, orderState, orderNo, startTime,
|
| | | endTime, dateType, listSource);
|
| | | } else {
|
| | | list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType, orderState, orderNo,
|
| | | startTime, endTime, dateType, listSource);
|
| | | count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo, startTime,
|
| | | endTime, dateType, listSource);
|
| | | }
|
| | |
|
| | | // 判断是否需要显示订单找回提示 8秒内请求3次触发
|
| | | String orderFindUrl = null;
|
| | |
| | | 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);
|
| | |
| | |
|
| | | /**
|
| | | * 搜索订单
|
| | | * |
| | | * @param key
|
| | | * @param out
|
| | | */
|
| | | private void searchOrder(AcceptData acceptData, String key, Integer page, Long uid, PrintWriter out) {
|
| | | private void searchOrder(AcceptData acceptData, String key, Integer page, Long uid, List<Integer> listSource, PrintWriter out) {
|
| | | try {
|
| | | long count = 0;
|
| | | List<CommonOrderVO> list = null;
|
| | | if (NumberUtil.isNumeric(key.replace("-", ""))) {
|
| | | list = commonOrderService.getOrderByUid(acceptData, page, uid, null, null, null, key, null, null, null,
|
| | | null);
|
| | | if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | list = commonOrderService.getOrderList(acceptData, page, uid, null, null, null, key, null, null, null,listSource);
|
| | | } else
|
| | | list = commonOrderService.getOrderByUid(acceptData, page, uid, null, null, null, key, null, null, null, listSource);
|
| | | }
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | |
| | | * 用户订单统计
|
| | | *
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * 用户id
|
| | | * type 类型:0全部、1淘宝 2京东、拼多多
|
| | | * @param uid 用户id type 类型:0全部、1淘宝 2京东、拼多多
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOrderCount", method = RequestMethod.POST)
|
| | |
| | |
|
| | | /**
|
| | | * 统计奖金
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param dateType 1-今日 2-昨天 3-本月 4-上个月
|
| | | * @param dateType 1-今日 2-昨天 3-本月 4-上个月
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getBonusCount", method = RequestMethod.POST)
|
| | |
| | | show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0;
|
| | | }
|
| | |
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1, null);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, null);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, null);
|
| | | BigDecimal selfMoney = null;
|
| | | BigDecimal shareMoney = null;
|
| | | BigDecimal teamMoney = null;
|
| | | // VIP预览信息
|
| | | if (VersionUtil.greaterThan_2_1_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());
|
| | | data.put("inviteMoney", inviteMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | |
|
| | | // 团队奖励 TODO
|
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | BigDecimal teamSubsidy = inviteOrderSubsidyServiceV2.sumValidMoneyByUidAndDate(uid, dateType, null);
|
| | | if (teamSubsidy == null) {
|
| | | teamSubsidy = new BigDecimal(0);
|
| | | }
|
| | |
|
| | | BigDecimal teamReward = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, dateType, null);
|
| | | if (teamReward == null) {
|
| | | teamReward = new BigDecimal(0);
|
| | | }
|
| | |
|
| | | data.put("teamSubsidy", teamSubsidy.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | data.put("teamReward", teamReward.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | data.put("tutorSubsidy", "0.00");
|
| | | }
|
| | | 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) {
|
| | | // 奖励
|
| | | sumTeamReward(out, user);
|
| | | } 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));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计团队奖励
|
| | | * @param out
|
| | | * @param user
|
| | | */
|
| | | private void sumTeamReward(PrintWriter out, UserInfo user) {
|
| | | Long uid = user.getId();
|
| | | // 是否VIP
|
| | | boolean vip = userVIPInfoService.isVIP(uid);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("link", configService.get(ConfigKeyEnum.orderTeamRewardLink.getKey()));
|
| | | if (!vip) {
|
| | | data.put("exist", false);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | data.put("exist", true);
|
| | | data.put("portrait", user.getPortrait());
|
| | |
|
| | | // 今日统计
|
| | | BigDecimal todayDirect = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, 1, OrderTeamReward.LEVEL_ONE);
|
| | | if (todayDirect == null) {
|
| | | todayDirect = new BigDecimal(0);
|
| | | }
|
| | | BigDecimal todayIndirect = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, 1, OrderTeamReward.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 = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, 2,
|
| | | OrderTeamReward.LEVEL_ONE);
|
| | | if (yesterdayDirect == null) {
|
| | | yesterdayDirect = new BigDecimal(0);
|
| | | }
|
| | | BigDecimal yesterdayIndirect = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, 2,
|
| | | OrderTeamReward.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 = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, 3,
|
| | | OrderTeamReward.LEVEL_ONE);
|
| | | if (thisMonthDirect == null) {
|
| | | thisMonthDirect = new BigDecimal(0);
|
| | | }
|
| | | BigDecimal thisMonthIndirect = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, 3,
|
| | | OrderTeamReward.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 = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, 4,
|
| | | OrderTeamReward.LEVEL_ONE);
|
| | | if (lastMonthDirect == null) {
|
| | | lastMonthDirect = new BigDecimal(0);
|
| | | }
|
| | | BigDecimal lastMonthIndirect = orderTeamRewardService.sumValidMoneyByUidAndDate(uid, 4,
|
| | | OrderTeamReward.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 = orderTeamRewardService.sumRecievedMoneyByUid(uid, OrderTeamReward.LEVEL_ONE);
|
| | | if (direct == null) {
|
| | | direct = new BigDecimal(0);
|
| | | }
|
| | | BigDecimal indirect = orderTeamRewardService.sumRecievedMoneyByUid(uid, OrderTeamReward.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());
|
| | | data.put("inviteMoney", teamMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 返利说明
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param orderNo
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | // 按订单号 查询
|
| | | List<CommonOrder> commonOrderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderNo);
|
| | | Integer rank = commonOrderList.get(0).getUrank();
|
| | | UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(rank);
|
| | | if (userLevel == null)
|
| | | userLevel = UserLevelEnum.daRen;
|
| | | // 红包信息
|
| | | List<HongBaoOrder> hoList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType,
|
| | | uid);
|
| | | HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hoList);
|
| | |
|
| | | List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceType(orderNo, sourceType);
|
| | | Integer hongBaoState = hongBaoCountVO.getCurrentState();
|
| | | String stateDesc = "";
|
| | | String predictDesc = "";
|
| | | if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
|
| | | stateDesc = "未到账";
|
| | | predictDesc = "预估";
|
| | | } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
|
| | | stateDesc = "已到账";
|
| | | } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
|
| | | stateDesc = "已失效";
|
| | | }
|
| | |
|
| | | OrderRebateVO orderRebateVO = new OrderRebateVO();
|
| | | List<GoodsRebateVO> voList = new ArrayList<>();
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | UserLevelEnum upperLevel = UserLevelUtil.getNextLevel(userLevel);
|
| | | BigDecimal upperTotalMoney = new BigDecimal(0);
|
| | | Map<Long, CommonOrderGoods> orderGoodsMap = new HashMap<>();
|
| | | int type = 0;
|
| | | String typeName = "";
|
| | | int hongBaoType = hoList.get(0).getHongBaoV2().getType();
|
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
|
| | | type = 1;
|
| | | typeName = "返利";
|
| | | } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
|
| | | type = 2;
|
| | | typeName = "奖金";
|
| | | } else if (HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType
|
| | | || HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
|
| | | || HongBaoV2.TYPE_ERJI == hongBaoType) {
|
| | | type = 3;
|
| | | typeName = "收益";
|
| | | }
|
| | |
|
| | | List<Long> goodsIdList = new ArrayList<>();
|
| | | if (hongBaoOrderList != null)
|
| | | for (HongBaoOrder hongBaoOrder : hongBaoOrderList) {
|
| | | if (hoList != null)
|
| | | for (HongBaoOrder hongBaoOrder : hoList) {
|
| | | if (hongBaoOrder.getCommonOrder() != null)
|
| | | goodsIdList.add(hongBaoOrder.getCommonOrder().getCommonOrderGoods().getId());
|
| | | }
|
| | |
|
| | | Map<Long, CommonOrderGoods> orderGoodsMap = new HashMap<>();
|
| | | List<CommonOrderGoods> goodsList = commonOrderGoodsService.listByByPrimaryKeys(goodsIdList);
|
| | | if (goodsList != null)
|
| | | for (CommonOrderGoods goods : goodsList)
|
| | | orderGoodsMap.put(goods.getId(), goods);
|
| | |
|
| | | if (userLevel == UserLevelEnum.daRen) {
|
| | | for (HongBaoOrder hongBaoOrder : hongBaoOrderList) {
|
| | | if (hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | hongBaoOrder.getHongBaoV2().setMoney(new BigDecimal(0));
|
| | | CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
|
| | | GoodsRebateVO goodsVO = new GoodsRebateVO();
|
| | | if (orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()) != null) {
|
| | | goodsVO.setTitle(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getTitle());
|
| | | goodsVO.setPicture(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getPicture());
|
| | | }
|
| | | BigDecimal payment = hongBaoOrder.getCommonOrder().getPayment();
|
| | | if (hongBaoOrder.getCommonOrder().getSettlement() != null)
|
| | | payment = hongBaoOrder.getCommonOrder().getSettlement();
|
| | | if (payment == null)
|
| | | payment = new BigDecimal(0);
|
| | | OrderRebateVO orderRebateVO = new OrderRebateVO();
|
| | | // 红包信息
|
| | | BigDecimal hongBao = hongBaoCountVO.getValidMoney();
|
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderNo);
|
| | | if (listWQ != null && listWQ.size() > 0) {
|
| | | BigDecimal weiQuanMoney = commonOrderService.getWeiQuanMoney(listWQ, sourceType, uid);
|
| | |
|
| | | goodsVO.setActualPay("¥" + payment);
|
| | |
|
| | | if (payment.compareTo(new BigDecimal(0)) <= 0) {
|
| | | goodsVO.setFanliRate("X0%");
|
| | | orderRebateVO.setWq(true);
|
| | | orderRebateVO.setWqMoney("¥" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | if (hongBao.compareTo(weiQuanMoney) > 0) {
|
| | | orderRebateVO.setWqDesc("部分售后退回");
|
| | | } else {
|
| | | goodsVO.setFanliRate("X"
|
| | | + MoneyBigDecimalUtil
|
| | | .div(hongBaoOrder.getHongBaoV2().getMoney().multiply(new BigDecimal(100)), payment)
|
| | | + "%");
|
| | | orderRebateVO.setWqDesc("售后退回");
|
| | | }
|
| | | goodsVO.setFanliExpect("¥" + hongBaoOrder.getHongBaoV2().getMoney());
|
| | | voList.add(goodsVO);
|
| | | totalMoney = totalMoney.add(hongBaoOrder.getHongBaoV2().getMoney());
|
| | | if (upperLevel != null) {
|
| | | upperTotalMoney = upperTotalMoney
|
| | | .add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel));
|
| | | }
|
| | | // 计算剩余红包
|
| | | hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
|
| | | }
|
| | | orderRebateVO.setListGoods(voList);
|
| | | } else {
|
| | | for (HongBaoOrder hongBaoOrder : hongBaoOrderList) {
|
| | | if (hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | hongBaoOrder.getHongBaoV2().setMoney(new BigDecimal(0));
|
| | | CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
|
| | | GoodsRebateVO goodsVO = new GoodsRebateVO();
|
| | | if (orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()) != null) {
|
| | | goodsVO.setTitle(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getTitle());
|
| | | goodsVO.setPicture(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getPicture());
|
| | | }
|
| | | BigDecimal payment = hongBaoOrder.getCommonOrder().getPayment();
|
| | | if (hongBaoOrder.getCommonOrder().getSettlement() != null)
|
| | | payment = hongBaoOrder.getCommonOrder().getSettlement();
|
| | | if (payment == null)
|
| | | payment = new BigDecimal(0);
|
| | | }
|
| | |
|
| | | goodsVO.setActualPay("¥" + payment);
|
| | | // 红包获得者
|
| | | HongBaoV2 hongBaoV2 = hoList.get(0).getHongBaoV2();
|
| | | UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(hongBaoV2.getUrank());
|
| | | if (userLevel == null)
|
| | | userLevel = UserLevelEnum.daRen;
|
| | | UserLevelEnum upperLevel = UserLevelEnum.superVIP;
|
| | |
|
| | | BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder);
|
| | | goodsVO.setCommision("¥" +commission);
|
| | | // 订单购买者
|
| | | 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) {
|
| | | if (hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | hongBaoOrder.getHongBaoV2().setMoney(new BigDecimal(0));
|
| | |
|
| | | GoodsRebateVO goodsVO = new GoodsRebateVO();
|
| | |
|
| | | // 标题、图片
|
| | | CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
|
| | | if (orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()) != null) {
|
| | | goodsVO.setTitle(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getTitle());
|
| | | goodsVO.setPicture(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getPicture());
|
| | | }
|
| | |
|
| | | // 实付款
|
| | | BigDecimal payment = hongBaoOrder.getCommonOrder().getPayment();
|
| | | // 若已结算 -显示结算金额
|
| | | 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, BigDecimal.ROUND_DOWN));
|
| | |
|
| | | BigDecimal fanli = hongBaoOrder.getHongBaoV2().getMoney();
|
| | | // 基础佣金
|
| | | BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder);
|
| | | 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, BigDecimal.ROUND_DOWN) + "");
|
| | | }
|
| | |
|
| | | BigDecimal vipFanli = hongBaoOrder.getHongBaoV2().getMoney();
|
| | | if (type == 3) { // 奖金
|
| | | goodsVO.setBonus("¥" + fanli.setScale(2, BigDecimal.ROUND_DOWN) + "");
|
| | | }
|
| | |
|
| | | goodsVO.setOriginSubsidy(darenFanli.subtract(commission) + "");
|
| | | goodsVO.setSubsidy("¥" +vipFanli.subtract(commission));
|
| | | voList.add(goodsVO);
|
| | | totalMoney = totalMoney.add(vipFanli);
|
| | | if (upperLevel != null) {
|
| | | upperTotalMoney = upperTotalMoney
|
| | | .add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel));
|
| | | voList.add(goodsVO);
|
| | |
|
| | | 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;
|
| | | }
|
| | | bossLevelList.add(new UserTeamLevel(null, directBoss));
|
| | | bossLevelList.add(new UserTeamLevel(null, UserLevelEnum.superVIP));
|
| | | upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService
|
| | | .computeSecondInviteMoney(commonOrder, buyer, bossLevelList));
|
| | | }
|
| | | }
|
| | | orderRebateVO.setListGoods(voList);
|
| | | }
|
| | | orderRebateVO.setTotalFanLi("¥" + totalMoney);
|
| | |
|
| | | 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) {
|
| | | Integer state = couponRecord.getState();
|
| | | 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) { // 已使用奖励券
|
| | | 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 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) {
|
| | | orderRebateVO.setCoupon(true);
|
| | | orderRebateVO.setCouponType(1);
|
| | | orderRebateVO.setCouponText("立即使用");
|
| | | orderRebateVO.setCouponDesc("返利再返");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户订单统计
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid 用户id type 类型:0全部、1淘宝 2京东、拼多多
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "teamOrderSearch")
|
| | | public void teamOrderSearch(String callback, AcceptData acceptData, Long uid, Integer page, String key,
|
| | | PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<TeamOrderVO> resultList = new ArrayList<>();
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", 0);
|
| | | data.put("list", resultList);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | if (page == null)
|
| | | page = 1;
|
| | |
|
| | | List<TeamOrderVO> list = teamDividentsSourceOrderUserMapService.searchByOrderNoOrSourceUid((page - 1) * 20,
|
| | | 20, uid, key);
|
| | | if (list == null) {
|
| | | list = new ArrayList<>();
|
| | | }
|
| | |
|
| | | if (list.size() > 0) {
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | TeamOrderVO teamVO = list.get(i);
|
| | | // 粉丝代数
|
| | | ThreeSaleDetail threeDetail = threeSaleDetailService.getByBossUidAndWorkerUid(uid, teamVO.getUid());
|
| | | if (threeDetail == null) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | continue;
|
| | | }
|
| | | teamVO.setTeamGrade(threeDetail.getLevel());
|
| | |
|
| | | // 粉丝基本信息
|
| | | UserInfo userInfo = userInfoService.getUserByIdWithMybatis(teamVO.getUid());
|
| | | if (userInfo == null) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | continue;
|
| | | }
|
| | | teamVO.setNickName(userInfo.getNickName());
|
| | | teamVO.setPortrait(userInfo.getPortrait());
|
| | |
|
| | | BigDecimal payment = BigDecimal.ZERO;
|
| | | List<CommonOrder> listOrder = commonOrderService.listBySourceTypeAndOrderId(teamVO.getSourceType(),
|
| | | teamVO.getOrderNo());
|
| | | if (listOrder != null && listOrder.size() > 0) {
|
| | | for (CommonOrder order : listOrder) {
|
| | | payment = payment.add(order.getPayment());
|
| | | teamVO.setSourceName(order.getChildSourceType());
|
| | | teamVO.setDownTime(TimeUtil.formatDate(order.getThirdCreateTime()));
|
| | |
|
| | | // 下单时等级
|
| | | UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(order.getUrank());
|
| | | if (userLevel == null)
|
| | | userLevel = UserLevelEnum.daRen;
|
| | | teamVO.setUserRank(UserLevelUtil.getShowLevel(userLevel).name());
|
| | |
|
| | | // 结算时间
|
| | | Date settleTime = order.getSettleTime();
|
| | | if (settleTime != null)
|
| | | teamVO.setSettleTime(TimeUtil.formatDate(settleTime));
|
| | |
|
| | | // 维权信息
|
| | | Integer orderState = order.getState();
|
| | | if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime())
|
| | | && CommonOrder.STATE_WQ == orderState) {
|
| | | if (order.getSourceType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | UserOrderWeiQuanRecord record = userOrderWeiQuanRecordService
|
| | | .selectByOrderInfoAndUid(uid, order.getTradeId(), order.getSourceType());
|
| | | if (record != null) {
|
| | | teamVO.setServiceTime(TimeUtil.formatDate(record.getCreateTime()));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | teamVO.setPayment(payment);
|
| | |
|
| | | // 订单时间信息
|
| | | String orderTime = "下单" + teamVO.getDownTime();
|
| | | if (!StringUtil.isNullOrEmpty(teamVO.getSettleTime())) {
|
| | | orderTime += "\n收货" + teamVO.getSettleTime();
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime())) {
|
| | | orderTime += "\n售后" + teamVO.getServiceTime();
|
| | | }
|
| | | teamVO.setOrderTime(orderTime);
|
| | | }
|
| | | }
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
|
| | | @Override
|
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | // 保留2位小数
|
| | | value = value.setScale(2, BigDecimal.ROUND_DOWN);
|
| | | return new JsonPrimitive(value.toString());
|
| | | }
|
| | | }
|
| | | });
|
| | | Gson gson = gsonBuilder.create();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", teamDividentsSourceOrderUserMapService.countSearchByOrderNoOrSourceUid(uid, key));
|
| | | data.put("list", gson.toJson(list));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|