订单详情增加设备信息
This commit is contained in:
1 parent
c54fed4ffc
commit
57f34353ba
11 files changed
+139
-11
No files matched your search
+2
-2
@@ -1,5 +1,5 @@
|
||||
### 获得订单交易的分页(默认)
|
||||
GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10
|
||||
### 获得商品 SPU 分页
|
||||
GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&deviceId=869667070337387
|
||||
Authorization: Bearer {{appToken}}
|
||||
tenant-id: {{appTenantId}}
|
||||
|
||||
|
||||
+9
@@ -32,6 +32,15 @@ public class TradeOrderItemBaseVO {
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "设备IMEI", requiredMode = Schema.RequiredMode.REQUIRED, example = "12345678")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "SKU 的条形码", requiredMode = Schema.RequiredMode.REQUIRED, example = "T123456")
|
||||
private String barCode;
|
||||
|
||||
@Schema(description = "货道或柜门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private String cabinetChannel;
|
||||
|
||||
@Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png")
|
||||
private String picUrl;
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商品 SPU DO
|
||||
* 交易订单项 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
|
||||
+12
@@ -70,6 +70,18 @@ public class TradeOrderItemDO extends BaseDO {
|
||||
* 关联 ProductSkuDO 的 id 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceId;
|
||||
/**
|
||||
* SKU 的条形码
|
||||
*/
|
||||
private String barCode;
|
||||
/**
|
||||
* 货道或柜门编号
|
||||
*/
|
||||
private String cabinetChannel;
|
||||
/**
|
||||
* 属性数组,JSON 格式
|
||||
*
|
||||
|
||||
+19
@@ -35,6 +35,8 @@ import cn.iocoder.yudao.module.promotion.api.giftvoucher.GiftVoucherApi;
|
||||
import cn.iocoder.yudao.module.promotion.api.giftvoucher.dto.GiftVoucherRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO;
|
||||
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.admin.order.vo.TradeOrderDeliveryReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO;
|
||||
@@ -145,6 +147,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
@Resource
|
||||
private GiftVoucherApi giftVoucherApi;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
// =================== Order ===================
|
||||
|
||||
public List<TradeOrderItemDO> findUserSuccessOrderItem(Long payUserId, List<Long> skuIdList, ProductSkuPurchaseBizTypeEnum status) {
|
||||
@@ -1109,6 +1114,20 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
// sku 信息
|
||||
orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties())
|
||||
.setWeight(sku.getWeight()).setVolume(sku.getVolume());
|
||||
//是否有机器号
|
||||
AdminUserRespDTO adminUser = adminUserApi.getUser(Long.valueOf(spu.getCreator()));
|
||||
if (null!=adminUser && null!=adminUser.getDeviceId()){
|
||||
// sku 设备信息
|
||||
orderItem.setDeviceId(adminUser.getDeviceId());
|
||||
}
|
||||
if (null!=sku.getBarCode()){
|
||||
// sku 条码
|
||||
orderItem.setBarCode(sku.getBarCode());
|
||||
}
|
||||
if (null!=sku.getCabinetChannel()){
|
||||
// sku 设备通道
|
||||
orderItem.setCabinetChannel(sku.getCabinetChannel());
|
||||
}
|
||||
// spu 信息
|
||||
orderItem.setSpuName(spu.getName()).setCategoryId(spu.getCategoryId())
|
||||
.setDeliveryTypes(spu.getDeliveryTypes()).setDeliveryTemplateId(spu.getDeliveryTemplateId())
|
||||
|
||||
+13
@@ -35,6 +35,19 @@ public class GiftVoucherCalculateRespBO extends TradeOrderDO {
|
||||
* SKU 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceId;
|
||||
/**
|
||||
* SKU 的条形码
|
||||
*/
|
||||
private String barCode;
|
||||
|
||||
/**
|
||||
* 货道或柜门编号
|
||||
*/
|
||||
private String cabinetChannel;
|
||||
/**
|
||||
* 购买数量
|
||||
*/
|
||||
|
||||
+10
-5
@@ -29,10 +29,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -76,9 +73,17 @@ public class TradePriceServiceImpl implements TradePriceService {
|
||||
// 1.2 获得商品 SPU 数组
|
||||
List<ProductSpuRespDTO> spuList = checkSpuList(skuList);
|
||||
|
||||
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);
|
||||
|
||||
// 2.1 计算价格
|
||||
TradePriceCalculateRespBO calculateRespBO = TradePriceCalculatorHelper
|
||||
.buildCalculateResp(calculateReqBO, spuList, skuList);
|
||||
.buildCalculateResp(calculateReqBO, spuList, skuList,userList);
|
||||
priceCalculators.forEach(calculator -> calculator.calculate(calculateReqBO, calculateRespBO));
|
||||
// 2.2 如果最终支付金额小于等于 0,则抛出业务异常
|
||||
/*if (calculateReqBO.getPointActivityId() == null // 积分订单,允许支付金额为 0
|
||||
|
||||
+13
@@ -156,6 +156,19 @@ public class TradePriceCalculateRespBO {
|
||||
* SKU 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceId;
|
||||
/**
|
||||
* SKU 的条形码
|
||||
*/
|
||||
private String barCode;
|
||||
|
||||
/**
|
||||
* 货道或柜门编号
|
||||
*/
|
||||
private String cabinetChannel;
|
||||
/**
|
||||
* 购买数量
|
||||
*/
|
||||
|
||||
+13
@@ -156,6 +156,19 @@ public class TradePriceCalculateSummaryRespBO {
|
||||
* SKU 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceId;
|
||||
/**
|
||||
* SKU 的条形码
|
||||
*/
|
||||
private String barCode;
|
||||
|
||||
/**
|
||||
* 货道或柜门编号
|
||||
*/
|
||||
private String cabinetChannel;
|
||||
/**
|
||||
* 购买数量
|
||||
*/
|
||||
|
||||
+45
-1
@@ -7,18 +7,21 @@ import cn.iocoder.yudao.module.product.api.device.DeviceApi;
|
||||
import cn.iocoder.yudao.module.product.api.device.dto.DeviceRespDto;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
|
||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateSummaryReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateSummaryRespBO;
|
||||
import net.sf.jsqlparser.expression.LongValue;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
@@ -40,7 +43,9 @@ public class TradePriceCalculatorHelper {
|
||||
private DeviceApi deviceApi;
|
||||
|
||||
public static TradePriceCalculateRespBO buildCalculateResp(TradePriceCalculateReqBO param,
|
||||
List<ProductSpuRespDTO> spuList, List<ProductSkuRespDTO> skuList) {
|
||||
List<ProductSpuRespDTO> spuList,
|
||||
List<ProductSkuRespDTO> skuList,
|
||||
List<AdminUserRespDTO> userList) {
|
||||
// 创建 PriceCalculateRespDTO 对象
|
||||
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO();
|
||||
result.setType(getOrderType(param)).setPromotions(new ArrayList<>()).setGiveCouponTemplateCounts(new LinkedHashMap<>());
|
||||
@@ -49,6 +54,12 @@ public class TradePriceCalculatorHelper {
|
||||
result.setItems(new ArrayList<>(param.getItems().size()));
|
||||
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||
Map<Long, ProductSkuRespDTO> skuMap = convertMap(skuList, ProductSkuRespDTO::getId);
|
||||
// 构建用户ID到deviceId的映射
|
||||
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) {
|
||||
@@ -69,6 +80,22 @@ public class TradePriceCalculatorHelper {
|
||||
// sku 信息
|
||||
orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties())
|
||||
.setWeight(sku.getWeight()).setVolume(sku.getVolume());
|
||||
//是否有机器号
|
||||
String deviceId = userDeviceMap.get(Long.valueOf(spu.getCreator()));
|
||||
if (null!=deviceId){
|
||||
//设备信息
|
||||
orderItem.setDeviceId(deviceId);
|
||||
}
|
||||
|
||||
if (null!=sku.getBarCode()){
|
||||
// sku 条码
|
||||
orderItem.setBarCode(sku.getBarCode());
|
||||
}
|
||||
if (null!=sku.getCabinetChannel()){
|
||||
// sku 设备通道
|
||||
orderItem.setCabinetChannel(sku.getCabinetChannel());
|
||||
}
|
||||
|
||||
// spu 信息
|
||||
orderItem.setSpuName(spu.getName()).setCategoryId(spu.getCategoryId())
|
||||
.setDeliveryTypes(spu.getDeliveryTypes()).setDeliveryTemplateId(spu.getDeliveryTemplateId())
|
||||
@@ -391,6 +418,21 @@ public class TradePriceCalculatorHelper {
|
||||
// sku 信息
|
||||
orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties())
|
||||
.setWeight(sku.getWeight()).setVolume(sku.getVolume());
|
||||
// sku 设备信息
|
||||
// orderItem.setDeviceId(device.getDeviceId()).setBarCode(sku.getBarCode()).setCabinetChannel(sku.getCabinetChannel());
|
||||
if (null!=device.getDeviceId()){
|
||||
//设备信息
|
||||
orderItem.setDeviceId(device.getDeviceId());
|
||||
}
|
||||
|
||||
if (null!=sku.getBarCode()){
|
||||
// sku 条码
|
||||
orderItem.setBarCode(sku.getBarCode());
|
||||
}
|
||||
if (null!=sku.getCabinetChannel()){
|
||||
// sku 设备通道
|
||||
orderItem.setCabinetChannel(sku.getCabinetChannel());
|
||||
}
|
||||
// spu 信息
|
||||
orderItem.setSpuName(spu.getName()).setCategoryId(spu.getCategoryId())
|
||||
.setDeliveryTypes(spu.getDeliveryTypes()).setDeliveryTemplateId(spu.getDeliveryTemplateId())
|
||||
@@ -437,6 +479,8 @@ public class TradePriceCalculatorHelper {
|
||||
// sku 信息
|
||||
orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties())
|
||||
.setWeight(sku.getWeight()).setVolume(sku.getVolume());
|
||||
// sku 设备信息
|
||||
orderItem.setDeviceId(device.getDeviceId()).setBarCode(sku.getBarCode()).setCabinetChannel(sku.getCabinetChannel());
|
||||
// spu 信息
|
||||
orderItem.setSpuName(spu.getName()).setCategoryId(spu.getCategoryId())
|
||||
.setDeliveryTypes(spu.getDeliveryTypes()).setDeliveryTemplateId(spu.getDeliveryTemplateId())
|
||||
|
||||
@@ -3,8 +3,8 @@ spring:
|
||||
name: yudao-server
|
||||
|
||||
profiles:
|
||||
# active: prod
|
||||
active: local
|
||||
active: prod
|
||||
# active: local
|
||||
|
||||
main:
|
||||
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
|
||||
|
||||
Reference in new issue
Block a user