下单修改
This commit is contained in:
1 parent
c59a491bb7
commit
7a960dad8b
11 files changed
+103
-49
No files matched your search
+1
@@ -53,4 +53,5 @@ public interface ProductSpuApi {
|
||||
*/
|
||||
ProductSpuRespDTO getSpu(Long id);
|
||||
|
||||
List<ProductSpuRespDTO> getSpuListByDeviceid(String deviceId);
|
||||
}
|
||||
+6
@@ -31,6 +31,12 @@ public class ProductSpuRespDTO {
|
||||
* 商品分类编号
|
||||
*/
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 商品封面图
|
||||
*/
|
||||
|
||||
+7
@@ -9,6 +9,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -42,4 +43,10 @@ public class ProductSpuApiImpl implements ProductSpuApi {
|
||||
return BeanUtils.toBean(spu, ProductSpuRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSpuRespDTO> getSpuListByDeviceid(String deviceId) {
|
||||
List<ProductSpuDO> spus = spuService.getSpuListByDeviceid(deviceId);
|
||||
return BeanUtils.toBean(spus, ProductSpuRespDTO.class);
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -223,4 +223,10 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
||||
.eq(ProductSpuDO::getId, updateReqVO.getId());
|
||||
return update(null, updateWrapper);
|
||||
}
|
||||
|
||||
default List<ProductSpuDO> getSpuListByDeviceid(String deviceId){
|
||||
LambdaQueryWrapperX<ProductSpuDO> query = new LambdaQueryWrapperX<ProductSpuDO>()
|
||||
.eqIfPresent(ProductSpuDO::getDeviceId, deviceId);
|
||||
return selectList(query);
|
||||
}
|
||||
}
|
||||
+2
@@ -150,4 +150,6 @@ public interface ProductSpuService {
|
||||
List<ProductSpuDO> getSpuListByCreator(String creator);
|
||||
|
||||
void updateSkuStock(ProductSkuUpdateStockReqVO updateReqVO);
|
||||
|
||||
List<ProductSpuDO> getSpuListByDeviceid(String deviceId);
|
||||
}
|
||||
+5
@@ -203,6 +203,11 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSpuDO> getSpuListByDeviceid(String deviceId) {
|
||||
return productSpuMapper.getSpuListByDeviceid(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteSpu(Long id) {
|
||||
|
||||
+5
-1
@@ -1115,10 +1115,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties())
|
||||
.setWeight(sku.getWeight()).setVolume(sku.getVolume());
|
||||
//是否有机器号
|
||||
AdminUserRespDTO adminUser = adminUserApi.getUser(Long.valueOf(spu.getCreator()));
|
||||
/* AdminUserRespDTO adminUser = adminUserApi.getUser(Long.valueOf(spu.getCreator()));
|
||||
if (null!=adminUser && null!=adminUser.getDeviceId()){
|
||||
// sku 设备信息
|
||||
orderItem.setDeviceId(adminUser.getDeviceId());
|
||||
}*/
|
||||
if (null!=spu.getDeviceId()){
|
||||
// sku 设备信息
|
||||
orderItem.setDeviceId(spu.getDeviceId());
|
||||
}
|
||||
if (null!=sku.getBarCode()){
|
||||
// sku 条码
|
||||
|
||||
+22
-13
@@ -103,17 +103,26 @@ public class TradeDeviceOrderHandler implements TradeOrderHandler {
|
||||
//订单中包含非提货柜商品
|
||||
log.error("订单中包含非提货柜商品");
|
||||
}else {
|
||||
//判断是不是有不同机器的订单(一个创建人是一台机器)
|
||||
//判断是不是有不同机器的订单
|
||||
boolean isSingleCreator = spuList.stream()
|
||||
.map(ProductSpuRespDTO::getCreator) //获取每个商品的Creator
|
||||
.distinct() //去重Creator
|
||||
.count() == 1; // 判断是否只有一个唯一的创建人
|
||||
.map(ProductSpuRespDTO::getDeviceId) //获取每个商品的DeviceId
|
||||
.distinct() //去重
|
||||
.count() == 1; // 判断是否只有一个设备
|
||||
if (isSingleCreator) {
|
||||
// 只有一个Creator的逻辑处理
|
||||
System.out.println("订单明细中只有一个商品创建人");
|
||||
System.out.println("订单明细中只有一个设备");
|
||||
//查询商品创建人的设备IMEI
|
||||
AdminUserRespDTO user = adminUserApi.getUser(Long.valueOf(spuList.get(0).getCreator()));
|
||||
if (user == null|| user.getDeviceId() == null){
|
||||
// AdminUserRespDTO user = adminUserApi.getUser(Long.valueOf(spuList.get(0).getCreator()));
|
||||
// if (user == null|| user.getDeviceId() == null){
|
||||
// return;
|
||||
// }
|
||||
String deviceId = spuList.get(0).getDeviceId();
|
||||
if (deviceId == null){
|
||||
//imei为空
|
||||
log.error("订单:{},商品的设备编号为空",order.getNo());
|
||||
deviceLogSaveReqVO.setDeviceStatus(500);
|
||||
deviceLogSaveReqVO.setContent("[出货异常]原因:商品的设备编号为空");
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
return;
|
||||
}
|
||||
//获取商品通道
|
||||
@@ -132,7 +141,7 @@ public class TradeDeviceOrderHandler implements TradeOrderHandler {
|
||||
.count() == 1; // 判断是否只有一个唯一的通道类型
|
||||
if (isSingleCabinetType) {
|
||||
DispenseRequestBo request = new DispenseRequestBo();
|
||||
request.setDeviceId(user.getDeviceId());
|
||||
request.setDeviceId(deviceId);
|
||||
StringBuilder message= new StringBuilder(skuList.get(0).getCabinetType() + ",");
|
||||
//遍历订单明细
|
||||
for (int i = 0; i < orderItems.size(); i++) {
|
||||
@@ -144,7 +153,7 @@ public class TradeDeviceOrderHandler implements TradeOrderHandler {
|
||||
}
|
||||
//记录最后一次出货的货道
|
||||
if (i == orderItems.size() - 1) {
|
||||
int d = deviceApi.updateDeviceLastChannel(user.getDeviceId(), sku.getCabinetChannel());
|
||||
int d = deviceApi.updateDeviceLastChannel(deviceId, sku.getCabinetChannel());
|
||||
}
|
||||
}
|
||||
request.setMessage(message.toString());
|
||||
@@ -174,14 +183,14 @@ public class TradeDeviceOrderHandler implements TradeOrderHandler {
|
||||
if (body.getCode() == 0) {
|
||||
System.out.println("出货成功!详情: " + body.getData());
|
||||
|
||||
deviceLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(body.getCode());
|
||||
deviceLogSaveReqVO.setContent(body.getData());
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
} else {
|
||||
System.out.println("操作失败!原因: " + body.getMsg());
|
||||
log.error("订单--{}:[出货失败]:原因: {}",order.getNo(), body.getMsg());
|
||||
deviceLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(body.getCode());
|
||||
deviceLogSaveReqVO.setContent(body.getData());
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
@@ -197,7 +206,7 @@ public class TradeDeviceOrderHandler implements TradeOrderHandler {
|
||||
} catch (Exception e) {
|
||||
System.err.println("请求异常: " + e.getMessage());
|
||||
log.error("订单--{}:[出货异常]:原因: {}",order.getNo(), e.getMessage());
|
||||
deviceLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(500);
|
||||
deviceLogSaveReqVO.setContent("[出货异常]原因:"+e.getMessage());
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
@@ -205,7 +214,7 @@ public class TradeDeviceOrderHandler implements TradeOrderHandler {
|
||||
}else {
|
||||
System.out.println("订单明细中包含多个通道类型");
|
||||
log.error("订单:{},明细中包含多个通道类型",order.getNo());
|
||||
deviceLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(500);
|
||||
deviceLogSaveReqVO.setContent("[出货异常]原因:订单明细中包含多个通道类型");
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
|
||||
+20
-11
@@ -100,18 +100,27 @@ public class TradeGiftVoucherOrderHandler implements TradeOrderHandler {
|
||||
//订单中包含非提货柜商品
|
||||
log.info("订单中包含非提货柜商品");
|
||||
}else {
|
||||
//判断是不是有不同机器的订单(一个创建人是一台机器)
|
||||
//判断是不是有不同机器的订单
|
||||
boolean isSingleCreator = spuList.stream()
|
||||
.map(ProductSpuRespDTO::getCreator) //获取每个商品的Creator
|
||||
.map(ProductSpuRespDTO::getDeviceId) //获取每个商品的DeviceId
|
||||
.distinct() //去重Creator
|
||||
.count() == 1; // 判断是否只有一个唯一的创建人
|
||||
.count() == 1; // 判断是否只有一个设备
|
||||
if (isSingleCreator) {
|
||||
// 只有一个Creator的逻辑处理
|
||||
System.out.println("订单明细中只有一个商品创建人");
|
||||
System.out.println("订单明细中只有一个设备");
|
||||
//查询商品创建人的设备IMEI
|
||||
AdminUserRespDTO user = adminUserApi.getUser(Long.valueOf(spuList.get(0).getCreator()));
|
||||
/* AdminUserRespDTO user = adminUserApi.getUser(Long.valueOf(spuList.get(0).getCreator()));
|
||||
if (user == null|| user.getDeviceId() == null){
|
||||
return;
|
||||
}*/
|
||||
String deviceId = spuList.get(0).getDeviceId();
|
||||
if (deviceId == null){
|
||||
//imei为空
|
||||
log.error("订单:{},商品的设备编号为空",order.getNo());
|
||||
deviceLogSaveReqVO.setDeviceStatus(500);
|
||||
deviceLogSaveReqVO.setContent("[出货异常]原因:商品的设备编号为空");
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
return;
|
||||
}
|
||||
//获取商品通道
|
||||
List<Long> skuIds = orderItems.stream()
|
||||
@@ -129,7 +138,7 @@ public class TradeGiftVoucherOrderHandler implements TradeOrderHandler {
|
||||
.count() == 1; // 判断是否只有一个唯一的创建人
|
||||
if (isSingleCabinetType) {
|
||||
DispenseRequestBo request = new DispenseRequestBo();
|
||||
request.setDeviceId(user.getDeviceId());
|
||||
request.setDeviceId(deviceId);
|
||||
StringBuilder message= new StringBuilder(skuList.get(0).getCabinetType() + ",");
|
||||
//遍历订单明细
|
||||
for (int i = 0; i < orderItems.size(); i++) {
|
||||
@@ -141,7 +150,7 @@ public class TradeGiftVoucherOrderHandler implements TradeOrderHandler {
|
||||
}
|
||||
//记录最后一次出货的货道
|
||||
if (i == orderItems.size() - 1) {
|
||||
int d = deviceApi.updateDeviceLastChannel(user.getDeviceId(), sku.getCabinetChannel());
|
||||
int d = deviceApi.updateDeviceLastChannel(deviceId, sku.getCabinetChannel());
|
||||
}
|
||||
}
|
||||
request.setMessage(message.toString());
|
||||
@@ -170,14 +179,14 @@ public class TradeGiftVoucherOrderHandler implements TradeOrderHandler {
|
||||
System.out.println("响应结果: " + body);
|
||||
if (body.getCode() == 0) {
|
||||
System.out.println("出货成功!详情: " + body.getData());
|
||||
deviceLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(body.getCode());
|
||||
deviceLogSaveReqVO.setContent(body.getData());
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
} else {
|
||||
System.out.println("操作失败!原因: " + body.getMsg());
|
||||
log.error("订单--{}:[出货失败]:原因: {}",order.getNo(), body.getMsg());
|
||||
deviceLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(body.getCode());
|
||||
deviceLogSaveReqVO.setContent(body.getData());
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
@@ -193,7 +202,7 @@ public class TradeGiftVoucherOrderHandler implements TradeOrderHandler {
|
||||
} catch (Exception e) {
|
||||
System.err.println("请求异常: " + e.getMessage());
|
||||
log.error("订单--{}:[出货异常]:原因: {}",order.getNo(), e.getMessage());
|
||||
deviceLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(500);
|
||||
deviceLogSaveReqVO.setContent("[出货异常]原因:"+e.getMessage());
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
@@ -201,7 +210,7 @@ public class TradeGiftVoucherOrderHandler implements TradeOrderHandler {
|
||||
}else {
|
||||
System.out.println("订单明细中包含多个通道类型");
|
||||
log.error("订单:{},明细中包含多个通道类型",order.getNo());
|
||||
deviceLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(500);
|
||||
deviceLogSaveReqVO.setContent("[出货异常]原因:订单明细中包含多个通道类型");
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
|
||||
+23
-17
@@ -14,8 +14,6 @@ import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO
|
||||
import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi;
|
||||
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeProductSettlementRespVO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||
@@ -29,7 +27,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -57,8 +57,8 @@ public class TradePriceServiceImpl implements TradePriceService {
|
||||
@Resource
|
||||
private DeviceApi deviceApi;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
// @Resource
|
||||
// private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private List<TradePriceCalculator> priceCalculators;
|
||||
@@ -73,17 +73,17 @@ public class TradePriceServiceImpl implements TradePriceService {
|
||||
// 1.2 获得商品 SPU 数组
|
||||
List<ProductSpuRespDTO> spuList = checkSpuList(skuList);
|
||||
|
||||
List<Long> creators = spuList.stream()
|
||||
/*List<Long> creators = spuList.stream()
|
||||
.map(ProductSpuRespDTO::getCreator)
|
||||
.filter(Objects::nonNull) // 防止空指针
|
||||
.map(Long::valueOf) // String 转 Long
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<AdminUserRespDTO> userList = adminUserApi.getUserList(creators);
|
||||
List<AdminUserRespDTO> userList = adminUserApi.getUserList(creators);*/
|
||||
|
||||
// 2.1 计算价格
|
||||
TradePriceCalculateRespBO calculateRespBO = TradePriceCalculatorHelper
|
||||
.buildCalculateResp(calculateReqBO, spuList, skuList,userList);
|
||||
.buildCalculateResp(calculateReqBO, spuList, skuList);
|
||||
priceCalculators.forEach(calculator -> calculator.calculate(calculateReqBO, calculateRespBO));
|
||||
// 2.2 如果最终支付金额小于等于 0,则抛出业务异常
|
||||
/*if (calculateReqBO.getPointActivityId() == null // 积分订单,允许支付金额为 0
|
||||
@@ -130,7 +130,7 @@ public class TradePriceServiceImpl implements TradePriceService {
|
||||
discountActivityApi.getMatchDiscountProductListBySkuIds(convertSet(allSkuList, ProductSkuRespDTO::getId)),
|
||||
DiscountProductRespDTO::getSkuId);
|
||||
// 1.4 获得满减送活动
|
||||
List<RewardActivityMatchRespDTO> rewardActivityMap = rewardActivityApi.getMatchRewardActivityListBySpuIds(spuIds);
|
||||
List<RewardActivityMatchRespDTO> rewardActivityMap = rewardActivityApi.getMatchRewardActivityListBySpuIds(spuIds);
|
||||
|
||||
// 2. 价格计算
|
||||
return convertList(spuIds, spuId -> {
|
||||
@@ -180,11 +180,11 @@ public class TradePriceServiceImpl implements TradePriceService {
|
||||
.map(TradePriceCalculateSummaryReqBO.Item::getDeviceId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<DeviceRespDto> devices =deviceApi.getDeviceByDeviceIds(deviceIds);
|
||||
List<DeviceRespDto> devices = deviceApi.getDeviceByDeviceIds(deviceIds);
|
||||
|
||||
// 2.1 计算价格
|
||||
TradePriceCalculateSummaryRespBO calculateRespBO = TradePriceCalculatorHelper
|
||||
.buildCalculateSummaryResp(calculateReqBO, spuList, skuList,devices);
|
||||
.buildCalculateSummaryResp(calculateReqBO, spuList, skuList, devices);
|
||||
priceCalculators.forEach(calculator -> calculator.summaryCalculate(calculateReqBO, calculateRespBO));
|
||||
// 2.2 如果最终支付金额小于等于 0,则抛出业务异常
|
||||
/*if (calculateReqBO.getPointActivityId() == null // 积分订单,允许支付金额为 0
|
||||
@@ -206,16 +206,22 @@ public class TradePriceServiceImpl implements TradePriceService {
|
||||
if (!isSingleCreator) {
|
||||
System.out.println("订单明细中涉及多台贩卖机");
|
||||
throw exception(SUMMARY_NOT_DUPLICATE);
|
||||
}
|
||||
}
|
||||
// 只有一个Creator的逻辑处理
|
||||
System.out.println("订单明细中只有一台贩卖机");
|
||||
//查询商品创建人的设备IMEI
|
||||
AdminUserRespDTO user = adminUserApi.getUserByDeviceid(calculateReqBO.getItems().get(0).getDeviceId());
|
||||
if (user == null|| user.getDeviceId() == null){
|
||||
// AdminUserRespDTO user = adminUserApi.getUserByDeviceid(calculateReqBO.getItems().get(0).getDeviceId());
|
||||
List<ProductSpuRespDTO> spus = productSpuApi.getSpuListByDeviceid(calculateReqBO.getItems().get(0).getDeviceId());
|
||||
if (spus == null || spus.size() <= 0) {
|
||||
throw exception(DEVICE_NOT_EXISTS);
|
||||
}
|
||||
// 获得商品 SKU 数组
|
||||
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListByCreator(user.getId())
|
||||
List<Long> spuIds = spus.stream()
|
||||
.map(ProductSpuRespDTO::getId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
// 获得商品 SKU 数组
|
||||
// List<ProductSkuRespDTO> skus = productSkuApi.getSkuListByCreator(user.getId())
|
||||
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(spuIds)
|
||||
.stream()
|
||||
.filter(sku -> sku.getStock() > 0)
|
||||
.sorted(Comparator.comparing(sku -> {
|
||||
@@ -250,7 +256,7 @@ public class TradePriceServiceImpl implements TradePriceService {
|
||||
if (stock < count) {
|
||||
throw exception(SKU_STOCK_NOT_ENOUGH);
|
||||
}
|
||||
DeviceRespDto device =deviceApi.getDeviceByDeviceId(deviceCountMap.get(barCode));
|
||||
DeviceRespDto device = deviceApi.getDeviceByDeviceId(deviceCountMap.get(barCode));
|
||||
if (device == null) {
|
||||
throw exception(DEVICE_NOT_EXISTS_INFO, deviceCountMap.get(barCode));
|
||||
}
|
||||
|
||||
+6
-7
@@ -44,8 +44,7 @@ public class TradePriceCalculatorHelper {
|
||||
|
||||
public static TradePriceCalculateRespBO buildCalculateResp(TradePriceCalculateReqBO param,
|
||||
List<ProductSpuRespDTO> spuList,
|
||||
List<ProductSkuRespDTO> skuList,
|
||||
List<AdminUserRespDTO> userList) {
|
||||
List<ProductSkuRespDTO> skuList) {
|
||||
// 创建 PriceCalculateRespDTO 对象
|
||||
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO();
|
||||
result.setType(getOrderType(param)).setPromotions(new ArrayList<>()).setGiveCouponTemplateCounts(new LinkedHashMap<>());
|
||||
@@ -55,11 +54,11 @@ public class TradePriceCalculatorHelper {
|
||||
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||
Map<Long, ProductSkuRespDTO> skuMap = convertMap(skuList, ProductSkuRespDTO::getId);
|
||||
// 构建用户ID到deviceId的映射
|
||||
Map<Long, String> userDeviceMap = userList.stream()
|
||||
/* Map<Long, String> userDeviceMap = userList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
AdminUserRespDTO::getId, // key: 用户ID
|
||||
AdminUserRespDTO::getDeviceId // value: deviceId
|
||||
));
|
||||
));*/
|
||||
param.getItems().forEach(item -> {
|
||||
ProductSkuRespDTO sku = skuMap.get(item.getSkuId());
|
||||
if (sku == null) {
|
||||
@@ -81,10 +80,10 @@ public class TradePriceCalculatorHelper {
|
||||
orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties())
|
||||
.setWeight(sku.getWeight()).setVolume(sku.getVolume());
|
||||
//是否有机器号
|
||||
String deviceId = userDeviceMap.get(Long.valueOf(spu.getCreator()));
|
||||
if (null!=deviceId){
|
||||
// String deviceId = userDeviceMap.get(Long.valueOf(spu.getCreator()));
|
||||
if (null!=spu.getDeviceId()){
|
||||
//设备信息
|
||||
orderItem.setDeviceId(deviceId);
|
||||
orderItem.setDeviceId(spu.getDeviceId());
|
||||
}
|
||||
|
||||
if (null!=sku.getBarCode()){
|
||||
|
||||
Reference in new issue
Block a user