@@ -1,6 +1,8 @@
package cn.pluss.platform.klk.service.impl ;
import cn.hutool.core.io.resource.UrlResource ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.http.HttpRequest ;
import cn.hutool.json.JSONUtil ;
import cn.pluss.platform.BankCardService ;
import cn.pluss.platform.IdCardService ;
@@ -11,20 +13,24 @@ import cn.pluss.platform.entity.*;
import cn.pluss.platform.exception.MsgException ;
import cn.pluss.platform.klk.LakalaConfig ;
import cn.pluss.platform.klk.service.* ;
import cn.pluss.platform.klk.util.HtmlUtil ;
import cn.pluss.platform.klk.util.RSAUtil ;
import cn.pluss.platform.klk.vo.* ;
import cn.pluss.platform.mapper.MerchantChannelFeeMapper ;
import cn.pluss.platform.mapper.MerchantChannelStatusMapper ;
import cn.pluss.platform.mapper.MerchantImageMapper ;
import cn.pluss.platform.mcc.MccReflectService ;
import cn.pluss.platform.merchant.AccountService ;
import cn.pluss.platform.merchant.MerchantBaseInfoService ;
import cn.pluss.platform.merchantChannelStatus.MerchantChannelStatusService ;
import cn.pluss.platform.userApp.UserAppService ;
import cn.pluss.platform.util.DateUtils ;
import cn.pluss.platform.util.StringUtil ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import freemarker.template.TemplateException ;
import lombok.Data ;
import lombok.SneakyThrows ;
import lombok.extern.slf4j.Slf4j ;
@@ -100,6 +106,10 @@ public class LaKalaInterfaceImpl {
@Autowired
LakalaConfig lakalaConfig ;
@Lazy
@Autowired
MerchantImageMapper merchantImageMapper ;
private static final String client_id = " chaozhanggui " ;
private static final String client_secret = " Y54Gqy6aLpxld3dp " ;
private static final String grant_type = " client_credentials " ;
@@ -148,14 +158,13 @@ public class LaKalaInterfaceImpl {
// private static final String tuoKeToken = "https://test.wsmsd.cn/sit/htkauth/oauth/token";
/**
* 拉卡拉模式进件
*/
/**
* 拉卡拉拓客进件
* */
*/
public void createTuoKeInfo ( String userId ) {
// UserApp userapp=userAppService.getById(userId);
@@ -166,21 +175,24 @@ public class LaKalaInterfaceImpl {
MerchantBaseInfo merchantBaseInfo = mbiService . getMerchantBaseInfoByUserId ( userId ) ;
IdCard idCard = idCardService . getCertIdCard ( userId ) ; //获取法人身份证信息
MsgException . checkNull ( idCard , " 商户基本信息不完整 " ) ;
MsgException . checkNull ( idCard , " 商户基本信息不完整 " ) ;
MerchantChannelStatus mcs = mcsService . getByMerchantCodeNoChannel ( merchantBaseInfo . getMerchantCode ( ) ) ;
if ( ObjectUtil . isEmpty ( mcs ) ) {
log . info ( " 审核失败,重新审核数据:{} " , merchantBaseInfo . getMerchantCode ( ) ) ;
QueryWrapper < MerchantChannelStatus > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
queryWrapper . eq ( " channel " , " 5 " ) ;
queryWrapper . eq ( " status " , 2 ) ;
mcs = merchantChannelStatusMapper . selectOne ( queryWrapper ) ;
if ( ObjectUtil . isEmpty ( mcs ) ) {
log . info ( " 审核失败,重新审核数据:{} " , merchantBaseInfo . getMerchantCode ( ) ) ;
QueryWrapper < MerchantChannelStatus > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
queryWrapper . eq ( " channel " , " 5 " ) ;
List < String > list = new ArrayList < > ( ) ;
list . add ( " 1 " ) ;
list . add ( " 2 " ) ;
queryWrapper . in ( " status " , list ) ;
mcs = merchantChannelStatusMapper . selectOne ( queryWrapper ) ;
}
String status = mcs . getStatus ( ) ;
String thirdStatus = mcs . getThirdStatus ( ) ;
MsgException . checkNull ( mcs , " 商户未提交审核 " ) ;
String status = mcs . getStatus ( ) ;
String thirdStatus = mcs . getThirdStatus ( ) ;
MsgException . checkNull ( mcs , " 商户未提交审核 " ) ;
if ( status . equals ( MerchantChannelStatus . AUDIT_STATUS_EXAMINING ) & & ! thirdStatus . equals ( MerchantChannelStatus . AUDIT_THIRD_STATUS_WAITING ) ) {
MsgException . throwException ( " 进件审核中,请等待审核结果 " ) ;
}
@@ -190,45 +202,66 @@ public class LaKalaInterfaceImpl {
}
JSONObject object1 = new JSONObject ( ) ;
JSONObject object2 = new JSONObject ( ) ;
object1 . put ( " userNo " , userNo ) ; //合作机构信息 由拓客SAAS提供
object1 . put ( " email " , " chaozhanggui2023@163.com " ) ; //商户邮箱
object1 . put ( " busiCode " , " WECHAT_PAY " ) ; //业务类型 BPOS:传统POS, ZPOS:电签,ZPOS4G: 4G电签,SUPER_POS:智能pos,B_WIZARD:蓝精灵,PAPER_CODE:码牌,WECHAT_PAY:专业化扫码,KLYX:云音箱,QRCODE:收款王,MONEY_BOX:收钱宝盒根据业务开放取值
object1 . put ( " merRegName " , merchantBaseInfo . getAlias ( ) ) ; //商户注册名称 不能少于七个中文
object1 . put ( " merType " , ( merchantBaseInfo . getMerchantType ( ) . equals ( 1 ) | | merchantBaseInfo . getMerchantType ( ) . equals ( " 2 " ) ) ? " TP_PERSONAL " : " TP_MERCHANT " ) ; //商户注册类型 TP_MERCHANT:企业 TP_PERSONAL:⼩微个⼈
object1 . put ( " merType " , ( merchantBaseInfo . getMerchantType ( ) . equals ( 1 ) | | merchantBaseInfo . getMerchantType ( ) . equals ( " 2 " ) ) ? " TP_PERSONAL " : " TP_MERCHANT " ) ; //商户注册类型 TP_MERCHANT:企业 TP_PERSONAL:⼩微个⼈
object1 . put ( " merName " , merchantBaseInfo . getAlias ( ) ) ; //商户名称(经营名称) 不能少于七个中文
object1 . put ( " merAddr " , merchantBaseInfo . getAddress ( ) ) ; //去掉省,市区后的详细地址
object1 . put ( " provinceCode " , tbPlussRegionLklService . getOne ( new QueryWrapper < TbPlussRegionLklEntity > ( ) . likeRight ( " name " , merchantBaseInfo . getProvince ( ) ) . last ( " limit 1 " ) ) . getCode ( ) ) ; //省代码 通过【地区信息→获取地区查询】接口获取 对应 code字段
object1 . put ( " cityCode " , tbPlussRegionLklService . getOne ( new QueryWrapper < TbPlussRegionLklEntity > ( ) . likeRight ( " name " , merchantBaseInfo . getCity ( ) ) . last ( " limit 1 " ) ) . getCode ( ) ) ; // 市代码 通过【地区信息→获取地区查询】接口获取 对应 code字段
object1 . put ( " countyCode " , tbPlussRegionLklService . getOne ( new QueryWrapper < TbPlussRegionLklEntity > ( ) . likeRight ( " name " , merchantBaseInfo . getDistrict ( ) ) . last ( " limit 1 " ) ) . getCode ( ) ) ; // 区县代码 通过【地区信息→获取地区查询】接口获取 对应 code字段
if ( ! merchantBaseInfo . getMerchantType ( ) . equals ( " 1 " ) ) {
object1 . put ( " provinceCode " , tbPlussRegionLklService . getOne ( new QueryWrapper < TbPlussRegionLklEntity > ( ) . likeRight ( " name " , merchantBaseInfo . getProvince ( ) ) . last ( " limit 1 " ) ) . getCode ( ) ) ; //省代码 通过【地区信息→获取地区查询】接口获取 对应 code字段
object1 . put ( " cityCode " , tbPlussRegionLklService . getOne ( new QueryWrapper < TbPlussRegionLklEntity > ( ) . likeRight ( " name " , merchantBaseInfo . getCity ( ) ) . last ( " limit 1 " ) ) . getCode ( ) ) ; // 市代码 通过【地区信息→获取地区查询】接口获取 对应 code字段
object1 . put ( " countyCode " , tbPlussRegionLklService . getOne ( new QueryWrapper < TbPlussRegionLklEntity > ( ) . likeRight ( " name " , merchantBaseInfo . getDistrict ( ) ) . last ( " limit 1 " ) ) . getCode ( ) ) ; // 区县代码 通过【地区信息→获取地区查询】接口获取 对应 code字段
Set < Object > attchmentsVoSet = new HashSet < > ( ) ;
QueryWrapper < Account > accountQueryWrapper1 = new QueryWrapper < > ( ) ;
accountQueryWrapper1 . eq ( " userId " , userId ) ;
accountQueryWrapper1 . eq ( " channelType " , " D1 " ) ;
Account accountServiceOne1 = accountService . getOne ( accountQueryWrapper1 ) ;
MsgException . checkNull ( accountServiceOne1 , " 结算信息未提交 " ) ;
QueryWrapper < BankCard > bankCardWrapper = new QueryWrapper < > ( ) ;
bankCardWrapper . eq ( " id " , accountServiceOne1 . getBankCardId ( ) ) ;
BankCard userBrakCard = bankCardService . getOne ( bankCardWrapper ) ;
MsgException . checkNull ( userBrakCard , " 结算卡信息未提交 " ) ;
QueryWrapper < MccReflect > userAppQueryWrapper = new QueryWrapper ( ) ;
userAppQueryWrapper . eq ( " standard_mcc_code " , merchantBaseInfo . getMcc ( ) ) . eq ( " channel_id " , " 5 " ) . last ( " limit 1 " ) ;
MccReflect mccReflect = service . getOne ( userAppQueryWrapper ) ;
if ( ! merchantBaseInfo . getMerchantType ( ) . equals ( " 1 " ) ) {
object1 . put ( " merRegName " , merchantBaseInfo . getMerchantName ( ) ) ;
object1 . put ( " merName " , merchantBaseInfo . getMerchantName ( ) ) ;
object1 . put ( " licenseName " , merchantBaseInfo . getBussAuthName ( ) ) ; //营业执照名称
object1 . put ( " licenseNo " , merchantBaseInfo . getBussAuthNum ( ) ) ; //营业执照号码 ⼩微商户可不传, 其他必传
StringBuffer startSb = new StringBuffer ( ) ;
StringBuffer endSb = new StringBuffer ( ) ;
StringBuffer startSb = new StringBuffer ( ) ;
StringBuffer endSb = new StringBuffer ( ) ;
if ( merchantBaseInfo . getBussAuthStartTime ( ) . contains ( " 年 " ) ) {
startSb . append ( merchantBaseInfo . getBussAuthStartTime ( ) . substring ( 0 , 4 ) ) ;
if ( merchantBaseInfo . getBussAuthStartTime ( ) . contains ( " 年 " ) ) {
startSb . append ( merchantBaseInfo . getBussAuthStartTime ( ) . substring ( 0 , 4 ) ) ;
startSb . append ( " - " ) ;
startSb . append ( merchantBaseInfo . getBussAuthStartTime ( ) . substring ( 5 , 7 ) ) ;
startSb . append ( merchantBaseInfo . getBussAuthStartTime ( ) . substring ( 5 , 7 ) ) ;
startSb . append ( " - " ) ;
startSb . append ( merchantBaseInfo . getBussAuthStartTime ( ) . substring ( 8 , 10 ) ) ;
} else {
startSb . append ( merchantBaseInfo . getBussAuthStartTime ( ) . substring ( 8 , 10 ) ) ;
} else {
startSb . append ( merchantBaseInfo . getBussAuthStartTime ( ) ) ;
}
if ( ObjectUtil . isEmpty ( merchantBaseInfo . getBussAuthEndTime ( ) ) | | " 长期 " . equals ( merchantBaseInfo . getBuslicType ( ) ) ) {
if ( ObjectUtil . isEmpty ( merchantBaseInfo . getBussAuthEndTime ( ) ) | | " 长期 " . equals ( merchantBaseInfo . getBuslicType ( ) ) ) {
endSb . append ( " 2099-12-31 " ) ;
} else {
if ( merchantBaseInfo . getBussAuthEndTime ( ) . contains ( " 年 " ) ) {
endSb . append ( merchantBaseInfo . getBussAuthEndTime ( ) . substring ( 0 , 4 ) ) ;
} else {
if ( merchantBaseInfo . getBussAuthEndTime ( ) . contains ( " 年 " ) ) {
endSb . append ( merchantBaseInfo . getBussAuthEndTime ( ) . substring ( 0 , 4 ) ) ;
endSb . append ( " - " ) ;
endSb . append ( merchantBaseInfo . getBussAuthEndTime ( ) . substring ( 5 , 7 ) ) ;
endSb . append ( merchantBaseInfo . getBussAuthEndTime ( ) . substring ( 5 , 7 ) ) ;
endSb . append ( " - " ) ;
endSb . append ( merchantBaseInfo . getBussAuthEndTime ( ) . substring ( 8 , 10 ) ) ;
} else {
endSb . append ( merchantBaseInfo . getBussAuthEndTime ( ) . substring ( 8 , 10 ) ) ;
} else {
endSb . append ( merchantBaseInfo . getBussAuthEndTime ( ) ) ;
}
@@ -238,6 +271,61 @@ public class LaKalaInterfaceImpl {
object1 . put ( " licenseDtStart " , startSb ) ; //营业执照开始时间⼩微商户可不传, 其他必传, 格式yyyy-MM-dd
object1 . put ( " licenseDtEnd " , endSb ) ; //⼩微商户可不传, 其他必传, 格式yyyy-MM-dd
QueryWrapper < MerchantImage > imageQueryWrapper = new QueryWrapper < > ( ) ;
imageQueryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
imageQueryWrapper . eq ( " photoType " , " 03 " ) ;
MerchantImage image = merchantImageMapper . selectOne ( imageQueryWrapper ) ;
MsgException . checkNull ( image , " 营业执照不存在 " ) ;
//营业执照
AttchmentsVo business_licence = new AttchmentsVo ( ) ; //图片set
business_licence . setId ( laKaLaFileUpload ( image . getPicUrl ( ) , " BUSINESS_LICENCE " ) ) ; //营业执照
business_licence . setType ( " BUSINESS_LICENCE " ) ; //营业执照
attchmentsVoSet . add ( business_licence ) ;
//开户许可证
AttchmentsVo opening_permit = new AttchmentsVo ( ) ; //图片set
opening_permit . setId ( laKaLaFileUpload ( userBrakCard . getLicenseUrl ( ) , " OPENING_PERMIT " ) ) ; //开户许可证
opening_permit . setType ( " OPENING_PERMIT " ) ; //开户许可证
attchmentsVoSet . add ( opening_permit ) ;
Map < String , Object > data = new HashMap < > ( ) ;
data . put ( " customerName " , merchantBaseInfo . getMerchantName ( ) ) ;
data . put ( " licenseNo " , merchantBaseInfo . getBussAuthNum ( ) ) ;
data . put ( " legalName " , idCard . getCertName ( ) ) ;
data . put ( " licenseName " , merchantBaseInfo . getMerchantName ( ) ) ;
data . put ( " identityNo " , idCard . getCertNo ( ) ) ;
data . put ( " address " , merchantBaseInfo . getProvince ( ) . concat ( merchantBaseInfo . getCity ( ) ) . concat ( merchantBaseInfo . getDistrict ( ) ) ) ;
data . put ( " receiveDetail " , merchantBaseInfo . getProvince ( ) . concat ( merchantBaseInfo . getCity ( ) ) . concat ( merchantBaseInfo . getDistrict ( ) ) . concat ( merchantBaseInfo . getAddress ( ) ) ) ;
data . put ( " identityNoExpire " , endSb ) ;
data . put ( " accountName " , userBrakCard . getBankHolder ( ) ) ;
data . put ( " accountIdCard " , idCard . getCertNo ( ) ) ;
data . put ( " accountNo " , userBrakCard . getBankCardNo ( ) ) ;
data . put ( " accountIdDtEnd " , idCard . getCertEndTime ( ) . equals ( " 长期 " ) ? " 2099-12-31 " : DateUtils . convertString ( idCard . getCertEndTime ( ) ) ) ;
data . put ( " bankName " , userBrakCard . getBankName ( ) ) ;
data . put ( " mail " , " chaozhanggui2023@163.com " ) ;
data . put ( " contactManName " , userBrakCard . getPhone ( ) ) ;
data . put ( " channelType " , ObjectUtils . isEmpty ( mccReflect ) ? " 7399 " : mccReflect . getMccCode ( ) ) ;
data . put ( " phone " , userBrakCard . getPhone ( ) ) ;
data . put ( " agencyName " , merchantBaseInfo . getBussAuthNum ( ) ) ;
// //协议
AttchmentsVo agree_ment = new AttchmentsVo ( ) ; //图片set
try {
agree_ment . setId ( laKaLaFileUpload ( HtmlUtil . createAgreementPicture ( HtmlUtil . writeHtml ( data ) ) , " AGREE_MENT " ) ) ; //协议
agree_ment . setType ( " AGREE_MENT " ) ; //协议
attchmentsVoSet . add ( agree_ment ) ;
} catch ( IOException e ) {
throw new RuntimeException ( e ) ;
} catch ( TemplateException e ) {
throw new RuntimeException ( e ) ;
}
}
object1 . put ( " latitude " , " 108.94647 " ) ; //经度 进件所在地址经度error
@@ -254,23 +342,10 @@ public class LaKalaInterfaceImpl {
object1 . put ( " contactName " , merchantBaseInfo . getContactName ( ) ) ; //商户联系⼈姓名
QueryWrapper < Account > accountQueryWrapper1 = new QueryWrapper < > ( ) ;
accountQueryWrapper1 . eq ( " userId " , userId ) ;
accountQueryWrapper1 . eq ( " channelType " , " D1 " ) ;
Account accountServiceOne1 = accountService . getOne ( accountQueryWrapper1 ) ;
MsgException . checkNull ( accountServiceOne1 , " 结算信息未提交 " ) ;
QueryWrapper < BankCard > bankCardWrapper = new QueryWrapper < > ( ) ;
bankCardWrapper . eq ( " id " , accountServiceOne1 . getBankCardId ( ) ) ;
BankCard userBrakCard = bankCardService . getOne ( bankCardWrapper ) ;
MsgException . checkNull ( userBrakCard , " 结算卡信息未提交 " ) ;
QueryWrapper < TbPlussBankBranchLklEntity > lklEntityQueryWrapper = new QueryWrapper < > ( ) ;
lklEntityQueryWrapper . eq ( " branch_bank_no " , userBrakCard . getContactLine ( ) ) ;
TbPlussBankBranchLklEntity lakalaBranchInfo = tbPlussBankBranchLklService . getOne ( lklEntityQueryWrapper ) ;
MsgException . checkNull ( lakalaBranchInfo , " 结算卡对应的分行支行信息不存在 " ) ;
MsgException . checkNull ( lakalaBranchInfo , " 结算卡对应的分行支行信息不存在 " ) ;
object1 . put ( " openningBankCode " , lakalaBranchInfo . getBranchBankNo ( ) ) ; //结算账户开户⾏号 通过【银行列表查询】接口获取 对应 branchBankNo字段
object1 . put ( " openningBankName " , lakalaBranchInfo . getBranchBankName ( ) ) ; //结算账户开户⾏名称 通过【银行列表查询】接口获取 对应 branchBankName字段
@@ -280,11 +355,11 @@ public class LaKalaInterfaceImpl {
QueryWrapper < TbPlussBankRegionLklEntity > regionLklEntityQueryWrapper = new QueryWrapper < > ( ) ;
regionLklEntityQueryWrapper . eq ( " code " , lakalaBranchInfo . getAreaCode ( ) ) ;
TbPlussBankRegionLklEntity bankParentCode = regionLklService . getOne ( regionLklEntityQueryWrapper ) ; //市code 和 name
MsgException . checkNull ( bankParentCode , " 结算卡对应的省份信息不存在 " ) ;
MsgException . checkNull ( bankParentCode , " 结算卡对应的省份信息不存在 " ) ;
regionLklEntityQueryWrapper . clear ( ) ;
regionLklEntityQueryWrapper . eq ( " code " , bankParentCode . getParentCode ( ) ) ;
TbPlussBankRegionLklEntity parentCode = regionLklService . getOne ( regionLklEntityQueryWrapper ) ; //省code 和 名称
MsgException . checkNull ( bankParentCode , " 结算卡对应的城市信息不存在 " ) ;
MsgException . checkNull ( bankParentCode , " 结算卡对应的城市信息不存在 " ) ;
object1 . put ( " settleProvinceCode " , parentCode . getCode ( ) ) ; //结算信息省份名称 通过【地区信息→获取银行地区查询】接口获取 对应 code字段
object1 . put ( " settleProvinceName " , parentCode . getName ( ) ) ; //结算信息省份代码 通过【地区信息→获取银行地区查询】接口获取 对应 name字段
@@ -292,16 +367,55 @@ public class LaKalaInterfaceImpl {
object1 . put ( " settleCityName " , bankParentCode . getName ( ) ) ; //结算信息城市代码 通过【地区信息→获取银行地区查询】接口获取 对应 name字段
AccountDTO accountV4 = getAccountV4 ( userId , " D1 " ) ; //结算人
MsgException . checkNull ( accountV4 , " 结算信息不存在 " ) ;
MsgException . checkNull ( accountV4 , " 结算信息不存在 " ) ;
object1 . put ( " accountNo " , accountV4 . getBankCard ( ) . getBankCardNo ( ) ) ; //结算人银行卡号
object1 . put ( " accountName " , accountV4 . getBankCard ( ) . getBankHolder ( ) ) ; //结算人账户名称
object1 . put ( " accountType " , accountV4 . getBankCard ( ) . getAccountType ( ) . equals ( " 01 " ) ? " 58 " : " 57 " ) ; //结算账户类型 57 对公 58 对私
object1 . put ( " accountType " , accountV4 . getBankCard ( ) . getAccountType ( ) . equals ( " 01 " ) ? " 58 " : " 57 " ) ; //结算账户类型 57 对公 58 对私
// object1.put("accountIdType",tuoKeVo.getUserNo()); //结算⼈证件类型 为空同法⼈
object1 . put ( " accountIdCard " , accountV4 . getIdcard ( ) . getCertNo ( ) ) ; //结算⼈证件号码
if ( ! accountV4 . getBankCard ( ) . getAccountType ( ) . equals ( " 1 " ) ) {
QueryWrapper < MerchantImage > imageQueryWrapper = new QueryWrapper < > ( ) ;
imageQueryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
imageQueryWrapper . eq ( " photoType " , " 08 " ) ;
MerchantImage image = merchantImageMapper . selectOne ( imageQueryWrapper ) ;
MsgException . checkNull ( image , " 收银台照片不存在 " ) ;
JSONArray array = new JSONArray ( ) ;
//对公收银台照片
AttchmentsVo checkstand_img = new AttchmentsVo ( ) ;
checkstand_img . setId ( laKaLaFileUpload ( accountV4 . getIdcard ( ) . getImgNegative ( ) , " CHECKSTAND_IMG " ) ) ; //收银台照片
checkstand_img . setType ( " CHECKSTAND_IMG " ) ; //收银台照片
attchmentsVoSet . add ( checkstand_img ) ;
imageQueryWrapper . clear ( ) ;
imageQueryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
imageQueryWrapper . eq ( " photoType " , " 06 " ) ;
image = merchantImageMapper . selectOne ( imageQueryWrapper ) ;
MsgException . checkNull ( image , " 门头照片不存在 " ) ;
//门头照片
AttchmentsVo shop_outside_img = new AttchmentsVo ( ) ;
shop_outside_img . setId ( laKaLaFileUpload ( image . getPicUrl ( ) , " SHOP_OUTSIDE_IMG " ) ) ; //门头照片
shop_outside_img . setType ( " SHOP_OUTSIDE_IMG " ) ;
attchmentsVoSet . add ( shop_outside_img ) ;
imageQueryWrapper . clear ( ) ;
imageQueryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
imageQueryWrapper . eq ( " photoType " , " 09 " ) ;
image = merchantImageMapper . selectOne ( imageQueryWrapper ) ;
MsgException . checkNull ( image , " 商铺内部照片不存在 " ) ;
//商铺内部照片
AttchmentsVo shop_inside_img = new AttchmentsVo ( ) ;
shop_inside_img . setId ( laKaLaFileUpload ( image . getPicUrl ( ) , " SHOP_INSIDE_IMG " ) ) ; //商铺内部照片
shop_inside_img . setType ( " SHOP_INSIDE_IMG " ) ;
attchmentsVoSet . add ( shop_inside_img ) ;
}
JSONArray array = new JSONArray ( ) ;
Set < FeesSetVo > feesSet = new HashSet < > ( ) ;
FeesSetVo w = new FeesSetVo ( ) ;
@@ -325,22 +439,19 @@ public class LaKalaInterfaceImpl {
object2 . put ( " termNum " , " 5 " ) ; //终端数量 1-5 最⼤ 5个终端
object2 . put ( " fees " , feesSet ) ; //费率集合
QueryWrapper < MccReflect > userAppQueryWrapper = new QueryWrapper ( ) ;
userAppQueryWrapper . eq ( " standard_mcc_code " , merchantBaseInfo . getMcc ( ) ) . eq ( " channel_id " , " 5 " ) . last ( " limit 1 " ) ;
MccReflect mccReflect = service . getOne ( userAppQueryWrapper ) ;
object2 . put ( " mcc " , ObjectUtils . isEmpty ( mccReflect ) ? " 7399 " : mccReflect . getMccCode ( ) ) ; //商户MCC编号 通过 【商户类别查询→查询小类】接口获取 对应 code字段
object2 . put ( " activityId " , " 37 " ) ; //归属活动信息 由拓客SAAS分配
object2 . put ( " mcc " , ObjectUtils . isEmpty ( mccReflect ) ? " 7399 " : mccReflect . getMccCode ( ) ) ; //商户MCC编号 通过 【商户类别查询→查询小类】接口获取 对应 code字段
object2 . put ( " activityId " , " 37 " ) ; //归属活动信息 由拓客SAAS分配
object1 . put ( " bizContent " , object2 ) ; //业务扩展信息 参⻅ 业务扩展信息
Set < Object > attchmentsVoSet = new HashSet < > ( ) ;
AttchmentsVo frontLegalPerson = new AttchmentsVo ( ) ; //图片set
frontLegalPerson . setId ( laKaLaFileUpload ( accountV4 . getIdcard ( ) . getImgPositive ( ) ) ) ; //法人身份证图片地址
frontLegalPerson . setId ( laKaLaFileUpload ( accountV4 . getIdcard ( ) . getImgPositive ( ) , " ID_CARD_FRONT " )) ; //法人身份证图片地址
frontLegalPerson . setType ( " ID_CARD_FRONT " ) ; //身份证正⾯
attchmentsVoSet . add ( frontLegalPerson ) ;
AttchmentsVo reverseLegalPerson = new AttchmentsVo ( ) ;
reverseLegalPerson . setId ( accountV4 . getIdcard ( ) . getImgNegative ( ) ) ; //法人身份证图片地址
reverseLegalPerson . setId ( laKaLaFileUpload ( accountV4. getIdcard ( ) . getImgNegative ( ) , " ID_CARD_BEHIND " ) ); //法人身份证图片地址
reverseLegalPerson . setType ( " ID_CARD_BEHIND " ) ; //身份证反⾯
attchmentsVoSet . add ( reverseLegalPerson ) ;
@@ -351,26 +462,29 @@ public class LaKalaInterfaceImpl {
System . out . println ( " 请求报文: " + object1 ) ;
/**获取拓客accessToken**/
Map map = getToken ( ) ;
String result = " " ;
try {
String result = " " ;
try {
result = cn . hutool . http . HttpRequest . post ( tuoKeMerchat )
. header ( " Authorization " , " bearer " + map . get ( " access_token " ) ) . header ( " content-type " , " application/json " )
. body ( object1 . toString ( ) ) . execute ( ) . body ( ) ;
System . out . println ( " 返回结果: " + result ) ;
System . out . println ( " 返回结果: " + result ) ;
Map arry = ( Map ) JSONArray . parse ( result ) ;
if ( String . valueOf ( arry . get ( " status " ) ) . equals ( " WAIT_AUDI " ) ) {
PlussMerchantLklEntity plussMerchantLklEntity = new PlussMerchantLklEntity ( ) ;
if ( String . valueOf ( arry . get ( " status " ) ) . equals ( " WAIT_AUDI " ) ) {
PlussMerchantLklEntity plussMerchantLklEntity = new PlussMerchantLklEntity ( ) ;
plussMerchantLklEntity . setMerchantId ( merchantBaseInfo . getMerchantCode ( ) ) ;
plussMerchantLklEntity . setMerchantlkl ( String . valueOf ( arry . get ( " merchantNo " ) ) ) ;
plussMerchantLklEntity . setType ( " 0 " ) ;
merchantLklService . save ( plussMerchantLklEntity ) ;
QueryWrapper < MerchantChannelFee > feeQueryWrapper = new QueryWrapper < > ( ) ;
feeQueryWrapper . eq ( " channel " , " 5 " ) ;
feeQueryWrapper . eq ( " merchant_code " , mcs . getMerchantCode ( ) ) ;
MerchantChannelFee merchantChannelFee = merchantChannelFeeMapper . selectOne ( feeQueryWrapper ) ;
if ( ObjectUtil . isEmpty ( merchantChannelFee ) ) {
QueryWrapper < MerchantChannelFee > feeQueryWrapper = new QueryWrapper < > ( ) ;
feeQueryWrapper . eq ( " channel " , " 5 " ) ;
feeQueryWrapper . eq ( " merchant_code " , mcs . getMerchantCode ( ) ) ;
MerchantChannelFee merchantChannelFee = merchantChannelFeeMapper . selectOne ( feeQueryWrapper ) ;
if ( ObjectUtil . isEmpty ( merchantChannelFee ) ) {
merchantChannelFee = new MerchantChannelFee ( ) ;
merchantChannelFee . setChannel ( 5 ) ;
merchantChannelFee . setMerchantCode ( merchantBaseInfo . getMerchantCode ( ) ) ;
merchantChannelFee . setFeeStr ( array . toJSONString ( ) ) ;
@@ -379,7 +493,6 @@ public class LaKalaInterfaceImpl {
}
mcs . setChannel ( 5 ) ;
mcs . setUpdateTime ( new Date ( ) ) ;
mcs . setMerchantCode ( merchantBaseInfo . getMerchantCode ( ) ) ;
@@ -406,11 +519,11 @@ public class LaKalaInterfaceImpl {
System . out . println ( " >>>>>>>>>>>>>>> " ) ;
} else {
JSONObject object = JSONObject . parseObject ( result ) ;
} else {
JSONObject object = JSONObject . parseObject ( result ) ;
MsgException . throwException ( object . getString ( " message " ) ) ;
}
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
Map arry = ( Map ) JSONArray . parse ( result ) ;
new MsgException ( String . valueOf ( arry . get ( " message " ) ) ) ;
@@ -418,51 +531,49 @@ public class LaKalaInterfaceImpl {
}
public void merchantAudit ( String userId ) {
public void merchantAudit ( String userId ) {
MerchantBaseInfo merchantBaseInfo = mbiService . getMerchantBaseInfoByUserId ( userId ) ;
MsgException . checkNull ( merchantBaseInfo , " 商户进件信息不存在 " ) ;
MsgException . checkNull ( merchantBaseInfo , " 商户进件信息不存在 " ) ;
QueryWrapper < MerchantChannelStatus > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( " channel " , " 5 " ) ;
List < Integer > list = new ArrayList < > ( ) ;
QueryWrapper < MerchantChannelStatus > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( " channel " , " 5 " ) ;
List < Integer > list = new ArrayList < > ( ) ;
list . add ( 1 ) ;
list . add ( 6 ) ;
queryWrapper . in ( " status " , list ) ;
queryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
MerchantChannelStatus mcs = merchantChannelStatusMapper . selectOne ( queryWrapper ) ;
MsgException . checkNull ( mcs , " 对应的商户信息不存在 " ) ;
queryWrapper . in ( " status " , list ) ;
queryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
MerchantChannelStatus mcs = merchantChannelStatusMapper . selectOne ( queryWrapper ) ;
MsgException . checkNull ( mcs , " 对应的商户信息不存在 " ) ;
AccountDTO accountV4 = getAccountV4 ( userId , " D1 " ) ; //结算人
MsgException . checkNull ( accountV4 , " 结算信息不存在 " ) ;
MsgException . checkNull ( accountV4 , " 结算信息不存在 " ) ;
JSONObject object = new JSONObject ( ) ;
object . put ( " accountKind " , accountV4 . getBankCard ( ) . getAccountType ( ) . equals ( " 01 " ) ? " 58 " : " 57 " ) ;
JSONObject object = new JSONObject ( ) ;
object . put ( " accountKind " , accountV4 . getBankCard ( ) . getAccountType ( ) . equals ( " 01 " ) ? " 58 " : " 57 " ) ;
object . put ( " accountNo " , accountV4 . getBankCard ( ) . getBankCardNo ( ) ) ; //结算人银行卡号
object . put ( " accountName " , accountV4 . getBankCard ( ) . getBankHolder ( ) ) ; //结算人账户名称
Set < ConcurrentMap < String , String > > attchmentsVoSet = new HashSet < > ( ) ;
ConcurrentMap < String , String > frontLegalPersonMap = new ConcurrentHashMap < > ( ) ;
frontLegalPersonMap . put ( " imgPath " , laKaLaFileUpload ( accountV4 . getIdcard ( ) . getImgPositive ( ) ) ) ;
frontLegalPersonMap . put ( " imgType " , " ID_CARD_FRONT " ) ;
Set < ConcurrentMap < String , String > > attchmentsVoSet = new HashSet < > ( ) ;
ConcurrentMap < String , String > frontLegalPersonMap = new ConcurrentHashMap < > ( ) ;
frontLegalPersonMap . put ( " imgPath " , laKaLaFileUpload ( accountV4 . getIdcard ( ) . getImgPositive ( ) , " ID_CARD_FRONT " )) ;
frontLegalPersonMap . put ( " imgType " , " ID_CARD_FRONT " ) ;
attchmentsVoSet . add ( frontLegalPersonMap ) ;
ConcurrentMap < String , String > reverseLegalPersonMap = new ConcurrentHashMap < > ( ) ;
reverseLegalPersonMap . put ( " imgPath " , laKaLaFileUpload ( accountV4 . getIdcard ( ) . getImgNegative ( ) ) ) ;
reverseLegalPersonMap . put ( " imgType " , " ID_CARD_BEHIND " ) ;
ConcurrentMap < String , String > reverseLegalPersonMap = new ConcurrentHashMap < > ( ) ;
reverseLegalPersonMap . put ( " imgPath " , laKaLaFileUpload ( accountV4 . getIdcard ( ) . getImgNegative ( ) , " ID_CARD_BEHIND " )) ;
reverseLegalPersonMap . put ( " imgType " , " ID_CARD_BEHIND " ) ;
attchmentsVoSet . add ( reverseLegalPersonMap ) ;
object . put ( " attachments " , attchmentsVoSet ) ;
object . put ( " attachments " , attchmentsVoSet ) ;
QueryWrapper < Account > accountQueryWrapper1 = new QueryWrapper < > ( ) ;
accountQueryWrapper1 . eq ( " userId " , userId ) ;
accountQueryWrapper1 . eq ( " channelType " , " D1 " ) ;
Account accountServiceOne1 = accountService . getOne ( accountQueryWrapper1 ) ;
MsgException . checkNull ( accountServiceOne1 , " 结算信息未提交 " ) ;
MsgException . checkNull ( accountServiceOne1 , " 结算信息未提交 " ) ;
QueryWrapper < BankCard > bankCardWrapper = new QueryWrapper < > ( ) ;
@@ -473,30 +584,30 @@ public class LaKalaInterfaceImpl {
QueryWrapper < TbPlussBankBranchLklEntity > lklEntityQueryWrapper = new QueryWrapper < > ( ) ;
lklEntityQueryWrapper . eq ( " branch_bank_no " , userBrakCard . getContactLine ( ) ) ;
TbPlussBankBranchLklEntity lakalaBranchInfo = tbPlussBankBranchLklService . getOne ( lklEntityQueryWrapper ) ;
MsgException . checkNull ( lakalaBranchInfo , " 结算卡对应的分行支行信息不存在 " ) ;
MsgException . checkNull ( lakalaBranchInfo , " 结算卡对应的分行支行信息不存在 " ) ;
object . put ( " bankNo " , lakalaBranchInfo . getBranchBankNo ( ) ) ; //结算账户开户⾏号 通过【银行列表查询】接口获取 对应 branchBankNo字段
object . put ( " bankName " , lakalaBranchInfo . getBranchBankName ( ) ) ; //结算账户开户⾏名称 通过【银行列表查询】接口获取 对应 branchBankName字段
object . put ( " clearingBankNo " , lakalaBranchInfo . getClearNo ( ) ) ; //结算账户清算⾏号 通过【银行列表查询】接口获取 对应 clearNo字段
JSONObject req = new JSONObject ( ) ;
req . put ( " dto " , object ) ;
req . put ( " customerNo " , Integer . valueOf ( mcs . getMerchantId ( ) ) ) ;
JSONObject req = new JSONObject ( ) ;
req . put ( " dto " , object ) ;
req . put ( " customerNo " , Integer . valueOf ( mcs . getMerchantId ( ) ) ) ;
Map map = getModifyToken ( " 19191703856 " , " klb1qaz " ) ;
String result = " " ;
Map map = getModifyToken ( " 19191703856 " , " klb1qaz " ) ;
String result = " " ;
try {
String url = " https://tkapi.lakala.com/htkmerchants/channel/customer/update/settle/ " ;
String url = " https://tkapi.lakala.com/htkmerchants/channel/customer/update/settle/ " ;
result = cn . hutool . http . HttpRequest . post ( url . concat ( mcs . getMerchantId ( ) ) )
. header ( " Authorization " , " bearer " + map . get ( " access_token " ) ) . header ( " content-type " , " application/json " )
. body ( req . toString ( ) ) . execute ( ) . body ( ) ;
System . out . println ( " 返回结果: " + result ) ;
Map arry = ( Map ) JSONArray . parse ( result ) ;
if ( arry . containsKey ( " message " ) & & " SUCCESS " . equals ( arry . get ( " message " ) + " " ) ) {
if ( arry . containsKey ( " message " ) & & " SUCCESS " . equals ( arry . get ( " message " ) + " " ) ) {
// 保存商户进件修改记录
MerchantAuditRecord updateRecord = new MerchantAuditRecord ( ) ;
updateRecord . setMerchantId ( mcs . getMerchantId ( ) ) ;
updateRecord . setApplicationId ( arry . get ( " reviewRelatedId " ) + " " ) ;
updateRecord . setApplicationId ( arry . get ( " reviewRelatedId " ) + " " ) ;
updateRecord . setChannel ( 5 ) ;
updateRecord . setStatus ( " 1 " ) ;
updateRecord . setMerchantCode ( merchantBaseInfo . getMerchantCode ( ) ) ;
@@ -504,96 +615,94 @@ public class LaKalaInterfaceImpl {
merchAuditRecService . save ( updateRecord ) ;
// 修改商户状态
mcs . setStatus ( MerchantChannelStatus . AUDIT_STATUS_DATA_EDIT ) ;
mcs . setApplicationId ( arry . get ( " reviewRelatedId " ) + " " ) ;
mcs . setApplicationId ( arry . get ( " reviewRelatedId " ) + " " ) ;
mcsService . updateById ( mcs ) ;
} else {
} else {
MsgException . throwException ( " 修改进件信息失败 " ) ;
}
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
}
@Autowired
@Lazy
MerchantChannelFeeMapper merchantChannelFeeMapper ;
public void merchAuditFee ( String userId ) {
public void merchAuditFee ( String userId ) {
MerchantBaseInfo merchantBaseInfo = mbiService . getMerchantBaseInfoByUserId ( userId ) ;
MsgException . checkNull ( merchantBaseInfo , " 商户进件信息不存在 " ) ;
MsgException . checkNull ( merchantBaseInfo , " 商户进件信息不存在 " ) ;
QueryWrapper < MerchantChannelStatus > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( " channel " , " 5 " ) ;
List < Integer > list = new ArrayList < > ( ) ;
QueryWrapper < MerchantChannelStatus > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( " channel " , " 5 " ) ;
List < Integer > list = new ArrayList < > ( ) ;
list . add ( 1 ) ;
list . add ( 6 ) ;
queryWrapper . in ( " status " , list ) ;
queryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
MerchantChannelStatus mcs = merchantChannelStatusMapper . selectOne ( queryWrapper ) ;
MsgException . checkNull ( mcs , " 对应的商户信息不存在 " ) ;
queryWrapper . in ( " status " , list ) ;
queryWrapper . eq ( " merchantCode " , merchantBaseInfo . getMerchantCode ( ) ) ;
MerchantChannelStatus mcs = merchantChannelStatusMapper . selectOne ( queryWrapper ) ;
MsgException . checkNull ( mcs , " 对应的商户信息不存在 " ) ;
QueryWrapper < MerchantChannelFee > feeQueryWrapper = new QueryWrapper < > ( ) ;
feeQueryWrapper . eq ( " channel " , " 5 " ) ;
feeQueryWrapper . eq ( " merchant_code " , merchantBaseInfo . getMerchantCode ( ) ) ;
QueryWrapper < MerchantChannelFee > feeQueryWrapper = new QueryWrapper < > ( ) ;
feeQueryWrapper . eq ( " channel " , " 5 " ) ;
feeQueryWrapper . eq ( " merchant_code " , merchantBaseInfo . getMerchantCode ( ) ) ;
MerchantChannelFee fee = merchantChannelFeeMapper . selectOne ( feeQueryWrapper ) ;
MsgException . checkNull ( fee , " 费率值为空 " ) ;
JSONArray array = JSONArray . parseArray ( fee . getFeeStr ( ) ) ;
JSONArray feeAarray = new JSONArray ( ) ;
for ( int i = 0 ; i < array . size ( ) ; i + + ) {
JSONObject req = array . getJSONObject ( i ) ;
JSONObject object = new JSONObject ( ) ;
object . put ( " fee " , req . getDoubleValue ( " feeValue " ) ) ;
object . put ( " feeType " , req . getString ( " feeCode " ) ) ;
MerchantChannelFee fee = merchantChannelFeeMapper . selectOne ( feeQueryWrapper ) ;
MsgException . checkNull ( fee , " 费率值为空 " ) ;
JSONArray array = JSONArray . parseArray ( fee . getFeeStr ( ) ) ;
JSONArray feeAarray = new JSONArray ( ) ;
for ( int i = 0 ; i < array . size ( ) ; i + + ) {
JSONObject req = array . getJSONObject ( i ) ;
JSONObject object = new JSONObject ( ) ;
object . put ( " fee " , req . getDoubleValue ( " feeValue " ) ) ;
object . put ( " feeType " , req . getString ( " feeCode " ) ) ;
feeAarray . add ( object ) ;
}
JSONObject request = new JSONObject ( ) ;
JSONObject request = new JSONObject ( ) ;
// JSONObject o=new JSONObject();
// o.put("fees",feeAarray);
request . put ( " settleType " , mcs . getVirChannelFlag ( ) ) ;
request . put ( " fees " , feeAarray ) ;
request . put ( " customerNo " , Integer . valueOf ( mcs . getMerchantId ( ) ) ) ;
request . put ( " settleType " , mcs . getVirChannelFlag ( ) ) ;
request . put ( " fees " , feeAarray ) ;
request . put ( " customerNo " , Integer . valueOf ( mcs . getMerchantId ( ) ) ) ;
Map map = getModifyToken ( " 19191703856 " , " klb1qaz " ) ;
String result = " " ;
Map map = getModifyToken ( " 19191703856 " , " klb1qaz " ) ;
String result = " " ;
try {
String url = " https://tkapi.lakala.com/htkmerchants/channel/customer/update/fee/ " ;
String url = " https://tkapi.lakala.com/htkmerchants/channel/customer/update/fee/ " ;
result = cn . hutool . http . HttpRequest . post ( url . concat ( mcs . getMerchantId ( ) ) )
. header ( " Authorization " , " bearer " + map . get ( " access_token " ) ) . header ( " content-type " , " application/json " )
. body ( request . toString ( ) ) . execute ( ) . body ( ) ;
System . out . println ( " 返回结果: " + result ) ;
Map arry = ( Map ) JSONArray . parse ( result ) ;
if ( arry . containsKey ( " message " ) & & " SUCCESS " . equals ( arry . get ( " message " ) + " " ) ) {
if ( arry . containsKey ( " message " ) & & " SUCCESS " . equals ( arry . get ( " message " ) + " " ) ) {
// 保存商户进件修改记录
MerchantAuditRecord updateRecord = new MerchantAuditRecord ( ) ;
updateRecord . setMerchantId ( mcs . getMerchantId ( ) ) ;
updateRecord . setApplicationId ( arry . get ( " reviewRelatedId " ) + " " ) ;
updateRecord . setApplicationId ( arry . get ( " reviewRelatedId " ) + " " ) ;
updateRecord . setChannel ( 5 ) ;
updateRecord . setStatus ( " 1 " ) ;
updateRecord . setMerchantCode ( merchantBaseInfo . getMerchantCode ( ) ) ;
// 文档上没有返回状态码
merchAuditRecService . save ( updateRecord ) ;
// 修改商户状态
mcs . setApplicationId ( arry . get ( " reviewRelatedId " ) + " " ) ;
mcs . setApplicationId ( arry . get ( " reviewRelatedId " ) + " " ) ;
mcsService . updateById ( mcs ) ;
} else {
} else {
MsgException . throwException ( " 修改进件信息失败 " ) ;
}
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
}
/**
* 获取拓客accessToken
*/
@@ -617,9 +726,7 @@ public class LaKalaInterfaceImpl {
}
public static Map getModifyToken ( String userName , String password ) {
public static Map getModifyToken ( String userName , String password ) {
RestTemplate client = new RestTemplate ( ) ;
HttpHeaders headers = new HttpHeaders ( ) ;
// 表单提交
@@ -632,7 +739,7 @@ public class LaKalaInterfaceImpl {
params . add ( " password " , password ) ;
HttpEntity < MultiValueMap < String , String > > requestEntity = new HttpEntity < MultiValueMap < String , String > > ( params , headers ) ;
// 执行HTTP请求
String url = " https://htkapi.lakala.com/auth/oauth/token " ;
String url = " https://htkapi.lakala.com/auth/oauth/token " ;
ResponseEntity < String > response = client . exchange ( url , HttpMethod . POST , requestEntity , String . class ) ;
Map map = ( Map ) JSONArray . parse ( response . getBody ( ) ) ;
@@ -640,39 +747,32 @@ public class LaKalaInterfaceImpl {
}
public Map queryMerchat ( String customerNo , String externalCustomerNo ) {
public Map queryMerchat ( String customerNo , String externalCustomerNo ) {
Map map = getToken ( ) ;
try {
JSONObject object = new JSONObject ( ) ;
if ( ObjectUtil . isNotEmpty ( customerNo ) ) {
object . put ( " customerNo " , customerNo ) ;
try {
JSONObject object = new JSONObject ( ) ;
if ( ObjectUtil . isNotEmpty ( customerNo ) ) {
object . put ( " customerNo " , customerNo ) ;
}
if ( ObjectUtil . isNotEmpty ( externalCustomerNo ) ) {
object . put ( " externalCustomerNo " , externalCustomerNo ) ;
if ( ObjectUtil . isNotEmpty ( externalCustomerNo ) ) {
object . put ( " externalCustomerNo " , externalCustomerNo ) ;
}
JSONObject req = new JSONObject ( ) ;
JSONObject req = new JSONObject ( ) ;
byte [ ] privateKey = Base64 . decodeBase64 ( lakalaConfig . getPrivateKey ( ) ) ;
byte [ ] bytes = RSAUtil . encryptByPrivateKey ( object . toString ( ) . getBytes ( ) , privateKey ) ;
req . put ( " data " , Base64 . encodeBase64String ( bytes ) ) ;
req . put ( " data " , Base64 . encodeBase64String ( bytes ) ) ;
log . info ( " 请求参数:加密前:{},加密后:{} " , object . toString ( ) , req . toString ( ) ) ;
log . info ( " 请求参数:加密前:{},加密后:{} " , object . toString ( ) , req . toString ( ) ) ;
String result = cn . hutool . http . HttpRequest . post ( " https://tkapi.lakala.com/htkmerchants/open/merchant/info " )
. header ( " Authorization " , " bearer " + map . get ( " access_token " ) ) . header ( " content-type " , " application/json " )
. body ( req . toJSONString ( ) ) . execute ( ) . body ( ) ;
Map arry = ( Map ) JSONArray . parse ( result ) ;
log . info ( " 返回参数: " , JSONUtil . toJsonStr ( arry ) ) ;
log . info ( " 返回参数: " , JSONUtil . toJsonStr ( arry ) ) ;
return arry ;
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
@@ -715,14 +815,14 @@ public class LaKalaInterfaceImpl {
*/
public AccountDTO getAccountV4 ( String userId , String type ) {
UserApp userApp = userAppService . getById ( userId ) ;
if ( type = = null ) {
UserApp userApp = userAppService . getById ( userId ) ;
if ( type = = null ) {
MerchantChannelStatus mcs = mcsService . getValidData ( userApp . getMerchantCode ( ) ) ;
if ( mcs = = null | | ! Objects . equals ( mcs . getChannel ( ) , 4 ) ) {
type = Account . CHANNEL_TYPE_D1 ;
type = Account . CHANNEL_TYPE_D1 ;
} else {
type = Account . CHANNEL_TYPE_D0 ;
type = Account . CHANNEL_TYPE_D0 ;
}
}
AccountDTO accountDTO = accountService . getRealAccount ( userId ) ;
@@ -851,7 +951,7 @@ public class LaKalaInterfaceImpl {
// 表单提交
headers . setContentType ( MediaType . APPLICATION_FORM_URLENCODED ) ;
Map parse = getToken ( ) ;
Map parse = getToken ( ) ;
HttpHeaders header = new HttpHeaders ( ) ;
header . set ( " Authorization " , " bearer " + parse . get ( " access_token " ) ) ;
// 封装参数
@@ -873,10 +973,9 @@ public class LaKalaInterfaceImpl {
* 拓客文件上传接口
*/
@SneakyThrows
public String laKaLaFileUpload ( String url1 ) {
RestTemplate restTemplate = new RestTemplate ( ) ;
public static String laKaLaFileUpload ( String url1 , String type ) {
String url = fileUpload ;
MultiValue Map< String , Object > params = new LinkedMultiValue Map< > ( ) ;
Map < String , Object > params = new Hash Map< > ( ) ;
// String url1 = "https://czg-oss.oss-cn-hangzhou.aliyuncs.com/images/9b42a8f68e2b4682bdb72490abe131fe.png?Expires=1994642722&OSSAccessKeyId=LTAI5tPdEfYSZcqHbjCrtPRD&Signature=cTcS0ey%2F6NYWQnyvVCMQsO6rZMU%3D";
URI uri = null ;
@@ -888,36 +987,56 @@ public class LaKalaInterfaceImpl {
RestTemplate restTemplate1 = new RestTemplate ( ) ;
ResponseEntity < byte [ ] > exchange = restTemplate1 . exchange ( uri , HttpMethod . GET , null , byte [ ] . class ) ;
MultipartFile file1 = new MockMultipartFile ( " file " , exchange . getBody ( ) ) ;
ByteArrayResource fileAsResource = new ByteArrayResource ( file1 . getBytes ( ) ) {
@Override
public String getFilename ( ) {
File file = convert ( file1 ) ;
params . put ( " file " , file ) ;
params . put ( " imgType " , type ) ;
params . put ( " sourcechnl " , " 0 " ) ;
params . put ( " isOcr " , " false " ) ;
return file1 . getOriginalFilename ( ) ;
// return null;
}
@Override
public long contentLength ( ) {
// return 0L;
return file1 . getSize ( ) ;
}
} ;
params . add ( " file " , fileAsResource ) ;
params . add ( " imgType " , " ID_CARD_FRONT " ) ;
params . add ( " sourcechnl " , " 1 " ) ;
params . add ( " isOcr " , " false " ) ;
HttpHeaders headers = new HttpHeaders ( ) ;
headers . setContentType ( MediaType . MULTIPART_FORM_DATA ) ;
Map token = getToken ( ) ;
headers . set ( " Authorization " , " bearer " + token . ge t( " access_token " ) ) ;
HttpEntity < MultiValueMap < String , Object > > requestEntity = new HttpEntity < > ( params , headers ) ;
String result = restTemplate . postForObject ( url , requestEntity , String . class ) ;
String result = HttpRequest . pos t( url )
. header ( " Authorization " , " bearer " + token . get ( " access_token " ) )
. form ( params ) . execute ( ) . body ( ) ;
Map parse = ( Map ) JSONArray . parse ( result ) ;
log . info ( " 拉卡拉图片上传返回信息:{} " , result ) ;
return parse . get ( " url " ) . toString ( ) ;
}
@SneakyThrows
public static String laKaLaFileUpload ( File file , String type ) {
RestTemplate restTemplate = new RestTemplate ( ) ;
String url = fileUpload ;
Map < String , Object > params = new HashMap < > ( ) ;
params . put ( " file " , file ) ;
params . put ( " imgType " , type ) ;
params . put ( " sourcechnl " , " 0 " ) ;
params . put ( " isOcr " , " false " ) ;
Map token = getToken ( ) ;
String result = HttpRequest . post ( url )
. header ( " Authorization " , " bearer " + token . get ( " access_token " ) )
. form ( params ) . execute ( ) . body ( ) ;
Map parse = ( Map ) JSONArray . parse ( result ) ;
log . info ( " 拉卡拉图片上传返回信息:{} " , result ) ;
return parse . get ( " url " ) . toString ( ) ;
}
public static File convert ( MultipartFile multipartFile ) throws IOException {
InputStream inputStream = multipartFile . getInputStream ( ) ;
File file = File . createTempFile ( ObjectUtil . isEmpty ( multipartFile . getOriginalFilename ( ) ) ? System . currentTimeMillis ( ) + " " : multipartFile . getOriginalFilename ( ) , " .png " ) ;
FileOutputStream outputStream = new FileOutputStream ( file ) ;
byte [ ] buffer = new byte [ 1024 ] ;
int bytesRead = 0 ;
while ( ( bytesRead = inputStream . read ( buffer ) ) ! = - 1 ) {
outputStream . write ( buffer , 0 , bytesRead ) ;
}
outputStream . close ( ) ;
file . deleteOnExit ( ) ;
return file ;
}
/**
@@ -972,8 +1091,10 @@ public class LaKalaInterfaceImpl {
public static void main ( String [ ] args ) {
Map map = getToken ( ) ;
System. out . println( JSONUtil. toJsonStr( map ) ) ;
// Map map = getToken() ;
// System.out. println( JSONUtil. toJsonStr(map)) ;
System . out . println ( laKaLaFileUpload ( " https://czg-oss.oss-cn-hangzhou.aliyuncs.com/images/819abf620cfe4e6f9e2c432a998090ab.png?Expires=2002093384&OSSAccessKeyId=LTAI5tPdEfYSZcqHbjCrtPRD&Signature=8%2FQMRnkTQmQF8jp93XxayPZbPuU%3D " , " BUSINESS_LICENCE " ) ) ;
// System.out.println(new LaKalaInterfaceImpl().getRegistrationChid());
// String result="";
@@ -991,7 +1112,6 @@ public class LaKalaInterfaceImpl {
// }
// LaKalaInterfaceImpl laKalaInterface = new LaKalaInterfaceImpl();
// laKalaInterface.getOrganCode("1");
// try {