From 215ab7f00492e8a90461f61154ce455b5bbe361f Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期二, 10 三月 2020 12:15:31 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div
---
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/OrderController.java | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 334 insertions(+), 5 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/OrderController.java b/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/OrderController.java
index 47c776f..8f9dacf 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/OrderController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/OrderController.java
@@ -2,18 +2,41 @@
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 javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.yeshi.utils.DateUtil;
import org.yeshi.utils.JsonUtil;
+import com.yeshi.fanli.dto.WXMPAcceptData;
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.config.SystemClientParamsService;
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.account.UserUtil;
+import com.yeshi.fanli.vo.order.CommonOrderVO;
+import com.yeshi.fanli.vo.order.OrderCountVO;
+import com.yeshi.fanli.vo.user.UserInfoExtraVO;
import com.yeshi.fanli.vo.user.UserSettingsVO;
import net.sf.json.JSONObject;
@@ -27,9 +50,27 @@
@Resource
private UserCustomSettingsService userCustomSettingsService;
-
+
@Resource
private HongBaoV2CountService hongBaoV2CountService;
+
+ @Resource
+ private CommonOrderService commonOrderService;
+
+ @Resource
+ private ConfigService configService;
+
+ @Resource
+ private UserInfoService userInfoService;
+
+ @Resource
+ private UserInfoExtraService userInfoExtraService;
+
+ @Resource
+ private RedisManager redisManager;
+
+ @Resource
+ private ESOrderService esOrderService;
/**
* 缁熻濂栭噾
@@ -41,7 +82,7 @@
* @param out
*/
@RequestMapping(value = "getBonusCount", method = RequestMethod.POST)
- public void getBonusCount(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
+ public void getBonusCount(WXMPAcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
if (uid == null) {
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
return;
@@ -54,6 +95,10 @@
} catch (Exception e) {
}
+ List<Integer> listSource = new ArrayList<>();
+ listSource.add(Constant.SOURCE_TYPE_JD);
+ listSource.add(Constant.SOURCE_TYPE_PDD);
+
// 楠岃瘉鏄惁鏄剧ず妯″潡
if (settings != null && settings.getNoBonusCount() != null) {
if (settings.getNoBonusCount() == 1) {
@@ -65,9 +110,9 @@
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, listSource);
+ BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, listSource);
+ BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, listSource);
JSONObject data = new JSONObject();
data.put("show", show);
@@ -76,4 +121,288 @@
data.put("inviteMoney", inviteMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
out.print(JsonUtil.loadTrueResult(data));
}
+
+ /**
+ * 璁㈠崟鍒楄〃
+ *
+ * @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
+ * 椤甸潰鏉ユ簮锛歸elfareCore-绂忓埄涓績銆乥onus -濂栭噾缁熻锛堟垜鐨勭晫闈級
+ * @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, String source, PrintWriter out) {
+ if (uid == null) {
+ out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+ return;
+ }
+
+ if (page == null || page < 1)
+ page = 1;
+
+ // 鎼滅储鍐呭銆佽鍗曞彿
+ if (!StringUtil.isNullOrEmpty(orderNo)) {
+ searchOrder(orderNo, page, uid, out);
+ return;
+ }
+
+ // 杞崲鐘舵��
+ 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;
+ }
+
+ // 璁㈠崟绫诲瀷
+ 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;
+
+ // 绛涢�夋椂闂�
+ 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();
+ }
+ }
+
+ if (endTime != null && endTime.trim().length() > 0) {
+ endTime += " 23:59:59";
+ }
+
+ List<Integer> listSource = new ArrayList<>();
+ if (goodsType != null) {
+ listSource.add(goodsType);
+ } else {
+ listSource.add(Constant.SOURCE_TYPE_JD);
+ listSource.add(Constant.SOURCE_TYPE_PDD);
+ }
+
+ try {
+ // 绛涢�夌粨鏋滈《閮ㄧ粺璁�
+ String validMoney = "0.00";
+ String invalidMoney = "0.00";
+ if (page == 1) {
+ BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, 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);
+ if (postSaleMoney != null)
+ invalidMoney = postSaleMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
+
+ 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, listSource);
+ // 缁熻鎬绘暟
+ long count = commonOrderService.countGroupOrderNoByUid(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.get(ConfigKeyEnum.orderFindNotifyUrl.getKey());
+ }
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", count);
+ data.put("list", JsonUtil.getApiCommonGson().toJson(list));
+ data.put("helpUrl", configService.get(ConfigKeyEnum.orderListHelp.getKey()));
+ 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) {
+ if (Constant.IS_TEST) {
+ e.printStackTrace(out);
+ } else
+ out.print(JsonUtil.loadFalseResult(1, "鏌ヨ澶辫触"));
+ LogHelper.errorDetailInfo(e);
+ }
+ }
+
+ /**
+ * 鎼滅储璁㈠崟
+ *
+ * @param key
+ * @param out
+ */
+ private void searchOrder(String key, Integer page, Long uid, PrintWriter out) {
+ try {
+ long count = 0;
+ List<CommonOrderVO> list = null;
+ List<Integer> listSource = new ArrayList<>();
+ listSource.add(Constant.SOURCE_TYPE_JD);
+ listSource.add(Constant.SOURCE_TYPE_PDD);
+ List<ESOrder> listES = esOrderService.query(key, uid.toString(), listSource);
+
+ if (listES.size() != 0) {
+ list = commonOrderService.searchOrderByUid(page, Constant.PAGE_SIZE, uid, listES);
+ count = commonOrderService.countSearchOrderByUid(uid, listES);
+ }
+
+ if (list == null) {
+ list = new ArrayList<>();
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", count);
+ data.put("list", JsonUtil.getApiCommonGson().toJson(list));
+ out.print(JsonUtil.loadTrueResult(data));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult(1, "鏌ヨ澶辫触"));
+ e.printStackTrace();
+ LogHelper.errorDetailInfo(e);
+ }
+ }
+
+ /**
+ * 鐢ㄦ埛璁㈠崟缁熻
+ *
+ * @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;
+ }
+
+ try {
+ UserInfo user = userInfoService.selectByPKey(uid);
+ if (user == 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);
+
+ List<Integer> listSource = new ArrayList<>();
+ if (type == null || type == 0) {
+ listSource.add(Constant.SOURCE_TYPE_JD);
+ listSource.add(Constant.SOURCE_TYPE_PDD);
+
+ OrderCountVO total = commonOrderService.getOrderCount(uid, null, listSource);
+ 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);
+ listSource.add(type);
+ }
+
+ // 浠婂ぉ
+ 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());
+
+ 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();
+ }
+ }
+
}
--
Gitblit v1.8.0