From 309a22d0624e8fec46f4b6722ed6135fe0a2ea3d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 27 二月 2019 15:43:51 +0800 Subject: [PATCH] 免单商品的红包处理 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java | 414 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 367 insertions(+), 47 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 a565421..292cf03 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,7 +1,9 @@ package com.yeshi.fanli.controller.admin; import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; import java.math.BigDecimal; +import java.net.URLDecoder; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -15,17 +17,24 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import net.sf.json.JSONArray; import net.sf.json.JSONObject; 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.IPUtil; +import org.yeshi.utils.JsonUtil; 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.entity.bus.user.Extract; import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord; import com.yeshi.fanli.entity.bus.user.HongBao; +import com.yeshi.fanli.entity.bus.user.HongBaoV2; import com.yeshi.fanli.entity.bus.user.Order; import com.yeshi.fanli.entity.bus.user.OrderItem; import com.yeshi.fanli.entity.bus.user.UserInfo; @@ -34,11 +43,15 @@ import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoOrder; import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; +import com.yeshi.fanli.exception.ExtractException; import com.yeshi.fanli.exception.NotExistObjectException; import com.yeshi.fanli.exception.ObjectStateException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.AdminUserService; +import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.count.ExtractCountService; +import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; +import com.yeshi.fanli.service.inter.count.UserInfoCountService; import com.yeshi.fanli.service.inter.hongbao.HongBaoService; import com.yeshi.fanli.service.inter.order.OrderItemServcie; import com.yeshi.fanli.service.inter.order.PidOrderService; @@ -55,16 +68,18 @@ import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; -import org.yeshi.utils.DateUtil; -import org.yeshi.utils.IPUtil; -import org.yeshi.utils.JsonUtil; - @Controller @RequestMapping("admin/new/api/v1/extract") public class ExtractAdminController { @Resource private ExtractService extractService; + + @Resource + private ConfigService configService; + + @Resource + private UserInfoCountService userInfoCountService; @Resource private ExtractCountService extractCountService; @@ -83,6 +98,9 @@ @Resource private HongBaoService hongBaoService; + + @Resource + private HongBaoV2CountService hongBaoV2CountService; @Resource private AdminUserService adminUserService; @@ -291,6 +309,12 @@ /* 鎷掔粷鎻愮幇 鎿嶄綔 */ try { + reason = URLDecoder.decode(reason, "UTF-8"); + } catch (Exception e1) { + e1.printStackTrace(); + } + + try { Extract extract = extractService.getExtractById(id); long extractTime = extract.getExtractTime(); extractService.rejectExtract(id, reason, extractTime, admin);// 鎻愮幇澶辫触 @@ -328,27 +352,12 @@ */ @RequestMapping(value = "checkExtract", method = RequestMethod.POST) public void checkExtract(String uid, PrintWriter out) { - JSONObject data = new JSONObject(); - - // 宸插埌璐︾殑绾㈠寘 - int count = hongBaoService.getCount(HongBao.STATE_YILINGQU); - if (count == 0) { - data.put("code", "0"); //寮傚父 - out.print(data); - return; - } - - List<Integer> checked = extractService.checkExtract(uid); - if (checked != null && checked.size() > 0) { - Integer diversity = checked.get(0); - if (diversity == 0) { - data.put("code", "0");// 寮傚父 - } else { - data.put("code", "1"); // 姝e父 - } - } else { - data.put("code", "1"); //姝e父 + try { + extractService.checkExtract(uid); + data.put("code", "1"); // 姝e父 + } catch (ExtractException e) { + data.put("code", "0");// 寮傚父 } out.print(data); } @@ -363,15 +372,31 @@ Map<String, Object> totalcount = extractCountService.getTodayCount(); - BigDecimal totalmoney = extractCountService.getTodayTotalSuccessMoney(); + // 浠婃棩鎻愮幇鎴愬姛閲戦 + BigDecimal todayextractMoney = extractCountService.getTodayTotalSuccessMoney(); - totalcount.put("totalmoney", totalmoney); + // 褰撳墠鐢ㄦ埛浣欓鎬昏锛氭墍鏈夌敤鎴锋�讳綑棰� + BigDecimal amountMoney = userInfoCountService.countAllMoney(null); + // 鍙彁鐜伴噾棰濋檺鍒� + String minMoney = configService.get(Constant.EXTRACT_MIN_MONEY); + if (minMoney == null) { + minMoney = "0"; + } + // 褰撳墠鍙彁鐜伴噾棰濇�昏锛� 瓒呰繃鏈�浣庢彁鐜伴噾棰�---璁″叆缁熻 + BigDecimal extractApply = userInfoCountService.countAllMoney(Double.parseDouble(minMoney)); + + // 绱宸叉彁鐜伴噾棰濇�昏锛氬凡鎻愮幇鎴愬姛鐨勬�婚/ 娆℃暟 Map<String, Object> resultData = extractCountService.countTotalSuccess(); JSONObject data = new JSONObject(); data.put("todayCount", totalcount); - data.put("totalount", resultData); + data.put("todayextractMoney", todayextractMoney); + + data.put("amountMoney", amountMoney); // 鎵�鏈夌敤鎴锋�讳綑棰� + data.put("extractApply", extractApply); // 鍙彁鐜伴噾棰濇�昏 + data.put("extractNumber", resultData.get("totalamount")); // 鎻愮幇鎴愬姛娆℃暟 + data.put("extractMoney", resultData.get("totalmoney")); // 鎻愮幇鎴愬姛閲戦 out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); } @@ -523,6 +548,23 @@ if (adminUser == null) { record.setAdminUser(new AdminUser()); } + + int warnLevel = 0; + Extract extract = record.getExtract(); + if (extract != null) { + Integer extractState = extract.getState(); + if (extractState != null && extractState == 0) { + UserInfo userInfo = extract.getUserInfo(); + if (userInfo != null) { + double countTodayMoney = extractService.countTodayMoney(userInfo.getId()); + if (countTodayMoney >= 100) { + warnLevel = 1; + } + } + } + + } + record.setWarnLevel(warnLevel); } int count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, null, days); @@ -791,7 +833,10 @@ try { // 缁熻宸查鍙栭噾棰� 璐︽埛鍘嗗彶鎬绘敹鐩� - double receiveMoneys = hongBaoService.countReceiveMoneysByUid(uid); + BigDecimal receiveMoneys = hongBaoV2CountService.countMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU); + if (receiveMoneys == null) { + receiveMoneys = new BigDecimal(0); + } // 鍘嗗彶鎻愮幇鎴愬姛閲戦 double successMoneys = extractCountService.countSuccessMoneysByUid(uid); @@ -811,7 +856,6 @@ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } catch (Exception e) { - // TODO: handle exception JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); e.printStackTrace(); } @@ -1024,7 +1068,11 @@ String auctionIds = auctionIdBuf.toString(); String ids = auctionIds.substring(0, auctionIds.length() - 1); - goodsBriefList = TaoKeApiUtil.getBatchGoodsInfos(ids); + try { + goodsBriefList = TaoKeApiUtil.getBatchGoodsInfos(ids); + } catch (Exception e) { + e.printStackTrace(); + } } List<Map<String, Object>> listResult = new ArrayList<Map<String, Object>>(); @@ -1075,7 +1123,7 @@ } catch (Exception e) { e.printStackTrace(); - out.print(JsonUtil.loadFalseResult(e.getMessage())); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); } } @@ -1278,7 +1326,7 @@ } catch (Exception e) { e.printStackTrace(); - out.print(JsonUtil.loadFalseResult(e.getMessage())); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage()))); } } @@ -1401,26 +1449,298 @@ return; } - // 宸插埌璐︾殑绾㈠寘 - int count = hongBaoService.getCount(HongBao.STATE_YILINGQU); - if (count == 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璧勯噾寮傚父")); - return; - } - - List<Integer> listChecked = extractService.checkExtract(uid); - if (listChecked == null || listChecked.size() == 0) { + try { + extractService.checkExtract(uid); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("璧勯噾姝e父")); + } catch (ExtractException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); + } + } + + /** + * 缁熻瀹℃牳娆℃暟 + * + * @param callback + * @param state + * 瀹℃牳鐘舵�侊細鎵�鏈�-3 閫氳繃-1 鎷掔粷- 2 + * @param type + * 缁熻绫诲瀷 1-24灏忔椂 2-鎵�鏈�3 + * @param dateType + * 绫诲瀷 1鏃� 2鏈� 3骞� + * @param year + * 2018 + * @param startTime + * 2018-12-01 + * @param endTime + * 2018-12-01 + * @param out + */ + @RequestMapping(value = "getAuditTotal") + public void getAuditTotal(String callback, String stateArray, 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)); return; } - Integer diversity = listChecked.get(0); - if (diversity == 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璧勯噾寮傚父")); - } else { - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("璧勯噾姝e父")); + if (dateType == 1 && year != null) { + year = null; // 璁剧疆涓虹┖ + } else if (dateType == 2) { + if (startTime != null) + startTime = null; + + if (endTime != null) + endTime = null; + + } else if (dateType == 3) { + if (year != null) + year = null; + + if (startTime != null) + startTime = null; + + if (endTime != null) + endTime = null; } - + + try { + Object objectDate = null; + List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + + Gson gson = new Gson(); + List<Integer> stateList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() { + }.getType()); + + JSONArray line_list = new JSONArray(); + for (Integer state : stateList) { + JSONObject innerList = new JSONObject(); + if (state == null || state == 3) { + innerList.put("name", "鎬昏"); + } else if (state == 1) { + innerList.put("name", "閫氳繃鏁�"); + } else if (state == 2) { + innerList.put("name", "椹冲洖鏁�"); + } + + List<Map<String, Object>> list = extractAuditRecordService.countAuditTotal(state, dateType, year, + startTime, endTime); + + if (dateType != 3) { + innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list))); + } else { + // 骞磋鍥� + Map<String, Object> map = AdminUtils.yearsDataFactory(list); + + if (objectDate == null) { + objectDate = map.get("date"); + } + innerList.put("data", gson.toJson(map.get("value"))); + } + + line_list.add(innerList); + } + + JSONObject data = new JSONObject(); + if (objectDate != null) { + data.put("xAxis_list", gson.toJson(objectDate)); + } else { + data.put("xAxis_list", gson.toJson(dateList)); + } + + data.put("line_list", line_list); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } + + /** + * 缁熻鎻愮幇鐢宠鎬婚 + * + * @param callback + * @param type + * 缁熻绫诲瀷 1-24灏忔椂 2-鎵�鏈� + * @param dateType + * 绫诲瀷 1鏃� 2鏈� 3 + * @param year + * 2018 + * @param startTime + * 2018-12-01 + * @param endTime + * 2018-12-01 + * @param out + */ + @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)); + return; + } + + if (dateType == 1 && year != null) { + year = null; // 璁剧疆涓虹┖ + } else if (dateType == 2) { + if (startTime != null) + startTime = null; + + if (endTime != null) + endTime = null; + + } else if (dateType == 3) { + if (year != null) + year = null; + + if (startTime != null) + startTime = null; + + if (endTime != null) + endTime = null; + } + + try { + + Object objectDate = null; + 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); + + if (dateType != 3) { + innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list))); + } else { + // 骞磋鍥� + Map<String, Object> map = AdminUtils.yearsDataFactory(list); + + if (objectDate == null) { + objectDate = map.get("date"); + } + innerList.put("data", gson.toJson(map.get("value"))); + } + + line_list.add(innerList); + + JSONObject data = new JSONObject(); + if (objectDate != null) { + data.put("xAxis_list", gson.toJson(objectDate)); + } else { + data.put("xAxis_list", gson.toJson(dateList)); + } + + data.put("line_list", line_list); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } + + /** + * 缁熻鎻愮幇鐢宠鎬绘鏁� + * + * @param callback + * @param state + * 鎵�鏈�-绌哄�兼垨鑰呬笉浼� 寰呭鏍�-0 閫氳繃-1 鎷掔粷- 2 + * @param type + * 缁熻绫诲瀷 1-24灏忔椂 2-鎵�鏈� + * @param dateType + * 绫诲瀷 1鏃� 2鏈� 3骞� + * @param year + * 2018 + * @param startTime + * 2018-12-01 + * @param endTime + * 2018-12-01 + * @param out + */ + @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)); + return; + } + + if (dateType == 1 && year != null) { + year = null; // 璁剧疆涓虹┖ + } else if (dateType == 2) { + if (startTime != null) + startTime = null; + + if (endTime != null) + endTime = null; + + } else if (dateType == 3) { + if (year != null) + year = null; + + if (startTime != null) + startTime = null; + + if (endTime != null) + endTime = null; + } + + try { + + Object objectDate = null; + 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.countExtractApplyNumber(null, dateType, year, + startTime, endTime); + + if (dateType != 3) { + innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list))); + } else { + // 骞磋鍥� + Map<String, Object> map = AdminUtils.yearsDataFactory(list); + + if (objectDate == null) { + objectDate = map.get("date"); + } + innerList.put("data", gson.toJson(map.get("value"))); + } + + line_list.add(innerList); + + JSONObject data = new JSONObject(); + if (objectDate != null) { + data.put("xAxis_list", gson.toJson(objectDate)); + } else { + data.put("xAxis_list", gson.toJson(dateList)); + } + + data.put("line_list", line_list); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } } } -- Gitblit v1.8.0