分包裹发货,库存预警

This commit is contained in:
chc 2024-01-11 13:33:13 +08:00
parent 6f0f8106e0
commit 6cea6af59b
29 changed files with 634 additions and 7 deletions

View File

@ -64,4 +64,6 @@ CREATE TABLE `li_order_package_item` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin ROW_FORMAT=DYNAMIC;
ALTER TABLE li_order_item ADD `deliver_number` int DEFAULT NULL COMMENT '发货数量';
ALTER TABLE li_order_item ADD `deliver_number` int DEFAULT NULL COMMENT '发货数量';
ALTER TABLE li_goods_sku ADD `alert_quantity` int DEFAULT NULL COMMENT '预警库存';

View File

@ -9,11 +9,14 @@ import cn.lili.common.security.OperationalJudgment;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.dos.OrderPackage;
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
import cn.lili.modules.order.order.entity.vo.OrderSimpleVO;
import cn.lili.modules.order.order.service.OrderPackageService;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.system.entity.vo.Traces;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -44,6 +47,9 @@ public class OrderBuyerController {
@Autowired
private OrderService orderService;
@Autowired
private OrderPackageService orderPackageService;
@ApiOperation(value = "查询会员订单列表")
@GetMapping
public ResultMessage<IPage<OrderSimpleVO>> queryMineOrder(OrderSearchParams orderSearchParams) {
@ -138,4 +144,21 @@ public class OrderBuyerController {
return ResultUtil.data(orderService.invoice(orderSn));
}
@ApiOperation(value = "查询物流踪迹")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
})
@GetMapping(value = "/getTracesList/{orderSn}")
public ResultMessage<Object> getTracesList(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
return ResultUtil.data(orderPackageService.getOrderPackageVOList(orderSn));
}
@ApiOperation(value = "查看包裹列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
})
@GetMapping(value = "/getPackage/{orderSn}")
public ResultMessage<Object> getPackage(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
return ResultUtil.data(orderPackageService.getOrderPackageVOList(orderSn));
}
}

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;
@ -163,6 +164,9 @@ public class GoodsSku extends BaseEntity {
@ApiModelProperty(value = "商品类型", required = true)
private String goodsType;
@ApiModelProperty(value = "预警数量")
private Integer alertQuantity;
public Double getWeight() {
if (weight == null) {
return 0d;

View File

@ -90,6 +90,9 @@ public class GoodsSearchParams extends PageVO {
@ApiModelProperty(value = "销售模式", required = true)
private String salesModel;
@ApiModelProperty(value = "预警库存")
private Boolean alertQuantity;
public <T> QueryWrapper<T> queryWrapper() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
if (CharSequenceUtil.isNotEmpty(goodsId)) {
@ -134,6 +137,9 @@ public class GoodsSearchParams extends PageVO {
if (recommend != null) {
queryWrapper.le("recommend", recommend);
}
if(alertQuantity != null && alertQuantity){
queryWrapper.apply("quantity < alert_quantity");
}
if (CharSequenceUtil.isNotEmpty(goodsType)) {
queryWrapper.eq("goods_type", goodsType);
}

View File

@ -21,5 +21,8 @@ public class GoodsSkuStockDTO {
@ApiModelProperty(value = "库存")
private Integer quantity;
@ApiModelProperty(value = "预警库存")
private Integer alertQuantity;
}

View File

@ -188,6 +188,8 @@ public interface GoodsSkuService extends IService<GoodsSku> {
*/
void updateStocks(List<GoodsSkuStockDTO> goodsSkuStockDTOS);
void updateAlertQuantity(List<GoodsSkuStockDTO> goodsSkuStockDTOS);
/**
* 更新SKU库存
*

View File

@ -536,6 +536,27 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
}
}
@Override
public void updateAlertQuantity(List<GoodsSkuStockDTO> goodsSkuStockDTOS) {
List<GoodsSku> goodsSkuList = new ArrayList<>();
List<String> skuIds = goodsSkuStockDTOS.stream().map(GoodsSkuStockDTO::getSkuId).collect(Collectors.toList());
List<GoodsSkuStockDTO> goodsSkuStockList = this.baseMapper.queryStocks(GoodsSearchParams.builder().ids(skuIds).build().queryWrapper());
List<String> goodsIdList = goodsSkuStockList.stream().map(GoodsSkuStockDTO::getGoodsId).collect(Collectors.toList());
HashSet<String> uniqueSet = new HashSet<>(goodsIdList);
// 将去重后的元素转回列表
List<String> uniqueGoodsIdList = new ArrayList<>(uniqueSet);
for (String goodsId : uniqueGoodsIdList) {
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
}
for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) {
GoodsSku goodsSku = this.getById(goodsSkuStockDTO.getSkuId());
goodsSku.setAlertQuantity(goodsSkuStockDTO.getAlertQuantity());
goodsSkuList.add(goodsSku);
}
this.updateBatchById(goodsSkuList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateStock(String skuId, Integer quantity) {

View File

@ -64,7 +64,7 @@ public class GoodsSkuBuilder {
Map<String, Object> specMap = new LinkedHashMap<>();
// 原始规格项
String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight"};
String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight","alertQuantity"};
//获取规格信息
for (Map.Entry<String, Object> spec : skuInfo.entrySet()) {
//保存新增规格信息
@ -91,6 +91,7 @@ public class GoodsSkuBuilder {
goodsSku.setQuantity(Convert.toInt(skuInfo.get("quantity"), 0));
goodsSku.setSpecs(JSONUtil.toJsonStr(specMap));
goodsSku.setSimpleSpecs(simpleSpecs.toString());
goodsSku.setAlertQuantity(Convert.toInt(skuInfo.get("alertQuantity"), 0));
}

View File

@ -115,6 +115,15 @@ public class OrderItem extends BaseEntity {
@ApiModelProperty(value = "退货商品数量")
private Integer returnGoodsNumber;
@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();

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

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

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();
@ -46,6 +52,17 @@ public class GoodsStatisticsServiceImpl extends ServiceImpl<GoodsStatisticsMappe
return this.count(queryWrapper);
}
@Override
public long alertQuantityNum() {
QueryWrapper queryWrapper = new QueryWrapper();
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
queryWrapper.eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()),
"store_id", currentUser.getStoreId());
queryWrapper.eq("market_enable",GoodsStatusEnum.UPPER.name());
queryWrapper.apply("quantity < alert_quantity");
return goodsSkuService.count(queryWrapper);
}
@Override
public long todayUpperNum() {
LambdaQueryWrapper<Goods> queryWrapper = Wrappers.lambdaQuery();

View File

@ -182,6 +182,7 @@ public class IndexStatisticsServiceImpl implements IndexStatisticsService {
//商品总数量
storeIndexStatisticsVO.setGoodsNum(goodsStatisticsService.goodsNum(GoodsStatusEnum.UPPER, null));
storeIndexStatisticsVO.setAlertQuantityNum(goodsStatisticsService.alertQuantityNum());
//订单总数量订单总金额
Map<String, Object> map = storeFlowStatisticsService.getOrderStatisticsPrice();
storeIndexStatisticsVO.setOrderNum(Convert.toInt(map.get("num").toString()));

View File

@ -93,7 +93,8 @@ public class GoodsStoreController {
StoreDetail storeDetail = OperationalJudgment.judgment(storeDetailService.getStoreDetail(storeId));
Integer stockWarnNum = storeDetail.getStockWarning();
goodsSearchParams.setStoreId(storeId);
goodsSearchParams.setLeQuantity(stockWarnNum);
// goodsSearchParams.setLeQuantity(stockWarnNum);
goodsSearchParams.setAlertQuantity(true);
goodsSearchParams.setMarketEnable(GoodsStatusEnum.UPPER.name());
IPage<GoodsSku> goodsSku = goodsSkuService.getGoodsSkuByPage(goodsSearchParams);
StockWarningVO stockWarning = new StockWarningVO(stockWarnNum, goodsSku);
@ -182,6 +183,21 @@ public class GoodsStoreController {
return ResultUtil.success();
}
@ApiOperation(value = "修改商品预警库存")
@PutMapping(value = "/update/alert/stocks", consumes = "application/json")
public ResultMessage<Object> updateAlertQuantity(@RequestBody List<GoodsSkuStockDTO> updateStockList) {
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
// 获取商品skuId集合
List<String> goodsSkuIds = updateStockList.stream().map(GoodsSkuStockDTO::getSkuId).collect(Collectors.toList());
// 根据skuId集合查询商品信息
List<GoodsSku> goodsSkuList = goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().in(GoodsSku::getId, goodsSkuIds).eq(GoodsSku::getStoreId, storeId));
// 过滤不符合当前店铺的商品
List<String> filterGoodsSkuIds = goodsSkuList.stream().map(GoodsSku::getId).collect(Collectors.toList());
List<GoodsSkuStockDTO> collect = updateStockList.stream().filter(i -> filterGoodsSkuIds.contains(i.getSkuId())).collect(Collectors.toList());
goodsSkuService.updateAlertQuantity(collect);
return ResultUtil.success();
}
@ApiOperation(value = "通过id获取商品信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path"),

View File

@ -13,8 +13,10 @@ import cn.lili.modules.member.entity.dto.MemberAddressDTO;
import cn.lili.modules.member.service.StoreLogisticsService;
import cn.lili.modules.order.order.entity.dto.OrderExportDTO;
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.service.OrderPackageService;
import cn.lili.modules.order.order.service.OrderPriceService;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.system.service.LogisticsService;
@ -70,6 +72,9 @@ public class OrderStoreController {
@Autowired
private LogisticsService logisticsService;
@Autowired
private OrderPackageService orderPackageService;
@ApiOperation(value = "查询订单列表")
@GetMapping
@ -217,4 +222,33 @@ public class OrderStoreController {
@NotNull(message = "请选择物流公司") String logisticsId) {
return ResultUtil.data(logisticsService.labelOrder(orderSn, logisticsId));
}
@ApiOperation(value = "查看包裹列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
})
@GetMapping(value = "/getPackage/{orderSn}")
public ResultMessage<Object> getPackage(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
return ResultUtil.data(orderPackageService.getOrderPackageVOList(orderSn));
}
@ApiOperation(value = "查询物流踪迹")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
})
@GetMapping(value = "/getTracesList/{orderSn}")
public ResultMessage<Object> getTracesList(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
return ResultUtil.data(orderPackageService.getOrderPackageVOList(orderSn));
}
@ApiOperation(value = "订单包裹发货")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderSn", value = "订单sn", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "logisticsNo", value = "发货单号", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "logisticsId", value = "物流公司", required = true, dataType = "String", paramType = "query")
})
@PostMapping(value = "/{orderSn}/partDelivery")
public ResultMessage<Object> delivery(@RequestBody PartDeliveryParamsDTO partDeliveryParamsDTO) {
return ResultUtil.data(orderService.partDelivery(partDeliveryParamsDTO));
}
}