1.租赁卡带出库优化,如果库存数量为0则报错提示;

2.采购退货时退货数量需要跟采购入库时的门店关联,只能从对应的采购入库门店退货;
This commit is contained in:
chenlin 2025-05-07 18:12:12 +08:00
parent 8bdedaf5a2
commit 9273d5ce56
3 changed files with 17 additions and 3 deletions

View File

@ -135,7 +135,7 @@ func GameCardGoodsStockDels(c *gin.Context) {
err := cardGoods.Dels(req.SerialNumberList, c)
if err != nil {
logger.Errorf("err:", logger.Field("err", err))
app.Error(c, http.StatusInternalServerError, err, "删除失败")
app.Error(c, http.StatusInternalServerError, err, "删除失败:"+err.Error())
return
}

View File

@ -1226,7 +1226,8 @@ func (*GameCardGoods) Dels(serials []string, c *gin.Context) error {
continue
}
if cardGoodsStock.RentStock < 1 {
continue
//continue
return errors.New("该卡带库存数量已为0")
}
begin := orm.Eloquent.Begin()

View File

@ -1701,7 +1701,8 @@ func checkPurchaseInventory(req *ErpPurchaseInventoryReq, imeiCheckFlag bool) er
logger.Error("checkPurchaseInventory purchase order err:", logger.Field("err", err))
return err
}
nCount, err := GetCommodityStockByPurchaseId(purchaseOrder.RejectedSerialNumber, commodity.ErpCommodityId)
nCount, err := GetCommodityStockByPurchaseIdAndStoreId(purchaseOrder.RejectedSerialNumber,
commodity.ErpCommodityId, purchaseOrder.StoreId)
if err != nil {
logger.Error("checkPurchaseInventory GetCommodityStockByPurchaseId err:", logger.Field("err", err))
return err
@ -2759,6 +2760,18 @@ func GetCommodityStockByPurchaseId(serialNumber string, orderId uint32) (uint32,
return uint32(count), nil
}
// GetCommodityStockByPurchaseIdAndStoreId 查询入库商品实际库存详情处剩余有效数,不包含已出库的数量
func GetCommodityStockByPurchaseIdAndStoreId(serialNumber string, orderId, storeId uint32) (uint32, error) {
var count int64
err := orm.Eloquent.Table("erp_stock_commodity").Where("original_sn = ? and erp_commodity_id = ? "+
"and state = ? and store_id = ?", serialNumber, orderId, InStock, storeId).Count(&count).Error
if err != nil {
return 0, err
}
return uint32(count), nil
}
// GetCommodityLastMonthSales 批量查询商品的上月销售数量
func GetCommodityLastMonthSales(commodityID uint32, stores []uint32) (map[uint32]uint32, error) {
// 获取上个月的时间范围