内部运费的优化,增加店铺可以设置内部运费。

This commit is contained in:
Jack 2025-11-01 11:00:39 +08:00
parent fd88f45625
commit 60c4df7625
14 changed files with 181 additions and 41 deletions

View File

@ -126,10 +126,5 @@ public class CommonConstant {
public static final Integer Order_Booking_State_YY = 2;
// 预约下单从当前时间延迟的最小分钟数单位分钟不能低于35分钟
public final static Integer MIN_DELAY_MINUTES_FOR_BOOKING_ORDER = 46;
// 预约订单创建提前分钟数用于提前创建顺丰订单
// public final static Integer MIN_DELAY_MINUTES_FOR_SF_EXPRESS_ORDER = 35;
public final static Integer MIN_DELAY_MINUTES_FOR_BOOKING_ORDER = 50;
}

View File

@ -326,5 +326,16 @@ public interface ShopService {
BigDecimal getOrderShippingFee(@RequestParam(name = "order_id") String order_id);
/**
* 获取店铺的内部运费 shopping_fee_inner 远程调用用途
*
* @param store_id
* @return
*/
@ApiOperation(value = "获取店铺的内部运费 shopping_fee_inner", notes = "获取店铺的内部运费 shopping_fee_inner (远程调用用途)")
@RequestMapping(value = "/admin/shop/shop-store-info/shopping-fee-inner", method = RequestMethod.POST)
Integer storeShoppingFeeInner(@RequestParam(name = "store_id") Integer store_id);
}

View File

@ -48,10 +48,11 @@ public interface AccountBaseConfigService extends IBaseService<AccountBaseConfig
String getSystemConfig(String configKey);
/**
* 获取平台内部最低配送费单位
* 获取店铺或平台内部最低配送费单位
*
* @return
* @param storeId 店铺Id
* @return 配送费单位分
*/
Integer getInnerMinDeliveryFee();
Integer getInnerMinDeliveryFee(Integer storeId);
}

View File

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suisung.mall.common.constant.CommonConstant;
import com.suisung.mall.common.constant.RedisConstant;
import com.suisung.mall.common.feignService.AccountService;
import com.suisung.mall.common.feignService.ShopService;
import com.suisung.mall.common.modules.account.AccountBaseConfig;
import com.suisung.mall.common.modules.account.AccountUserInfo;
import com.suisung.mall.common.utils.CheckUtil;
@ -20,6 +21,7 @@ import com.suisung.mall.pay.service.AccountBaseConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -47,6 +49,11 @@ public class AccountBaseConfigServiceImpl extends BaseServiceImpl<AccountBaseCon
public static Long version = 0L;
@Autowired
private AccountService accountService;
@Lazy
@Autowired
private ShopService shopService;
@Autowired
private RedisService redisService;
@ -254,16 +261,41 @@ public class AccountBaseConfigServiceImpl extends BaseServiceImpl<AccountBaseCon
}
/**
* 获取平台内部最低配送费单位
* 获取店铺或平台内部最低配送费单位
*
* @return
* @param storeId 店铺Id
* @return 配送费单位分
*/
@Override
public Integer getInnerMinDeliveryFee() {
String v = getSystemConfig(CommonConstant.Inner_Min_DeliveryFee_Key);
return NumberUtil.isNumber(v) ? Convert.toInt(v) : 0;
public Integer getInnerMinDeliveryFee(Integer storeId) {
// 如果storeId无效直接使用平台默认配置
if (storeId == null || storeId <= 0) {
return getDefaultMinDeliveryFee();
}
// 获取店铺内部运费
Integer storeFee = shopService.storeShoppingFeeInner(storeId);
// 如果店铺未设置有效运费则使用平台默认配置
if (storeFee == null || storeFee <= 0) {
return getDefaultMinDeliveryFee();
}
return storeFee;
}
/**
* 获取平台默认最低配送费
*
* @return 默认配送费单位分
*/
private Integer getDefaultMinDeliveryFee() {
String configValue = getSystemConfig(CommonConstant.Inner_Min_DeliveryFee_Key);
int fee = NumberUtil.isNumber(configValue) ? Convert.toInt(configValue) : 0;
return fee > 0 ? fee : 0;
}
/**
* 交易模式 2直接交易:商家直接收款 1担保交易平台收款平台和商家结算
*/

View File

@ -251,8 +251,8 @@ public class LakalaPayServiceImpl implements LakalaPayService {
}
// 平台最低配送费单位
Integer innerMinDeliverFee = accountBaseConfigService.getInnerMinDeliveryFee();
reqData.set("shopping_fee_inner", innerMinDeliverFee); // 平台内部最低配送费单位
Integer innerMinDeliverFee = accountBaseConfigService.getInnerMinDeliveryFee(Convert.toInt(storeId));
reqData.set("shopping_fee_inner", innerMinDeliverFee); // 重要平台内部最低配送费单位
log.info("[拉卡拉预下单] 支付成功,准备保存订单记录, orderId={}", orderId);
// 新增一个拉卡拉订单记录 shop_order_lkl
@ -280,7 +280,7 @@ public class LakalaPayServiceImpl implements LakalaPayService {
/**
* 拉卡拉合单预下单主要有运费的订单使用合单
* 暂时废弃拉卡拉合单预下单主要有运费的订单使用合单
* 参考https://o.lakala.com/#/home/document/detail?id=208
*
* @param merchantNo 商户号(商城商家)
@ -299,6 +299,7 @@ public class LakalaPayServiceImpl implements LakalaPayService {
* @param remark 备注
* @return 拉卡拉合单预下单响应结果
**/
@Deprecated
@Override
public JSONObject lklTransMergePreOrder(String merchantNo, String termNo, String agentMerchantNo, String agentTermNo, String xcxAppId, String openId, String storeId, String orderId, String subject, String totalAmount, String agentAmount, String notifyURL, String requestIP, String remark) {
log.info("[拉卡拉合单预下单] 开始处理请求, merchantNo={}, termNo={}, agentMerchantNo={}, agentTermNo={}, orderId={}",
@ -558,7 +559,7 @@ public class LakalaPayServiceImpl implements LakalaPayService {
log.warn("[拉卡拉退款] 退款金额不合法: refundAmount={}", refundAmount);
return Pair.of(false, I18nUtil._("退款金额不合法!"));
}
if (StrUtil.hasBlank(lklMerchantNo, lklTermNo)) {
// 4. 获取店铺的拉卡拉商户号和终端号
ShopStoreBase shopStoreBase = shopService.getLklMerchantNoAndTermNo(storeId);

View File

@ -671,15 +671,14 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
String requestIP = IpKit.getRealIp(request);
String notifyUrl = domain + "/lkl_wxPay_notify_url";
String storeIdStr = Convert.toStr(storeId);// 店铺Id
BigDecimal shippingFee = shopService.getOrderShippingFee(out_trade_no);
if (shippingFee == null || shippingFee.intValue() <= 0) {
shippingFee = BigDecimal.ZERO;
}
// 平台最低配送费单位
Integer innerMinDeliverFee = accountBaseConfigService.getInnerMinDeliveryFee();
Integer innerMinDeliverFee = accountBaseConfigService.getInnerMinDeliveryFee(storeId);
logger.debug("预支付时,查到的订单{},商家配送费:{}元,平台最低配送费要求:{}分", out_trade_no, shippingFee, innerMinDeliverFee);
// 平台最低配送费单位
@ -687,7 +686,7 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
// 内部运费统一由分账接收方收取了 2025-10-11
// 拉卡拉预支付返回参数
// TODO 判断订单有没有运费有运费请求合单交易没有运费请求聚合主扫交易
// 聚合主扫交易
cn.hutool.json.JSONObject lakalaRespJSON = lakalaPayService.lklTransPreOrder(shopStoreBase.getLkl_merchant_no(), shopStoreBase.getLkl_term_no(),
appId, openId, storeIdStr, out_trade_no, subject, total_amt,
notifyUrl,

View File

@ -60,9 +60,10 @@ public interface AccountBaseConfigService extends IBaseService<AccountBaseConfig
String getSystemConfig(String configKey);
/**
* 获取平台内部最低配送费单位
* 获取店铺或平台内部最低配送费单位
*
* @return
* @param storeId 店铺Id
* @return 配送费单位分
*/
Integer getInnerMinDeliveryFee();
Integer getInnerMinDeliveryFee(Integer storeId);
}

View File

@ -22,9 +22,11 @@ import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.base.mapper.AccountBaseConfigMapper;
import com.suisung.mall.shop.base.service.AccountBaseConfigService;
import com.suisung.mall.shop.config.CookieUtil;
import com.suisung.mall.shop.store.service.ShopStoreInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -51,6 +53,11 @@ public class AccountBaseConfigServiceImpl extends BaseServiceImpl<AccountBaseCon
public static Long version = 0L;
@Autowired
private AccountService accountService;
@Lazy
@Autowired
private ShopStoreInfoService shopStoreInfoService;
@Autowired
private RedisService redisService;
@ -369,14 +376,38 @@ public class AccountBaseConfigServiceImpl extends BaseServiceImpl<AccountBaseCon
}
/**
* 获取平台内部最低配送费单位
* 获取店铺或平台内部最低配送费单位
*
* @return
* @param storeId 店铺Id
* @return 配送费单位分
*/
@Override
public Integer getInnerMinDeliveryFee() {
String v = getSystemConfig(CommonConstant.Inner_Min_DeliveryFee_Key);
return NumberUtil.isNumber(v) ? Convert.toInt(v) : 0;
public Integer getInnerMinDeliveryFee(Integer storeId) {
// 如果storeId无效直接使用平台默认配置
if (storeId == null || storeId <= 0) {
return getDefaultMinDeliveryFee();
}
// 获取店铺内部运费
Integer storeFee = shopStoreInfoService.getStoreShippingFeeInner(storeId);
// 如果店铺未设置有效运费则使用平台默认配置
if (storeFee == null || storeFee <= 0) {
return getDefaultMinDeliveryFee();
}
return storeFee;
}
/**
* 获取平台默认最低配送费
*
* @return 默认配送费单位分
*/
private Integer getDefaultMinDeliveryFee() {
String configValue = getSystemConfig(CommonConstant.Inner_Min_DeliveryFee_Key);
int fee = NumberUtil.isNumber(configValue) ? Convert.toInt(configValue) : 0;
return fee > 0 ? fee : 0;
}

View File

@ -7763,7 +7763,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
data_row.setPacking_fee(packingFee);
// 平台最低配送费单位
Integer innerMinDeliverFee = accountBaseConfigService.getInnerMinDeliveryFee();
Integer innerMinDeliverFee = accountBaseConfigService.getInnerMinDeliveryFee(store_id);
// 平台最低配送费单位
BigDecimal shoppingFeeInner = Convert.toBigDecimal(innerMinDeliverFee).divide(BigDecimal.valueOf(100));

View File

@ -248,6 +248,4 @@ public class ShopOrderBookingServiceImpl extends BaseServiceImpl<ShopOrderBookin
return count;
}
}

View File

@ -79,5 +79,18 @@ public class ShopStoreInfoController extends BaseControllerImpl {
return CommonResult.success(shopStoreInfoService.remove(store_id));
}
/**
* 获取店铺的内部运费 shopping_fee_inner 远程调用用途
*
* @param store_id
* @return
*/
@ApiOperation(value = "获取店铺的内部运费 shopping_fee_inner", notes = "获取店铺的内部运费 shopping_fee_inner (远程调用用途)")
@RequestMapping(value = "/shopping-fee-inner", method = RequestMethod.POST)
public Integer storeShoppingFeeInner(@RequestParam(name = "store_id") Integer store_id) {
return shopStoreInfoService.getStoreShippingFeeInner(store_id);
}
}

View File

@ -38,4 +38,13 @@ public interface ShopStoreInfoService extends IBaseService<ShopStoreInfo> {
*/
List<String> getStoreKeeperMobile(Integer storeId);
/**
* 获取店铺的内部运费 shopping_fee_inner
* <p>
* 店铺内部运费单位0-使用平台的内部运费>0 使用店铺的内部运费
*
* @param storeId
* @return
*/
Integer getStoreShippingFeeInner(Integer storeId);
}

View File

@ -8,19 +8,18 @@ import com.suisung.mall.common.feignService.AccountService;
import com.suisung.mall.common.modules.account.AccountUserBase;
import com.suisung.mall.common.modules.store.ShopStoreAnalytics;
import com.suisung.mall.common.modules.store.ShopStoreInfo;
import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.store.mapper.ShopStoreInfoMapper;
import com.suisung.mall.shop.store.service.ShopStoreAnalyticsService;
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
import com.suisung.mall.shop.store.service.ShopStoreInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
@ -32,6 +31,7 @@ import java.util.stream.Collectors;
* @author Xinze
* @since 2021-06-16
*/
@Slf4j
@Service
public class ShopStoreInfoServiceImpl extends BaseServiceImpl<ShopStoreInfoMapper, ShopStoreInfo> implements ShopStoreInfoService {
@ -101,15 +101,64 @@ public class ShopStoreInfoServiceImpl extends BaseServiceImpl<ShopStoreInfoMappe
/**
* 获取店长的手机号码
*
* @param storeId
* @return
* @param storeId 店铺ID
* @return 手机号码列表如果未找到则返回null
*/
@Override
public List<String> getStoreKeeperMobile(Integer storeId) {
// 参数校验
if (storeId == null) {
return null;
}
QueryWrapper<ShopStoreInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", storeId).select("store_tel");
return null;
List<ShopStoreInfo> list = find(queryWrapper);
// 空值检查优化
if (list == null || list.isEmpty()) {
return null;
}
// 使用方法引用简化代码
return list.stream()
.map(ShopStoreInfo::getStore_tel)
.filter(Objects::nonNull) // 过滤掉null值
.collect(Collectors.toList());
}
/**
* 获取店铺的内部运费 shopping_fee_inner
* <p>
* 店铺内部运费单位0-使用平台的内部运费>0 使用店铺的内部运费
*
* @param storeId 店铺ID
* @return 内部运费单位分
*/
@Override
public Integer getStoreShippingFeeInner(Integer storeId) {
// 参数校验
if (storeId == null) {
return 0;
}
try {
QueryWrapper<ShopStoreInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", storeId).select("shopping_fee_inner");
ShopStoreInfo shopStoreInfo = getOne(queryWrapper);
if (shopStoreInfo == null || CheckUtil.isEmpty(shopStoreInfo.getShopping_fee_inner())) {
return 0;
}
return shopStoreInfo.getShopping_fee_inner();
} catch (Exception e) {
// 记录日志或打印错误信息
log.error("获取店铺内部运费失败storeId: {}", storeId, e);
// 返回默认值避免影响主流程
return 0;
}
}
}

View File

@ -2670,7 +2670,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
}
// RMK 平台最低配送费单位add:2025-09-26
Integer innerMinDeliverFee = accountBaseConfigService.getInnerMinDeliveryFee();
Integer innerMinDeliverFee = accountBaseConfigService.getInnerMinDeliveryFee(Convert.toInt(storeId));
if (canThrow
&& CheckUtil.isNotEmpty(innerMinDeliverFee)
&& CheckUtil.isNotEmpty(orderSelMoneyAmount)