添加拉卡拉修改通道

This commit is contained in:
韩鹏辉 2023-10-16 14:52:53 +08:00
parent bc21e05fd2
commit 80970b1726
6 changed files with 218 additions and 16 deletions

View File

@ -3,6 +3,7 @@ package com.chaozhanggui.dao.system.dao;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantChannelFee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@Component
@ -19,4 +20,6 @@ public interface TbPlussMerchantChannelFeeMapper {
int updateByPrimaryKeySelective(TbPlussMerchantChannelFee record);
int updateByPrimaryKey(TbPlussMerchantChannelFee record);
TbPlussMerchantChannelFee selectByChannelAndMerchantCode(@Param("channelId") Integer channelId,@Param("merchantCode") String merchantCode);
}

View File

@ -54,4 +54,7 @@ public interface TbPlussMerchantChannelStatusMapper {
TbPlussMerchantChannelStatus getIncomingInfoAnother(@Param("merchantCode")String merchantCode);
TbPlussMerchantChannelStatus reject(@Param("merchantCode") String merchantCode,@Param("ids") List<Integer> ids);
TbPlussMerchantChannelStatus selectByChannelAndmerchantCodeAndStatus(@Param("channel") String channel,@Param("merchantCode") String merchantCode);
}

View File

@ -103,4 +103,9 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByChannelAndMerchantCode" resultMap="BaseResultMap">
SELECT * FROM tb_pluss_merchant_channel_fee WHERE merchant_code=#{merchantCode} AND channel=#{channelId}
</select>
</mapper>

View File

@ -473,4 +473,11 @@
WHERE merchantCode=#{merchantCode}
AND status In (3,6)
</select>
<select id="selectByChannelAndmerchantCodeAndStatus" resultMap="BaseResultMap">
SELECT * FROM tb_pluss_merchant_channel_status
WHERE merchantCode=#{merchantCode}
AND status In (1,3,6)
and channel=#{channel}
</select>
</mapper>

View File

@ -31,10 +31,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@Component
@Slf4j
@ -86,8 +85,18 @@ public class LklAuditService {
@Autowired
TbPlussBankRegionLklMapper tbPlussBankRegionLklMapper;
@Autowired
TbPlussMerchantLklMapper tbPlussMerchantLklMapper;
@Autowired
TbPlussMerchantChannelFeeMapper tbPlussMerchantChannelFeeMapper;
public Map merchantAudit(TbPlussMerchantBaseInfo baseInfo, TbPlussMerchantChannelStatus channelStatus) {
@Autowired
TbPlussMerchantChannelStatusMapper tbPlussMerchantChannelStatusMapper;
@Autowired
TbPlussMerchantAuditRecordMapper tbPlussMerchantAuditRecordMapper;
public void merchantAudit(TbPlussMerchantBaseInfo baseInfo, TbPlussMerchantChannelStatus channelStatus) {
JSONObject object1 = new JSONObject();
JSONObject object2 = new JSONObject();
@ -334,7 +343,166 @@ public class LklAuditService {
.body(object1.toString()).execute().body();
System.out.println("返回结果:" + result);
Map arry = (Map) JSONArray.parse(result);
return arry;
if (String.valueOf(arry.get("status")).equals("WAIT_AUDI")) {
log.info("进件成功,等待三方审核");
TbPlussMerchantLkl plussMerchantLklEntity=new TbPlussMerchantLkl();
plussMerchantLklEntity.setMerchantid(baseInfo.getMerchantcode());
plussMerchantLklEntity.setMerchantlkl(String.valueOf(arry.get("merchantNo")));
plussMerchantLklEntity.setType("0");
tbPlussMerchantLklMapper.insert(plussMerchantLklEntity);
TbPlussMerchantChannelFee channelFee=tbPlussMerchantChannelFeeMapper.selectByChannelAndMerchantCode(5,baseInfo.getMerchantcode());
if(ObjectUtil.isEmpty(channelFee)){
channelFee=new TbPlussMerchantChannelFee();
channelFee.setChannel("5");
channelFee.setMerchantCode(baseInfo.getMerchantcode());
JSONObject object = new JSONObject();
object.put("D0", array);
object.put("D1", array);
channelFee.setFeeStr(new JSONObject(object).toJSONString());
channelFee.setCreateTime(new Date());
tbPlussMerchantChannelFeeMapper.insert(channelFee);
}else {
JSONObject object = new JSONObject();
object.put("D0", array);
object.put("D1", array);
channelFee.setFeeStr(new JSONObject(object).toJSONString());
channelFee.setCreateTime(new Date());
tbPlussMerchantChannelFeeMapper.updateByPrimaryKey(channelFee);
}
channelStatus.setChannel(5);
channelStatus.setUpdatetime(new Date());
channelStatus.setMerchantcode(baseInfo.getMerchantcode());
channelStatus.setStatus("1");
channelStatus.setThirdstatus("-100");
channelStatus.setCallbackstatus("0");
channelStatus.setRemark("拉卡拉审核中");
channelStatus.setMerchantid(String.valueOf(arry.get("merchantNo")));
if(ObjectUtil.isEmpty(channelStatus.getId())){
channelStatus.setCreatetime(new Date());
tbPlussMerchantChannelStatusMapper.insert(channelStatus);
}else {
channelStatus.setUpdatetime(new Date());
tbPlussMerchantChannelStatusMapper.updateByPrimaryKey(channelStatus);
}
TbPlussMerchantAuditRecord merchantAuditRecord = new TbPlussMerchantAuditRecord();
merchantAuditRecord.setStatus("1");
merchantAuditRecord.setMerchantcode(baseInfo.getMerchantcode());
merchantAuditRecord.setChannel(5);
merchantAuditRecord.setThirdstatus("-100");
merchantAuditRecord.setMerchantid(String.valueOf(arry.get("merchantNo")));
merchantAuditRecord.setCreatetime(new Date());
tbPlussMerchantAuditRecordMapper.insert(merchantAuditRecord);
}else {
JSONObject object = JSONObject.parseObject(result);
log.error("进件失败{}", object.getString("message"));
channelStatus.setChannel(5);
channelStatus.setUpdatetime(new Date());
channelStatus.setMerchantcode(baseInfo.getMerchantcode());
channelStatus.setStatus("1");
channelStatus.setThirdstatus("-100");
channelStatus.setCallbackstatus("0");
channelStatus.setRemark(object.getString("message"));
channelStatus.setMerchantid(object.getString("customerNo"));
if(ObjectUtil.isEmpty(channelStatus.getId())){
channelStatus.setCreatetime(new Date());
tbPlussMerchantChannelStatusMapper.insert(channelStatus);
}else {
channelStatus.setUpdatetime(new Date());
tbPlussMerchantChannelStatusMapper.updateByPrimaryKey(channelStatus);
}
TbPlussMerchantAuditRecord merchantAuditRecord = new TbPlussMerchantAuditRecord();
merchantAuditRecord.setStatus("1");
merchantAuditRecord.setMerchantcode(baseInfo.getMerchantcode());
merchantAuditRecord.setChannel(5);
merchantAuditRecord.setThirdstatus("-100");
merchantAuditRecord.setMerchantid(String.valueOf(arry.get("merchantNo")));
merchantAuditRecord.setCreatetime(new Date());
tbPlussMerchantAuditRecordMapper.insert(merchantAuditRecord);
MsgException.throwException(object.getString("message"));
}
}
public void merchantAudit(TbPlussMerchantBaseInfo merchantBaseInfo,TbPlussBankCard bankCard, TbPlussIdCard accountIdCard) {
MsgException.checkNull(merchantBaseInfo, "商户进件信息不存在");
TbPlussMerchantChannelStatus mcs=tbPlussMerchantChannelStatusMapper.selectByChannelAndmerchantCodeAndStatus("5",merchantBaseInfo.getMerchantcode());
MsgException.checkNull(mcs, "对应的商户信息不存在");
JSONObject object = new JSONObject();
object.put("accountKind", bankCard.getAccounttype().equals("01") ? "58" : "57");
object.put("accountNo", bankCard.getBankcardno()); //结算人银行卡号
object.put("accountName", bankCard.getBankholder()); //结算人账户名称
Set<ConcurrentMap<String, String>> attchmentsVoSet = new HashSet<>();
ConcurrentMap<String, String> frontLegalPersonMap = new ConcurrentHashMap<>();
frontLegalPersonMap.put("imgPath", laKaLaFileUpload(accountIdCard.getImgpositive(), "ID_CARD_FRONT"));
frontLegalPersonMap.put("imgType", "ID_CARD_FRONT");
attchmentsVoSet.add(frontLegalPersonMap);
ConcurrentMap<String, String> reverseLegalPersonMap = new ConcurrentHashMap<>();
reverseLegalPersonMap.put("imgPath", laKaLaFileUpload(accountIdCard.getImgnegative(), "ID_CARD_BEHIND"));
reverseLegalPersonMap.put("imgType", "ID_CARD_BEHIND");
attchmentsVoSet.add(reverseLegalPersonMap);
object.put("attachments", attchmentsVoSet);
TbPlussBankBranchLkl lakalaBranchInfo = tbPlussBankBranchLklMapper.selectByBankNo(bankCard.getContactline());
MsgException.checkNull(lakalaBranchInfo, "结算卡对应的分行支行信息不存在");
object.put("bankNo", lakalaBranchInfo.getBranchBankNo()); //结算账户开户 通过银行列表查询接口获取 对应 branchBankNo字段
object.put("bankName", lakalaBranchInfo.getBranchBankName()); //结算账户开户名称 通过银行列表查询接口获取 对应 branchBankName字段
object.put("clearingBankNo", lakalaBranchInfo.getClearNo()); //结算账户清算 通过银行列表查询接口获取 对应 clearNo字段
object.put("customerNo", Integer.valueOf(mcs.getMerchantid()));
Map map = getModifyToken("19191703856", "klb1qaz");
String result = "";
try {
log.info("修改信息:{}", object);
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(object.toString()).execute().body();
System.out.println("返回结果:" + result);
Map arry = (Map) JSONArray.parse(result);
if (arry.containsKey("message") && "SUCCESS".equals(String.valueOf(arry.get("message")))) {
// 保存商户进件修改记录
TbPlussMerchantAuditRecord merchantAuditRecord = new TbPlussMerchantAuditRecord();
merchantAuditRecord.setStatus("1");
merchantAuditRecord.setMerchantcode(merchantBaseInfo.getMerchantcode());
merchantAuditRecord.setChannel(5);
merchantAuditRecord.setThirdstatus("-100");
merchantAuditRecord.setMerchantid(String.valueOf(arry.get("merchantNo")));
merchantAuditRecord.setCreatetime(new Date());
tbPlussMerchantAuditRecordMapper.insert(merchantAuditRecord);
// 修改商户状态
mcs.setStatus("6");
mcs.setApplicationid(String.valueOf(arry.get("reviewRelatedId")));
tbPlussMerchantChannelStatusMapper.updateByPrimaryKey(mcs);
} else {
MsgException.throwException("修改进件信息失败");
}
} catch (Exception e) {
e.printStackTrace();
}
}
public String birthdayDate(String date) {
@ -345,6 +513,26 @@ public class LklAuditService {
}
public static Map getModifyToken(String userName, String password) {
RestTemplate client = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
// 表单提交
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.set("Authorization", "Basic " + getBase64());
// 封装参数
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
params.add("grant_type", "password");
params.add("username", userName);
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";
ResponseEntity<String> response = client.exchange(url, HttpMethod.POST, requestEntity, String.class);
Map map = (Map) JSONArray.parse(response.getBody());
return map;
}
public static Map getToken() {
RestTemplate client = new RestTemplate();
HttpHeaders headers = new HttpHeaders();

View File

@ -100,12 +100,7 @@ public class MerchantService {
ysAuditServiceV3.merchantAuditV3(userId,false, Integer.valueOf(channelId));
break;
case "5":
Map map= lklAuditService.merchantAudit(baseInfo,channelStatus);
if (ObjectUtil.isNotEmpty(map)&&String.valueOf(map.get("status")).equals("WAIT_AUDI")) {
}
lklAuditService.merchantAudit(baseInfo,channelStatus);
break;
case "6":
ysAuditServiceV3.merchantAuditV3(userId,false, Integer.valueOf(channelId));
@ -195,18 +190,18 @@ public class MerchantService {
}
if (size == 1) {
//一个通道
updateChannel(merchantCodes.get(0).getChannel(), merchantCodes.get(0).getMerchantid(), bankCard,idCard,userInfo);
updateChannel(merchantCodes.get(0).getChannel(), merchantCodes.get(0).getMerchantid(), baseInfo,bankCard,idCard,userInfo);
}
if (size == 2) {
//两个通道
updateChannel(merchantCodes.get(0).getChannel(), merchantCodes.get(0).getMerchantid(), bankCard,idCard,userInfo);
updateChannel(merchantCodes.get(1).getChannel(), merchantCodes.get(1).getMerchantid(), bankCard,idCard,userInfo);
updateChannel(merchantCodes.get(0).getChannel(), merchantCodes.get(0).getMerchantid(),baseInfo, bankCard,idCard,userInfo);
updateChannel(merchantCodes.get(1).getChannel(), merchantCodes.get(1).getMerchantid(),baseInfo, bankCard,idCard,userInfo);
}
}
}
}
}
public void updateChannel(Integer channel,String MerchantId, TbPlussBankCard bankCard,
public void updateChannel(Integer channel,String MerchantId,TbPlussMerchantBaseInfo baseInfo, TbPlussBankCard bankCard,
TbPlussIdCard idCard, TbPlussUserInfo userInfo){
switch (channel) {
case 1:
@ -217,6 +212,7 @@ public class MerchantService {
ysAuditServiceV3.updateMerchantIdCard(MerchantId, idCard, channel, userInfo);
break;
case 5:
lklAuditService.merchantAudit(baseInfo,bankCard,idCard);
break;
default:
break;