xuhy
2023-05-12 4ff5f35054ab141d915c11ad878d4dcffe7e034a
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
package com.stylefeng.guns.modular.system.controller.general;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.TSystemConfig;
import com.stylefeng.guns.modular.system.service.ITSystemConfigService;
 
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
 
/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2023-03-02 17:09:55
 */
@Controller
@RequestMapping("/tSystemConfig")
public class TSystemConfigController extends BaseController {
 
    private String PREFIX = "/system/tSystemConfig/";
 
    @Autowired
    private ITSystemConfigService tSystemConfigService;
 
    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "tSystemConfig.html";
    }
 
    /**
     * 跳转到添加
     */
    @RequestMapping("/tSystemConfig_add")
    public String tSystemConfigAdd() {
        return PREFIX + "tSystemConfig_add.html";
    }
 
    /**
     * 跳转到修改
     */
    @RequestMapping("/tSystemConfig_update/{tSystemConfigId}")
    public String tSystemConfigUpdate(@PathVariable Integer tSystemConfigId, Model model) {
        TSystemConfig tSystemConfig = tSystemConfigService.selectById(tSystemConfigId);
        model.addAttribute("item",tSystemConfig);
        LogObjectHolder.me().set(tSystemConfig);
        return PREFIX + "tSystemConfig_edit.html";
    }
 
    /**
     * 跳转到派单规则
     */
    @RequestMapping("/dispatchRules")
    public String dispatchRules(Model model) {
        TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 1)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
        model.addAttribute("num1",jsonObject.getInteger("num1"));
        model.addAttribute("num2",jsonObject.getInteger("num2"));
        model.addAttribute("num3",jsonObject.getInteger("num3"));
        model.addAttribute("num4",jsonObject.getInteger("num4"));
        model.addAttribute("num5",jsonObject.getInteger("num5"));
        return PREFIX + "tSystemConfigDispatchRules.html";
    }
 
    /**
     * 跳转到佣金分成规则
     */
    @RequestMapping("/commissionShareRules")
    public String commissionShareRules(Model model) {
        TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 2)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
        model.addAttribute("num1",jsonObject.getString("num1"));
        model.addAttribute("num2",jsonObject.getString("num2"));
        model.addAttribute("num3",jsonObject.getString("num3"));
        model.addAttribute("num4",jsonObject.getString("num4"));
        model.addAttribute("num5",jsonObject.getString("num5"));
        model.addAttribute("num6",jsonObject.getString("num6"));
        model.addAttribute("num7",jsonObject.getString("num7"));
        return PREFIX + "tSystemConfigCommissionShareRules.html";
    }
 
    /**
     * 跳转到抽成规则
     */
    @RequestMapping("/extractionRules")
    public String extractionRules(Model model) {
        TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 3)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
        model.addAttribute("num1",jsonObject.getInteger("num1"));
        model.addAttribute("num2",jsonObject.getInteger("num2"));
        model.addAttribute("num3",jsonObject.getInteger("num3"));
        return PREFIX + "tSystemConfigExtractionRules.html";
    }
    /**
     * 跳转到积分规则
     */
    @RequestMapping("/integralRules")
    public String integralRules(Model model) {
        TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 4)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
        model.addAttribute("num1",jsonObject.getString("num1"));
        model.addAttribute("num2",jsonObject.getString("num2"));
        model.addAttribute("num3",jsonObject.getInteger("num3"));
        model.addAttribute("num4",jsonObject.getInteger("num4"));
        model.addAttribute("num5",jsonObject.getInteger("num5"));
        model.addAttribute("num6",jsonObject.getInteger("num6"));
        model.addAttribute("num7",jsonObject.getInteger("num7"));
        model.addAttribute("num8",jsonObject.getInteger("num8"));
        model.addAttribute("num9",jsonObject.getInteger("num9"));
        model.addAttribute("num10",jsonObject.getInteger("num10"));
        return PREFIX + "tSystemConfigIntegralRules.html";
    }
 
    /**
     * 跳转到价格规则
     */
    @RequestMapping("/priceRules")
    public String priceRules(Model model) {
        TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 5)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
        JSONArray array = jsonObject.getJSONArray("ChargeStandard");
        JSONArray objects = new JSONArray();
        for (int i = 0; i < array.size(); i++) {
            JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(array.get(i)));
            if(i == 0){
                jsonObject1.put("key",0);
            }else {
                jsonObject1.put("key",1);
            }
            objects.add(jsonObject1);
        }
 
        TSystemConfig config = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 8)
                .last("LIMIT 1"));
        JSONObject jsonObj = JSONObject.parseObject(config.getContent());
        Integer zcOne = jsonObj.getInteger("num1");
        model.addAttribute("zcOne",zcOne);
        model.addAttribute("array",objects);
        JSONObject extraCost = JSONObject.parseObject(jsonObject.getString("ExtraCost"));
        model.addAttribute("ExtraCost",extraCost);
        return PREFIX + "tSystemConfigPriceRules.html";
    }
    /**
     * 跳转到余额规则
     */
    @RequestMapping("/balanceRules")
    public String balanceRules(Model model) {
        TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 6)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
        model.addAttribute("num1",jsonObject.getInteger("num1"));
        model.addAttribute("num2",jsonObject.getInteger("num2"));
        return PREFIX + "tSystemConfigBalanceRules.html";
    }
    /**
     * 跳转到客服管理
     */
    @RequestMapping("/serviceMgmt")
    public String serviceMgmt(Model model) {
        TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 7)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
        model.addAttribute("num1",jsonObject.getString("num1"));
        return PREFIX + "tSystemConfigServiceMgmt.html";
    }
 
 
    /**
     * 获取列表
     */
    @RequestMapping(value = "/systemConfigSubmit")
    @ResponseBody
    public Object systemConfigSubmit(Integer type,String content) {
 
        TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", type)
                .last("LIMIT 1"));
 
        System.err.println(content);
 
        tSystemConfig.setContent(content);
 
        return tSystemConfigService.updateById(tSystemConfig);
    }
    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return tSystemConfigService.selectList(null);
    }
 
    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TSystemConfig tSystemConfig) {
        tSystemConfigService.insert(tSystemConfig);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tSystemConfigId) {
        tSystemConfigService.deleteById(tSystemConfigId);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TSystemConfig tSystemConfig) {
        tSystemConfigService.updateById(tSystemConfig);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改价格规则开关
     */
    @RequestMapping(value = "/openOrClose")
    @ResponseBody
    public Object openOrClose(Integer num1) {
        TSystemConfig config = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 8)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(config.getContent());
        jsonObject.remove(jsonObject.getString("num1"));
        jsonObject.put("num1",num1);
        config.setContent(JSONObject.toJSONString(jsonObject));
        tSystemConfigService.updateById(config);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改启动页状态
     */
    @RequestMapping(value = "/updateStartState")
    @ResponseBody
    public Object updateStartState(Integer num2) {
        TSystemConfig config = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 8)
                .last("LIMIT 1"));
        JSONObject jsonObject = JSONObject.parseObject(config.getContent());
        jsonObject.remove(jsonObject.getString("num2"));
        jsonObject.put("num2",num2);
        config.setContent(JSONObject.toJSONString(jsonObject));
        tSystemConfigService.updateById(config);
        return SUCCESS_TIP;
    }
 
    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{tSystemConfigId}")
    @ResponseBody
    public Object detail(@PathVariable("tSystemConfigId") Integer tSystemConfigId) {
        return tSystemConfigService.selectById(tSystemConfigId);
    }
}