| | |
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.order.ESOrder;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.ESOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | | import com.yeshi.fanli.vo.order.OrderCountVO;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsService userCustomSettingsService;
|
| | | |
| | | @Resource
|
| | | private ESOrderService esOrderService;
|
| | |
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 订单列表
|
| | | *
|
| | |
| | | * 时间段:1-最近三天 2-最近七天 3最近半月 4本月 5近三月 6近半年
|
| | | * @param dateType
|
| | | * 1-今日 2-昨天 3-本月 4-上个月 |
|
| | | * @param needCount
|
| | | * @param source |
| | | * 页面来源:welfareCore-福利中心、bonus -奖金统计(我的界面)
|
| | | * @param out
|
| | | */
|
| | | @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, PrintWriter out) {
|
| | | Integer dateType, Integer goodsType, String source, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | orderType = Integer.parseInt(type);
|
| | | }
|
| | |
|
| | | if (goodsType != null && goodsType == 0)
|
| | | goodsType = null;
|
| | | |
| | | // 筛选时间
|
| | | if (slotTime != null) {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
|
| | | try {
|
| | | endTime = sd.format(new Date());
|
| | | startTime = convertDate(slotTime, endTime);
|
| | | 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();
|
| | | }
|
| | | }
|
| | | |
| | | if (endTime != null && endTime.trim().length() > 0) {
|
| | | endTime += " 23:59:59";
|
| | | }
|
| | |
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (goodsType != null) {
|
| | | listSource.add(goodsType);
|
| | | } |
| | | |
| | | try {
|
| | | // 筛选结果顶部统计
|
| | | String validMoney = "0.00";
|
| | | String invalidMoney = "0.00";
|
| | | if (page == 1) {
|
| | | BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 1,
|
| | | orderNo, goodsType, startTime, endTime);
|
| | | 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, goodsType, startTime, endTime);
|
| | | orderNo, state, startTime, endTime, listSource);
|
| | | if (postSaleMoney != null)
|
| | | invalidMoney = postSaleMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
|
| | |
|
| | | if (dateType != null && dateType == 4)
|
| | | dateType = 5; // 新版查询本月到账
|
| | | if (orderType != null && dateType != null && dateType == 4) {
|
| | | if (orderType == 1) {
|
| | | dateType = 6; // 返利订单有效
|
| | | } else {
|
| | | dateType = 5; // 新版查询本月到账
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 查询列表
|
| | | List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType, orderState,
|
| | | orderNo, startTime, endTime, dateType, goodsType);
|
| | | orderNo, startTime, endTime, dateType, listSource);
|
| | | // 统计总数
|
| | | long count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo, startTime,
|
| | | endTime, dateType, goodsType);
|
| | | 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.get("order_find_notify_url");
|
| | | orderFindUrl = configService.get(ConfigKeyEnum.orderFindNotifyUrl.getKey());
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("result_list", JsonUtil.getApiCommonGson().toJson(list));
|
| | | data.put("helpUrl", configService.get("order_list_help"));
|
| | | data.put("helpUrl", configService.get(ConfigKeyEnum.orderListHelp.getKey()));
|
| | | data.put("validMoney", "¥ " + validMoney);
|
| | | data.put("invalidMoney", "¥ " + invalidMoney);
|
| | | data.put("findOrderHelpUrl", orderFindUrl);
|
| | |
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 时间转换
|
| | | * |
| | | * @param slotTime
|
| | | * @param startTime
|
| | | * @return
|
| | | * @throws Exception
|
| | | * 搜索订单
|
| | | * @param key
|
| | | * @param out
|
| | | */
|
| | | private String convertDate(Integer slotTime, String endTime) throws Exception {
|
| | | String startTime = null;
|
| | |
|
| | | switch (slotTime) {
|
| | | case 1: // 最近三天
|
| | | startTime = DateUtil.reduceDay(2, endTime);
|
| | | break;
|
| | | case 2: // 最近七天
|
| | | startTime = DateUtil.reduceDay(6, endTime);
|
| | | break;
|
| | | case 3: // 最近15天 (半月)
|
| | | startTime = DateUtil.reduceDay(14, endTime);
|
| | | break;
|
| | | case 4: // 最近三十天 (本月)
|
| | | startTime = DateUtil.reduceDay(29, endTime);
|
| | | break;
|
| | | case 5: // 最近九十天(近三月)
|
| | | startTime = DateUtil.reduceDay(3 * 30 - 1, endTime);
|
| | | break;
|
| | | case 6: // 最近一百八十天(近半年)
|
| | | startTime = DateUtil.reduceDay(6 * 30 - 1, endTime);
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | private void searchOrder(AcceptData acceptData, String key, Integer page, Long uid, 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 (list == null || list.size() == 0) {
|
| | | List<ESOrder> listES = esOrderService.query(key, uid.toString(), null);
|
| | | if (listES.size() != 0) {
|
| | | list = commonOrderService.searchOrderByUid(page, Constant.PAGE_SIZE, uid, listES);
|
| | | count = commonOrderService.countSearchOrderByUid(uid, listES);
|
| | | }
|
| | | } else {
|
| | | count = list.size();
|
| | | }
|
| | | |
| | | if (list == null) {
|
| | | list = new ArrayList<>();
|
| | | }
|
| | | |
| | | 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);
|
| | | }
|
| | | return startTime;
|
| | | }
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | | * 用户订单统计
|
| | |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * 用户id
|
| | | * type 类型:0全部、1淘宝 2京东、拼多多
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOrderCount", method = RequestMethod.POST)
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("userInfo", userInfo);
|
| | |
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (type == null || type == 0) {
|
| | | OrderCountVO total = commonOrderService.getOrderCount(uid, null, type);
|
| | | 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("self", 0);
|
| | | data.put("shared", 0);
|
| | | data.put("invite", 0);
|
| | | |
| | | listSource.add(type);
|
| | | }
|
| | |
|
| | | // 今天
|
| | | OrderCountVO today = commonOrderService.getOrderCount(uid, 1, type);
|
| | | OrderCountVO today = commonOrderService.getOrderCount(uid, 1, listSource);
|
| | | today.setTotal(today.getSelf() + today.getShared() + today.getInvite());
|
| | | // 昨天
|
| | | OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, type);
|
| | | OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, listSource);
|
| | | yesterday.setTotal(yesterday.getSelf() + yesterday.getShared() + yesterday.getInvite());
|
| | | // 本月
|
| | | OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, type);
|
| | | OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, listSource);
|
| | | thisMonth.setTotal(thisMonth.getSelf() + thisMonth.getShared() + thisMonth.getInvite());
|
| | | // 上月
|
| | | OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, type);
|
| | | OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, listSource);
|
| | | lastMonth.setTotal(lastMonth.getSelf() + lastMonth.getShared() + lastMonth.getInvite());
|
| | |
|
| | | data.put("today", today);
|
| | |
| | | show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0;
|
| | | }
|
| | |
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3);
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1, null);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, null);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, null);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("show", show);
|