更改内部配送费计算方法

This commit is contained in:
Jack 2025-12-23 11:09:21 +08:00
parent 52ff9dabe0
commit 144cf92c27
5 changed files with 75 additions and 14 deletions

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
* Vestibulum commodo. Ut rhoncus gravida arcu.
*/
package com.suisung.mall.common.modules.store;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("shop_mch_entry_branch")
@ApiModel(value = "shop_mch_entry_branch 实体", description = "商家分店拉卡拉商户申请数据")
public class ShopMchEntryBranch implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自增ID")
@TableId(value = "id", type = IdType.INPUT)
private Long id;
@ApiModelProperty(value = "拉卡拉外部(银联)商户号", required = true)
private String lkl_mer_cup_no;
@ApiModelProperty(value = "拉卡拉终端号")
private String lkl_term_no;
@ApiModelProperty(value = "审核关联号", required = true)
private String review_related_id;
@ApiModelProperty(value = "请求拉卡拉参数")
private String lkl_req;
@ApiModelProperty(value = "拉卡拉响应参数")
private String lkl_reps;
@ApiModelProperty(value = "该商家入驻记录是否有效0:无效1:有效")
private Integer status;
@ApiModelProperty(value = "商家入驻记录的创建时间")
private Date created_at;
@ApiModelProperty(value = "商家入驻记录的更新时间")
private Date updated_at;
}

View File

@ -34,7 +34,7 @@ public class ShopStorePrinterController {
@ApiOperation(value = "内部测试案例", notes = "内部测试案例") @ApiOperation(value = "内部测试案例", notes = "内部测试案例")
@RequestMapping(value = "/testcase", method = {RequestMethod.GET}) @RequestMapping(value = "/testcase", method = {RequestMethod.GET})
public CommonResult TestCase() { public CommonResult TestCase() {
Object data = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(3L, "110.078141", "23.375037", 100, BigDecimal.valueOf(19), BigDecimal.valueOf(5.5), BigDecimal.valueOf(5.5), true); Object data = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(3L, "110.078141", "23.375037", 100, BigDecimal.valueOf(19), BigDecimal.valueOf(5.5), BigDecimal.valueOf(5.5), false, true);
// Double distanceD = PositionUtil.getDistance4(110.084376,23.394216,110.11752034714767,23.31704849881646); // Double distanceD = PositionUtil.getDistance4(110.084376,23.394216,110.11752034714767,23.31704849881646);
// BigDecimal s = new BigDecimal(2.50).setScale(2, RoundingMode.HALF_UP); // BigDecimal s = new BigDecimal(2.50).setScale(2, RoundingMode.HALF_UP);

View File

@ -94,10 +94,11 @@ public interface ShopStoreSameCityTransportBaseService {
* @param orderProductAmount 订单商品原价金额 * @param orderProductAmount 订单商品原价金额
* @param orderDiscountAmount 订单商品折扣金额订单原价减去每个商品折扣费 * @param orderDiscountAmount 订单商品折扣金额订单原价减去每个商品折扣费
* @param orderPayAmount 订单实际支付金额折扣金额-优惠券-积分扣-人工干预扣费不包含运费 * @param orderPayAmount 订单实际支付金额折扣金额-优惠券-积分扣-人工干预扣费不包含运费
* @param isPlatform 是否平台 1-2-
* @param canThrow 能否抛出异常 * @param canThrow 能否抛出异常
* @return * @return
*/ */
SameCityDeliveryFeeRespDTO computeSameCityTransportFee(Long storeId, String orderLongitude, String orderLatitude, Integer weightGram, BigDecimal orderProductAmount, BigDecimal orderDiscountAmount, BigDecimal orderPayAmount, Boolean canThrow); SameCityDeliveryFeeRespDTO computeSameCityTransportFee(Long storeId, String orderLongitude, String orderLatitude, Integer weightGram, BigDecimal orderProductAmount, BigDecimal orderDiscountAmount, BigDecimal orderPayAmount, Boolean isPlatform, Boolean canThrow);
/** /**
* 平台计算同城订单的内部配送费仅仅作用于平台内部配送费计算商家配送费忽略此方法只对下单成功的订单起效果 * 平台计算同城订单的内部配送费仅仅作用于平台内部配送费计算商家配送费忽略此方法只对下单成功的订单起效果

View File

@ -601,11 +601,12 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
* @param orderProductAmount 订单商品原价金额 * @param orderProductAmount 订单商品原价金额
* @param orderDiscountAmount 订单商品折扣金额订单原价减去每个商品折扣费 * @param orderDiscountAmount 订单商品折扣金额订单原价减去每个商品折扣费
* @param orderPayAmount 订单实际支付金额折扣金额-优惠券-积分扣-人工干预扣费不包含运费 * @param orderPayAmount 订单实际支付金额折扣金额-优惠券-积分扣-人工干预扣费不包含运费
* @param isPlatform 是否平台 1-2-
* @param canThrow 不能配送是否抛出异常 * @param canThrow 不能配送是否抛出异常
* @return * @return
*/ */
@Override @Override
public SameCityDeliveryFeeRespDTO computeSameCityTransportFee(Long storeId, String orderLongitude, String orderLatitude, Integer weightGram, BigDecimal orderProductAmount, BigDecimal orderDiscountAmount, BigDecimal orderPayAmount, Boolean canThrow) { public SameCityDeliveryFeeRespDTO computeSameCityTransportFee(Long storeId, String orderLongitude, String orderLatitude, Integer weightGram, BigDecimal orderProductAmount, BigDecimal orderDiscountAmount, BigDecimal orderPayAmount, Boolean isPlatform, Boolean canThrow) {
// 计算订单同城配送费该函数的流程说明 // 计算订单同城配送费该函数的流程说明
// 1.先获取订单的经纬度计算配送距离获取配送范围确定是否能配送如果能计算基础运费 // 1.先获取订单的经纬度计算配送距离获取配送范围确定是否能配送如果能计算基础运费
// 2.如果能配送再订单总重量订单原价金额订单折后金额订单实付金额 // 2.如果能配送再订单总重量订单原价金额订单折后金额订单实付金额
@ -639,8 +640,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "无法获取" + storeName + "的具体位置,请联系商家。"); return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "无法获取" + storeName + "的具体位置,请联系商家。");
} }
// 获取店铺商家的基础运费设置记录 ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(storeId, isPlatform ? CommonConstant.Enable : CommonConstant.Disable2);
ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(storeId, CommonConstant.Disable2);
if (transportBase == null) { if (transportBase == null) {
logger.error("{}同城配送费计算:无法获取基础运费设置记录。", storeName); logger.error("{}同城配送费计算:无法获取基础运费设置记录。", storeName);
if (canThrow) { if (canThrow) {
@ -767,8 +767,8 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
} }
// logger.debug(storeName + "下单时,根据商家运费设置规则减免{}元运费", reduceDeliveryFee); logger.debug(storeName + "下单时,根据商家运费设置规则减免{}元运费", reduceDeliveryFee);
// logger.debug(storeName + "下单时,不符合规则的:\n {}\n符合规则的:{}", JSONUtil.toJsonStr(noPassed), JSONUtil.toJsonStr(passed)); logger.debug(storeName + "下单时,不符合规则的:\n {}\n符合规则的:{}", 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) {
// 没有一个满足起送距离和起送金额的规则订单 // 没有一个满足起送距离和起送金额的规则订单
@ -889,7 +889,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
*/ */
@Override @Override
public Integer computeSameCityInnerDeliveryFee(Integer storeId, String orderLongitude, String orderLatitude, Integer orderWeightGram, BigDecimal orderProductAmount, BigDecimal orderDiscountAmount, BigDecimal orderPayAmount) { public Integer computeSameCityInnerDeliveryFee(Integer storeId, String orderLongitude, String orderLatitude, Integer orderWeightGram, BigDecimal orderProductAmount, BigDecimal orderDiscountAmount, BigDecimal orderPayAmount) {
SameCityDeliveryFeeRespDTO sameCityDeliveryFeeRespDTO = computeSameCityTransportFee(Convert.toLong(storeId), orderLongitude, orderLatitude, orderWeightGram, orderProductAmount, orderDiscountAmount, orderPayAmount, false); SameCityDeliveryFeeRespDTO sameCityDeliveryFeeRespDTO = computeSameCityTransportFee(Convert.toLong(storeId), orderLongitude, orderLatitude, orderWeightGram, orderProductAmount, orderDiscountAmount, orderPayAmount, true, false);
if (sameCityDeliveryFeeRespDTO == null if (sameCityDeliveryFeeRespDTO == null
|| sameCityDeliveryFeeRespDTO.getDeliveryFee() == null || sameCityDeliveryFeeRespDTO.getDeliveryFee() == null
|| sameCityDeliveryFeeRespDTO.getDeliveryFee().compareTo(BigDecimal.ZERO) <= 0) { || sameCityDeliveryFeeRespDTO.getDeliveryFee().compareTo(BigDecimal.ZERO) <= 0) {

View File

@ -270,15 +270,15 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
if (ObjectUtil.equal(cart.getUser_id(), user_id)) { if (ObjectUtil.equal(cart.getUser_id(), user_id)) {
cart.setCart_quantity(cart_quantity); cart.setCart_quantity(cart_quantity);
int i=0; int i = 0;
while (i<3){ while (i < 3) {
boolean result=edit(cart); boolean result = edit(cart);
if (!result) { if (!result) {
i++; i++;
if(i==3){ if (i == 3) {
throw new ApiException(ResultCode.FAILED); throw new ApiException(ResultCode.FAILED);
} }
}else { } else {
logger.info("重试成功,跳出"); logger.info("重试成功,跳出");
break; break;
} }
@ -2656,7 +2656,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
BigDecimal orderPaymentAmount = Convert.toBigDecimal(store_row.get("order_money_select_items")); BigDecimal orderPaymentAmount = Convert.toBigDecimal(store_row.get("order_money_select_items"));
// 同城配送运费检查和计算(只返回数据不能配送不抛异常) // 同城配送运费检查和计算(只返回数据不能配送不抛异常)
SameCityDeliveryFeeRespDTO sameCityDeliveryFeeResp = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(storeId, orderLng, orderLat, 0, productMoneyOriginGoods, orderSelDiscountAmount, orderPaymentAmount, canThrow); SameCityDeliveryFeeRespDTO sameCityDeliveryFeeResp = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(storeId, orderLng, orderLat, 0, productMoneyOriginGoods, orderSelDiscountAmount, orderPaymentAmount, false, canThrow);
// 是否能配送在配送范围内 // 是否能配送在配送范围内
Boolean canDelivery = sameCityDeliveryFeeResp.getCanDelivery(); Boolean canDelivery = sameCityDeliveryFeeResp.getCanDelivery();