Pu Zhibing
1 天以前 d0d6f8f40e5d9762d940b47c566da1876361020e
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
package com.stylefeng.guns.modular.system.controller.checkCar;
 
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.exception.GunsException;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.modular.system.controller.util.UploadUtil;
import com.stylefeng.guns.modular.system.model.TBranchOffice;
import com.stylefeng.guns.modular.system.model.TBranchOfficeArea;
import com.stylefeng.guns.modular.system.model.TRegion;
import com.stylefeng.guns.modular.system.service.ITBranchOfficeAreaService;
import com.stylefeng.guns.modular.system.service.ITBranchOfficeService;
import com.stylefeng.guns.modular.system.service.ITRegionService;
import com.stylefeng.guns.modular.system.util.OssUploadUtil;
import com.stylefeng.guns.modular.system.util.wxutils.WeChatUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
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.TCheckCarActivity;
import com.stylefeng.guns.modular.system.service.ITCheckCarActivityService;
 
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 代检车活动控制器
 *
 * @author fengshuonan
 * @Date 2025-08-02 18:21:14
 */
@Slf4j
@Controller
@RequestMapping("/tCheckCarActivity")
public class TCheckCarActivityController extends BaseController {
 
    private String PREFIX = "/system/tCheckCarActivity/";
 
    @Autowired
    private ITCheckCarActivityService tCheckCarActivityService;
 
    @Autowired
    private ITBranchOfficeService branchOfficeService;
 
    @Autowired
    private ITBranchOfficeAreaService branchOfficeAreaService;
 
    @Autowired
    private ITRegionService regionService;
 
    @Autowired
    private WeChatUtil weChatUtil;
 
    @Value("wx.conf.secret")
    private String secret;
 
    @Value("wx.conf.appId")
    private String appId;
 
 
    /**
     * 跳转到代检车活动首页
     */
    @RequestMapping("")
    public String index(Model model) {
        // 查询当前帐号的省市区
        Integer objectId = ShiroKit.getUser().getObjectId();
        Integer roleType = ShiroKit.getUser().getRoleType();
        TBranchOffice tBranchOffice = branchOfficeService.selectById(objectId);
        if (roleType == 1) {
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>());
            if (CollectionUtils.isEmpty(branchOfficeAreaList)) {
                model.addAttribute("branchOfficeAreaList", new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item -> {
                item.setActivityAreaCode(item.getProvinceCode() + "-" + item.getCityCode() + "-" + item.getAreaCode());
            });
            model.addAttribute("branchOfficeAreaList", branchOfficeAreaList);
            model.addAttribute("roleType", roleType);
            return PREFIX + "tCheckCarActivity_audit.html";
        } else {
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>()
                    .eq("branchOfficeId", tBranchOffice.getId()));
            if (CollectionUtils.isEmpty(branchOfficeAreaList)) {
                model.addAttribute("branchOfficeAreaList", new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item -> {
                item.setActivityAreaCode(item.getProvinceCode() + "-" + item.getCityCode() + "-" + item.getAreaCode());
            });
            model.addAttribute("roleType", roleType);
            model.addAttribute("branchOfficeAreaList", branchOfficeAreaList);
            return PREFIX + "tCheckCarActivity.html";
        }
    }
 
    /**
     * 跳转到添加代检车活动
     */
    @RequestMapping("/tCheckCarActivity_add")
    public String tCheckCarActivityAdd(Model model) {
        // 查询当前帐号的省市区
        Integer objectId = ShiroKit.getUser().getObjectId();
        Integer roleType = ShiroKit.getUser().getRoleType();
        if(roleType == 1){
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>());
            if(CollectionUtils.isEmpty(branchOfficeAreaList)){
                model.addAttribute("provinceList",new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item->{
                item.setActivityAreaCode(item.getProvinceCode()+"-"+item.getCityCode()+"-"+item.getAreaCode());
            });
            branchOfficeAreaList = branchOfficeAreaList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                    new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getProvinceCode))),ArrayList::new));
            model.addAttribute("provinceList",branchOfficeAreaList);
        }else {
            TBranchOffice tBranchOffice = branchOfficeService.selectById(objectId);
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>()
                    .eq("branchOfficeId",tBranchOffice.getId()));
            if(CollectionUtils.isEmpty(branchOfficeAreaList)){
                model.addAttribute("provinceList",new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item->{
                item.setActivityAreaCode(item.getProvinceCode()+"-"+item.getCityCode()+"-"+item.getAreaCode());
            });
            branchOfficeAreaList = branchOfficeAreaList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                    new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getProvinceCode))),ArrayList::new));
            model.addAttribute("provinceList",branchOfficeAreaList);
        }
        return PREFIX + "tCheckCarActivity_add.html";
    }
 
    /**
     * 跳转到修改代检车活动
     */
    @RequestMapping("/tCheckCarActivity_update/{tCheckCarActivityId}")
    public String tCheckCarActivityUpdate(@PathVariable Integer tCheckCarActivityId, Model model) {
        TCheckCarActivity tCheckCarActivity = tCheckCarActivityService.selectById(tCheckCarActivityId);
        String timeRange = DateUtil.format(tCheckCarActivity.getStartTime(), DatePattern.NORM_DATE_FORMAT) + " - " +
                DateUtil.format(tCheckCarActivity.getEndTime(), DatePattern.NORM_DATE_FORMAT);
        tCheckCarActivity.setTimeRange(timeRange);
        // 查询当前帐号的省市区
        Integer objectId = ShiroKit.getUser().getObjectId();
        Integer roleType = ShiroKit.getUser().getRoleType();
        if(roleType == 1){
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>());
            if(CollectionUtils.isEmpty(branchOfficeAreaList)){
                model.addAttribute("provinceList",new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item->{
                item.setActivityAreaCode(item.getProvinceCode()+"-"+item.getCityCode()+"-"+item.getAreaCode());
            });
            branchOfficeAreaList = branchOfficeAreaList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                    new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getProvinceCode))),ArrayList::new));
            model.addAttribute("provinceList", branchOfficeAreaList);
 
        }else {
            TBranchOffice tBranchOffice = branchOfficeService.selectById(objectId);
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>()
                    .eq("branchOfficeId",tBranchOffice.getId()));
            if(CollectionUtils.isEmpty(branchOfficeAreaList)){
                model.addAttribute("provinceList",new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item->{
                item.setActivityAreaCode(item.getProvinceCode()+"-"+item.getCityCode()+"-"+item.getAreaCode());
            });
            branchOfficeAreaList = branchOfficeAreaList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                    new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getProvinceCode))),ArrayList::new));
            model.addAttribute("provinceList",branchOfficeAreaList);
        }
        List<TBranchOfficeArea> cityList = getBranchOfficeByProvinceCode(tCheckCarActivity.getProvinceCode(), objectId, roleType);
        List<TBranchOfficeArea> areaList = getBranchOfficeByCityCode(tCheckCarActivity.getCityCode(), objectId, roleType);
        model.addAttribute("cityList", cityList);
        model.addAttribute("areaList", areaList);
        model.addAttribute("item",tCheckCarActivity);
        LogObjectHolder.me().set(tCheckCarActivity);
        return PREFIX + "tCheckCarActivity_edit.html";
    }
 
    /**
     * 根据省份编码获取代检车活动区域
     * @param provinceCode
     * @param objectId
     * @param roleType
     * @return
     */
    private List<TBranchOfficeArea> getBranchOfficeByProvinceCode(String provinceCode, Integer objectId, Integer roleType) {
        List<TBranchOfficeArea> list = new ArrayList<>();
        if (SinataUtil.isNotEmpty(provinceCode)) {
            EntityWrapper<TBranchOfficeArea> wrapper = new EntityWrapper<>();
            wrapper.eq("provinceCode", provinceCode);
            if (roleType == 2) {
                wrapper.eq("branchOfficeId", objectId);
            }
            list = branchOfficeAreaService.selectList(wrapper);
        }
        list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getCityCode))), ArrayList::new));
        return list;
    }
 
    /**
     * 根据城市编码获取代检车活动区域
     * @param cityCode
     * @param objectId
     * @param roleType
     * @return
     */
    private List<TBranchOfficeArea> getBranchOfficeByCityCode(String cityCode, Integer objectId, Integer roleType) {
        List<TBranchOfficeArea> list = new ArrayList<>();
        if (SinataUtil.isNotEmpty(cityCode)) {
            EntityWrapper<TBranchOfficeArea> wrapper = new EntityWrapper<>();
            wrapper.eq("cityCode", cityCode);
            if (roleType == 2) {
                wrapper.eq("branchOfficeId", objectId);
            }
            list = branchOfficeAreaService.selectList(wrapper);
        }
        list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getAreaCode))), ArrayList::new));
        return list;
    }
    /**
     * 跳转到详情代检车活动
     */
    @RequestMapping("/tCheckCarActivity_detail/{tCheckCarActivityId}")
    public String tCheckCarActivityDetail(@PathVariable Integer tCheckCarActivityId, Model model) {
        TCheckCarActivity tCheckCarActivity = tCheckCarActivityService.selectById(tCheckCarActivityId);
        String timeRange = DateUtil.format(tCheckCarActivity.getStartTime(), DatePattern.NORM_DATE_FORMAT) + " - " +
                DateUtil.format(tCheckCarActivity.getEndTime(), DatePattern.NORM_DATE_FORMAT);
        tCheckCarActivity.setTimeRange(timeRange);
        if (tCheckCarActivity.getAuditStatus().equals(1)) {
            //判断是否开始
            Date now = new Date();
            if (tCheckCarActivity.getStartTime() != null && tCheckCarActivity.getStartTime().after(now)) {
                tCheckCarActivity.setActivityStatus(0); // 未开始
            } else if (tCheckCarActivity.getEndTime() != null && tCheckCarActivity.getEndTime().before(now)) {
                tCheckCarActivity.setActivityStatus(2); // 已结束
            } else if (tCheckCarActivity.getPauseFlag() != null && tCheckCarActivity.getPauseFlag().equals(1) &&
                    tCheckCarActivity.getStartTime() != null && tCheckCarActivity.getStartTime().before(now) &&
                    tCheckCarActivity.getEndTime() != null && tCheckCarActivity.getEndTime().after(now)) {
                tCheckCarActivity.setActivityStatus(3); // 已暂停
            } else if (tCheckCarActivity.getStartTime() != null && tCheckCarActivity.getStartTime().before(now) &&
                    tCheckCarActivity.getEndTime() != null && tCheckCarActivity.getEndTime().after(now)) {
                tCheckCarActivity.setActivityStatus(1); // 进行中
            }else {
                tCheckCarActivity.setActivityStatus(0); // 未开始
            }
        }
        //格式化审核时间
        if (Objects.nonNull(tCheckCarActivity.getAuditTime())) {
            tCheckCarActivity.setAuditTimeFormat(DateUtil.format(tCheckCarActivity.getAuditTime(), DatePattern.NORM_DATETIME_FORMAT));
        }
        // 查询当前帐号的省市区
        Integer objectId = ShiroKit.getUser().getObjectId();
        Integer roleType = ShiroKit.getUser().getRoleType();
        if(roleType == 1){
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>());
            if(CollectionUtils.isEmpty(branchOfficeAreaList)){
                model.addAttribute("provinceList",new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item->{
                item.setActivityAreaCode(item.getProvinceCode()+"-"+item.getCityCode()+"-"+item.getAreaCode());
            });
            branchOfficeAreaList = branchOfficeAreaList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                    new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getProvinceCode))),ArrayList::new));
            model.addAttribute("provinceList",branchOfficeAreaList);
        }else {
            TBranchOffice tBranchOffice = branchOfficeService.selectById(objectId);
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>()
                    .eq("branchOfficeId",tBranchOffice.getId()));
            if(CollectionUtils.isEmpty(branchOfficeAreaList)){
                model.addAttribute("provinceList",new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item->{
                item.setActivityAreaCode(item.getProvinceCode()+"-"+item.getCityCode()+"-"+item.getAreaCode());
            });
            branchOfficeAreaList = branchOfficeAreaList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                    new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getProvinceCode))),ArrayList::new));
            model.addAttribute("provinceList",branchOfficeAreaList);
        }
        List<TBranchOfficeArea> cityList = getBranchOfficeByProvinceCode(tCheckCarActivity.getProvinceCode(), objectId, roleType);
        List<TBranchOfficeArea> areaList = getBranchOfficeByCityCode(tCheckCarActivity.getCityCode(), objectId, roleType);
        model.addAttribute("cityList", cityList);
        model.addAttribute("areaList", areaList);
        model.addAttribute("item",tCheckCarActivity);
        LogObjectHolder.me().set(tCheckCarActivity);
        return PREFIX + "tCheckCarActivity_detail.html";
    }
 
    /**
     * 获取代检车活动列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String createTime,String branchOfficeName,String name,
                       String activityAreaCode,Integer status) {
        return super.packForBT(tCheckCarActivityService.getOrderList(createTime,branchOfficeName,name,activityAreaCode,status));
    }
 
    /**
     * 新增代检车活动
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TCheckCarActivity tCheckCarActivity) {
        tCheckCarActivity.setBranchOfficeId(ShiroKit.getUser().getObjectId());
        tCheckCarActivity.setCreateBy(ShiroKit.getUser().getName());
        TRegion distinct = regionService.selectOne(new EntityWrapper<TRegion>().eq("code", tCheckCarActivity.getDistrictCode()));
        if (distinct != null) {
            tCheckCarActivity.setDistrictName(distinct.getName());
            //查询城市
            TRegion city = regionService.selectOne(new EntityWrapper<TRegion>().eq("id", distinct.getParentId()));
            if (city != null) {
                tCheckCarActivity.setCityName(city.getName());
                //查询省份
                TRegion province = regionService.selectOne(new EntityWrapper<TRegion>().eq("id", city.getParentId()));
                if (province != null) {
                    tCheckCarActivity.setProvinceName(province.getName());
                }
            }
        }
        tCheckCarActivityService.insert(tCheckCarActivity);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除代检车活动
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tCheckCarActivityId) {
        tCheckCarActivityService.deleteById(tCheckCarActivityId);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改代检车活动
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TCheckCarActivity tCheckCarActivity) {
        tCheckCarActivity.setUpdateBy(ShiroKit.getUser().getName());
        TRegion distinct = regionService.selectOne(new EntityWrapper<TRegion>().eq("code", tCheckCarActivity.getDistrictCode()));
        if (distinct != null) {
            tCheckCarActivity.setDistrictName(distinct.getName());
            //查询城市
            TRegion city = regionService.selectOne(new EntityWrapper<TRegion>().eq("id", distinct.getParentId()));
            if (city != null) {
                tCheckCarActivity.setCityName(city.getName());
                //查询省份
                TRegion province = regionService.selectOne(new EntityWrapper<TRegion>().eq("id", city.getParentId()));
                if (province != null) {
                    tCheckCarActivity.setProvinceName(province.getName());
                }
            }
        }
        tCheckCarActivity.setAuditStatus(0); // 重置审核状态为未审核
        tCheckCarActivityService.updateById(tCheckCarActivity);
        return SUCCESS_TIP;
    }
 
    /**
     * 代检车活动详情
     */
    @RequestMapping(value = "/detail/{tCheckCarActivityId}")
    @ResponseBody
    public Object detail(@PathVariable("tCheckCarActivityId") Integer tCheckCarActivityId) {
        return tCheckCarActivityService.selectById(tCheckCarActivityId);
    }
 
    /**
     * 获取活动统计数据
     */
    @RequestMapping(value = "/statistics/{tCheckCarActivityId}")
    @ResponseBody
    public Object getActivityStatistics(@PathVariable("tCheckCarActivityId") Integer tCheckCarActivityId) {
        return tCheckCarActivityService.getActivityStatistics(tCheckCarActivityId);
    }
 
    /**
     * 获取活动优惠券领取记录列表
     */
    @RequestMapping(value = "/records/{tCheckCarActivityId}")
    @ResponseBody
    public Object getActivityRecords(@PathVariable("tCheckCarActivityId") Integer tCheckCarActivityId,
                                   @RequestParam(required = false) String userPhone) {
        return super.packForBT(tCheckCarActivityService.getActivityRecords(tCheckCarActivityId, userPhone));
    }
 
    /**
     * 跳转到审核代检车活动详情页面
     */
    @RequestMapping("/tCheckCarActivity_audit_detail/{tCheckCarActivityId}")
    public String tCheckCarActivityAuditDetail(@PathVariable Integer tCheckCarActivityId, Model model) {
        TCheckCarActivity tCheckCarActivity = tCheckCarActivityService.selectById(tCheckCarActivityId);
        String timeRange = DateUtil.format(tCheckCarActivity.getStartTime(), DatePattern.NORM_DATE_FORMAT) + " - " +
                DateUtil.format(tCheckCarActivity.getEndTime(), DatePattern.NORM_DATE_FORMAT);
        tCheckCarActivity.setTimeRange(timeRange);
        
        // 查询当前帐号的省市区
        Integer objectId = ShiroKit.getUser().getObjectId();
        Integer roleType = ShiroKit.getUser().getRoleType();
        if(roleType == 1){
            List<TBranchOfficeArea> branchOfficeAreaList = branchOfficeAreaService.selectList(new EntityWrapper<TBranchOfficeArea>());
            if(CollectionUtils.isEmpty(branchOfficeAreaList)){
                model.addAttribute("provinceList",new ArrayList<>());
            }
            branchOfficeAreaList.forEach(item->{
                item.setActivityAreaCode(item.getProvinceCode()+"-"+item.getCityCode()+"-"+item.getAreaCode());
            });
            branchOfficeAreaList = branchOfficeAreaList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
                    new TreeSet<>(Comparator.comparing(TBranchOfficeArea::getProvinceCode))),ArrayList::new));
            model.addAttribute("provinceList",branchOfficeAreaList);
        }
        List<TBranchOfficeArea> cityList = getBranchOfficeByProvinceCode(tCheckCarActivity.getProvinceCode(), objectId, roleType);
        List<TBranchOfficeArea> areaList = getBranchOfficeByCityCode(tCheckCarActivity.getCityCode(), objectId, roleType);
        model.addAttribute("cityList", cityList);
        model.addAttribute("areaList", areaList);
        model.addAttribute("item",tCheckCarActivity);
        LogObjectHolder.me().set(tCheckCarActivity);
        return PREFIX + "tCheckCarActivity_auditPage.html";
    }
 
    /**
     * 审核代检车活动
     */
    @RequestMapping(value = "/audit")
    @ResponseBody
    public Object audit(Integer id, Integer auditStatus, String auditRemark) {
        TCheckCarActivity activity = tCheckCarActivityService.selectById(id);
        activity.setAuditStatus(auditStatus);
        activity.setRejectReason(auditRemark);
        activity.setAuditTime(new Date());
        //如果审核通过,则生成小程序二维码
        if (auditStatus == 1) {
            String pagePath = "";//TODO 小程序路径
            try {
                InputStream release = weChatUtil.getwxacodeunlimit(appId, secret, pagePath, "id=" + id, "release");
                String url = OssUploadUtil.ossUploadInputStream(release);
                activity.setQrCode(url);
            } catch (Exception e) {
                log.error("生成小程序二维码失败", e);
                throw new GunsException("服务器开小差啦");
            }
        }
        tCheckCarActivityService.updateById(activity);
        return SUCCESS_TIP;
    }
 
    /**
     * 暂停/开启活动
     */
    @RequestMapping(value = "/pause")
    @ResponseBody
    public Object pause(@RequestParam Integer tCheckCarActivityId) {
        TCheckCarActivity activity = tCheckCarActivityService.selectById(tCheckCarActivityId);
        if (activity.getPauseFlag() == null || activity.getPauseFlag() == 0) {
            activity.setPauseFlag(1); // 暂停
        } else {
            activity.setPauseFlag(0); // 开启
        }
        tCheckCarActivityService.updateById(activity);
        return SUCCESS_TIP;
    }
}