Helius
2021-07-14 290ae8b3a86a4fb00cc6c45744c76065593d276d
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
package com.xzx.gc.user.controller;
 
 
import cn.hutool.core.collection.CollUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xzx.gc.common.Result;
import com.xzx.gc.common.annotations.PassToken;
import com.xzx.gc.common.constant.CommonEnum;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.constant.UserEnum;
import com.xzx.gc.common.dto.log.OperationAppLog;
import com.xzx.gc.common.request.BaseController;
import com.xzx.gc.common.utils.BusinessUtil;
import com.xzx.gc.common.utils.SpringUtil;
import com.xzx.gc.entity.OtherUserInfo;
import com.xzx.gc.entity.UserGatherApply;
import com.xzx.gc.entity.UserGatherInfo;
import com.xzx.gc.entity.UserScrapStore;
import com.xzx.gc.model.IdDTO;
import com.xzx.gc.model.user.UserGatherApplyListParam;
import com.xzx.gc.model.user.UserGatherAuditParam;
import com.xzx.gc.user.service.OtherUserService;
import com.xzx.gc.user.service.UserGatherApplyService;
import com.xzx.gc.user.service.UserGatherInfoService;
import com.xzx.gc.user.service.UserScrapStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
 
@RestController
@Validated
@Slf4j
@Api(tags = "外驻人员申请审核管理")
public class UserGatherApplyController extends BaseController {
 
 
    @Autowired
    private UserGatherApplyService userGatherApplyService;
 
    @Autowired
    private BusinessUtil businessUtil;
 
    @Autowired
    private OtherUserService otherUserService;
 
    @Autowired
    private UserGatherInfoService userGatherInfoService;
 
    @Autowired
    private UserScrapStoreService userScrapStoreService;
 
 
    @PostMapping("/userGatherApply/apply")
    @ApiOperation(value = "外驻人员提交申请")
    @PassToken
    public Result userGatherApply(HttpServletRequest request, @RequestBody UserGatherApply userGatherApply) {
        String mobilePhone = userGatherApply.getMobilePhone();
        String code = userGatherApply.getCode();
        //1:集货员申请 2:回收员申请 3:废品店申请
        String type = userGatherApply.getType();
 
        boolean b = businessUtil.checkSmsCode(code, mobilePhone);
 
        if(!b){
            return Result.error("验证码不正确");
        }
 
        List<UserGatherApply> byMobile = userGatherApplyService.findByMobileAndType(mobilePhone,type);
        if(CollUtil.isNotEmpty(byMobile)){
 
            if(byMobile.stream().filter(x->x.getStatus().equals(CommonEnum.待审核.getValue())).count()>0){
                return Result.error("当前手机号正在审核中");
            }
        }
 
        //查询是否存在集货员、回收员、废品站等身份
        List<OtherUserInfo> byMobileForBidden = otherUserService.findByMobileForBidden(mobilePhone);
        if(CollUtil.isNotEmpty(byMobileForBidden)){
            return Result.error("当前手机号已被平台用户注册");
        }
 
        UserGatherInfo userGatherInfo = userGatherInfoService.findByMobileForBidden(mobilePhone);
        if (userGatherInfo != null) {
            return Result.error("当前手机号已被集货员注册");
        }
 
        UserScrapStore userScrapStore = userScrapStoreService.findByMobile(mobilePhone);
        if (userScrapStore != null) {
            return Result.error("当前手机号已被废品站注册");
        }
 
        userGatherApplyService.apply(userGatherApply);
        OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(userGatherApply.getMobilePhone())
                .methodName(Constants.USER_MODUL_NAME).operateAction("外驻人员提交申请-"+userGatherApply.getMobilePhone()).build();
        mqUtil.sendApp(build);
        return Result.success("申请成功,请重新登录");
    }
 
    @PostMapping(value = {"/userGatherApply/list","/admin/front/userGatherApply/list"})
    @ApiOperation(value = "外驻审核列表")
    public Result<PageInfo<UserGatherApply>> userGatherApplyList(HttpServletRequest request, @RequestBody UserGatherApplyListParam userGatherApplyListParam) {
        PageHelper.startPage(userGatherApplyListParam.getPageNo(),userGatherApplyListParam.getPageSize());
        boolean mobile = isMobile(request);
        if(mobile){
            userGatherApplyListParam.setClientType(CommonEnum.app.getValue());
        }
        List<UserGatherApply> list=userGatherApplyService.list(userGatherApplyListParam);
        return Result.success(new PageInfo<>(list));
    }
 
    @PostMapping(value = {"/userGatherApply/audit","/admin/front/userGatherApply/audit"})
    @ApiOperation(value = "外驻人员审核")
    public Result userGatherAudit(HttpServletRequest request, @RequestBody UserGatherAuditParam userGatherAuditParam) {
 
        //审核
        userGatherApplyService.audit(userGatherAuditParam);
 
 
        if(isMobile(request)){
            String mobilePhone = otherUserService.findById(getUserId(request)).getMobilePhone();
            OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone)
                    .methodName(Constants.USER_MODUL_NAME).operateAction("外驻人员审核-" + userGatherAuditParam.getId()).build();
            mqUtil.sendApp(build);
        }else {
            OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))
                    .methodName(Constants.USER_MODUL_NAME).operateAction("外驻人员审核-" + userGatherAuditParam.getId()).build();
            mqUtil.sendApp(build);
        }
        return Result.success();
    }
 
 
}