无关风月
2024-12-31 0c51a577db337520452022d9d6a22b720ef858d4
xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/VipSettingController.java
@@ -1,19 +1,19 @@
package com.xinquan.system.controller;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.xinquan.common.core.domain.R;
import com.xinquan.system.domain.ContentSetting;
import com.xinquan.system.domain.HotWords;
import com.xinquan.system.domain.VipSetting;
import com.xinquan.system.domain.dto.AggrementDto;
import com.xinquan.system.domain.dto.VipSettingDTO;
import com.xinquan.system.service.VipSettingService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.omg.CORBA.PRIVATE_MEMBER;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -30,29 +30,110 @@
public class VipSettingController {
    @Resource
    private VipSettingService vipSettingService;
    @PostMapping("/queryVip")
    @ApiOperation(value = "获取会员价格设置", tags = {"管理后台-会员设置"})
    public R<VipSettingDTO> queryVip() {
        VipSettingDTO vipSettingDTO = new VipSettingDTO();
        VipSetting one = vipSettingService.lambdaQuery()
                .eq(VipSetting::getSettingType, 1)
                .eq(VipSetting::getClientType,1).one();
        VipSetting two = vipSettingService.lambdaQuery()
                .eq(VipSetting::getSettingType, 1)
                .eq(VipSetting::getClientType,2).one();
        if (one!=null){
            vipSettingDTO.setMonthlyVip(one.getMonthlyVip());
            vipSettingDTO.setQuarterlyVip(one.getQuarterlyVip());
            vipSettingDTO.setAnnualVip(one.getAnnualVip());
        }
        if (two!=null){
            vipSettingDTO.setMonthlyVipIos(one.getMonthlyVip());
            vipSettingDTO.setQuarterlyVipIos(one.getQuarterlyVip());
            vipSettingDTO.setAnnualVipIos(one.getAnnualVip());
        }
        return R.ok(vipSettingDTO);
    }
    @PostMapping("/saveVip")
    @ApiOperation(value = "保存会员价格设置", tags = {"管理后台-会员设置"})
    public R<VipSetting> saveVip(@RequestBody VipSettingDTO dto) {
        VipSetting one = vipSettingService.lambdaQuery()
                .eq(VipSetting::getSettingType, 1)
                .eq(VipSetting::getClientType,1).one();
        VipSetting two = vipSettingService.lambdaQuery()
                .eq(VipSetting::getSettingType, 1)
                .eq(VipSetting::getClientType,2).one();
        if (one == null){
            one = new VipSetting();
            one.setSettingType(1);
            one.setClientType(1);
            one.setMonthlyVip(dto.getMonthlyVip());
            one.setQuarterlyVip(dto.getQuarterlyVip());
            one.setAnnualVip(dto.getAnnualVip());
            vipSettingService.saveOrUpdate(one);
        }else{
            one.setMonthlyVip(dto.getMonthlyVip());
            one.setQuarterlyVip(dto.getQuarterlyVip());
            one.setAnnualVip(dto.getAnnualVip());
            vipSettingService.saveOrUpdate(one);
        }
        if (two == null){
            two = new VipSetting();
            two.setSettingType(1);
            two.setClientType(2);
            two.setMonthlyVip(dto.getMonthlyVipIos());
            two.setQuarterlyVip(dto.getQuarterlyVipIos());
            two.setAnnualVip(dto.getAnnualVipIos());
            vipSettingService.saveOrUpdate(two);
        }else{
            two.setMonthlyVip(dto.getMonthlyVipIos());
            two.setQuarterlyVip(dto.getQuarterlyVipIos());
            two.setAnnualVip(dto.getAnnualVipIos());
            vipSettingService.saveOrUpdate(two);
        }
        return R.ok();
    }
    @PostMapping("/updateVipContent")
    @ApiOperation(value = "修改会员权益介绍/获取会员用户协议/获取续费管理说明",tags = "管理后台-会员设置")
    public R updateVipContent(@RequestBody AggrementDto dto) {
        VipSetting one = vipSettingService.lambdaQuery()
                .eq(VipSetting::getSettingType, dto.getType()+1).one();
        if (one == null){
            one = new VipSetting();
        }
        one.setSettingType(dto.getType()+1);
        one.setContent(dto.getContent());
        vipSettingService.saveOrUpdate(one);
        return R.ok();
    }
    @PostMapping("/getVipPrice")
    @ApiOperation(value = "安卓-获取月度 季度 年度会员价格",tags = "会员")
    @ApiOperation(value = "安卓-获取月度 季度 年度会员价格",tags = "APP-会员")
    public R<VipSetting> getVipPrice() {
        VipSetting one = vipSettingService.lambdaQuery().eq(VipSetting::getClientType, 1)
                .eq(VipSetting::getSettingType, 1).one();
        return R.ok(one);
    }
    @PostMapping("/getVipPriceApple")
    @ApiOperation(value = "苹果-获取月度 季度 年度会员价格",tags = "会员")
    @ApiOperation(value = "苹果-获取月度 季度 年度会员价格",tags = "APP-会员")
    public R<VipSetting> getVipPriceApple() {
        VipSetting one = vipSettingService.lambdaQuery().eq(VipSetting::getClientType, 2)
                .eq(VipSetting::getSettingType, 1).one();
        return R.ok(one);
    }
    @PostMapping("/getVipContent")
    @ApiOperation(value = "获取会员权益介绍/获取会员用户协议/获取续费管理说明",tags = "会员")
    @ApiOperation(value = "获取会员权益介绍/获取会员用户协议/获取续费管理说明",tags = "管理后台-会员设置")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "内容类型 1=会员权益介绍 2=会员用户协议 3=续费管理说明", name = "type", required = true, dataType = "int"),
    })
    public R<String> getVipPriceApple(Integer type) {
        VipSetting one = vipSettingService.lambdaQuery()
                .eq(VipSetting::getSettingType, type+1).one();
        if (one == null){
            return R.ok("");
        }
        return R.ok(one.getContent());
    }
}