| | |
| | | package com.yeshi.fanli.controller.admin;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | 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.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.common.entity.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.vo.user.SystemCouponVO;
|
| | | import com.yeshi.fanli.vo.user.UserSystemCouponCountVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/userCoupon")
|
| | | public class UserSystemCouponAdminController {
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponCountService userSystemCouponCountService;
|
| | | |
| | | @Resource
|
| | | private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService;
|
| | |
|
| | | /**
|
| | | * 用户奖励券列表
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key
|
| | | * @param keyType 1-用户id、 2来源
|
| | | * @param state
|
| | | * @param percent
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "listRebateCoupon")
|
| | | 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;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | | List<UserSystemCouponCountVO> list = userSystemCouponCountService
|
| | | .listRebateCoupon((pageIndex - 1) * pageSize, pageSize, key, keyType, state, percent);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = userSystemCouponCountService.countRebateCoupon(key, keyType, state, percent);
|
| | |
|
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "listSystemRebateCoupon")
|
| | | public void listSystemRebateCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer sort,
|
| | | PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | | List<SystemCouponVO> list = userSystemCouponCountService
|
| | | .listSystemCouponByRebate((pageIndex - 1) * pageSize, pageSize, key, sort);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = userSystemCouponCountService.countSystemCouponRebate(key);
|
| | |
|
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "listSystemFreeCoupon")
|
| | | public void listSystemFreeCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer sort,
|
| | | PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | | List<SystemCouponVO> list = userSystemCouponCountService.listSystemCouponByFree((pageIndex - 1) * pageSize,
|
| | | pageSize, key, sort);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = list.size();
|
| | |
|
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户奖励券列表
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key
|
| | | * @param keyType 1-用户id、 2来源
|
| | | * @param state
|
| | | * @param percent
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "listFreeCoupon")
|
| | | 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) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | | List<UserSystemCouponCountVO> list = userSystemCouponCountService.listFreeCoupon((pageIndex - 1) * pageSize,
|
| | | pageSize, key, keyType, state, activated);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = userSystemCouponCountService.countFreeCoupon(key, keyType, state, activated);
|
| | |
|
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户奖励券列表
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key
|
| | | * @param keyType 1-用户id、 2来源
|
| | | * @param state
|
| | | * @param percent
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "listFreeCouponRecord")
|
| | | public void listFreeCouponRecord(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType,
|
| | | Integer state, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | | List<UserSystemCouponCountVO> list = userSystemCouponCountService
|
| | | .listFreeCouponRecord((pageIndex - 1) * pageSize, pageSize, key, keyType, state);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = userSystemCouponCountService.countFreeCouponRecord(key, keyType, state);
|
| | |
|
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 查询赠送免券
|
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key
|
| | | * @param type 1赠送免单券 、2-奖励券
|
| | | * @param state
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "listGiveCoupon")
|
| | | public void listGiveCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer type,
|
| | | Integer state, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | | |
| | | String couponType = null;
|
| | | if (type != null) {
|
| | | if (type == 1) {
|
| | | couponType = "freeCouponGive";
|
| | | } else if (type == 2){
|
| | | couponType = "rebatePercentCoupon";
|
| | | } |
| | | }
|
| | |
|
| | | try {
|
| | | List<UserSystemCouponGiveRecord> list = userSystemCouponGiveRecordService.listGiveRecord((pageIndex - 1) * pageSize,
|
| | | pageSize, couponType, state);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = userSystemCouponGiveRecordService.countGiveRecord(couponType, state);
|
| | |
|
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 券统计
|
| | | * @param callback
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "statisticsCoupon")
|
| | | public void statisticsCoupon(AdminAcceptData acceptData,String callback, Long uid, PrintWriter out) {
|
| | | try {
|
| | | 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("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.admin; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | 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.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.common.entity.PageEntity; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.vo.user.SystemCouponVO; |
| | | import com.yeshi.fanli.vo.user.UserSystemCouponCountVO; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/v1/userCoupon") |
| | | public class UserSystemCouponAdminController { |
| | | |
| | | @Resource |
| | | private UserSystemCouponCountService userSystemCouponCountService; |
| | | |
| | | @Resource |
| | | private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService; |
| | | |
| | | /** |
| | | * 用户奖励券列表 |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param key |
| | | * @param keyType 1-用户id、 2来源 |
| | | * @param state |
| | | * @param percent |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "listRebateCoupon") |
| | | 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; |
| | | } |
| | | |
| | | if (pageSize == null || pageSize < 1) { |
| | | pageSize = Constant.PAGE_SIZE; |
| | | } |
| | | |
| | | try { |
| | | List<UserSystemCouponCountVO> list = userSystemCouponCountService |
| | | .listRebateCoupon((pageIndex - 1) * pageSize, pageSize, key, keyType, state, percent); |
| | | |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | long count = userSystemCouponCountService.countRebateCoupon(key, keyType, state, percent); |
| | | |
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(list)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "listSystemRebateCoupon") |
| | | public void listSystemRebateCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, |
| | | PrintWriter out) { |
| | | |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (pageSize == null || pageSize < 1) { |
| | | pageSize = Constant.PAGE_SIZE; |
| | | } |
| | | |
| | | try { |
| | | List<SystemCouponVO> list = userSystemCouponCountService |
| | | .listSystemCouponByRebate((pageIndex - 1) * pageSize, pageSize, key, sort); |
| | | |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | long count = userSystemCouponCountService.countSystemCouponRebate(key); |
| | | |
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(list)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "listSystemFreeCoupon") |
| | | public void listSystemFreeCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, |
| | | PrintWriter out) { |
| | | |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (pageSize == null || pageSize < 1) { |
| | | pageSize = Constant.PAGE_SIZE; |
| | | } |
| | | |
| | | try { |
| | | List<SystemCouponVO> list = userSystemCouponCountService.listSystemCouponByFree((pageIndex - 1) * pageSize, |
| | | pageSize, key, sort); |
| | | |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | long count = list.size(); |
| | | |
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(list)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 用户奖励券列表 |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param key |
| | | * @param keyType 1-用户id、 2来源 |
| | | * @param state |
| | | * @param percent |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "listFreeCoupon") |
| | | 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) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (pageSize == null || pageSize < 1) { |
| | | pageSize = Constant.PAGE_SIZE; |
| | | } |
| | | |
| | | try { |
| | | List<UserSystemCouponCountVO> list = userSystemCouponCountService.listFreeCoupon((pageIndex - 1) * pageSize, |
| | | pageSize, key, keyType, state, activated); |
| | | |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | long count = userSystemCouponCountService.countFreeCoupon(key, keyType, state, activated); |
| | | |
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(list)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 用户奖励券列表 |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param key |
| | | * @param keyType 1-用户id、 2来源 |
| | | * @param state |
| | | * @param percent |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "listFreeCouponRecord") |
| | | public void listFreeCouponRecord(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, |
| | | Integer state, PrintWriter out) { |
| | | |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (pageSize == null || pageSize < 1) { |
| | | pageSize = Constant.PAGE_SIZE; |
| | | } |
| | | |
| | | try { |
| | | List<UserSystemCouponCountVO> list = userSystemCouponCountService |
| | | .listFreeCouponRecord((pageIndex - 1) * pageSize, pageSize, key, keyType, state); |
| | | |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | long count = userSystemCouponCountService.countFreeCouponRecord(key, keyType, state); |
| | | |
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(list)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询赠送免券 |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param key |
| | | * @param type 1赠送免单券 、2-奖励券 |
| | | * @param state |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "listGiveCoupon") |
| | | public void listGiveCoupon(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Integer type, |
| | | Integer state, PrintWriter out) { |
| | | |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (pageSize == null || pageSize < 1) { |
| | | pageSize = Constant.PAGE_SIZE; |
| | | } |
| | | |
| | | String couponType = null; |
| | | if (type != null) { |
| | | if (type == 1) { |
| | | couponType = "freeCouponGive"; |
| | | } else if (type == 2){ |
| | | couponType = "rebatePercentCoupon"; |
| | | } |
| | | } |
| | | |
| | | try { |
| | | List<UserSystemCouponGiveRecord> list = userSystemCouponGiveRecordService.listGiveRecord((pageIndex - 1) * pageSize, |
| | | pageSize, couponType, state); |
| | | |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | long count = userSystemCouponGiveRecordService.countGiveRecord(couponType, state); |
| | | |
| | | int totalPage = (int) (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.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(list)); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 券统计 |
| | | * @param callback |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "statisticsCoupon") |
| | | public void statisticsCoupon(AdminAcceptData acceptData,String callback, Long uid, PrintWriter out) { |
| | | try { |
| | | 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("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |