Merge branch 'feature/mall_product' of http://117.33.142.185:3000/zenghuapei/cyywl_server into feature/mall_product

pull/2/head
TianYu 2023-05-24 15:56:50 +08:00
commit 2987f82352
30 changed files with 330 additions and 170 deletions

View File

@ -24,4 +24,5 @@ public interface ApiConfigApi {
* </pre>
*/
CommonResult<String> getConfigKey( String key);
String getConfigKeyValue( String key);
}

View File

@ -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();
}
}

View File

@ -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 = "支付类型不能为空")

View File

@ -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 = "快递类型不能为空")

View File

@ -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")

View File

@ -54,6 +54,9 @@ public class AttrValueResponse implements Serializable {
@Schema(description= "原价")
private BigDecimal otPrice;
@Schema(description= "商品条码(一维码)")
private String barCode;
@Schema(description= "重量")
private BigDecimal weight;

View File

@ -45,7 +45,7 @@ public class OrderInfoVo {
private BigDecimal payFee;
@Schema(description = "地址id")
private Integer addressId;
private Long addressId;
@Schema(description = "收货人姓名(前端用)")
private String realName;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -57,7 +57,7 @@ public class ShippingTemplatesReqVO implements Serializable {
private Boolean noDelivery;
@Schema(description = "指定不送设置", required = true)
private List<ShippingTemplatesNoDeliveryRespVO> shippingTemplatesNoDeliveryRespVOS;
private ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVOS;
@Schema(description = "排序", example = "0")
@NotNull(message = "排序数字必须填写")

View File

@ -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;

View File

@ -45,5 +45,10 @@ public class ShippingTemplatesNoDeliveryDO implements Serializable {
private Integer provinceId;
/**
*
*/
private String uniqid;
}

View File

@ -43,6 +43,11 @@ public class ShippingTemplatesRegionDO implements Serializable {
*/
private Integer cityId;
/**
*
*/
private String uniqid;
private Integer provinceId;

View File

@ -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;

View File

@ -25,7 +25,7 @@ import java.util.List;
@Validated
public interface ShippingTemplatesNoDeliveryService extends IService<ShippingTemplatesNoDeliveryDO> {
void saveAll(List<ShippingTemplatesNoDeliveryRespVO> shippingTemplatesFreeRespVOList, Integer id);
void saveAll(ShippingTemplatesNoDeliveryRespVO shippingTemplatesFreeRespVOList, Integer id);
List<ShippingTemplatesNoDeliveryRespVO> getListGroup(Integer tempId);

View File

@ -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<Shipping
* @since 2020-05-20
*/
@Override
public void saveAll(List<ShippingTemplatesNoDeliveryRespVO> shippingTemplatesNoDeliveryRespVOS, Integer tempId) {
public void saveAll(ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVOS, Integer tempId) {
ArrayList<ShippingTemplatesNoDeliveryDO> 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);

View File

@ -78,6 +78,7 @@ public class ShippingTemplatesRegionServiceImpl extends ServiceImpl<ShippingTemp
for (Integer cityId: cityIdList) {
ShippingTemplatesRegionDO shippingTemplatesRegionDO = new ShippingTemplatesRegionDO();
shippingTemplatesRegionDO.setCityId(cityId);
shippingTemplatesRegionDO.setUniqid(uniqueKey);
// shippingTemplatesRegionDO.setTitle(shippingTemplatesRegionRespVO.getTitle());
shippingTemplatesRegionDO.setRenewal(shippingTemplatesRegionRespVO.getRenewal());
shippingTemplatesRegionDO.setRenewalPrice(shippingTemplatesRegionRespVO.getRenewalPrice());

View File

@ -109,12 +109,11 @@ public class ShippingTemplatesServiceImpl extends ServiceImpl<ShippingTemplatesM
shippingTemplatesFreeService.saveAll(shippingTemplatesFreeRespVOList, request.getType(), shippingTemplatesDO.getId());
}
List<ShippingTemplatesNoDeliveryRespVO> 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<ShippingTemplatesM
if(CollUtil.isNotEmpty(shippingTemplatesFreeRespVOList) && request.getAppoint()){
shippingTemplatesFreeService.saveAll(shippingTemplatesFreeRespVOList, request.getType(), shippingTemplatesDO.getId());
}
List<ShippingTemplatesNoDeliveryRespVO> 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;

View File

@ -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<Integer, MyRecord> 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<Integer, MyRecord> 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<Integer, MyRecord> 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<Integer, MyRecord> 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("请填写姓名和电话");
@ -1249,7 +1261,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());

View File

@ -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;

View File

@ -3,6 +3,6 @@
<mapper namespace="cn.iocoder.yudao.module.shop.dal.mysql.express.ShippingTemplatesFreeMapper">
<select id="getListGroup" resultType="cn.iocoder.yudao.module.shop.controller.admin.express.vo.ShippingTemplatesFreeRespVO" parameterType="integer">
SELECT group_concat(`city_id`) AS city_id, province_id, `number`, price FROM eb_shipping_templates_free where temp_id = #{tempId, jdbcType=INTEGER} GROUP BY `id` ORDER BY id ASC
SELECT group_concat(`city_id`) AS city_id, province_id, `number`, price, uniqid FROM eb_shipping_templates_free where temp_id = #{tempId, jdbcType=INTEGER} GROUP BY `uniqid`,id ORDER BY id ASC
</select>
</mapper>

View File

@ -3,6 +3,6 @@
<mapper namespace="cn.iocoder.yudao.module.shop.dal.mysql.express.ShippingTemplatesNoDeliveryMapper">
<select id="getList" resultType="cn.iocoder.yudao.module.shop.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO" parameterType="integer">
SELECT group_concat(`city_id`) AS city_id, province_id FROM eb_shipping_templates_no_delivery WHERE temp_id = #{tempId, jdbcType=INTEGER} GROUP BY `id` ORDER BY id ASC
SELECT group_concat(`city_id`) AS city_id, province_id, uniqid FROM eb_shipping_templates_no_delivery WHERE temp_id = #{tempId, jdbcType=INTEGER} GROUP BY `uniqid`,id ORDER BY id ASC
</select>
</mapper>

View File

@ -3,6 +3,6 @@
<mapper namespace="cn.iocoder.yudao.module.shop.dal.mysql.express.ShippingTemplatesRegionMapper">
<select id="getListGroup" resultType="cn.iocoder.yudao.module.shop.controller.admin.express.vo.ShippingTemplatesRegionRespVO" parameterType="integer">
SELECT group_concat(`city_id`) AS city_id, `first`, first_price, `renewal`, renewal_price FROM eb_shipping_templates_region where temp_id = #{tempId, jdbcType=INTEGER} GROUP BY `id` ORDER BY id ASC
SELECT group_concat(`city_id`) AS city_id, province_id, `first`, first_price, `renewal`, renewal_price, uniqid FROM eb_shipping_templates_region where temp_id = #{tempId, jdbcType=INTEGER} GROUP BY `uniqid`,id ORDER BY id ASC
</select>
</mapper>

View File

@ -19,7 +19,7 @@ public interface AddressApi {
AddressRespDTO getAddress(Long id, Long userId);
AddressRespDTO getById(Integer addressId);
AddressRespDTO getById(Long addressId);
/**
*

View File

@ -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);
}

View File

@ -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;
}

View File

@ -36,7 +36,7 @@ public class AddressApiImpl implements AddressApi {
}
@Override
public AddressRespDTO getById(Integer addressId) {
public AddressRespDTO getById(Long addressId) {
LambdaQueryWrapper<AddressDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(AddressDO::getId, addressId);
return AddressConvert.INSTANCE.convert02(addressMapper.selectOne(lambdaQueryWrapper));

View File

@ -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<UserAddress> 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<UserAddress> 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;
}
}

View File

@ -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;