添加pos 机退款接口

This commit is contained in:
韩鹏辉 2023-06-14 16:06:34 +08:00
parent 8e4133d57e
commit c1f8056629
10 changed files with 307 additions and 58 deletions

View File

@ -0,0 +1,9 @@
package cn.pluss.platform.mapper;
import cn.pluss.platform.entity.MerchantChannelFee;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MerchantChannelFeeMapper extends BaseMapper<MerchantChannelFee> {
}

View File

@ -0,0 +1,37 @@
package cn.pluss.platform.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@TableName("tb_pluss_merchant_channel_fee")
public class MerchantChannelFee implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("merchant_code")
private String merchantCode;
@TableField("channel")
private Integer channel;
@TableField("fee_str")
private String feeStr;
@TableField("create_time")
private Date createTime;
@TableField("update_time")
private Date updateTime;
}

View File

@ -27,8 +27,8 @@ public class LaKaLaController {
laKalaInterface.ff();
}
@PostMapping("/tuoke")
public void jjklss(){
laKalaInterface.createTuoKeInfo("244");
public void jjklss(@RequestParam("userId") String userId){
laKalaInterface.merchAuditFee(userId);
}
@ -42,4 +42,6 @@ public class LaKaLaController {
public String querySubMerInfo(String orgCode,String merInnerNo,String merCupNo){
return lklPayService.querySubMerInfo(orgCode, merInnerNo,merCupNo);
}
}

View File

@ -1,45 +0,0 @@
package cn.pluss.platform.klk.service;
import cn.pluss.platform.klk.LakalaConfig;
import cn.pluss.platform.klk.entity.ReqKlkEntity;
import cn.pluss.platform.util.RSAUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import static org.springframework.http.MediaType.APPLICATION_JSON;
/**
* @author lyf
*/
@Slf4j
@Service("KlkService")
public class KlkService {
@Autowired
private LakalaConfig lakalaConfig;
public void reqKlk()throws Exception{
String data = "req_data\": {\n" +
" \"member_id\": \"AAA200154561278\",\n" +
" \"mer_order_id\": \"202112030923011\"\n" +
" }\n";
String key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDvDBZyHUDndAGxrIcsCV2njhNO3vCEZotTaWYSYwtDvkcAb1EjsBFabXZaKigpqFXk5XXNI3NIHP9M8XKzIgGvc65NpLAfRjVql8JiTvLyYd1gIUcOXMInabu+oX7dQSI1mS8XzqaoVRhDZQWhXcJW9bxMulgnzvk0Ggw07AjGF7si+hP/Va8SJmN7EJwfQq6TpSxR+WdIHpbWdhZ+NHwitnQwAJTLBFvfk28INM39G7XOsXdVLfsooFdglVTOHpNuRiQAj9gShCCNrpGsNQxDiJIxE43qRsNsRwigyo6DPJk/klgDJa417E2wgP8VrwiXparO4FMzOGK15quuoD7DAgMBAAECggEBANhmWOt1EAx3OBFf3f4/fEjylQgRSiqRqg8Ymw6KGuh4mE4Md6eW/B6geUOmZjVP7nIIR1wte28M0REWgn8nid8LGf+v1sB5DmIwgAf+8G/7qCwd8/VMg3aqgQtRp0ckb5OV2Mv0h2pbnltkWHR8LDIMwymyh5uCApbn/aTrCAZKNXcPOyAn9tM8Bu3FHk3Pf24Er3SN+bnGxgpzDrFjsDSHjDFT9UMIc2WdA3tuMv9X3DDn0bRCsHnsIw3WrwY6HQ8mumdbURk+2Ey3eRFfMYxyS96kOgBC2hqZOlDwVPAKTPtS4hoq+cQ0sRaJQ4T0UALJrBVHa+EESgRaTvrXqAECgYEA+WKmy9hcvp6IWZlk9Q1JZ+dgIVxrO65zylK2FnD1/vcTx2JMn73WKtQb6vdvTuk+Ruv9hY9PEsf7S8gHSTTmzHOUgo5x0F8yCxXFnfji2juoUnDdpkjtQK5KySDcpQb5kcCJWEVi9v+zObM0Zr1Nu5/NreE8EqUl3+7MtHOu1TMCgYEA9WM9P6m4frHPW7h4gs/GISA9LuOdtjLvAtgCK4cW2mhtGNAMttD8zOBQrRuafcbFAyU9de6nhGwetOhkW9YSV+xRNa7HWTeIRgXJuJBrluq5e1QGTIwZU/GujpNaR4Qiu0B8TodM/FME7htsyxjmCwEfT6SDYlkeMzTbMa9Q0DECgYBqsR/2+dvD2YMwAgZFKKgNAdoIq8dcwyfamUQ5mZ5EtGQL2yw48zibHh/LiIxgUD1Kjk/qQgNsX45NP4iOc0mCkrgomtRqdy+rumbPTNmQ0BEVJCBPscd+8pIgNiTvnWpMRvj7gMP0NDTzLI3wnnCRIq8WAtR2jZ0Ejt+ZHBziLQKBgQDibEe/zqNmhDuJrpXEXmO7fTv3YB/OVwEj5p1Z/LSho2nHU3Hn3r7lbLYEhUvwctCnLl2fzC7Wic1rsGOqOcWDS5NDrZpUQGGF+yE/JEOiZcPwgH+vcjaMtp0TAfRzuQEzNzV8YGwxB4mtC7E/ViIuVULHAk4ZGZI8PbFkDxjKgQKBgG8jEuLTI1tsP3kyaF3jAylnw7SkBc4gfe9knsYlw44YlrDSKr8AOp/zSgwvMYvqT+fygaJ3yf9uIBdrIilqCHKXccZ9uA/bT5JfIi6jbg3EoE9YhB0+1aGAS1O2dBvUiD8tJ+BjAT4OB0UDpmM6QsFLQgFyXgvDnzr/o+hQJelW";
ReqKlkEntity reqKlkEntity = ReqKlkEntity.get(data);
System.out.println("signFormat++++++++++++++"+reqKlkEntity.getSign());
String sign = RSAUtils.signSHA256(key, reqKlkEntity.getSign());
System.out.println("sign++++++++++++++++++"+sign);
//设置Authorization
HttpHeaders headers = new HttpHeaders();
headers.setContentType(APPLICATION_JSON);
headers.set("Authorization", "LKLAPI-SHA256withRSA");
String finalSign = "Content-Type: application/json"+"\n"+"Authorization:LKLAPI-SHA256withRSA"+" "+"appid="+reqKlkEntity.getAppid()+","+"serial_no="+reqKlkEntity.getSerialNo()+","+
reqKlkEntity.getTimestamp()+","+"nonce_str="+reqKlkEntity.getNonceStr()+","+
"signature="+sign;
System.out.println(finalSign);
}
// public String signEncrypt(String sign){
// SM4Util
// }
}

View File

@ -268,7 +268,7 @@ public class LkLPayServiceImpl implements PayService {
queryWrapper.eq("user_no", LaKalaInterfaceImpl.userNo);
MerchantBackLkl merchantBackLkl = merchantBackLklMapper.selectOne(queryWrapper);
MsgException.checkNull(merchantBackLkl, "进件信息不存在");
MsgException.checkNull(merchantBackLkl, "商户信息不存在");
@ -336,7 +336,7 @@ public class LkLPayServiceImpl implements PayService {
queryWrapper.eq("user_no", LaKalaInterfaceImpl.userNo);
MerchantBackLkl merchantBackLkl = merchantBackLklMapper.selectOne(queryWrapper);
MsgException.checkNull(merchantBackLkl, "进件信息不存在");
MsgException.checkNull(merchantBackLkl, "商户信息不存在");
String req_time = DateUtils.getSdfTimes();
Long order_amt = changeY2F(order.getConsumeFee());

View File

@ -0,0 +1,7 @@
package cn.pluss.platform.klk.service;
import cn.pluss.platform.entity.MerchantChannelFee;
import com.baomidou.mybatisplus.extension.service.IService;
public interface MerchantChannelFeeService extends IService<MerchantChannelFee> {
}

View File

@ -14,6 +14,7 @@ import cn.pluss.platform.klk.service.*;
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.mcc.MccReflectService;
import cn.pluss.platform.merchant.AccountService;
@ -45,6 +46,8 @@ import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@Service
@Slf4j
@ -289,19 +292,23 @@ public class LaKalaInterfaceImpl {
object1.put("accountIdCard", accountV4.getIdcard().getCertNo()); //结算证件号码
JSONArray array=new JSONArray();
Set<FeesSetVo> feesSet = new HashSet<>();
FeesSetVo w = new FeesSetVo();
w.setFeeCode("WECHAT");
w.setFeeValue(0.38d);
array.add(w);
FeesSetVo a = new FeesSetVo();
a.setFeeCode("ALIPAY");
a.setFeeValue(0.38d);
array.add(a);
FeesSetVo u = new FeesSetVo();
u.setFeeCode("SCAN_PAY_SECOND");
u.setFeeValue(0.38d);
array.add(u);
feesSet.add(w);
feesSet.add(a);
feesSet.add(u);
@ -350,6 +357,19 @@ public class LaKalaInterfaceImpl {
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)){
merchantChannelFee.setChannel(5);
merchantChannelFee.setMerchantCode(merchantBaseInfo.getMerchantCode());
merchantChannelFee.setFeeStr(array.toJSONString());
merchantChannelFee.setCreateTime(new Date());
merchantChannelFeeMapper.insert(merchantChannelFee);
}
mcs.setChannel(5);
mcs.setUpdateTime(new Date());
@ -378,7 +398,8 @@ public class LaKalaInterfaceImpl {
System.out.println(">>>>>>>>>>>>>>>");
}else {
JSONObject object=JSONObject.parseObject(result);
MsgException.throwException(object.getString("message"));
}
}catch (Exception e){
e.printStackTrace();
@ -387,14 +408,182 @@ public class LaKalaInterfaceImpl {
}
}
/**
* 参数组装
* */
@Resource
YSAuditServiceV3 auditServiceV3;
/**
* 进件回调
* */
public void merchantAudit(String userId){
MerchantBaseInfo merchantBaseInfo = mbiService.getMerchantBaseInfoByUserId(userId);
MsgException.checkNull(merchantBaseInfo,"商户进件信息不存在");
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,"对应的商户信息不存在");
AccountDTO accountV4 = getAccountV4(userId, "D1"); //结算人
MsgException.checkNull(accountV4,"结算信息不存在");
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");
attchmentsVoSet.add(frontLegalPersonMap);
ConcurrentMap<String,String> reverseLegalPersonMap=new ConcurrentHashMap<>();
reverseLegalPersonMap.put("imgPath",laKaLaFileUpload(accountV4.getIdcard().getImgNegative()));
reverseLegalPersonMap.put("imgType","ID_CARD_BEHIND");
attchmentsVoSet.add(reverseLegalPersonMap);
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,"结算信息未提交");
QueryWrapper<BankCard> bankCardWrapper = new QueryWrapper<>();
bankCardWrapper.eq("id", accountServiceOne1.getBankCardId());
BankCard userBrakCard = bankCardService.getOne(bankCardWrapper);
QueryWrapper<TbPlussBankBranchLklEntity> lklEntityQueryWrapper = new QueryWrapper<>();
lklEntityQueryWrapper.eq("branch_bank_no", userBrakCard.getContactLine());
TbPlussBankBranchLklEntity lakalaBranchInfo = tbPlussBankBranchLklService.getOne(lklEntityQueryWrapper);
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()));
Map map = getModifyToken("19191703856","klb1qaz");
String result="";
try {
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")+"")){
// 保存商户进件修改记录
MerchantAuditRecord updateRecord = new MerchantAuditRecord();
updateRecord.setMerchantId(mcs.getMerchantId());
updateRecord.setApplicationId(arry.get("reviewRelatedId")+"");
updateRecord.setChannel(5);
updateRecord.setStatus("1");
updateRecord.setMerchantCode(merchantBaseInfo.getMerchantCode());
// 文档上没有返回状态码
merchAuditRecService.save(updateRecord);
// 修改商户状态
mcs.setStatus(MerchantChannelStatus.AUDIT_STATUS_DATA_EDIT);
mcs.setApplicationId(arry.get("reviewRelatedId")+"");
mcsService.updateById(mcs);
}else {
MsgException.throwException("修改进件信息失败");
}
}catch (Exception e){
e.printStackTrace();
}
}
@Autowired
@Lazy
MerchantChannelFeeMapper merchantChannelFeeMapper;
public void merchAuditFee(String userId){
MerchantBaseInfo merchantBaseInfo = mbiService.getMerchantBaseInfoByUserId(userId);
MsgException.checkNull(merchantBaseInfo,"商户进件信息不存在");
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<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"));
feeAarray.add(object);
}
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()));
Map map = getModifyToken("19191703856","klb1qaz");
String result="";
try {
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")+"")){
// 保存商户进件修改记录
MerchantAuditRecord updateRecord = new MerchantAuditRecord();
updateRecord.setMerchantId(mcs.getMerchantId());
updateRecord.setApplicationId(arry.get("reviewRelatedId")+"");
updateRecord.setChannel(5);
updateRecord.setStatus("1");
updateRecord.setMerchantCode(merchantBaseInfo.getMerchantCode());
// 文档上没有返回状态码
merchAuditRecService.save(updateRecord);
// 修改商户状态
mcs.setApplicationId(arry.get("reviewRelatedId")+"");
mcsService.updateById(mcs);
}else {
MsgException.throwException("修改进件信息失败");
}
}catch (Exception e){
e.printStackTrace();
}
}
/**
* 获取拓客accessToken
@ -421,6 +610,29 @@ public class LaKalaInterfaceImpl {
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;
}

View File

@ -0,0 +1,11 @@
package cn.pluss.platform.klk.service.impl;
import cn.pluss.platform.entity.MerchantChannelFee;
import cn.pluss.platform.klk.service.MerchantChannelFeeService;
import cn.pluss.platform.mapper.MerchantChannelFeeMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@Service("merchantChannelFeeService")
public class MerchantChannelFeeServiceImpl extends ServiceImpl<MerchantChannelFeeMapper, MerchantChannelFee> implements MerchantChannelFeeService {
}

View File

@ -15,6 +15,7 @@ import cn.pluss.platform.dto.BankInfoDTO;
import cn.pluss.platform.dto.CertificationDTO;
import cn.pluss.platform.entity.*;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.klk.service.impl.LaKalaInterfaceImpl;
import cn.pluss.platform.mapper.AccountMapper;
import cn.pluss.platform.mapper.BankCodeSxfMapper;
import cn.pluss.platform.mapper.RiskBlacklistMapper;
@ -128,6 +129,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Lazy
private SxfMerAuditHandler sxfMerAuditHandler;
@Autowired
@Lazy
private LaKalaInterfaceImpl laKalaInterface;
@Override
public void editSuccess(MerchantChannelStatus mcs, String accountType) {
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@ -1197,6 +1202,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
}
// 银盛
ysAuditServiceV2.editMerchantAudit(bankCardDTO.getUserId());
break;
case "5":
laKalaInterface.merchantAudit(bankCard.getUserId());
//等待修改接口
break;
default:
throw new MsgException("未知的进件通道");

View File

@ -96,6 +96,8 @@ public class LklMerAuditHandler{
@Autowired
private UserAppService uaService;
@Autowired
private MerchantChannelFeeMapper merchantChannelFeeMapper;
@ -216,6 +218,10 @@ public class LklMerAuditHandler{
merchantBackLkl.setCreateTime(new Date());
backLklMapper.insert(merchantBackLkl);
}
MerchantAuditRecord lastRecord = merchantAuditRecordService.getLastRecord(merchantChannelStatus.getMerchantCode());
if (lastRecord != null) {
lastRecord.setStatus(merchantChannelStatus.getStatus());