更改内部配送费计算方法
This commit is contained in:
parent
52ff9dabe0
commit
144cf92c27
@ -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;
|
||||
}
|
||||
@ -34,7 +34,7 @@ public class ShopStorePrinterController {
|
||||
@ApiOperation(value = "内部测试案例", notes = "内部测试案例")
|
||||
@RequestMapping(value = "/testcase", method = {RequestMethod.GET})
|
||||
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);
|
||||
|
||||
// BigDecimal s = new BigDecimal(2.50).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
@ -94,10 +94,11 @@ public interface ShopStoreSameCityTransportBaseService {
|
||||
* @param orderProductAmount 订单商品原价金额
|
||||
* @param orderDiscountAmount 订单商品折扣金额(订单原价减去每个商品折扣费)
|
||||
* @param orderPayAmount 订单实际支付金额(折扣金额-优惠券-积分扣-人工干预扣费),不包含运费
|
||||
* @param isPlatform 是否平台: 1-是;2-否
|
||||
* @param canThrow 能否抛出异常?
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* 平台计算同城订单的内部配送费(仅仅作用于平台内部配送费计算,商家配送费忽略此方法,只对下单成功的订单起效果)
|
||||
|
||||
@ -601,11 +601,12 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
* @param orderProductAmount 订单商品原价金额
|
||||
* @param orderDiscountAmount 订单商品折扣金额(订单原价减去每个商品折扣费)
|
||||
* @param orderPayAmount 订单实际支付金额(折扣金额-优惠券-积分扣-人工干预扣费),不包含运费
|
||||
* @param isPlatform 是否平台: 1-是;2-否
|
||||
* @param canThrow 不能配送是否抛出异常?
|
||||
* @return
|
||||
*/
|
||||
@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.先获取订单的经纬度,计算配送距离,获取配送范围,确定是否能配送,如果能计算基础运费?
|
||||
// 2.如果能配送,再订单总重量,订单原价金额,订单折后金额,订单实付金额
|
||||
@ -639,8 +640,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "无法获取" + storeName + "的具体位置,请联系商家。");
|
||||
}
|
||||
|
||||
// 获取店铺商家的基础运费设置记录
|
||||
ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(storeId, CommonConstant.Disable2);
|
||||
ShopStoreSameCityTransportBase transportBase = getShopStoreSameCityTransportBaseById(storeId, isPlatform ? CommonConstant.Enable : CommonConstant.Disable2);
|
||||
if (transportBase == null) {
|
||||
logger.error("{}同城配送费计算:无法获取基础运费设置记录。", storeName);
|
||||
if (canThrow) {
|
||||
@ -767,8 +767,8 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
|
||||
}
|
||||
|
||||
// logger.debug(storeName + "下单时,根据商家运费设置规则减免{}元运费", reduceDeliveryFee);
|
||||
// logger.debug(storeName + "下单时,不符合规则的:\n {}\n符合规则的:{}", JSONUtil.toJsonStr(noPassed), JSONUtil.toJsonStr(passed));
|
||||
logger.debug(storeName + "下单时,根据商家运费设置规则减免{}元运费", reduceDeliveryFee);
|
||||
logger.debug(storeName + "下单时,不符合规则的:\n {}\n符合规则的:{}", JSONUtil.toJsonStr(noPassed), JSONUtil.toJsonStr(passed));
|
||||
boolean canDelivery = true;
|
||||
if (passed.size() == 0 && noPassed.size() > 0) {
|
||||
// 没有一个满足起送距离和起送金额的规则订单
|
||||
@ -889,7 +889,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
|| sameCityDeliveryFeeRespDTO.getDeliveryFee() == null
|
||||
|| sameCityDeliveryFeeRespDTO.getDeliveryFee().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
|
||||
@ -270,15 +270,15 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
|
||||
if (ObjectUtil.equal(cart.getUser_id(), user_id)) {
|
||||
cart.setCart_quantity(cart_quantity);
|
||||
int i=0;
|
||||
while (i<3){
|
||||
boolean result=edit(cart);
|
||||
int i = 0;
|
||||
while (i < 3) {
|
||||
boolean result = edit(cart);
|
||||
if (!result) {
|
||||
i++;
|
||||
if(i==3){
|
||||
if (i == 3) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
logger.info("重试成功,跳出");
|
||||
break;
|
||||
}
|
||||
@ -2656,7 +2656,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user