平台内部配送费的逻辑新增。细节调整默认值

This commit is contained in:
Jack 2025-12-12 14:17:11 +08:00
parent 3fbccbfd31
commit 390eca8b63
4 changed files with 99 additions and 35 deletions

View File

@ -22,13 +22,21 @@ public interface ShopStoreSameCityTransportService {
*/ */
CommonResult deleteShopStoreSameCityTransport(Long transportId); CommonResult deleteShopStoreSameCityTransport(Long transportId);
/**
* 根据店铺 Id 获取同城配送扩展设置列表
*
* @param storeId
* @return
*/
List<ShopStoreSameCityTransport> selectShopStoreSameCityTransportList(Long storeId);
/** /**
* 根据同城配送基础配置自增 Id 获取同城配送扩展设置列表 * 根据同城配送基础配置自增 Id 获取同城配送扩展设置列表
* *
* @param transportBaseId * @param transportBaseId
* @return * @return
*/ */
List<ShopStoreSameCityTransport> selectShopStoreSameCityTransportList(Long transportBaseId); List<ShopStoreSameCityTransport> selectShopStoreSameCityTransportListByTransportBaseId(Long transportBaseId);
/** /**
* 保存同城配送扩展设置列表存在就更新不存在就新增 * 保存同城配送扩展设置列表存在就更新不存在就新增

View File

@ -282,60 +282,93 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
/** /**
* 根据店铺 Id 获取同城配送设置详情信息 * 根据店铺 Id 获取同城配送设置详情信息
* *
* @param storeId * @param storeId 店铺ID
* @param isPlatform * @param isPlatform 是否平台操作标识
* @return * @return 同城配送设置详情DTO
*/ */
@Override @Override
public ShopStoreSameCityTransportBaseDTO getShopStoreSameCityTransportBaseDTOById(Long storeId, Integer isPlatform) { public ShopStoreSameCityTransportBaseDTO getShopStoreSameCityTransportBaseDTOById(Long storeId, Integer isPlatform) {
// 参数校验
if (storeId == null || storeId <= 0) { if (storeId == null || storeId <= 0) {
logger.warn("获取同城配送设置详情失败店铺ID无效storeId={}", storeId);
return null; return null;
} }
// 店铺基本信息 // 获取店铺基本信息
ShopStoreBase shopStoreBase = shopStoreBaseService.getShopStoreBaseByStoreId(storeId.intValue()); ShopStoreBase shopStoreBase = shopStoreBaseService.getShopStoreBaseByStoreId(storeId.intValue());
if (shopStoreBase == null) { if (shopStoreBase == null) {
logger.warn("获取同城配送设置详情失败店铺基本信息不存在storeId={}", storeId);
return null; return null;
} }
// 获取同城配送基础设置记录
ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(storeId, isPlatform); ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(storeId, isPlatform);
// 如果未找到对应记录则根据不同角色处理
if (transportBase == null) { if (transportBase == null) {
transportBase = new ShopStoreSameCityTransportBase(); if (isPlatform == CommonConstant.Enable) {
transportBase.setStore_id(storeId); // 平台用户尝试从商家店铺配送设置中获取记录
transportBase = getShopStoreSameCityTransportBaseById(storeId, CommonConstant.Disable2);
if (transportBase == null) {
logger.warn("获取同城配送设置详情失败平台和商家配送设置均不存在storeId={}", storeId);
return null;
} else {
// 复用商家设置但需要重置平台相关字段
transportBase.setIs_platform(CommonConstant.Disable);
transportBase.setTransport_base_id(null);
transportBase.setStore_id(storeId);
logger.debug("平台用户复用商家配送设置storeId={}", storeId);
}
} else {
// 商家用户创建默认配送设置
transportBase = new ShopStoreSameCityTransportBase();
transportBase.setStore_id(storeId);
transportBase.setIs_platform(isPlatform);
transportBase.setIs_platform(isPlatform); // 设置默认值
// 没有记录时指定默认值 transportBase.setArea_type(1);
transportBase.setArea_type(1); transportBase.setBasis(1);
transportBase.setBasis(1); transportBase.setDistance_base(5);
transportBase.setDistance_base(5); transportBase.setWeight_base(5);
transportBase.setWeight_base(5); transportBase.setDelivery_base_fee(BigDecimal.valueOf(5));
transportBase.setDelivery_base_fee(BigDecimal.valueOf(5)); transportBase.setDistance_increase_km(1);
transportBase.setDistance_increase_km(1); transportBase.setDistance_increase_fee(BigDecimal.valueOf(1));
transportBase.setDistance_increase_fee(BigDecimal.valueOf(1)); transportBase.setWeight_increase_kg(1);
transportBase.setWeight_increase_kg(1); transportBase.setWeight_increase_fee(BigDecimal.valueOf(1));
transportBase.setWeight_increase_fee(BigDecimal.valueOf(1)); transportBase.setStatus(CommonConstant.Enable);
transportBase.setStatus(CommonConstant.Enable);
Date now = new Date(); // 设置时间戳
transportBase.setCreated_at(now); Date now = new Date();
transportBase.setUpdated_at(transportBase.getCreated_at()); transportBase.setCreated_at(now);
transportBase.setUpdated_at(now);
// shop_store_base 表获取店铺的地址和经纬度 // 从店铺基本信息中获取地址和经纬度
transportBase.setStore_address(StrUtil.removeAll(shopStoreBase.getStore_area(), "/") + shopStoreBase.getStore_address()); transportBase.setStore_address(StrUtil.removeAll(shopStoreBase.getStore_area(), "/") + shopStoreBase.getStore_address());
transportBase.setStore_longitude(shopStoreBase.getStore_longitude()); transportBase.setStore_longitude(shopStoreBase.getStore_longitude());
transportBase.setStore_latitude(shopStoreBase.getStore_latitude()); transportBase.setStore_latitude(shopStoreBase.getStore_latitude());
logger.debug("为商家创建默认配送设置storeId={}", storeId);
}
} }
// 构造返回DTO
ShopStoreSameCityTransportBaseDTO shopStoreSameCityTransportBaseDTO = new ShopStoreSameCityTransportBaseDTO(); ShopStoreSameCityTransportBaseDTO shopStoreSameCityTransportBaseDTO = new ShopStoreSameCityTransportBaseDTO();
shopStoreSameCityTransportBaseDTO.setTransportBase(transportBase); shopStoreSameCityTransportBaseDTO.setTransportBase(transportBase);
// 多个店铺同城快递运费设置起送条件+优惠条件 // 获取配送扩展设置列表
List<ShopStoreSameCityTransport> transportList = shopStoreSameCityTransportService.selectShopStoreSameCityTransportList(transportBase.getStore_id()); List<ShopStoreSameCityTransport> transportList;
if (CheckUtil.isEmpty(transportBase.getTransport_base_id())) {
transportList = shopStoreSameCityTransportService.selectShopStoreSameCityTransportList(transportBase.getStore_id());
} else {
transportList = shopStoreSameCityTransportService.selectShopStoreSameCityTransportListByTransportBaseId(transportBase.getTransport_base_id());
}
shopStoreSameCityTransportBaseDTO.setTransportList(transportList); shopStoreSameCityTransportBaseDTO.setTransportList(transportList);
logger.debug("成功获取店铺 {} 的同城配送设置详情", storeId);
return shopStoreSameCityTransportBaseDTO; return shopStoreSameCityTransportBaseDTO;
} }
/** /**
* 根据店铺Id获取同城配送基础运费记录 * 根据店铺Id获取同城配送基础运费记录
* *

View File

@ -62,6 +62,31 @@ public class ShopStoreSameCityTransportServiceImpl extends BaseServiceImpl<ShopS
return CommonResult.success(); return CommonResult.success();
} }
/**
* 根据同城配送基础配置自增 Id 获取同城配送扩展设置列表
*
* @param transportBaseId
* @return
*/
@Override
public List<ShopStoreSameCityTransport> selectShopStoreSameCityTransportListByTransportBaseId(Long transportBaseId) {
if (transportBaseId == null || transportBaseId <= 0) {
return Collections.emptyList();
}
QueryWrapper<ShopStoreSameCityTransport> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("transport_base_id", transportBaseId);
queryWrapper.eq("status", CommonConstant.Enable);
queryWrapper.orderByAsc("transport_id");
List<ShopStoreSameCityTransport> shopStoreSameCityTransportList = list(queryWrapper);
if (CollectionUtil.isEmpty(shopStoreSameCityTransportList)) {
shopStoreSameCityTransportList = Collections.emptyList();
}
return shopStoreSameCityTransportList;
}
/** /**
* 根据同城配送基础配置自增 Id 获取同城配送扩展设置列表 * 根据同城配送基础配置自增 Id 获取同城配送扩展设置列表
* *

12
pom.xml
View File

@ -539,11 +539,6 @@
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin> <plugin>
<groupId>com.spotify</groupId> <groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId> <artifactId>docker-maven-plugin</artifactId>
@ -571,7 +566,9 @@
<goal>build</goal> <goal>build</goal>
</goals> </goals>
</execution> </execution>
</executions>
</executions>
<configuration> <configuration>
<!--定义镜像名称--> <!--定义镜像名称-->
<imageName>${docker.registry}/mall/${project.artifactId}:${project.version}</imageName> <imageName>${docker.registry}/mall/${project.artifactId}:${project.version}</imageName>
@ -592,7 +589,7 @@
<forceTags>true</forceTags> <forceTags>true</forceTags>
<imageTags> <imageTags>
<imageTag>${project.version}</imageTag> <imageTag>${project.version}</imageTag>
<!-- <imageTag>latest</imageTag>--> <imageTag>latest</imageTag>
</imageTags> </imageTags>
<!--定义容器启动命令,注意不能换行--> <!--定义容器启动命令,注意不能换行-->
@ -609,6 +606,7 @@
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>