商品出入库统计

This commit is contained in:
Tankaikai
2025-03-18 10:19:22 +08:00
parent 1a297840bd
commit 3d37116264
6 changed files with 40 additions and 13 deletions

View File

@@ -95,4 +95,9 @@ public class ProductStockFlow implements Serializable {
* 备注
*/
private String remark;
/**
* 商品订单编号
*/
@Column(ignore = true)
private String orderNo;
}

View File

@@ -1,5 +1,6 @@
package com.czg.product.param;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import java.io.Serial;
@@ -27,4 +28,9 @@ public class ProductStockFlowParam implements Serializable {
* 出入库名目 win-in:手动增加 order-in:退货 loss-out:手动减少 order-out:销售量 damage-out:报损
*/
private String inOutItem;
/**
* 门店id
*/
@JSONField(serialize = false)
private Long shopId;
}

View File

@@ -2,10 +2,13 @@ package com.czg.service.product.mapper;
import com.czg.product.entity.ProductStockFlow;
import com.czg.product.param.ProductInfoParam;
import com.czg.product.param.ProductStockFlowParam;
import com.czg.product.vo.ProductStatisticsVo;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 商品库存变动记录
*
@@ -15,4 +18,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ProductStockFlowMapper extends BaseMapper<ProductStockFlow> {
ProductStatisticsVo getProductStatistics(ProductInfoParam param);
List<ProductStockFlow> getProductStockFlowList(ProductStockFlowParam param);
}

View File

@@ -223,6 +223,7 @@ public class ProductRpcServiceImpl implements ProductRpcService {
flow.setAfterNumber(NumberUtil.add(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
flow.setInOutType(InOutTypeEnum.IN.value());
flow.setInOutItem(InOutItemEnum.ORDER_IN.value());
flow.setOrderId(orderId);
productStockFlowMapper.insert(flow);
// 查询商品绑定耗材信息
List<ProdConsRelation> relationList = prodConsRelationMapper.selectListByQuery(QueryWrapper.create().eq(ProdConsRelation::getProductId, dto.getProductId()));

View File

@@ -25,6 +25,8 @@ import com.czg.product.vo.ProductStatisticsVo;
import com.czg.sa.StpKit;
import com.czg.service.product.mapper.*;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
@@ -501,18 +503,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override
public Page<ProductStockFlow> findProductStockFlowPage(ProductStockFlowParam param) {
Long shopId = StpKit.USER.getShopId(0L);
QueryWrapper queryWrapper = QueryWrapper.create();
queryWrapper.eq(ProductStockFlow::getShopId, shopId);
if (StrUtil.isNotBlank(param.getInOutType())) {
queryWrapper.eq(ProductStockFlow::getInOutType, param.getInOutType());
}
if (StrUtil.isNotBlank(param.getInOutItem())) {
queryWrapper.eq(ProductStockFlow::getInOutItem, param.getInOutItem());
}
if (ObjUtil.isNotNull(param.getProductId())) {
queryWrapper.eq(ProductStockFlow::getProductId, param.getProductId());
}
queryWrapper.orderBy(ProductStockFlow::getId, false);
return productStockFlowMapper.paginate(PageUtil.buildPage(), queryWrapper);
param.setShopId(shopId);
PageHelper.startPage(PageUtil.buildPageHelp());
return PageUtil.convert(new PageInfo<>(productStockFlowMapper.getProductStockFlowList(param)));
}
}

View File

@@ -29,4 +29,22 @@
and t2.type = #{type}
</if>
</select>
<select id="getProductStockFlowList" resultType="com.czg.product.entity.ProductStockFlow">
select
t1.*,
t2.order_no
from tb_product_stock_flow t1
left join tb_order_info t2 on t1.order_id = t2.id
where t1.shop_id = #{shopId}
<if test="inOutType != null and inOutType != ''">
and t1.in_out_type = #{inOutType}
</if>
<if test="inOutItem != null and inOutItem != ''">
and t1.in_out_item = #{inOutItem}
</if>
<if test="productId != null">
and t1.product_id = #{productId}
</if>
order by t1.id desc
</select>
</mapper>