| | |
| | | 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; |
| | |
| | | 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.*; |
| | |
| | | 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; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private VIPPriceService vipPriceService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | |
| | | @RequestMapping("getVIPPriceList") |
| | |
| | | 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)); |
| | |
| | | |
| | | 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()); |
| | | } |
| | | |
| | |
| | | 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) { |
| | |
| | | .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); |