运费提示更加精细化,完善程序
This commit is contained in:
parent
ec97faf2af
commit
0ec8e3f0a8
@ -71,7 +71,7 @@ public class PositionUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法一:(反余弦计算方式)
|
||||
* 注:推荐使用该方法,距离误差0.5以内,方法一:(反余弦计算方式)
|
||||
* 计算国内 Gcj02 坐标系两点之间的直线距离(高德地图)
|
||||
*
|
||||
* @param longitude1 第一个点的经度
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package com.suisung.mall.shop.store.controller.mobile;
|
||||
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.pojo.dto.ShopStoreSameCityTransportBaseDTO;
|
||||
import com.suisung.mall.common.utils.JsonUtil;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreSameCityTransportBaseService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreSameCityTransportService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Api(tags = "同城配送运费设置控制器")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/shop/store/same-city-transport")
|
||||
public class ShopStoreSameCityTransportBaseController {
|
||||
|
||||
@Resource
|
||||
private ShopStoreSameCityTransportBaseService transportBaseService;
|
||||
|
||||
@Resource
|
||||
private ShopStoreSameCityTransportService transportService;
|
||||
|
||||
@ApiOperation(value = "下单前检测同城订单配送是否符合要求", notes = "下单前检测同城订单配送是否符合要求")
|
||||
@RequestMapping(value = "/check/same-city/delivery", method = {RequestMethod.POST})
|
||||
public CommonResult checkSameCityDelivery(@RequestBody ShopStoreSameCityTransportBaseDTO transportBaseDTO) {
|
||||
return transportBaseService.ShopStoreSameCityTransportBaseDetail();
|
||||
}
|
||||
}
|
||||
@ -40,6 +40,13 @@ public interface ShopStoreSameCityTransportBaseService {
|
||||
CommonResult storeBusinessTypeList();
|
||||
|
||||
/**
|
||||
* 下单前检测同城订单配送是否符合要求
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
CommonResult checkSameCityDelivery();
|
||||
|
||||
/**
|
||||
* 根据店铺 Id 获取同城配送设置详情信息
|
||||
*
|
||||
* @param storeId
|
||||
|
||||
@ -2947,7 +2947,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
return PositionUtil.bd09ToGcj02(NumberUtil.parseDouble(lng), NumberUtil.parseDouble(lat));
|
||||
}
|
||||
|
||||
logger.debug("百度api坐标系Bd09ToGcj02转换结果 lng,lat:{},{},原始经纬度 lng,lat:{},{}", gps.getWgLon(), gps.getWgLat(),lng, lat);
|
||||
logger.debug("百度api坐标系Bd09ToGcj02转换结果 lng,lat:{},{},原始经纬度 lng,lat:{},{}", gps.getWgLon(), gps.getWgLat(), lng, lat);
|
||||
return gps;
|
||||
}
|
||||
|
||||
@ -2987,7 +2987,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
logger.debug("百度api坐标系Gcj02Tobd09转换失败!");
|
||||
return PositionUtil.gcj02ToBd09(NumberUtil.parseDouble(lng), NumberUtil.parseDouble(lat));
|
||||
}
|
||||
logger.debug("百度api坐标系Gcj02Tobd09转换结果 lng,lat:{},{},原始经纬度 lng,lat:{},{}", gps.getWgLon(), gps.getWgLat());
|
||||
logger.debug("百度api坐标系Gcj02Tobd09转换结果 lng,lat:{},{},原始经纬度 lng,lat:{},{}", gps.getWgLon(), gps.getWgLat(), lng, lat);
|
||||
return gps;
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
@ -30,6 +31,7 @@ import com.suisung.mall.common.pojo.dto.ShopStoreSameCityTransportBaseDTO;
|
||||
import com.suisung.mall.common.utils.CommonUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.PositionUtil;
|
||||
import com.suisung.mall.common.utils.StringUtils;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.chain.controller.admin.ShopChainUserController;
|
||||
import com.suisung.mall.shop.store.mapper.ShopStoreSameCityTransportBaseMapper;
|
||||
@ -187,6 +189,21 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
return CommonResult.success(list, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 下单前检测同城订单配送是否符合要求
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult checkSameCityDelivery() {
|
||||
UserDto user = getCurrentUser();
|
||||
if (user == null) {
|
||||
throw new ApiException(ResultCode.NEED_LOGIN);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据店铺 Id 获取同城配送设置详情信息
|
||||
*
|
||||
@ -350,9 +367,28 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
if (storeId == null || orderLongitude == null || orderLatitude == null || storeId <= 0) {
|
||||
logger.error("同城配送费计算时,缺少必要参数。");
|
||||
if (canThrow) {
|
||||
throw new ApiException(I18nUtil._("同城配送费计算缺少必要参数。"));
|
||||
throw new ApiException(I18nUtil._("同城配送缺少必要参数。"));
|
||||
}
|
||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "同城配送费计算缺少必要的参数。");
|
||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "同城配送缺少必要的参数。");
|
||||
}
|
||||
|
||||
ShopStoreBase storeBase = shopStoreBaseService.get(storeId);
|
||||
if (storeBase == null) {
|
||||
logger.error("同城配送费计算时,缺少店铺基本信息。");
|
||||
if (canThrow) {
|
||||
throw new ApiException(I18nUtil._("同城配送缺少店铺基本信息。"));
|
||||
}
|
||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "同城配送缺少店铺基本信息。");
|
||||
}
|
||||
|
||||
String storeLng = storeBase.getStore_longitude();
|
||||
String storeLat = storeBase.getStore_latitude();
|
||||
if (StrUtil.isBlank(storeLng) || StrUtil.isBlank(storeLat)) {
|
||||
logger.error("同城配送费计算:店铺经纬度为空");
|
||||
if (canThrow) {
|
||||
throw new ApiException(I18nUtil._("无法获取店铺的具体位置,请联系商家。"));
|
||||
}
|
||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "无法获取店铺的具体位置,请联系商家。");
|
||||
}
|
||||
|
||||
// 获取基础运费设置记录
|
||||
@ -360,18 +396,9 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
if (transportBase == null) {
|
||||
logger.error("同城配送费计算:无法获取基础运费设置记录。");
|
||||
if (canThrow) {
|
||||
throw new ApiException(I18nUtil._("商家尚未配置同城配送相关设置。"));
|
||||
throw new ApiException(I18nUtil._("商家尚未完成同城配送设置。"));
|
||||
}
|
||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "商家尚未配置同城配送相关设置。");
|
||||
}
|
||||
String storeLng = transportBase.getStore_longitude();
|
||||
String storeLat = transportBase.getStore_latitude();
|
||||
if (StrUtil.isBlank(storeLng) || StrUtil.isBlank(storeLat)) {
|
||||
logger.error("同城配送费计算:店铺经纬度为空");
|
||||
if (canThrow) {
|
||||
throw new ApiException(I18nUtil._("无法获取店铺的具体位置,请联系商家。"));
|
||||
}
|
||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "无法获取店铺的具体位置,请联系商家。");
|
||||
return new SameCityDeliveryFeeRespDTO(false, false, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "商家尚未完成同城配送设置。");
|
||||
}
|
||||
|
||||
if (transportBase.getDistance_base() == null) {
|
||||
@ -433,6 +460,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
// #### 基础配送费计算完毕
|
||||
|
||||
|
||||
|
||||
// 优惠(减免)的配送费(重要)
|
||||
BigDecimal reduceDeliveryFee = BigDecimal.ZERO;
|
||||
|
||||
@ -469,6 +497,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
deliveryFeeResultDTO.setDistancePassed(true);
|
||||
// 距离在配送范围内,继续判断金额是否符合起配金额额度?
|
||||
if (CommonConstant.Delivery_Amount_Comput_Type_Original.equals(transport.getMin_delivery_amount_type())) {
|
||||
|
||||
if (transport.getMin_delivery_amount().compareTo(orderProductAmount) > 0) {
|
||||
deliveryFeeResultDTO.setMoneyPassed(false);
|
||||
BigDecimal diffMoney = transport.getMin_delivery_amount().subtract(orderProductAmount);
|
||||
@ -477,7 +506,9 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
} else {
|
||||
deliveryFeeResultDTO.setMoneyPassed(true);
|
||||
}
|
||||
|
||||
} else if (CommonConstant.Delivery_Amount_Comput_Type_Discounted.equals(transport.getMin_delivery_amount_type())) {
|
||||
|
||||
if (transport.getMin_delivery_amount().compareTo(orderDiscountAmount) > 0) {
|
||||
deliveryFeeResultDTO.setMoneyPassed(false);
|
||||
BigDecimal diffMoney = transport.getMin_delivery_amount().subtract(orderDiscountAmount);
|
||||
@ -486,6 +517,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
} else {
|
||||
deliveryFeeResultDTO.setMoneyPassed(true);
|
||||
}
|
||||
|
||||
} else if (CommonConstant.Delivery_Amount_Comput_Type_Payment.equals(transport.getMin_delivery_amount_type())) {
|
||||
|
||||
if (transport.getMin_delivery_amount().compareTo(orderPayAmount) > 0) {
|
||||
|
||||
@ -857,7 +857,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
Date currentDate = new Date();
|
||||
voucherQueryWrapper.le("voucher_start_date", currentDate);
|
||||
voucherQueryWrapper.ge("voucher_end_date", currentDate);
|
||||
voucherQueryWrapper.eq("voucher_state_id", StateCode.VOUCHER_STATE_UNUSED);//可用的的优惠券)
|
||||
voucherQueryWrapper.eq("voucher_state_id", StateCode.VOUCHER_STATE_UNUSED);//可用的的优惠券
|
||||
voucherQueryWrapper.orderByDesc("voucher_subtotal");
|
||||
Map voucher_list = shopUserVoucherService.getLists(voucherQueryWrapper, 1, 500);
|
||||
|
||||
@ -890,7 +890,6 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
// 如果活动保存的sku不包含当前sku,则移除优惠券
|
||||
if (!new HashSet<>(itemIdList).containsAll(item_ids)) {
|
||||
voucherIter.remove();
|
||||
continue;
|
||||
} else {
|
||||
//计算额度是否满足指定商品的额度要求
|
||||
for (Map store_item : items) {
|
||||
@ -913,7 +912,6 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
|
||||
if (voucherItemSubtotal.compareTo(voucherSubtotal) < 0) {
|
||||
voucherIter.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user