ApiQuotalInquiryService.java 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package com.kmall.api.service.quotalInquiry;
  2. import com.google.common.collect.ImmutableBiMap;
  3. import com.kmall.api.dao.*;
  4. import com.kmall.api.entity.*;
  5. import com.kmall.common.constant.Dict;
  6. import com.kmall.common.utils.*;
  7. import com.kmall.manager.dto.CrossBoundaryQuotalDto;
  8. import com.kmall.manager.dto.CrossQuotalInquiryResponseDto;
  9. import com.kmall.manager.manager.quotalInquiry.CrossBoundaryQuotalInquiryUtil;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import org.springframework.transaction.annotation.Transactional;
  13. import java.util.Map;
  14. /**
  15. * @author huangyq
  16. * @version 1.0
  17. * 2019-12-17 15:52
  18. */
  19. @Service
  20. public class ApiQuotalInquiryService {
  21. @Autowired
  22. private ApiThirdMerchantBizMapper apiThirdMerchantBizMapper;
  23. @Autowired
  24. private ApiMerchMapper apiMerchMapper;
  25. @Autowired
  26. private ApiUserMapper apiUserMapper;
  27. /**
  28. * 跨境额度查询
  29. * @param crossBoundaryQuotalDto
  30. * @param storeId
  31. * @param userId
  32. * @return
  33. */
  34. @Transactional
  35. public CrossQuotalInquiryResponseDto getCrossBoundaryQuotaQuery(CrossBoundaryQuotalDto crossBoundaryQuotalDto, Long storeId, Long userId) {
  36. Map<String, Object> valideDate = MapBeanUtil.fromObject(crossBoundaryQuotalDto);
  37. ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
  38. builder.put("merchId", "商户编号");
  39. builder.put("idCard", "身份证号");
  40. builder.put("name", "姓名");
  41. R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  42. if (Integer.valueOf(r.get("code").toString()) != 0) {
  43. throw new RRException(r.get("msg").toString());
  44. }
  45. /*UserVo userVo = apiUserMapper.queryObjectByIdNoAndName(crossBoundaryQuotalDto.getIdCard(),crossBoundaryQuotalDto.getName());
  46. if(userVo == null){
  47. throw new RRException("身份证信息未绑定");
  48. }else{
  49. if(userVo.getId() != userId){
  50. throw new RRException("只能查询当前微信用户绑定的身份证信息");
  51. }
  52. }*/
  53. String merchSn = crossBoundaryQuotalDto.getMerchId();
  54. MerchVo merchVo = apiMerchMapper.queryObjectByMerchSn(merchSn);
  55. if(merchVo == null){
  56. throw new RRException("商户不存在");
  57. }
  58. ThirdMerchantBizVo thirdMerchantBizVo = apiThirdMerchantBizMapper.queryDataByStoreId(storeId);
  59. if(thirdMerchantBizVo == null){
  60. throw new RRException("该门店的第三方商户不存在");
  61. }
  62. crossBoundaryQuotalDto.setMerchName(merchVo.getMerchName());
  63. crossBoundaryQuotalDto.setThirdPartyMerchCode(thirdMerchantBizVo.getThirdPartyMerchCode());
  64. crossBoundaryQuotalDto.setThirdPartyMerchName(thirdMerchantBizVo.getThirdPartyMerchName());
  65. crossBoundaryQuotalDto.setIsCheckIdCard("0");//是否身份证认证:0:否,1:是
  66. ResponseData responseData = CrossBoundaryQuotalInquiryUtil.getCrossBoundaryQuotaQuery(crossBoundaryQuotalDto);
  67. if(!responseData.getCode().equalsIgnoreCase("0")){
  68. throw new RRException(responseData.getMsg());
  69. }else{
  70. //跨境额度查询成功,保存返回数据
  71. Map quotalInquiryResponseDto = (Map)responseData.getData().getRows().get(0);
  72. CrossQuotalInquiryResponseDto crossQuotalInquiryResponseDto = new CrossQuotalInquiryResponseDto();
  73. String serviceTime = (String)quotalInquiryResponseDto.get("serviceTime");
  74. Map resultMap = (Map)quotalInquiryResponseDto.get("result");
  75. if(resultMap != null){
  76. Double totalAmount = (Double)resultMap.get("totalAmount");
  77. Double innerbalance = (Double)resultMap.get("innerbalance");
  78. crossQuotalInquiryResponseDto.setInnerbalance(innerbalance);
  79. crossQuotalInquiryResponseDto.setTotalAmount(totalAmount);
  80. }
  81. crossQuotalInquiryResponseDto.setServiceTime(serviceTime);
  82. return crossQuotalInquiryResponseDto;
  83. }
  84. }
  85. }