From 512f368d7d8e71ee72a8f71dd7d2146f4c64f774 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 02 六月 2021 18:54:58 +0800 Subject: [PATCH] 特价相关bug修改 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java | 1507 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 758 insertions(+), 749 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java index 0f409a7..1100abc 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java @@ -12,6 +12,7 @@ import javax.annotation.Resource; +import com.yeshi.fanli.entity.SystemEnum; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -88,848 +89,856 @@ @RequestMapping("api/v2/user/order") public class UserOrderControllerV2 { - @Resource - private ConfigService configService; + @Resource + private ConfigService configService; - @Resource - private UserInfoService userInfoService; + @Resource + private UserInfoService userInfoService; - @Resource - private UserInfoExtraService userInfoExtraService; + @Resource + private UserInfoExtraService userInfoExtraService; - @Resource - private CommonOrderService commonOrderService; + @Resource + private CommonOrderService commonOrderService; - @Resource - private HongBaoV2CountService hongBaoV2CountService; + @Resource + private HongBaoV2CountService hongBaoV2CountService; - @Resource - private RedisManager redisManager; + @Resource + private RedisManager redisManager; - @Resource - private UserCustomSettingsService userCustomSettingsService; + @Resource + private UserCustomSettingsService userCustomSettingsService; - @Resource - private ESOrderService esOrderService; + @Resource + private ESOrderService esOrderService; - @Resource - private HongBaoV2Service hongBaoV2Service; + @Resource + private HongBaoV2Service hongBaoV2Service; - @Resource - private HongBaoOrderService hongBaoOrderService; + @Resource + private HongBaoOrderService hongBaoOrderService; - @Resource - private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; - @Resource - private CommonOrderGoodsService commonOrderGoodsService; + @Resource + private CommonOrderGoodsService commonOrderGoodsService; - @Resource - private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService; + @Resource + private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService; - @Resource - private JumpDetailV2Service jumpDetailV2Service; + @Resource + private JumpDetailV2Service jumpDetailV2Service; - @Resource - private UserSystemCouponRecordService userSystemCouponRecordService; + @Resource + private UserSystemCouponRecordService userSystemCouponRecordService; - @Resource - private UserInviteService userInviteService; + @Resource + private UserInviteService userInviteService; - @Resource - private OrderHongBaoMapService orderHongBaoMapService; + @Resource + private OrderHongBaoMapService orderHongBaoMapService; - @Resource - private PreviewInfoService previewInfoService; + @Resource + private PreviewInfoService previewInfoService; - @Resource - private TeamDividentsSourceOrderUserMapService teamDividentsSourceOrderUserMapService; + @Resource + private TeamDividentsSourceOrderUserMapService teamDividentsSourceOrderUserMapService; - @Resource - private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService; + @Resource + private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService; - @Resource - private ThreeSaleDetailService threeSaleDetailService; + @Resource + private ThreeSaleDetailService threeSaleDetailService; - /** - * 澶勭悊鎼滅储鏉′欢 - * - * @param filter - */ - private void handleSearchFilter(SearchFilterOrder filter) { - Integer goodsType = filter.getGoodsType(); - if (goodsType != null && goodsType == 0) { - goodsType = null; - filter.setGoodsType(goodsType); - } + /** + * 澶勭悊鎼滅储鏉′欢 + * + * @param filter + */ + private void handleSearchFilter(SearchFilterOrder filter) { + Integer goodsType = filter.getGoodsType(); + if (goodsType != null && goodsType == 0) { + goodsType = null; + filter.setGoodsType(goodsType); + } - List<Integer> listSource = new ArrayList<>(); - if (goodsType != null) { - listSource.add(goodsType); - } - filter.setListSource(listSource); + 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); + // 璁㈠崟绫诲瀷 + 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; // 鎵�鏈� - } else if (state == 4) { - state = null; - orderState = 4; // 宸叉敹璐� - } else if (state == 5) { - state = null; - orderState = 2; // 宸茬淮鏉� - } - } - if (state != null && orderState != null && (orderState == 2 || orderState == 3)) { - state = null; - } - filter.setState(state); - filter.setOrderState(orderState); + // 杞崲鐘舵�� + Integer orderState = filter.getOrderState(); + Integer state = filter.getState(); + if (state != null) { + if (state == 0) { + state = null; // 鎵�鏈� + } else if (state == 4) { + state = null; + orderState = 4; // 宸叉敹璐� + } else if (state == 5) { + state = null; + orderState = 2; // 宸茬淮鏉� + } + } + if (state != null && orderState != null && (orderState == 2 || orderState == 3)) { + state = 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"); + // 绛涢�夋椂闂� + 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"); - switch (slotTime) { - case 1: // 鏈�杩戜笁澶� - endTime = sd.format(new Date()); - startTime = DateUtil.reduceDay(2, endTime); - break; - case 2: // 鏈�杩戜竷澶� - endTime = sd.format(new Date()); - startTime = DateUtil.reduceDay(6, endTime); - break; - case 3: // 鏈�杩�15澶� 锛堝崐鏈堬級 - endTime = sd.format(new Date()); - startTime = DateUtil.reduceDay(14, endTime); - break; - case 4: // 鏈�杩戜笁鍗佸ぉ 锛堟湰鏈堬級 - dateType = 10; - break; - case 5: // 鏈�杩戜節鍗佸ぉ锛堣繎涓夋湀锛� - dateType = 11; - break; - case 6: // 鏈�杩戜竴鐧惧叓鍗佸ぉ锛堣繎鍗婂勾锛� - dateType = 12; - break; - default: - break; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - filter.setDateType(dateType); - filter.setStartTime(startTime); + switch (slotTime) { + case 1: // 鏈�杩戜笁澶� + endTime = sd.format(new Date()); + startTime = DateUtil.reduceDay(2, endTime); + break; + case 2: // 鏈�杩戜竷澶� + endTime = sd.format(new Date()); + startTime = DateUtil.reduceDay(6, endTime); + break; + case 3: // 鏈�杩�15澶� 锛堝崐鏈堬級 + endTime = sd.format(new Date()); + startTime = DateUtil.reduceDay(14, endTime); + break; + case 4: // 鏈�杩戜笁鍗佸ぉ 锛堟湰鏈堬級 + dateType = 10; + break; + case 5: // 鏈�杩戜節鍗佸ぉ锛堣繎涓夋湀锛� + dateType = 11; + break; + case 6: // 鏈�杩戜竴鐧惧叓鍗佸ぉ锛堣繎鍗婂勾锛� + dateType = 12; + break; + default: + break; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + filter.setDateType(dateType); + filter.setStartTime(startTime); - if (endTime != null && endTime.trim().length() > 0) { - endTime += " 23:59:59"; - } - filter.setEndTime(endTime); + if (endTime != null && endTime.trim().length() > 0) { + endTime += " 23:59:59"; + } + filter.setEndTime(endTime); - } + } - /** - * 璁㈠崟鍒楄〃 - * @param acceptData - * @param page - * @param filter - * @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; - } + /** + * 璁㈠崟鍒楄〃 + * + * @param acceptData + * @param page + * @param filter + * @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; + 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(); + 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; - } + 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 validMoney = "0.00"; - String invalidMoney = "0.00"; - if (page == 1) { - 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(); + // 鎼滅储鍐呭銆佽鍗曞彿 + 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; + } - 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(); + // 绛涢�夌粨鏋滈《閮ㄧ粺璁� + String validMoney = "0.00"; + String invalidMoney = "0.00"; + if (page == 1) { + 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(); - if (orderType != null && dateType != null && dateType == 4) { - if (orderType == 1) { - dateType = 6; // 杩斿埄璁㈠崟鏈夋晥 - } else { - dateType = 5; // 鏂扮増鏌ヨ鏈湀鍒拌处 - } - } - } + 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(); - 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); + if (orderType != null && dateType != null && dateType == 4) { + if (orderType == 1) { + dateType = 6; // 杩斿埄璁㈠崟鏈夋晥 + } else { + dateType = 5; // 鏂扮増鏌ヨ鏈湀鍒拌处 + } + } + } - 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); - } + long count = 0L; + List<CommonOrderVO> list = null; + if (acceptData.getSystem() == SystemEnum.yhqjx) { + 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 { + if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { + list = commonOrderService.getOrderList(acceptData, page, uid, state, orderType, orderState, orderNo, + startTime, endTime, dateType, listSource); - // 鍒ゆ柇鏄惁闇�瑕佹樉绀鸿鍗曟壘鍥炴彁绀� 8绉掑唴璇锋眰3娆¤Е鍙� - String orderFindUrl = null; - if (state == null && page == 1) { - if (redisManager.frequencyLimit("orderlist-" + acceptData.getDevice(), 8, 4) || count == 0L) { - orderFindUrl = configService.getValue(ConfigKeyEnum.orderFindNotifyUrl.getKey(),acceptData.getSystem()); - } - } + 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); + } + } - JSONObject data = new JSONObject(); - data.put("count", count); - data.put("result_list", JsonUtil.getApiCommonGson().toJson(list)); - data.put("helpUrl", configService.getValue(ConfigKeyEnum.orderListHelp.getKey(),acceptData.getSystem())); - data.put("validMoney", "楼 " + validMoney); - data.put("invalidMoney", "楼 " + invalidMoney); - data.put("findOrderHelpUrl", orderFindUrl); - out.print(JsonUtil.loadTrueResult(data)); - } catch (CommonOrderException e) { - out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult(1, "鏌ヨ澶辫触")); - LogHelper.errorDetailInfo(e); - } - } + // 鍒ゆ柇鏄惁闇�瑕佹樉绀鸿鍗曟壘鍥炴彁绀� 8绉掑唴璇锋眰3娆¤Е鍙� + String orderFindUrl = null; + if (state == null && page == 1) { + if (redisManager.frequencyLimit("orderlist-" + acceptData.getDevice(), 8, 4) || count == 0L) { + orderFindUrl = configService.getValue(ConfigKeyEnum.orderFindNotifyUrl.getKey(), acceptData.getSystem()); + } + } - /** - * 鎼滅储璁㈠崟 - * - * @param key - * @param 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("-", ""))) { - 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); - } + JSONObject data = new JSONObject(); + data.put("count", count); + data.put("result_list", JsonUtil.getApiCommonGson().toJson(list)); + data.put("helpUrl", configService.getValue(ConfigKeyEnum.orderListHelp.getKey(), acceptData.getSystem())); + data.put("validMoney", "楼 " + validMoney); + data.put("invalidMoney", "楼 " + invalidMoney); + data.put("findOrderHelpUrl", orderFindUrl); + out.print(JsonUtil.loadTrueResult(data)); + } catch (CommonOrderException e) { + out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult(1, "鏌ヨ澶辫触")); + LogHelper.errorDetailInfo(e); + } + } - if (list == null || list.size() == 0) { - List<ESOrder> listES = esOrderService.query(key, uid.toString(), null); - if (listES.size() != 0) { - list = commonOrderService.searchOrderByUid(acceptData, page, Constant.PAGE_SIZE, uid, listES); - count = commonOrderService.countSearchOrderByUid(uid, listES); - } - } else { - count = list.size(); - } + /** + * 鎼滅储璁㈠崟 + * + * @param key + * @param 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("-", ""))) { + 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 = new ArrayList<>(); - } + if (list == null || list.size() == 0) { + List<ESOrder> listES = esOrderService.query(key, uid.toString(), null); + if (listES.size() != 0) { + list = commonOrderService.searchOrderByUid(acceptData, page, Constant.PAGE_SIZE, uid, listES); + count = commonOrderService.countSearchOrderByUid(uid, listES); + } + } else { + count = list.size(); + } - JSONObject data = new JSONObject(); - data.put("count", count); - data.put("result_list", JsonUtil.getApiCommonGson().toJson(list)); - out.print(JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult(1, "鏌ヨ澶辫触")); - e.printStackTrace(); - LogHelper.errorDetailInfo(e); - } - } + if (list == null) { + list = new ArrayList<>(); + } - /** - * 鐢ㄦ埛璁㈠崟缁熻 - * - * @param acceptData - * @param uid 鐢ㄦ埛id type 绫诲瀷锛�0鍏ㄩ儴銆�1娣樺疂 2浜笢銆佹嫾澶氬 - * @param out - */ - @RequestMapping(value = "getOrderCount", method = RequestMethod.POST) - public void getOrderCount(AcceptData acceptData, Long uid, Integer type, PrintWriter out) { - if (uid == null) { - out.print(JsonUtil.loadFalseResult(1, "璇锋眰鍙傛暟涓嶆纭�")); - return; - } + JSONObject data = new JSONObject(); + data.put("count", count); + data.put("result_list", JsonUtil.getApiCommonGson().toJson(list)); + out.print(JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult(1, "鏌ヨ澶辫触")); + e.printStackTrace(); + LogHelper.errorDetailInfo(e); + } + } - try { - UserInfo user = userInfoService.selectByPKey(uid); - if (user == null) { - out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛涓嶅瓨鍦�")); - return; - } + /** + * 鐢ㄦ埛璁㈠崟缁熻 + * + * @param acceptData + * @param uid 鐢ㄦ埛id type 绫诲瀷锛�0鍏ㄩ儴銆�1娣樺疂 2浜笢銆佹嫾澶氬 + * @param out + */ + @RequestMapping(value = "getOrderCount", method = RequestMethod.POST) + public void getOrderCount(AcceptData acceptData, Long uid, Integer type, PrintWriter out) { + if (uid == null) { + out.print(JsonUtil.loadFalseResult(1, "璇锋眰鍙傛暟涓嶆纭�")); + return; + } - UserInfo userInfo = UserUtil.filterForClientUser(user); - UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId()); - if (userInfoExtra != null && userInfoExtra.getUserRank() != null) { - userInfo.setRankIcon(userInfoExtra.getUserRank().getIcon()); - userInfo.setRankNamePicture(userInfoExtra.getUserRank().getPicture()); - } - JSONObject data = new JSONObject(); - data.put("userInfo", userInfo); + try { + UserInfo user = userInfoService.selectByPKey(uid); + if (user == null) { + out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛涓嶅瓨鍦�")); + return; + } - List<Integer> listSource = new ArrayList<>(); - if (type == null || type == 0) { - OrderCountVO total = commonOrderService.getOrderCount(uid, null, null); - data.put("total", total.getSelf() + total.getShared() + total.getInvite()); - data.put("self", total.getSelf()); - data.put("shared", total.getShared()); - data.put("invite", total.getInvite()); - } else { - data.put("total", 0); - data.put("self", 0); - data.put("shared", 0); - data.put("invite", 0); + UserInfo userInfo = UserUtil.filterForClientUser(user); + UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId()); + if (userInfoExtra != null && userInfoExtra.getUserRank() != null) { + userInfo.setRankIcon(userInfoExtra.getUserRank().getIcon()); + userInfo.setRankNamePicture(userInfoExtra.getUserRank().getPicture()); + } + JSONObject data = new JSONObject(); + data.put("userInfo", userInfo); - listSource.add(type); - } + List<Integer> listSource = new ArrayList<>(); + if (type == null || type == 0) { + OrderCountVO total = commonOrderService.getOrderCount(uid, null, null); + data.put("total", total.getSelf() + total.getShared() + total.getInvite()); + data.put("self", total.getSelf()); + data.put("shared", total.getShared()); + data.put("invite", total.getInvite()); + } else { + data.put("total", 0); + data.put("self", 0); + data.put("shared", 0); + data.put("invite", 0); - // 浠婂ぉ - OrderCountVO today = commonOrderService.getOrderCount(uid, 1, listSource); - today.setTotal(today.getSelf() + today.getShared() + today.getInvite()); - // 鏄ㄥぉ - OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, listSource); - yesterday.setTotal(yesterday.getSelf() + yesterday.getShared() + yesterday.getInvite()); - // 鏈湀 - OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, listSource); - thisMonth.setTotal(thisMonth.getSelf() + thisMonth.getShared() + thisMonth.getInvite()); - // 涓婃湀 - OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, listSource); - lastMonth.setTotal(lastMonth.getSelf() + lastMonth.getShared() + lastMonth.getInvite()); + listSource.add(type); + } - data.put("today", today); - data.put("yesterday", yesterday); - data.put("thisMonth", thisMonth); - data.put("lastMonth", lastMonth); - out.print(JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult(1, "鑾峰彇淇℃伅澶辫触")); - e.printStackTrace(); - } - } + // 浠婂ぉ + OrderCountVO today = commonOrderService.getOrderCount(uid, 1, listSource); + today.setTotal(today.getSelf() + today.getShared() + today.getInvite()); + // 鏄ㄥぉ + OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, listSource); + yesterday.setTotal(yesterday.getSelf() + yesterday.getShared() + yesterday.getInvite()); + // 鏈湀 + OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, listSource); + thisMonth.setTotal(thisMonth.getSelf() + thisMonth.getShared() + thisMonth.getInvite()); + // 涓婃湀 + OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, listSource); + lastMonth.setTotal(lastMonth.getSelf() + lastMonth.getShared() + lastMonth.getInvite()); - /** - * 缁熻濂栭噾 - * - * @param acceptData - * @param uid - * @param dateType 1-浠婃棩 2-鏄ㄥぉ 3-鏈湀 4-涓婁釜鏈� - * @param out - */ - @RequestMapping(value = "getBonusCount", method = RequestMethod.POST) - public void getBonusCount(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) { - if (uid == null) { - out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); - return; - } + data.put("today", today); + data.put("yesterday", yesterday); + data.put("thisMonth", thisMonth); + data.put("lastMonth", lastMonth); + out.print(JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult(1, "鑾峰彇淇℃伅澶辫触")); + e.printStackTrace(); + } + } - boolean show = false; - UserSettingsVO settings = null; - try { - settings = userCustomSettingsService.getMySettings(uid); - } catch (Exception e) { - } + /** + * 缁熻濂栭噾 + * + * @param acceptData + * @param uid + * @param dateType 1-浠婃棩 2-鏄ㄥぉ 3-鏈湀 4-涓婁釜鏈� + * @param out + */ + @RequestMapping(value = "getBonusCount", method = RequestMethod.POST) + public void getBonusCount(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) { + if (uid == null) { + out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); + return; + } - // 楠岃瘉鏄惁鏄剧ず妯″潡 - if (settings != null && settings.getNoBonusCount() != null) { - if (settings.getNoBonusCount() == 1) { - show = false; - } else if (settings.getNoBonusCount() == 0) { - show = true; - } - } else { - show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0; - } + boolean show = false; + UserSettingsVO settings = null; + try { + settings = userCustomSettingsService.getMySettings(uid); + } catch (Exception e) { + } - 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 (settings != null && settings.getNoBonusCount() != null) { + if (settings.getNoBonusCount() == 1) { + show = false; + } else if (settings.getNoBonusCount() == 0) { + show = true; + } + } else { + show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0; + } + + 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); - } + 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", teamMoney.setScale(2, BigDecimal.ROUND_DOWN).toString()); - out.print(JsonUtil.loadTrueResult(data)); - } + 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", teamMoney.setScale(2, BigDecimal.ROUND_DOWN).toString()); + out.print(JsonUtil.loadTrueResult(data)); + } - /** - * 杩斿埄璇存槑 - * - * @param acceptData - * @param uid - * @param orderNo - * @param sourceType - * @param out - */ - @RequestMapping(value = "getReBateInfo") - public void getReBateInfo(String callback, AcceptData acceptData, Long uid, String orderNo, Integer sourceType, - PrintWriter out) { - if (uid == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); - return; - } + /** + * 杩斿埄璇存槑 + * + * @param acceptData + * @param uid + * @param orderNo + * @param sourceType + * @param out + */ + @RequestMapping(value = "getReBateInfo") + public void getReBateInfo(String callback, AcceptData acceptData, Long uid, String orderNo, Integer sourceType, + PrintWriter out) { + if (uid == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } - UserInfo user = userInfoService.selectByPKey(uid); - if (user == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); - return; - } + UserInfo user = userInfoService.selectByPKey(uid); + if (user == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); + return; + } - // 绾㈠寘淇℃伅 - List<HongBaoOrder> hoList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType, - uid); - HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hoList); + // 绾㈠寘淇℃伅 + List<HongBaoOrder> hoList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType, + uid); + HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hoList); - 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 = "宸插け鏁�"; - } + 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 = "宸插け鏁�"; + } - 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 = "鏀剁泭"; - } + 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 (hoList != null) - for (HongBaoOrder hongBaoOrder : hoList) { - if (hongBaoOrder.getCommonOrder() != null) - goodsIdList.add(hongBaoOrder.getCommonOrder().getCommonOrderGoods().getId()); - } + List<Long> goodsIdList = new ArrayList<>(); + 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); + Map<Long, CommonOrderGoods> orderGoodsMap = new HashMap<>(); + List<CommonOrderGoods> goodsList = commonOrderGoodsService.listByByPrimaryKeys(goodsIdList); + if (goodsList != null) + for (CommonOrderGoods goods : goodsList) + orderGoodsMap.put(goods.getId(), goods); - 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); + 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); - orderRebateVO.setWq(true); - orderRebateVO.setWqMoney("楼" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN)); - if (hongBao.compareTo(weiQuanMoney) > 0) { - orderRebateVO.setWqDesc("閮ㄥ垎鍞悗閫�鍥�"); - } else { - orderRebateVO.setWqDesc("鍞悗閫�鍥�"); - } - // 璁$畻鍓╀綑绾㈠寘 - hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney); - } - } + orderRebateVO.setWq(true); + orderRebateVO.setWqMoney("楼" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN)); + if (hongBao.compareTo(weiQuanMoney) > 0) { + orderRebateVO.setWqDesc("閮ㄥ垎鍞悗閫�鍥�"); + } else { + orderRebateVO.setWqDesc("鍞悗閫�鍥�"); + } + // 璁$畻鍓╀綑绾㈠寘 + hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney); + } + } - // 绾㈠寘鑾峰緱鑰� - HongBaoV2 hongBaoV2 = hoList.get(0).getHongBaoV2(); - UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(hongBaoV2.getUrank()); - if (userLevel == null) - userLevel = UserLevelEnum.daRen; - UserLevelEnum upperLevel = UserLevelEnum.superVIP; + // 绾㈠寘鑾峰緱鑰� + 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; - } + // 璁㈠崟璐拱鑰� + 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)); + 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(); + 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()); - } + // 鏍囬銆佸浘鐗� + 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 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(); - // 鍩虹浣i噾 - BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder); - goodsVO.setCommision("楼" + commission.setScale(2, BigDecimal.ROUND_DOWN)); + BigDecimal fanli = hongBaoOrder.getHongBaoV2().getMoney(); + // 鍩虹浣i噾 + BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder); + goodsVO.setCommision("楼" + commission.setScale(2, BigDecimal.ROUND_DOWN)); - // 骞冲彴琛ヨ创 = 杩斿埄 - 鍩虹浣i噾 - 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) + ""); - } + // 骞冲彴琛ヨ创 = 杩斿埄 - 鍩虹浣i噾 + 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) + ""); + } - if (type == 3) { // 濂栭噾 - goodsVO.setBonus("楼" + fanli.setScale(2, BigDecimal.ROUND_DOWN) + ""); - } + if (type == 3) { // 濂栭噾 + goodsVO.setBonus("楼" + fanli.setScale(2, BigDecimal.ROUND_DOWN) + ""); + } - voList.add(goodsVO); + 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)); - } - } - } + 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.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()); - } + 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.setJumpLink(upperLevel.getDetailLink()); - } + // 瓒呯骇浼氬憳杩斿埄 + if (upperLevel != null) { + orderRebateVO.setUpperFanLi("楼" + upperTotalMoney); + 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; - } - } - } + 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, - sourceType, null); - if (couponRecord == null) { - orderRebateVO.setCoupon(true); - orderRebateVO.setCouponType(1); - orderRebateVO.setCouponText("绔嬪嵆浣跨敤"); - orderRebateVO.setCouponDesc("杩斿埄鍐嶈繑"); - } - } - } - } + 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, + sourceType, null); + if (couponRecord == null) { + orderRebateVO.setCoupon(true); + orderRebateVO.setCouponType(1); + orderRebateVO.setCouponText("绔嬪嵆浣跨敤"); + orderRebateVO.setCouponDesc("杩斿埄鍐嶈繑"); + } + } + } + } - JSONObject data = new JSONObject(); - data.put("result", orderRebateVO); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } + JSONObject data = new JSONObject(); + data.put("result", orderRebateVO); + 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; - } + /** + * 鐢ㄦ埛璁㈠崟缁熻 + * + * @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; - } + 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; + try { + if (page == null) + page = 1; - List<TeamOrderVO> list = teamDividentsSourceOrderUserMapService.searchByOrderNoOrSourceUid((page - 1) * 20, - 20, uid, key); - if (list == null) { - list = new ArrayList<>(); - } + 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); - // 绮変笣浠f暟 - ThreeSaleDetail threeDetail = threeSaleDetailService.getByBossUidAndWorkerUid(uid, teamVO.getUid()); - if (threeDetail == null) { - list.remove(i); - i--; - continue; - } - teamVO.setTeamGrade(threeDetail.getLevel()); + if (list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + TeamOrderVO teamVO = list.get(i); + // 绮変笣浠f暟 + 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()); + // 绮変笣鍩烘湰淇℃伅 + 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())); + 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()); + // 涓嬪崟鏃剁瓑绾� + 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)); + // 缁撶畻鏃堕棿 + 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())); - } - } - } + // 缁存潈淇℃伅 + 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); + } + } + 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); - } - } + // 璁㈠崟鏃堕棿淇℃伅 + 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; - } - } + 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; + } + } } -- Gitblit v1.8.0