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();
|
}
|
|
|
}
|