|
@@ -0,0 +1,289 @@
|
|
|
+package com.tianhu.system.companyAuth.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.tianhu.common.core.cfca.CfcaUtil;
|
|
|
+import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.CommonUtil;
|
|
|
+import com.tianhu.common.core.utils.IdUtils;
|
|
|
+import com.tianhu.common.core.utils.SecurityUtils;
|
|
|
+import com.tianhu.common.core.utils.ServletUtils;
|
|
|
+import com.tianhu.common.core.web.controller.BaseController;
|
|
|
+import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.RemoteFileService;
|
|
|
+import com.tianhu.system.api.domain.PubFileInf;
|
|
|
+import com.tianhu.system.api.model.LoginUser;
|
|
|
+import com.tianhu.system.companyAuth.service.IOwnAuthService;
|
|
|
+import com.tianhu.system.domain.PayBankAccInf;
|
|
|
+import com.tianhu.system.domain.SysCompany;
|
|
|
+import com.tianhu.system.domain.ZcCfcaBankInf;
|
|
|
+import com.tianhu.system.service.IPayBankAccInfService;
|
|
|
+import com.tianhu.system.service.ISysCompanyService;
|
|
|
+import com.tianhu.system.service.IZcCfcaBankInfService;
|
|
|
+import org.json.JSONObject;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 企业认证管理
|
|
|
+ *
|
|
|
+ * @author cuixq@minpay.cc
|
|
|
+ * @date 2021-08-20
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("companyAuth")
|
|
|
+public class OwnAuthController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOwnAuthService ownAuthService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysCompanyService sysCompanyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPayBankAccInfService payBankAccInfService;
|
|
|
+ @Autowired
|
|
|
+ private IZcCfcaBankInfService zcCfcaBankInfService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RemoteFileService remoteFileService;
|
|
|
+ /**
|
|
|
+ * CFCA (是否开启生产环境配置 true 开启 false 关闭)
|
|
|
+ */
|
|
|
+ private static boolean ISPRO = false;
|
|
|
+ /**
|
|
|
+ * CFCA机构编号 (测试环境默认:100804)
|
|
|
+ */
|
|
|
+ private static String INSTITUTIONID = "100804";
|
|
|
+ /**
|
|
|
+ * 证件类型 (暂只支持 0=身份证 2=护照 3=军官证 4=士兵证 5=港澳居民来往内地通行 证 6=台湾同胞来往内地通行 证 8=外国人居留证 9=警官证 Z=港澳台居民身份证 R=居住证 L=居留证)
|
|
|
+ */
|
|
|
+ private static String IDENTIFICATIONTYPE = "0";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增企业认证
|
|
|
+ *
|
|
|
+ * @param map 企业信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/add")
|
|
|
+ public R add(@RequestBody Map<String,Object> map) throws Exception {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ //企业名称
|
|
|
+ String scyName = CommonUtil.objToString(map.get("scyName"));
|
|
|
+ //社会信用代码
|
|
|
+ String scySocialCode = CommonUtil.objToString(map.get("scySocialCode"));
|
|
|
+ //注册资本
|
|
|
+ String scyRegisteredCapital = CommonUtil.objToString(map.get("scyRegisteredCapital"));
|
|
|
+ //时间格式化
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ //注册时间
|
|
|
+ String scyStartTime = sdf.format(CommonUtil.objToString(map.get("scyStartTime")));
|
|
|
+ //到期时间
|
|
|
+ String scyEndTime = sdf.format(CommonUtil.objToString(map.get("scyEndTime")));
|
|
|
+ //企业地址
|
|
|
+ String scyAddress = CommonUtil.objToString(map.get("scyAddress"));
|
|
|
+ //企业电话
|
|
|
+ String scyPhone = CommonUtil.objToString(map.get("scyPhone"));
|
|
|
+ //法人姓名
|
|
|
+ String scyLegal = CommonUtil.objToString(map.get("scyLegal"));
|
|
|
+ //法人证件号码
|
|
|
+ String scyLegalId = CommonUtil.objToString(map.get("scyLegalId"));
|
|
|
+ //营业执照
|
|
|
+ String scyLicenseFile = CommonUtil.objToString(map.get("scyLicenseFile"));
|
|
|
+ //经办人姓名
|
|
|
+ String name = CommonUtil.objToString(map.get("name"));
|
|
|
+ //经办人身份证号
|
|
|
+ String nameCard = CommonUtil.objToString(map.get("nameCard"));
|
|
|
+ //经办人手机号
|
|
|
+ String phoneNumber = CommonUtil.objToString(map.get("phoneNumber"));
|
|
|
+ //备注
|
|
|
+ String zbiRemark = CommonUtil.objToString(map.get("zbiRemark"));
|
|
|
+ SysCompany SysCompany = new SysCompany();
|
|
|
+ String scyId = IdUtils.fastSimpleUUID();
|
|
|
+ SysCompany.setScyId(scyId);
|
|
|
+ sysCompanyService.createSysCompany(SysCompany);
|
|
|
+ //运营商三要素
|
|
|
+ JSONObject operatorAuth = CfcaUtil.operatorAuth(ISPRO, INSTITUTIONID, name, IDENTIFICATIONTYPE, nameCard, phoneNumber, zbiRemark);
|
|
|
+ System.out.print("运营商三要素结果==========>" + operatorAuth);
|
|
|
+ /* operatorAuth.getJSONObject(WORDS_RESULT);*/
|
|
|
+ //工商四要素
|
|
|
+ JSONObject companyAuth = CfcaUtil.companyAuth(ISPRO, INSTITUTIONID, scyName, scySocialCode, scyLegal, IDENTIFICATIONTYPE, scyLegalId, zbiRemark);
|
|
|
+ System.out.print("工商四要素结果==========>" + companyAuth);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 营业执照识别
|
|
|
+ *
|
|
|
+ * @param file 文件
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/getlicense")
|
|
|
+ public SysCompany getlicense(@RequestParam("file") MultipartFile file) {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ String companyId = user.getSysUser().getCompanyId();
|
|
|
+ //获取企业信息
|
|
|
+ SysCompany sysCompany = ownAuthService.businessLicense(file);
|
|
|
+ LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //企业名称
|
|
|
+ queryWrapper.eq(SysCompany::getScyName,sysCompany.getScyName());
|
|
|
+ //统一社会信用代码
|
|
|
+ queryWrapper.eq(SysCompany::getScyRemarks,sysCompany.getScySocialCode());
|
|
|
+ List<SysCompany> list = sysCompanyService.findSysCompanys(queryWrapper);
|
|
|
+ //不重复则储存营业执照并上传
|
|
|
+ if(list.size() == 0){
|
|
|
+ sysCompanyService.createSysCompany(sysCompany);
|
|
|
+ //获取上传文件token
|
|
|
+ String token = SecurityUtils.getToken(ServletUtils.getRequest());
|
|
|
+ //文件传输
|
|
|
+ R<PubFileInf> fileResult = remoteFileService.uploadFile(file,"01","04","00", companyId, token);
|
|
|
+ sysCompany.setScyLicenseFile(fileResult.getData().getPfiFileId());
|
|
|
+ }else{
|
|
|
+// zcInvoiceInf.setZiiId(list.get(0).getZiiId());
|
|
|
+ }
|
|
|
+ //返回发票信息
|
|
|
+ return sysCompany;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 法人身份证正面识别
|
|
|
+ *
|
|
|
+ * @param file 文件
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/getCardPositive")
|
|
|
+ public R getCardPositive(MultipartFile file) {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ String companyId = user.getSysUser().getCompanyId();
|
|
|
+ //获取企业信息
|
|
|
+ SysCompany sysCompany = ownAuthService.getCardPositive(file);
|
|
|
+ LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //企业名称
|
|
|
+ queryWrapper.eq(SysCompany::getScyName,sysCompany.getScyName());
|
|
|
+ //统一社会信用代码
|
|
|
+ queryWrapper.eq(SysCompany::getScyRemarks,sysCompany.getScySocialCode());
|
|
|
+ List<SysCompany> list = sysCompanyService.findSysCompanys(queryWrapper);
|
|
|
+ //不重复则储存营业执照并上传
|
|
|
+ if(list.size() == 0){
|
|
|
+ sysCompanyService.createSysCompany(sysCompany);
|
|
|
+ //获取上传文件token
|
|
|
+ String token = SecurityUtils.getToken(ServletUtils.getRequest());
|
|
|
+ //文件传输
|
|
|
+ R<PubFileInf> fileResult = remoteFileService.uploadFile(file,"01","04","00", companyId, token);
|
|
|
+ sysCompany.setScyLicenseFile(fileResult.getData().getPfiFileId());
|
|
|
+ }else{
|
|
|
+// zcInvoiceInf.setZiiId(list.get(0).getZiiId());
|
|
|
+ }
|
|
|
+ //返回发票信息
|
|
|
+ return R.ok(sysCompany);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 绑定对公账户
|
|
|
+ *
|
|
|
+ * @param map 企业信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/account")
|
|
|
+ public R account(@RequestBody Map<String,Object> map) throws Exception {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ //企业id
|
|
|
+ String scyId = CommonUtil.objToString(map.get("scyId"));
|
|
|
+ //开户名
|
|
|
+ String pbaiAccountName = CommonUtil.objToString(map.get("pbaiAccountName"));
|
|
|
+ //银行卡号
|
|
|
+ String pbaiBankaccountId = CommonUtil.objToString(map.get("pbaiBankaccountId"));
|
|
|
+ //所属银行
|
|
|
+ String pbaiBankName = CommonUtil.objToString(map.get("pbaiBankName"));
|
|
|
+ //备注
|
|
|
+ String zbiRemark = CommonUtil.objToString(map.get("zbiRemark"));
|
|
|
+ PayBankAccInf payBankAccInf = new PayBankAccInf();
|
|
|
+ String pbiId = IdUtils.fastSimpleUUID();
|
|
|
+ payBankAccInf.setPbaiId(pbiId);
|
|
|
+ payBankAccInf.setPbaiCstno(scyId);
|
|
|
+ payBankAccInf.setPbaiAccountName(pbaiAccountName);
|
|
|
+ payBankAccInf.setPbaiBankaccountId(pbaiBankaccountId);
|
|
|
+ payBankAccInf.setPbaiBankName(pbaiBankName);
|
|
|
+ payBankAccInfService.createPayBankAccInf(payBankAccInf);
|
|
|
+ //查询银行行号
|
|
|
+ LambdaQueryWrapper<ZcCfcaBankInf> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //所属银行
|
|
|
+ queryWrapper.eq(ZcCfcaBankInf::getZcbiBankName,pbaiBankName);
|
|
|
+ List<ZcCfcaBankInf> list = zcCfcaBankInfService.findZcCfcaBankInfs(queryWrapper);
|
|
|
+ if(list.size()==0){
|
|
|
+ return R.fail("银行名称错误,请输入正确的银行名");
|
|
|
+ }
|
|
|
+ //企业打款申请
|
|
|
+ JSONObject operatorAuth = CfcaUtil.paymentApply(ISPRO, INSTITUTIONID, pbaiAccountName, pbaiBankaccountId,list.get(0).getZcbiBankNo(),zbiRemark);
|
|
|
+ System.out.print("绑定对公户返回结果==========>" + operatorAuth);
|
|
|
+ /* operatorAuth.getJSONObject(WORDS_RESULT);*/
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打款验证
|
|
|
+ *
|
|
|
+ * @param map 企业信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/payment")
|
|
|
+ public R payment(@RequestBody Map<String,Object> map) throws Exception {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ //交易流水号
|
|
|
+ String originalTxSN = CommonUtil.objToString(map.get("originalTxSN"));
|
|
|
+ //金额(分)
|
|
|
+ String amount = CommonUtil.objToString(map.get("amount"));
|
|
|
+ //备注
|
|
|
+ String zbiRemark = CommonUtil.objToString(map.get("zbiRemark"));
|
|
|
+ //企业打款申请
|
|
|
+ JSONObject operatorAuth = CfcaUtil.paymentAuth(ISPRO, INSTITUTIONID, originalTxSN, amount, zbiRemark);
|
|
|
+ System.out.print("打款认证结果==========>" + operatorAuth);
|
|
|
+ /* operatorAuth.getJSONObject(WORDS_RESULT);*/
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 发送短信验证码
|
|
|
+ *
|
|
|
+ * @param phone 手机号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/send")
|
|
|
+ public R send(String phone) throws Exception {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ //企业打款申请
|
|
|
+ JSONObject operatorAuth = CfcaUtil.sendSmsCode(ISPRO, INSTITUTIONID,null,phone,null);
|
|
|
+ System.out.print("发送短信验证码结果==========>" + operatorAuth);
|
|
|
+ /* operatorAuth.getJSONObject(WORDS_RESULT);*/
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 短信验证
|
|
|
+ *
|
|
|
+ * @param phone 手机号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/verification")
|
|
|
+ public R verification(String phone,String code) throws Exception {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ //企业打款申请
|
|
|
+ JSONObject operatorAuth = CfcaUtil.checkSmsCode(ISPRO, INSTITUTIONID,code,phone,null);
|
|
|
+ System.out.print("短信验证码验证结果==========>" + operatorAuth);
|
|
|
+ /* operatorAuth.getJSONObject(WORDS_RESULT);*/
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+}
|