From 3667eb5e9cafcd0565a13ab6c0c383289b75a3b3 Mon Sep 17 00:00:00 2001 From: chenlin Date: Wed, 24 Apr 2024 17:14:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E5=85=B6=E4=BB=96=E5=87=BA?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E6=B1=87=E6=80=BB=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/models/inventory_report.go | 78 ++++++++++++++++++---------- docs/docs.go | 74 ++++++++++++++++++-------- docs/swagger.json | 74 ++++++++++++++++++-------- docs/swagger.yaml | 58 ++++++++++++++------- 4 files changed, 196 insertions(+), 88 deletions(-) diff --git a/app/admin/models/inventory_report.go b/app/admin/models/inventory_report.go index f9bce2c..9b88ff2 100644 --- a/app/admin/models/inventory_report.go +++ b/app/admin/models/inventory_report.go @@ -150,7 +150,7 @@ type InventoryReportByOtherReq struct { StoreId []uint32 `json:"store_id"` // 门店id CommodityName []string `json:"commodity_name"` // 商品名称 CategoryID []uint32 `json:"category_id"` // 商品分类id - State uint32 `json:"state"` // 调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 + Type uint32 `json:"type"` // 出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 StartTime string `json:"start_time"` // 开始时间/入库时间 EndTime string `json:"end_time"` // 结束时间/出库时间 IsExport uint32 `json:"is_export"` // 1-导出 @@ -171,15 +171,16 @@ type InventoryReportByOtherResp struct { // ReportByOtherData 其他出入库汇总数据 type ReportByOtherData struct { - StoreId uint32 `json:"store_id"` // 门店id - StoreName string `json:"store_name"` // 门店名称 - CommodityId uint32 `json:"commodity_id"` // 商品id - CommodityName string `json:"commodity_name"` // 商品名称 - CategoryID uint32 `json:"category_id"` // 商品分类id - CategoryName string `json:"category_name"` // 商品分类名称 - Type uint32 `json:"type"` // 调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 - Count int64 `json:"count"` // 数量 - Amount float64 `json:"amount"` // 金额 + StoreId uint32 `json:"store_id"` // 门店id + StoreName string `json:"store_name"` // 门店名称 + CommodityId uint32 `json:"commodity_id"` // 商品id + CommodityName string `json:"commodity_name"` // 商品名称 + CategoryID uint32 `json:"category_id"` // 商品分类id + CategoryName string `json:"category_name"` // 商品分类名称 + StockTime *time.Time `json:"stock_time"` // 出入库时间 + Type uint32 `json:"type"` // 出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 + Count int64 `json:"count"` // 数量 + Amount float64 `json:"amount"` // 金额 } // InventoryReportOtherDetailReq 其他出入库明细入参 @@ -1210,20 +1211,10 @@ func (m *InventoryReportByOtherReq) ReportByOtherList(c *gin.Context) (*Inventor allData := append(productList, changeList...) allData = append(allData, systemList...) - var nTotalAllotCount uint32 - var nTotalAllotAmount float64 // 创建 map 用于存储汇总数据 summaryMap := make(map[string]*ReportByOtherData) // 遍历切片 for _, item := range allData { - if item.Type == 3 || item.Type == 4 { - nTotalAllotCount -= 1 - nTotalAllotAmount -= item.PurchasePrice - } else { - nTotalAllotCount += 1 - nTotalAllotAmount += item.PurchasePrice - } - // 生成键 key := fmt.Sprintf("%d_%d_%d", item.CommodityId, item.StoreId, item.Type) // 检查是否已经存在该键的汇总数据 @@ -1241,6 +1232,7 @@ func (m *InventoryReportByOtherReq) ReportByOtherList(c *gin.Context) (*Inventor CommodityName: item.CommodityName, CategoryID: item.CategoryID, CategoryName: item.CategoryName, + StockTime: item.StockTime, Type: item.Type, Count: 1, // 初始化为 1 Amount: item.PurchasePrice, @@ -1266,22 +1258,56 @@ func (m *InventoryReportByOtherReq) ReportByOtherList(c *gin.Context) (*Inventor summaryList = append(summaryList, *summary) } + // 进行条件查询 + var startTime time.Time + if m.StartTime != "" { // 出入库开始时间 + startTime, err = time.Parse(QueryTimeFormat, m.StartTime) + if err != nil { + logger.Errorf("ReportByOtherDetailList err:", err) + return nil, err + } + } + var endTime time.Time + if m.EndTime != "" { // 出入库结束时间 + endTime, err = time.Parse(QueryTimeFormat, m.EndTime) + if err != nil { + logger.Errorf("ReportByOtherDetailList err:", err) + return nil, err + } + } + + var nTotalAllotCount uint32 + var nTotalAllotAmount float64 + filteredData := make([]ReportByOtherData, 0) + for _, data := range summaryList { + if (len(m.StoreId) == 0 || tools.Uint32SliceContains(m.StoreId, data.StoreId)) && + (len(m.CommodityName) == 0 || tools.StringSliceContains(m.CommodityName, data.CommodityName)) && + (len(m.CategoryID) == 0 || tools.Uint32SliceContains(m.CategoryID, data.CategoryID)) && + (m.Type == 0 || m.Type == data.Type) && + ((m.StartTime == "" && m.EndTime == "") || (data.StockTime.After(startTime) && data.StockTime.Before(endTime))) { + nTotalAllotCount += 1 + nTotalAllotAmount += data.Amount + + filteredData = append(filteredData, data) + } + } + // 使用排序规则函数对汇总数据进行排序 - sortSummaryList(summaryList) + sortSummaryList(filteredData) // 计算分页所需的切片索引 startIndex := page * m.PageSize endIndex := (page + 1) * m.PageSize - if endIndex > len(summaryList) { - endIndex = len(summaryList) + if endIndex > len(filteredData) { + endIndex = len(filteredData) } - resp.Total = len(summaryList) + resp.Total = len(filteredData) resp.TotalCount = nTotalAllotCount resp.TotalAmount = tools.RoundToTwoDecimalPlaces(nTotalAllotAmount) if m.IsExport == 1 { - resp.List = summaryList + resp.List = filteredData resp.ExportUrl, err = reportOtherExport(resp) if err != nil { return nil, err @@ -1290,7 +1316,7 @@ func (m *InventoryReportByOtherReq) ReportByOtherList(c *gin.Context) (*Inventor resp.TotalCount = 0 resp.TotalAmount = 0 } else { - resp.List = summaryList[startIndex:endIndex] + resp.List = filteredData[startIndex:endIndex] } return resp, nil diff --git a/docs/docs.go b/docs/docs.go index 23bb42b..3736e12 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -7949,6 +7949,10 @@ const docTemplate = `{ "description": "库存调拨订单表id", "type": "integer" }, + "amount": { + "description": "金额(采购价)", + "type": "number" + }, "commodity_id": { "description": "商品id", "type": "integer" @@ -10528,7 +10532,7 @@ const docTemplate = `{ "type": "string" }, "dispatch_count": { - "description": "调拨中数量", + "description": "调拨中数量(调拨中调入)", "type": "integer" }, "erp_category_id": { @@ -10745,6 +10749,10 @@ const docTemplate = `{ "description": "是否串码:0-查全部 1-查串码类 2-查非串码", "type": "integer" }, + "original_sn": { + "description": "首次入库订单编号", + "type": "string" + }, "pageIndex": { "description": "页码", "type": "integer" @@ -10761,10 +10769,6 @@ const docTemplate = `{ "description": "商品编号", "type": "string" }, - "sn": { - "description": "首次入库订单编号", - "type": "string" - }, "state": { "description": "库存状态:1-在库 2-已售 3-采购退货 4-调拨中 5-出库(前端只看1,4)", "type": "integer" @@ -11699,7 +11703,10 @@ const docTemplate = `{ }, "deliver_store_id": { "description": "调出门店id", - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } }, "is_export": { "description": "1-导出", @@ -11715,7 +11722,10 @@ const docTemplate = `{ }, "receive_store_id": { "description": "调入门店id", - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } }, "receive_time_end": { "description": "调入结束时间", @@ -11899,16 +11909,16 @@ const docTemplate = `{ "description": "开始时间/入库时间", "type": "string" }, - "state": { - "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", - "type": "integer" - }, "store_id": { "description": "门店id", "type": "array", "items": { "type": "integer" } + }, + "type": { + "description": "出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", + "type": "integer" } } }, @@ -12080,16 +12090,16 @@ const docTemplate = `{ "description": "开始时间/入库时间", "type": "string" }, - "state": { - "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", - "type": "integer" - }, "store_id": { "description": "门店id", "type": "array", "items": { "type": "integer" } + }, + "type": { + "description": "出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", + "type": "integer" } } }, @@ -13506,6 +13516,14 @@ const docTemplate = `{ "description": "调入门店名称", "type": "string" }, + "receive_time": { + "description": "收货时间/调入时间", + "type": "string" + }, + "remark": { + "description": "备注", + "type": "string" + }, "serial_number": { "description": "单据编号", "type": "string" @@ -13527,6 +13545,10 @@ const docTemplate = `{ "description": "调拨数量", "type": "integer" }, + "audit_time": { + "description": "审核时间", + "type": "string" + }, "category_id": { "description": "商品分类id", "type": "integer" @@ -13559,6 +13581,10 @@ const docTemplate = `{ "description": "调入门店名称", "type": "string" }, + "receive_time": { + "description": "收货时间/调入时间", + "type": "string" + }, "state": { "description": "调拨状态:1-调拨中 2-已完成", "type": "integer" @@ -13748,9 +13774,9 @@ const docTemplate = `{ "description": "数量", "type": "integer" }, - "state": { - "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", - "type": "integer" + "stock_time": { + "description": "出入库时间", + "type": "string" }, "store_id": { "description": "门店id", @@ -13759,6 +13785,10 @@ const docTemplate = `{ "store_name": { "description": "门店名称", "type": "string" + }, + "type": { + "description": "出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", + "type": "integer" } } }, @@ -13854,10 +13884,6 @@ const docTemplate = `{ "description": "单据编号", "type": "string" }, - "state": { - "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", - "type": "integer" - }, "stock_time": { "description": "出入库时间", "type": "string" @@ -13877,6 +13903,10 @@ const docTemplate = `{ "supplier_name": { "description": "供应商名称", "type": "string" + }, + "type": { + "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", + "type": "integer" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index 445863a..5711bdd 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7938,6 +7938,10 @@ "description": "库存调拨订单表id", "type": "integer" }, + "amount": { + "description": "金额(采购价)", + "type": "number" + }, "commodity_id": { "description": "商品id", "type": "integer" @@ -10517,7 +10521,7 @@ "type": "string" }, "dispatch_count": { - "description": "调拨中数量", + "description": "调拨中数量(调拨中调入)", "type": "integer" }, "erp_category_id": { @@ -10734,6 +10738,10 @@ "description": "是否串码:0-查全部 1-查串码类 2-查非串码", "type": "integer" }, + "original_sn": { + "description": "首次入库订单编号", + "type": "string" + }, "pageIndex": { "description": "页码", "type": "integer" @@ -10750,10 +10758,6 @@ "description": "商品编号", "type": "string" }, - "sn": { - "description": "首次入库订单编号", - "type": "string" - }, "state": { "description": "库存状态:1-在库 2-已售 3-采购退货 4-调拨中 5-出库(前端只看1,4)", "type": "integer" @@ -11688,7 +11692,10 @@ }, "deliver_store_id": { "description": "调出门店id", - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } }, "is_export": { "description": "1-导出", @@ -11704,7 +11711,10 @@ }, "receive_store_id": { "description": "调入门店id", - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } }, "receive_time_end": { "description": "调入结束时间", @@ -11888,16 +11898,16 @@ "description": "开始时间/入库时间", "type": "string" }, - "state": { - "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", - "type": "integer" - }, "store_id": { "description": "门店id", "type": "array", "items": { "type": "integer" } + }, + "type": { + "description": "出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", + "type": "integer" } } }, @@ -12069,16 +12079,16 @@ "description": "开始时间/入库时间", "type": "string" }, - "state": { - "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", - "type": "integer" - }, "store_id": { "description": "门店id", "type": "array", "items": { "type": "integer" } + }, + "type": { + "description": "出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", + "type": "integer" } } }, @@ -13495,6 +13505,14 @@ "description": "调入门店名称", "type": "string" }, + "receive_time": { + "description": "收货时间/调入时间", + "type": "string" + }, + "remark": { + "description": "备注", + "type": "string" + }, "serial_number": { "description": "单据编号", "type": "string" @@ -13516,6 +13534,10 @@ "description": "调拨数量", "type": "integer" }, + "audit_time": { + "description": "审核时间", + "type": "string" + }, "category_id": { "description": "商品分类id", "type": "integer" @@ -13548,6 +13570,10 @@ "description": "调入门店名称", "type": "string" }, + "receive_time": { + "description": "收货时间/调入时间", + "type": "string" + }, "state": { "description": "调拨状态:1-调拨中 2-已完成", "type": "integer" @@ -13737,9 +13763,9 @@ "description": "数量", "type": "integer" }, - "state": { - "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", - "type": "integer" + "stock_time": { + "description": "出入库时间", + "type": "string" }, "store_id": { "description": "门店id", @@ -13748,6 +13774,10 @@ "store_name": { "description": "门店名称", "type": "string" + }, + "type": { + "description": "出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", + "type": "integer" } } }, @@ -13843,10 +13873,6 @@ "description": "单据编号", "type": "string" }, - "state": { - "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", - "type": "integer" - }, "stock_time": { "description": "出入库时间", "type": "string" @@ -13866,6 +13892,10 @@ "supplier_name": { "description": "供应商名称", "type": "string" + }, + "type": { + "description": "调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库", + "type": "integer" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index c1758c3..1ba9d27 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1492,6 +1492,9 @@ definitions: allot_order_id: description: 库存调拨订单表id type: integer + amount: + description: 金额(采购价) + type: number commodity_id: description: 商品id type: integer @@ -3377,7 +3380,7 @@ definitions: description: 创建时间 type: string dispatch_count: - description: 调拨中数量 + description: 调拨中数量(调拨中调入) type: integer erp_category_id: description: 分类id @@ -3538,6 +3541,9 @@ definitions: is_imei: description: 是否串码:0-查全部 1-查串码类 2-查非串码 type: integer + original_sn: + description: 首次入库订单编号 + type: string pageIndex: description: 页码 type: integer @@ -3550,9 +3556,6 @@ definitions: serial_number: description: 商品编号 type: string - sn: - description: 首次入库订单编号 - type: string state: description: 库存状态:1-在库 2-已售 3-采购退货 4-调拨中 5-出库(前端只看1,4) type: integer @@ -4228,7 +4231,9 @@ definitions: type: array deliver_store_id: description: 调出门店id - type: integer + items: + type: integer + type: array is_export: description: 1-导出 type: integer @@ -4240,7 +4245,9 @@ definitions: type: integer receive_store_id: description: 调入门店id - type: integer + items: + type: integer + type: array receive_time_end: description: 调入结束时间 type: string @@ -4372,14 +4379,14 @@ definitions: start_time: description: 开始时间/入库时间 type: string - state: - description: 调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 - type: integer store_id: description: 门店id items: type: integer type: array + type: + description: 出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 + type: integer type: object models.InventoryReportByOtherResp: properties: @@ -4502,14 +4509,14 @@ definitions: start_time: description: 开始时间/入库时间 type: string - state: - description: 调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 - type: integer store_id: description: 门店id items: type: integer type: array + type: + description: 出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 + type: integer type: object models.InventoryReportOtherDetailResp: properties: @@ -5522,6 +5529,12 @@ definitions: receive_store_name: description: 调入门店名称 type: string + receive_time: + description: 收货时间/调入时间 + type: string + remark: + description: 备注 + type: string serial_number: description: 单据编号 type: string @@ -5537,6 +5550,9 @@ definitions: allot_count: description: 调拨数量 type: integer + audit_time: + description: 审核时间 + type: string category_id: description: 商品分类id type: integer @@ -5561,6 +5577,9 @@ definitions: receive_store_name: description: 调入门店名称 type: string + receive_time: + description: 收货时间/调入时间 + type: string state: description: 调拨状态:1-调拨中 2-已完成 type: integer @@ -5700,15 +5719,18 @@ definitions: count: description: 数量 type: integer - state: - description: 调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 - type: integer + stock_time: + description: 出入库时间 + type: string store_id: description: 门店id type: integer store_name: description: 门店名称 type: string + type: + description: 出入库方式:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 + type: integer type: object models.ReportByProductData: properties: @@ -5778,9 +5800,6 @@ definitions: serial_number: description: 单据编号 type: string - state: - description: 调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 - type: integer stock_time: description: 出入库时间 type: string @@ -5796,6 +5815,9 @@ definitions: supplier_name: description: 供应商名称 type: string + type: + description: 调拨状态:1-产品入库 2-盘点入库 3-系统出库 4-盘点出库 + type: integer type: object models.RetailDetailTotalData: properties: