分账比例 默认配置化
This commit is contained in:
parent
3f35de9507
commit
2feebfafd4
@ -38,6 +38,7 @@ public class LklLedgerEc implements Serializable {
|
||||
private String resp_notify_body;
|
||||
private String ec_no;
|
||||
private String ec_name;
|
||||
private String ec_file;
|
||||
private String ec_status;
|
||||
private Long ec_apply_id;
|
||||
private String result_url;
|
||||
|
||||
@ -223,6 +223,15 @@ public class ShopMchEntry implements Serializable {
|
||||
@ApiModelProperty(value = "拉卡拉进件成功返回的JSON数据")
|
||||
private String lkl_tk_reg_resp;
|
||||
|
||||
@ApiModelProperty(value = "拉卡拉入网电子合同编号(进件必须使用)")
|
||||
private String lkl_ec_no;
|
||||
|
||||
@ApiModelProperty(value = "拉卡拉入网电子合同名称")
|
||||
private String lkl_ec_name;
|
||||
|
||||
@ApiModelProperty(value = "拉卡拉入网电子合同签署H5地址(进件必须使用)")
|
||||
private String lkl_ec_result_url;
|
||||
|
||||
@ApiModelProperty(value = "合同签署状态:0-无任何签署;1-一方签署;2-双方已签署;")
|
||||
private Integer signed_status;
|
||||
|
||||
|
||||
@ -369,5 +369,57 @@ public class UploadUtil {
|
||||
return path.substring(lastIndex + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 base64UrlSafeString Base64字符串转换为文件
|
||||
*
|
||||
* @param base64UrlSafeString
|
||||
* @return
|
||||
*/
|
||||
public static File convertBase64ToFile(String base64UrlSafeString) {
|
||||
// 输入校验
|
||||
if (base64UrlSafeString == null || base64UrlSafeString.isEmpty()) {
|
||||
log.error("Base64字符串不能为空");
|
||||
return null;
|
||||
// throw new IllegalArgumentException("Base64字符串不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
// 1. 替换URL安全字符为标准Base64字符
|
||||
String standardBase64 = base64UrlSafeString.replace('-', '+').replace('_', '/');
|
||||
|
||||
// 2. 补齐缺失的填充字符 '='
|
||||
while (standardBase64.length() % 4 != 0) {
|
||||
standardBase64 += '=';
|
||||
}
|
||||
|
||||
// 3. 解码为字节数组
|
||||
byte[] decodedBytes = Base64Utils.decodeFromString(standardBase64);
|
||||
|
||||
// 4. 创建临时文件(自动生成唯一文件名)
|
||||
File tempFile = File.createTempFile("base64-", ".tmp");
|
||||
|
||||
// 5. 设置JVM退出时自动删除(可选)
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
// 6. 写入文件内容
|
||||
try (FileOutputStream fos = new FileOutputStream(tempFile)) {
|
||||
fos.write(decodedBytes);
|
||||
}
|
||||
|
||||
return tempFile;
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
// 处理Base64解码失败
|
||||
// throw new IllegalArgumentException("无效的Base64字符串: " + e.getMessage(), e);
|
||||
log.error("无效的Base64字符串: " + e.getMessage());
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
// 处理文件操作异常
|
||||
// throw new RuntimeException("临时文件创建失败: " + e.getMessage(), e);
|
||||
log.error("临时文件创建失败: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -33,7 +33,8 @@ public class LakalaController extends BaseControllerImpl {
|
||||
@ApiOperation(value = "测试案例", notes = "测试案例")
|
||||
@RequestMapping(value = "/testcase", method = RequestMethod.POST)
|
||||
public Object testcase(@RequestBody JSONObject paramsJSON) {
|
||||
return lakalaPayService.applyLedgerMerEc(paramsJSON.getStr("mchMobile"));
|
||||
// return lakalaPayService.applyLedgerMerEc(paramsJSON.getStr("mchMobile"));
|
||||
return lakalaPayService.LedgerMerEcDownload(975790666910121984L);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "本地文件转base64", notes = "本地文件转base64")
|
||||
|
||||
@ -68,7 +68,7 @@ public class LklTkController extends BaseControllerImpl {
|
||||
|
||||
// https://mall.gpxscs.cn/api/mobile/shop/lakala/ledger/applyLedgerMerReceiverBindNotify
|
||||
@ApiOperation(value = "拉卡拉进件申请异步回调通知", notes = "拉卡拉进件申请异步回调通知")
|
||||
@RequestMapping(value = "/registrationMerchantNotify", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
@RequestMapping(value = "/registrationMerchantNotify", method = {RequestMethod.POST})
|
||||
public ResponseEntity<JSONObject> registrationMerchantNotify(HttpServletRequest request) {
|
||||
JSONObject resp = lklTkService.registrationMerchantNotify(request);
|
||||
if (resp != null && resp.get("code").equals("200")) {
|
||||
|
||||
@ -125,6 +125,15 @@ public interface LakalaApiService {
|
||||
*/
|
||||
JSONObject applyLedgerMerEcNotify(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 商户入网电子合同下载
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=294
|
||||
*
|
||||
* @param ecApplyId
|
||||
* @return
|
||||
*/
|
||||
String LedgerMerEcDownload(Long ecApplyId);
|
||||
|
||||
/**
|
||||
* 商户分账业务开通申请回调
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=379
|
||||
|
||||
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
public interface LklBanksService {
|
||||
|
||||
/**
|
||||
* 根据关键字查询有效记录分页列表
|
||||
* 根据关键字查询有效记录分页列表(不带地区)
|
||||
*
|
||||
* @param keyword
|
||||
* @param pageNum
|
||||
@ -27,5 +27,24 @@ public interface LklBanksService {
|
||||
Page<LklBanks> searchBranchBanksPageList(String keyword, Integer pageNum, Integer pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* 根据关键字分词进行分页查询支行列表(带省市地区)
|
||||
*
|
||||
* @param bankNo 总行号
|
||||
* @param branchBankNo 支行号
|
||||
* @param type 1-店铺地区;2-银行地区
|
||||
* @param keyword 查询关键字,做分词
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
IPage<Map> pageBranchBanksList(String bankNo, String branchBankNo, Integer type, String keyword, Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 根据支行号查询支行信息(带省市地区)
|
||||
*
|
||||
* @param branchBankNo 支行号
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> GetLklBankByBranchBankNo(String branchBankNo);
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
|
||||
package com.suisung.mall.shop.lakala.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.suisung.mall.common.modules.lakala.LklLedgerEc;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
@ -34,18 +33,21 @@ public interface LklLedgerEcService extends IBaseService<LklLedgerEc> {
|
||||
* 根据接applyId查询记录
|
||||
*
|
||||
* @param applyId
|
||||
* @param ecStatus
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
LklLedgerEc getByApplyId(Long applyId, Integer status);
|
||||
|
||||
LklLedgerEc getByApplyId(Long applyId, String ecStatus, Integer status);
|
||||
|
||||
/**
|
||||
* 通过mchId商家Id记录信息构建申请入网电子合同的请求参数
|
||||
* 根据商户手机号查询记录
|
||||
*
|
||||
* @param mchMobile
|
||||
* @param ecStatus
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
JSONObject buildApplyLedgerEcReqParams(String mchMobile);
|
||||
LklLedgerEc getByMchMobile(String mchMobile, String ecStatus, Integer status);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ import com.suisung.mall.shop.esign.service.EsignContractFillingFileService;
|
||||
import com.suisung.mall.shop.esign.service.EsignContractService;
|
||||
import com.suisung.mall.shop.lakala.service.*;
|
||||
import com.suisung.mall.shop.lakala.utils.LakalaUtil;
|
||||
import com.suisung.mall.shop.page.service.OssService;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -49,6 +50,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@ -83,10 +85,16 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
private String lklNotifyCerPath; //拉卡拉支付平台证书地址2(用于拉卡拉通知验签)
|
||||
@Value("${lakala.org_code}")
|
||||
private String orgCode;
|
||||
@Value("${lakala.tk.ratio}")
|
||||
private String ratio;
|
||||
@Value("${project.domain}")
|
||||
private String projectDomain;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profile;
|
||||
|
||||
@Value("#{accountBaseConfigService.getConfig('tengxun_default_dir')}")
|
||||
private String TENGXUN_DEFAULT_DIR;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
@ -122,6 +130,14 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
@Autowired
|
||||
private LklLedgerEcService lklLedgerEcService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private LklTkServiceImpl lklTkService;
|
||||
|
||||
@Resource
|
||||
private OssService ossService;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化 拉卡拉SDK
|
||||
*
|
||||
@ -136,7 +152,9 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
}
|
||||
|
||||
protected boolean isProd() {
|
||||
return "prod".equalsIgnoreCase(profile);
|
||||
return false;
|
||||
// 正式发布时再启用
|
||||
//return "prod".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -454,7 +472,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家申请入网电子合同
|
||||
* 商家申请入网电子合同(给到商家签署合同)
|
||||
*
|
||||
* @param mchMobile
|
||||
* @return
|
||||
@ -472,6 +490,11 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
return Pair.of(false, I18nUtil._("无法查找商家相关信息!"));
|
||||
}
|
||||
|
||||
LklLedgerEc lklLedgerEc = lklLedgerEcService.getByMchMobile(mchMobile, "", CommonConstant.Enable);
|
||||
if (lklLedgerEc != null && "COMPLETED".equals(lklLedgerEc.getEc_status())) {
|
||||
return Pair.of(true, I18nUtil._("商家已经申请过入网电子合同!"));
|
||||
}
|
||||
|
||||
// 是企业类型商家
|
||||
Boolean isQy = CommonConstant.MCH_ENTITY_TYPE_QY.equals(shopMchEntry.getEntity_type());
|
||||
|
||||
@ -502,8 +525,8 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
if (isProd()) {
|
||||
domain += "/api";
|
||||
}
|
||||
// 给拉卡拉通知的回调地址
|
||||
String retUrl = domain + "/mobile/shop/lakala/ec/applyNotify";
|
||||
// 给拉卡拉通知的回调地址 TODO 生产环境一定去掉 api
|
||||
String retUrl = domain + "/api/mobile/shop/lakala/ec/applyNotify";
|
||||
reqData.put("ret_url", retUrl);
|
||||
|
||||
LocalDate today = LocalDate.now(); // 获取当前日期
|
||||
@ -546,6 +569,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
ecParams.put("D1", shopMchEntry.getBank_name());
|
||||
ecParams.put("D2", signDate);
|
||||
ecParams.put("D4", platformName);
|
||||
ecParams.put("D5", shopMchEntry.getLogin_mobile());
|
||||
ecParams.put("D7", signDate);
|
||||
ecParams.put("D9", signDate);
|
||||
ecParams.put("D11", signDate);
|
||||
@ -553,12 +577,12 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
ecParams.put("E1", platformName);
|
||||
ecParams.put("E2", "小发同城平台商户合作协议");
|
||||
ecParams.put("E3", "2");
|
||||
ecParams.put("E4", "70");
|
||||
ecParams.put("E5", platformName);
|
||||
ecParams.put("E6", ratio);
|
||||
ecParams.put("E7", signDate);
|
||||
ecParams.put("E8", shopMchEntry.getAccount_holder_name());
|
||||
|
||||
// 注:该字段是字符串,不是json
|
||||
// 注:该字段是json字符串,不是json对象
|
||||
reqData.put("ec_content_parameters", ecParams.toString());
|
||||
|
||||
JSONObject reqBody = new JSONObject();
|
||||
@ -609,7 +633,6 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
return Pair.of(false, "商家入网申请电子合同失败:本地数据保存失败");
|
||||
}
|
||||
|
||||
|
||||
return Pair.of(true, "商家入网申请电子合同成功");
|
||||
}
|
||||
|
||||
@ -638,7 +661,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
req.setContactMobile(paramsJSON.getStr("contactMobile")); // 商户入驻注册的手机号
|
||||
// 分账比例为了考虑低价订单的运费占比高,分账比例暂时定70%分账给商户,30%分账给平台
|
||||
// new BigDecimal(paramsJSON.getStr("splitLowestRatio"))
|
||||
req.setSplitLowestRatio(BigDecimal.valueOf(70));
|
||||
req.setSplitLowestRatio(new BigDecimal(ratio));
|
||||
String fileName = paramsJSON.getStr("splitEntrustFileName");
|
||||
req.setSplitEntrustFileName(fileName);
|
||||
|
||||
@ -699,7 +722,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
|
||||
@Override
|
||||
public Pair<Boolean, String> innerApplyLedgerMer(String merCupNo) {
|
||||
log.info("商户分账业务开通申请开始");
|
||||
log.debug("商户分账业务开通申请开始");
|
||||
|
||||
if (StringUtils.isBlank(merCupNo)) {
|
||||
return Pair.of(false, I18nUtil._("商户号不能为空!"));
|
||||
@ -730,7 +753,8 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
req.setContactMobile(shopMchEntry.getLogin_mobile()); // 商户入驻注册的手机号
|
||||
// 分账比例为了考虑低价订单的运费占比高,分账比例暂时定70%分账给商户,30%分账给平台
|
||||
// new BigDecimal(paramsJSON.getStr("splitLowestRatio"))
|
||||
req.setSplitLowestRatio(BigDecimal.valueOf(70));
|
||||
req.setSplitLowestRatio(new BigDecimal(ratio));
|
||||
req.setEleContractNo(shopMchEntry.getLkl_ec_no());
|
||||
String fileName = "小发同城分账授权委托书.pdf";//paramsJSON.getStr("splitEntrustFileName");
|
||||
req.setSplitEntrustFileName(fileName);
|
||||
|
||||
@ -832,23 +856,42 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
if (paramsJSON != null) {
|
||||
Long ecApplyId = paramsJSON.getLong("ecApplyId");
|
||||
String ecNo = paramsJSON.getStr("ecNo");
|
||||
String ecStatus = paramsJSON.getStr("ecStatus"); // COMPLETED
|
||||
if (ecStatus == null || !ecStatus.equals("COMPLETED")) {
|
||||
log.info("商户入网电子合同申请状态尚未签署完成!");
|
||||
respData.put("retMsg", "入网电子合同尚未签署完成!");
|
||||
return respData;
|
||||
}
|
||||
|
||||
if (ecApplyId == null || StrUtil.isBlank(ecNo)) {
|
||||
log.info("商户入网电子合同申请回调:ecApplyId 为空");
|
||||
respData.put("retMsg", "ecApplyId 返回空值!");
|
||||
return respData;
|
||||
}
|
||||
|
||||
if (lklLedgerEcService.getByApplyId(ecApplyId, CommonConstant.Enable) != null) {
|
||||
LklLedgerEc lklLedgerEc = lklLedgerEcService.getByApplyId(ecApplyId, "", CommonConstant.Enable);
|
||||
if (lklLedgerEc == null) {
|
||||
log.info("商户入网电子合同申请回调:未找到对应的入网电子合同记录");
|
||||
respData.put("retMsg", "未找到对应的入网电子合同记录!");
|
||||
return respData;
|
||||
}
|
||||
|
||||
if ("COMPLETED".equals(lklLedgerEc.getEc_status())) {
|
||||
respData.put("retCode", lklSuccessCode);
|
||||
respData.put("retMsg", "操作成功!");
|
||||
log.info("商户入网电子合同申请回调:已处理成功,不需再重新处理");
|
||||
return respData;
|
||||
}
|
||||
|
||||
// 更改本地分账记录状态数据
|
||||
// 把 base64 合同文件,上传到 cos 服务器,返回 url 地址
|
||||
String ecFileUrl = LedgerMerEcDownload(ecApplyId);
|
||||
|
||||
// 更改本地记录状态数据
|
||||
LklLedgerEc updRecord = new LklLedgerEc();
|
||||
updRecord.setEc_apply_id(ecApplyId);
|
||||
updRecord.setEc_no(ecNo);
|
||||
updRecord.setEc_name(paramsJSON.getStr("ecName"));
|
||||
updRecord.setEc_file(ecFileUrl); // 合同本地文件COS URL链接
|
||||
updRecord.setEc_status(paramsJSON.getStr("ecStatus"));
|
||||
// 更新本地数据状态和合同编号、合同名字
|
||||
Boolean success = lklLedgerEcService.updateByApplyId(updRecord);
|
||||
@ -857,13 +900,106 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
respData.put("retMsg", "操作成功!");
|
||||
log.info("商户入网电子合同申请回调:处理成功");
|
||||
|
||||
// 更新商家入驻表的合同编号,合同名称
|
||||
// 更新商家入驻表的合同编号,和签署地址
|
||||
shopMchEntryService.updateMerchEntryLklEcNo(lklLedgerEc.getMch_id(), ecNo, paramsJSON.getStr("ecName"), lklLedgerEc.getResult_url(), ecFileUrl);
|
||||
|
||||
// TODO 商家电子合同签署完毕后,收到异步通知,触发拉卡拉商家进件(重要环节)
|
||||
// 下一步,等待拉卡拉系统审核,和人工审核,收到异步通知之后,触发1、e签宝的电子合同签署,2、新增分账接收方
|
||||
Pair<Boolean, String> resultPair = lklTkService.registrationMerchant(lklLedgerEc.getMch_mobile(), "");
|
||||
if (!resultPair.getFirst()) {
|
||||
log.error("###商户入网电子合同签署通知回调:拉卡拉商家进件失败:", resultPair.getSecond());
|
||||
// return CommonResult.failed(resultPair.getSecond());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return respData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户入网盖章电子合同下载
|
||||
*
|
||||
* @param ecApplyId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String LedgerMerEcDownload(Long ecApplyId) {
|
||||
log.debug("商家开始申请入网电子合同");
|
||||
if (ObjectUtil.isEmpty(ecApplyId)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
JSONObject reqData = new JSONObject();
|
||||
reqData.put("order_no", StringUtils.genLklOrderNo(8));
|
||||
reqData.put("org_code", orgCode);
|
||||
reqData.put("ec_apply_id", ecApplyId);
|
||||
|
||||
JSONObject reqBody = new JSONObject();
|
||||
reqBody.put("req_time", DateTimeUtils.formatDateTime(LocalDateTime.now(), "yyyyMMddHHmmss"));
|
||||
reqBody.put("version", "1.0");
|
||||
reqBody.put("req_data", reqData);
|
||||
|
||||
String reqUrl = serverUrl + "/sit/api/v3/mms/open_api/ec/download";
|
||||
if (isProd()) {
|
||||
reqUrl = serverUrl + "/api/v3/mms/open_api/ec/download";
|
||||
}
|
||||
|
||||
String privateKey = LakalaUtil.getResourceFile(priKeyPath, false, true);
|
||||
String authorization = LakalaUtil.genAuthorization(privateKey, appId, serialNo, reqBody.toString());
|
||||
|
||||
JSONObject header = new JSONObject();
|
||||
header.put("Authorization", authorization);
|
||||
|
||||
ResponseEntity<JSONObject> response = RestTemplateHttpUtil.sendPostBodyBackEntity(reqUrl, header, reqBody, JSONObject.class);
|
||||
if (ObjectUtil.isEmpty(response) || response.getStatusCode() != HttpStatus.OK) {
|
||||
log.error("下载电子合同失败:返回状态有误!");
|
||||
return "";
|
||||
}
|
||||
|
||||
JSONObject respBody = response.getBody();
|
||||
if (ObjectUtil.isNotEmpty(respBody) && !lklSuccessCode.equals(respBody.getStr("code"))) {
|
||||
String errMsg = StrUtil.isBlank(respBody.getStr("msg")) ? "返回状态有误" : respBody.getStr("msg");
|
||||
log.error("下载电子合同失败:{}!", errMsg);
|
||||
return "";
|
||||
}
|
||||
|
||||
JSONObject respData = respBody.getJSONObject("resp_data");
|
||||
if (respBody.getJSONObject("resp_data") == null) {
|
||||
log.error("下载电子合同失败:返回数据有误!");
|
||||
return "";
|
||||
}
|
||||
|
||||
String ecFile = respData.getStr("ec_file");
|
||||
if (StrUtil.isBlank(ecFile)) {
|
||||
log.error("下载电子合同失败:返回数据有误!");
|
||||
return "";
|
||||
}
|
||||
|
||||
LklLedgerEc lklLedgerEc = lklLedgerEcService.getByApplyId(ecApplyId, "", CommonConstant.Enable);
|
||||
if (lklLedgerEc == null) {
|
||||
log.error("下载电子合同失败:未找到对应的入网电子合同记录");
|
||||
return "";
|
||||
}
|
||||
|
||||
String fileBase64 = respData.getStr("ec_file");
|
||||
File file = UploadUtil.convertBase64ToFile(fileBase64);
|
||||
|
||||
// REMARK 把合同文件 url 上传到cos服务器
|
||||
String cosFileName = TENGXUN_DEFAULT_DIR.concat("/").concat("contract")
|
||||
.concat("/")
|
||||
.concat(lklLedgerEc.getMch_mobile()).concat("/")
|
||||
.concat("signed").concat("/")
|
||||
.concat(ecApplyId.toString()).concat(".pdf");
|
||||
|
||||
// 上传到cos服务器
|
||||
String cosFileUrl = ossService.uploadObject4OSS(file, cosFileName);
|
||||
|
||||
// 删除临时文件
|
||||
file.delete();
|
||||
|
||||
return cosFileUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户分账业务开通申请回调
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=379
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
package com.suisung.mall.shop.lakala.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -93,4 +94,24 @@ public class LklBanksServiceImpl extends BaseServiceImpl<LklBanksMapper, LklBank
|
||||
Page<Map> page = new Page<>(pageNum, pageSize);
|
||||
return lklBanksMapper.pageBranchBanksList(page, bankNo, branchBankNo, type, jiebaUtils.segmentForSearch(keyword));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据支行号查询支行信息(带省市地区)
|
||||
*
|
||||
* @param branchBankNo 支行号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> GetLklBankByBranchBankNo(String branchBankNo) {
|
||||
if (StrUtil.isBlank(branchBankNo)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IPage<Map> list = lklBanksMapper.pageBranchBanksList(new Page<>(1, 1), null, branchBankNo, 2, null);
|
||||
if (list == null || CollectionUtil.isEmpty(list.getRecords())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.getRecords().get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,10 +11,8 @@ package com.suisung.mall.shop.lakala.service.impl;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.modules.lakala.LklLedgerEc;
|
||||
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.esign.service.EsignPlatformInfoService;
|
||||
import com.suisung.mall.shop.lakala.mapper.LklLedgerEcMapper;
|
||||
@ -104,10 +102,12 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
|
||||
* 根据接applyId查询记录
|
||||
*
|
||||
* @param applyId
|
||||
* @param ecStatus
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public LklLedgerEc getByApplyId(Long applyId, Integer status) {
|
||||
public LklLedgerEc getByApplyId(Long applyId, String ecStatus, Integer status) {
|
||||
if (ObjectUtil.isEmpty(applyId)) {
|
||||
return null;
|
||||
}
|
||||
@ -118,41 +118,44 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
|
||||
queryWrapper.eq("status", status);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(ecStatus)) {
|
||||
queryWrapper.eq("ec_status", ecStatus);
|
||||
}
|
||||
|
||||
|
||||
return getOne(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过mchId商家Id记录信息构建申请入网电子合同的请求参数
|
||||
* 根据商户手机号查询记录
|
||||
*
|
||||
* @param mchMobile
|
||||
* @param ecStatus
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject buildApplyLedgerEcReqParams(String mchMobile) {
|
||||
if (StrUtil.isBlank(mchMobile)) {
|
||||
public LklLedgerEc getByMchMobile(String mchMobile, String ecStatus, Integer status) {
|
||||
if (ObjectUtil.isEmpty(mchMobile)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByCondition(mchMobile, "");
|
||||
if (shopMchEntry == null) {
|
||||
QueryWrapper<LklLedgerEc> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("mch_mobile", mchMobile).orderByDesc("id");
|
||||
if (ObjectUtil.isNotEmpty(status)) {
|
||||
queryWrapper.eq("status", status);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(ecStatus)) {
|
||||
queryWrapper.eq("ec_status", ecStatus);
|
||||
}
|
||||
|
||||
List<LklLedgerEc> lklLedgerEcList = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(lklLedgerEcList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
jsonObject.put("mch_id", shopMchEntry.getId());
|
||||
|
||||
|
||||
return jsonObject;
|
||||
return lklLedgerEcList.get(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ import com.suisung.mall.common.utils.UploadUtil;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.shop.esign.service.EsignContractFillingFileService;
|
||||
import com.suisung.mall.shop.esign.service.EsignContractService;
|
||||
import com.suisung.mall.shop.lakala.service.LklBanksService;
|
||||
import com.suisung.mall.shop.lakala.service.LklLedgerReceiverService;
|
||||
import com.suisung.mall.shop.lakala.utils.LakalaUtil;
|
||||
import com.suisung.mall.shop.page.service.impl.OssServiceImpl;
|
||||
@ -86,6 +87,10 @@ public class LklTkServiceImpl {
|
||||
@Resource
|
||||
private EsignContractFillingFileService esignContractFillingFileService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private LklBanksService lklBanksService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private OssServiceImpl ossService;
|
||||
@ -340,7 +345,8 @@ public class LklTkServiceImpl {
|
||||
}
|
||||
|
||||
formData.put("contactMobile", mchMobile);
|
||||
formData.put("contactName", shopMchEntry.getContact_name());
|
||||
formData.put("contactName", shopMchEntry.getContact_name());// 联系人姓名
|
||||
formData.put("contractNo", shopMchEntry.getLkl_ec_no()); // 拉卡拉入网合同编号
|
||||
|
||||
// 银行账号关键字段
|
||||
formData.put("openningBankCode", shopMchEntry.getOpenning_bank_code());//结算账户开户⾏号
|
||||
@ -364,14 +370,34 @@ public class LklTkServiceImpl {
|
||||
}
|
||||
|
||||
//结算信息省市信息
|
||||
Map<String, String> bankAreaCode = getAreaCode(shopMchEntry.getBank_area(), true);
|
||||
if (ObjectUtil.isNotEmpty(bankAreaCode)) {
|
||||
formData.put("settleProvinceCode", bankAreaCode.get("provinceCode"));
|
||||
formData.put("settleCityCode", bankAreaCode.get("cityCode"));
|
||||
String[] bankAreaName = shopMchEntry.getBank_area().split(",");
|
||||
if (bankAreaName.length >= 2) {
|
||||
formData.put("settleProvinceName", bankAreaName[0]);
|
||||
formData.put("settleCityName", bankAreaName[1]);
|
||||
if (StrUtil.isBlank(shopMchEntry.getBank_district()) || StrUtil.isBlank(shopMchEntry.getBank_area())) {
|
||||
Map<String, Object> bankInfo = lklBanksService.GetLklBankByBranchBankNo(shopMchEntry.getOpenning_bank_code());
|
||||
if (ObjectUtil.isNotEmpty(bankInfo)) {
|
||||
shopMchEntry.setBank_district(bankInfo.get("district").toString());
|
||||
shopMchEntry.setBank_area(bankInfo.get("area").toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(shopMchEntry.getBank_district()) && StrUtil.isNotBlank(shopMchEntry.getBank_area())) {
|
||||
// 直接分解取值
|
||||
String[] bankAreaCodes = shopMchEntry.getBank_district().split("/");
|
||||
String[] bankAreaNames = shopMchEntry.getBank_area().split("/");
|
||||
if (bankAreaCodes.length >= 2 && bankAreaNames.length >= 2) {
|
||||
formData.put("settleProvinceCode", bankAreaCodes[0]);
|
||||
formData.put("settleProvinceName", bankAreaCodes[1]);
|
||||
formData.put("settleCityCode", bankAreaNames[0]);
|
||||
formData.put("settleCityName", bankAreaNames[1]);
|
||||
}
|
||||
} else {
|
||||
Map<String, String> bankAreaCode = getAreaCode(shopMchEntry.getBank_area(), true);
|
||||
if (ObjectUtil.isNotEmpty(bankAreaCode)) {
|
||||
formData.put("settleProvinceCode", bankAreaCode.get("provinceCode"));
|
||||
formData.put("settleCityCode", bankAreaCode.get("cityCode"));
|
||||
String[] bankAreaName = shopMchEntry.getBank_area().split("/");
|
||||
if (bankAreaName.length >= 2) {
|
||||
formData.put("settleProvinceName", bankAreaName[0]);
|
||||
formData.put("settleCityName", bankAreaName[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -178,5 +178,17 @@ public interface ShopMchEntryService {
|
||||
*/
|
||||
Boolean updateMerchEntryStoreId(Long id, Integer storeId);
|
||||
|
||||
/**
|
||||
* 更新拉卡拉入网电子合同、合同名称、签署地址
|
||||
*
|
||||
* @param id
|
||||
* @param lklEcNo
|
||||
* @param lklEcName
|
||||
* @param lklEcResultUrl
|
||||
* @param ecDownloadUrl
|
||||
* @return
|
||||
*/
|
||||
Boolean updateMerchEntryLklEcNo(Long id, String lklEcNo, String lklEcName, String lklEcResultUrl, String ecDownloadUrl);
|
||||
|
||||
|
||||
}
|
||||
@ -30,6 +30,7 @@ import com.suisung.mall.shop.components.TaskService;
|
||||
import com.suisung.mall.shop.esign.service.EsignContractFillingFileService;
|
||||
import com.suisung.mall.shop.esign.service.EsignContractService;
|
||||
import com.suisung.mall.shop.esign.service.EsignPlatformInfoService;
|
||||
import com.suisung.mall.shop.lakala.service.impl.LakalaApiServiceImpl;
|
||||
import com.suisung.mall.shop.lakala.service.impl.LklTkServiceImpl;
|
||||
import com.suisung.mall.shop.message.service.ShopMessageTemplateService;
|
||||
import com.suisung.mall.shop.store.mapper.ShopMchEntryMapper;
|
||||
@ -81,6 +82,10 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private LakalaApiServiceImpl lakalaApiService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取店铺的经营类目列表
|
||||
@ -514,8 +519,15 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
return CommonResult.failed("系统处理审批出错,请联系管理员!");
|
||||
}
|
||||
|
||||
// TODO 审核通过后,触发去拉卡拉进件,系统审核
|
||||
Pair<Boolean, String> resultPair = lklTkService.registrationMerchant(record.getLogin_mobile(), record.getBiz_license_number());
|
||||
if (approvalStatus.equals(CommonConstant.MCH_APPR_STA_NOPASS)) {
|
||||
return CommonResult.success(null, "驳回成功!");
|
||||
}
|
||||
|
||||
// 审批通过的时候,进行下一步工作:触发去拉卡拉商家入网电子合同签署
|
||||
|
||||
// 平台人工审核通过后,触发去拉卡拉商家入网电子合同签署
|
||||
// 下一步:商家入网电子合同签署完毕后,收到异步通知,触发拉卡拉商家进件(重要环节)
|
||||
Pair<Boolean, String> resultPair = lakalaApiService.applyLedgerMerEc(record.getLogin_mobile());
|
||||
if (!resultPair.getFirst()) {
|
||||
return CommonResult.failed(resultPair.getSecond());
|
||||
}
|
||||
@ -836,4 +848,40 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
.eq("id", id)
|
||||
.set("store_id", storeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新拉卡拉入网电子合同和签署地址
|
||||
*
|
||||
* @param id
|
||||
* @param lklEcNo
|
||||
* @param lklEcResultUrl
|
||||
* @param ecDownloadUrl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateMerchEntryLklEcNo(Long id, String lklEcNo, String lklEcName, String lklEcResultUrl, String ecDownloadUrl) {
|
||||
if (ObjectUtil.isEmpty(id) && StrUtil.isBlank(lklEcNo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", id);
|
||||
updateWrapper.set("lkl_ec_no", lklEcNo);
|
||||
|
||||
if (StrUtil.isNotBlank(lklEcName)) {
|
||||
updateWrapper.set("lkl_ec_name", lklEcName);
|
||||
}
|
||||
|
||||
|
||||
if (StrUtil.isNotBlank(lklEcResultUrl)) {
|
||||
updateWrapper.set("lkl_ec_result_url", lklEcResultUrl);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(ecDownloadUrl)) {
|
||||
updateWrapper.set("contract_download_url", ecDownloadUrl);
|
||||
}
|
||||
|
||||
|
||||
return update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,6 +168,7 @@ lakala:
|
||||
client_id: lsycs
|
||||
client_secret: XPa1HB5d55Ig0qV8
|
||||
user_no: 29153396
|
||||
ratio: 70.00
|
||||
api_pub_key_path: payKey/lakala/dev/tk_api_public_key.txt
|
||||
api_pri_key_path: payKey/lakala/dev/tk_api_private_key.txt
|
||||
notify_pub_key_path: payKey/lakala/dev/tk_notify_public_key.txt
|
||||
|
||||
@ -168,6 +168,7 @@ lakala:
|
||||
client_id: lsycs
|
||||
client_secret: XPa1HB5d55Ig0qV8
|
||||
user_no: 29153396
|
||||
ratio: 70.00
|
||||
api_pub_key_path: payKey/lakala/dev/tk_api_public_key.txt
|
||||
api_pri_key_path: payKey/lakala/dev/tk_api_private_key.txt
|
||||
notify_pub_key_path: payKey/lakala/dev/tk_notify_public_key.txt
|
||||
|
||||
@ -195,6 +195,7 @@ lakala:
|
||||
client_id: lsycs
|
||||
client_secret: XPa1HB5d55Ig0qV8
|
||||
user_no: 29153396
|
||||
ratio: 70.00
|
||||
api_pub_key_path: payKey/lakala/dev/tk_api_public_key.txt
|
||||
api_pri_key_path: payKey/lakala/dev/tk_api_private_key.txt
|
||||
notify_pub_key_path: payKey/lakala/dev/tk_notify_public_key.txt
|
||||
|
||||
@ -172,6 +172,7 @@ lakala:
|
||||
client_id: lsycs
|
||||
client_secret: XPa1HB5d55Ig0qV8
|
||||
user_no: 29153396
|
||||
ratio: 70.00
|
||||
api_pub_key_path: payKey/lakala/dev/tk_api_public_key.txt
|
||||
api_pri_key_path: payKey/lakala/dev/tk_api_private_key.txt
|
||||
notify_pub_key_path: payKey/lakala/dev/tk_notify_public_key.txt
|
||||
|
||||
@ -172,6 +172,7 @@ lakala:
|
||||
client_id: lsycs
|
||||
client_secret: XPa1HB5d55Ig0qV8
|
||||
user_no: 29153396
|
||||
ratio: 70.00
|
||||
api_pub_key_path: payKey/lakala/dev/tk_api_public_key.txt
|
||||
api_pri_key_path: payKey/lakala/dev/tk_api_private_key.txt
|
||||
notify_pub_key_path: payKey/lakala/dev/tk_notify_public_key.txt
|
||||
|
||||
Loading…
Reference in New Issue
Block a user