订单生成 库存消耗记录 并记录销量
This commit is contained in:
parent
fcff40f72b
commit
09c6cd178a
|
|
@ -9,12 +9,15 @@ import javax.persistence.Id;
|
|||
public class StockCountDTO {
|
||||
private String shopId;
|
||||
@Id
|
||||
private Long skuId;
|
||||
private Long proId;
|
||||
private String proName;
|
||||
private Integer isStock;
|
||||
private String skuName;
|
||||
private String unitName;
|
||||
// 消耗数
|
||||
private Integer stockCount;
|
||||
// 当前库存
|
||||
private Integer stockNumber;
|
||||
private String specSnap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@ package cn.ysk.cashier.mybatis.mapper;
|
|||
|
||||
import cn.ysk.cashier.pojo.product.TbProductSku;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbProducSkutMapper extends BaseMapper<TbProductSku> {
|
||||
|
||||
|
|
@ -22,6 +19,9 @@ public interface TbProducSkutMapper extends BaseMapper<TbProductSku> {
|
|||
@Update("update tb_product_sku set stock_number=stock_number+#{addNum} WHERE id=#{skuId}")
|
||||
int incrStock(@Param("skuId") Integer skuId, @Param("addNum") Integer addNum);
|
||||
|
||||
@Update("update tb_product_sku set real_sales_number=real_sales_number+#{num} WHERE id=#{skuId}")
|
||||
int incrRealSalesNumber(@Param("skuId") Integer skuId, @Param("num") Integer num);
|
||||
|
||||
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} >= 0")
|
||||
int decrStock(String id, int num);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ public interface StockCountRepository extends JpaRepository<StockCountDTO, Integ
|
|||
List<StockCountDTO> countStock( @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
|
||||
@Query(value = "SELECT\n" +
|
||||
"pro.shop_id AS shop_id,\n" +
|
||||
"pro.id AS pro_id,\n" +
|
||||
"info.shop_id AS shop_id,\n" +
|
||||
"info.product_id AS pro_id,\n" +
|
||||
"info.product_name AS pro_name,\n" +
|
||||
"info.product_sku_id AS sku_id,\n" +
|
||||
"pro.is_stock,\n" +
|
||||
"info.product_sku_name AS sku_name,\n" +
|
||||
"unit.NAME AS unit_name,\n" +
|
||||
|
|
@ -57,11 +58,6 @@ public interface StockCountRepository extends JpaRepository<StockCountDTO, Integ
|
|||
"AND ( info.STATUS = 'closed' OR info.STATUS = 'refund' ) \n" +
|
||||
"GROUP BY\n" +
|
||||
"info.product_id,\n" +
|
||||
"pro.shop_id,\n" +
|
||||
"pro.id,\n" +
|
||||
"info.product_name,\n" +
|
||||
"pro.is_stock,\n" +
|
||||
"info.product_sku_name,\n" +
|
||||
"unit.NAME;",nativeQuery = true)
|
||||
"info.product_sku_id;",nativeQuery = true)
|
||||
List<StockCountDTO> countStockById(Integer orderId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package cn.ysk.cashier.service.impl.productimpl;
|
|||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.product.StockCountDTO;
|
||||
import cn.ysk.cashier.dto.rabbit.StockRecordMsg;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
|
||||
import cn.ysk.cashier.repository.order.StockCountRepository;
|
||||
|
|
@ -60,6 +60,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
|||
private final StockCountRepository stockCountRepository;
|
||||
private final EntityManager entityManager;
|
||||
private final TbOrderInfoRepository tbOrderInfoRepository;
|
||||
private final TbProducSkutMapper skutMapper;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -203,7 +204,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
|||
productStockDetail.setSubType(-1);
|
||||
tbProductStockDetailRepository.save(productStockDetail);
|
||||
}
|
||||
|
||||
skutMapper.incrRealSalesNumber(s.getSkuId().intValue(),s.getStockCount());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue