无关风月
2025-01-22 99367ea1c11a68b420936e7f7db5fa7367da4f44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package com.xinquan.system.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.xinquan.common.core.domain.R;
import com.xinquan.common.log.annotation.Log;
import com.xinquan.common.log.enums.BusinessType;
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.*;
 
import javax.annotation.Resource;
 
/**
 * <p>
 * 会员设置表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-08-21
 */
@RestController
@RequestMapping("/system/vip-setting")
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 = {"管理后台-会员设置"})
    @Log(title = "【会员设置】修改会员设置", businessType = BusinessType.UPDATE)
    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 = "管理后台-会员设置")
    @Log(title = "【会员设置】修改会员富文本内容设置", businessType = BusinessType.UPDATE)
 
    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 = "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 = "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 = "管理后台-会员设置")
    @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());
    }
 
}