| package com.xzx.gc.user.controller;  | 
|   | 
|   | 
| import cn.hutool.core.convert.Convert;  | 
| import cn.hutool.core.lang.Dict;  | 
| import com.xzx.gc.common.Result;  | 
| 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.request.BaseController;  | 
| import com.xzx.gc.common.dto.AuthNameDto;  | 
| import com.xzx.gc.common.utils.SecurityUtil;  | 
| import com.xzx.gc.common.utils.ali.SmsUtil;  | 
| import com.xzx.gc.entity.AuthNameInfo;  | 
| import com.xzx.gc.entity.OtherUserInfo;  | 
| import com.xzx.gc.entity.VersionInfo;  | 
| import com.xzx.gc.model.CommonReq;  | 
| import com.xzx.gc.user.mapper.AuthNameInfoMapper;  | 
| import com.xzx.gc.user.mapper.VersionInfoMapper;  | 
| import com.xzx.gc.user.service.AuthNameService;  | 
| import com.xzx.gc.user.service.OtherUserService;  | 
| 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.RequestMapping;  | 
| import org.springframework.web.bind.annotation.RestController;  | 
|   | 
| import javax.servlet.http.HttpServletRequest;  | 
|   | 
| @RestController  | 
| @RequestMapping("/authName")  | 
| @Validated  | 
| @Slf4j  | 
| @Api(tags = "实名认证")  | 
| public class AuthNameController extends BaseController {  | 
|   | 
|     @Autowired  | 
|     private AuthNameService authNameService;  | 
|   | 
|     @Autowired  | 
|     private AuthNameInfoMapper authNameInfoMapper;  | 
|   | 
|     @Autowired  | 
|     private OtherUserService otherUserService;  | 
|   | 
|     @Autowired  | 
|     private VersionInfoMapper versionInfoMapper;  | 
|   | 
|   | 
|     @ApiOperation(value = "实名认证")  | 
|     @PostMapping("")  | 
|     public Result auth(HttpServletRequest request,@Validated @RequestBody AuthNameDto authNameDto) {  | 
|         Result res=new Result();  | 
|         authNameDto.setUserId(getUserId(request));  | 
|         AuthNameInfo menu = authNameService.findToday(getUserId(request));  | 
|         if(menu!=null){  | 
|             return Result.error(-1,"您当日认证机会已用完,请明日再来!");  | 
|         }  | 
|         Result result = SmsUtil.authName(authNameDto);  | 
|         if(result.getCode()==0){  | 
|             authNameService.add(authNameDto);  | 
|         }else{  | 
|             res.setCode(-3);  | 
|             res.setMsg("信息有误,认证失败请明日再来!");  | 
|         }  | 
|         return res;  | 
|     }  | 
|   | 
|     @ApiOperation(value = "验证是否已实名")  | 
|     @PostMapping("/find")  | 
|     public Result authFind(HttpServletRequest request, @RequestBody CommonReq commonReq) {  | 
|         Result res=new Result();  | 
|         String userId=getUserId(request);  | 
|         AuthNameInfo authNameInfo=new AuthNameInfo();  | 
|         authNameInfo.setUserId(userId);  | 
|         AuthNameInfo authNameInfo1 = authNameInfoMapper.selectOne(authNameInfo);  | 
|         if(authNameInfo1!=null&&UserEnum.认证通过.getValue().equals(Convert.toStr(authNameInfo1.getAuthFlag()))){  | 
|             OtherUserInfo byMobileAndUserType = otherUserService.findByMobileAndUserType(commonReq.getMobilePhone(), CommonEnum.回收员.getValue());  | 
|             if(byMobileAndUserType!=null){  | 
|                 VersionInfo versionInfo=new VersionInfo();  | 
|                 versionInfo.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG));  | 
|                 VersionInfo versionInfo1 = versionInfoMapper.selectOne(versionInfo);  | 
|                 if(versionInfo1!=null){  | 
|                     byMobileAndUserType.setDownloadUrl(versionInfo1.getApkUrl());  | 
|                 }  | 
|                 //密码解密  | 
|                 String decrypt = SecurityUtil.decrypt(byMobileAndUserType.getSalt(), byMobileAndUserType.getPassword());  | 
|                 OtherUserInfo otherUserInfo=new OtherUserInfo();  | 
|                 otherUserInfo.setDownloadUrl(byMobileAndUserType.getDownloadUrl());  | 
|                 otherUserInfo.setLoginAccount(commonReq.getMobilePhone());  | 
|                 otherUserInfo.setPassword(decrypt);  | 
|                 Dict set = Dict.create().set("code", 0).set("data", otherUserInfo);  | 
|                 res.setData(set);  | 
|             }  | 
|         }else {  | 
|             Dict set = Dict.create().set("code", -1);  | 
|             res.setData(set);  | 
|         }  | 
|         return res;  | 
|     }  | 
|   | 
|   | 
| }  |