fix: Merging dev

This commit is contained in:
lele0521
2024-01-16 11:29:03 +08:00
25 changed files with 625 additions and 21 deletions

View File

@@ -205,6 +205,7 @@ public enum ResultCode {
POINT_NOT_ENOUGH(31015, "当前会员积分不足购买当前积分商品!"),
ORDER_LABEL_ORDER_ERROR(31016, "订单不能打印电子面单"),
ORDER_PRICE_ERROR(31017,"订单金额不能小于等于0"),
ORDER_PACKAGE_NOT_EXIST(31017, "当前订单包裹不存在!"),
/**

View File

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

View File

@@ -536,6 +536,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateStock(String skuId, Integer quantity) {

View File

@@ -125,6 +125,16 @@ public class OrderItem extends BaseEntity {
@ApiModelProperty(value = "退款金额")
private Double refundPrice;
@ApiModelProperty(value = "已发货数量")
private Integer deliverNumber;
public Integer getDeliverNumber() {
if(deliverNumber == null){
return 0;
}
return deliverNumber;
}
public OrderItem(CartSkuVO cartSkuVO, CartVO cartVO, TradeDTO tradeDTO) {
String oldId = this.getId();
BeanUtil.copyProperties(cartSkuVO.getGoodsSku(), this);

View File

@@ -0,0 +1,39 @@
package cn.lili.modules.order.order.entity.dos;
import cn.lili.mybatis.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@TableName("li_order_package")
@ApiModel(value = "订单包裹")
@NoArgsConstructor
@AllArgsConstructor
public class OrderPackage extends BaseEntity {
@ApiModelProperty(value = "包裹单号")
private String packageNo;
@ApiModelProperty(value = "订单编号")
private String orderSn;
@ApiModelProperty(value = "发货单号")
private String logisticsNo;
@ApiModelProperty(value = "物流公司CODE")
private String logisticsCode;
@ApiModelProperty(value = "物流公司名称")
private String logisticsName;
@ApiModelProperty(value = "收件人手机")
private String consigneeMobile;
@ApiModelProperty(value = "状态")
private String status;
}

View File

@@ -0,0 +1,47 @@
package cn.lili.modules.order.order.entity.dos;
import cn.lili.mybatis.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @author chc
* @since 2022/6/2114:46
*/
@Data
@TableName("li_order_package_item")
@ApiModel(value = "订单分包裹详情")
@NoArgsConstructor
@AllArgsConstructor
public class OrderPackageItem extends BaseEntity {
@ApiModelProperty(value = "包裹单号")
private String packageNo;
@ApiModelProperty(value = "订单编号")
private String orderSn;
@ApiModelProperty(value = "子订单编号")
private String orderItemSn;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "商品图片")
private String thumbnail;
@ApiModelProperty(value = "已发货数量")
private Integer deliverNumber;
@ApiModelProperty(value = "送货时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date logisticsTime;
}

View File

@@ -0,0 +1,19 @@
package cn.lili.modules.order.order.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 部分发货
*/
@Data
public class PartDeliveryDTO {
@ApiModelProperty(value = "订单货物Id")
private String orderItemId;
@ApiModelProperty(value = "发货数量")
private Integer deliveryNum;
}

View File

@@ -0,0 +1,30 @@
package cn.lili.modules.order.order.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 部分发货参数封装
*
* @author liushuai(liushuai711 @ gmail.com)
* @version v4.0
* @Description:
* @since 2022/10/29 17:52
*/
@Data
public class PartDeliveryParamsDTO {
@ApiModelProperty(value = "订单号")
private String orderSn;
@ApiModelProperty(value = "发货单号")
private String logisticsNo;
@ApiModelProperty(value = "发货方式")
private String logisticsId;
@ApiModelProperty(value = "物流详细")
private List<PartDeliveryDTO> partDeliveryDTOList;
}

View File

@@ -0,0 +1,65 @@
package cn.lili.modules.order.order.entity.vo;
import cn.lili.common.utils.BeanUtil;
import cn.lili.modules.order.order.entity.dos.OrderPackage;
import cn.lili.modules.order.order.entity.dos.OrderPackageItem;
import cn.lili.modules.system.entity.vo.Traces;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 分包裹详情VO
*
* @author Chopper
* @since 2020-08-17 20:28
*/
@Data
@NoArgsConstructor
public class OrderPackageVO implements Serializable {
private static final long serialVersionUID = 1810890757303309436L;
@ApiModelProperty(value = "包裹单号")
private String packageNo;
@ApiModelProperty(value = "订单编号")
private String orderSn;
@ApiModelProperty(value = "发货单号")
private String logisticsNo;
@ApiModelProperty(value = "物流公司CODE")
private String logisticsCode;
@ApiModelProperty(value = "物流公司名称")
private String logisticsName;
@ApiModelProperty(value = "收件人手机")
private String consigneeMobile;
@ApiModelProperty(value = "状态")
private String status;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "子订单包裹详情列表")
private List<OrderPackageItem> orderPackageItemList;
@ApiModelProperty(value = "物流信息")
private Traces traces;
public OrderPackageVO(OrderPackage orderPackage) {
BeanUtil.copyProperties(orderPackage, this);
}
}

View File

@@ -0,0 +1,14 @@
package cn.lili.modules.order.order.mapper;
import cn.lili.modules.order.order.entity.dos.OrderPackageItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 子订单包裹数据处理层
*
* @author Bulbasaur
* @since 2020/11/17 7:34 下午
*/
public interface OrderPackageItemMapper extends BaseMapper<OrderPackageItem> {
}

View File

@@ -0,0 +1,14 @@
package cn.lili.modules.order.order.mapper;
import cn.lili.modules.order.order.entity.dos.OrderPackage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 订单包裹数据处理层
*
* @author Bulbasaur
* @since 2020/11/17 7:34 下午
*/
public interface OrderPackageMapper extends BaseMapper<OrderPackage> {
}

View File

@@ -0,0 +1,31 @@
package cn.lili.modules.order.order.service;
import cn.lili.modules.order.order.entity.dos.OrderPackageItem;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 子订单业务层
*
* @author Chopper
* @since 2020/11/17 7:36 下午
*/
public interface OrderPackageItemService extends IService<OrderPackageItem> {
/**
* 根据订单编号获取订单包裹列表
* @param orderSn 订单编号
* @return 子订单包裹列表
*/
List<OrderPackageItem> getOrderPackageItemListByOrderSn(String orderSn);
/**
* 根据包裹编号获取子包裹列表
* @param packageNo 包裹编号
* @return 子包裹列表
*/
List<OrderPackageItem> getOrderPackageItemListByPno(String packageNo);
}

View File

@@ -0,0 +1,31 @@
package cn.lili.modules.order.order.service;
import cn.lili.modules.order.order.entity.dos.OrderPackage;
import cn.lili.modules.order.order.entity.vo.OrderPackageVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 子订单业务层
*
* @author Chopper
* @since 2020/11/17 7:36 下午
*/
public interface OrderPackageService extends IService<OrderPackage> {
/**
* 根据订单编号获取订单包裹列表
* @param orderSn
* @return
*/
List<OrderPackage> orderPackageList(String orderSn);
/**
* 获取指定订单编号的所有包裹
* @param orderSn
* @return
*/
List<OrderPackageVO> getOrderPackageVOList(String orderSn);
}

View File

@@ -6,6 +6,7 @@ import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.dto.OrderExportDTO;
import cn.lili.modules.order.order.entity.dto.OrderMessage;
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
import cn.lili.modules.order.order.entity.dto.PartDeliveryParamsDTO;
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
import cn.lili.modules.order.order.entity.vo.OrderSimpleVO;
import cn.lili.modules.order.order.entity.vo.PaymentLog;
@@ -311,4 +312,12 @@ public interface OrderService extends IService<Order> {
*/
boolean checkFictitiousOrder(String pintuanId, Integer requiredNum, Boolean fictitious);
/**
* 订单部分发货
*
* @param partDeliveryParamsDTO 参数
* @return 订单
*/
Order partDelivery(PartDeliveryParamsDTO partDeliveryParamsDTO);
}

View File

@@ -0,0 +1,43 @@
package cn.lili.modules.order.order.serviceimpl;
import cn.lili.modules.order.order.entity.dos.OrderPackageItem;
import cn.lili.modules.order.order.mapper.OrderPackageItemMapper;
import cn.lili.modules.order.order.service.OrderPackageItemService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 订单包裹业务层实现
*
* @author Chopper
* @since 2020/11/17 7:38 下午
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderPackageItemServiceImpl extends ServiceImpl<OrderPackageItemMapper, OrderPackageItem> implements OrderPackageItemService {
/**
* 根据订单编号获取订单包裹列表
* @param orderSn 订单编号
* @return 子订单包裹列表
*/
@Override
public List<OrderPackageItem> getOrderPackageItemListByOrderSn(String orderSn) {
return this.list(new LambdaQueryWrapper<OrderPackageItem>().eq(OrderPackageItem::getOrderSn, orderSn));
}
/**
* 根据包裹编号获取子包裹列表
* @param packageNo 包裹编号
* @return 子包裹列表
*/
@Override
public List<OrderPackageItem> getOrderPackageItemListByPno(String packageNo) {
return this.list(new LambdaQueryWrapper<OrderPackageItem>().eq(OrderPackageItem::getPackageNo, packageNo));
}
}

View File

@@ -0,0 +1,64 @@
package cn.lili.modules.order.order.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.modules.order.order.entity.dos.OrderPackage;
import cn.lili.modules.order.order.entity.dos.OrderPackageItem;
import cn.lili.modules.order.order.entity.vo.OrderPackageVO;
import cn.lili.modules.order.order.mapper.OrderPackageMapper;
import cn.lili.modules.order.order.service.OrderPackageItemService;
import cn.lili.modules.order.order.service.OrderPackageService;
import cn.lili.modules.system.entity.vo.Traces;
import cn.lili.modules.system.service.LogisticsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* 订单包裹业务层实现
*
* @author Chopper
* @since 2020/11/17 7:38 下午
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderPackageServiceImpl extends ServiceImpl<OrderPackageMapper, OrderPackage> implements OrderPackageService {
@Autowired
private OrderPackageItemService orderpackageItemService;
@Autowired
private LogisticsService logisticsService;
@Override
public List<OrderPackage> orderPackageList(String orderSn) {
return this.list(new LambdaQueryWrapper<OrderPackage>().eq(OrderPackage::getOrderSn, orderSn));
}
@Override
public List<OrderPackageVO> getOrderPackageVOList(String orderSn) {
List<OrderPackage> orderPackages = this.orderPackageList(orderSn);
if (orderPackages == null){
throw new ServiceException(ResultCode.ORDER_PACKAGE_NOT_EXIST);
}
List<OrderPackageVO> orderPackageVOS = new ArrayList<>();
orderPackages.forEach(orderPackage -> {
OrderPackageVO orderPackageVO = new OrderPackageVO(orderPackage);
// 获取子订单包裹详情
List<OrderPackageItem> orderPackageItemList = orderpackageItemService.getOrderPackageItemListByPno(orderPackage.getPackageNo());
orderPackageVO.setOrderPackageItemList(orderPackageItemList);
String str = orderPackage.getConsigneeMobile();
str = str.substring(str.length() - 4);
// Traces traces = logisticsService.getLogisticTrack(orderPackage.getLogisticsCode(), orderPackage.getLogisticsNo(), str);
// orderPackageVO.setTraces(traces);
orderPackageVOS.add(orderPackageVO);
});
return orderPackageVOS;
}
}

View File

@@ -23,10 +23,7 @@ import cn.lili.modules.order.cart.entity.dto.TradeDTO;
import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum;
import cn.lili.modules.order.order.aop.OrderLogPoint;
import cn.lili.modules.order.order.entity.dos.*;
import cn.lili.modules.order.order.entity.dto.OrderBatchDeliverDTO;
import cn.lili.modules.order.order.entity.dto.OrderExportDTO;
import cn.lili.modules.order.order.entity.dto.OrderMessage;
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
import cn.lili.modules.order.order.entity.dto.*;
import cn.lili.modules.order.order.entity.enums.*;
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
import cn.lili.modules.order.order.entity.vo.OrderSimpleVO;
@@ -146,6 +143,17 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
@Autowired
private StoreDetailService storeDetailService;
/**
* 订单包裹
*/
@Autowired
private OrderPackageService orderPackageService;
/**
* 订单包裹货物
*/
@Autowired
private OrderPackageItemService orderPackageItemService;
@Override
@Transactional(rollbackFor = Exception.class)
public void intoDB(TradeDTO tradeDTO) {
@@ -790,6 +798,74 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
return false;
}
@Override
public Order partDelivery(PartDeliveryParamsDTO partDeliveryParamsDTO) {
String logisticsId = partDeliveryParamsDTO.getLogisticsId();
String orderSn = partDeliveryParamsDTO.getOrderSn();
String invoiceNumber = partDeliveryParamsDTO.getLogisticsNo();
//获取对应物流
Logistics logistics = logisticsService.getById(logisticsId);
if (logistics == null) {
throw new ServiceException(ResultCode.ORDER_LOGISTICS_ERROR);
}
Order order = OperationalJudgment.judgment(this.getBySn(orderSn));
List<OrderItem> orderItemList = orderItemService.getByOrderSn(orderSn);
OrderPackage orderPackage = new OrderPackage();
orderPackage.setPackageNo(SnowFlake.createStr("OP"));
orderPackage.setOrderSn(orderSn);
orderPackage.setLogisticsNo(invoiceNumber);
orderPackage.setLogisticsCode(logistics.getCode());
orderPackage.setLogisticsName(logistics.getName());
orderPackage.setStatus("1");
orderPackage.setConsigneeMobile(order.getConsigneeMobile());
orderPackageService.save(orderPackage);
List<OrderLog> orderLogList = new ArrayList<>();
for (PartDeliveryDTO partDeliveryDTO : partDeliveryParamsDTO.getPartDeliveryDTOList()) {
for (OrderItem orderItem : orderItemList) {
//寻找订单货物进行判断
if (partDeliveryDTO.getOrderItemId().equals(orderItem.getId())) {
if ((partDeliveryDTO.getDeliveryNum() + orderItem.getDeliverNumber()) > orderItem.getNum()) {
throw new ServiceException("发货数量不正确!");
}
orderItem.setDeliverNumber((partDeliveryDTO.getDeliveryNum() + orderItem.getDeliverNumber()));
// 记录分包裹中每个item子单的具体发货信息
OrderPackageItem orderPackageItem = new OrderPackageItem();
orderPackageItem.setOrderSn(orderSn);
orderPackageItem.setPackageNo(orderPackage.getPackageNo());
orderPackageItem.setOrderItemSn(orderItem.getSn());
orderPackageItem.setDeliverNumber(partDeliveryDTO.getDeliveryNum());
orderPackageItem.setLogisticsTime(new Date());
orderPackageItem.setGoodsName(orderItem.getGoodsName());
orderPackageItem.setThumbnail(orderItem.getImage());
orderPackageItemService.save(orderPackageItem);
OrderLog orderLog = new OrderLog(orderSn, UserContext.getCurrentUser().getId(), UserContext.getCurrentUser().getRole().getRole(), UserContext.getCurrentUser().getUsername(), "订单 [ " + orderSn + " ]商品 [ " + orderItem.getGoodsName() + " ]发货,发货数量: [ " + partDeliveryDTO.getDeliveryNum() + " ],发货单号[ " + invoiceNumber + " ]");
orderLogList.add(orderLog);
}
}
}
//修改订单货物
orderItemService.updateBatchById(orderItemList);
orderLogService.saveBatch(orderLogList);
//判断订单货物是否全部发货完毕
Boolean delivery = true;
for (OrderItem orderItem : orderItemList) {
if (orderItem.getDeliverNumber() < orderItem.getNum()) {
delivery = false;
break;
}
}
//是否全部发货
if (delivery) {
return delivery(orderSn, invoiceNumber, logisticsId);
}
return order;
}
/**
* 虚拟成团
*

View File

@@ -50,5 +50,8 @@ public class StoreIndexStatisticsVO {
@ApiModelProperty(value = "待自提数量")
private Long selfPickNum;
@ApiModelProperty(value = "警告库存")
private Long alertQuantityNum;
}

View File

@@ -21,7 +21,6 @@ public interface GoodsStatisticsService extends IService<Goods> {
* @return 所有的已上架的商品数量
*/
long goodsNum(GoodsStatusEnum goodsStatusEnum, GoodsAuthEnum goodsAuthEnum);
/**
* 获取今天的已上架的商品数量
*

View File

@@ -9,11 +9,14 @@ import cn.lili.common.security.enums.UserEnums;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.statistics.mapper.GoodsStatisticsMapper;
import cn.lili.modules.statistics.service.GoodsStatisticsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
@@ -27,6 +30,9 @@ import java.util.Objects;
@Service
public class GoodsStatisticsServiceImpl extends ServiceImpl<GoodsStatisticsMapper, Goods> implements GoodsStatisticsService {
@Autowired
private GoodsSkuService goodsSkuService;
@Override
public long goodsNum(GoodsStatusEnum goodsStatusEnum, GoodsAuthEnum goodsAuthEnum) {
LambdaQueryWrapper<Goods> queryWrapper = Wrappers.lambdaQuery();