| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- package me.zhengjie.application.bank.controller;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import me.zhengjie.annotation.rest.AnonymousPostMapping;
- import me.zhengjie.application.bank.controller.vo.*;
- import me.zhengjie.application.bank.service.*;
- import me.zhengjie.base.config.TencentHumanFaceVerify;
- import me.zhengjie.dao.mybatis.entity.OrderEntity;
- import me.zhengjie.dao.mybatis.entity.SysUserEntity;
- import me.zhengjie.base.AppBaseResponse;
- import me.zhengjie.base.util.tencent.h5face.SdkTest;
- import me.zhengjie.base.util.DateUtils;
- import me.zhengjie.base.util.FileUploadUtil;
- import me.zhengjie.base.util.StatusEnum.StepStatusEnum;
- import me.zhengjie.base.ResponseDTO;
- import me.zhengjie.base.ResultCode;
- import me.zhengjie.base.BaseController;
- import me.zhengjie.dao.mybatis.OrderFileRepository;
- import me.zhengjie.dao.mybatis.entity.OrderFileEntity;
- import me.zhengjie.modules.security.security.TokenProvider;
- import org.apache.commons.collections.CollectionUtils;
- 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;
- import org.springframework.web.multipart.MultipartFile;
- import javax.validation.Valid;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * 银行端的登录接口
- *
- * @author auas
- *
- */
- @Validated
- @RestController
- @RequestMapping("/app/bank")
- @Slf4j
- @RequiredArgsConstructor
- public class AppBankController extends BaseController {
- private final ApiBankService apiBankService;
- private final FileInfoService fileInfoService;
- private final BorrowerService borrowerService;
- private final MortgageService mortgageService;
- private final GuaranteeService guaranteeService;
- private final TokenProvider tokenProvider;
- private final OrderService orderService;
- private final OrderFileRepository orderFileRepository;
- private final TencentHumanFaceVerify faceVerify;
- private final UserAXQInfoService userAXQInfoService;
- /**
- * 登录接口
- *
- * @param loginVo
- * @return
- */
- @AnonymousPostMapping("/login")
- public ResponseDTO<String> login(@Valid @RequestBody BankLoginVo loginVo) {
- return apiBankService.login(loginVo);
- }
- /**
- * 得到业务编号
- *
- * @return
- */
- @AnonymousPostMapping("/businessNo")
- public ResponseDTO<String> businessNo() {
- // String str;
- String no = "100" + DateUtils.getNo();
- return ResponseDTO.success(no);
- }
- /**
- * 保存借款人
- *
- * @return
- */
- @RequestMapping("/saveBorrower")
- public AppBaseResponse saveBorrower(@Valid @RequestBody BorrowerVo vo) {
- log.info("借款人保存请求的参数:" + vo);
- String auth = getAuthorization();
- String sysUser = (String) tokenProvider.getAppToken(auth);
- System.out.println(sysUser);
- SysUserEntity entity = new SysUserEntity();
- if (StringUtils.isNotBlank(sysUser)) {
- entity = JSON.parseObject(sysUser, SysUserEntity.class);
- }
- return borrowerService.saveBorrowerOrder(vo, entity);
- }
- /**
- * 保存担保人
- *
- * @return
- */
- @RequestMapping("/saveGuarantee")
- public ResponseDTO<String> saveGuarantee(@Valid @RequestBody GuaranteeVo vo) {
- String auth = getAuthorization();
- String sysUser = (String) tokenProvider.getAppToken(auth);
- SysUserEntity entity = new SysUserEntity();
- if (StringUtils.isNotBlank(sysUser)) {
- entity = JSON.parseObject(sysUser, SysUserEntity.class);
- }
- guaranteeService.saveGuarantee(vo, entity);
- return ResponseDTO.success();
- }
- /**
- * 保存抵押人
- *
- * @return
- */
- @RequestMapping("/saveMortgage")
- public ResponseDTO<String> saveMortgage(@Valid @RequestBody MortgageVo vo) {
- String auth = getAuthorization();
- String sysUser = (String) tokenProvider.getAppToken(auth);
- SysUserEntity entity = new SysUserEntity();
- if (StringUtils.isNotBlank(sysUser)) {
- entity = JSON.parseObject(sysUser, SysUserEntity.class);
- }
- mortgageService.saveMortgage(vo, entity);
- return ResponseDTO.success();
- }
- /**
- * 得到抵押人详细信息
- *
- * @return
- */
- @RequestMapping("/getMortgage")
- public ResponseDTO<OrderDetailDto> getMortgage(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String id = jsonObj.getString("id");
- if (StringUtils.isEmpty(id)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- Map<String, String> map = new HashMap<String, String>();
- map.put("id", id);
- AppBaseResponse response = mortgageService.mortgageInfo(map);
- OrderDetailDto detailDto = (OrderDetailDto) response.getData().getResult();
- return ResponseDTO.success(detailDto);
- }
- /**
- * 得到担保人详细信息
- *
- * @return
- */
- @RequestMapping("/getGuarantee")
- public ResponseDTO<OrderDetailDto> getGuarantee(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String id = jsonObj.getString("id");
- if (StringUtils.isEmpty(id)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- Map<String, String> map = new HashMap<String, String>();
- map.put("id", id);
- AppBaseResponse response = guaranteeService.guaranteeInfo(map);
- OrderDetailDto detailDto = (OrderDetailDto) response.getData().getResult();
- return ResponseDTO.success(detailDto);
- }
- @RequestMapping("/order/search")
- public ResponseDTO<?> orderSearch( @RequestBody OrderVo order ) {
-
- if (order == null) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- List<OrderDto> orders = this.orderService.getOrderByContion(order);
-
- return ResponseDTO.success(orders);
- }
- /**
- * 提交订单
- *
- * @param json
- * @return
- */
- @RequestMapping("/submit")
- public AppBaseResponse submit(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String businessNo = jsonObj.getString("businessNo");
- return orderService.submitOrder(businessNo, getCurrentUser());
- }
- /**
- * 文件和图片
- *
- * @return
- */
- @RequestMapping("/uploadFiles")
- public ResponseDTO<List<FileInfoDto>> uploadFiles(@Valid FileUploadVo file) {
- log.info("文件上传参数:" + file);
- String value = StepStatusEnum.getValue(Integer.valueOf(file.getStep()));
- if (StringUtils.isEmpty(value)) {
- return ResponseDTO.error(ResultCode.BUSINESS_PROCESS_ERROR);
- }
- List<MultipartFile> fileUpload = file.getFileUpload();
- if (CollectionUtils.isEmpty(fileUpload)) {
- return ResponseDTO.error(ResultCode.FILE_DOES_NOT_EXIST);
- }
- List<FileInfoDto> fileDtos = new ArrayList<>();
- // 顺序
- Integer order = 1;
- for (MultipartFile partFile : fileUpload) {
- FileInfoDto filedto = new FileInfoDto();
- file.setOrder(order++);
- String filePath = FileUploadUtil.uploadFile(file, partFile);
- if (StringUtils.isEmpty(filePath)) {
- return ResponseDTO.error(ResultCode.BUSINESS_IMAGE_UPLOAD_ERROR);
- }
- JSONObject json = fileInfoService.saveFile(file, filePath);
- filedto.setImageId(json.getString("imageId"));
- filedto.setUrl(json.getString("url"));
- fileDtos.add(filedto);
- }
- log.info("文件上传结果返回:" + fileDtos);
- return ResponseDTO.success(fileDtos);
- }
- /**
- * 获取借款人信息
- *
- * @param json
- * @return
- */
- @RequestMapping("/getBorrower")
- public ResponseDTO<OrderDetailDto> getBorrower(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String id = jsonObj.getString("id");
- if (StringUtils.isEmpty(id)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- Map<String, String> map = new HashMap<String, String>();
- map.put("id", id);
- AppBaseResponse response = borrowerService.borrowerInfo(map);
- OrderDetailDto detailDto = (OrderDetailDto) response.getData().getResult();
- return ResponseDTO.success(detailDto);
- }
- /**
- * 上传身份证,现在是base64位,这里需要业务流水号
- *
- * @return
- */
- @RequestMapping("/uploadCard")
- public ResponseDTO<JSONObject> uploadCard(@Valid @RequestBody ImageUploadVo image) {
- String value = StepStatusEnum.getValue(Integer.valueOf(image.getStep()));
- if (StringUtils.isEmpty(value)) {
- return ResponseDTO.error(ResultCode.BUSINESS_PROCESS_ERROR);
- }
- // FIL
- if (StringUtils.isBlank(image.getOrder())) {
- image.setOrder("1");
- }
- String filePath = FileUploadUtil.saveImage(image);
- if (StringUtils.isEmpty(filePath)) {
- return ResponseDTO.error(ResultCode.BUSINESS_IMAGE_UPLOAD_ERROR);
- }
- JSONObject json = fileInfoService.saveCard(image, filePath);
- return ResponseDTO.success(json);
- }
- /**
- * 订单列表
- *
- * @param json
- * @return
- */
- @RequestMapping("/order/list")
- public ResponseDTO<?> getOrderList(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String phone = jsonObj.getString("phone");
- String status = jsonObj.getString("status");
- Integer startIndex = 1;
- Integer size = Integer.MAX_VALUE;
- List<OrderEntity> list = borrowerService.getOrderList(phone, status, startIndex, size);
- return ResponseDTO.success(list);
- }
- /**
- * 得到抵押人,借款人,担保人订单
- *
- * @param json
- * @return
- */
- @RequestMapping("/sub/order/list")
- public ResponseDTO<?> getSubOrderList(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String phone = jsonObj.getString("businessNo");
- String status = jsonObj.getString("status");
- Integer startIndex = 1;
- Integer size = Integer.MAX_VALUE;
- List<OrderDto> list = borrowerService.getSubOrderList(phone, status, startIndex, size);
- return ResponseDTO.success(list);
- }
- @RequestMapping("/order/detail")
- public ResponseDTO<?> getDetail(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String orderId = jsonObj.getString("orderId");
- if (StringUtils.isEmpty(orderId)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- OrderDto order = this.orderService.getOrderById(orderId);
- if (order == null) {
- return ResponseDTO.error(ResultCode.ORDER_DATA_NOT_EXIST);
- }
- return ResponseDTO.success(order);
- }
- // 得到公证书
- @RequestMapping("/getNotarization")
- public ResponseDTO<?> getNotarization(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String orderId = jsonObj.getString("orderId");
- OrderFileEntity orderFile = orderFileRepository.getOrderNotarization(orderId);
- return ResponseDTO.success(orderFile.getSignedPdfUrl());
- }
- // ocr解析
- @RequestMapping("/orderOCRParser")
- public ResponseDTO<?> orderOCRParser(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String orderType = jsonObj.getString("orderType");
- String content = jsonObj.getString("content");
- Object object = orderService.parseOrder(orderType, content, getCurrentUser());
- if (object == null) {
- return ResponseDTO.error(ResultCode.ORDER_OCR_SERVICE_UNAVAILABLE);
- }
- return ResponseDTO.success(object);
- }
- @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 orderId = jsonObj.getString("orderId");
- if (StringUtils.isEmpty(orderId)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- OrderDto order = this.apiBankService.getOrderDetail(orderId);
- JSONObject str = SdkTest.getFaceId(faceVerify.getBankWebankAppId(), faceVerify.getBankSecret(),
- faceVerify.getBankKeyLicence(), order.getUsername(), order.getIdCard(), orderId);
- return ResponseDTO.success(str);
- }
- @AnonymousPostMapping("/video/call")
- public ResponseDTO<?> videoCall(@RequestBody String json) {
- return this.apiBankService.videoCall(json);
- }
-
- @RequestMapping("/order/pdf")
- public ResponseDTO<?> getOrderPDF(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String orderId = jsonObj.getString("orderId");
- if (StringUtils.isEmpty(orderId)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- ResponseDTO<?> order = this.apiBankService.getOrderPDF(orderId);
- return order;
- }
- @AnonymousPostMapping("/order/note")
- public ResponseDTO<?> note(@RequestBody String json) {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String orderId = jsonObj.getString("orderId");
- if (StringUtils.isEmpty(orderId)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- //
- OrderFileEntity orderFile = orderFileRepository.getOrderNote(orderId);
- // 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("/order/updateStatus")
- public ResponseDTO<?> updateOrderStatus(@RequestBody String json) throws Exception {
- JSONObject jsonObj = JSONObject.parseObject(json);
- String orderId = jsonObj.getString("orderId");
- if (StringUtils.isEmpty(orderId)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- orderService.updateOrderStatus(orderId);
- return ResponseDTO.success();
- }
-
- @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 idCard = jsonObj.getString("idCard");
- String contractId = jsonObj.getString("contractId");
- String content = jsonObj.getString("content");
- if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(contractId) || StringUtils.isEmpty(content)) {
- return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
- }
- return userAXQInfoService.uploadSeal(idCard, contractId, content);
- }
- }
|