diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/OrderService.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/OrderService.java index 7a6ea875e..d60b389fd 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/OrderService.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/OrderService.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.shop.service.order; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.shop.controller.admin.order.vo.StoreOrderPageQueryReqVo; import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder; import cn.iocoder.yudao.module.shop.request.order.*; import cn.iocoder.yudao.module.shop.request.product.StoreProductReplyAddRequest; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderServiceImpl.java index 757e928ed..7c8ae3f38 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderServiceImpl.java @@ -9,13 +9,6 @@ import cn.iocoder.yudao.module.member.api.address.AddressApi; import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.express.ShippingTemplatesApi; -import cn.iocoder.yudao.module.product.api.express.ShippingTemplatesFreeApi; -import cn.iocoder.yudao.module.product.api.express.ShippingTemplatesRegionApi; -import cn.iocoder.yudao.module.product.api.express.dto.ShippingTemplatesDO; -import cn.iocoder.yudao.module.product.api.express.dto.ShippingTemplatesFreeDO; -import cn.iocoder.yudao.module.product.api.express.dto.ShippingTemplatesRegionDO; -import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; import cn.iocoder.yudao.module.shop.constants.PayConstants; import cn.iocoder.yudao.framework.common.enums.Constants; import cn.iocoder.yudao.framework.common.exception.ServiceException; @@ -119,18 +112,16 @@ public class OrderServiceImpl implements OrderService { @Autowired private AddressApi addressApi; - @Autowired - private GetProductReply getProductReply; - - @Autowired - private ShippingTemplatesApi shippingTemplatesApi; - - @Autowired - private ShippingTemplatesFreeApi shippingTemplatesFreeApi; - - @Autowired - private ShippingTemplatesRegionApi shippingTemplatesRegionApi; - + +// @Autowired +// private ShippingTemplatesApi shippingTemplatesApi; +// +// @Autowired +// private ShippingTemplatesFreeApi shippingTemplatesFreeApi; +// +// @Autowired +// private ShippingTemplatesRegionApi shippingTemplatesRegionApi; + @Autowired private StoreProductService storeProductService; @@ -612,115 +603,115 @@ public class OrderServiceImpl implements OrderService { * 计算订单运费 */ private void getFreightFee(OrderInfoVo orderInfoVo, AddressRespDTO userAddress) { - // 判断是否满额包邮 type=1按件数 2按重量 3按体积 - // 全场满额包邮开关 - String postageSwitchString = apiConfigApi.getConfigKey(SysConfigConstants.STORE_FEE_POSTAGE_SWITCH).toString(); - // 全场满额包邮金额 - String storeFreePostageString = apiConfigApi.getConfigKey(SysConfigConstants.STORE_FEE_POSTAGE).toString(); - BigDecimal storePostage = BigDecimal.ZERO; - if (postageSwitchString.equals("true") && (storeFreePostageString.equals("0") || orderInfoVo.getProTotalFee().compareTo(new BigDecimal(storeFreePostageString)) >= 0)) { - storePostage = BigDecimal.ZERO; - } else if (ObjectUtil.isNull(userAddress) || userAddress.getCityId() <= 0) { - // 用户地址不存在,默认运费为0元 - storePostage = BigDecimal.ZERO; - } else { - // 有用户地址的情况下 - // 运费根据商品计算 - Map proMap = new HashMap<>(); - orderInfoVo.getOrderDetailList().forEach(e -> { - Integer proId = e.getProductId(); - if (proMap.containsKey(proId)) { - MyRecord record = proMap.get(proId); - record.set("totalPrice", record.getBigDecimal("totalPrice").add(e.getPrice().multiply(BigDecimal.valueOf(e.getPayNum())))); - record.set("totalNum", record.getInt("totalNum") + e.getPayNum()); - BigDecimal weight = e.getWeight().multiply(BigDecimal.valueOf(e.getPayNum())); - record.set("weight", record.getBigDecimal("weight").add(weight)); - BigDecimal volume = e.getVolume().multiply(BigDecimal.valueOf(e.getPayNum())); - record.set("volume", record.getBigDecimal("volume").add(volume)); - } else { - MyRecord record = new MyRecord(); - record.set("totalPrice", e.getPrice().multiply(BigDecimal.valueOf(e.getPayNum()))); - record.set("totalNum", e.getPayNum()); - record.set("tempId", e.getTempId()); - record.set("proId", proId); - BigDecimal weight = e.getWeight().multiply(BigDecimal.valueOf(e.getPayNum())); - record.set("weight", weight); - BigDecimal volume = e.getVolume().multiply(BigDecimal.valueOf(e.getPayNum())); - record.set("volume", volume); - - proMap.put(proId, record); - } - }); - - // 指定包邮(单品运费模板)> 指定区域配送(单品运费模板) - int cityId = userAddress.getCityId(); - - for (Map.Entry m : proMap.entrySet()) { - MyRecord value = m.getValue(); - Integer tempId = value.getInt("tempId"); - ShippingTemplatesDO shippingTemplatesDO = shippingTemplatesApi.getById(tempId); - if (shippingTemplatesDO.getAppoint()) {// 指定包邮 - // 判断是否在指定包邮区域内 - // 必须满足件数 + 金额 才能包邮 - ShippingTemplatesFreeDO shippingTemplatesFree = shippingTemplatesFreeApi.getByTempIdAndCityId(tempId, cityId); - if (ObjectUtil.isNotNull(shippingTemplatesFree)) { // 在包邮区域内 - BigDecimal freeNum = shippingTemplatesFree.getNumber(); - BigDecimal multiply = value.getBigDecimal("totalPrice"); - if (new BigDecimal(value.getInt("totalNum")).compareTo(freeNum) >= 0 && multiply.compareTo(shippingTemplatesFree.getPrice()) >= 0) { - // 满足件数 + 金额 = 包邮 - continue; - } - } - } - // 不满足指定包邮条件,走指定区域配送 - ShippingTemplatesRegionDO shippingTemplatesRegion = shippingTemplatesRegionApi.getByTempIdAndCityId(tempId, cityId); - if (ObjectUtil.isNull(shippingTemplatesRegion)) { - throw new ServiceException("计算运费时,未找到全国运费配置"); - } - - // 判断计费方式:件数、重量、体积 - switch (shippingTemplatesDO.getType()) { - case 1: // 件数 - // 判断件数是否超过首件 - Integer num = value.getInt("totalNum"); - if (num <= shippingTemplatesRegion.getFirst().intValue()) { - storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()); - } else {// 超过首件的需要计算续件 - int renewalNum = num - shippingTemplatesRegion.getFirst().intValue(); - // 剩余件数/续件 = 需要计算的续件费用的次数 - BigDecimal divide = new BigDecimal(renewalNum).divide(shippingTemplatesRegion.getRenewal(), 0, BigDecimal.ROUND_UP); - BigDecimal renewalPrice = shippingTemplatesRegion.getRenewalPrice().multiply(divide); - storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()).add(renewalPrice); - } - break; - case 2: // 重量 - BigDecimal weight = value.getBigDecimal("weight"); - if (weight.compareTo(shippingTemplatesRegion.getFirst()) <= 0) { - storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()); - } else {// 超过首件的需要计算续件 - BigDecimal renewalNum = weight.subtract(shippingTemplatesRegion.getFirst()); - // 剩余件数/续件 = 需要计算的续件费用的次数 - BigDecimal divide = renewalNum.divide(shippingTemplatesRegion.getRenewal(), 0, BigDecimal.ROUND_UP); - BigDecimal renewalPrice = shippingTemplatesRegion.getRenewalPrice().multiply(divide); - storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()).add(renewalPrice); - } - break; - case 3: // 体积 - BigDecimal volume = value.getBigDecimal("volume"); - if (volume.compareTo(shippingTemplatesRegion.getFirst()) <= 0) { - storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()); - } else {// 超过首件的需要计算续件 - BigDecimal renewalNum = volume.subtract(shippingTemplatesRegion.getFirst()); - // 剩余件数/续件 = 需要计算的续件费用的次数 - BigDecimal divide = renewalNum.divide(shippingTemplatesRegion.getRenewal(), 0, BigDecimal.ROUND_UP); - BigDecimal renewalPrice = shippingTemplatesRegion.getRenewalPrice().multiply(divide); - storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()).add(renewalPrice); - } - break; - } - } - } - orderInfoVo.setFreightFee(storePostage); +// // 判断是否满额包邮 type=1按件数 2按重量 3按体积 +// // 全场满额包邮开关 +// String postageSwitchString = apiConfigApi.getConfigKey(SysConfigConstants.STORE_FEE_POSTAGE_SWITCH).toString(); +// // 全场满额包邮金额 +// String storeFreePostageString = apiConfigApi.getConfigKey(SysConfigConstants.STORE_FEE_POSTAGE).toString(); +// BigDecimal storePostage = BigDecimal.ZERO; +// if (postageSwitchString.equals("true") && (storeFreePostageString.equals("0") || orderInfoVo.getProTotalFee().compareTo(new BigDecimal(storeFreePostageString)) >= 0)) { +// storePostage = BigDecimal.ZERO; +// } else if (ObjectUtil.isNull(userAddress) || userAddress.getCityId() <= 0) { +// // 用户地址不存在,默认运费为0元 +// storePostage = BigDecimal.ZERO; +// } else { +// // 有用户地址的情况下 +// // 运费根据商品计算 +// Map proMap = new HashMap<>(); +// orderInfoVo.getOrderDetailList().forEach(e -> { +// Integer proId = e.getProductId(); +// if (proMap.containsKey(proId)) { +// MyRecord record = proMap.get(proId); +// record.set("totalPrice", record.getBigDecimal("totalPrice").add(e.getPrice().multiply(BigDecimal.valueOf(e.getPayNum())))); +// record.set("totalNum", record.getInt("totalNum") + e.getPayNum()); +// BigDecimal weight = e.getWeight().multiply(BigDecimal.valueOf(e.getPayNum())); +// record.set("weight", record.getBigDecimal("weight").add(weight)); +// BigDecimal volume = e.getVolume().multiply(BigDecimal.valueOf(e.getPayNum())); +// record.set("volume", record.getBigDecimal("volume").add(volume)); +// } else { +// MyRecord record = new MyRecord(); +// record.set("totalPrice", e.getPrice().multiply(BigDecimal.valueOf(e.getPayNum()))); +// record.set("totalNum", e.getPayNum()); +// record.set("tempId", e.getTempId()); +// record.set("proId", proId); +// BigDecimal weight = e.getWeight().multiply(BigDecimal.valueOf(e.getPayNum())); +// record.set("weight", weight); +// BigDecimal volume = e.getVolume().multiply(BigDecimal.valueOf(e.getPayNum())); +// record.set("volume", volume); +// +// proMap.put(proId, record); +// } +// }); +// +// // 指定包邮(单品运费模板)> 指定区域配送(单品运费模板) +// int cityId = userAddress.getCityId(); +// +// for (Map.Entry m : proMap.entrySet()) { +// MyRecord value = m.getValue(); +// Integer tempId = value.getInt("tempId"); +// ShippingTemplatesDO shippingTemplatesDO = shippingTemplatesApi.getById(tempId); +// if (shippingTemplatesDO.getAppoint()) {// 指定包邮 +// // 判断是否在指定包邮区域内 +// // 必须满足件数 + 金额 才能包邮 +// ShippingTemplatesFreeDO shippingTemplatesFree = shippingTemplatesFreeApi.getByTempIdAndCityId(tempId, cityId); +// if (ObjectUtil.isNotNull(shippingTemplatesFree)) { // 在包邮区域内 +// BigDecimal freeNum = shippingTemplatesFree.getNumber(); +// BigDecimal multiply = value.getBigDecimal("totalPrice"); +// if (new BigDecimal(value.getInt("totalNum")).compareTo(freeNum) >= 0 && multiply.compareTo(shippingTemplatesFree.getPrice()) >= 0) { +// // 满足件数 + 金额 = 包邮 +// continue; +// } +// } +// } +// // 不满足指定包邮条件,走指定区域配送 +// ShippingTemplatesRegionDO shippingTemplatesRegion = shippingTemplatesRegionApi.getByTempIdAndCityId(tempId, cityId); +// if (ObjectUtil.isNull(shippingTemplatesRegion)) { +// throw new ServiceException("计算运费时,未找到全国运费配置"); +// } +// +// // 判断计费方式:件数、重量、体积 +// switch (shippingTemplatesDO.getType()) { +// case 1: // 件数 +// // 判断件数是否超过首件 +// Integer num = value.getInt("totalNum"); +// if (num <= shippingTemplatesRegion.getFirst().intValue()) { +// storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()); +// } else {// 超过首件的需要计算续件 +// int renewalNum = num - shippingTemplatesRegion.getFirst().intValue(); +// // 剩余件数/续件 = 需要计算的续件费用的次数 +// BigDecimal divide = new BigDecimal(renewalNum).divide(shippingTemplatesRegion.getRenewal(), 0, BigDecimal.ROUND_UP); +// BigDecimal renewalPrice = shippingTemplatesRegion.getRenewalPrice().multiply(divide); +// storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()).add(renewalPrice); +// } +// break; +// case 2: // 重量 +// BigDecimal weight = value.getBigDecimal("weight"); +// if (weight.compareTo(shippingTemplatesRegion.getFirst()) <= 0) { +// storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()); +// } else {// 超过首件的需要计算续件 +// BigDecimal renewalNum = weight.subtract(shippingTemplatesRegion.getFirst()); +// // 剩余件数/续件 = 需要计算的续件费用的次数 +// BigDecimal divide = renewalNum.divide(shippingTemplatesRegion.getRenewal(), 0, BigDecimal.ROUND_UP); +// BigDecimal renewalPrice = shippingTemplatesRegion.getRenewalPrice().multiply(divide); +// storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()).add(renewalPrice); +// } +// break; +// case 3: // 体积 +// BigDecimal volume = value.getBigDecimal("volume"); +// if (volume.compareTo(shippingTemplatesRegion.getFirst()) <= 0) { +// storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()); +// } else {// 超过首件的需要计算续件 +// BigDecimal renewalNum = volume.subtract(shippingTemplatesRegion.getFirst()); +// // 剩余件数/续件 = 需要计算的续件费用的次数 +// BigDecimal divide = renewalNum.divide(shippingTemplatesRegion.getRenewal(), 0, BigDecimal.ROUND_UP); +// BigDecimal renewalPrice = shippingTemplatesRegion.getRenewalPrice().multiply(divide); +// storePostage = storePostage.add(shippingTemplatesRegion.getFirstPrice()).add(renewalPrice); +// } +// break; +// } +// } +// } +// orderInfoVo.setFreightFee(storePostage); } /** diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/AddressApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/AddressApiImpl.java index 1eb4ccf1d..e0d9ce97a 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/AddressApiImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/AddressApiImpl.java @@ -29,8 +29,6 @@ public class AddressApiImpl implements AddressApi { @Resource private AddressMapper addressMapper; - @Autowired - private AddressConvert addressConvert; @Override public AddressRespDTO getAddress(Long id, Long userId) { @@ -41,8 +39,7 @@ public class AddressApiImpl implements AddressApi { public AddressRespDTO getById(Integer addressId) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(AddressDO::getId, addressId); - lambdaQueryWrapper.eq(AddressDO::getIsDel, false); - return addressConvert.convert02(addressMapper.selectOne(lambdaQueryWrapper)); + return AddressConvert.INSTANCE.convert02(addressMapper.selectOne(lambdaQueryWrapper)); } /** @@ -54,7 +51,7 @@ public class AddressApiImpl implements AddressApi { LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); lambdaQueryWrapper.eq(AddressDO::getDefaulted, true); lambdaQueryWrapper.eq(AddressDO::getId, uid); - return addressConvert.convert02(addressMapper.selectOne(lambdaQueryWrapper)); + return AddressConvert.INSTANCE.convert02(addressMapper.selectOne(lambdaQueryWrapper)); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java index a2d1e9788..366766f36 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java @@ -89,7 +89,7 @@ public class MemberUserApiImpl implements MemberUserApi { if (getUserId() == 0L) { return null; } - return UserConvert.INSTANCE.convert2(userService.getById(getUserId())); + return UserConvert.INSTANCE.convert2(userService.getUser(getUserId())); } /** diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/AddressDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/AddressDO.java index 2a888dc9d..6f96238f8 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/AddressDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/AddressDO.java @@ -56,10 +56,5 @@ public class AddressDO extends BaseDO { */ private Boolean defaulted; - /** - *是否删除 - */ - @TableLogic - private Boolean isDel; }