电子合同 fix bug
This commit is contained in:
parent
23deb53971
commit
9f313856f2
@ -8,38 +8,19 @@
|
||||
|
||||
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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.modules.lakala.LklLedgerEc;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
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;
|
||||
import com.suisung.mall.shop.lakala.service.LakalaApiService;
|
||||
import com.suisung.mall.shop.lakala.service.LklLedgerEcService;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, LklLedgerEc> implements LklLedgerEcService {
|
||||
|
||||
|
||||
@Resource
|
||||
private EsignPlatformInfoService esignPlatformInfoService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private LakalaApiService lakalaApiService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private ShopMchEntryService shopMchEntryService;
|
||||
|
||||
|
||||
/**
|
||||
* 根据商家Id新增或更新记录
|
||||
*
|
||||
@ -53,19 +34,21 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
|
||||
}
|
||||
|
||||
QueryWrapper<LklLedgerEc> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isEmpty(record.getMch_id())) {
|
||||
if (CheckUtil.isNotEmpty(record.getMch_id())) {
|
||||
queryWrapper.eq("mch_id", record.getMch_id());
|
||||
}
|
||||
if (ObjectUtil.isEmpty(record.getMch_mobile())) {
|
||||
|
||||
if (StrUtil.isNotBlank(record.getMch_mobile())) {
|
||||
queryWrapper.eq("mch_mobile", record.getMch_mobile());
|
||||
}
|
||||
|
||||
List<LklLedgerEc> existsRecordList = list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(existsRecordList)
|
||||
&& existsRecordList.get(0) != null
|
||||
&& existsRecordList.get(0).getId() > 0) {
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
LklLedgerEc existsRecord = findOne(queryWrapper);
|
||||
if (existsRecord != null
|
||||
&& existsRecord.getId() > 0) {
|
||||
// 更新记录
|
||||
record.setId(existsRecordList.get(0).getId());
|
||||
record.setId(existsRecord.getId());
|
||||
return updateById(record);
|
||||
}
|
||||
|
||||
@ -81,14 +64,14 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByApplyId(LklLedgerEc record) {
|
||||
if (record == null || ObjectUtil.isEmpty(record.getEc_apply_id())) {
|
||||
if (record == null || CheckUtil.isEmpty(record.getEc_apply_id())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QueryWrapper<LklLedgerEc> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("ec_apply_id", record.getEc_apply_id());
|
||||
queryWrapper.eq("ec_apply_id", record.getEc_apply_id()).orderByDesc("id");
|
||||
|
||||
LklLedgerEc existsRecord = getOne(queryWrapper);
|
||||
LklLedgerEc existsRecord = findOne(queryWrapper);
|
||||
if (existsRecord == null) {
|
||||
return false;
|
||||
}
|
||||
@ -108,13 +91,13 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
|
||||
*/
|
||||
@Override
|
||||
public LklLedgerEc getByApplyId(Long applyId, String ecStatus, Integer status) {
|
||||
if (ObjectUtil.isEmpty(applyId)) {
|
||||
if (CheckUtil.isEmpty(applyId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
QueryWrapper<LklLedgerEc> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("ec_apply_id", applyId);
|
||||
if (ObjectUtil.isNotEmpty(status)) {
|
||||
if (CheckUtil.isNotEmpty(status)) {
|
||||
queryWrapper.eq("status", status);
|
||||
}
|
||||
|
||||
@ -142,12 +125,12 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
|
||||
}
|
||||
|
||||
QueryWrapper<LklLedgerEc> queryWrapper = new QueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(mchMobile)) {
|
||||
queryWrapper.eq("mch_mobile", mchMobile);
|
||||
if (CheckUtil.isNotEmpty(mchId)) {
|
||||
queryWrapper.eq("mch_id", mchId);
|
||||
}
|
||||
|
||||
if (mchId != null && mchId > 0) {
|
||||
queryWrapper.eq("mch_id", mchId);
|
||||
if (StrUtil.isNotBlank(mchMobile)) {
|
||||
queryWrapper.eq("mch_mobile", mchMobile);
|
||||
}
|
||||
|
||||
queryWrapper.orderByDesc("id");
|
||||
@ -155,16 +138,11 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
|
||||
queryWrapper.eq("status", status);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(ecStatus)) {
|
||||
if (StrUtil.isNotBlank(ecStatus)) {
|
||||
queryWrapper.eq("ec_status", ecStatus);
|
||||
}
|
||||
|
||||
List<LklLedgerEc> lklLedgerEcList = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(lklLedgerEcList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return lklLedgerEcList.get(0);
|
||||
return findOne(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2186,12 +2186,12 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家处理退货退款不退货(支持全单/部分商品退货)
|
||||
* 商家处理退货退款不退货(支持全单/部分商品退款)
|
||||
*
|
||||
* @param requestParams JSON参数包含:
|
||||
* - order_id: 订单ID (必填)
|
||||
* - order_return_vo: 退货商品信息 (可选)
|
||||
* - reason: 退货理由 (可选)
|
||||
* - order_return_vo: 退款商品信息 (可选)
|
||||
* - reason: 退款理由 (可选)
|
||||
* @return CommonResult 统一返回结果
|
||||
* @throws ApiException 仅当用户未登录时抛出
|
||||
*/
|
||||
@ -2217,8 +2217,14 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
return CommonResult.failed("订单不存在");
|
||||
}
|
||||
if (StateCode.ORDER_PAID_STATE_NO == orderInfo.getOrder_is_paid()) {
|
||||
return CommonResult.failed("订单未付款,无法退货");
|
||||
return CommonResult.failed("订单未付款,无法退款");
|
||||
}
|
||||
|
||||
// 发货之后,不能退款了
|
||||
if (StateCode.ORDER_STATE_SHIPPED <= orderInfo.getOrder_state_id()) {
|
||||
return CommonResult.failed("订单状态,无法退款");
|
||||
}
|
||||
|
||||
// 验证店铺权限
|
||||
if (orderInfo.getStore_id() != null
|
||||
&& !orderInfo.getStore_id().equals(Convert.toInt(currentUser.getStore_id()))) {
|
||||
@ -2259,7 +2265,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
}
|
||||
|
||||
String reason = StrUtil.isBlank(requestParams.getStr("reason")) ?
|
||||
(isPartialRefund ? "商家部分商品退货" : "商家整单退货") :
|
||||
(isPartialRefund ? "商家部分商品退款" : "商家整单退款") :
|
||||
requestParams.getStr("reason");
|
||||
|
||||
// === 5. 创建退货单(如不存在) ===
|
||||
|
||||
@ -283,4 +283,14 @@ public interface ShopMchEntryService {
|
||||
* @return
|
||||
*/
|
||||
Boolean checkMchEntryStoreStatus(Integer storeId);
|
||||
|
||||
/**
|
||||
* 更新商户入驻签约状态和合同下载URL
|
||||
* 处理逻辑:
|
||||
* 1. 当商户已签约但未获取合同文件时,同步最新签约状态和合同URL
|
||||
* 2. 支持两种签约方式:E签宝(注释保留)和拉卡拉(当前实现)
|
||||
*
|
||||
* @param record 商户入驻记录
|
||||
*/
|
||||
void updateMerchEntrySignedStatusAndContractDownloadUrl(ShopMchEntry record);
|
||||
}
|
||||
@ -20,8 +20,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.modules.lakala.LklLedgerEc;
|
||||
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
||||
import com.suisung.mall.common.utils.BankUtil;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.DateTimeUtils;
|
||||
import com.suisung.mall.common.utils.StringUtils;
|
||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||
@ -32,8 +34,8 @@ 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.LklLedgerEcService;
|
||||
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;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||
@ -42,6 +44,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -82,7 +85,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private LklTkServiceImpl lklTkService;
|
||||
private LklLedgerEcService lklLedgerEcService;
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@ -558,32 +561,70 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
return CommonResult.success(record);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 试试更新入驻表的合同下载地址和合同签署状态
|
||||
* 更新商户入驻签约状态和合同下载URL
|
||||
* 处理逻辑:
|
||||
* 1. 当商户已签约但未获取合同文件时,同步最新签约状态和合同URL
|
||||
* 2. 支持两种签约方式:E签宝(注释保留)和拉卡拉(当前实现)
|
||||
*
|
||||
* @param record
|
||||
* @param record 商户入驻记录
|
||||
*/
|
||||
private void updateMerchEntrySignedStatusAndContractDownloadUrl(ShopMchEntry record) {
|
||||
if (record == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CommonConstant.MCH_APPR_STA_PASS.equals(record.getApproval_status())
|
||||
&& (StrUtil.isBlank(record.getContract_download_url()) || !CommonConstant.CONTRACT_SIGN_STA_FINISH.equals(record.getSigned_status()))) {
|
||||
// 审核通过的,但是没有合同文件的情况,要进一步同步状态和合同文件
|
||||
Pair<Integer, String> contractInfo = esignContractService.checkSignFlowStatus(record.getLogin_mobile());
|
||||
if (contractInfo != null) {
|
||||
record.setSigned_status(contractInfo.getFirst());
|
||||
record.setContract_download_url(contractInfo.getSecond());
|
||||
|
||||
// 更改同步合同审核状态和合同下载地址
|
||||
taskService.executeTask(() -> {
|
||||
log.debug("###更改同步合同审核状态和下载地址###");
|
||||
if (!updateMerchEntrySignedStatusAndContractDownloadUrl(record.getLogin_mobile(), record.getSigned_status(), record.getContract_download_url())) {
|
||||
log.error("###更改同步合同审核状态和下载地址失败###");
|
||||
}
|
||||
});
|
||||
@Async("asyncExecutor")
|
||||
@Override
|
||||
public void updateMerchEntrySignedStatusAndContractDownloadUrl(ShopMchEntry record) {
|
||||
try {
|
||||
// === 参数校验 ===
|
||||
if (record == null || CheckUtil.isEmpty(record.getId())) {
|
||||
log.warn("商户入驻记录为空或ID为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 这是E签宝的逻辑
|
||||
// if (CommonConstant.MCH_APPR_STA_PASS.equals(record.getApproval_status())
|
||||
// && (StrUtil.isBlank(record.getContract_download_url()) || !CommonConstant.CONTRACT_SIGN_STA_FINISH.equals(record.getSigned_status()))) {
|
||||
// // 审核通过的,但是没有合同文件的情况,要进一步同步状态和合同文件
|
||||
// Pair<Integer, String> contractInfo = esignContractService.checkSignFlowStatus(record.getLogin_mobile());
|
||||
// if (contractInfo != null) {
|
||||
// record.setSigned_status(contractInfo.getFirst());
|
||||
// record.setContract_download_url(contractInfo.getSecond());
|
||||
//
|
||||
// // 更改同步合同审核状态和合同下载地址
|
||||
// taskService.executeTask(() -> {
|
||||
// log.debug("###更改同步合同审核状态和下载地址###");
|
||||
// if (!updateMerchEntrySignedStatusAndContractDownloadUrl(record.getLogin_mobile(), record.getSigned_status(), record.getContract_download_url())) {
|
||||
// log.error("###更改同步合同审核状态和下载地址失败###");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// === 拉卡拉签约逻辑 ===
|
||||
|
||||
if (CommonConstant.Enable.equals(record.getHas_ec_signed())) {
|
||||
LklLedgerEc ec = lklLedgerEcService.getByMchMobile(
|
||||
record.getId(),
|
||||
"",
|
||||
"COMPLETED",
|
||||
CommonConstant.Enable
|
||||
);
|
||||
|
||||
if (ec != null && StrUtil.isNotBlank(ec.getEc_file())) {
|
||||
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", record.getId())
|
||||
.set("signed_status", CommonConstant.Enable)
|
||||
.set("contract_download_url", ec.getEc_file());
|
||||
|
||||
if (!update(updateWrapper)) {
|
||||
log.error("更新商户签约状态失败, recordId:{}", record.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("更新商户签约状态异常, recordId:{}, error:{}",
|
||||
record != null ? record.getId() : "null",
|
||||
e.getMessage(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -793,14 +834,9 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
queryWrapper.eq("login_mobile", loginMobile)
|
||||
.orderByAsc("id");
|
||||
|
||||
List<ShopMchEntry> recordList = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(recordList)) {
|
||||
return null;
|
||||
}
|
||||
ShopMchEntry record = findOne(queryWrapper);
|
||||
|
||||
ShopMchEntry record = recordList.get(0);
|
||||
|
||||
// 试试更新入驻表的合同下载地址和合同签署状态
|
||||
// 试试更新入驻表的合同下载地址和合同签署状态(E 签宝)
|
||||
updateMerchEntrySignedStatusAndContractDownloadUrl(record);
|
||||
|
||||
return record;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user