Commit 7ae85dbf by zhouhaibao

feat(service): 添加精品升级场景商户服务开通日期更新功能

- 新增 ServiceMerchantMapper 接口用于操作商户服务数据
- 在 StoreAppRulePublishService 中注入 ServiceMerchantMapper 依赖
- 添加 updateServiceMerchantOpenDate 方法更新商户服务开通日期
- 添加 getBaseByMerchantId 方法根据商户ID查询基础信息
- 实现精品升级场景下商户服务开通日期的自动更新逻辑
- 集成事务管理确保数据一致性
1 parent 715c2a63
package cn.com.glsx.dj.oaapproval.mapper.old;
import cn.com.glsx.dj.smartcarlife.model.ServiceMerchant;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface ServiceMerchantMapper extends OreMapper<ServiceMerchant> {
}
...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.oaapproval.mapper.StoreApproveSceneMapper; ...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.oaapproval.mapper.StoreApproveSceneMapper;
import cn.com.glsx.dj.oaapproval.mapper.StoreCreateBusinessApproveMapper; import cn.com.glsx.dj.oaapproval.mapper.StoreCreateBusinessApproveMapper;
import cn.com.glsx.dj.oaapproval.mapper.old.*; import cn.com.glsx.dj.oaapproval.mapper.old.*;
import cn.com.glsx.dj.oaapproval.model.store.*; import cn.com.glsx.dj.oaapproval.model.store.*;
import cn.com.glsx.dj.smartcarlife.constant.CommonConstants;
import cn.com.glsx.dj.smartcarlife.dto.ExpenseCategoryDTO; import cn.com.glsx.dj.smartcarlife.dto.ExpenseCategoryDTO;
import cn.com.glsx.dj.smartcarlife.enums.*; import cn.com.glsx.dj.smartcarlife.enums.*;
import cn.com.glsx.dj.smartcarlife.model.*; import cn.com.glsx.dj.smartcarlife.model.*;
...@@ -104,6 +105,9 @@ public class StoreAppRulePublishService { ...@@ -104,6 +105,9 @@ public class StoreAppRulePublishService {
@Autowired @Autowired
private SmartcarSceneMerchantRefNewMapper smartcarSceneMerchantRefNewMapper; private SmartcarSceneMerchantRefNewMapper smartcarSceneMerchantRefNewMapper;
@Autowired
private ServiceMerchantMapper serviceMerchantMapper;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public void publishApprovedData(String businessCode, String updatedBy,Date now) { public void publishApprovedData(String businessCode, String updatedBy,Date now) {
RpcAssert.assertNotEmpty(businessCode, DefaultErrorEnum.DATA_NULL, "businessCode is null"); RpcAssert.assertNotEmpty(businessCode, DefaultErrorEnum.DATA_NULL, "businessCode is null");
...@@ -987,6 +991,36 @@ public class StoreAppRulePublishService { ...@@ -987,6 +991,36 @@ public class StoreAppRulePublishService {
List<Integer> mainMerchantIdList = context.merchantRefs.stream() List<Integer> mainMerchantIdList = context.merchantRefs.stream()
.map(StoreAppMerchantRef::getMerchantId).collect(Collectors.toList()); .map(StoreAppMerchantRef::getMerchantId).collect(Collectors.toList());
smartcarSceneMerchantRefNewMapper.updateOprTime(mainMerchantIdList, context.updatedBy, context.baseSceneCode); smartcarSceneMerchantRefNewMapper.updateOprTime(mainMerchantIdList, context.updatedBy, context.baseSceneCode);
// 如果是精品升级场景,需要更新精品升级场景的字段
if(context.baseSceneCode != null && context.baseSceneCode.equals(BaseSceneEnum.QUALITY_UPGRADE.getBaseSceneCode())){
for (Integer merchantId: mainMerchantIdList) {
updateServiceMerchantOpenDate(merchantId, new Date());
}
}
}
@Transactional(propagation= Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public void updateServiceMerchantOpenDate(Integer merchantId, Date openDate){
ServiceMerchant sm = getBaseByMerchantId(merchantId);
if(sm != null && sm.getOpenDate() == null) {
ServiceMerchant updatedRecord = ServiceMerchant.builder().id(sm.getId()).openDate(openDate)
.updatedDate(new Date()).updatedBy(CommonConstants.DEFAULT_UPDATE_BY).build();
serviceMerchantMapper.updateByPrimaryKeySelective(updatedRecord);
}
}
@Transactional(propagation= Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public ServiceMerchant getBaseByMerchantId(Integer merchantId){
RpcAssert.assertNotNull(merchantId, DefaultErrorEnum.DATA_NULL,"merchantId not be null");
try{
ServiceMerchant condition = new ServiceMerchant();
condition.setMerchantId(merchantId);
condition.setDeletedFlag(DeletedFlagEnum.N.name());
return serviceMerchantMapper.selectOne(condition);
}catch(Exception e){
log.info(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR,e.getMessage());
}
} }
private MerchantTarget resolveDistributionTarget(StoreAppMerchantRef merchantRef, StoreAppDistributionRule distribution,ApprovalPublishContext context) { private MerchantTarget resolveDistributionTarget(StoreAppMerchantRef merchantRef, StoreAppDistributionRule distribution,ApprovalPublishContext context) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!