From 3582bdd395499a8f478aee78393dc787733cef4c Mon Sep 17 00:00:00 2001 From: tangqian Date: Wed, 24 May 2023 11:02:32 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=98=AF=E5=90=A6=E8=A2=AB=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iocoder/yudao/module/member/api/user/MemberUserApiImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c165524dd..abb82eedb 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 @@ -134,7 +134,7 @@ public class MemberUserApiImpl implements MemberUserApi { throw new ServiceException("用户信息不存在!"); } - if (user.getStatus() == 0) { + if (user.getStatus() == 1) { throw new ServiceException("用户已经被禁用!"); } return user; From bb5ef9be1cd10e9017c5cf456bec8c0d95ea6d24 Mon Sep 17 00:00:00 2001 From: js199000131 <2728757160@qq.com> Date: Wed, 24 May 2023 11:09:19 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=B1=9E=E6=80=A7=E6=B7=BB=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/request/product/StoreProductAttrValueAddRequest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/product/StoreProductAttrValueAddRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/product/StoreProductAttrValueAddRequest.java index b6787e820..85ee696f5 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/product/StoreProductAttrValueAddRequest.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/product/StoreProductAttrValueAddRequest.java @@ -72,6 +72,9 @@ public class StoreProductAttrValueAddRequest implements Serializable { @DecimalMin(value = "0", message = "原价不能小于0") private BigDecimal otPrice; + @Schema(description= "商品条码(一维码)") + private String barCode; + @Schema(description= "重量", required = true) @NotNull(message = "规格属性重量不能为空") @DecimalMin(value = "0", message = "重量不能小于0") From 13e8e647263a21335c05569de7b196e6fe5a053a Mon Sep 17 00:00:00 2001 From: js199000131 <2728757160@qq.com> Date: Wed, 24 May 2023 11:34:13 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=80=BC=E5=93=8D=E5=BA=94=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/shop/response/product/AttrValueResponse.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/product/AttrValueResponse.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/product/AttrValueResponse.java index 69261c33c..5fad979cd 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/product/AttrValueResponse.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/product/AttrValueResponse.java @@ -54,6 +54,9 @@ public class AttrValueResponse implements Serializable { @Schema(description= "原价") private BigDecimal otPrice; + @Schema(description= "商品条码(一维码)") + private String barCode; + @Schema(description= "重量") private BigDecimal weight; From c82b495ca5b31b023e33cb0027593f27de963869 Mon Sep 17 00:00:00 2001 From: tangqian Date: Wed, 24 May 2023 14:12:43 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=98=AF=E5=90=A6=E8=A2=AB=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/infra/api/config/ApiConfigApi.java | 1 + .../yudao/module/infra/api/config/ApiConfigImpl.java | 12 ++++++++++++ .../shop/request/order/CreateOrderRequest.java | 4 ++-- .../request/order/OrderComputedPriceRequest.java | 4 ++-- .../module/shop/dal/dataobject/order/StoreOrder.java | 2 +- .../shop/service/order/impl/OrderServiceImpl.java | 2 +- .../iocoder/yudao/module/shop/utils/OrderUtil.java | 6 +++--- .../yudao/module/member/api/address/AddressApi.java | 2 +- .../module/member/api/address/AddressApiImpl.java | 2 +- 9 files changed, 24 insertions(+), 11 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/config/ApiConfigApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/config/ApiConfigApi.java index b72cfea4b..79492e80c 100644 --- a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/config/ApiConfigApi.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/config/ApiConfigApi.java @@ -24,4 +24,5 @@ public interface ApiConfigApi { * */ CommonResult getConfigKey( String key); + String getConfigKeyValue( String key); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/config/ApiConfigImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/config/ApiConfigImpl.java index 58e2186ad..31595375f 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/config/ApiConfigImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/config/ApiConfigImpl.java @@ -50,4 +50,16 @@ public class ApiConfigImpl implements ApiConfigApi{ } return success(config.getValue()); } + + @Override + public String getConfigKeyValue(String key) { + ConfigDO config = configService.getConfigByKey(key); + if (config == null) { + return null; + } + if (!config.getVisible()) { + throw exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE); + } + return config.getValue(); + } } diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/CreateOrderRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/CreateOrderRequest.java index 42636003e..9e9b5b330 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/CreateOrderRequest.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/CreateOrderRequest.java @@ -40,10 +40,10 @@ public class CreateOrderRequest implements Serializable { private Integer shippingType; @Schema(description = "收货地址id") - private Integer addressId; + private Long addressId; @Schema(description = "优惠券编号") - private Integer couponId; + private Long couponId; @Schema(description = "支付类型:weixin-微信支付,yue-余额支付,alipay-支付宝支付") @NotBlank(message = "支付类型不能为空") diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/OrderComputedPriceRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/OrderComputedPriceRequest.java index 92650b4db..83590a4d6 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/OrderComputedPriceRequest.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/OrderComputedPriceRequest.java @@ -32,10 +32,10 @@ public class OrderComputedPriceRequest { private String preOrderNo; @Schema(description = "地址id") - private Integer addressId; + private Long addressId; @Schema(description = "优惠券id") - private Integer couponId; + private Long couponId; @Schema(description = "快递类型: 1-快递配送,2-到店自提") @NotNull(message = "快递类型不能为空") diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrder.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrder.java index 5b95330b7..d9bbd7e5e 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrder.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrder.java @@ -74,7 +74,7 @@ public class StoreOrder implements Serializable { private BigDecimal deductionPrice; @Schema(description = "优惠券id") - private Integer couponId; + private Long couponId; @Schema(description = "优惠券金额") private BigDecimal couponPrice; 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 536346d02..cc0f5dcae 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 @@ -1249,7 +1249,7 @@ public class OrderServiceImpl implements OrderService { storeOrder.setStoreId(orderRequest.getStoreId()); } storeOrder.setTotalNum(orderInfoVo.getOrderProNum()); - storeOrder.setCouponId(Optional.ofNullable(orderRequest.getCouponId()).orElse(0)); + storeOrder.setCouponId(Optional.ofNullable(orderRequest.getCouponId()).orElse(0L)); // 订单总价 BigDecimal totalPrice = computedOrderPriceResponse.getProTotalFee().add(computedOrderPriceResponse.getFreightFee()); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/utils/OrderUtil.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/utils/OrderUtil.java index 051b9d4d7..6918fa04c 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/utils/OrderUtil.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/utils/OrderUtil.java @@ -106,13 +106,13 @@ public class OrderUtil { payType = payType.toLowerCase(); switch (payType){ case PayConstants.PAY_TYPE_WE_CHAT: - result = apiConfigApi.getConfigKey(SysConfigConstants.CONFIG_PAY_WEIXIN_OPEN).equals("1"); + result = apiConfigApi.getConfigKeyValue(SysConfigConstants.CONFIG_PAY_WEIXIN_OPEN).equals("1"); break; case PayConstants.PAY_TYPE_YUE: - result = (apiConfigApi.getConfigKey(SysConfigConstants.CONFIG_YUE_PAY_STATUS).equals("1")); + result = (apiConfigApi.getConfigKeyValue(SysConfigConstants.CONFIG_YUE_PAY_STATUS).equals("1")); break; case PayConstants.PAY_TYPE_ALI_PAY: - result = (apiConfigApi.getConfigKey(SysConfigConstants.CONFIG_ALI_PAY_STATUS).equals("1")); + result = (apiConfigApi.getConfigKeyValue(SysConfigConstants.CONFIG_ALI_PAY_STATUS).equals("1")); break; } return result; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/AddressApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/AddressApi.java index 93597ec02..299335702 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/AddressApi.java +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/AddressApi.java @@ -19,7 +19,7 @@ public interface AddressApi { AddressRespDTO getAddress(Long id, Long userId); - AddressRespDTO getById(Integer addressId); + AddressRespDTO getById(Long addressId); /** * 获取默认地址 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 e0d9ce97a..06f679c26 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 @@ -36,7 +36,7 @@ public class AddressApiImpl implements AddressApi { } @Override - public AddressRespDTO getById(Integer addressId) { + public AddressRespDTO getById(Long addressId) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(AddressDO::getId, addressId); return AddressConvert.INSTANCE.convert02(addressMapper.selectOne(lambdaQueryWrapper)); From d76f9950a1fdc2ddcd0a90ba0d89a70ae6a02ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B0=8F=E5=BC=A0?= <1085577365@qq.com> Date: Wed, 24 May 2023 15:27:08 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=90=8E=E5=8F=B0--=E8=BF=90=E8=B4=B9?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=EF=BC=9A=E9=85=8D=E9=80=81=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../express/vo/ShippingTemplatesReqVO.java | 2 +- .../express/ShippingTemplatesDO.java | 1 - .../ShippingTemplatesNoDeliveryDO.java | 5 ++++ .../express/ShippingTemplatesRegionDO.java | 5 ++++ .../ShippingTemplatesNoDeliveryService.java | 2 +- ...hippingTemplatesNoDeliveryServiceImpl.java | 27 ++++++++++--------- .../ShippingTemplatesRegionServiceImpl.java | 1 + .../impl/ShippingTemplatesServiceImpl.java | 13 +++++---- .../express/ShippingTemplatesFreeMapper.xml | 2 +- .../ShippingTemplatesNoDeliveryMapper.xml | 2 +- .../express/ShippingTemplatesRegionMapper.xml | 2 +- 11 files changed, 36 insertions(+), 26 deletions(-) diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesReqVO.java index 0bfe99592..6c1394473 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesReqVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesReqVO.java @@ -57,7 +57,7 @@ public class ShippingTemplatesReqVO implements Serializable { private Boolean noDelivery; @Schema(description = "指定不送设置", required = true) - private List shippingTemplatesNoDeliveryRespVOS; + private ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVOS; @Schema(description = "排序", example = "0") @NotNull(message = "排序数字必须填写") diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesDO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesDO.java index 90184ac0c..8a38f241e 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesDO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesDO.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.module.shop.dal.dataobject.express; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesNoDeliveryDO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesNoDeliveryDO.java index c43abbdc1..8dcbcb291 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesNoDeliveryDO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesNoDeliveryDO.java @@ -45,5 +45,10 @@ public class ShippingTemplatesNoDeliveryDO implements Serializable { private Integer provinceId; + /** + * 分组唯一值 + */ + private String uniqid; + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesRegionDO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesRegionDO.java index 91d6e49a7..efcf7d02c 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesRegionDO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/express/ShippingTemplatesRegionDO.java @@ -43,6 +43,11 @@ public class ShippingTemplatesRegionDO implements Serializable { */ private Integer cityId; + /** + * 分组唯一值 + */ + private String uniqid; + private Integer provinceId; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/ShippingTemplatesNoDeliveryService.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/ShippingTemplatesNoDeliveryService.java index ba98b4d93..a911950b4 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/ShippingTemplatesNoDeliveryService.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/ShippingTemplatesNoDeliveryService.java @@ -25,7 +25,7 @@ import java.util.List; @Validated public interface ShippingTemplatesNoDeliveryService extends IService { - void saveAll(List shippingTemplatesFreeRespVOList, Integer id); + void saveAll(ShippingTemplatesNoDeliveryRespVO shippingTemplatesFreeRespVOList, Integer id); List getListGroup(Integer tempId); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/impl/ShippingTemplatesNoDeliveryServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/impl/ShippingTemplatesNoDeliveryServiceImpl.java index 726d42337..aaf34226f 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/impl/ShippingTemplatesNoDeliveryServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/impl/ShippingTemplatesNoDeliveryServiceImpl.java @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.shop.dal.mysql.express.ShippingTemplatesNoDeliver import cn.iocoder.yudao.module.shop.service.express.ShippingTemplatesNoDeliveryService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.codec.digest.DigestUtils; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -36,22 +37,22 @@ public class ShippingTemplatesNoDeliveryServiceImpl extends ServiceImpl shippingTemplatesNoDeliveryRespVOS, Integer tempId) { + public void saveAll(ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVOS, Integer tempId) { ArrayList shippingTemplatesNoDeliveryDOS = new ArrayList<>(); delete(tempId); - for (ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVO : shippingTemplatesNoDeliveryRespVOS) { - if(shippingTemplatesNoDeliveryRespVO.getCityId().equals("all") || shippingTemplatesNoDeliveryRespVO.getCityId().equals("0")){ - cityIdList = getCityIdList(); - }else{ - cityIdList = StrUtils.stringToArray(shippingTemplatesNoDeliveryRespVO.getCityId()); - } - for (Integer cityId: cityIdList) { - ShippingTemplatesNoDeliveryDO shippingTemplatesNoDeliveryDO = new ShippingTemplatesNoDeliveryDO(); - shippingTemplatesNoDeliveryDO.setCityId(cityId); - shippingTemplatesNoDeliveryDO.setTempId(tempId); - shippingTemplatesNoDeliveryDOS.add(shippingTemplatesNoDeliveryDO); - } + String uniqueKey = DigestUtils.md5Hex(shippingTemplatesNoDeliveryRespVOS.toString()); + if(shippingTemplatesNoDeliveryRespVOS.getCityId().equals("all") || shippingTemplatesNoDeliveryRespVOS.getCityId().equals("0")){ + cityIdList = getCityIdList(); + }else{ + cityIdList = StrUtils.stringToArray(shippingTemplatesNoDeliveryRespVOS.getCityId()); + } + for (Integer cityId: cityIdList) { + ShippingTemplatesNoDeliveryDO shippingTemplatesNoDeliveryDO = new ShippingTemplatesNoDeliveryDO(); + shippingTemplatesNoDeliveryDO.setCityId(cityId); + shippingTemplatesNoDeliveryDO.setUniqid(uniqueKey); + shippingTemplatesNoDeliveryDO.setTempId(tempId); + shippingTemplatesNoDeliveryDOS.add(shippingTemplatesNoDeliveryDO); } //批量保存模板数据 saveBatch(shippingTemplatesNoDeliveryDOS); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/impl/ShippingTemplatesRegionServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/impl/ShippingTemplatesRegionServiceImpl.java index dbacf1fce..1ddad2340 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/impl/ShippingTemplatesRegionServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/express/impl/ShippingTemplatesRegionServiceImpl.java @@ -78,6 +78,7 @@ public class ShippingTemplatesRegionServiceImpl extends ServiceImpl shippingTemplatesNoDeliveryRespVOList = request.getShippingTemplatesNoDeliveryRespVOS(); - if(null != shippingTemplatesNoDeliveryRespVOList && shippingTemplatesNoDeliveryRespVOList.size() > 0){ - shippingTemplatesNoDeliveryService.saveAll(shippingTemplatesNoDeliveryRespVOList, shippingTemplatesDO.getId()); + ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVO = request.getShippingTemplatesNoDeliveryRespVOS(); + if(!ObjectUtil.isNull(shippingTemplatesNoDeliveryRespVO)){ + shippingTemplatesNoDeliveryService.saveAll(shippingTemplatesNoDeliveryRespVO, shippingTemplatesDO.getId()); } - return true; } @@ -169,9 +168,9 @@ public class ShippingTemplatesServiceImpl extends ServiceImpl shippingTemplatesNoDeliveryRespVOList = request.getShippingTemplatesNoDeliveryRespVOS(); - if(CollUtil.isNotEmpty(shippingTemplatesNoDeliveryRespVOList)){ - shippingTemplatesNoDeliveryService.saveAll(shippingTemplatesNoDeliveryRespVOList, shippingTemplatesDO.getId()); + ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVO= request.getShippingTemplatesNoDeliveryRespVOS(); + if(ObjectUtil.isNotNull(shippingTemplatesNoDeliveryRespVO)){ + shippingTemplatesNoDeliveryService.saveAll(shippingTemplatesNoDeliveryRespVO, shippingTemplatesDO.getId()); } return true; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesFreeMapper.xml b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesFreeMapper.xml index d27a6d8f0..76ef60c67 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesFreeMapper.xml +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesFreeMapper.xml @@ -3,6 +3,6 @@ diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesNoDeliveryMapper.xml b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesNoDeliveryMapper.xml index 06da0e77c..680a2f38a 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesNoDeliveryMapper.xml +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesNoDeliveryMapper.xml @@ -3,6 +3,6 @@ diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml index d31a41ad7..05bf8333c 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml @@ -3,6 +3,6 @@ From a9d146cba16506ce7e9588a355f6906747ae38fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B0=8F=E5=BC=A0?= <1085577365@qq.com> Date: Wed, 24 May 2023 15:40:15 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=90=8E=E5=8F=B0--=E8=BF=90=E8=B4=B9?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=EF=BC=9A=E9=85=8D=E9=80=81=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/express/vo/ShippingTemplatesFreeRespVO.java | 3 +++ .../admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java | 3 ++- .../admin/express/vo/ShippingTemplatesRegionRespVO.java | 3 +++ .../resources/mapper/express/ShippingTemplatesRegionMapper.xml | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesFreeRespVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesFreeRespVO.java index 5a037a619..b535a5a8b 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesFreeRespVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesFreeRespVO.java @@ -48,4 +48,7 @@ public class ShippingTemplatesFreeRespVO implements Serializable { @NotNull(message = "请填写包邮金额") @DecimalMin(value = "0", message = "包邮金额不能低于0") private BigDecimal price; + + @Schema(description = "分组唯一值", required = true) + private String uniqid; } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java index 07e9f152a..2dbd2744c 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java @@ -34,7 +34,8 @@ public class ShippingTemplatesNoDeliveryRespVO implements Serializable { @NotNull(message = "请选择城市") private String cityId; - + @Schema(description = "分组唯一值", required = true) + private String uniqid; @Schema(description = "省ID, 多个逗号分割。 全国 all", required = true, example = "1,2,3,4") private String provinceId; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesRegionRespVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesRegionRespVO.java index d02fb3fd7..4bd4be343 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesRegionRespVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/express/vo/ShippingTemplatesRegionRespVO.java @@ -55,4 +55,7 @@ public class ShippingTemplatesRegionRespVO implements Serializable { @DecimalMin(value = "0.1", message = "续件运费金额不能低于0.1") private BigDecimal renewalPrice; + @Schema(description = "分组唯一值", required = true) + private String uniqid; + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml index 05bf8333c..063f68943 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml @@ -3,6 +3,6 @@ From 8a595cbef00cc2ef6afa883b23061d5be9e063f0 Mon Sep 17 00:00:00 2001 From: tangqian Date: Wed, 24 May 2023 15:41:00 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=E5=95=86=E5=9F=8E=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/shop/vo/order/OrderInfoVo.java | 2 +- .../service/order/impl/OrderServiceImpl.java | 272 +++++++++--------- .../member/api/address/UserAddressApi.java | 21 ++ .../api/address/dto/UserAddressRespDTO.java | 41 +++ .../api/address/UserAddressApiImpl.java | 50 ++++ 5 files changed, 255 insertions(+), 131 deletions(-) create mode 100644 yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/UserAddressApi.java create mode 100644 yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/UserAddressRespDTO.java create mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/UserAddressApiImpl.java diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/vo/order/OrderInfoVo.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/vo/order/OrderInfoVo.java index 06cd6a8f7..ce6a82caa 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/vo/order/OrderInfoVo.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/vo/order/OrderInfoVo.java @@ -45,7 +45,7 @@ public class OrderInfoVo { private BigDecimal payFee; @Schema(description = "地址id") - private Integer addressId; + private Long addressId; @Schema(description = "收货人姓名(前端用)") private String realName; 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 cc0f5dcae..9879a8370 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 @@ -6,7 +6,9 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.module.member.api.address.AddressApi; +import cn.iocoder.yudao.module.member.api.address.UserAddressApi; import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; +import cn.iocoder.yudao.module.member.api.address.dto.UserAddressRespDTO; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.shop.constants.PayConstants; @@ -19,14 +21,21 @@ import cn.iocoder.yudao.module.shop.constants.SysConfigConstants; import cn.iocoder.yudao.module.shop.convert.order.StoreOrderConvert; import cn.iocoder.yudao.module.shop.convert.order.StoreOrderOneConvert; import cn.iocoder.yudao.module.shop.dal.dataobject.cat.StoreCart; +import cn.iocoder.yudao.module.shop.dal.dataobject.express.ShippingTemplatesDO; +import cn.iocoder.yudao.module.shop.dal.dataobject.express.ShippingTemplatesFreeDO; +import cn.iocoder.yudao.module.shop.dal.dataobject.express.ShippingTemplatesRegionDO; import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder; import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrderInfo; import cn.iocoder.yudao.module.shop.dal.dataobject.product.StoreProduct; import cn.iocoder.yudao.module.shop.dal.dataobject.product.StoreProductAttrValue; +import cn.iocoder.yudao.module.shop.dal.mysql.express.ShippingTemplatesMapper; import cn.iocoder.yudao.module.shop.dal.mysql.order.StoreOrderMapper; import cn.iocoder.yudao.module.shop.request.order.*; import cn.iocoder.yudao.module.shop.request.product.StoreProductReplyAddRequest; import cn.iocoder.yudao.module.shop.response.order.*; +import cn.iocoder.yudao.module.shop.service.express.ShippingTemplatesFreeService; +import cn.iocoder.yudao.module.shop.service.express.ShippingTemplatesRegionService; +import cn.iocoder.yudao.module.shop.service.express.ShippingTemplatesService; import cn.iocoder.yudao.module.shop.service.order.OrderService; import cn.iocoder.yudao.module.shop.service.order.StoreOrderInfoService; import cn.iocoder.yudao.module.shop.service.order.StoreOrderService; @@ -110,16 +119,18 @@ public class OrderServiceImpl implements OrderService { @Autowired private AddressApi addressApi; + @Autowired + private UserAddressApi userAddressApi; -// @Autowired -// private ShippingTemplatesApi shippingTemplatesApi; -// -// @Autowired -// private ShippingTemplatesFreeApi shippingTemplatesFreeApi; -// -// @Autowired -// private ShippingTemplatesRegionApi shippingTemplatesRegionApi; + @Autowired + private ShippingTemplatesService shippingTemplatesApi; + + @Autowired + private ShippingTemplatesFreeService shippingTemplatesFreeApi; + + @Autowired + private ShippingTemplatesRegionService shippingTemplatesRegionApi; @Autowired private StoreProductService storeProductService; @@ -601,116 +612,116 @@ 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); + private void getFreightFee(OrderInfoVo orderInfoVo, UserAddressRespDTO 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); } /** @@ -740,22 +751,22 @@ public class OrderServiceImpl implements OrderService { int orderProNum = orderInfoVo.getOrderDetailList().stream().mapToInt(OrderInfoDetailVo::getPayNum).sum(); orderInfoVo.setOrderProNum(orderProNum); // 获取默认地址 - AddressRespDTO userAddress = addressApi.getDefaultByUid(user.getId()); + UserAddressRespDTO userAddress = userAddressApi.getDefaultByUid(user.getId()); if (ObjectUtil.isNotNull(userAddress)) { // 计算运费 getFreightFee(orderInfoVo, userAddress); orderInfoVo.setAddressId(userAddress.getId()); - orderInfoVo.setRealName(userAddress.getName()); - orderInfoVo.setPhone(userAddress.getMobile()); + orderInfoVo.setRealName(userAddress.getRealName()); + orderInfoVo.setPhone(userAddress.getPhone()); orderInfoVo.setProvince(userAddress.getProvince()); orderInfoVo.setCity(userAddress.getCity()); orderInfoVo.setDistrict(userAddress.getDistrict()); - orderInfoVo.setDetail(userAddress.getDetailAddress()); + orderInfoVo.setDetail(userAddress.getDetail()); } else { orderInfoVo.setFreightFee(BigDecimal.ZERO); } // 实际支付金额 - orderInfoVo.setPayFee(orderInfoVo.getProTotalFee().add(orderInfoVo.getFreightFee())); + orderInfoVo.setPayFee(orderInfoVo.getProTotalFee().add(BigDecimal.ZERO)); //用户剩余积分 //用户剩余经验 // 缓存订单 @@ -1033,7 +1044,7 @@ public class OrderServiceImpl implements OrderService { // 快递配送,无地址 priceResponse.setFreightFee(BigDecimal.ZERO); } else {// 快递配送,有地址 - AddressRespDTO userAddress = addressApi.getById(request.getAddressId()); + UserAddressRespDTO userAddress = userAddressApi.getById(request.getAddressId()); if (ObjectUtil.isNull(userAddress)) { priceResponse.setFreightFee(BigDecimal.ZERO); } else { @@ -1041,7 +1052,7 @@ public class OrderServiceImpl implements OrderService { priceResponse.setFreightFee(orderInfoVo.getFreightFee()); } } - // 计算优惠券金额 + // 计算优惠券金额 现在不开启优惠卷功能 // if (orderInfoVo.getProTotalFee().compareTo(storeCouponUser.getMoney()) <= 0) { // priceResponse.setCouponFee(orderInfoVo.getProTotalFee()); @@ -1056,6 +1067,7 @@ public class OrderServiceImpl implements OrderService { // priceResponse.setCouponFee(storeCouponUser.getMoney()); // } + priceResponse.setProTotalFee(orderInfoVo.getProTotalFee()); // 积分部分 // 使用积分 @@ -1118,13 +1130,13 @@ public class OrderServiceImpl implements OrderService { String userAddressStr = ""; if (orderRequest.getShippingType() == 1) { // 快递配送 if (orderRequest.getAddressId() <= 0) throw new ServiceException("请选择收货地址"); - AddressRespDTO userAddress = addressApi.getById(orderRequest.getAddressId()); - if (ObjectUtil.isNull(userAddress) || userAddress.getDeleted()) { + UserAddressRespDTO userAddress = userAddressApi.getById(orderRequest.getAddressId()); + if (ObjectUtil.isNull(userAddress)) { throw new ServiceException("收货地址有误"); } - orderRequest.setRealName(userAddress.getName()); - orderRequest.setPhone(userAddress.getMobile()); - userAddressStr = userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getDetailAddress(); + orderRequest.setRealName(userAddress.getRealName()); + orderRequest.setPhone(userAddress.getPhone()); + userAddressStr = userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getDetail(); }else if (orderRequest.getShippingType() == 2) { // 到店自提 if (StringUtils.isBlank(orderRequest.getRealName()) || StringUtils.isBlank(orderRequest.getPhone())) { throw new ServiceException("请填写姓名和电话"); diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/UserAddressApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/UserAddressApi.java new file mode 100644 index 000000000..aa41dfa41 --- /dev/null +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/UserAddressApi.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.member.api.address; + +import cn.iocoder.yudao.module.member.api.address.dto.UserAddressRespDTO; + +/** + * @Title:UserAddressApi + * @Description: TODO + * @author: tangqian + * @date: 2023/5/24 14:39 + * @version: V1.0.0 + */ +public interface UserAddressApi { + + UserAddressRespDTO getById(Long addressId); + + /** + * 获取默认地址 + * @return UserAddress + */ + UserAddressRespDTO getDefaultByUid(Long uid); +} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/UserAddressRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/UserAddressRespDTO.java new file mode 100644 index 000000000..0c9e9aa20 --- /dev/null +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/UserAddressRespDTO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.member.api.address.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +/** + * @Title:UserAddressRespDTO + * @Description: TODO + * @author: tangqian + * @date: 2023/5/24 14:46 + * @version: V1.0.0 + */ +@Data +public class UserAddressRespDTO { + private Long id; + + private Long userId; + + private String realName; + + private String phone; + + private String province; + + private String city; + + private Integer cityId; + + private String district; + + private String detail; + + private Integer postCode; + + private String longitude; + + private String latitude; + + private Boolean isDefault; +} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/UserAddressApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/UserAddressApiImpl.java new file mode 100644 index 000000000..1ede49b52 --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/UserAddressApiImpl.java @@ -0,0 +1,50 @@ +package cn.iocoder.yudao.module.member.api.address; + +import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; +import cn.iocoder.yudao.module.member.api.address.dto.UserAddressRespDTO; +import cn.iocoder.yudao.module.member.convert.address.AddressConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.address.AddressDO; +import cn.iocoder.yudao.module.member.dal.dataobject.address.UserAddress; +import cn.iocoder.yudao.module.member.dal.mysql.address.UserAddressMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +/** + * @Title:UserAddressApiImpl + * @Description: TODO + * @author: tangqian + * @date: 2023/5/24 14:40 + * @version: V1.0.0 + */ +@Service +@Validated +public class UserAddressApiImpl implements UserAddressApi{ + @Autowired + private UserAddressMapper addressMapper; + @Override + public UserAddressRespDTO getById(Long addressId) { + UserAddressRespDTO respDTO = new UserAddressRespDTO(); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(UserAddress::getId, addressId); + UserAddress userAddress = addressMapper.selectOne(lambdaQueryWrapper); + BeanUtils.copyProperties(userAddress,respDTO); + return respDTO; + } + + @Override + public UserAddressRespDTO getDefaultByUid(Long uid) { + UserAddressRespDTO respDTO = new UserAddressRespDTO(); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.eq(UserAddress::getIsDefault, true); + lambdaQueryWrapper.eq(UserAddress::getUserId, uid); + UserAddress userAddress = addressMapper.selectOne(lambdaQueryWrapper); + if (null != userAddress) { + BeanUtils.copyProperties(userAddress,respDTO); + } + return respDTO; + } +}