puzhibing
2024-01-03 168d852672f8f671a01d6f0f053349d0d321ec7c
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
package com.dsh.guns.modular.system.controller.code;
 
 
 
import com.dsh.course.feignClient.account.model.CityManager;
import com.dsh.course.feignClient.account.model.TStoreStaff;
import com.dsh.course.feignClient.activity.model.QueryBodySideAppointmentVO;
import com.dsh.course.feignClient.other.StoreValueConfigClient;
import com.dsh.guns.config.UserExt;
import com.dsh.guns.modular.system.model.Store;
import com.dsh.guns.modular.system.model.StoredValueConfig;
import com.dsh.guns.modular.system.util.ResultUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
/**
 * 储值规则配置控制器
 */
 
@Controller
@RequestMapping("/storeValueConfig")
public class TStoredValueConfigController {
    private String PREFIX = "/system/storeValueConfig/";
    @Autowired
    private StoreValueConfigClient storeValueConfigClient;
    /**
     * 跳转储值管理页面
     */
    @RequestMapping("")
    public String index(Model model) {
        StoredValueConfig storeValueConfig = storeValueConfigClient.getStoreValueConfig();
 
        model.addAttribute("description",storeValueConfig.getDescription());
        // 解析json串 获取时间
        JSONObject jsonObject = new JSONObject(storeValueConfig.getContent());
        JSONArray timeRulesArray = jsonObject.getJSONArray("time_rules");
        model.addAttribute("content",jsonObject.toString());
        if (timeRulesArray.length() > 0) {
            JSONObject timeRule = timeRulesArray.getJSONObject(0);
            String startTime = timeRule.getString("startTime");
            String endTime = timeRule.getString("endTime");
            model.addAttribute("time",startTime+" - " + endTime);
            System.out.println("StartTime: " + startTime);
            System.out.println("EndTime: " + endTime);
        }
        return PREFIX + "StoreValueConfig.html";
    }
    /**
     *  添加储值规则
     */
    @ResponseBody
    @RequestMapping(value = "/addStoreValueConfig")
    public ResultUtil addStoreValueConfig(@RequestBody StoredValueConfig storedValueConfig) {
        storeValueConfigClient.addStoreValueConfig(storedValueConfig);
        return  ResultUtil.success();
    }
}