|
@@ -3,21 +3,30 @@ package com.huyi.service.conmany.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.huyi.service.base.entity.SysCompany;
|
|
import com.huyi.service.base.entity.SysCompany;
|
|
|
|
+import com.huyi.service.base.entity.SysConfig;
|
|
import com.huyi.service.base.entity.SysUser;
|
|
import com.huyi.service.base.entity.SysUser;
|
|
import com.huyi.service.base.entity.SysUserCompanyRel;
|
|
import com.huyi.service.base.entity.SysUserCompanyRel;
|
|
import com.huyi.service.base.service.ISysCompanyService;
|
|
import com.huyi.service.base.service.ISysCompanyService;
|
|
|
|
+import com.huyi.service.base.service.ISysConfigService;
|
|
import com.huyi.service.base.service.ISysUserCompanyRelService;
|
|
import com.huyi.service.base.service.ISysUserCompanyRelService;
|
|
import com.huyi.service.base.service.ISysUserService;
|
|
import com.huyi.service.base.service.ISysUserService;
|
|
import com.huyi.service.conmany.service.IOwnCompanyManageService;
|
|
import com.huyi.service.conmany.service.IOwnCompanyManageService;
|
|
import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
|
|
import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
|
|
|
|
+import com.tianhu.common.core.cfca.AxqCommonUtil;
|
|
|
|
+import com.tianhu.common.core.cfca.connector.HttpConnector;
|
|
import com.tianhu.common.core.domain.R;
|
|
import com.tianhu.common.core.domain.R;
|
|
import com.tianhu.common.core.utils.CommonUtil;
|
|
import com.tianhu.common.core.utils.CommonUtil;
|
|
|
|
+import com.tianhu.common.core.utils.DateUtils;
|
|
import com.tianhu.common.core.web.controller.BaseController;
|
|
import com.tianhu.common.core.web.controller.BaseController;
|
|
|
|
+import com.tianhu.common.core.web.domain.AjaxResult;
|
|
import com.tianhu.common.security.service.TokenService;
|
|
import com.tianhu.common.security.service.TokenService;
|
|
|
|
+import com.tianhu.system.api.RemoteConfigService;
|
|
import com.tianhu.system.api.model.LoginUser;
|
|
import com.tianhu.system.api.model.LoginUser;
|
|
|
|
+import org.json.JSONObject;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
@@ -50,6 +59,15 @@ public class CompanyInformationController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private TokenService tokenService;
|
|
private TokenService tokenService;
|
|
|
|
|
|
|
|
+ //系统参数服务类
|
|
|
|
+ @Autowired
|
|
|
|
+ private RemoteConfigService configService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysConfigService sysConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysUserCompanyRelService relService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 企业四要素认证状态;未认证
|
|
* 企业四要素认证状态;未认证
|
|
*/
|
|
*/
|
|
@@ -221,4 +239,152 @@ public class CompanyInformationController extends BaseController {
|
|
}
|
|
}
|
|
return l;
|
|
return l;
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 发送短信
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/sendMessage")
|
|
|
|
+ public R sendMessage() throws Exception{
|
|
|
|
+ //查询当前操作员
|
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
|
+ //企业Id
|
|
|
|
+ String companyId = userInfo.getSysUser().getCompanyId();
|
|
|
|
+ //查询该企业的经办人信息
|
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> relLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ //该企业
|
|
|
|
+ relLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrCompanyId,companyId);
|
|
|
|
+ //经办人
|
|
|
|
+ relLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
|
+ List<SysUserCompanyRel> relList = relService.findSysUserCompanyRels(relLambdaQueryWrapper);
|
|
|
|
+ if(relList.size() != 1){
|
|
|
|
+ throw new Exception("该企业经办人信息存在错误");
|
|
|
|
+ }
|
|
|
|
+ //经办人
|
|
|
|
+ String handler = CommonUtil.objToString(relList.get(0).getSucrUserId());
|
|
|
|
+ LambdaQueryWrapper<com.huyi.service.base.entity.SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ //非删除
|
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getDelFlag,"0");
|
|
|
|
+ //用户编号
|
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getUserId,handler);
|
|
|
|
+ //正常
|
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getStatus,"0");
|
|
|
|
+ List<com.huyi.service.base.entity.SysUser> userList = iSysUserService.findSysUsers(sysUserLambdaQueryWrapper);
|
|
|
|
+ if(userList.size() < 1){
|
|
|
|
+ throw new Exception("获取经办人信息失败");
|
|
|
|
+ }
|
|
|
|
+ //获取手机号
|
|
|
|
+ String iphone = userList.get(0).getUserName();
|
|
|
|
+ if(CommonUtil.isEmpty(iphone)){
|
|
|
|
+ throw new Exception("获取经办人手机号失败");
|
|
|
|
+ }
|
|
|
|
+ //CFCA电子签章用户id
|
|
|
|
+ SysCompany sysCompany = iSysCompanyService.getById(companyId);
|
|
|
|
+ String userId = sysCompany.getScyCfcaUserId();
|
|
|
|
+ //生成CFCA授权编号
|
|
|
|
+ String cfcaNumber = configService.selectConfigByKey("ZCYL-CFCA").getMsg();
|
|
|
|
+ cfcaNumber = "ZCYL-CFCA-" + cfcaNumber ;
|
|
|
|
+ //jks路径
|
|
|
|
+ String jksPath = configService.selectConfigByKey("jks_path").getMsg();
|
|
|
|
+ //密码
|
|
|
|
+ String keyStorePassword = configService.selectConfigByKey("cfca_key_store_password").getMsg();
|
|
|
|
+ //渠道
|
|
|
|
+ String channel = configService.selectConfigByKey("cfca_channel").getMsg();
|
|
|
|
+ //platId
|
|
|
|
+ String platId = configService.selectConfigByKey("cfca_platId").getMsg();
|
|
|
|
+ //发送短信验证码
|
|
|
|
+ JSONObject jsonObject = AxqCommonUtil.sendSms(userId,cfcaNumber,new HttpConnector(jksPath,keyStorePassword, channel,platId));
|
|
|
|
+ Boolean isHave = jsonObject.has("head");
|
|
|
|
+ if(isHave){
|
|
|
|
+ JSONObject jsonObjects = jsonObject.getJSONObject("head");
|
|
|
|
+ Boolean have = jsonObjects.has("retCode");
|
|
|
|
+ if(have){
|
|
|
|
+ String retCode =CommonUtil.objToString(jsonObjects.get("retCode"));
|
|
|
|
+ if ("60000000".equals(retCode)) {
|
|
|
|
+ //手机号掩码
|
|
|
|
+ String newIphone = iphone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
|
|
|
|
+ Map<String,String > map = new HashMap<>();
|
|
|
|
+ map.put("result",retCode);
|
|
|
|
+ map.put("newIphone",newIphone);
|
|
|
|
+ map.put("cfcaNumber",cfcaNumber);
|
|
|
|
+ return R.ok(map);
|
|
|
|
+ }else{
|
|
|
|
+ return R.fail(jsonObject.getString("retMessage"));
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ return R.fail(jsonObject.getString("retMessage"));
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ return R.fail(jsonObject.getString("errorMessage"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 校验验证码
|
|
|
|
+ * @param validCode
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/checkCode")
|
|
|
|
+ public AjaxResult checkCode(@RequestParam(required=false) String validCode,@RequestParam(required=false)String cfcaNumber) throws Exception {
|
|
|
|
+
|
|
|
|
+ if(CommonUtil.isEmpty(validCode)){
|
|
|
|
+ throw new Exception("请输入验证码");
|
|
|
|
+ }
|
|
|
|
+ if(CommonUtil.isEmpty(cfcaNumber)){
|
|
|
|
+ throw new Exception("项目授权编号不为空");
|
|
|
|
+ }
|
|
|
|
+ //查询当前操作员
|
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
|
+ com.tianhu.system.api.domain.SysUser use = userInfo.getSysUser();
|
|
|
|
+ //获取企业
|
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
|
+ //CFCA电子签章用户id
|
|
|
|
+ SysCompany sysCompany = iSysCompanyService.getById(companyId);
|
|
|
|
+ String userId = sysCompany.getScyCfcaUserId();
|
|
|
|
+ //jks路径
|
|
|
|
+ String jksPath = configService.selectConfigByKey("jks_path").getMsg();
|
|
|
|
+ //密码
|
|
|
|
+ String keyStorePassword = configService.selectConfigByKey("cfca_key_store_password").getMsg();
|
|
|
|
+ //渠道
|
|
|
|
+ String channel = configService.selectConfigByKey("cfca_channel").getMsg();
|
|
|
|
+ //platId
|
|
|
|
+ String platId = configService.selectConfigByKey("cfca_platId").getMsg();
|
|
|
|
+ //校验短信验证码
|
|
|
|
+ JSONObject jsonObject = AxqCommonUtil.checkSmsCode(userId,cfcaNumber,validCode,new HttpConnector(jksPath,keyStorePassword, channel,platId));
|
|
|
|
+ Boolean isHave = jsonObject.has("head");
|
|
|
|
+ if(isHave){
|
|
|
|
+ JSONObject jsonObjects = jsonObject.getJSONObject("head");
|
|
|
|
+ Boolean have = jsonObjects.has("retCode");
|
|
|
|
+ if(have){
|
|
|
|
+ String retCode =CommonUtil.objToString(jsonObjects.get("retCode"));
|
|
|
|
+ if ("60000000".equals(retCode)) {
|
|
|
|
+ String number = cfcaNumber.substring(cfcaNumber.lastIndexOf("-")+1);
|
|
|
|
+ int num = Integer.parseInt(number) + 1;
|
|
|
|
+ SysConfig sysConfig = new SysConfig();
|
|
|
|
+ sysConfig.setConfigKey("ZCYL-CFCA");
|
|
|
|
+ List<SysConfig> list = sysConfigService.selectConfigList(sysConfig);
|
|
|
|
+ SysConfig config = list.get(0);
|
|
|
|
+ config.setConfigValue(num+"");
|
|
|
|
+ sysConfigService.updateConfig(config);
|
|
|
|
+ //项目授权编号
|
|
|
|
+ sysCompany.setScyCfcaAuthNumber(cfcaNumber);
|
|
|
|
+ //修改时间
|
|
|
|
+ sysCompany.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
+ //修改人
|
|
|
|
+ sysCompany.setUpdateBy(CommonUtil.objToString(use.getUserId()));
|
|
|
|
+ iSysCompanyService.updateSysCompany(sysCompany);
|
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
|
+ //获取结果
|
|
|
|
+ map.put("verification",retCode);
|
|
|
|
+ return AjaxResult.success(map);
|
|
|
|
+ } else {
|
|
|
|
+ return AjaxResult.error(jsonObject.getString("retMessage"));
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ return AjaxResult.error(jsonObject.getString("retMessage"));
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ return AjaxResult.error(jsonObject.getString("errorMessage"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|