nickchange
2023-11-14 a1d261d6c92c38d9e496e11d1bc224ecc1d34798
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
package com.dsh.guns.modular.system.controller.code;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.course.feignClient.activity.CouponClient;
import com.dsh.course.feignClient.activity.model.Coupon;
import com.dsh.course.feignClient.activity.model.CouponExamineListSearch;
import com.dsh.course.feignClient.activity.model.CouponListOfSearch;
import com.dsh.guns.core.base.controller.BaseController;
import com.dsh.guns.core.common.constant.factory.PageFactory;
import com.dsh.guns.core.exception.GunsException;
import com.dsh.guns.core.util.ToolUtil;
import com.dsh.guns.modular.system.model.TOperator;
import com.dsh.guns.modular.system.model.TStore;
import com.dsh.guns.modular.system.model.User;
import com.dsh.guns.modular.system.service.IStoreService;
import com.dsh.guns.modular.system.service.IUserService;
import com.dsh.guns.modular.system.service.TOperatorService;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
 
/**
 * 优惠券审核 控制器
 */
 
@Controller
@RequestMapping("/tCouponExamine")
public class TCouponExamineController extends BaseController {
 
 
    private String PREFIX = "/system/tCouponExamine/";
 
    @Resource
    private CouponClient client;
    @Autowired
    private IUserService userService;
    @Autowired
    private TOperatorService operatorService;
    @Autowired
    private IStoreService storeService;
 
    /**
     * 优惠券审核列表页
     */
    @RequestMapping("")
    public String index(Model model) {
        return PREFIX + "TCouponExamineList.html";
    }
 
 
    /**
     * 获取根据门店id 获取店长信息
     */
    @RequestMapping(value = "/getStoreInfo")
    @ResponseBody
    public String getStoreInfo(@RequestBody Integer id) {
        User byId = userService.getById(id);
        return byId.getName() + "-" + byId.getAccount();
    }
    /**
     * 获取 优惠券审核列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object listOfDatas(String name, Integer type, Integer distributionMethod , Integer userPopulation, Integer auditStatus) {
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        CouponExamineListSearch ofSearch = new CouponExamineListSearch();
        ofSearch.setPage(page);
        ofSearch.setName(name);
        ofSearch.setType(type);
        ofSearch.setDistributionMethod(distributionMethod);
        ofSearch.setUserPopulation(userPopulation);
        ofSearch.setAuditStatus(auditStatus);
        List<Map<String, Object>> res = client.getCouponExamineListOfSearch(ofSearch);
        for (Map<String, Object> re : res) {
            if (re.get("publisherType")!=null){
 
            }
            switch (Integer.valueOf(re.get("publisherType").toString())){
                case 1:
                    // 运营商添加
                    if (re.get("cityManagerId")!=null){
                        TOperator one = operatorService.getOne(new QueryWrapper<TOperator>()
                                .eq("id", Integer.valueOf(re.get("cityManagerId").toString())));
                        if (one!=null){
                            User id = userService.getOne(new QueryWrapper<User>().eq("id", one.getUserId()));
                            if (id!=null){
                                re.put("account",one.getName()+"-"+id.getPhone());
                            }
                        }
                    }
                    break;
                case 2:
                    re.put("account","平台");
                    // 平台添加
                    break;
                case 3:
                    // 门店添加
                    if (re.get("cityManagerId")!=null){
                        TStore one = storeService.getOne(new QueryWrapper<TStore>()
                                .eq("id", Integer.valueOf(re.get("cityManagerId").toString())));
                        if (one!=null){
                            User id = userService.getOne(new QueryWrapper<User>().eq("id", one.getStoreStaffId()));
                            if (id!=null){
                                re.put("account",one.getName()+"-"+id.getPhone());
                            }
                        }
                    }
                    break;
            }
        }
        return res;
    }
 
    /**
     * 获取 优惠券审核详情
     */
    @RequestMapping(value = "/couponOfDetail/{id}")
    public String detailOfCoupon(@PathVariable Integer id, Model model){
        Map<String, Object> stringObjectMap = client.queryCouponExamineDetail(id);
        model.addAttribute(stringObjectMap);
        return PREFIX + "TCouponExamineInfo.html";
    }
 
 
    /**
     * 获取 优惠券审核详情
     */
    @RequestMapping(value = "/couponExaminePage/{id}")
    public String couponExaminePage(@PathVariable Integer id, Model model){
        model.addAttribute("id",id);
        return PREFIX + "TCouponExamine.html";
    }
 
 
 
    @RequestMapping(value = "/examine")
    @ResponseBody
    public Object examine(Integer id, Integer state, String remark) {
        Coupon coupon = client.queryCouponById(id);
        try {
            if (state == 2) {
                coupon.setAuditStatus(2);
            }
            if (state == 3) {
                coupon.setAuditStatus(3);
                coupon.setAuditRemark(remark);
            }
            client.updateCouponData(coupon);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
}