|
|
|
@ -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("请填写姓名和电话");
|
|
|
|
|