|
@@ -1,18 +1,38 @@
|
|
|
package com.huyi.service.credit.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.huyi.service.base.entity.SysCompany;
|
|
|
+import com.huyi.service.base.entity.SysConfig;
|
|
|
+import com.huyi.service.base.entity.SysUserCompanyRel;
|
|
|
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.ISysUserService;
|
|
|
+import com.tianhu.common.core.cfca.AxqCommonUtil;
|
|
|
+import com.tianhu.common.core.cfca.CfcaUtil;
|
|
|
+import com.tianhu.common.core.cfca.connector.HttpConnector;
|
|
|
import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.AmtUtil;
|
|
|
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.domain.AjaxResult;
|
|
|
+import com.tianhu.common.log.annotation.Log;
|
|
|
+import com.tianhu.common.log.enums.BusinessType;
|
|
|
import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.RemoteConfigService;
|
|
|
import com.tianhu.system.api.domain.SysUser;
|
|
|
import com.tianhu.system.api.model.LoginUser;
|
|
|
+import org.checkerframework.checker.units.qual.C;
|
|
|
+import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
@@ -28,6 +48,26 @@ public class OwnCfcaProjectController extends BaseController {
|
|
|
@Autowired
|
|
|
private ISysCompanyService sysCompanyService;
|
|
|
|
|
|
+ //经办人关系服务类
|
|
|
+ @Autowired
|
|
|
+ private ISysUserCompanyRelService relService;
|
|
|
+
|
|
|
+ //用户信息服务类
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+
|
|
|
+ //系统参数服务类
|
|
|
+ @Autowired
|
|
|
+ private RemoteConfigService configService;
|
|
|
+
|
|
|
+ //公司服务类
|
|
|
+ @Autowired
|
|
|
+ private ISysCompanyService companyService;
|
|
|
+
|
|
|
+ //参数服务类
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService sysConfigService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询当前企业是否存在cfca授权编号
|
|
|
* @return
|
|
@@ -53,4 +93,157 @@ public class OwnCfcaProjectController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 发送短信
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @GetMapping("/proSendMessage")
|
|
|
+ public R list() throws Exception {
|
|
|
+ //查询当前操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.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 = userService.findSysUsers(sysUserLambdaQueryWrapper);
|
|
|
+ if(userList.size() < 1){
|
|
|
+ throw new Exception("获取经办人信息失败");
|
|
|
+ }
|
|
|
+ //获取手机号
|
|
|
+ String iphone = userList.get(0).getUserName();
|
|
|
+ if(CommonUtil.isEmpty(iphone)){
|
|
|
+ throw new Exception("获取经办人手机号失败");
|
|
|
+ }
|
|
|
+ //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();
|
|
|
+ //当前公司的cfca人员编号
|
|
|
+ //查询当前企业信息
|
|
|
+ SysCompany currentCompany = companyService.getById(companyId);
|
|
|
+ if(currentCompany == null) {
|
|
|
+ throw new Exception("获取当前企业信息失败");
|
|
|
+ }
|
|
|
+ String userId = currentCompany.getScyCfcaUserId();
|
|
|
+ //获取授权项目编号
|
|
|
+ String projectCode = configService.selectConfigByKey("ZCYL-CFCA").getMsg();
|
|
|
+ projectCode = "ZCYL-CFCA-"+projectCode;
|
|
|
+
|
|
|
+ //发送短信验证码
|
|
|
+ JSONObject jsonObject = AxqCommonUtil.sendSms(userId,projectCode,new HttpConnector(jksPath,keyStorePassword, channel,platId));
|
|
|
+ String retCode = jsonObject.getString("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("projectCode",projectCode);
|
|
|
+ return R.ok(map);
|
|
|
+ }else{
|
|
|
+ return R.fail(jsonObject.getString("retMessage"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验验证码
|
|
|
+ * @param code
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Log(title = "授权校验验证码", businessType = BusinessType.UPDATE)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GetMapping("/checkProCode")
|
|
|
+ public AjaxResult checkCode(@RequestParam(required=false) String code,@RequestParam(required=false) String projectCode) throws Exception {
|
|
|
+
|
|
|
+ if(CommonUtil.isEmpty(code)){
|
|
|
+ throw new Exception("请输入验证码");
|
|
|
+ }
|
|
|
+ if(CommonUtil.isEmpty(projectCode)){
|
|
|
+ throw new Exception("项目授权编号不为空");
|
|
|
+ }
|
|
|
+ //查询当前操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ //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();
|
|
|
+ //当前公司的cfca人员编号
|
|
|
+ SysCompany currentCompany = companyService.getById(companyId);
|
|
|
+ if(currentCompany == null) {
|
|
|
+ throw new Exception("获取当前企业信息失败");
|
|
|
+ }
|
|
|
+ String userId = currentCompany.getScyCfcaUserId();
|
|
|
+ JSONObject jsonObject = AxqCommonUtil.checkSmsCode(userId,projectCode,code,new HttpConnector(jksPath,keyStorePassword, channel,platId));
|
|
|
+ String retCode = jsonObject.getString("retCode");
|
|
|
+ //成功
|
|
|
+ if ("60000000".equals(retCode)) {
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ //获取结果
|
|
|
+ map.put("verification",retCode);
|
|
|
+ //存入项目授权编号
|
|
|
+ SysCompany cp = new SysCompany();
|
|
|
+ //公司
|
|
|
+ cp.setScyId(companyId);
|
|
|
+ //项目授权编号
|
|
|
+ cp.setScyCfcaAuthNumber(projectCode);
|
|
|
+ //修改时间
|
|
|
+ cp.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //修改人
|
|
|
+ cp.setUpdateBy(CommonUtil.objToString(use.getUserId()));
|
|
|
+ companyService.updateById(cp);
|
|
|
+ //更改系统参数项目编号的值
|
|
|
+ String cfcaMessage = configService.selectConfigByKey("ZCYL-CFCA").getMsg();
|
|
|
+ cfcaMessage = AmtUtil.add(cfcaMessage,"1",0);
|
|
|
+ SysConfig sysConfig = new SysConfig();
|
|
|
+ sysConfig.setConfigKey("ZCYL-CFCA");
|
|
|
+ List<SysConfig> configList = sysConfigService.selectConfigList(sysConfig);
|
|
|
+ if(configList.size() < 1){
|
|
|
+ throw new Exception("参数配置错误");
|
|
|
+ }
|
|
|
+ SysConfig config = configList.get(0);
|
|
|
+ config.setConfigValue(cfcaMessage);
|
|
|
+ sysConfigService.updateConfig(config);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error(jsonObject.getString("retMessage"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|