xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
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
package com.stylefeng.guns.modular.system.controller.general;
 
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.model.MerchantCoupon;
import com.stylefeng.guns.modular.system.service.IMerchantCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
 
 
/**
 * 商家卷/商家商品卷控制层
 */
@Controller
@RequestMapping("/merchantCoupon")
public class MerchantCouponController extends BaseController {
 
    private String PREFIX = "/system/merchantCoupon/";
 
    @Autowired
    private IMerchantCouponService merchantCouponService;
 
 
    /**
     * 跳转商家卷管理列表
     *
     * @return
     */
    @RequestMapping("/index")
    public String index() {
        return PREFIX + "merchantCoupon.html";
    }
 
    /**
     * @param startTime
     * @param endTime
     * @param merchantName 商家名
     * @param name         商家卷名
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public Object list(String startTime, String endTime, String merchantName, String name, Integer type) {
 
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        List<Map<String, Object>> list = merchantCouponService.list(startTime, endTime, merchantName, name, type, page);
        page.setRecords(list);
        return super.packForBT(page);
    }
 
    /**
     * 跳转到添加商家卷添加
     *
     * @param model
     * @return
     */
    @RequestMapping("/merchantCoupon_add/{type}")
    public String openMerchantCouponAdd(@PathVariable Integer type, Model model) {
 
        /*查询商家列表*/
        List<Map<String, Object>> list = merchantCouponService.getMerchantList();
        model.addAttribute("item", list);
        model.addAttribute("type", type);
 
        return PREFIX + "merchantCoupon_add.html";
    }
 
 
    /**
     * 添加商家券
     *
     * @param coupon
     * @return
     */
    @RequestMapping("/add")
    @ResponseBody
    public Object add(MerchantCoupon coupon) {
 
        if (SinataUtil.isNotEmpty(coupon.getContent())) {
            coupon.setContent(ToolUtil.cleanXSS(coupon.getContent()));
        }
        coupon.setCreateTime(new Date());
        coupon.setState(1);
        merchantCouponService.insert(coupon);
 
        return SUCCESS_TIP;
    }
 
    @RequestMapping("/merchantCoupon_update")
    public String openMerchantCouponUpdate(Integer type, Integer id, Model model) {
 
        MerchantCoupon merchantCoupon = merchantCouponService.selectById(id);
        model.addAttribute("item", merchantCoupon);
 
        List<Map<String, Object>> list = merchantCouponService.getMerchantList();
        model.addAttribute("merchantList", list);
        model.addAttribute("type", type);
 
        return PREFIX + "merchantCoupon_edit.html";
    }
 
    /**
     * 编辑商家卷信息
     *
     * @param coupon
     * @return
     */
    @RequestMapping("/update")
    @ResponseBody
    public Object update(MerchantCoupon coupon) {
 
        if (SinataUtil.isNotEmpty(coupon.getContent())) {
            coupon.setContent(ToolUtil.cleanXSS(coupon.getContent()));
        }
        merchantCouponService.updateById(coupon);
 
        return SUCCESS_TIP;
    }
 
    /**
     * 编辑商家卷信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/remove")
    @ResponseBody
    public Object remove(Integer id) {
 
        MerchantCoupon merchantCoupon = merchantCouponService.selectById(id);
 
        if (ToolUtil.isNotEmpty(merchantCoupon)) {
            merchantCoupon.setState(3);
            merchantCouponService.updateById(merchantCoupon);
        }
        return SUCCESS_TIP;
    }
 
 
    @RequestMapping("/merchandiseCouponIndex")
    public String merchandiseCouponIndex() {
        return PREFIX + "merchandiseCoupon.html";
    }
 
}