商户入驻后增加了设置提现模式:自动结算余额
This commit is contained in:
parent
a453a571be
commit
07a420c1e6
@ -44,6 +44,7 @@ public class LklLedgerMember implements Serializable {
|
||||
private String ele_contract_no;
|
||||
private String split_launch_mode;
|
||||
private String settle_type;
|
||||
private String settle_type_draw;
|
||||
private String split_rule_source;
|
||||
private String ret_url;
|
||||
private String apply_id;
|
||||
|
||||
@ -125,7 +125,7 @@ public class ShopBaseCrontabServiceImpl extends BaseServiceImpl<ShopBaseCrontabM
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cron 表达式
|
||||
* 获取 cron 表达式
|
||||
*
|
||||
* @param shopBaseCrontab
|
||||
* @return
|
||||
|
||||
@ -21,7 +21,7 @@ import java.util.List;
|
||||
*/
|
||||
public class UpdateOrderStatusJob extends QuartzJobBean {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UpdateOrderStatusJob.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(UpdateOrderStatusJob.class);
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
@ -29,6 +29,8 @@ public class UpdateOrderStatusJob extends QuartzJobBean {
|
||||
ShopOrderInfoService shopOrderInfoService = SpringUtil.getBean(ShopOrderInfoService.class);
|
||||
ShopDistributionUserOrderService shopDistributionUserOrderService = SpringUtil.getBean(ShopDistributionUserOrderService.class);
|
||||
|
||||
// 在UpdateOrderStatusJob.execute方法开始添加日志
|
||||
logger.info("UpdateOrderStatusJob 方法开始执行");
|
||||
|
||||
// 自动取消未支付订单
|
||||
//shopOrderBaseService.autoCancelOrder();
|
||||
|
||||
@ -102,9 +102,17 @@ public class QuartzServiceImpl implements QuartzService {
|
||||
scheduler.start();
|
||||
logger.info("[Quartz] 调度器启动成功");
|
||||
}
|
||||
|
||||
if (scheduler.getTriggerState(triggerKey) != Trigger.TriggerState.NORMAL) {
|
||||
logger.error("Trigger注册异常,当前状态: {}", scheduler.getTriggerState(triggerKey));
|
||||
}
|
||||
|
||||
logger.info("Trigger当前状态: {}", scheduler.getTriggerState(triggerKey));
|
||||
|
||||
// 在调度器启动检查前添加
|
||||
logger.debug("[Quartz] 调度器当前状态 - isStarted: {}, SchedulerName: {}",
|
||||
scheduler.isStarted(), scheduler.getSchedulerName());
|
||||
|
||||
} catch (SchedulerException e) {
|
||||
logger.error("[Quartz] 添加定时任务失败!任务名称={}, 任务组={}, 触发器名称={}, 触发器组={}",
|
||||
jName, jGroup, tName, tGroup, e);
|
||||
|
||||
@ -28,7 +28,7 @@ public class LakalaAdminController extends BaseControllerImpl {
|
||||
|
||||
@Resource
|
||||
private LakalaApiService lakalaPayService;
|
||||
|
||||
|
||||
@ApiOperation(value = "查询拉卡拉商户可分账的金额", notes = "查询拉卡拉商户可分账的金额")
|
||||
@RequestMapping(value = "/sacs/queryMchSplitAmt", method = RequestMethod.POST)
|
||||
public CommonResult queryMchCanSplitAmt(@RequestBody JSONObject paramsJSON) {
|
||||
@ -39,4 +39,26 @@ public class LakalaAdminController extends BaseControllerImpl {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "提款模式设置", notes = "提款模式设置")
|
||||
@RequestMapping(value = "/ewallet/settleProfile", method = RequestMethod.POST)
|
||||
public CommonResult ewalletSettleProfile(@RequestBody JSONObject paramsJSON) {
|
||||
try {
|
||||
// 参数校验
|
||||
if (paramsJSON == null) {
|
||||
return CommonResult.failed("请求参数不能为空");
|
||||
}
|
||||
|
||||
// 执行业务逻辑
|
||||
Boolean success = lakalaPayService.ewalletSettleProfile(paramsJSON.getStr("mercId"), paramsJSON.getStr("settleType"), paramsJSON.getStr("settleTime"));
|
||||
|
||||
if (success) {
|
||||
return CommonResult.success("提款模式设置成功");
|
||||
}
|
||||
|
||||
return CommonResult.failed("提款模式设置失败");
|
||||
} catch (Exception e) {
|
||||
return CommonResult.failed("系统异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -239,4 +239,23 @@ public class LakalaController extends BaseControllerImpl {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分账结果通知
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=393
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "提款模式设置结果通知", notes = "提款模式设置结果通知")
|
||||
@RequestMapping(value = "/ewallet/settleProfileNotify", method = RequestMethod.POST)
|
||||
public ResponseEntity<JSONObject> ewalletSettleProfileNotify(HttpServletRequest request) {
|
||||
JSONObject resp = lakalaPayService.ewalletSettleProfileNotify(request);
|
||||
if (resp != null && "SUCCESS".equals(resp.get("code"))) {
|
||||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resp);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -309,5 +309,25 @@ public interface LakalaApiService {
|
||||
*/
|
||||
Boolean checkAndFixLedgerMerApplyAndBindRelations(ShopMchEntry shopMchEntry);
|
||||
|
||||
/**
|
||||
* 提款模式设置
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=372
|
||||
*
|
||||
* @param mercId 822商户号或receiveNo
|
||||
* @param settleType 提款模式(01主动提款 02余额自动结算 03交易自动结算)
|
||||
* @param settleTime 余额自动结算时间(小时)- 默认值:06。如08:00-09:00到账,则传入08。
|
||||
* @return 设置是否成功
|
||||
*/
|
||||
Boolean ewalletSettleProfile(String mercId, String settleType, String settleTime);
|
||||
|
||||
|
||||
/**
|
||||
* 提款模式设置结果通知
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=372
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
JSONObject ewalletSettleProfileNotify(HttpServletRequest request);
|
||||
|
||||
}
|
||||
|
||||
@ -55,4 +55,13 @@ public interface LklLedgerMemberService extends IBaseService<LklLedgerMember> {
|
||||
*/
|
||||
Boolean updateAuditResult(String applyId, String merInnerNo, String merCupNo, String entrustFileName, String entrustFilePath, String auditStatus, String auditStatusText, String remark, String notifyResp);
|
||||
|
||||
|
||||
/**
|
||||
* 更新商户的提现模式
|
||||
*
|
||||
* @param merCupNo 银联商户号
|
||||
* @param settleType 提款模式(01主动提款 02余额自动结算 03交易自动结算)
|
||||
* @return 更新是否成功
|
||||
*/
|
||||
Boolean updateSettleTypeDraw(String merCupNo, String settleType);
|
||||
}
|
||||
|
||||
@ -682,7 +682,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
|
||||
reqData.put("splitLowestRatio", splitLowestRatio); // 商家最低分账比例不低于 20%
|
||||
reqData.put("splitRange", "ALL");
|
||||
reqData.put("settleType", "01"); //01:主动提款 03:交易自动结算 不填默认01
|
||||
reqData.put("settleType", "03"); //01:主动提款 03:交易自动结算 不填默认01
|
||||
|
||||
String postUrl = "";
|
||||
String operationType = ""; // 操作类型,用于日志记录和提示信息
|
||||
@ -1800,6 +1800,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
// 10. 检查商户绑定状态是否完成, 更改总的审核状态
|
||||
shopMchEntryService.checkMerchEntryFinished(mchId);
|
||||
|
||||
|
||||
// 11. 日志记录并返回成功响应
|
||||
log.info("商家绑定分账接收方异步通知处理完成,mchId:{} merCupNo:{}", mchId, merCupNo);
|
||||
return JSONUtil.createObj().set("code", "SUCCESS").set("message", "分账接收方绑定成功");
|
||||
@ -3256,5 +3257,121 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提款模式设置
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=372
|
||||
*
|
||||
* @param mercId 822商户号或receiveNo
|
||||
* @param settleType 提款模式(01主动提款 02余额自动结算 03交易自动结算)
|
||||
* @param settleTime 余额自动结算时间(小时)- 默认值:06。如08:00-09:00到账,则传入08。
|
||||
* @return 设置是否成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean ewalletSettleProfile(String mercId, String settleType, String settleTime) {
|
||||
// 1. 参数校验
|
||||
if (StrUtil.isBlank(mercId)) {
|
||||
log.warn("[提款模式设置] 参数校验失败:缺少必要参数, mercId={}", mercId);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置默认值
|
||||
if (StrUtil.isBlank(settleType)) {
|
||||
settleType = "02"; // 默认余额自动结算
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(settleTime)) {
|
||||
settleTime = "06"; // 默认06点结算
|
||||
}
|
||||
|
||||
try {
|
||||
// 2. 配置初始化
|
||||
initLKLSDK();
|
||||
|
||||
// 3. 装配数据
|
||||
V2LaepIndustryEwalletSettleProfileRequest request = new V2LaepIndustryEwalletSettleProfileRequest();
|
||||
request.setBmcpNo(orgCode);
|
||||
request.setMercId(mercId);
|
||||
request.setSettleType(settleType);
|
||||
request.setSettleTime(settleTime);
|
||||
request.setNotifyUrl(projectDomain + "/api/mobile/shop/lakala/ewallet/settleProfileNotify");
|
||||
|
||||
log.info("[提款模式设置] 开始设置提款模式, mercId={}, settleType={}, settleTime={}",
|
||||
mercId, settleType, settleTime);
|
||||
|
||||
// 4. 发送请求
|
||||
String responseStr = LKLSDK.httpPost(request);
|
||||
if (StrUtil.isBlank(responseStr)) {
|
||||
log.error("[提款模式设置] 服务器无响应, mercId={}", mercId);
|
||||
return false;
|
||||
}
|
||||
|
||||
JSONObject lakalaRespJSON = JSONUtil.parseObj(responseStr);
|
||||
if (lakalaRespJSON == null) {
|
||||
log.error("[提款模式设置] 响应数据解析失败, mercId={}, response={}", mercId, responseStr);
|
||||
return false;
|
||||
}
|
||||
|
||||
String retCode = lakalaRespJSON.getStr("retCode");
|
||||
boolean success = "000000".equals(retCode);
|
||||
|
||||
if (success) {
|
||||
log.info("[提款模式设置] 设置成功, mercId={}", mercId);
|
||||
|
||||
// 更新商户的提现模式
|
||||
lklLedgerMemberService.updateSettleTypeDraw(mercId, settleType);
|
||||
} else {
|
||||
log.warn("[提款模式设置] 设置失败, mercId={}, retCode={}, retMsg={}",
|
||||
mercId, retCode, lakalaRespJSON.getStr("retMsg"));
|
||||
}
|
||||
|
||||
return success;
|
||||
} catch (SDKException e) {
|
||||
log.error("[提款模式设置] SDK调用异常, mercId={}", mercId, e);
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
log.error("[提款模式设置] 设置过程中发生未知异常, mercId={}", mercId, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提款模式设置结果通知
|
||||
* 参考:https://o.lakala.com/#/home/document/detail?id=372
|
||||
*
|
||||
* @param request HTTP请求对象,包含拉卡拉回调通知的参数
|
||||
* @return JSONObject 响应结果对象
|
||||
*/
|
||||
@Override
|
||||
public JSONObject ewalletSettleProfileNotify(HttpServletRequest request) {
|
||||
log.info("[提款模式设置通知] 开始处理拉卡拉提款模式设置结果异步回调");
|
||||
|
||||
// 1. 验签处理 - 验证通知来源的合法性
|
||||
Pair<Boolean, String> signCheckResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false);
|
||||
if (!signCheckResult.getFirst()) {
|
||||
String errorMsg = "提款模式设置通知验签失败: " + signCheckResult.getSecond();
|
||||
log.warn("[提款模式设置通知] {}", errorMsg);
|
||||
return JSONUtil.createObj()
|
||||
.set("code", "FAIL")
|
||||
.set("message", signCheckResult.getSecond());
|
||||
}
|
||||
|
||||
// 2. 解析回调参数
|
||||
JSONObject paramsJSON = JSONUtil.parseObj(signCheckResult.getSecond());
|
||||
if (paramsJSON == null) {
|
||||
log.warn("[提款模式设置通知] 回调参数解析失败");
|
||||
return JSONUtil.createObj()
|
||||
.set("code", "FAIL")
|
||||
.set("message", "回调参数解析失败");
|
||||
}
|
||||
|
||||
log.info("[提款模式设置通知] 验签成功,回调参数: {}", paramsJSON);
|
||||
|
||||
// 3. 返回成功响应
|
||||
return JSONUtil.createObj()
|
||||
.set("code", "SUCCESS")
|
||||
.set("message", "处理成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -125,4 +125,40 @@ public class LklLedgerMemberServiceImpl extends BaseServiceImpl<LklLedgerMemberM
|
||||
return update(updateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商户的提现模式
|
||||
*
|
||||
* @param merCupNo 银联商户号
|
||||
* @param settleType 提款模式(01主动提款 02余额自动结算 03交易自动结算)
|
||||
* @return 更新是否成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateSettleTypeDraw(String merCupNo, String settleType) {
|
||||
// 参数校验
|
||||
if (StrUtil.hasBlank(merCupNo, settleType)) {
|
||||
log.warn("[更新提现模式] 参数校验失败:merCupNo或settleType为空, merCupNo={}, settleType={}", merCupNo, settleType);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
UpdateWrapper<LklLedgerMember> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("mer_cup_no", merCupNo).ne("settle_type_draw", settleType);
|
||||
updateWrapper.set("settle_type_draw", settleType);
|
||||
|
||||
boolean result = update(updateWrapper);
|
||||
|
||||
if (result) {
|
||||
log.info("[更新提现模式] 更新成功, merCupNo={}, settleType={}", merCupNo, settleType);
|
||||
} else {
|
||||
log.warn("[更新提现模式] 未找到匹配记录或更新失败, merCupNo={}, settleType={}", merCupNo, settleType);
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("[更新提现模式] 更新过程中发生异常, merCupNo={}, settleType={}", merCupNo, settleType, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -106,21 +106,26 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
*
|
||||
* @param mchId 入驻记录Id, 必填项(mchId 和 storeId 其一必填) 优先
|
||||
* @param storeId 商家门店ID 必填项(mchId 和 storeId 其一必填)
|
||||
* @return
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示结果信息或错误信息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> createSfExpressShop(Long mchId, Integer storeId) {
|
||||
logger.info("[顺丰] 开始创建连锁店铺: mchId={}, storeId={}", mchId, storeId);
|
||||
|
||||
// 参数校验
|
||||
if (ObjectUtil.isEmpty(mchId) && ObjectUtil.isEmpty(storeId)) {
|
||||
if (CheckUtil.isEmpty(mchId) && CheckUtil.isEmpty(storeId)) {
|
||||
logger.error("创建顺丰同店铺:mchId 和 storeId 其一必填");
|
||||
return Pair.of(false, "缺少必填参数");
|
||||
}
|
||||
|
||||
// 获取商家入驻信息
|
||||
ShopMchEntry shopMchEntry;
|
||||
if (ObjectUtil.isEmpty(mchId)) {
|
||||
shopMchEntry = shopMchEntryService.getShopMerchEntryByStoreId(storeId);
|
||||
} else {
|
||||
if (ObjectUtil.isNotEmpty(mchId)) {
|
||||
shopMchEntry = shopMchEntryService.shopMerchEntryById(mchId);
|
||||
logger.debug("[顺丰] 通过mchId获取入驻信息: mchId={}", mchId);
|
||||
} else {
|
||||
shopMchEntry = shopMchEntryService.getShopMerchEntryByStoreId(storeId);
|
||||
logger.debug("[顺丰] 通过storeId获取入驻信息: storeId={}", storeId);
|
||||
}
|
||||
|
||||
if (shopMchEntry == null) {
|
||||
@ -149,39 +154,53 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
return Pair.of(false, "联系人姓名不能为空");
|
||||
}
|
||||
|
||||
String contact_mobile = StrUtil.isBlank(shopMchEntry.getLegal_person_mobile()) ?
|
||||
shopMchEntry.getLogin_mobile() : shopMchEntry.getLegal_person_mobile();
|
||||
String contactMobile = StrUtil.isNotBlank(shopMchEntry.getLegal_person_mobile()) ?
|
||||
shopMchEntry.getLegal_person_mobile() : shopMchEntry.getLogin_mobile();
|
||||
|
||||
if (StrUtil.isBlank(contact_mobile)) {
|
||||
if (StrUtil.isBlank(contactMobile)) {
|
||||
logger.error("创建顺丰同店铺:联系人手机号不能为空");
|
||||
return Pair.of(false, "联系人手机号不能为空");
|
||||
}
|
||||
|
||||
// shopMchEntry.getStore_area() == 广西壮族自治区/贵港市/桂平市 or 广西壮族自治区/贵港市
|
||||
String[] areaNames = StrUtil.isNotBlank(shopMchEntry.getStore_area()) ?
|
||||
shopMchEntry.getStore_area().split("/") : new String[0];
|
||||
String cityName = areaNames.length > 0 ?
|
||||
areaNames[areaNames.length - 1] :
|
||||
shopMchEntry.getStore_area() != null ? shopMchEntry.getStore_area().replace("/", "") : "";
|
||||
|
||||
// 如果城市名为空,使用默认值
|
||||
if (StrUtil.isBlank(cityName)) {
|
||||
cityName = "桂平市"; // 默认城市
|
||||
logger.warn("城市名为空,使用默认城市: {}", cityName);
|
||||
// 解析城市名称
|
||||
String cityName = "桂平市"; // 默认城市
|
||||
if (StrUtil.isNotBlank(shopMchEntry.getStore_area())) {
|
||||
String[] areaNames = shopMchEntry.getStore_area().split("/");
|
||||
if (areaNames.length > 0) {
|
||||
cityName = areaNames[areaNames.length - 1];
|
||||
} else {
|
||||
cityName = shopMchEntry.getStore_area().replace("/", "");
|
||||
}
|
||||
}
|
||||
|
||||
return createSfExpressShop(
|
||||
// 如果解析后城市名为空,使用默认值
|
||||
if (StrUtil.isBlank(cityName)) {
|
||||
cityName = "桂平市";
|
||||
logger.warn("[顺丰] 城市名为空,使用默认城市: {}", cityName);
|
||||
} else {
|
||||
logger.debug("[顺丰] 解析得到城市名: {}", cityName);
|
||||
}
|
||||
|
||||
// 为了其他顺丰店同名,店铺名称加上[门店ID]; 如:xxxx[xxxx] 聚万家生鲜超市[69]
|
||||
String shopStoreName = String.format("%s[%s]", shopMchEntry.getStore_name(), shopMchEntry.getStore_id());
|
||||
|
||||
// 调用创建店铺方法
|
||||
Pair<Boolean, String> result = createSfExpressShop(
|
||||
Convert.toInt(shopMchEntry.getStore_id()),
|
||||
shopMchEntry.getStore_name(),
|
||||
shopStoreName,
|
||||
cityName,
|
||||
shopMchEntry.getStore_address(),
|
||||
shopMchEntry.getContact_name(),
|
||||
contact_mobile,
|
||||
contactMobile,
|
||||
shopMchEntry.getStore_longitude(),
|
||||
shopMchEntry.getStore_latitude()
|
||||
);
|
||||
|
||||
logger.info("[顺丰] 连锁店铺创建结果: success={}, message={}", result.getFirst(), result.getSecond());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建顺丰同城(普通型)店铺
|
||||
*
|
||||
|
||||
@ -1777,6 +1777,9 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置商户的提现模式:02余额自动结算,6-7点自动提现
|
||||
lakalaApiService.ewalletSettleProfile(merchantEntry.getLkl_mer_cup_no(), "02", "06");
|
||||
|
||||
return true; // 返回 true,表示入驻流程已全部完成
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user