配送费调试日志添加
This commit is contained in:
parent
2bfe7c48dc
commit
0bd5e40487
@ -1047,14 +1047,17 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
|||||||
Pair<String, String> storeBizTimeRange = null;
|
Pair<String, String> storeBizTimeRange = null;
|
||||||
|
|
||||||
// 如果storeId不为空,则尝试获取店铺信息
|
// 如果storeId不为空,则尝试获取店铺信息
|
||||||
if (StrUtil.isNotBlank(storeIds)) {
|
if (StrUtil.isBlank(storeIds)) {
|
||||||
|
logger.info("[生成预约参数] 缺少店铺Id参数");
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
// 根据一个或多个店铺id获取有效店铺的有效营业时间段
|
// 根据一个或多个店铺id获取有效店铺的有效营业时间段
|
||||||
List<Pair<String, String>> storeBizTimeRangesList = selectMulStoreBizTimeRanges(storeIds);
|
List<Pair<String, String>> storeBizTimeRangesList = selectMulStoreBizTimeRanges(storeIds);
|
||||||
if (!CollUtil.isEmpty(storeBizTimeRangesList)) {
|
if (!CollUtil.isEmpty(storeBizTimeRangesList)) {
|
||||||
// 获取多个店铺的营业时间段的一个交集
|
// 获取多个店铺的营业时间段的一个交集
|
||||||
storeBizTimeRange = DateTimeUtils.findTimeInterSection(storeBizTimeRangesList);
|
storeBizTimeRange = DateTimeUtils.findTimeInterSection(storeBizTimeRangesList);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (storeBizTimeRange == null
|
if (storeBizTimeRange == null
|
||||||
|| StrUtil.isBlank(storeBizTimeRange.getFirst())
|
|| StrUtil.isBlank(storeBizTimeRange.getFirst())
|
||||||
|
|||||||
@ -1980,16 +1980,16 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
throw new ApiException(I18nUtil._("订单信息不存在!"));
|
throw new ApiException(I18nUtil._("订单信息不存在!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消订单,更改订单的状态为已取消
|
|
||||||
shopOrderBaseService.cancel(order_id, info_row, false);
|
|
||||||
logger.info("订单已取消:{}", order_id);
|
|
||||||
|
|
||||||
// 当前订单状态
|
// 当前订单状态
|
||||||
Integer order_state_id = info_row.getOrder_state_id();
|
Integer order_state_id = info_row.getOrder_state_id();
|
||||||
|
|
||||||
// 订单不是禁止退货(能退货)的情况下
|
// 订单不是禁止退货(能退货)的情况下
|
||||||
if (order_state_id != null && !isOrderDenyReturn(order_id)) {
|
if (order_state_id != null && !isOrderDenyReturn(order_id)) {
|
||||||
logger.info("处理运费和打包费事宜:{}", order_id);
|
// 取消订单,更改订单的状态为已取消
|
||||||
|
shopOrderBaseService.cancel(order_id, info_row, false);
|
||||||
|
logger.info("订单已取消:{}", order_id);
|
||||||
|
|
||||||
|
logger.info("处理运费和打包费逻辑:{}", order_id);
|
||||||
ShopOrderData order_data_row = shopOrderDataService.get(order_id);
|
ShopOrderData order_data_row = shopOrderDataService.get(order_id);
|
||||||
|
|
||||||
if (order_data_row != null) {
|
if (order_data_row != null) {
|
||||||
@ -2001,7 +2001,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
order_data_row.getPacking_fee().compareTo(BigDecimal.ZERO) > 0) {
|
order_data_row.getPacking_fee().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
additionalFees = additionalFees.add(order_data_row.getPacking_fee());
|
additionalFees = additionalFees.add(order_data_row.getPacking_fee());
|
||||||
feeTypes.add("打包费");
|
feeTypes.add("打包费");
|
||||||
logger.debug("添加打包费: {},订单ID: {}", order_data_row.getPacking_fee(), order_id);
|
logger.info("添加打包费: {},订单ID: {}", order_data_row.getPacking_fee(), order_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理配送费
|
// 处理配送费
|
||||||
@ -2009,9 +2009,11 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
order_data_row.getOrder_shipping_fee().compareTo(BigDecimal.ZERO) > 0) {
|
order_data_row.getOrder_shipping_fee().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
additionalFees = additionalFees.add(order_data_row.getOrder_shipping_fee());
|
additionalFees = additionalFees.add(order_data_row.getOrder_shipping_fee());
|
||||||
feeTypes.add("配送费");
|
feeTypes.add("配送费");
|
||||||
logger.debug("添加配送费: {},订单ID: {}", order_data_row.getOrder_shipping_fee(), order_id);
|
logger.info("添加配送费: {},订单ID: {}", order_data_row.getOrder_shipping_fee(), order_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("处理运费和打包费结果:{}, 金额:{}", order_id, additionalFees);
|
||||||
|
|
||||||
// 更新退款金额和说明
|
// 更新退款金额和说明
|
||||||
if (additionalFees.compareTo(BigDecimal.ZERO) > 0) {
|
if (additionalFees.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
BigDecimal newRefundAmount = return_row.getReturn_refund_amount().add(additionalFees);
|
BigDecimal newRefundAmount = return_row.getReturn_refund_amount().add(additionalFees);
|
||||||
@ -2031,7 +2033,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
logger.error("更新退货单退款金额失败!退货单ID: {}", return_row.getReturn_id());
|
logger.error("更新退货单退款金额失败!退货单ID: {}", return_row.getReturn_id());
|
||||||
throw new ApiException(ResultCode.FAILED);
|
throw new ApiException(ResultCode.FAILED);
|
||||||
}
|
}
|
||||||
logger.debug("成功更新退款金额,新增费用: {},总退款金额: {},订单ID: {}",
|
logger.info("成功更新退款金额,新增费用: {},总退款金额: {},订单ID: {}",
|
||||||
additionalFees, newRefundAmount, order_id);
|
additionalFees, newRefundAmount, order_id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2631,7 +2633,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
public boolean isOrderDenyReturn(String orderId) {
|
public boolean isOrderDenyReturn(String orderId) {
|
||||||
// 参数校验
|
// 参数校验
|
||||||
if (StrUtil.isBlank(orderId)) {
|
if (StrUtil.isBlank(orderId)) {
|
||||||
log.debug("[订单是否禁止退货] 订单ID为空,禁止退货,orderId: {}", orderId);
|
log.warn("[订单是否禁止退货] 订单ID为空,禁止退货,orderId: {}", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2639,25 +2641,25 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
// 获取订单信息
|
// 获取订单信息
|
||||||
ShopOrderInfo shopOrderInfo = shopOrderInfoService.get(orderId);
|
ShopOrderInfo shopOrderInfo = shopOrderInfoService.get(orderId);
|
||||||
if (shopOrderInfo == null) {
|
if (shopOrderInfo == null) {
|
||||||
log.debug("[订单是否禁止退货] 订单信息不存在,禁止退货,orderId: {}", orderId);
|
log.warn("[订单是否禁止退货] 订单信息不存在,禁止退货,orderId: {}", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查订单状态是否已收货或已完成
|
// 检查订单状态是否已收货或已完成
|
||||||
Integer orderStateId = shopOrderInfo.getOrder_state_id();
|
int orderStateId = shopOrderInfo.getOrder_state_id();
|
||||||
if (CheckUtil.isEmpty(orderStateId)) {
|
if (CheckUtil.isEmpty(orderStateId)) {
|
||||||
log.debug("[订单是否禁止退货] 订单状态为空,禁止退货,orderId: {}", orderId);
|
log.warn("[订单是否禁止退货] 订单状态为空,禁止退货,orderId: {}", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderStateId.intValue() == StateCode.ORDER_STATE_CANCEL ||
|
if (orderStateId == StateCode.ORDER_STATE_CANCEL ||
|
||||||
orderStateId.intValue() == StateCode.ORDER_STATE_WAIT_PAY) {
|
orderStateId == StateCode.ORDER_STATE_WAIT_PAY) {
|
||||||
log.debug("[订单是否禁止退货] 订单状态为已取消或未支付,禁止退货,orderId: {}, orderStateId: {}", orderId, orderStateId);
|
log.warn("[订单是否禁止退货] 订单状态为已取消或未支付,禁止退货,orderId: {}, orderStateId: {}", orderId, orderStateId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderStateId.intValue() == StateCode.ORDER_STATE_RECEIVED ||
|
if (orderStateId == StateCode.ORDER_STATE_RECEIVED ||
|
||||||
orderStateId.intValue() == StateCode.ORDER_STATE_FINISH) {
|
orderStateId == StateCode.ORDER_STATE_FINISH) {
|
||||||
|
|
||||||
// 获取可提现时间戳
|
// 获取可提现时间戳
|
||||||
Long withdrawTime = shopOrderBaseService.getWithdrawTime();
|
Long withdrawTime = shopOrderBaseService.getWithdrawTime();
|
||||||
@ -2665,7 +2667,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
|
|
||||||
// 如果订单成交时间早于可提现时间,说明已过退货期
|
// 如果订单成交时间早于可提现时间,说明已过退货期
|
||||||
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
||||||
log.debug("[订单是否禁止退货] 订单已超过退货期限,禁止退货,orderId: {}, orderDealTime: {}, withdrawTime: {}",
|
log.warn("[订单是否禁止退货] 订单已超过退货期限,禁止退货,orderId: {}, orderDealTime: {}, withdrawTime: {}",
|
||||||
orderId, orderDealTime, withdrawTime);
|
orderId, orderDealTime, withdrawTime);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2677,13 +2679,13 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
boolean isLklProcessed = isLklSeparated && isLklDrawed;
|
boolean isLklProcessed = isLklSeparated && isLklDrawed;
|
||||||
|
|
||||||
if (isLklProcessed) {
|
if (isLklProcessed) {
|
||||||
log.debug("[订单是否禁止退货] 拉卡拉分账订单已提现,禁止退货,orderId: {}, separated: {}, drawed: {}",
|
log.warn("[订单是否禁止退货] 拉卡拉分账订单已提现,禁止退货,orderId: {}, separated: {}, drawed: {}",
|
||||||
orderId, isLklSeparated, isLklDrawed);
|
orderId, isLklSeparated, isLklDrawed);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 允许退货
|
// 允许退货
|
||||||
log.debug("[订单是否禁止退货] 订单允许退货,orderId: {}", orderId);
|
log.warn("[订单是否禁止退货] 订单允许退货,orderId: {}", orderId);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -612,8 +612,12 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
// 2.如果能配送,再订单总重量,订单原价金额,订单折后金额,订单实付金额
|
// 2.如果能配送,再订单总重量,订单原价金额,订单折后金额,订单实付金额
|
||||||
// 3.根据两点经纬度,计算配送距离,结合订单总重量,计算基础运费。
|
// 3.根据两点经纬度,计算配送距离,结合订单总重量,计算基础运费。
|
||||||
// 4.查看是否有运费优惠设置,如果有,就直接从基础运费中扣除优惠运费,得出最终的订单配送费。
|
// 4.查看是否有运费优惠设置,如果有,就直接从基础运费中扣除优惠运费,得出最终的订单配送费。
|
||||||
|
|
||||||
|
String tip = isPlatform ? "平台同城配送费" : "商家同城配送费";
|
||||||
|
logger.info("开始计算{}。", tip);
|
||||||
|
|
||||||
if (storeId == null || orderLongitude == null || orderLatitude == null || storeId <= 0) {
|
if (storeId == null || orderLongitude == null || orderLatitude == null || storeId <= 0) {
|
||||||
logger.error("同城配送费计算时,缺少必要参数。");
|
logger.error("{}计算时,缺少必要参数。", tip);
|
||||||
if (canThrow) {
|
if (canThrow) {
|
||||||
throw new ApiException(I18nUtil._("同城配送缺少必要参数。"));
|
throw new ApiException(I18nUtil._("同城配送缺少必要参数。"));
|
||||||
}
|
}
|
||||||
@ -622,9 +626,9 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
|
|
||||||
ShopStoreBase storeBase = shopStoreBaseService.get(storeId);
|
ShopStoreBase storeBase = shopStoreBaseService.get(storeId);
|
||||||
if (storeBase == null) {
|
if (storeBase == null) {
|
||||||
logger.error("同城配送费计算时,缺少店铺基本信息。");
|
logger.error("{}计算时,缺少店铺基本信息。", tip);
|
||||||
if (canThrow) {
|
if (canThrow) {
|
||||||
throw new ApiException(I18nUtil._("同城配送缺少店铺基本信息。"));
|
throw new ApiException(tip + I18nUtil._("缺少店铺基本信息。"));
|
||||||
}
|
}
|
||||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "同城配送缺少店铺基本信息。");
|
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "同城配送缺少店铺基本信息。");
|
||||||
}
|
}
|
||||||
@ -633,7 +637,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
String storeLng = storeBase.getStore_longitude();
|
String storeLng = storeBase.getStore_longitude();
|
||||||
String storeLat = storeBase.getStore_latitude();
|
String storeLat = storeBase.getStore_latitude();
|
||||||
if (StrUtil.isBlank(storeLng) || StrUtil.isBlank(storeLat)) {
|
if (StrUtil.isBlank(storeLng) || StrUtil.isBlank(storeLat)) {
|
||||||
logger.error("{}同城配送费计算:店铺经纬度为空", storeName);
|
logger.error("{}{}计算:店铺经纬度为空", storeName, tip);
|
||||||
if (canThrow) {
|
if (canThrow) {
|
||||||
throw new ApiException(I18nUtil._("无法获取" + storeName + "的具体位置,请联系商家。"));
|
throw new ApiException(I18nUtil._("无法获取" + storeName + "的具体位置,请联系商家。"));
|
||||||
}
|
}
|
||||||
@ -642,7 +646,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
|
|
||||||
ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(storeId, isPlatform ? CommonConstant.Enable : CommonConstant.Disable2);
|
ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(storeId, isPlatform ? CommonConstant.Enable : CommonConstant.Disable2);
|
||||||
if (transportBase == null) {
|
if (transportBase == null) {
|
||||||
logger.error("{}同城配送费计算:无法获取基础运费设置记录。", storeName);
|
logger.error("{}{}计算:无法获取基础运费设置记录。", storeName, tip);
|
||||||
if (canThrow) {
|
if (canThrow) {
|
||||||
throw new ApiException(I18nUtil._("商家尚未完成同城配送设置。"));
|
throw new ApiException(I18nUtil._("商家尚未完成同城配送设置。"));
|
||||||
}
|
}
|
||||||
@ -666,7 +670,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
}
|
}
|
||||||
// 实际配送距离,单位米
|
// 实际配送距离,单位米
|
||||||
Integer distance = distanceD.intValue();
|
Integer distance = distanceD.intValue();
|
||||||
logger.debug(storeName + "下单时,店铺与收货地址经纬度是{},{},{},{} 距离为{}米。", storeLng, storeLat, orderLongitude, orderLatitude, distance);
|
logger.warn(storeName + "下单时,店铺与收货地址经纬度是{},{},{},{} 距离为{}米。", storeLng, storeLat, orderLongitude, orderLatitude, distance);
|
||||||
|
|
||||||
// ### 基础配送费计算
|
// ### 基础配送费计算
|
||||||
BigDecimal deliveryBaseFee = Convert.toBigDecimal(transportBase.getDelivery_base_fee(), BigDecimal.ZERO);
|
BigDecimal deliveryBaseFee = Convert.toBigDecimal(transportBase.getDelivery_base_fee(), BigDecimal.ZERO);
|
||||||
@ -676,8 +680,8 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
|
|
||||||
// 通过配送范围和起送金额,决定使用哪个配送费优惠规则
|
// 通过配送范围和起送金额,决定使用哪个配送费优惠规则
|
||||||
// 获取运费配送范围和优惠信息
|
// 获取运费配送范围和优惠信息
|
||||||
List<ShopStoreSameCityTransport> transportList = shopStoreSameCityTransportService.selectShopStoreSameCityTransportList(storeId);
|
// List<ShopStoreSameCityTransport> transportList = shopStoreSameCityTransportService.selectShopStoreSameCityTransportList(storeId);
|
||||||
|
List<ShopStoreSameCityTransport> transportList = shopStoreSameCityTransportService.selectShopStoreSameCityTransportListByTransportBaseId(transportBase.getTransport_base_id());
|
||||||
if (CollUtil.isEmpty(transportList)) {
|
if (CollUtil.isEmpty(transportList)) {
|
||||||
// 没有配送范围和起配金额规则的时候,直接以基础配送费来配送
|
// 没有配送范围和起配金额规则的时候,直接以基础配送费来配送
|
||||||
return new SameCityDeliveryFeeRespDTO(true, false, deliveryBaseFee, BigDecimal.ZERO, deliveryBaseFee, "");
|
return new SameCityDeliveryFeeRespDTO(true, false, deliveryBaseFee, BigDecimal.ZERO, deliveryBaseFee, "");
|
||||||
@ -690,7 +694,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
for (ShopStoreSameCityTransport transport : transportList) {
|
for (ShopStoreSameCityTransport transport : transportList) {
|
||||||
DeliveryFeeResultDTO deliveryFeeResultDTO = new DeliveryFeeResultDTO();
|
DeliveryFeeResultDTO deliveryFeeResultDTO = new DeliveryFeeResultDTO();
|
||||||
deliveryFeeResultDTO.setId(transport.getTransport_id());
|
deliveryFeeResultDTO.setId(transport.getTransport_id());
|
||||||
logger.debug(storeName + "下单时,配送范围/收货实际距离:{}/{}米。", transport.getMax_delivery_radius(), distance);
|
logger.warn(storeName + "下单时,配送范围/收货实际距离:{}/{}米。", transport.getMax_delivery_radius(), distance);
|
||||||
|
|
||||||
// 判断订单距离在不在配送范围内?
|
// 判断订单距离在不在配送范围内?
|
||||||
if (transport.getMax_delivery_radius() < distance) {
|
if (transport.getMax_delivery_radius() < distance) {
|
||||||
@ -767,8 +771,8 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(storeName + "下单时,根据商家运费设置规则减免{}元运费", reduceDeliveryFee);
|
logger.warn(storeName + "下单时,根据{}设置规则减免{}元运费", tip, reduceDeliveryFee);
|
||||||
logger.debug(storeName + "下单时,不符合规则的:\n {}\n符合规则的:{}", JSONUtil.toJsonStr(noPassed), JSONUtil.toJsonStr(passed));
|
logger.debug(storeName + "下单时,{}不符合规则的数据:\n {}\n符合规则的数据:{}", tip, JSONUtil.toJsonStr(noPassed), JSONUtil.toJsonStr(passed));
|
||||||
boolean canDelivery = true;
|
boolean canDelivery = true;
|
||||||
if (passed.size() == 0 && noPassed.size() > 0) {
|
if (passed.size() == 0 && noPassed.size() > 0) {
|
||||||
// 没有一个满足起送距离和起送金额的规则订单
|
// 没有一个满足起送距离和起送金额的规则订单
|
||||||
@ -827,7 +831,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deliveryBaseFee != null && deliveryBaseFee.compareTo(BigDecimal.ZERO) > 0) {
|
if (deliveryBaseFee != null && deliveryBaseFee.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
logger.debug(storeName + "下单时,超出基础距离、重量的额外配送费:{}元。", deliveryBaseFee);
|
logger.warn(storeName + "下单时,{}超出基础距离、重量的额外配送费:{}元。", tip, deliveryBaseFee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #### 额外配送费计算完毕
|
// #### 额外配送费计算完毕
|
||||||
@ -851,7 +855,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
public Integer computeSameCityInnerDeliveryFeeByOrderId(String orderId) {
|
public Integer computeSameCityInnerDeliveryFeeByOrderId(String orderId) {
|
||||||
// 参数校验
|
// 参数校验
|
||||||
if (orderId == null || orderId.trim().isEmpty()) {
|
if (orderId == null || orderId.trim().isEmpty()) {
|
||||||
logger.warn("计算同城配送费失败:订单ID不能为空");
|
logger.warn("计算平台同城配送费失败:订单ID不能为空");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,7 +864,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
|
|
||||||
// 检查返回结果是否为空
|
// 检查返回结果是否为空
|
||||||
if (orderCacDeliveryFeeArgs == null) {
|
if (orderCacDeliveryFeeArgs == null) {
|
||||||
logger.warn("计算同城配送费失败:未能获取订单[{}]的配送费计算参数", orderId);
|
logger.warn("计算平台同城配送费失败:未能获取订单[{}]的配送费计算参数", orderId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -893,167 +897,13 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
|||||||
if (sameCityDeliveryFeeRespDTO == null
|
if (sameCityDeliveryFeeRespDTO == null
|
||||||
|| sameCityDeliveryFeeRespDTO.getDeliveryFee() == null
|
|| sameCityDeliveryFeeRespDTO.getDeliveryFee() == null
|
||||||
|| sameCityDeliveryFeeRespDTO.getDeliveryFee().compareTo(BigDecimal.ZERO) <= 0) {
|
|| sameCityDeliveryFeeRespDTO.getDeliveryFee().compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
logger.warn("计算平台同城配送费失败:配送费计算结果为空");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.warn("计算平台同城配送费成功:{}", sameCityDeliveryFeeRespDTO);
|
||||||
|
|
||||||
return sameCityDeliveryFeeRespDTO.getDeliveryFee().multiply(new BigDecimal(100)).intValue();
|
return sameCityDeliveryFeeRespDTO.getDeliveryFee().multiply(new BigDecimal(100)).intValue();
|
||||||
|
|
||||||
// 参数校验
|
|
||||||
// if (storeId == null || orderLongitude == null || orderLatitude == null || storeId <= 0) {
|
|
||||||
// logger.warn("同城配送缺少必要参数,无法计算配送费。");
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 获取店铺基本信息
|
|
||||||
// ShopStoreBase storeBase = shopStoreBaseService.get(storeId);
|
|
||||||
// if (storeBase == null) {
|
|
||||||
// logger.warn("同城配送缺少店铺基本信息,无法计算配送费。");
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// String storeName = storeBase.getStore_name();
|
|
||||||
// String storeLng = storeBase.getStore_longitude();
|
|
||||||
// String storeLat = storeBase.getStore_latitude();
|
|
||||||
// if (StrUtil.isBlank(storeLng) || StrUtil.isBlank(storeLat)) {
|
|
||||||
// logger.warn("无法获取{}的具体位置,请联系商家。", storeName);
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 获取平台的基础运费设置记录
|
|
||||||
// ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(Convert.toLong(storeId), CommonConstant.Enable);
|
|
||||||
// if (transportBase == null) {
|
|
||||||
// logger.warn("商家{}尚未完成同城配送设置,无法计算配送费。", storeName);
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 设置默认值
|
|
||||||
// if (transportBase.getDistance_base() == null) {
|
|
||||||
// transportBase.setDistance_base(0);
|
|
||||||
// }
|
|
||||||
// if (transportBase.getWeight_base() == null) {
|
|
||||||
// transportBase.setWeight_base(0);
|
|
||||||
// }
|
|
||||||
// if (transportBase.getDelivery_base_fee() == null) {
|
|
||||||
// transportBase.setDelivery_base_fee(BigDecimal.ZERO);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 计算两点的距离(单位米)
|
|
||||||
// Double distanceD = PositionUtil.getDistance1(Convert.toDouble(storeLng), Convert.toDouble(storeLat), Convert.toDouble(orderLongitude), Convert.toDouble(orderLatitude));
|
|
||||||
// Integer distance = (distanceD != null) ? distanceD.intValue() : 0;
|
|
||||||
//
|
|
||||||
// // 基础配送费计算
|
|
||||||
// BigDecimal deliveryBaseFee = Convert.toBigDecimal(transportBase.getDelivery_base_fee(), BigDecimal.ZERO);
|
|
||||||
//
|
|
||||||
// // 获取运费配送范围信息
|
|
||||||
// List<ShopStoreSameCityTransport> transportList = shopStoreSameCityTransportService.selectShopStoreSameCityTransportList(Convert.toLong(storeId));
|
|
||||||
//
|
|
||||||
// if (CollUtil.isEmpty(transportList)) {
|
|
||||||
// // 没有配送范围规则的时候,直接以基础配送费来配送
|
|
||||||
// return deliveryBaseFee.multiply(BigDecimal.valueOf(100)).intValue();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 判断配送范围和起送金额条件
|
|
||||||
// String canNotDeliveryReason = "";
|
|
||||||
// boolean canDelivery = false;
|
|
||||||
//
|
|
||||||
// // 优先处理距离和金额都满足的规则
|
|
||||||
// for (ShopStoreSameCityTransport transport : transportList) {
|
|
||||||
// // 判断订单距离是否在配送范围内
|
|
||||||
// if (transport.getMax_delivery_radius() >= distance) {
|
|
||||||
// // 距离在配送范围内,判断金额是否符合起配金额额度
|
|
||||||
// boolean moneyPassed = false;
|
|
||||||
// if (CommonConstant.Delivery_Amount_Comput_Type_Original.equals(transport.getMin_delivery_amount_type())) {
|
|
||||||
// moneyPassed = orderProductAmount != null && transport.getMin_delivery_amount().compareTo(orderProductAmount) <= 0;
|
|
||||||
// } else if (CommonConstant.Delivery_Amount_Comput_Type_Discounted.equals(transport.getMin_delivery_amount_type())) {
|
|
||||||
// moneyPassed = orderDiscountAmount != null && transport.getMin_delivery_amount().compareTo(orderDiscountAmount) <= 0;
|
|
||||||
// } else if (CommonConstant.Delivery_Amount_Comput_Type_Payment.equals(transport.getMin_delivery_amount_type())) {
|
|
||||||
// moneyPassed = orderPayAmount != null && transport.getMin_delivery_amount().compareTo(orderPayAmount) <= 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 距离和金额都满足条件
|
|
||||||
// if (moneyPassed) {
|
|
||||||
// canDelivery = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 如果没有找到完全满足条件的规则,再详细检查找出失败原因
|
|
||||||
// if (!canDelivery) {
|
|
||||||
// for (ShopStoreSameCityTransport transport : transportList) {
|
|
||||||
// // 判断订单距离是否在配送范围内
|
|
||||||
// if (transport.getMax_delivery_radius() < distance) {
|
|
||||||
// // 记录距离不满足的原因
|
|
||||||
// canNotDeliveryReason = storeName + "的订单不在配送范围内,订单无法配送。";
|
|
||||||
// } else {
|
|
||||||
// // 距离在配送范围内,判断金额是否符合起配金额额度
|
|
||||||
// if (CommonConstant.Delivery_Amount_Comput_Type_Original.equals(transport.getMin_delivery_amount_type())) {
|
|
||||||
// if (orderProductAmount != null && transport.getMin_delivery_amount().compareTo(orderProductAmount) > 0) {
|
|
||||||
// BigDecimal diffMoney = transport.getMin_delivery_amount().subtract(orderProductAmount);
|
|
||||||
// canNotDeliveryReason = String.format("%s商品原价金额还差%.2f元,才满足配送条件,请检查订单。", storeName, diffMoney);
|
|
||||||
// } else {
|
|
||||||
// canDelivery = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// } else if (CommonConstant.Delivery_Amount_Comput_Type_Discounted.equals(transport.getMin_delivery_amount_type())) {
|
|
||||||
// if (orderDiscountAmount != null && transport.getMin_delivery_amount().compareTo(orderDiscountAmount) > 0) {
|
|
||||||
// BigDecimal diffMoney = transport.getMin_delivery_amount().subtract(orderDiscountAmount);
|
|
||||||
// canNotDeliveryReason = String.format("%s订单折后金额还差%.2f元,才满足配送条件,请检查订单。", storeName, diffMoney);
|
|
||||||
// } else {
|
|
||||||
// canDelivery = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// } else if (CommonConstant.Delivery_Amount_Comput_Type_Payment.equals(transport.getMin_delivery_amount_type())) {
|
|
||||||
// if (orderPayAmount != null && transport.getMin_delivery_amount().compareTo(orderPayAmount) > 0) {
|
|
||||||
// BigDecimal diffMoney = transport.getMin_delivery_amount().subtract(orderPayAmount);
|
|
||||||
// canNotDeliveryReason = String.format("%s订单应支付金额还差%.2f元,才满足配送条件,请检查订单。", storeName, diffMoney);
|
|
||||||
// } else {
|
|
||||||
// canDelivery = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 如果仍然不能配送,记录日志并返回0
|
|
||||||
// if (!canDelivery) {
|
|
||||||
// logger.warn(canNotDeliveryReason.isEmpty() ? (storeName + "订单不在配送范围内或未达起送金额,请检查!") : canNotDeliveryReason);
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 额外配送费计算
|
|
||||||
// // 每增加一个距离累加运费
|
|
||||||
// if (transportBase.getDistance_increase_km() != null && transportBase.getDistance_increase_fee() != null && distance > transportBase.getDistance_base() * 1000) {
|
|
||||||
// // 实际配送距离超出基础距离,单位km
|
|
||||||
// BigDecimal diffDistanceM = CommonUtil.DecimalRoundHalfUp(BigDecimal.valueOf(distance - transportBase.getDistance_base() * 1000).divide(BigDecimal.valueOf(1000)));
|
|
||||||
// // 倍数
|
|
||||||
// BigDecimal times = BigDecimal.ZERO;
|
|
||||||
// if (transportBase.getDistance_increase_km() > 0 && diffDistanceM.intValue() > transportBase.getDistance_increase_km()) {
|
|
||||||
// // 末尾非零进位,比如:2.1将是3, 2.0将是2,2.001将是3
|
|
||||||
// times = NumberUtil.div(diffDistanceM, transportBase.getDistance_increase_km()).setScale(0, RoundingMode.UP);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 超过基础运费距离后,累加上运费
|
|
||||||
// deliveryBaseFee = deliveryBaseFee.add(transportBase.getDistance_increase_fee().multiply(times));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 每增加一个重量累加运费(重量暂时忽略,配置的时候设置0)
|
|
||||||
// if (transportBase.getWeight_increase_kg() != null && transportBase.getWeight_increase_fee() != null && orderWeightGram != null && orderWeightGram > transportBase.getWeight_base() * 1000) {
|
|
||||||
// // 实际配送重量超出基础重量,单位kg
|
|
||||||
// BigDecimal diffWeightKg = CommonUtil.DecimalRoundHalfUp(BigDecimal.valueOf(orderWeightGram - transportBase.getWeight_base() * 1000).divide(BigDecimal.valueOf(1000)));
|
|
||||||
// // 倍数
|
|
||||||
// BigDecimal times = BigDecimal.ZERO;
|
|
||||||
// if (transportBase.getWeight_increase_kg() > 0 && diffWeightKg.intValue() > transportBase.getWeight_increase_kg()) {
|
|
||||||
// // 末尾非零进位,比如:2.1将是3, 2.0将是2,2.001将是3
|
|
||||||
// times = NumberUtil.div(diffWeightKg, transportBase.getWeight_increase_kg()).setScale(0, RoundingMode.UP);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// deliveryBaseFee = deliveryBaseFee.add(transportBase.getWeight_increase_fee().multiply(times));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 返回单位为分的配送费
|
|
||||||
// return deliveryBaseFee.multiply(BigDecimal.valueOf(100)).intValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -78,18 +78,14 @@ public class ShopStoreSameCityTransportServiceImpl extends BaseServiceImpl<ShopS
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryWrapper<ShopStoreSameCityTransport> queryWrapper = new QueryWrapper<>();
|
LambdaQueryWrapper<ShopStoreSameCityTransport> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq("transport_base_id", transportBaseId);
|
queryWrapper.eq(ShopStoreSameCityTransport::getTransport_base_id, transportBaseId)
|
||||||
queryWrapper.eq("status", CommonConstant.Enable);
|
.eq(ShopStoreSameCityTransport::getStatus, CommonConstant.Enable)
|
||||||
queryWrapper.orderByAsc("transport_id");
|
.orderByAsc(ShopStoreSameCityTransport::getTransport_id);
|
||||||
|
|
||||||
List<ShopStoreSameCityTransport> shopStoreSameCityTransportList = list(queryWrapper);
|
return list(queryWrapper);
|
||||||
if (CollectionUtil.isEmpty(shopStoreSameCityTransportList)) {
|
|
||||||
shopStoreSameCityTransportList = Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return shopStoreSameCityTransportList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据同城配送基础配置自增 Id 获取同城配送扩展设置列表
|
* 根据同城配送基础配置自增 Id 获取同城配送扩展设置列表
|
||||||
|
|||||||
@ -58,7 +58,6 @@ import com.suisung.mall.shop.user.mapper.ShopUserCartMapper;
|
|||||||
import com.suisung.mall.shop.user.service.ShopUserCartService;
|
import com.suisung.mall.shop.user.service.ShopUserCartService;
|
||||||
import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService;
|
import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService;
|
||||||
import com.suisung.mall.shop.user.service.ShopUserVoucherService;
|
import com.suisung.mall.shop.user.service.ShopUserVoucherService;
|
||||||
import io.swagger.models.auth.In;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@ -2788,6 +2787,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
|
|
||||||
// 同城配送运费检查和计算(只返回数据,不能配送不抛异常)
|
// 同城配送运费检查和计算(只返回数据,不能配送不抛异常)
|
||||||
SameCityDeliveryFeeRespDTO sameCityDeliveryFeeResp = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(storeId, orderLng, orderLat, 0, productMoneyOriginGoods, orderSelDiscountAmount, orderPaymentAmount, false, canThrow);
|
SameCityDeliveryFeeRespDTO sameCityDeliveryFeeResp = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(storeId, orderLng, orderLat, 0, productMoneyOriginGoods, orderSelDiscountAmount, orderPaymentAmount, false, canThrow);
|
||||||
|
logger.info("计算商家同城配送运费成功:{}", sameCityDeliveryFeeResp);
|
||||||
|
|
||||||
// 是否能配送(在配送范围内)
|
// 是否能配送(在配送范围内)
|
||||||
Boolean canDelivery = sameCityDeliveryFeeResp.getCanDelivery();
|
Boolean canDelivery = sameCityDeliveryFeeResp.getCanDelivery();
|
||||||
@ -3291,8 +3291,10 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
logger.debug("店铺ID为{},实体商品订单,收取打包费{}元", storeId, packingFee);
|
logger.debug("店铺ID为{},实体商品订单,收取打包费{}元", storeId, packingFee);
|
||||||
return packingFee;
|
return packingFee;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验限购
|
* 校验限购
|
||||||
|
*
|
||||||
* @param activity_id
|
* @param activity_id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -3360,6 +3362,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否为新用户
|
* 检查是否为新用户
|
||||||
|
*
|
||||||
* @param user_id
|
* @param user_id
|
||||||
*/
|
*/
|
||||||
private boolean checkoutNewPerson(Integer user_id, Integer store_id) {
|
private boolean checkoutNewPerson(Integer user_id, Integer store_id) {
|
||||||
@ -3378,6 +3381,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查等级是否可以参加
|
* 检查等级是否可以参加
|
||||||
|
*
|
||||||
* @param user_id
|
* @param user_id
|
||||||
*/
|
*/
|
||||||
public boolean checkStoreMemberLever(Integer user_id, ShopStoreActivityBase shopStoreActivityBase) {
|
public boolean checkStoreMemberLever(Integer user_id, ShopStoreActivityBase shopStoreActivityBase) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user