From fe646416d8d46de7b896ddbf65a3ad0cd30b729b Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 15 七月 2020 16:05:56 +0800 Subject: [PATCH] 大淘客与好单库与主包剥离 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java | 220 ++++++++++++------------------------------------------ 1 files changed, 51 insertions(+), 169 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java index 699c8a2..8a4ea22 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java @@ -1,29 +1,28 @@ package com.yeshi.fanli.controller.admin; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.List; -import java.util.Map; import javax.annotation.Resource; +import com.yeshi.fanli.entity.accept.AdminAcceptData; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.yeshi.fanli.controller.admin.utils.AdminUtils; -import com.yeshi.fanli.dto.ChartTDO; +import com.yeshi.fanli.entity.bus.user.UserSystemCoupon; import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord; +import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; import com.yeshi.fanli.service.inter.count.UserSystemCouponCountService; import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.vo.user.SystemCouponVO; import com.yeshi.fanli.vo.user.UserSystemCouponCountVO; -import net.sf.json.JSONArray; import net.sf.json.JSONObject; @Controller @@ -49,8 +48,8 @@ * @param out */ @RequestMapping(value = "listRebateCoupon") - public void listRebateCoupon(String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, - Integer state, Integer percent, PrintWriter out) { + public void listRebateCoupon(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, + Integer state, Integer percent, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { pageIndex = 1; @@ -91,7 +90,7 @@ } @RequestMapping(value = "listSystemRebateCoupon") - public void listSystemRebateCoupon(String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, + public void listSystemRebateCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { @@ -133,7 +132,7 @@ } @RequestMapping(value = "listSystemFreeCoupon") - public void listSystemFreeCoupon(String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, + public void listSystemFreeCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { @@ -187,7 +186,7 @@ * @param out */ @RequestMapping(value = "listFreeCoupon") - public void listFreeCoupon(String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, + public void listFreeCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, Integer state, Integer activated, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { @@ -241,7 +240,7 @@ * @param out */ @RequestMapping(value = "listFreeCouponRecord") - public void listFreeCouponRecord(String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, + public void listFreeCouponRecord(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, Integer state, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { @@ -295,7 +294,7 @@ * @param out */ @RequestMapping(value = "listGiveCoupon") - public void listGiveCoupon(String callback, Integer pageIndex, Integer pageSize, String key, Integer type, + public void listGiveCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer type, Integer state, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { @@ -342,174 +341,57 @@ e.printStackTrace(); } } - + /** - * 濂栧姳鍒告暟閲忔洸绾垮浘 + * 鍒哥粺璁� * @param callback - * @param dateType - * @param year - * @param startTime - * @param endTime + * @param uid * @param out */ - @RequestMapping(value = "getRebateCouponUsedNumCharts") - public void getRebateCouponUsedNumCharts(String callback, Integer dateType, String year, String startTime, - String endTime, PrintWriter out){ + @RequestMapping(value = "statisticsCoupon") + public void statisticsCoupon(AdminAcceptData acceptData,String callback, Long uid, PrintWriter out) { try { - String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime); - if (validateMsg != null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg)); - return; - } - JSONObject data = getChartsData(dateType, year, startTime, endTime, 1, null); + List<String> listSource = new ArrayList<>(); + listSource.add(UserSystemCoupon.SOURCE_EXCHANGE); + + // 鍏嶅崟鍒� + List<String> listFree = new ArrayList<>(); + listFree.add(CouponTypeEnum.freeCoupon.name()); + listFree.add(CouponTypeEnum.welfareFreeCoupon.name()); + listFree.add(CouponTypeEnum.freeCouponBuy.name()); + listFree.add(CouponTypeEnum.freeCouponGive.name()); + // 绱-閲戝竵鍏戞崲 + long freeTotal = userSystemCouponCountService.countCouponNum(uid, null, null, listFree,listSource); + // 浣跨敤涓� + long freeUseIn = userSystemCouponCountService.countCouponNum(uid, UserSystemCoupon.STATE_IN_USE, null, listFree, null); + // 鍓╀綑 + long freeUseCan = userSystemCouponCountService.countCouponNum(uid, UserSystemCoupon.STATE_CAN_USE, null, listFree, null); + long freeUseActive = userSystemCouponCountService.countCouponNum(uid, 0, 0, listFree, null); + + // 濂栧姳鍒� + listFree.clear(); + listFree.add(CouponTypeEnum.rebatePercentCoupon.name()); + // 绱-閲戝竵鍏戞崲 + long rebateTotal = userSystemCouponCountService.countCouponNum(uid, null, null, listFree, listSource); + // 浣跨敤涓� + long rebateUseIn = userSystemCouponCountService.countCouponNum(uid, UserSystemCoupon.STATE_IN_USE, null, listFree, null); + // 鍓╀綑 + long rebateUseCan = userSystemCouponCountService.countCouponNum(uid, UserSystemCoupon.STATE_CAN_USE, null, listFree, null); + + JSONObject data = new JSONObject(); + data.put("freeTotal", freeTotal); + data.put("freeUseIn", freeUseIn); + data.put("freeLeft", freeUseCan + freeUseActive); + data.put("rebateTotal", rebateTotal); + data.put("rebateUseIn", rebateUseIn); + data.put("rebateLeft", rebateUseCan); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); e.printStackTrace(); } } - - /** - * 濂栧姳鍒告暟閲忔洸绾垮浘 - * @param callback - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getRebateCouponMoneyCharts") - public void getRebateCouponMoneyCharts(String callback, Integer dateType, String year, String startTime, - String endTime, PrintWriter out){ - try { - String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime); - if (validateMsg != null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg)); - return; - } - JSONObject data = getChartsData(dateType, year, startTime, endTime, 2, null); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - /** - * 濂栧姳鍒告暟閲忔洸绾垮浘 - * @param callback - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getFreeCouponMoneyCharts") - public void getFreeCouponMoneyCharts(String callback, Integer dateType, String year, String startTime, - String endTime, Integer coupon, PrintWriter out){ - try { - if (coupon == null || (coupon.intValue() < 0 && coupon.intValue() > 4)) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒哥被鍨嬩笉姝g‘")); - return; - } - - String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime); - if (validateMsg != null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg)); - return; - } - - String couponType = null; - if (coupon == 1) { - couponType = "freeCoupon"; - } else if (coupon == 2){ - couponType = "welfareFreeCoupon"; - } else if (coupon == 3){ - couponType = "freeCouponBuy"; - } - - JSONObject data = getChartsData(dateType, year, startTime, endTime, 3, couponType); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - public JSONObject getChartsData(Integer dateType, String year, String startTime, - String endTime, int source, String couponType) throws Exception { - if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) { - startTime = null; - endTime = null; - } - 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; - } - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - - JSONObject innerList = new JSONObject(); - List<ChartTDO> list = null; - if (source == 1) { - // 濂栧姳鍒告暟閲� - innerList.put("name", "鏁伴噺"); - list = userSystemCouponCountService.getRebateCouponUsedNumToCharts(dateType, year, - startTime, endTime); - } else if (source == 2) { - // 濂栧姳鍒搁噾棰� - innerList.put("name", "閲戦"); - list = userSystemCouponCountService.getRebateCouponMoneyToCharts(dateType, year, - startTime, endTime); - } else if (source == 3) { - // 濂栧姳鍒搁噾棰� - innerList.put("name", "閲戦"); - list = userSystemCouponCountService.getFreeCouponMoneyToCharts(dateType, year, - startTime, endTime, couponType); - } - - Object objectDate = null; - 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"))); - } - - JSONArray line_list = new JSONArray(); - 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); - return data; - } } -- Gitblit v1.8.0