From 7abe4e6827998c56fafe53679addc5d78c6e45c0 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 18 十月 2019 11:35:00 +0800
Subject: [PATCH] 同店铺订单,同商品订单高危标识添加

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java |  189 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 165 insertions(+), 24 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
index 07854a5..5f4b31a 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
@@ -1,8 +1,10 @@
 package com.yeshi.fanli.controller.admin;
 
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.math.BigDecimal;
 import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -13,21 +15,29 @@
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+import org.yeshi.utils.CsvUtil;
 import org.yeshi.utils.DateUtil;
 import org.yeshi.utils.IPUtil;
 import org.yeshi.utils.JsonUtil;
+import org.yeshi.utils.entity.wx.RedPackRecord;
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.reflect.TypeToken;
 import com.yeshi.fanli.controller.admin.utils.AdminUtils;
+import com.yeshi.fanli.dto.ChartTDO;
 import com.yeshi.fanli.entity.bus.user.Extract;
 import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord;
 import com.yeshi.fanli.entity.bus.user.HongBaoV2;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
 import com.yeshi.fanli.entity.common.AdminUser;
 import com.yeshi.fanli.exception.ExtractException;
 import com.yeshi.fanli.exception.NotExistObjectException;
@@ -40,9 +50,11 @@
 import com.yeshi.fanli.service.inter.money.extract.ExtractAuditRecordService;
 import com.yeshi.fanli.service.inter.money.extract.ExtractCountService;
 import com.yeshi.fanli.service.inter.money.extract.ExtractService;
+import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
+import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
+import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
 import com.yeshi.fanli.service.inter.push.PushRecordService;
-import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
-import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanOrderService;
+import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.RedisManager;
@@ -91,6 +103,12 @@
 
 	@Resource
 	private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
+
+	@Resource
+	private UserInfoExtraService userInfoExtraService;
+
+	@Resource
+	private CommonOrderCountService commonOrderCountService;
 
 	/**
 	 * 
@@ -382,6 +400,11 @@
 				if (adminUser == null) {
 					record.setAdminUser(new AdminUser());
 				}
+				// 鏌ヨ鐢ㄦ埛澶囨敞淇℃伅
+				UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(record.getExtract().getUserInfo().getId());
+				if (extra != null) {
+					record.getExtract().getUserInfo().setStateDesc(extra.getMark());
+				}
 
 				int warnLevel = 0;
 				Extract extract = record.getExtract();
@@ -421,7 +444,26 @@
 					}
 					record.setExtraInfoStr(desc.toString());
 				}
+
+				if (warnLevel == 0) {
+					// 鏌ヨ鍚屽簵閾哄晢鍝侊紝鍚屽晢鍝佽鍗曡秴杩囦竴瀹氭暟閲忕殑
+					List<Integer> typeList = new ArrayList<>();
+					typeList.add(HongBaoV2.TYPE_ZIGOU);
+					long sameGoodsOrderCount = commonOrderCountService.countSameGoodsOrderByUidAndHongBaoType(typeList,
+							record.getExtract().getUserInfo().getId(),
+							Integer.parseInt(configService.get("admin_min_same_goods_order_count")));
+					long sameShopOrderCount = commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList,
+							record.getExtract().getUserInfo().getId(),
+							Integer.parseInt(configService.get("admin_min_same_shop_order_count")));
+					if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) {
+						warnLevel = 3;
+						record.setExtraInfoStr(
+								String.format("鍚屽簵閾�:%s   鍚屽晢鍝�:%s", sameShopOrderCount, sameGoodsOrderCount));
+					}
+				}
+
 				record.setWarnLevel(warnLevel);
+
 			}
 
 			int count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, null, days);
@@ -431,7 +473,7 @@
 			GsonBuilder gsonBuilder = new GsonBuilder();
 			gsonBuilder.serializeNulls();
 			gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss");
-			
+
 			Gson gson = gsonBuilder.create();
 
 			JSONObject data = new JSONObject();
@@ -546,6 +588,13 @@
 					surplusTime = DateUtil.dateDiff(formattodayTime, formatTime);
 				}
 
+				String mark = "";
+				UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(extract.getUserInfo().getId());
+				if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getMark())) {
+					mark = "璀︽儠锛侊紒 " + userInfoExtra.getMark();
+				}
+
+				data.put("mark", mark);
 				data.put("extract", extract);
 				data.put("beforeMoney", beforeMoney);
 				data.put("surplusTime", surplusTime);
@@ -609,6 +658,13 @@
 						surplusTime = DateUtil.dateDiff(formattodayTime, formatTime);
 					}
 
+					String mark = "";
+					UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(extract.getUserInfo().getId());
+					if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getMark())) {
+						mark = "璀︽儠锛侊紒 " + userInfoExtra.getMark();
+					}
+
+					data.put("mark", mark);
 					data.put("extract", extract);
 					data.put("beforeMoney", beforeMoney);
 					data.put("surplusTime", surplusTime);
@@ -821,9 +877,8 @@
 					innerList.put("name", "椹冲洖鏁�");
 				}
 
-				List<Map<String, Object>> list = extractAuditRecordService.countAuditTotal(state, dateType, year,
-						startTime, endTime);
-
+				List<ChartTDO> list = extractAuditRecordService.countAuditTotal(state, dateType, year, startTime,
+						endTime);
 				if (dateType != 3) {
 					innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
 				} else {
@@ -835,7 +890,6 @@
 					}
 					innerList.put("data", gson.toJson(map.get("value")));
 				}
-
 				line_list.add(innerList);
 			}
 
@@ -847,9 +901,7 @@
 			}
 
 			data.put("line_list", line_list);
-
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
 			e.printStackTrace();
@@ -875,7 +927,6 @@
 	@RequestMapping(value = "getExtractApplyMoney")
 	public void getExtractApplyMoney(String callback, Integer dateType, String year, String startTime, String endTime,
 			PrintWriter out) {
-
 		String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
 		if (validateMsg != null) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
@@ -908,13 +959,11 @@
 			List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
 
 			Gson gson = new Gson();
-			JSONArray line_list = new JSONArray();
-
 			JSONObject innerList = new JSONObject();
 			innerList.put("name", "鎬昏");
 
-			List<Map<String, Object>> list = extractAuditRecordService.countExtractApplyMoney(null, dateType, year,
-					startTime, endTime);
+			List<ChartTDO> list = extractAuditRecordService.countExtractApplyMoney(null, dateType, year, startTime,
+					endTime);
 
 			if (dateType != 3) {
 				innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
@@ -928,6 +977,7 @@
 				innerList.put("data", gson.toJson(map.get("value")));
 			}
 
+			JSONArray line_list = new JSONArray();
 			line_list.add(innerList);
 
 			JSONObject data = new JSONObject();
@@ -938,9 +988,7 @@
 			}
 
 			data.put("line_list", line_list);
-
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
 			e.printStackTrace();
@@ -968,7 +1016,6 @@
 	@RequestMapping(value = "getExtractApplyNumber")
 	public void getExtractApplyNumber(String callback, Integer state, Integer dateType, String year, String startTime,
 			String endTime, PrintWriter out) {
-
 		String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
 		if (validateMsg != null) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
@@ -996,18 +1043,15 @@
 		}
 
 		try {
-
 			Object objectDate = null;
-			List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
-
 			Gson gson = new Gson();
-			JSONArray line_list = new JSONArray();
+			List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
 
 			JSONObject innerList = new JSONObject();
 			innerList.put("name", "鎬昏");
 
-			List<Map<String, Object>> list = extractAuditRecordService.countExtractApplyNumber(null, dateType, year,
-					startTime, endTime);
+			List<ChartTDO> list = extractAuditRecordService.countExtractApplyNumber(null, dateType, year, startTime,
+					endTime);
 
 			if (dateType != 3) {
 				innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
@@ -1021,6 +1065,7 @@
 				innerList.put("data", gson.toJson(map.get("value")));
 			}
 
+			JSONArray line_list = new JSONArray();
 			line_list.add(innerList);
 
 			JSONObject data = new JSONObject();
@@ -1031,9 +1076,105 @@
 			}
 
 			data.put("line_list", line_list);
-
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
 
+	@RequestMapping(value = "downAutoExtractTxt")
+	public void downAutoExtractTxt(String callback, HttpServletResponse response, PrintWriter out) {
+		try {
+			List<String> list = extractService.getAutoExtractOpenIds();
+			if (list == null || list.size() <= 1) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鐢ㄦ埛婊¤冻鑷姩鎻愮幇鏉′欢"));
+				return;
+			}
+
+			String filepath = "鑷姩鎻愮幇OpenId " + java.lang.System.currentTimeMillis() + ".txt";
+			response.reset();
+			response.setContentType("application/octet-stream");
+			String fileName = URLDecoder.decode(filepath, "utf-8");
+			response.addHeader("Content-Disposition",
+					"attachment;" + "filename=\"" + URLEncoder.encode(fileName, "utf-8") + "\"");
+
+			StringBuilder sb = new StringBuilder();
+			for (String t : list) {
+				sb.append(t + "\r\n");
+			}
+
+			String opid_str = sb.toString();
+			if (!StringUtil.isNullOrEmpty(opid_str) && opid_str.endsWith("\r\n")) {
+				opid_str = opid_str.substring(0, opid_str.length() - 2);
+			}
+
+			OutputStream os = response.getOutputStream();
+			byte[] byt = opid_str.getBytes();
+			os.write(byt);
+			os.flush();
+			os.close();
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+
+	@RequestMapping(value = "uploadExcel", method = RequestMethod.POST)
+	public void uploadExcel(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
+		if (file == null) {
+			out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓嶈兘涓虹┖锛�"));
+			return;
+		}
+
+		try {
+			List<RedPackRecord> list = CsvUtil.getCsvData(file, RedPackRecord.class);
+			extractService.updateManualExtractRecord(list);
+			out.print(JsonUtil.loadTrueResult("涓婁紶鎴愬姛"));
+		} catch (ExtractException e) {
+			out.print(JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			e.printStackTrace();
+			out.print(JsonUtil.loadFalseResult("涓婁紶澶辫触"));
+		}
+	}
+
+	@RequestMapping(value = "preAutoUser")
+	public void preAutoUser(String callback, Integer pageIndex, Integer pageSize, PrintWriter out) {
+		try {
+			List<UserInfo> list = extractService.preAutoUser();
+			if (list == null || list.isEmpty()) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鐢ㄦ埛婊¤冻鑷姩鎻愮幇鏉′欢"));
+				return;
+			}
+
+			if (pageIndex == null || pageIndex < 1) {
+				pageIndex = 1;
+			}
+
+			if (pageSize == null || pageSize < 1) {
+				pageSize = Constant.PAGE_SIZE;
+			}
+
+			int count = list.size();
+			int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
+			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
+
+			List<UserInfo> listResult = null;
+			if (pageIndex < totalPage) {
+				int start = (pageIndex - 1) * pageSize;
+				listResult = list.subList(start, start + pageSize);
+			} else if (pageIndex == totalPage) {
+				listResult = list.subList((pageIndex - 1) * pageSize, list.size());
+			} else {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("娌℃湁鏇村浜�"));
+				return;
+			}
+
+			JSONObject data = new JSONObject();
+			data.put("pe", pe);
+			data.put("result_list", listResult);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
 			e.printStackTrace();

--
Gitblit v1.8.0