From ad3ac53da1c3a11a96ae62d790aa61a81b9eab91 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 20 三月 2021 18:47:23 +0800 Subject: [PATCH] 完善APP首页顶部标签栏兼容,初步处理推送 --- src/main/java/com/yeshi/buwan/controller/api/VIPController.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/controller/api/VIPController.java b/src/main/java/com/yeshi/buwan/controller/api/VIPController.java index c912480..2ff98fc 100644 --- a/src/main/java/com/yeshi/buwan/controller/api/VIPController.java +++ b/src/main/java/com/yeshi/buwan/controller/api/VIPController.java @@ -1,6 +1,7 @@ package com.yeshi.buwan.controller.api; import com.google.gson.*; +import com.yeshi.buwan.domain.system.SystemConfig; import com.yeshi.buwan.domain.user.LoginUser; import com.yeshi.buwan.domain.vip.UserVIPInfo; import com.yeshi.buwan.domain.vip.VIPOrderRecord; @@ -8,6 +9,7 @@ import com.yeshi.buwan.domain.vip.VIPPriceType; import com.yeshi.buwan.exception.vip.VIPException; import com.yeshi.buwan.service.inter.LoginUserService; +import com.yeshi.buwan.service.inter.system.SystemConfigService; import com.yeshi.buwan.service.inter.vip.VIPPriceService; import com.yeshi.buwan.service.inter.vip.VIPService; import com.yeshi.buwan.util.*; @@ -26,6 +28,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.lang.reflect.Type; +import java.util.Date; import java.util.List; import java.util.UUID; @@ -46,6 +49,9 @@ @Resource private VIPPriceService vipPriceService; + + @Resource + private SystemConfigService systemConfigService; @RequestMapping("getVIPPriceList") @@ -72,6 +78,11 @@ userInfoVO.setId(user.getId()); userInfoVO.setNickName(user.getName()); userInfoVO.setPortrait(user.getPortrait()); + if (StringUtil.isNullOrEmpty(userInfoVO.getPortrait())) { + String portrait = systemConfigService.getConfigValueByKeyCache("default_portrait"); + userInfoVO.setPortrait(portrait); + } + if (vipInfo != null && vipInfo.getExpireDate() != null) userInfoVO.setVipExpireTime(vipInfo.getExpireDate().getTime()); root.put("user", new Gson().toJson(userInfoVO)); @@ -79,6 +90,42 @@ List<VIPPrice> vipPriceList = vipPriceService.listValidPrice(); root.put("list", gson.toJson(vipPriceList)); + return JsonUtilV2.loadTrueJson(root.toString()); + } + + + @RequestMapping("getVIPOrderList") + @ResponseBody + public String getVIPOrderList(AcceptData acceptData, String loginUid, int page) { + Gson gson = new GsonBuilder().registerTypeAdapter(VIPPriceType.class, new JsonSerializer<VIPPriceType>() { + @Override + public JsonElement serialize(VIPPriceType value, Type theType, JsonSerializationContext context) { + if (value == null) { + return new JsonPrimitive(""); + } else { + return new JsonPrimitive(value.getName()); + } + } + }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() { + @Override + public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { + if (value == null) { + return new JsonPrimitive(""); + } else { + return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy.MM.dd HH:mm")); + } + } + }).create(); + JSONObject root = new JSONObject(); + + List<VIPOrderRecord> list = vipService.listOrderRecord(loginUid, null, page, Constant.pageCount); + for (VIPOrderRecord record : list) { + record.setIpInfo(null); + record.setUpdateTime(null); + } + long count = vipService.countOrderRecord(loginUid, null); + root.put("list", gson.toJson(list)); + root.put("count", count); return JsonUtilV2.loadTrueJson(root.toString()); } @@ -116,9 +163,10 @@ VIPOrderRecord record = new VIPOrderRecord(); record.setUid(loginUid); record.setType(vipPrice.getType()); - record.setMoney(vipPrice.getPrice()); + record.setMoney(vipPrice.getActualPrice()); record.setPayWay(payWay); record.setState(VIPOrderRecord.STATE_NOT_PAY); + record.setIpInfo(IPUtil.getRemotIP(request) + ":" + IPUtil.getRemotePort(request)); try { vipService.addVIPRecord(record); } catch (VIPException e) { @@ -146,7 +194,7 @@ .PAY_WAY_WX: { //鐢熸垚寰俊鏀粯璁㈠崟 try { - String payUrl = VipUtil.createWXOrder(record.getId(), ip, orderNo, vipPrice.getPrice(), "褰辫澶у叏VIP-" + vipPrice.getType().getName()); + String payUrl = VipUtil.createWXOrder(record.getId(), ip, orderNo, vipPrice.getActualPrice(), "褰辫澶у叏VIP-" + vipPrice.getType().getName()); org.json.JSONObject data = new org.json.JSONObject(); data.put("payUrl", payUrl); data.put("payWay", payWay); -- Gitblit v1.8.0