admin
2021-04-08 d7a3014c38dbb1061cba70e7dbb49d58831e6399
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);