| | |
| | | package com.yeshi.buwan.controller.admin.api; |
| | | |
| | | import com.google.gson.*; |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.domain.vip.OrderRecord; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.order.OrderService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.vo.vip.UserVIPInfoVO; |
| | | import com.yeshi.buwan.web.tag.PageEntity; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.PrintWriter; |
| | | import java.lang.reflect.Type; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | @Resource |
| | | private LoginUserService loginUserService; |
| | | |
| | | private Gson getGson() { |
| | | |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/vipUserList", method = RequestMethod.POST) |
| | | public String vipUserList(Boolean vip,String uid, int page) { |
| | | public void vipUserList(Boolean vip, String uid, int page, PrintWriter out) { |
| | | Date minDate = null; |
| | | Date maxDate = null; |
| | | if (vip != null) { |
| | |
| | | maxDate = new Date(); |
| | | } |
| | | } |
| | | List<UserVIPInfo> list = new ArrayList<>(); |
| | | long count = 0; |
| | | if (!StringUtil.isNullOrEmpty(uid)) { |
| | | UserVIPInfo vipInfo = vipService.getVIPInfo(uid); |
| | | if (vipInfo != null) { |
| | | list.add(vipInfo); |
| | | count = 1; |
| | | } |
| | | } else { |
| | | list = vipService.listVIPUser(minDate, maxDate, page, Constant.pageCount); |
| | | count = vipService.countVIPUser(minDate, maxDate); |
| | | } |
| | | |
| | | List<UserVIPInfo> list = vipService.listVIPUser(minDate, maxDate, page, Constant.pageCount); |
| | | long count = vipService.countVIPUser(minDate, maxDate); |
| | | List<UserVIPInfoVO> voList = new ArrayList<>(); |
| | | for (UserVIPInfo vipInfo : list) { |
| | | UserVIPInfoVO vo = new UserVIPInfoVO(); |
| | | vo.setCreateTime(vipInfo.getCreateTime()); |
| | | vo.setExpireDate(vipInfo.getExpireDate()); |
| | | vo.setUpdateTime(vipInfo.getUpdateTime()); |
| | | LoginUser loginUser = loginUserService.getLoginUser(vipInfo.getUid()); |
| | | vo.setUser(loginUser); |
| | | voList.add(vo); |
| | | } |
| | | |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pageEntity", new PageEntity(page, Constant.pageCount,(int)count)); |
| | | data.put("list", getGson().toJson(list)); |
| | | return JsonUtil.loadTrueResult(data); |
| | | data.put("pageEntity", new PageEntity(page, Constant.pageCount, (int) count)); |
| | | data.put("list", getGson().toJson(voList)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/vipOrderList", method = RequestMethod.POST) |
| | | public String vipOrderList(Boolean pay, String uid, int page) { |
| | | public void vipOrderList(Boolean pay, String uid, int page, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(uid)) { |
| | | uid = null; |
| | | } |
| | | Integer state = null; |
| | | if (pay != null) { |
| | | if (pay) { |
| | | state = VIPOrderRecord.STATE_PAY; |
| | | state = OrderRecord.STATE_PAY; |
| | | } else { |
| | | state = VIPOrderRecord.STATE_NOT_PAY; |
| | | state = OrderRecord.STATE_NOT_PAY; |
| | | } |
| | | } |
| | | |
| | | List<VIPOrderRecord> list = vipService.listOrderRecord(uid, state, page, Constant.pageCount); |
| | | long count = vipService.countOrderRecord(uid, state); |
| | | List<OrderRecord> list = orderService.listOrderRecord(uid,null, state, page, Constant.pageCount); |
| | | long count = orderService.countOrderRecord(uid,null, state); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pageEntity", new PageEntity(page, Constant.pageCount,(int)count)); |
| | | data.put("pageEntity", new PageEntity(page, Constant.pageCount, (int) count)); |
| | | data.put("list", getGson().toJson(list)); |
| | | return JsonUtil.loadTrueResult(data); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | |