package me.zhengjie.application.bank.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.annotation.rest.AnonymousPostMapping; import me.zhengjie.application.bank.service.BankNotarizeService; import me.zhengjie.application.bank.service.UserAXQInfoService; import me.zhengjie.base.ResponseDTO; import me.zhengjie.base.ResultCode; import me.zhengjie.base.config.TencentHumanFaceVerify; import me.zhengjie.base.util.FileUploadUtil; import me.zhengjie.base.util.UUIDGenerator; import me.zhengjie.base.util.tencent.h5face.SdkTest; import me.zhengjie.dao.mybatis.OrderFileRepository; import me.zhengjie.dao.mybatis.entity.OrderFileEntity; import org.apache.commons.lang3.StringUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @Validated @RestController @RequestMapping("${fqgz.bank.app.url-prefix}") @Slf4j @RequiredArgsConstructor public class BankNotarizeController { private final OrderFileRepository orderFileRepository; private final UserAXQInfoService userAXQInfoService; private final BankNotarizeService bankNotarizeService; private final TencentHumanFaceVerify faceVerify; /** * 获取签名公证书URL * * @param json * @return * @throws Exception */ @RequestMapping("/getNotarization") public ResponseDTO getNotarization(@RequestBody String json) throws Exception { JSONObject jsonObj = JSONObject.parseObject(json); String businessNo = jsonObj.getString("businessNo"); if (StringUtils.isEmpty(businessNo)) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } OrderFileEntity orderFile = orderFileRepository.getOrderNotarization(businessNo); // 下载到指定的目录 String filePath = "tmp/" + UUIDGenerator.uuid() + ".pdf"; return ResponseDTO.success(FileUploadUtil.getCustomUrl(orderFile.getSignedPdfUrl(),filePath)); } @RequestMapping("/axqRegister") public ResponseDTO axqRegister(@RequestBody String json) { JSONObject jsonObj = JSONObject.parseObject(json); String idCard = jsonObj.getString("idCard"); String phone = jsonObj.getString("phone"); String name = jsonObj.getString("name"); if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(phone) || StringUtils.isEmpty(name)) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } return userAXQInfoService.registAXQUser(idCard, phone, name); } // 人脸核身 @RequestMapping("/order/getFaceId") public ResponseDTO getFaceId(@RequestBody String json) throws Exception { JSONObject jsonObj = JSONObject.parseObject(json); String userName = jsonObj.getString("userName"); String idCard = jsonObj.getString("idCard"); if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(idCard)) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } JSONObject str = SdkTest.getFaceId(faceVerify.getBankWebankAppId(), faceVerify.getBankSecret(), faceVerify.getBankKeyLicence(), userName, idCard, idCard); return ResponseDTO.success(str); } @AnonymousPostMapping("/video/call") public ResponseDTO videoCall(@RequestBody String json) { return bankNotarizeService.videoCall(json); } @RequestMapping("/order/pdf") public ResponseDTO getOrderPDF(@RequestBody String json) { JSONObject jsonObj = JSONObject.parseObject(json); String businessNo = jsonObj.getString("businessNo"); if (StringUtils.isEmpty(businessNo)) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } ResponseDTO order = bankNotarizeService.getOrderPDF(businessNo); return order; } @AnonymousPostMapping("/order/note") public ResponseDTO note(@RequestBody String json) { JSONObject jsonObj = JSONObject.parseObject(json); String businessNo = jsonObj.getString("businessNo"); if (StringUtils.isEmpty(businessNo)) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } // OrderFileEntity orderFile = orderFileRepository.getOrderNote(businessNo); // pdf的地址预览 String noteUrl = FileUploadUtil.getPreviewUrl(orderFile.getHtmlUrl()); return ResponseDTO.success(noteUrl); } @RequestMapping("/sendAuthMessage") public ResponseDTO sendAuthMessage(@RequestBody String json) { JSONObject jsonObj = JSONObject.parseObject(json); String idCard = jsonObj.getString("idCard"); if (StringUtils.isEmpty(idCard)) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } return userAXQInfoService.sendAuthMessage(idCard); } @RequestMapping("/verifyAuthMessage") public ResponseDTO verifyAuthMessage(@RequestBody String json) { JSONObject jsonObj = JSONObject.parseObject(json); String idCard = jsonObj.getString("idCard"); String checkCode = jsonObj.getString("checkCode"); if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(checkCode)) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } return userAXQInfoService.verifyAuthMessage(idCard, checkCode); } @RequestMapping("/getAuthStatus") public ResponseDTO getAuthStatus(@RequestBody String json) { JSONObject jsonObj = JSONObject.parseObject(json); String idCard = jsonObj.getString("idCard"); if (StringUtils.isEmpty(idCard)) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } return userAXQInfoService.getAuthStatus(idCard); } @AnonymousPostMapping("/uploadSeal") public ResponseDTO uploadSeal(@RequestBody String json) { JSONObject jsonObj = JSONObject.parseObject(json); String businessNo = jsonObj.getString("businessNo"); JSONArray jsonArray = jsonObj.getJSONArray("signInfo"); if (StringUtils.isEmpty(businessNo) || jsonArray == null) { return ResponseDTO.error(ResultCode.PARAM_IS_BLANK); } return userAXQInfoService.uploadSeal(businessNo, jsonArray); } }