From 651a15c78f668bef3859d9ed1bb7ad0b669d3600 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 03 七月 2020 17:52:07 +0800 Subject: [PATCH] 多APP优化 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java | 1498 +++++++++++++++++++++++++++++------------------------------ 1 files changed, 735 insertions(+), 763 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 f35bcdc..f78a52f 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 @@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.yeshi.fanli.entity.accept.AdminAcceptData; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -65,921 +66,892 @@ @RequestMapping("admin/new/api/v1/extract") public class ExtractAdminController { - @Resource - private ExtractService extractService; + @Resource + private ExtractService extractService; - @Resource - private ConfigService configService; + @Resource + private ConfigService configService; - @Resource - private UserInfoCountService userInfoCountService; + @Resource + private UserInfoCountService userInfoCountService; - @Resource - private ExtractCountService extractCountService; + @Resource + private ExtractCountService extractCountService; - @Resource - private PushRecordService pushRecordService; + @Resource + private ExtractAuditRecordService extractAuditRecordService; - @Resource - private PushController xingePushController; + @Resource + private HongBaoV2CountService hongBaoV2CountService; - @Resource - private ExtractAuditRecordService extractAuditRecordService; + @Resource + private UserInfoExtraService userInfoExtraService; - @Resource - private HongBaoV2CountService hongBaoV2CountService; + @Resource + private CommonOrderCountService commonOrderCountService; - @Resource - private AdminUserService adminUserService; + /** + * 鏂规硶璇存槑: 閫氳繃鎻愮幇璇锋眰 鍙痡sonP鏂瑰紡 + * + * @param id + * @param code 楠岃瘉鐮� + * @param out + * @param request + */ + @RequestMapping(value = "passExtractJP") + public void passExtractJP(String callback, Long id, String code, PrintWriter out, HttpServletRequest request) { - @Resource - private RedisManager redisManager; + /* 妫�楠屾槸鍚︾櫥闄� */ + AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); + if (admin == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄嗐��")); + return; + } - @Resource - private TaoBaoOrderService taoBaoOrderService; + /* 妫�楠屾槸鍚﹂�氳繃楠岃瘉 */ + String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT); + if (!"1".equals(codeType)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "閭楠岃瘉鏈�氳繃")); + return; + } - @Resource - private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService; + /* 鍏佽鎻愮幇 鎿嶄綔 */ + Integer integer = extractService.passExtract(id, admin); - @Resource - private UserInfoExtraService userInfoExtraService; + // 鏃ュ織璁板綍 + if (integer == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("宸查�氳繃")); + LogHelper + .userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "閫氳繃浜哰id=" + id + "]鐨勬彁鐜扮敵璇�!"); + } else if (integer == 1) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ユ彁鐜拌褰曞凡涓嶅瓨鍦�,璇峰埛鏂�")); + LogHelper.userInfo( + "[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鍚屾剰鎻愮幇id=" + id + "鐨勬彁鐜扮敵璇蜂笉瀛樺湪"); + } else { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ敤鎴峰凡琚鐞�,璇峰埛鏂�")); + LogHelper.userInfo( + "[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鍚屾剰鎻愮幇id=" + id + "鐨勬彁鐜扮敵璇风姸鎬佸紓甯�"); + } - @Resource - private CommonOrderCountService commonOrderCountService; + } - /** - * - * 鏂规硶璇存槑: 閫氳繃鎻愮幇璇锋眰 鍙痡sonP鏂瑰紡 - * - * @param id - * @param code - * 楠岃瘉鐮� - * @param out - * @param request - */ - @RequestMapping(value = "passExtractJP") - public void passExtractJP(String callback, Long id, String code, PrintWriter out, HttpServletRequest request) { + /** + * 鏂规硶璇存槑: 鎷掔粷鎻愮幇璇锋眰jsonP + * + * @param id + * @param reason + * @param out + * @param request + * @author mawurui createTime 2018骞�3鏈�14鏃� 涓嬪崍3:15:55 + */ + @RequestMapping(value = "rejectExtractJP") + public void rejectExtractJP(String callback, Long id, String code, String reason, PrintWriter out, + HttpServletRequest request) { + /* 妫�楠屾槸鍚︾櫥闄� */ + AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); + if (admin == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�")); + return; + } - /* 妫�楠屾槸鍚︾櫥闄� */ - AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); - if (admin == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄嗐��")); - return; - } + /* 妫�楠屾槸鍚﹂�氳繃楠岃瘉 */ + String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT); + if (!"1".equals(codeType)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "閭楠岃瘉鏈�氳繃")); + return; + } - /* 妫�楠屾槸鍚﹂�氳繃楠岃瘉 */ - String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT); - if (!"1".equals(codeType)) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "閭楠岃瘉鏈�氳繃")); - return; - } + try { + // 缂栫爜杞崲 + reason = URLDecoder.decode(reason, "UTF-8"); + } catch (Exception e1) { + e1.printStackTrace(); + } - /* 鍏佽鎻愮幇 鎿嶄綔 */ - Integer integer = extractService.passExtract(id, admin); + try { - // 鏃ュ織璁板綍 - if (integer == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("宸查�氳繃")); - LogHelper - .userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "閫氳繃浜哰id=" + id + "]鐨勬彁鐜扮敵璇�!"); - } else if (integer == 1) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ユ彁鐜拌褰曞凡涓嶅瓨鍦�,璇峰埛鏂�")); - LogHelper.userInfo( - "[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鍚屾剰鎻愮幇id=" + id + "鐨勬彁鐜扮敵璇蜂笉瀛樺湪"); - } else { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ敤鎴峰凡琚鐞�,璇峰埛鏂�")); - LogHelper.userInfo( - "[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鍚屾剰鎻愮幇id=" + id + "鐨勬彁鐜扮敵璇风姸鎬佸紓甯�"); - } + extractService.rejectExtract(id, reason, admin);// 鎻愮幇澶辫触 - } + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎷掔粷鎴愬姛")); - /** - * - * 鏂规硶璇存槑: 鎷掔粷鎻愮幇璇锋眰jsonP - * - * @author mawurui createTime 2018骞�3鏈�14鏃� 涓嬪崍3:15:55 - * @param id - * @param reason - * @param out - * @param request - */ - @RequestMapping(value = "rejectExtractJP") - public void rejectExtractJP(String callback, Long id, String code, String reason, PrintWriter out, - HttpServletRequest request) { - /* 妫�楠屾槸鍚︾櫥闄� */ - AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); - if (admin == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�")); - return; - } + LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "鎷掔粷浜哰id=" + id + + "]鐨勬彁鐜扮敵璇�!鎷掔粷鍘熷洜鏄�" + reason); - /* 妫�楠屾槸鍚﹂�氳繃楠岃瘉 */ - String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT); - if (!"1".equals(codeType)) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "閭楠岃瘉鏈�氳繃")); - return; - } + } catch (ObjectStateException e) { + LogHelper.userInfo( + "[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鎷掔粷鎻愮幇id=" + id + "鐨勬彁鐜扮敵璇风姸鎬佸紓甯�!"); // - try { - // 缂栫爜杞崲 - reason = URLDecoder.decode(reason, "UTF-8"); - } catch (Exception e1) { - e1.printStackTrace(); - } + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage())); - try { + } catch (NotExistObjectException e) { + LogHelper.userInfo( + "[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鎷掔粷鎻愮幇id=" + id + "鐨勬彁鐜扮敵璇蜂笉瀛樺湪!"); - extractService.rejectExtract(id, reason, admin);// 鎻愮幇澶辫触 + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage())); + } - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎷掔粷鎴愬姛")); + } - LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "鎷掔粷浜哰id=" + id - + "]鐨勬彁鐜扮敵璇�!鎷掔粷鍘熷洜鏄�" + reason); + /** + * 鑾峰彇浠婃棩鎻愮幇璁板綍锛氫粖鏃ユ�婚銆佹�绘鏁般�佹垚鍔熸鏁般�佸け璐ユ鏁� 鑾峰彇绯荤粺鎻愮幇璁板綍锛氭�婚銆佹�绘鏁� + * + * @param out + */ + @RequestMapping(value = "countExtract") + public void countExtract(AdminAcceptData acceptData, String callback, PrintWriter out) { - } catch (ObjectStateException e) { - LogHelper.userInfo( - "[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鎷掔粷鎻愮幇id=" + id + "鐨勬彁鐜扮敵璇风姸鎬佸紓甯�!"); // + Map<String, Object> totalcount = extractCountService.getTodayCount(); - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage())); + // 浠婃棩鎻愮幇鎴愬姛閲戦 + BigDecimal todayextractMoney = extractCountService.getTodayTotalSuccessMoney(); - } catch (NotExistObjectException e) { - LogHelper.userInfo( - "[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鎷掔粷鎻愮幇id=" + id + "鐨勬彁鐜扮敵璇蜂笉瀛樺湪!"); + // 褰撳墠鐢ㄦ埛浣欓鎬昏锛氭墍鏈夌敤鎴锋�讳綑棰� + BigDecimal amountMoney = userInfoCountService.countAllMoney(null); - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage())); - } + // 鍙彁鐜伴噾棰濋檺鍒� + String minMoney = configService.getValue(ConfigKeyEnum.extractMoneyMin.getKey(), acceptData.getSystem()); + if (minMoney == null) { + minMoney = "0"; + } + // 褰撳墠鍙彁鐜伴噾棰濇�昏锛� 瓒呰繃鏈�浣庢彁鐜伴噾棰�---璁″叆缁熻 + BigDecimal extractApply = userInfoCountService.countAllMoney(Double.parseDouble(minMoney)); - } + // 绱宸叉彁鐜伴噾棰濇�昏锛氬凡鎻愮幇鎴愬姛鐨勬�婚/ 娆℃暟 + Map<String, Object> resultData = extractCountService.countTotalSuccess(); - /** - * 鑾峰彇浠婃棩鎻愮幇璁板綍锛氫粖鏃ユ�婚銆佹�绘鏁般�佹垚鍔熸鏁般�佸け璐ユ鏁� 鑾峰彇绯荤粺鎻愮幇璁板綍锛氭�婚銆佹�绘鏁� - * - * @param out - */ - @RequestMapping(value = "countExtract") - public void countExtract(String callback, PrintWriter out) { + JSONObject data = new JSONObject(); + data.put("todayCount", totalcount); + data.put("todayextractMoney", todayextractMoney); - Map<String, Object> totalcount = extractCountService.getTodayCount(); + data.put("amountMoney", amountMoney); // 鎵�鏈夌敤鎴锋�讳綑棰� + data.put("extractApply", extractApply); // 鍙彁鐜伴噾棰濇�昏 + data.put("extractNumber", resultData.get("totalamount")); // 鎻愮幇鎴愬姛娆℃暟 + data.put("extractMoney", resultData.get("totalmoney")); // 鎻愮幇鎴愬姛閲戦 - // 浠婃棩鎻愮幇鎴愬姛閲戦 - BigDecimal todayextractMoney = extractCountService.getTodayTotalSuccessMoney(); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + } - // 褰撳墠鐢ㄦ埛浣欓鎬昏锛氭墍鏈夌敤鎴锋�讳綑棰� - BigDecimal amountMoney = userInfoCountService.countAllMoney(null); + /** + * 鏌ヨ鎵�鏈夊鏍歌褰曚俊鎭� + * + * @param callback + * @param pageIndex + * @param key + * @param startTime + * @param endTime + * @param out + */ + @RequestMapping(value = "getFinishRecordList") + public void getFinishRecordList(String callback, Integer pageIndex, String key, String startTime, String endTime, + PrintWriter out) { - // 鍙彁鐜伴噾棰濋檺鍒� - String minMoney = configService.get(ConfigKeyEnum.extractMoneyMin.getKey()); - if (minMoney == null) { - minMoney = "0"; - } - // 褰撳墠鍙彁鐜伴噾棰濇�昏锛� 瓒呰繃鏈�浣庢彁鐜伴噾棰�---璁″叆缁熻 - BigDecimal extractApply = userInfoCountService.countAllMoney(Double.parseDouble(minMoney)); + try { - // 绱宸叉彁鐜伴噾棰濇�昏锛氬凡鎻愮幇鎴愬姛鐨勬�婚/ 娆℃暟 - Map<String, Object> resultData = extractCountService.countTotalSuccess(); + // 璧峰鏃堕棿 涓虹┖璁剧疆榛樿鍊硷細 + if (StringUtil.isNullOrEmpty(startTime)) { + startTime = "1970-01-01"; + } - JSONObject data = new JSONObject(); - data.put("todayCount", totalcount); - data.put("todayextractMoney", todayextractMoney); + // 缁撴潫鏃堕棿 涓虹┖璁剧疆榛樿鍊煎綋鍓嶆棩鏈� + if (StringUtil.isNullOrEmpty(endTime)) { + Date curDate = new Date(); + endTime = TimeUtil.getSimpleDate(curDate); + } - data.put("amountMoney", amountMoney); // 鎵�鏈夌敤鎴锋�讳綑棰� - data.put("extractApply", extractApply); // 鍙彁鐜伴噾棰濇�昏 - data.put("extractNumber", resultData.get("totalamount")); // 鎻愮幇鎴愬姛娆℃暟 - data.put("extractMoney", resultData.get("totalmoney")); // 鎻愮幇鎴愬姛閲戦 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date enddate = sdf.parse(endTime); + Calendar c = Calendar.getInstance(); + c.setTime(enddate); + c.add(Calendar.DAY_OF_MONTH, 1);// 浠婂ぉ+1澶� - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - } + endTime = sdf.format(c.getTime()); - /** - * 鏌ヨ鎵�鏈夊鏍歌褰曚俊鎭� - * - * @param callback - * @param pageIndex - * @param key - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getFinishRecordList") - public void getFinishRecordList(String callback, Integer pageIndex, String key, String startTime, String endTime, - PrintWriter out) { + if (pageIndex == null) + pageIndex = 1; - try { + int pageSize = Constant.PAGE_SIZE; - // 璧峰鏃堕棿 涓虹┖璁剧疆榛樿鍊硷細 - if (StringUtil.isNullOrEmpty(startTime)) { - startTime = "1970-01-01"; - } + List<ExtractAuditRecord> auditList = extractAuditRecordService.getList(pageIndex, pageSize, key, startTime, + endTime); - // 缁撴潫鏃堕棿 涓虹┖璁剧疆榛樿鍊煎綋鍓嶆棩鏈� - if (StringUtil.isNullOrEmpty(endTime)) { - Date curDate = new Date(); - endTime = TimeUtil.getSimpleDate(curDate); - } + int count = extractAuditRecordService.getCount(key, startTime, endTime); + int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; + PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Date enddate = sdf.parse(endTime); - Calendar c = Calendar.getInstance(); - c.setTime(enddate); - c.add(Calendar.DAY_OF_MONTH, 1);// 浠婂ぉ+1澶� + if (auditList == null || auditList.size() == 0) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"))); + } else { - endTime = sdf.format(c.getTime()); + for (ExtractAuditRecord extractAuditRecord : auditList) { + int countByUid = 0; + int countCancel = 0; + Extract extract = extractAuditRecord.getExtract(); + if (extract != null) { + UserInfo userInfo = extract.getUserInfo(); + Long id = userInfo.getId(); + countByUid = hongBaoV2CountService.countNumberByUid(id); + countCancel = hongBaoV2CountService.countNumberByUidAndState(id, HongBaoV2.STATE_SHIXIAO); + } + extractAuditRecord.setCancelOrderNum((long) countCancel); + extractAuditRecord.setOrderNum((long) countByUid); + } - if (pageIndex == null) - pageIndex = 1; + JSONObject data = new JSONObject(); + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.serializeNulls(); // 閲嶇偣 + Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); - int pageSize = Constant.PAGE_SIZE; + data.put("pe", pe); + data.put("auditList", gson.toJson(auditList)); - List<ExtractAuditRecord> auditList = extractAuditRecordService.getList(pageIndex, pageSize, key, startTime, - endTime); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + } - int count = extractAuditRecordService.getCount(key, startTime, endTime); - int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; - PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); + } catch (Exception e) { + e.printStackTrace(); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"))); + } + } - if (auditList == null || auditList.size() == 0) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"))); - } else { + /** + * 鏌ヨ瀹㈡湇涓汉鎻愮幇瀹℃壒璁板綍淇℃伅 + * + * @param callback + * @param pageIndex 椤电爜 + * @param key 绛涢�夋潯浠� + * @param timeSlot 鏌ヨ鏃堕棿娈� + * @param state 鏌ョ湅瀹℃牳鐘舵�� + * @param out + * @param request + */ + @RequestMapping(value = "getMyAuditedList") + public void getMyAuditedList(String callback, Integer pageIndex, String key, String timeSlot, Integer state, + PrintWriter out, HttpServletRequest request) { - for (ExtractAuditRecord extractAuditRecord : auditList) { - int countByUid = 0; - int countCancel = 0; - Extract extract = extractAuditRecord.getExtract(); - if (extract != null) { - UserInfo userInfo = extract.getUserInfo(); - Long id = userInfo.getId(); - countByUid = hongBaoV2CountService.countNumberByUid(id); - countCancel = hongBaoV2CountService.countNumberByUidAndState(id, HongBaoV2.STATE_SHIXIAO); - } - extractAuditRecord.setCancelOrderNum((long) countCancel); - extractAuditRecord.setOrderNum((long) countByUid); - } + try { - JSONObject data = new JSONObject(); - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.serializeNulls(); // 閲嶇偣 - Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); + // AdminUser admin = (AdminUser) + // request.getSession().getAttribute(Constant.SESSION_ADMIN); + // if (admin == null) { + // JsonUtil.printMode(out, callback, + // JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�")); + // return; + // } - data.put("pe", pe); - data.put("auditList", gson.toJson(auditList)); + int pageSize = Constant.PAGE_SIZE; + Integer days = null; + if ("1".equals(timeSlot)) { + days = 0; // 浠婃棩 + } else if ("2".equals(timeSlot)) { + days = 3; // 鍓�3澶� + } else if ("3".equals(timeSlot)) { + days = 7; // 鍓�7澶� + } - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - } + if (state != null && state != 0 && state != 1 && state != 2) { + state = null; + } - } catch (Exception e) { - e.printStackTrace(); - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"))); - } - } + // 鏌ヨ褰撳墠浜哄憳鐨勫鏍稿垪琛ㄤ俊鎭� + // Long adminId = admin.getId(); + // auditList = + // extractAuditRecordService.getMyAuditedTimeSlotList(pageIndex, + // pageSize, key,state, adminId, days); + // count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, + // state, adminId,days); - /** - * 鏌ヨ瀹㈡湇涓汉鎻愮幇瀹℃壒璁板綍淇℃伅 - * - * @param callback - * @param pageIndex - * 椤电爜 - * @param key - * 绛涢�夋潯浠� - * @param timeSlot - * 鏌ヨ鏃堕棿娈� - * @param state - * 鏌ョ湅瀹℃牳鐘舵�� - * @param out - * @param request - */ - @RequestMapping(value = "getMyAuditedList") - public void getMyAuditedList(String callback, Integer pageIndex, String key, String timeSlot, Integer state, - PrintWriter out, HttpServletRequest request) { + // 鏆備笉鍖哄垎璐﹀彿锛岄粯璁ゆ墍鏈� + List<ExtractAuditRecord> auditList = extractAuditRecordService.getMyAuditedTimeSlotList(pageIndex, pageSize, + key, state, null, days); + if (auditList == null || auditList.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); + return; + } - try { + for (ExtractAuditRecord record : auditList) { + AdminUser adminUser = record.getAdminUser(); + if (adminUser == null) { + record.setAdminUser(new AdminUser()); + } + // 鏌ヨ鐢ㄦ埛澶囨敞淇℃伅 + UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(record.getExtract().getUserInfo().getId()); + if (extra != null) { + record.getExtract().getUserInfo().setStateDesc(extra.getMark()); + } - // AdminUser admin = (AdminUser) - // request.getSession().getAttribute(Constant.SESSION_ADMIN); - // if (admin == null) { - // JsonUtil.printMode(out, callback, - // JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�")); - // return; - // } + int warnLevel = 0; + Extract extract = record.getExtract(); + if (extract != null) { + Integer extractState = extract.getState(); + if (extractState != null && extractState == Extract.STATE_NOT_PROCESS) { + UserInfo userInfo = extract.getUserInfo(); + if (userInfo != null) { + BigDecimal countTodayMoney = extractService.sumTodayApplyMoney(userInfo.getId(), + TimeUtil.getGernalTime(extract.getExtractTime())); + if (countTodayMoney.compareTo(new BigDecimal(100)) > 0) { + warnLevel = 1; + } + } + } + } - int pageSize = Constant.PAGE_SIZE; - Integer days = null; - if ("1".equals(timeSlot)) { - days = 0; // 浠婃棩 - } else if ("2".equals(timeSlot)) { - days = 3; // 鍓�3澶� - } else if ("3".equals(timeSlot)) { - days = 7; // 鍓�7澶� - } + if (record.getExtraInfo() != null) { + StringBuffer desc = new StringBuffer(); + if (System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2019-06-21", "yyyy-MM-dd")) { + desc.append("澶х瑪璁㈠崟鏁�:" + record.getExtraInfo().getOrderCount50More() + "\n#"); + desc.append("缁存潈璁㈠崟鏁�:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#"); + desc.append("缁存潈璁㈠崟浣i噾:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#"); + if (record.getExtraInfo().getOrderCount50More() > 0 + || record.getExtraInfo().getWeiQuanOrderCount() > 0 + || record.getExtraInfo().getWeiQuanOrderFanAmount().compareTo(new BigDecimal(10)) >= 0) + warnLevel = 2; + } else { + if (record.getExtraInfo().getOrderCount50More() > 0 + || record.getExtraInfo().getWeiQuanOrderCount() > 0 + || record.getExtraInfo().getWeiQuanOrderFanAmount().compareTo(new BigDecimal(0)) > 0) + warnLevel = 2; + desc.append("澶т簬50鍏冭鍗�:" + record.getExtraInfo().getOrderCount50More() + "\n#"); + desc.append("缁存潈璁㈠崟鏁�:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#"); + desc.append("缁存潈璁㈠崟閫�鍥為噾棰�:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#"); + desc.append("180澶╁畨鍏ㄨ鍗曟暟:" + record.getExtraInfo().getSafeOrderCount()); + } - if (state != null && state != 0 && state != 1 && state != 2) { - state = null; - } + if (record.getExtraInfo().getLess10OrderCount() != null && record.getExtraInfo().getLess10OrderCount() > 10) { + desc.append("鍒峰崟瀚岀枒\n#"); + } - // 鏌ヨ褰撳墠浜哄憳鐨勫鏍稿垪琛ㄤ俊鎭� - // Long adminId = admin.getId(); - // auditList = - // extractAuditRecordService.getMyAuditedTimeSlotList(pageIndex, - // pageSize, key,state, adminId, days); - // count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, - // state, adminId,days); + record.setExtraInfoStr(desc.toString()); + } - // 鏆備笉鍖哄垎璐﹀彿锛岄粯璁ゆ墍鏈� - List<ExtractAuditRecord> auditList = extractAuditRecordService.getMyAuditedTimeSlotList(pageIndex, pageSize, - key, state, null, days); - if (auditList == null || auditList.size() == 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); - return; - } - for (ExtractAuditRecord record : auditList) { - AdminUser adminUser = record.getAdminUser(); - if (adminUser == null) { - record.setAdminUser(new AdminUser()); - } - // 鏌ヨ鐢ㄦ埛澶囨敞淇℃伅 - UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(record.getExtract().getUserInfo().getId()); - if (extra != null) { - record.getExtract().getUserInfo().setStateDesc(extra.getMark()); - } + // 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(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey()))); + // long sameShopOrderCount = + // commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList, + // record.getExtract().getUserInfo().getId(), + // Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameShopOrderCount.getKey()))); + // if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) { + // warnLevel = 3; + // record.setExtraInfoStr( + // String.format("鍚屽簵閾�:%s 鍚屽晢鍝�:%s", sameShopOrderCount, + // sameGoodsOrderCount)); + // } + // } - int warnLevel = 0; - Extract extract = record.getExtract(); - if (extract != null) { - Integer extractState = extract.getState(); - if (extractState != null && extractState == Extract.STATE_NOT_PROCESS) { - UserInfo userInfo = extract.getUserInfo(); - if (userInfo != null) { - BigDecimal countTodayMoney = extractService.sumTodayApplyMoney(userInfo.getId(), - TimeUtil.getGernalTime(extract.getExtractTime())); - if (countTodayMoney.compareTo(new BigDecimal(100)) > 0) { - warnLevel = 1; - } - } - } - } + record.setWarnLevel(warnLevel); + } - if (record.getExtraInfo() != null) { - StringBuffer desc = new StringBuffer(); - if (System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2019-06-21", "yyyy-MM-dd")) { - desc.append("澶х瑪璁㈠崟鏁�:" + record.getExtraInfo().getOrderCount50More() + "\n#"); - desc.append("缁存潈璁㈠崟鏁�:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#"); - desc.append("缁存潈璁㈠崟浣i噾:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#"); - if (record.getExtraInfo().getOrderCount50More() > 0 - || record.getExtraInfo().getWeiQuanOrderCount() > 0 - || record.getExtraInfo().getWeiQuanOrderFanAmount().compareTo(new BigDecimal(10)) >= 0) - warnLevel = 2; - } else { - if (record.getExtraInfo().getOrderCount50More() > 0 - || record.getExtraInfo().getWeiQuanOrderCount() > 0 - || record.getExtraInfo().getWeiQuanOrderFanAmount().compareTo(new BigDecimal(0)) > 0) - warnLevel = 2; - desc.append("澶т簬50鍏冭鍗�:" + record.getExtraInfo().getOrderCount50More() + "\n#"); - desc.append("缁存潈璁㈠崟鏁�:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#"); - desc.append("缁存潈璁㈠崟閫�鍥為噾棰�:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#"); - desc.append("180澶╁畨鍏ㄨ鍗曟暟:" + record.getExtraInfo().getSafeOrderCount()); - } - - if (record.getExtraInfo().getLess10OrderCount() != null && record.getExtraInfo().getLess10OrderCount() > 10) { - desc.append("鍒峰崟瀚岀枒\n#"); - } - - record.setExtraInfoStr(desc.toString()); - } - + int count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, null, days); + int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; + PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); - // 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(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey()))); - // long sameShopOrderCount = - // commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList, - // record.getExtract().getUserInfo().getId(), - // Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameShopOrderCount.getKey()))); - // if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) { - // warnLevel = 3; - // record.setExtraInfoStr( - // String.format("鍚屽簵閾�:%s 鍚屽晢鍝�:%s", sameShopOrderCount, - // sameGoodsOrderCount)); - // } - // } + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.serializeNulls(); + gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss"); - record.setWarnLevel(warnLevel); - } + Gson gson = gsonBuilder.create(); - int count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, null, days); - int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; - PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); + JSONObject data = new JSONObject(); + data.put("pe", pe); + data.put("list", gson.toJson(auditList)); - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.serializeNulls(); - gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss"); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - Gson gson = gsonBuilder.create(); + } catch (Exception e) { + e.printStackTrace(); + out.print(JsonUtil.loadFalseResult(e.getMessage())); + } + } - JSONObject data = new JSONObject(); - data.put("pe", pe); - data.put("list", gson.toJson(auditList)); + @RequestMapping(value = "getMyAuditedDanger") + public void getMyAuditedDanger(AdminAcceptData acceptData, String callback, Long uid, PrintWriter out) { + if (uid == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇风櫥褰�")); + return; + } + // 鏌ヨ鍚屽簵閾哄晢鍝侊紝鍚屽晢鍝佽鍗曡秴杩囦竴瀹氭暟閲忕殑 + List<Integer> typeList = new ArrayList<>(); + typeList.add(HongBaoV2.TYPE_ZIGOU); + long sameGoodsOrderCount = commonOrderCountService.countSameGoodsOrderByUidAndHongBaoType(typeList, uid, + Integer.parseInt(configService.getValue(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey(), acceptData.getSystem()))); + long sameShopOrderCount = commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList, uid, + Integer.parseInt(configService.getValue(ConfigKeyEnum.adminMinSameShopOrderCount.getKey(), acceptData.getSystem()))); + if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) { + String text = (String.format("鍚屽簵閾�:%s 鍚屽晢鍝�:%s", sameShopOrderCount, sameGoodsOrderCount)); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(text)); + return; + } + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("搴楅摵/鍟嗗搧鏃犲紓甯�")); + } - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - - } catch (Exception e) { - e.printStackTrace(); - out.print(JsonUtil.loadFalseResult(e.getMessage())); - } - } + /** + * 鑾峰彇浠婃棩鎻愮幇璁板綍锛氫粖鏃ユ�婚銆佹�绘鏁般�佹垚鍔熸鏁般�佸け璐ユ鏁� 鑾峰彇绯荤粺鎻愮幇璁板綍锛氭�婚銆佹�绘鏁� + * + * @param out + */ + @RequestMapping(value = "getMyAuditedCount") + public void getMyAuditedCount(String callback, HttpServletRequest request, PrintWriter out) { - @RequestMapping(value = "getMyAuditedDanger") - public void getMyAuditedDanger(String callback, Long uid, PrintWriter out) { - if (uid == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇风櫥褰�")); - return; - } - // 鏌ヨ鍚屽簵閾哄晢鍝侊紝鍚屽晢鍝佽鍗曡秴杩囦竴瀹氭暟閲忕殑 - List<Integer> typeList = new ArrayList<>(); - typeList.add(HongBaoV2.TYPE_ZIGOU); - long sameGoodsOrderCount = commonOrderCountService.countSameGoodsOrderByUidAndHongBaoType(typeList, uid, - Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey()))); - long sameShopOrderCount = commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList, uid, - Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameShopOrderCount.getKey()))); - if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) { - String text = (String.format("鍚屽簵閾�:%s 鍚屽晢鍝�:%s", sameShopOrderCount, sameGoodsOrderCount)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(text)); - return; - } - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("搴楅摵/鍟嗗搧鏃犲紓甯�")); - } + AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); - /** - * 鑾峰彇浠婃棩鎻愮幇璁板綍锛氫粖鏃ユ�婚銆佹�绘鏁般�佹垚鍔熸鏁般�佸け璐ユ鏁� 鑾峰彇绯荤粺鎻愮幇璁板綍锛氭�婚銆佹�绘鏁� - * - * @param out - */ - @RequestMapping(value = "getMyAuditedCount") - public void getMyAuditedCount(String callback, HttpServletRequest request, PrintWriter out) { + if (admin == null) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄嗐��"))); + } else { + Long adminId = admin.getId(); - AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); + int taskToday = extractCountService.countTodayApply(); + // int countTodayComplete = extractService.countTodayComplete(); - if (admin == null) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄嗐��"))); - } else { - Long adminId = admin.getId(); + // 浠婃棩绱澶勭悊鏁版嵁 + int countToday = extractAuditRecordService.getMyAuditedCountToday(adminId); + // 鏈懆绱澶勭悊鏁版嵁 + int countWeek = extractAuditRecordService.getMyAuditedCountWeek(adminId); + // 鏈湀绱澶勭悊鏁版嵁 + int countMonth = extractAuditRecordService.getMyAuditedCountMonth(adminId); - int taskToday = extractCountService.countTodayApply(); - // int countTodayComplete = extractService.countTodayComplete(); + JSONObject data = new JSONObject(); + data.put("adminUser", admin); + data.put("taskToday", taskToday); + data.put("countToday", countToday); + data.put("countWeek", countWeek); + data.put("countMonth", countMonth); - // 浠婃棩绱澶勭悊鏁版嵁 - int countToday = extractAuditRecordService.getMyAuditedCountToday(adminId); - // 鏈懆绱澶勭悊鏁版嵁 - int countWeek = extractAuditRecordService.getMyAuditedCountWeek(adminId); - // 鏈湀绱澶勭悊鏁版嵁 - int countMonth = extractAuditRecordService.getMyAuditedCountMonth(adminId); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + } - JSONObject data = new JSONObject(); - data.put("adminUser", admin); - data.put("taskToday", taskToday); - data.put("countToday", countToday); - data.put("countWeek", countWeek); - data.put("countMonth", countMonth); + } - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - } + /** + * 瀹㈡湇浠诲姟椤甸潰灞曠ず鏁版嵁锛氫紶鍏ユ彁鐜扮敵璇穒d 鍒欐樉绀哄綋鍓嶇敵璇凤紝鑻ユ棤id鍒欐樉绀哄鏈嶄换鍔′笅绗竴涓敵璇锋暟鎹� + * + * @param callback + * @param extractId 鎻愮幇id + * @param request + * @param out + */ + @RequestMapping(value = "getIaskInfo") + public void getIaskInfo(String callback, Long extractId, HttpServletRequest request, PrintWriter out) { + try { - } + String surplusTime = ""; + JSONObject data = new JSONObject(); + Extract extract = new Extract(); + AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); + if (admin == null) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄嗐��"))); + return; + } - /** - * 瀹㈡湇浠诲姟椤甸潰灞曠ず鏁版嵁锛氫紶鍏ユ彁鐜扮敵璇穒d 鍒欐樉绀哄綋鍓嶇敵璇凤紝鑻ユ棤id鍒欐樉绀哄鏈嶄换鍔′笅绗竴涓敵璇锋暟鎹� - * - * @param callback - * @param extractId - * 鎻愮幇id - * @param request - * @param out - */ - @RequestMapping(value = "getIaskInfo") - public void getIaskInfo(String callback, Long extractId, HttpServletRequest request, PrintWriter out) { - try { + if (extractId != null) { + /* 浼犲叆鎻愮幇鐢宠id 鏌ヨ鍓嶅鏈嶄换鍔℃暟鎹� */ - String surplusTime = ""; - JSONObject data = new JSONObject(); - Extract extract = new Extract(); - AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); - if (admin == null) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄嗐��"))); - return; - } + extract = extractService.selectByPrimaryKey(extractId); + if (extract == null) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("褰撳墠鐢宠宸蹭笉瀛樺湪"))); + return; + } - if (extractId != null) { - /* 浼犲叆鎻愮幇鐢宠id 鏌ヨ鍓嶅鏈嶄换鍔℃暟鎹� */ + // 褰撳墠浠诲姟鎸囧畾涓鸿璐︽埛澶勭悊 + /* + * extract.setAdminId(admin.getId()); + * extractService.updateByPrimaryKeySelective(extract); + */ - extract = extractService.selectByPrimaryKey(extractId); - if (extract == null) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("褰撳墠鐢宠宸蹭笉瀛樺湪"))); - return; - } + BigDecimal beforeMoney = null; + List<ExtractAuditRecord> records = extractAuditRecordService.getbyExtractId(extract.getId()); + if (records != null && records.size() > 0) { + ExtractAuditRecord extractAuditRecord = records.get(0); + if (extractAuditRecord != null) { + beforeMoney = extractAuditRecord.getBeforeMoney(); + } + } - // 褰撳墠浠诲姟鎸囧畾涓鸿璐︽埛澶勭悊 - /* - * extract.setAdminId(admin.getId()); - * extractService.updateByPrimaryKeySelective(extract); - */ + Long extractTime = extract.getExtractTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(extractTime); + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.DAY_OF_MONTH, 3);// 浠婂ぉ+3澶� + Date todayTime = new Date(); + String formattodayTime = sdf.format(todayTime); + String formatTime = sdf.format(c.getTime()); - BigDecimal beforeMoney = null; - List<ExtractAuditRecord> records = extractAuditRecordService.getbyExtractId(extract.getId()); - if (records != null && records.size() > 0) { - ExtractAuditRecord extractAuditRecord = records.get(0); - if (extractAuditRecord != null) { - beforeMoney = extractAuditRecord.getBeforeMoney(); - } - } + long diff = sdf.parse(formatTime).getTime() - sdf.parse(formattodayTime).getTime(); + if (diff <= 0) { + surplusTime = "宸茶秴鏃�"; + } else { + surplusTime = DateUtil.dateDiff(formattodayTime, formatTime); + } - Long extractTime = extract.getExtractTime(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date date = new Date(extractTime); - Calendar c = Calendar.getInstance(); - c.setTime(date); - c.add(Calendar.DAY_OF_MONTH, 3);// 浠婂ぉ+3澶� - Date todayTime = new Date(); - String formattodayTime = sdf.format(todayTime); - String formatTime = sdf.format(c.getTime()); + String mark = ""; + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(extract.getUserInfo().getId()); + if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getMark())) { + mark = "璀︽儠锛侊紒 " + userInfoExtra.getMark(); + } - long diff = sdf.parse(formatTime).getTime() - sdf.parse(formattodayTime).getTime(); - if (diff <= 0) { - surplusTime = "宸茶秴鏃�"; - } else { - surplusTime = DateUtil.dateDiff(formattodayTime, formatTime); - } + Integer countOrder = commonOrderCountService.countOderByUidAndLess10(extract.getUserInfo().getId()); + if (countOrder != null && countOrder >= 10) { + if (StringUtil.isNullOrEmpty(mark)) { + mark = "鍒峰崟棰勮锛侊紒"; + } else { + mark = mark + " 鍒峰崟棰勮锛侊紒"; + } + } + data.put("mark", mark); + data.put("extract", extract); + data.put("beforeMoney", beforeMoney); + data.put("surplusTime", surplusTime); - String mark = ""; - UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(extract.getUserInfo().getId()); - if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getMark())) { - mark = "璀︽儠锛侊紒 " + userInfoExtra.getMark(); - } + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - Integer countOrder = commonOrderCountService.countOderByUidAndLess10(extract.getUserInfo().getId()); - if (countOrder != null && countOrder >= 10) { - if (StringUtil.isNullOrEmpty(mark)) { - mark = "鍒峰崟棰勮锛侊紒"; - } else { - mark = mark + " 鍒峰崟棰勮锛侊紒"; - } - } - data.put("mark", mark); - data.put("extract", extract); - data.put("beforeMoney", beforeMoney); - data.put("surplusTime", surplusTime); + } else { + /* 鏈紶鍏ユ彁鐜扮敵璇穒d 鏌ヨ褰撳墠瀹㈡湇浠诲姟 涓殑绗竴涓� 鏁版嵁 */ - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + boolean newTask = false; - } else { - /* 鏈紶鍏ユ彁鐜扮敵璇穒d 鏌ヨ褰撳墠瀹㈡湇浠诲姟 涓殑绗竴涓� 鏁版嵁 */ + // 鏌ヨ涔嬪墠鏈鐞嗗畬鐨勪换鍔� + extract = extractService.getMyTaskInfo(admin.getId()); - boolean newTask = false; + if (extract == null) { + // 鏂颁换鍔� + extract = extractService.getNewTaskInfo(); + if (extract != null) + newTask = true; + } - // 鏌ヨ涔嬪墠鏈鐞嗗畬鐨勪换鍔� - extract = extractService.getMyTaskInfo(admin.getId()); + if (extract == null) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏆傛棤鐢ㄦ埛鎻愮幇鐢宠"))); + } else { - if (extract == null) { - // 鏂颁换鍔� - extract = extractService.getNewTaskInfo(); - if (extract != null) - newTask = true; - } + if (newTask) { + // 褰撳墠浠诲姟鎸囧畾涓鸿璐︽埛澶勭悊 + /* + * extract.setAdminId(admin.getId()); + * + * extractService.updateByPrimaryKeySelective(extract); + */ + } - if (extract == null) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏆傛棤鐢ㄦ埛鎻愮幇鐢宠"))); - } else { + BigDecimal beforeMoney = null; - if (newTask) { - // 褰撳墠浠诲姟鎸囧畾涓鸿璐︽埛澶勭悊 - /* - * extract.setAdminId(admin.getId()); - * - * extractService.updateByPrimaryKeySelective(extract); - */ - } + List<ExtractAuditRecord> records = extractAuditRecordService.getbyExtractId(extract.getId()); + if (records != null && records.size() > 0) { + ExtractAuditRecord extractAuditRecord = records.get(0); + if (extractAuditRecord != null) { + beforeMoney = extractAuditRecord.getBeforeMoney(); + } + } - BigDecimal beforeMoney = null; + Long extractTime = extract.getExtractTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(extractTime); - List<ExtractAuditRecord> records = extractAuditRecordService.getbyExtractId(extract.getId()); - if (records != null && records.size() > 0) { - ExtractAuditRecord extractAuditRecord = records.get(0); - if (extractAuditRecord != null) { - beforeMoney = extractAuditRecord.getBeforeMoney(); - } - } + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.DAY_OF_MONTH, 3);// 浠婂ぉ+3澶� + Date todayTime = new Date(); - Long extractTime = extract.getExtractTime(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date date = new Date(extractTime); + String formattodayTime = sdf.format(todayTime); + String formatTime = sdf.format(c.getTime()); - Calendar c = Calendar.getInstance(); - c.setTime(date); - c.add(Calendar.DAY_OF_MONTH, 3);// 浠婂ぉ+3澶� - Date todayTime = new Date(); + long diff = sdf.parse(formatTime).getTime() - sdf.parse(formattodayTime).getTime(); + if (diff <= 0) { + surplusTime = "宸茶秴鏃�"; + } else { + surplusTime = DateUtil.dateDiff(formattodayTime, formatTime); + } - String formattodayTime = sdf.format(todayTime); - String formatTime = sdf.format(c.getTime()); + String mark = ""; + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(extract.getUserInfo().getId()); + if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getMark())) { + mark = "璀︽儠锛侊紒 " + userInfoExtra.getMark(); + } - long diff = sdf.parse(formatTime).getTime() - sdf.parse(formattodayTime).getTime(); - if (diff <= 0) { - surplusTime = "宸茶秴鏃�"; - } else { - surplusTime = DateUtil.dateDiff(formattodayTime, formatTime); - } + Integer countOrder = commonOrderCountService.countOderByUidAndLess10(extract.getUserInfo().getId()); + if (countOrder != null && countOrder >= 10) { + if (StringUtil.isNullOrEmpty(mark)) { + mark = "鍒峰崟棰勮锛侊紒"; + } else { + mark = mark + " 鍒峰崟棰勮锛侊紒"; + } + } - 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); - Integer countOrder = commonOrderCountService.countOderByUidAndLess10(extract.getUserInfo().getId()); - if (countOrder != null && countOrder >= 10) { - if (StringUtil.isNullOrEmpty(mark)) { - mark = "鍒峰崟棰勮锛侊紒"; - } else { - mark = mark + " 鍒峰崟棰勮锛侊紒"; - } - } - - data.put("mark", mark); - data.put("extract", extract); - data.put("beforeMoney", beforeMoney); - data.put("surplusTime", surplusTime); + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + } - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - } + } - } + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + } - } + /** + * 鏌ヨ鐢ㄦ埛鍘嗗彶鎻愮幇璁板綍 + * + * @param callback + * @param pageIndex 椤电爜 + * 鐢ㄦ埛id + * @param request + * @param out + */ + @RequestMapping(value = "getByUidList") + public void getByUidList(String callback, Integer pageIndex, Long uid, HttpServletRequest request, + PrintWriter out) { + try { + if (uid == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); + return; + } - /** - * 鏌ヨ鐢ㄦ埛鍘嗗彶鎻愮幇璁板綍 - * - * @param callback - * @param pageIndex - * 椤电爜 - * @param key - * 鐢ㄦ埛id - * @param request - * @param out - */ - @RequestMapping(value = "getByUidList") - public void getByUidList(String callback, Integer pageIndex, Long uid, HttpServletRequest request, - PrintWriter out) { - try { - if (uid == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); - return; - } + if (pageIndex == null) + pageIndex = 1; - if (pageIndex == null) - pageIndex = 1; + int pageSize = Constant.PAGE_SIZE; - int pageSize = Constant.PAGE_SIZE; + List<ExtractAuditRecord> list = extractAuditRecordService.getByUidList(pageIndex, pageSize, uid); + if (list == null || list.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鎻愮幇璁板綍")); + return; + } - List<ExtractAuditRecord> list = extractAuditRecordService.getByUidList(pageIndex, pageSize, uid); - if (list == null || list.size() == 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鎻愮幇璁板綍")); - return; - } + for (ExtractAuditRecord record : list) { - for (ExtractAuditRecord record : list) { + if (record.getExtraInfo() != null) { + StringBuffer desc = new StringBuffer(); + desc.append("澶т簬50鍏冭鍗�:" + record.getExtraInfo().getOrderCount50More() + "\n#"); + desc.append("缁存潈璁㈠崟鏁�:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#"); + desc.append("缁存潈璁㈠崟閫�鍥為噾棰�:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#"); + desc.append("180澶╁畨鍏ㄨ鍗曟暟:" + record.getExtraInfo().getSafeOrderCount()); + record.setExtraInfoStr(desc.toString()); + } + } - if (record.getExtraInfo() != null) { - StringBuffer desc = new StringBuffer(); - desc.append("澶т簬50鍏冭鍗�:" + record.getExtraInfo().getOrderCount50More() + "\n#"); - desc.append("缁存潈璁㈠崟鏁�:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#"); - desc.append("缁存潈璁㈠崟閫�鍥為噾棰�:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#"); - desc.append("180澶╁畨鍏ㄨ鍗曟暟:" + record.getExtraInfo().getSafeOrderCount()); - record.setExtraInfoStr(desc.toString()); - } - } + int count = extractAuditRecordService.getByUidCount(uid); + int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; + PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); - int count = extractAuditRecordService.getByUidCount(uid); - int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; - PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.serializeNulls(); // 閲嶇偣 + Gson gson = gsonBuilder.create(); - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.serializeNulls(); // 閲嶇偣 - Gson gson = gsonBuilder.create(); + JSONObject data = new JSONObject(); + data.put("pe", pe); + data.put("list", gson.toJson(list)); - JSONObject data = new JSONObject(); - data.put("pe", pe); - data.put("list", gson.toJson(list)); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + // TODO: handle exception + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } - } catch (Exception e) { - // TODO: handle exception - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); - e.printStackTrace(); - } - } + /** + * 鏁伴噺缁熻 + * + * @param callback + * @param uid 鐢ㄦ埛id + * @param request + * @param out + */ + @RequestMapping(value = "countByUid") + public void countByUid(String callback, Long uid, HttpServletRequest request, PrintWriter out) { - /** - * 鏁伴噺缁熻 - * - * @param callback - * @param uid - * 鐢ㄦ埛id - * @param request - * @param out - */ - @RequestMapping(value = "countByUid") - public void countByUid(String callback, Long uid, HttpServletRequest request, PrintWriter out) { + try { - try { + // 缁熻宸查鍙栭噾棰� 璐︽埛鍘嗗彶鎬绘敹鐩� + BigDecimal receiveMoneys = hongBaoV2CountService.countMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU); + if (receiveMoneys == null) { + receiveMoneys = new BigDecimal(0); + } - // 缁熻宸查鍙栭噾棰� 璐︽埛鍘嗗彶鎬绘敹鐩� - BigDecimal receiveMoneys = hongBaoV2CountService.countMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU); - if (receiveMoneys == null) { - receiveMoneys = new BigDecimal(0); - } + // 鍘嗗彶鎻愮幇鎴愬姛閲戦 + double successMoneys = extractCountService.countSuccessMoneysByUid(uid); - // 鍘嗗彶鎻愮幇鎴愬姛閲戦 - double successMoneys = extractCountService.countSuccessMoneysByUid(uid); + // 鍘嗗彶鎻愮幇鎬绘鏁般�佹垚鍔熸鏁般�佸け璐ユ鏁� + Map<String, Object> map = extractCountService.countRecordsByUid(uid); - // 鍘嗗彶鎻愮幇鎬绘鏁般�佹垚鍔熸鏁般�佸け璐ユ鏁� - Map<String, Object> map = extractCountService.countRecordsByUid(uid); + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.serializeNulls(); + Gson gson = gsonBuilder.create(); - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.serializeNulls(); - Gson gson = gsonBuilder.create(); + JSONObject data = new JSONObject(); + data.put("map", gson.toJson(map)); + data.put("successMoneys", gson.toJson(successMoneys)); + data.put("receiveMoneys", gson.toJson(receiveMoneys)); - JSONObject data = new JSONObject(); - data.put("map", gson.toJson(map)); - data.put("successMoneys", gson.toJson(successMoneys)); - data.put("receiveMoneys", gson.toJson(receiveMoneys)); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); - e.printStackTrace(); - } - } + /** + * 鏍¢獙鐢ㄦ埛璧勯噾鏄惁寮傚父 + * + * @param uid + * @param out + */ + @RequestMapping(value = "checkMoney") + public void checkMoney(String callback, String uid, PrintWriter out) { - /** - * 鏍¢獙鐢ㄦ埛璧勯噾鏄惁寮傚父 - * - * @param uid - * @param out - */ - @RequestMapping(value = "checkMoney") - public void checkMoney(String callback, String uid, PrintWriter out) { + if (StringUtil.isNullOrEmpty(uid)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("UID涓嶈兘涓虹┖")); + return; + } - if (StringUtil.isNullOrEmpty(uid)) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("UID涓嶈兘涓虹┖")); - return; - } + try { + extractService.checkExtract(Long.parseLong(uid)); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("璧勯噾姝e父")); + } catch (ExtractException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); + } + } - try { - extractService.checkExtract(Long.parseLong(uid)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("璧勯噾姝e父")); - } catch (ExtractException e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); - } - } + /** + * 涓嬭浇鎻愮幇绾㈠寘Openid + * + * @param callback + * @param response + * @param out + */ + @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; + } - /** - * 涓嬭浇鎻愮幇绾㈠寘Openid - * - * @param callback - * @param response - * @param out - */ - @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") + "\""); - 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"); + } - 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); + } - 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(); + } + } - 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(); - } - } + /** + * 涓婁紶鎻愮幇绾㈠寘Excel + * + * @param file + * @param out + */ + @RequestMapping(value = "uploadExcel", method = RequestMethod.POST) + public void uploadExcel(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) { + if (file == null) { + out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓嶈兘涓虹┖锛�")); + return; + } - /** - * 涓婁紶鎻愮幇绾㈠寘Excel - * - * @param file - * @param out - */ - @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 = WXRedPackUtil.readCsv(file.getInputStream()); + 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("涓婁紶澶辫触")); + } + } - try { - List<RedPackRecord> list = WXRedPackUtil.readCsv(file.getInputStream()); - 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("涓婁紶澶辫触")); - } - } - - public static String getValue(String[] item,int index){ - if(item.length > index){ + public static String getValue(String[] item, int index) { + if (item.length > index) { String value = item[index]; return value; } return ""; } - - /** - * 棰勮绾㈠寘鍙戠敓浜� - * - * @param callback - * @param pageIndex - * @param out - */ - @RequestMapping(value = "preAutoUser") - public void preAutoUser(String callback, Integer pageIndex, 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; - } + /** + * 棰勮绾㈠寘鍙戠敓浜� + * + * @param callback + * @param pageIndex + * @param out + */ + @RequestMapping(value = "preAutoUser") + public void preAutoUser(String callback, Integer pageIndex, PrintWriter out) { + try { + List<UserInfo> list = extractService.preAutoUser(); + if (list == null || list.isEmpty()) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鐢ㄦ埛婊¤冻鑷姩鎻愮幇鏉′欢")); + return; + } - Integer pageSize = 100; - if (pageSize == null || pageSize < 1) { - pageSize = Constant.PAGE_SIZE; - } + if (pageIndex == null || pageIndex < 1) { + pageIndex = 1; + } - int count = list.size(); - int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; - PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); + Integer pageSize = 100; + if (pageSize == null || pageSize < 1) { + pageSize = Constant.PAGE_SIZE; + } - 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; - } + int count = list.size(); + int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; + PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); - 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(); - } - } + 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