增加查询银行卡Bin接口,增加单独给商家创建店铺接口,申请分账业务接口
This commit is contained in:
parent
20726bf256
commit
d3e2596585
@ -246,6 +246,9 @@ public class ShopMchEntry implements Serializable {
|
||||
@ApiModelProperty(value = "是否签署电子合同:1-是;2-否;")
|
||||
private Integer has_ec_signed;
|
||||
|
||||
@ApiModelProperty(value = "是否进件成功:1-是;2-否;")
|
||||
private Integer has_apply_mer;
|
||||
|
||||
@ApiModelProperty(value = "是否申请分账业务:1-是;2-否;")
|
||||
private Integer has_apply_split;
|
||||
|
||||
|
||||
@ -316,7 +316,7 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
|
||||
}
|
||||
|
||||
// 更新商家的hasEsigned状态=1
|
||||
shopMchEntryService.updateMulStatus(esignContract.getMch_mobile(), "", 1, 0, 0, 0);
|
||||
shopMchEntryService.updateMulStatus(esignContract.getMch_mobile(), "", 1, 0, 0, 0, 0);
|
||||
|
||||
return new ResponseEntity<>(new JSONObject().put("code", 200).put("msg", "success").toString(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class LakalaController extends BaseControllerImpl {
|
||||
|
||||
@ApiOperation(value = "获取银行卡的 BIN 信息", notes = "获取银行卡的 BIN 信息")
|
||||
@RequestMapping(value = "/bankCardBin", method = RequestMethod.POST)
|
||||
public JSONObject bankCardBin(@RequestBody JSONObject paramsJSON) {
|
||||
public CommonResult bankCardBin(@RequestBody JSONObject paramsJSON) {
|
||||
return lakalaPayService.getBankCardBin(paramsJSON.getStr("bankCardNo"));
|
||||
}
|
||||
|
||||
|
||||
@ -180,7 +180,7 @@ public interface LakalaApiService {
|
||||
* @param bankCardNo
|
||||
* @return
|
||||
*/
|
||||
JSONObject getBankCardBin(String bankCardNo);
|
||||
CommonResult getBankCardBin(String bankCardNo);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -82,4 +82,14 @@ public interface LklLedgerReceiverService extends IBaseService<LklLedgerReceiver
|
||||
* @return
|
||||
*/
|
||||
List<LklLedgerReceiver> getByCondition(String LicenseNo, String ContactMobile);
|
||||
|
||||
/**
|
||||
* 根据条件查询记录数量
|
||||
*
|
||||
* @param LicenseNo
|
||||
* @param ContactMobile
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
Long countByCondition(String LicenseNo, String ContactMobile, Long platformId);
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ package com.suisung.mall.shop.lakala.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ijpay.core.kit.IpKit;
|
||||
@ -612,8 +613,12 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
JSONObject header = new JSONObject();
|
||||
header.put("Authorization", authorization);
|
||||
|
||||
log.debug("申请入网电子合同请求参数:{}", JsonUtil.toJSONString(reqBody));
|
||||
|
||||
String errMsg = "";
|
||||
ResponseEntity<JSONObject> response = RestTemplateHttpUtil.sendPostBodyBackEntity(reqUrl, header, reqBody, JSONObject.class);
|
||||
log.debug("申请入网电子合同响应参数:{}", JsonUtil.toJSONString(response));
|
||||
|
||||
if (ObjectUtil.isEmpty(response) || response.getStatusCode() != HttpStatus.OK) {
|
||||
errMsg = "申请入网电子合同失败,无响应数据!";
|
||||
shopMchEntryService.updateMerchEntryApprovalByMchId(shopMchEntry.getId(), "", CommonConstant.MCH_APPR_STA_LKL_NOPASS, errMsg);
|
||||
@ -628,7 +633,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
}
|
||||
|
||||
JSONObject respData = respBody.getJSONObject("resp_data");
|
||||
if (respBody.getJSONObject("resp_data") == null) {
|
||||
if (respData == null) {
|
||||
errMsg = "申请入网电子合同失败,返回数据有误";
|
||||
shopMchEntryService.updateMerchEntryApprovalByMchId(shopMchEntry.getId(), "", CommonConstant.MCH_APPR_STA_LKL_NOPASS, errMsg);
|
||||
return Pair.of(false, errMsg);
|
||||
@ -981,98 +986,42 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户分账业务开通申请
|
||||
* 申请商户分账业务开通
|
||||
* 流程:提交分账业务申请(同时申请分账接收方)-等待拉卡拉审核通过-绑定商户和接收方关系-等待拉卡拉审核通过-完成整个流程
|
||||
*
|
||||
* @param paramsJSON
|
||||
* @param paramsJSON {merCupNo 拉卡拉外部商户号}
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult applyLedgerMer(JSONObject paramsJSON) {
|
||||
Pair<Boolean, String> resultPair = innerApplyLedgerMer(paramsJSON.getStr("merCupNo"));
|
||||
// 检查参数
|
||||
if (ObjectUtil.isEmpty(paramsJSON) || StrUtil.isBlank(paramsJSON.getStr("merCupNo"))) {
|
||||
return CommonResult.failed("请填写商户号!");
|
||||
}
|
||||
|
||||
String merCupNo = paramsJSON.getStr("merCupNo");
|
||||
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo);
|
||||
if (shopMchEntry == null) {
|
||||
return CommonResult.failed("无法获取入驻记录");
|
||||
}
|
||||
|
||||
Long receiverCnt = lklLedgerReceiverService.countByCondition("", "", shopMchEntry.getDistributor_id());
|
||||
if (receiverCnt <= 0) {
|
||||
// 1:新增一个接收方记录,起码要一个平台方,代理商根据入驻信息新增
|
||||
Boolean success = lklLedgerReceiverService.innerApplyLedgerReceiver(merCupNo, shopMchEntry.getDistributor_id());
|
||||
if (!success) {
|
||||
return CommonResult.failed("申请分账接收方失败");
|
||||
}
|
||||
}
|
||||
|
||||
Pair<Boolean, String> resultPair = innerApplyLedgerMer(merCupNo);
|
||||
if (!resultPair.getFirst()) {
|
||||
return CommonResult.failed(resultPair.getSecond());
|
||||
}
|
||||
|
||||
return CommonResult.success();
|
||||
|
||||
// log.debug("商户分账业务开通申请1开始");
|
||||
//
|
||||
// // TODO 判断是否已经申请过?
|
||||
// // 1. 配置初始化
|
||||
// initLKLSDK();
|
||||
//
|
||||
// //2. 装配数据
|
||||
// V2MmsOpenApiLedgerApplyLedgerMerRequest req = new V2MmsOpenApiLedgerApplyLedgerMerRequest();
|
||||
// req.setVersion("2.0");
|
||||
// req.setOrderNo(StringUtils.genLklOrderNo(8));// 14位年月日时(24小时制)分秒+8位的随机数
|
||||
// req.setOrgCode(orgCode);
|
||||
// req.setMerInnerNo(paramsJSON.getStr("merInnerNo"));// 从进件申请返回的商户号
|
||||
// req.setMerCupNo(paramsJSON.getStr("merCupNo")); // 从进件申请返回的商户号
|
||||
// req.setContactMobile(paramsJSON.getStr("contactMobile")); // 商户入驻注册的手机号
|
||||
// // 分账比例为了考虑低价订单的运费占比高,分账比例暂时定70%分账给商户,30%分账给平台
|
||||
// // new BigDecimal(paramsJSON.getStr("splitLowestRatio"))
|
||||
// req.setSplitLowestRatio(new BigDecimal(splitLowestRatio));
|
||||
// String fileName = paramsJSON.getStr("splitEntrustFileName");
|
||||
// req.setSplitEntrustFileName(fileName);
|
||||
//
|
||||
// // 分账结算委托书文件上传到拉卡拉服务器
|
||||
// JSONObject fileUploadResp = uploadFile(req.getOrderNo(), "SPLIT_ENTRUST_FILE", StringUtils.getFileExt(fileName), UploadUtil.fileUrlToBase64(paramsJSON.getStr("splitEntrustFile")));
|
||||
// if (fileUploadResp == null || StrUtil.isBlank(fileUploadResp.getStr("attFileId"))) {
|
||||
// throw new ApiException(I18nUtil._("分账结算委托书上传失败!"));
|
||||
// }
|
||||
//
|
||||
// String splitEntrustFilePath = fileUploadResp.getStr("attFileId");
|
||||
// req.setSplitEntrustFilePath(splitEntrustFilePath); //比如:G1/M00/06/64/CrFdEmBQc-aAGc_XAAAiIbS3WIE960.pdf;
|
||||
//
|
||||
// // 正式上线的时候,调整 api 地址
|
||||
// String domain = projectDomain;
|
||||
// if (isProdProject()) {
|
||||
// domain += "/api";
|
||||
// }
|
||||
// // 给拉卡拉通知的回调地址
|
||||
// String retUrl = domain + "/mobile/shop/lakala/ledger/applyLedgerMerNotify";
|
||||
// req.setRetUrl(retUrl);
|
||||
//
|
||||
// paramsJSON.set("orderNo", req.getOrderNo());
|
||||
// paramsJSON.set("version", "2.0");
|
||||
// paramsJSON.set("ret_url", retUrl);
|
||||
// paramsJSON.set("org_code", orgCode);
|
||||
// paramsJSON.set("split_entrust_file_path", splitEntrustFilePath);
|
||||
//
|
||||
// String errMsg = "商户分账业务开通申请:";
|
||||
//
|
||||
// try {
|
||||
// //3. 发送请求
|
||||
// String responseStr = LKLSDK.httpPost(req);
|
||||
//
|
||||
// // 成功返回示例:{'retCode':'000000','retMsg':'申请已受理,请等待审核结果','respData':{'version':'1.0','orderNo':'KFPT20230223181025407788734','orgCode':'1','applyId':681201215598657536}}
|
||||
// JSONObject lakalaRespJSON = JSONUtil.parseObj(responseStr);
|
||||
// if (StrUtil.isBlank(responseStr) || lakalaRespJSON == null) {
|
||||
// return CommonResult.failed(I18nUtil._("申请开通分账失败!"));
|
||||
// }
|
||||
//
|
||||
// if (!lakalaRespJSON.getStr("retCode").equals(lklSuccessCode)) {
|
||||
// return CommonResult.failed(lakalaRespJSON.getStr("retMsg"));
|
||||
// }
|
||||
//
|
||||
// paramsJSON.set("apply_id", lakalaRespJSON.getByPath("respData.applyId"));
|
||||
// paramsJSON.set("remark", lakalaRespJSON.getStr("retMsg"));
|
||||
// paramsJSON.set("audit_status_text", paramsJSON.get("remark"));
|
||||
//
|
||||
// paramsJSON.set("mch_id", paramsJSON.get("mchId"));
|
||||
//
|
||||
// // 新增数据
|
||||
// // 将 JSON 对象的键名转换为下划线命名
|
||||
// LklLedgerMember lklLedgerMember = JSONUtil.toBean(StringUtils.convertCamelToSnake(paramsJSON.toString()), LklLedgerMember.class);
|
||||
// lklLedgerMemberService.saveOrUpdateByMerCupNo(lklLedgerMember);
|
||||
//
|
||||
// return CommonResult.success(null, "提交成功,待审核中!");
|
||||
// } catch (SDKException e) {
|
||||
// errMsg += e.getMessage();
|
||||
// log.error(errMsg);
|
||||
// shopMchEntryService.updateMerchEntryApprovalByMchId(paramsJSON.getLong("mchId"), paramsJSON.getStr("mchMobile"), CommonConstant.MCH_APPR_STA_NOPASS, errMsg);
|
||||
// throw new ApiException(I18nUtil._("商家申请开通分账出错!"), e);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1160,7 +1109,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
}
|
||||
|
||||
// 更新商家的hasApplySplit状态=1;
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 1, 0, 0);
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 1, 0, 0, 0);
|
||||
|
||||
respData.put("code", "SUCCESS");
|
||||
respData.put("message", "操作成功!");
|
||||
@ -1262,7 +1211,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
}
|
||||
|
||||
// 更新商家分账申请状态为已申请(hasApplySplit=1)
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 1, 0, 0);
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 1, 0, 0, 0);
|
||||
|
||||
log.debug("商户分账申请业务回调:处理成功,applyId={}", applyId);
|
||||
return JSONUtil.createObj().put("code", "SUCCESS").put("message", "操作成功!");
|
||||
@ -1275,8 +1224,152 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
* @param paramsJSON
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public CommonResult applyLedgerReceiver(JSONObject paramsJSON) {
|
||||
// 前置检查:避免重复创建
|
||||
LklLedgerReceiver existingReceiver = lklLedgerReceiverService.getByCondition(
|
||||
paramsJSON.getStr("licenseNo"),
|
||||
paramsJSON.getStr("contactMobile"),
|
||||
paramsJSON.getLong("platformId")
|
||||
);
|
||||
if (existingReceiver != null) {
|
||||
return CommonResult.success(existingReceiver, "该接收方已创建过!");
|
||||
}
|
||||
|
||||
// 1. 配置初始化
|
||||
initLKLSDK();
|
||||
|
||||
// 2. 装配数据
|
||||
V2MmsOpenApiLedgerApplyLedgerReceiverRequest req = new V2MmsOpenApiLedgerApplyLedgerReceiverRequest();
|
||||
String orderNo = StringUtils.genLklOrderNo(8); // 8位随机数
|
||||
String mchMobile = paramsJSON.getStr("contactMobile");
|
||||
|
||||
// 基础参数设置
|
||||
req.setOrderNo(orderNo);
|
||||
req.setOrgCode(orgCode);
|
||||
req.setVersion("2.0");
|
||||
req.setReceiverName(paramsJSON.getStr("receiverName"));
|
||||
req.setContactMobile(mchMobile);
|
||||
req.setLicenseNo(paramsJSON.getStr("licenseNo"));
|
||||
req.setLicenseName(paramsJSON.getStr("licenseName"));
|
||||
req.setLegalPersonName(paramsJSON.getStr("legalPersonName"));
|
||||
req.setLegalPersonCertificateType(paramsJSON.getStr("legalPersonCertificateType"));
|
||||
req.setLegalPersonCertificateNo(paramsJSON.getStr("legalPersonCertificateNo"));
|
||||
req.setAcctNo(paramsJSON.getStr("acctNo"));
|
||||
req.setAcctName(paramsJSON.getStr("acctName"));
|
||||
req.setAcctTypeCode(paramsJSON.getStr("acctTypeCode"));
|
||||
req.setAcctCertificateType(paramsJSON.getStr("acctCertificateType"));
|
||||
req.setAcctCertificateNo(paramsJSON.getStr("acctCertificateNo"));
|
||||
req.setAcctOpenBankCode(paramsJSON.getStr("acctOpenBankCode"));
|
||||
req.setAcctOpenBankName(paramsJSON.getStr("acctOpenBankName"));
|
||||
req.setAcctClearBankCode(paramsJSON.getStr("acctClearBankCode"));
|
||||
|
||||
// 附件处理(优化循环逻辑)
|
||||
JSONArray attachList = paramsJSON.getJSONArray("attachList");
|
||||
if (attachList != null && !attachList.isEmpty()) {
|
||||
List<V2MmsOpenApiLedgerApplyLedgerReceiverRequest.AttachInfo> processedAttachments = new ArrayList<>();
|
||||
|
||||
for (Object obj : attachList) {
|
||||
if (!(obj instanceof JSONObject)) continue;
|
||||
|
||||
JSONObject attachJSON = (JSONObject) obj;
|
||||
String fileName = attachJSON.getStr("attachName");
|
||||
String attachType = attachJSON.getStr("attachType");
|
||||
String fileUrl = attachJSON.getStr("attachStoreFile");
|
||||
|
||||
if (StrUtil.isBlank(fileName) || StrUtil.isBlank(attachType) || StrUtil.isBlank(fileUrl)) {
|
||||
log.warn("附件参数不完整,跳过: {}", attachJSON);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
String fileBase64 = UploadUtil.fileUrlToBase64(fileUrl);
|
||||
JSONObject uploadResponse = uploadFile(
|
||||
StringUtils.genLklOrderNo(8),
|
||||
attachType,
|
||||
StringUtils.getFileExt(fileName),
|
||||
fileBase64
|
||||
);
|
||||
|
||||
if (uploadResponse == null || StrUtil.isBlank(uploadResponse.getStr("attFileId"))) {
|
||||
log.error("附件上传失败: {} ({})", fileName, attachType);
|
||||
continue;
|
||||
}
|
||||
|
||||
V2MmsOpenApiLedgerApplyLedgerReceiverRequest.AttachInfo info =
|
||||
new V2MmsOpenApiLedgerApplyLedgerReceiverRequest.AttachInfo();
|
||||
info.setAttachName(fileName);
|
||||
info.setAttachType(attachType);
|
||||
info.setAttachStorePath(uploadResponse.getStr("attFileId"));
|
||||
processedAttachments.add(info);
|
||||
} catch (Exception e) {
|
||||
log.error("处理附件时出错: {} ({})", fileName, attachType, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!processedAttachments.isEmpty()) {
|
||||
req.setAttachList(processedAttachments);
|
||||
paramsJSON.set("attach_list", JSONUtil.toJsonStr(processedAttachments));
|
||||
}
|
||||
}
|
||||
|
||||
// 保存请求参数
|
||||
paramsJSON.set("orderNo", orderNo);
|
||||
paramsJSON.set("version", "2.0");
|
||||
paramsJSON.set("org_code", orgCode);
|
||||
|
||||
// 3. 发送请求并处理响应
|
||||
try {
|
||||
String responseStr = LKLSDK.httpPost(req);
|
||||
|
||||
if (StrUtil.isBlank(responseStr)) {
|
||||
return CommonResult.failed(I18nUtil._("创建分账接收方响应数据无效!"));
|
||||
}
|
||||
|
||||
JSONObject lakalaRespJSON = JSONUtil.parseObj(responseStr);
|
||||
if (lakalaRespJSON == null || !lklSuccessCode.equals(lakalaRespJSON.getStr("retCode"))) {
|
||||
String errorMsg = lakalaRespJSON != null
|
||||
? lakalaRespJSON.getStr("retMsg", "未知错误")
|
||||
: "响应解析失败";
|
||||
return CommonResult.failed(I18nUtil._(errorMsg));
|
||||
}
|
||||
|
||||
// 提取响应数据
|
||||
paramsJSON.set("receiver_no", lakalaRespJSON.getByPath("respData.receiverNo"));
|
||||
paramsJSON.set("org_id", lakalaRespJSON.getByPath("respData.orgId"));
|
||||
paramsJSON.set("org_name", lakalaRespJSON.getByPath("respData.orgName"));
|
||||
|
||||
// 转换并保存数据
|
||||
LklLedgerReceiver receiver = JSONUtil.toBean(
|
||||
StringUtils.convertCamelToSnake(paramsJSON.toString()),
|
||||
LklLedgerReceiver.class
|
||||
);
|
||||
|
||||
if (!lklLedgerReceiverService.saveOrUpdateByReceiverNo(receiver)) {
|
||||
log.error("接收方创建成功,但更新本地数据失败!");
|
||||
return CommonResult.failed(I18nUtil._("接收方创建成功,但更新本地数据失败!"));
|
||||
}
|
||||
|
||||
// 更新商户分账状态
|
||||
shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0, 0);
|
||||
return CommonResult.success(receiver, "创建接收方成功!");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("接收方创建失败:{}", e.getMessage(), e);
|
||||
throw new ApiException(I18nUtil._("创建接收方失败: {}" + e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分账接收方创建申请
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=380
|
||||
*
|
||||
* @param paramsJSON
|
||||
* @return
|
||||
*/
|
||||
// @Override
|
||||
public CommonResult applyLedgerReceiverTemp(JSONObject paramsJSON) {
|
||||
// 判断分账接收方记录是否存在,存在就不再新建了
|
||||
LklLedgerReceiver lklLedgerReceiverOld = lklLedgerReceiverService.getByCondition(paramsJSON.getStr("licenseNo"), paramsJSON.getStr("contactMobile"), paramsJSON.getLong("platformId"));
|
||||
if (lklLedgerReceiverOld != null) {
|
||||
@ -1313,6 +1406,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
req.setAcctOpenBankName(paramsJSON.getStr("acctOpenBankName"));
|
||||
req.setAcctClearBankCode(paramsJSON.getStr("acctClearBankCode"));
|
||||
|
||||
|
||||
if (paramsJSON.getJSONArray("attachList") != null && paramsJSON.getJSONArray("attachList").size() > 0) {
|
||||
List<V2MmsOpenApiLedgerApplyLedgerReceiverRequest.AttachInfo> attachList = new ArrayList<>();
|
||||
V2MmsOpenApiLedgerApplyLedgerReceiverRequest.AttachInfo attachInfo = new V2MmsOpenApiLedgerApplyLedgerReceiverRequest.AttachInfo();
|
||||
@ -1373,7 +1467,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
}
|
||||
|
||||
// 更新商户分账多个状态 has_apply_receiver=1
|
||||
shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0);
|
||||
shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0, 0);
|
||||
|
||||
return CommonResult.success(lklLedgerReceiver, "创建接收方成功!");
|
||||
} catch (Exception e) {
|
||||
@ -1716,48 +1810,77 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
}
|
||||
|
||||
// 6. 更新商家绑定状态
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 1);
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 1, 0);
|
||||
|
||||
log.debug("分账商家绑定接收方回调处理完成,merCupNo:{}", merCupNo);
|
||||
return JSONUtil.createObj().put("code", "SUCCESS").put("message", "操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行卡信息查询
|
||||
* 查询银行卡Bin信息
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=179
|
||||
*
|
||||
* @param bankCardNo 银行卡号
|
||||
* @return bankCode, bankName, clearingBankCode
|
||||
*/
|
||||
@Override
|
||||
public JSONObject getBankCardBin(String bankCardNo) {
|
||||
public CommonResult getBankCardBin(String bankCardNo) {
|
||||
// 参数校验
|
||||
if (StrUtil.isBlank(bankCardNo)) {
|
||||
return null;
|
||||
return CommonResult.failed("银行卡号不能为空");
|
||||
}
|
||||
|
||||
// 1. 配置初始化
|
||||
initLKLSDK();
|
||||
// 构建请求参数
|
||||
JSONObject reqData = new JSONObject()
|
||||
.put("version", "1.0")
|
||||
.put("orderNo", StringUtils.genLklOrderNo(8))
|
||||
.put("orgCode", orgCode)
|
||||
.put("cardNo", bankCardNo);
|
||||
|
||||
// //2. 装配数据
|
||||
// V2MmsOpenApiBankCardBinRequest req = new V2MmsOpenApiLedgerApplyLedgerReceiverRequest();
|
||||
//
|
||||
// JSONObject formData = new JSONObject();
|
||||
// formData.putByPath("reqData.version", "2.0");
|
||||
// formData.putByPath("reqData.orderNo", StringUtils.genLklOrderNo(8));
|
||||
// formData.putByPath("reqData.orgCode", orgCode);
|
||||
// formData.putByPath("reqData.cardNo", bankCardNo);
|
||||
//
|
||||
// String urlPath = "/api/v2/mms/openApi/cardBin";
|
||||
// ResponseEntity<JSONObject> response = RestTemplateHttpUtil.sendPostFormDataBackEntity(buildLklServiceUrl(urlPath), header, formData, JSONObject.class);
|
||||
// if (ObjectUtil.isEmpty(response) || response.getStatusCode() != HttpStatus.OK) {
|
||||
// return null;
|
||||
// }
|
||||
// JSONObject result = response.getBody();
|
||||
// if (result == null) {
|
||||
// return null;
|
||||
// }
|
||||
JSONObject reqBody = new JSONObject()
|
||||
.put("timestamp", DateTimeUtils.formatDateTime(LocalDateTime.now(), "yyyyMMddHHmmss"))
|
||||
.put("version", "1.0.0")
|
||||
.put("reqData", reqData);
|
||||
|
||||
return null;
|
||||
// 构建请求URL(优化逻辑)
|
||||
String reqUrl = serverUrl + "/api/v2/mms/openApi/cardBin";
|
||||
|
||||
// 生成授权信息
|
||||
String privateKey = LakalaUtil.getResourceFile(priKeyPath, false, true);
|
||||
String authorization = LakalaUtil.genAuthorization(privateKey, appId, serialNo, reqBody.toString());
|
||||
|
||||
// 设置请求头
|
||||
JSONObject header = new JSONObject().put("Authorization", authorization);
|
||||
|
||||
log.debug("查询银行卡Bin信息请求参数:{}", JsonUtil.toJSONString(reqBody));
|
||||
|
||||
// 发送请求并获取响应
|
||||
ResponseEntity<JSONObject> response = RestTemplateHttpUtil.sendPostBodyBackEntity(
|
||||
reqUrl, header, reqBody, JSONObject.class);
|
||||
|
||||
|
||||
// 响应校验(简化逻辑)
|
||||
if (ObjectUtil.isEmpty(response) || !HttpStatus.OK.equals(response.getStatusCode())) {
|
||||
return CommonResult.failed("查询银行卡Bin信息失败,无响应数据!");
|
||||
}
|
||||
|
||||
JSONObject respBody = response.getBody();
|
||||
log.debug("查询银行卡Bin信息响应参数:{}", respBody);
|
||||
if (respBody == null || !lklSuccessCode.equals(respBody.getStr("retCode"))) {
|
||||
String errorMsg = respBody != null && StrUtil.isNotBlank(respBody.getStr("retMsg"))
|
||||
? respBody.getStr("msg")
|
||||
: "返回状态有误";
|
||||
return CommonResult.failed("查询银行卡Bin信息失败," + errorMsg);
|
||||
}
|
||||
|
||||
|
||||
// 获取并返回结果数据
|
||||
JSONObject respData = respBody.getJSONObject("respData");
|
||||
if (respData == null) {
|
||||
return CommonResult.failed("查询银行卡Bin信息失败,返回数据有误");
|
||||
}
|
||||
|
||||
return CommonResult.success(respData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -210,6 +210,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
/**
|
||||
* 内部调用:申请一个或多个分账接收方(平台方和代理商)
|
||||
*
|
||||
* @param merCupNo 用于标记接收方绑定merCupNo商家
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
@ -218,7 +219,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
// 接收方至少有一个平台方
|
||||
JSONArray buildApplyLedgerReceiverReqParams = buildApplyLedgerReceiverReqParams(platformId);
|
||||
if (buildApplyLedgerReceiverReqParams == null || buildApplyLedgerReceiverReqParams.isEmpty()) {
|
||||
log.error("获取不到平台或代理商信息");
|
||||
log.error("先新增平台或代理商信息");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -237,7 +238,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
boolean success = successCnt > 0;
|
||||
if (success) {
|
||||
// 更新多个状态
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 1, 0);
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 1, 0, 0);
|
||||
}
|
||||
|
||||
return success;
|
||||
@ -311,4 +312,31 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询记录数量
|
||||
*
|
||||
* @param LicenseNo
|
||||
* @param ContactMobile
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long countByCondition(String LicenseNo, String ContactMobile, Long platformId) {
|
||||
QueryWrapper<LklLedgerReceiver> queryWrapper = new QueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(LicenseNo)) {
|
||||
queryWrapper.eq("license_no", LicenseNo);
|
||||
}
|
||||
if (StrUtil.isNotBlank(ContactMobile)) {
|
||||
queryWrapper.eq("contact_mobile", ContactMobile);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(platformId) && platformId > 0) {
|
||||
queryWrapper.eq("platform_id", platformId);
|
||||
}
|
||||
|
||||
queryWrapper.eq("status", CommonConstant.Enable);
|
||||
|
||||
return count(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,8 +510,9 @@ public class LklTkServiceImpl {
|
||||
}
|
||||
|
||||
JSONObject respBody = response.getBody();
|
||||
logger.debug("进件返回结果:{}", respBody);
|
||||
if (response.getStatusCode() != HttpStatus.OK && ObjectUtil.isNotEmpty(respBody)) {
|
||||
String errMsg = respBody.getStr("message") == null ? "返回状态有误" : respBody.getStr("message");
|
||||
String errMsg = respBody.getStr("message") == null ? "未知错误" : respBody.getStr("message");
|
||||
return Pair.of(false, "进件失败:" + errMsg);
|
||||
}
|
||||
|
||||
@ -544,6 +545,7 @@ public class LklTkServiceImpl {
|
||||
// 解密请求参数
|
||||
String requestBody = LakalaUtil.getBody(request);
|
||||
logger.debug("拉卡拉进件异步通知返回参数:{}", requestBody);
|
||||
|
||||
if (StrUtil.isBlank(requestBody)) {
|
||||
return new JSONObject().set("code", "400").set("message", "返回参数为空");
|
||||
}
|
||||
@ -562,39 +564,44 @@ public class LklTkServiceImpl {
|
||||
String notifyPubKey = LakalaUtil.getResourceFile(notifyPubKeyPath, false, false);
|
||||
String data = LakalaUtil.decryptNotifyData(notifyPubKey, srcData);
|
||||
if (StrUtil.isBlank(data)) {
|
||||
return new JSONObject().set("code", "400").set("message", "密文解密出错!");
|
||||
return new JSONObject().set("code", "400").set("message", "数据解密出错!");
|
||||
}
|
||||
|
||||
logger.debug("拉卡拉进件异步通知data解密成功,开始处理逻辑");
|
||||
|
||||
// 逻辑处理
|
||||
JSONObject dataJSON = JSONUtil.parseObj(data);
|
||||
if (dataJSON.isEmpty() || StrUtil.isBlank(dataJSON.getStr("externalCustomerNo")) || StrUtil.isBlank(dataJSON.getStr("status"))) {
|
||||
String auditStatus = dataJSON.getStr("status");
|
||||
String merCupNo = dataJSON.getStr("externalCustomerNo"); //拉卡拉外部商户号
|
||||
String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号
|
||||
String termNos = dataJSON.getStr("termNos"); //拉卡拉分配的业务终端号
|
||||
|
||||
// 合并参数校验,减少嵌套
|
||||
if (dataJSON.isEmpty() ||
|
||||
StrUtil.isBlank(auditStatus) ||
|
||||
StrUtil.isBlank(merCupNo) ||
|
||||
StrUtil.isBlank(merInnerNo)) {
|
||||
return new JSONObject().set("code", "500").set("message", "参数解析出错");
|
||||
}
|
||||
|
||||
String auditStatus = dataJSON.getStr("status");
|
||||
// 校验审核状态
|
||||
if (!"SUCCESS".equals(auditStatus) && !"REVIEW_PASS".equals(auditStatus)) {
|
||||
logger.debug("返回的审核状态:{}", auditStatus);
|
||||
return new JSONObject().set("code", "FAIL").set("message", "返回审核状态有误");
|
||||
}
|
||||
|
||||
// RMK 拉卡拉进价提交成功,边处理周边的数据,边等待审核异步通知
|
||||
|
||||
// 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据
|
||||
String merCupNo = dataJSON.getStr("externalCustomerNo"); //拉卡拉外部商户号
|
||||
String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号
|
||||
String termNos = dataJSON.getStr("termNos"); //拉卡拉分配的业务终端号
|
||||
if (StrUtil.isBlank(merInnerNo) || StrUtil.isBlank(merCupNo)) {
|
||||
return new JSONObject().set("code", "500").set("message", "返回数据有误");
|
||||
}
|
||||
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo);
|
||||
if (ObjectUtil.isEmpty(shopMchEntry)) {
|
||||
logger.error("拉卡拉进件异步通知:返回的内部商户号:{} 入驻信息不存在!", merInnerNo);
|
||||
return new JSONObject().put("code", "500").put("message", "内部商户号:" + merInnerNo + " 入驻信息不存在");
|
||||
logger.error("拉卡拉进件异步通知:{}内部商户号入驻信息不存在!", merInnerNo);
|
||||
return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在");
|
||||
}
|
||||
|
||||
Boolean success = shopMchEntryService.updateMerchEntryLklAuditStatusByLklMerCupNo(merInnerNo, merCupNo, termNos, CommonConstant.Enable, null, data);
|
||||
Boolean success = shopMchEntryService.updateMerchEntryLklAuditStatusByLklMerCupNo(
|
||||
merInnerNo, merCupNo, termNos, CommonConstant.Enable, null, data);
|
||||
|
||||
if (!success) {
|
||||
return new JSONObject().set("code", "500").set("message", "更新商户号失败");
|
||||
// throw new ApiException("更新商户号失败");
|
||||
@ -618,23 +625,26 @@ public class LklTkServiceImpl {
|
||||
if (success && StrUtil.isNotBlank(shopMchEntry.getContract_download_url())) {
|
||||
|
||||
// TODO 新建一个正式的已审核通过的店铺, 新建之前判断是否已经新建过了?
|
||||
// 新建一个正式的已审核通过的店铺
|
||||
// ShopMchEntry shopEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo);
|
||||
// if (shopEntry != null && !CommonConstant.Enable.equals(shopEntry.getStore_status())) {
|
||||
// String mchMobile = shopEntry.getLogin_mobile();
|
||||
// Pair<Integer, String> retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile);
|
||||
// if (retPair.getFirst() > 0) {
|
||||
// // 2025-05-17暂停e签宝电子合同生成流程
|
||||
// // 更改合同记录表的店铺id
|
||||
// // esignContractService.updateContractStoreId(mchMobile, retPair.getFirst());
|
||||
// // 填充合同模版表的店铺Id
|
||||
// // esignContractFillingFileService.updateContractFillingStoreId(mchMobile, retPair.getFirst());
|
||||
// // 店铺创建状态已完成
|
||||
// shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable);
|
||||
// } else {
|
||||
// throw new ApiException("商家进件:初始化店铺失败!");
|
||||
// }
|
||||
// }
|
||||
// 新建一个正式的已审核通过的店铺,不要抛异常,使用补偿机制,可以独立初始化店铺
|
||||
ShopMchEntry shopEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo);
|
||||
if (shopEntry != null && !CommonConstant.Enable.equals(shopEntry.getStore_status())) {
|
||||
String mchMobile = shopEntry.getLogin_mobile();
|
||||
Pair<Integer, String> retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile);
|
||||
|
||||
if (retPair.getFirst() > 0) {
|
||||
// 2025-05-17暂停e签宝电子合同生成流程
|
||||
// 更改合同记录表的店铺id
|
||||
// esignContractService.updateContractStoreId(mchMobile, retPair.getFirst());
|
||||
// 填充合同模版表的店铺Id
|
||||
// esignContractFillingFileService.updateContractFillingStoreId(mchMobile, retPair.getFirst());
|
||||
// 店铺创建状态已完成
|
||||
shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable);
|
||||
logger.info("商家进件:初始化店铺成功!");
|
||||
} else {
|
||||
logger.error("商家进件:初始化店铺失败!");
|
||||
// throw new ApiException("商家进件:初始化店铺失败!");
|
||||
}
|
||||
}
|
||||
|
||||
// 1、(电子合同)给商家申请分账功能使用;务必检查是否申请过?申请过忽略
|
||||
// 下一步等待拉卡拉审核通过,再绑定接收方和商家的关系
|
||||
@ -643,6 +653,7 @@ public class LklTkServiceImpl {
|
||||
// 2:新增一个接收方记录,起码要一个平台方,代理商根据入驻信息新增
|
||||
Boolean genSuccess = lklLedgerReceiverService.innerApplyLedgerReceiver(merCupNo, shopMchEntry.getDistributor_id());
|
||||
|
||||
// 统一处理分账申请结果
|
||||
if (retPair.getFirst() && genSuccess) {
|
||||
return new JSONObject().put("code", "200").put("message", "处理成功");
|
||||
}
|
||||
|
||||
@ -213,8 +213,9 @@ public interface ShopMchEntryService {
|
||||
* @param hasApplySplit
|
||||
* @param hasApplyReceiver
|
||||
* @param hasBindReceiver
|
||||
* @param hasApplyMer
|
||||
* @return
|
||||
*/
|
||||
Boolean updateMulStatus(String mchMobile, String merCupNo, Integer hasEcSigned, Integer hasApplySplit, Integer hasApplyReceiver, Integer hasBindReceiver);
|
||||
Boolean updateMulStatus(String mchMobile, String merCupNo, Integer hasEcSigned, Integer hasApplySplit, Integer hasApplyReceiver, Integer hasBindReceiver, Integer hasApplyMer);
|
||||
|
||||
}
|
||||
@ -847,6 +847,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("lkl_mer_inner_no", lklInnerMerNo);
|
||||
|
||||
updateWrapper.set("has_apply_mer", CommonConstant.Enable); // 是否进件成功:1-是;2-否;
|
||||
if (StrUtil.isNotBlank(lklMerCupNo)) {
|
||||
updateWrapper.set("lkl_mer_cup_no", lklMerCupNo);
|
||||
}
|
||||
@ -974,11 +975,12 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
* @param hasApplySplit
|
||||
* @param hasApplyReceiver
|
||||
* @param hasBindReceiver
|
||||
* @param hasApplyMer
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateMulStatus(String mchMobile, String merCupNo, Integer hasEcSigned,
|
||||
Integer hasApplySplit, Integer hasApplyReceiver, Integer hasBindReceiver) {
|
||||
Integer hasApplySplit, Integer hasApplyReceiver, Integer hasBindReceiver, Integer hasApplyMer) {
|
||||
// 参数校验
|
||||
if (StrUtil.isAllBlank(merCupNo, mchMobile)) {
|
||||
log.error("缺少merCupNo或mchMobile参数");
|
||||
@ -1000,6 +1002,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
fieldMap.put("has_apply_split", hasApplySplit);
|
||||
fieldMap.put("has_apply_receiver", hasApplyReceiver);
|
||||
fieldMap.put("has_bind_receiver", hasBindReceiver);
|
||||
fieldMap.put("has_apply_mer", hasApplyMer);
|
||||
|
||||
// 过滤有效字段并设置
|
||||
fieldMap.entrySet().stream()
|
||||
|
||||
@ -2998,14 +2998,14 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
public Pair<Integer, String> merchEntryInfo2StoreInfo(String mchMobile) {
|
||||
if (StrUtil.isBlank(mchMobile)) {
|
||||
logger.error("生成店铺:商家手机号不能为空");
|
||||
return Pair.of(0, "商家手机号不能为空");
|
||||
return Pair.of(0, "商家手机不能为空");
|
||||
}
|
||||
|
||||
// 从绑定关系中,获取商家注册账号信息
|
||||
Integer userId = accountService.getUserBindConnectUserIdByCondition(mchMobile, BindCode.MOBILE, CommonConstant.USER_TYPE_MCH);
|
||||
if (userId == null) {
|
||||
logger.error("生成店铺:绑定关系中获取不到该手机{}商家的账号", mchMobile);
|
||||
return Pair.of(0, "商家账号异常!");
|
||||
return Pair.of(0, "该商家手机未注册账号!");
|
||||
}
|
||||
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByCondition(mchMobile, "");
|
||||
@ -3019,6 +3019,17 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
return Pair.of(0, "店铺名称已存在");
|
||||
}
|
||||
|
||||
// 校验店铺状态,
|
||||
if (CommonConstant.Enable.equals(shopMchEntry.getStore_status())) {
|
||||
return Pair.of(0, "操作失败,检查店铺是否已创建完成?");
|
||||
}
|
||||
|
||||
if (!CommonConstant.Enable.equals(shopMchEntry.getStore_status())
|
||||
&& !CommonConstant.Enable.equals(shopMchEntry.getHas_ec_signed())
|
||||
&& !CommonConstant.Enable.equals(shopMchEntry.getHas_apply_mer())) {
|
||||
return Pair.of(0, "前置条件为满足,请检查电子合同或申请进件状态");
|
||||
}
|
||||
|
||||
try {
|
||||
// 新增 shop_store_base,shop_store_info,shop_store_company, shop_store_employee 待补充
|
||||
|
||||
@ -3060,7 +3071,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
shopStoreBase.setStore_end_time(System.currentTimeMillis() + 1000L * 60 * 60 * 24 * 365 * 5); // 5年
|
||||
if (!save(shopStoreBase)) {
|
||||
logger.error("生成店铺:新增店铺基本信息失败");
|
||||
throw new ApiException(I18nUtil._("新增店铺失败"));
|
||||
throw new ApiException(I18nUtil._("新增店铺基础信息失败"));
|
||||
}
|
||||
|
||||
// 保存后店铺Id
|
||||
@ -3099,7 +3110,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
shopStoreInfo.setStore_state_id(StateCode.STORE_STATE_YES);
|
||||
if (!shopStoreInfoService.save(shopStoreInfo)) {
|
||||
logger.error("生成店铺:新增店铺info失败");
|
||||
throw new ApiException(I18nUtil._("新增店铺失败"));
|
||||
throw new ApiException(I18nUtil._("新增店铺信息失败"));
|
||||
}
|
||||
|
||||
// 初始化默认公司信息,避免商家编辑不了,申请入驻即使是个人类型的,也需要保存相关应有信息,公司信息不能空着
|
||||
@ -3178,8 +3189,8 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
|
||||
return Pair.of(storeId, "新增成功");
|
||||
} catch (Exception e) {
|
||||
logger.error("生成店铺失败", e);
|
||||
return Pair.of(0, I18nUtil._("新增店铺失败"));
|
||||
logger.error("店铺生成失败", e);
|
||||
return Pair.of(0, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user