diff --git a/app/admin/apis/basic/commodity.go b/app/admin/apis/basic/commodity.go index 82f6220..ef84532 100644 --- a/app/admin/apis/basic/commodity.go +++ b/app/admin/apis/basic/commodity.go @@ -93,15 +93,16 @@ func CommodityCreate(c *gin.Context) { RetailPrice: req.RetailPrice, MinRetailPrice: req.MinRetailPrice, //StaffCostPrice: req.StaffCostPrice + req.WholesalePrice, - StaffCostPrice: req.StaffCostPrice, - WholesalePrice: req.WholesalePrice, - Brokerage1: brokerage1Float, - Brokerage2: brokerage2Float, - MemberDiscount: memberDiscountFloat, - Origin: req.Origin, - Remark: req.Remark, - Img: req.Img, - StopPurchase: req.StopPurchase, + StaffCostPrice: req.StaffCostPrice, + WholesalePrice: req.WholesalePrice, + Brokerage1: brokerage1Float, + Brokerage2: brokerage2Float, + MemberDiscount: memberDiscountFloat, + Origin: req.Origin, + Remark: req.Remark, + Img: req.Img, + StopPurchase: req.StopPurchase, + ManufacturerCode: req.ManufacturerCode, } err = commodity.SetErpCategory() if err != nil { @@ -258,15 +259,16 @@ func CommodityEdit(c *gin.Context) { RetailPrice: req.RetailPrice, MinRetailPrice: req.MinRetailPrice, //StaffCostPrice: req.StaffCostPrice + req.WholesalePrice, - StaffCostPrice: req.StaffCostPrice, - WholesalePrice: req.WholesalePrice, - Brokerage1: brokerage1Float, - Brokerage2: brokerage2Float, - MemberDiscount: memberDiscountFloat, - Origin: req.Origin, - Remark: req.Remark, - Img: req.Img, - StopPurchase: req.StopPurchase, + StaffCostPrice: req.StaffCostPrice, + WholesalePrice: req.WholesalePrice, + Brokerage1: brokerage1Float, + Brokerage2: brokerage2Float, + MemberDiscount: memberDiscountFloat, + Origin: req.Origin, + Remark: req.Remark, + Img: req.Img, + StopPurchase: req.StopPurchase, + ManufacturerCode: req.ManufacturerCode, } commodity.ID = req.Id err = commodity.SetErpCategory() diff --git a/app/admin/models/commodity.go b/app/admin/models/commodity.go index fe4e460..81f82f3 100644 --- a/app/admin/models/commodity.go +++ b/app/admin/models/commodity.go @@ -102,29 +102,30 @@ type ErpStockCommodity struct { type ErpCommodity struct { Model - SerialNumber string `json:"serial_number"` // 商品编号 - Number uint32 `json:"number"` // 商品数量 - Name string `json:"name"` // 商品名称 - ErpCategoryId uint32 `json:"erp_category_id" gorm:"index"` // 商品分类id - ErpCategoryName string `json:"erp_category_name"` // 商品分类名称 - ErpBarcode string `json:"erp_barcode"` // 商品条码 - IsIMEI uint32 `json:"is_imei" gorm:"-"` // 是否串码:1-串码类 2-非串码 - IMEIType uint32 `json:"imei_type"` // 1-无串码 2-串码(系统生成) 3-串码(手动添加) - IMEI string `json:"imei"` // 串码 - ErpSupplierId uint32 `json:"erp_supplier_id" gorm:"index"` // 主供应商id - ErpSupplierName string `json:"erp_supplier_name"` // 主供应商名称 - RetailPrice float64 `json:"retail_price"` // 指导零售价 - MinRetailPrice float64 `json:"min_retail_price"` // 最低零售价 - StaffCostPrice float64 `json:"staff_cost_price"` // 员工成本价加价(如:加价50,不是加价后的价格) - WholesalePrice float64 `json:"wholesale_price"` // 指导采购价 - Brokerage1 float64 `json:"brokerage_1"` // 销售毛利提成 - Brokerage2 float64 `json:"brokerage_2"` // 员工毛利提成 - MemberDiscount float64 `json:"member_discount"` // 会员优惠 - Origin string `json:"origin"` // 产地 - Remark string `json:"remark" gorm:"type:varchar(512)"` // 备注 - StockCount uint32 `json:"stock_count" gorm:"-"` // 库存数量 - Img string `json:"img"` // 图片 - StopPurchase uint32 `json:"stop_purchase"` // 0-未勾选,正常采购;1-勾选,停止采购 + SerialNumber string `json:"serial_number"` // 商品编号 + Number uint32 `json:"number"` // 商品数量 + Name string `json:"name"` // 商品名称 + ErpCategoryId uint32 `json:"erp_category_id" gorm:"index"` // 商品分类id + ErpCategoryName string `json:"erp_category_name"` // 商品分类名称 + ErpBarcode string `json:"erp_barcode"` // 商品条码 + IsIMEI uint32 `json:"is_imei" gorm:"-"` // 是否串码:1-串码类 2-非串码 + IMEIType uint32 `json:"imei_type"` // 1-无串码 2-串码(系统生成) 3-串码(手动添加) + IMEI string `json:"imei"` // 串码 + ErpSupplierId uint32 `json:"erp_supplier_id" gorm:"index"` // 主供应商id + ErpSupplierName string `json:"erp_supplier_name"` // 主供应商名称 + RetailPrice float64 `json:"retail_price"` // 指导零售价 + MinRetailPrice float64 `json:"min_retail_price"` // 最低零售价 + StaffCostPrice float64 `json:"staff_cost_price"` // 员工成本价加价(如:加价50,不是加价后的价格) + WholesalePrice float64 `json:"wholesale_price"` // 指导采购价 + Brokerage1 float64 `json:"brokerage_1"` // 销售毛利提成 + Brokerage2 float64 `json:"brokerage_2"` // 员工毛利提成 + MemberDiscount float64 `json:"member_discount"` // 会员优惠 + Origin string `json:"origin"` // 产地 + Remark string `json:"remark" gorm:"type:varchar(512)"` // 备注 + StockCount uint32 `json:"stock_count" gorm:"-"` // 库存数量 + Img string `json:"img"` // 图片 + StopPurchase uint32 `json:"stop_purchase"` // 0-未勾选,正常采购;1-勾选,停止采购 + ManufacturerCode string `json:"manufacturer_code"` // 厂家编码 ErpCategory *ErpCategory `json:"erp_category" gorm:"-"` } @@ -3610,44 +3611,46 @@ func GetErpCommodityMap(ids []uint32) (map[uint32]ErpCommodity, error) { } type CommodityCreateRequest struct { - Name string `json:"name" binding:"required"` // 商品名称 - ErpCategoryId uint32 `json:"erp_category_id" binding:"required"` // 商品分类id - IsIMEI uint32 `json:"is_imei" binding:"required"` // 是否串码:1-串码类 2-非串码 - ErpBarcode string `json:"erp_barcode"` // 商品条码 - IMEIType uint32 `json:"imei_type"` // 系统生成串码:2-是(系统生成) 3-否(手动添加) - ErpSupplierId uint32 `json:"erp_supplier_id" binding:"required"` // 主供应商 - RetailPrice float64 `json:"retail_price"` // 指导零售价 - MinRetailPrice float64 `json:"min_retail_price"` // 最低零售价 - StaffCostPrice float64 `json:"staff_cost_price"` // 员工成本价加价 - WholesalePrice float64 `json:"wholesale_price"` // 指导采购价 - Brokerage1 float64 `json:"brokerage_1"` // 销售毛利提成 - Brokerage2 float64 `json:"brokerage_2"` // 员工毛利提成 - MemberDiscount float64 `json:"member_discount"` // 会员优惠 - Origin string `json:"origin"` // 产地 - Remark string `json:"remark"` // 备注 - Img string `json:"img"` // 图片 - StopPurchase uint32 `json:"stop_purchase"` // 0-未勾选,正常采购;1-勾选,停止采购 + Name string `json:"name" binding:"required"` // 商品名称 + ErpCategoryId uint32 `json:"erp_category_id" binding:"required"` // 商品分类id + IsIMEI uint32 `json:"is_imei" binding:"required"` // 是否串码:1-串码类 2-非串码 + ErpBarcode string `json:"erp_barcode"` // 商品条码 + IMEIType uint32 `json:"imei_type"` // 系统生成串码:2-是(系统生成) 3-否(手动添加) + ErpSupplierId uint32 `json:"erp_supplier_id" binding:"required"` // 主供应商 + RetailPrice float64 `json:"retail_price"` // 指导零售价 + MinRetailPrice float64 `json:"min_retail_price"` // 最低零售价 + StaffCostPrice float64 `json:"staff_cost_price"` // 员工成本价加价 + WholesalePrice float64 `json:"wholesale_price"` // 指导采购价 + Brokerage1 float64 `json:"brokerage_1"` // 销售毛利提成 + Brokerage2 float64 `json:"brokerage_2"` // 员工毛利提成 + MemberDiscount float64 `json:"member_discount"` // 会员优惠 + Origin string `json:"origin"` // 产地 + Remark string `json:"remark"` // 备注 + Img string `json:"img"` // 图片 + StopPurchase uint32 `json:"stop_purchase"` // 0-未勾选,正常采购;1-勾选,停止采购 + ManufacturerCode string `json:"manufacturer_code"` // 厂家编码 } type CommodityEditRequest struct { - Id uint32 `json:"id" binding:"required"` // 商品id - Name string `json:"name" binding:"required"` // 商品名称 - ErpCategoryId uint32 `json:"erp_category_id" binding:"required"` // 商品分类id - ErpBarcode string `json:"erp_barcode"` // 商品条码 - IsIMEI uint32 `json:"is_imei" binding:"required"` // 是否串码:1-串码类 2-非串码 - IMEIType uint32 `json:"imei_type" binding:"required"` // 1-无串码 2-串码(系统生成) 3-串码(手动添加) - ErpSupplierId uint32 `json:"erp_supplier_id" binding:"required"` // 主供应商id - RetailPrice float64 `json:"retail_price"` // 指导零售价 - MinRetailPrice float64 `json:"min_retail_price"` // 最低零售价 - StaffCostPrice float64 `json:"staff_cost_price"` // 员工成本价加价 - WholesalePrice float64 `json:"wholesale_price"` // 指导采购价 - Brokerage1 float64 `json:"brokerage_1"` // 销售毛利提成 - Brokerage2 float64 `json:"brokerage_2"` // 员工毛利提成 - MemberDiscount float64 `json:"member_discount"` // 会员优惠 - Origin string `json:"origin"` // 产地 - Remark string `json:"remark"` // 备注 - Img string `json:"img"` // 图片 - StopPurchase uint32 `json:"stop_purchase"` // 0-未勾选,正常采购;1-勾选,停止采购 + Id uint32 `json:"id" binding:"required"` // 商品id + Name string `json:"name" binding:"required"` // 商品名称 + ErpCategoryId uint32 `json:"erp_category_id" binding:"required"` // 商品分类id + ErpBarcode string `json:"erp_barcode"` // 商品条码 + IsIMEI uint32 `json:"is_imei" binding:"required"` // 是否串码:1-串码类 2-非串码 + IMEIType uint32 `json:"imei_type" binding:"required"` // 1-无串码 2-串码(系统生成) 3-串码(手动添加) + ErpSupplierId uint32 `json:"erp_supplier_id" binding:"required"` // 主供应商id + RetailPrice float64 `json:"retail_price"` // 指导零售价 + MinRetailPrice float64 `json:"min_retail_price"` // 最低零售价 + StaffCostPrice float64 `json:"staff_cost_price"` // 员工成本价加价 + WholesalePrice float64 `json:"wholesale_price"` // 指导采购价 + Brokerage1 float64 `json:"brokerage_1"` // 销售毛利提成 + Brokerage2 float64 `json:"brokerage_2"` // 员工毛利提成 + MemberDiscount float64 `json:"member_discount"` // 会员优惠 + Origin string `json:"origin"` // 产地 + Remark string `json:"remark"` // 备注 + Img string `json:"img"` // 图片 + StopPurchase uint32 `json:"stop_purchase"` // 0-未勾选,正常采购;1-勾选,停止采购 + ManufacturerCode string `json:"manufacturer_code"` // 厂家编码 } type CommodityDetailRequest struct { diff --git a/app/admin/models/purchase.go b/app/admin/models/purchase.go index d90cb12..ec2deaf 100644 --- a/app/admin/models/purchase.go +++ b/app/admin/models/purchase.go @@ -292,6 +292,7 @@ type DemandData struct { ErpCommodityName string `json:"erp_commodity_name"` // 商品名称 ErpCategoryID uint32 `json:"erp_category_id"` // 商品分类id ErpCategoryName string `json:"erp_category_name"` // 商品分类名称 + ErpManufacturerCode string `json:"erp_manufacturer_code"` // 商品厂家编码 Img string `json:"img"` // 图片 RetailPrice float64 `json:"retail_price"` // 指导零售价 LastWholesalePrice float64 `json:"last_wholesale_price"` // 最近采购价 @@ -2243,6 +2244,7 @@ func convertToDemandDataAll(commodity ErpCommodity, usedStore []uint32, stores [ ErpCommodityID: commodity.ID, ErpCommoditySerialNumber: commodity.SerialNumber, ErpCommodityName: commodity.Name, + ErpManufacturerCode: commodity.ManufacturerCode, ErpCategoryID: commodity.ErpCategoryId, ErpCategoryName: commodity.ErpCategoryName, RetailPrice: commodity.RetailPrice, @@ -2545,6 +2547,7 @@ func convertToDemandData(commodity ErpCommodity, usedStore []uint32, stores []St ErpCommodityID: commodity.ID, ErpCommoditySerialNumber: commodity.SerialNumber, ErpCommodityName: commodity.Name, + ErpManufacturerCode: commodity.ManufacturerCode, ErpCategoryID: commodity.ErpCategoryId, ErpCategoryName: commodity.ErpCategoryName, RetailPrice: commodity.RetailPrice, @@ -2991,20 +2994,20 @@ func demandDataExport(list []DemandData) (string, error) { fmt.Println("url fileName:", url+fileName) // 组合标题栏第一行数据 - title1 := []interface{}{"主供应商", "商品名称", "商品编号", "商品分类", "指导零售价", "最近采购价"} + title1 := []interface{}{"主供应商", "商品名称", "商品编号", "商品分类", "厂家编码", "指导零售价", "最近采购价"} storeCount := len(list[0].StoreList) var mergeCells []string // 存储需要合并的单元格范围 for _, v := range list[0].StoreList { - for i := 0; i < 3; i++ { + for i := 0; i < 4; i++ { title1 = append(title1, v.StoreName) } } for i := 0; i < storeCount; i++ { // 计算每个商户名称的起始和结束单元格 - startCol, _ := excelize.ColumnNumberToName(7 + i*3) // 从第7列开始,每个商户占3列 - endCol, _ := excelize.ColumnNumberToName(9 + i*3) + startCol, _ := excelize.ColumnNumberToName(8 + i*4) // 从第8列开始,每个商户占4列 + endCol, _ := excelize.ColumnNumberToName(11 + i*4) mergeCell := startCol + "1:" + endCol + "1" mergeCells = append(mergeCells, mergeCell) } @@ -3020,9 +3023,10 @@ func demandDataExport(list []DemandData) (string, error) { } // 组合标题栏第二行数据 - title2 := []interface{}{"主供应商", "商品名称", "商品编号", "商品分类", "指导零售价", "最近采购价"} + title2 := []interface{}{"主供应商", "商品名称", "商品编号", "商品分类", "厂家编码", "指导零售价", "最近采购价"} for _, _ = range list[0].StoreList { title2 = append(title2, "上月销售数") + title2 = append(title2, "上周销售数") title2 = append(title2, "库存数量") title2 = append(title2, "需采购数") } @@ -3054,6 +3058,7 @@ func demandDataExport(list []DemandData) (string, error) { list[i].ErpCommodityName, // 商品名称 list[i].ErpCommoditySerialNumber, // 商品编号 list[i].ErpCategoryName, // 商品分类名称 + list[i].ErpManufacturerCode, // 商品厂家编码 list[i].RetailPrice, // 指导零售价 list[i].LastWholesalePrice, // 最近采购价 } @@ -3065,6 +3070,12 @@ func demandDataExport(list []DemandData) (string, error) { row = append(row, "") } + if v.LastWeekSales != 0 { + row = append(row, v.LastWeekSales) // 上周销售数 + } else { + row = append(row, "") + } + if v.StockCount != 0 { row = append(row, v.StockCount) // 库存数量 } else { @@ -3103,7 +3114,7 @@ func demandDataExport(list []DemandData) (string, error) { } // 合并 "需采购总数量","需采购总金额" 和 "备注" 列的单元格 - strTotalCountCol, strTotalAmountCol, strRemarkCol := computeExtraColumns("F", storeCount) + strTotalCountCol, strTotalAmountCol, strRemarkCol := computeExtraColumns("G", storeCount) _ = file.MergeCell(fSheet, strTotalCountCol+"1", strTotalCountCol+"2") _ = file.MergeCell(fSheet, strTotalAmountCol+"1", strTotalAmountCol+"2") _ = file.MergeCell(fSheet, strRemarkCol+"1", strRemarkCol+"2") @@ -3125,6 +3136,7 @@ func demandDataExport(list []DemandData) (string, error) { _ = file.MergeCell(fSheet, "D1", "D2") _ = file.MergeCell(fSheet, "E1", "E2") _ = file.MergeCell(fSheet, "F1", "F2") + _ = file.MergeCell(fSheet, "G1", "G2") fmt.Println("save fileName:", config.ExportConfig.Path+fileName) if err := file.SaveAs(config.ExportConfig.Path + fileName); err != nil { @@ -3155,8 +3167,8 @@ func demandDataExportOnShopAssistant(list []DemandData) (string, error) { for i := 0; i < storeCount; i++ { // 计算每个商户名称的起始和结束单元格 - startCol, _ := excelize.ColumnNumberToName(5 + i*3) // 从第5列开始,每个商户占3列 - endCol, _ := excelize.ColumnNumberToName(7 + i*3) + startCol, _ := excelize.ColumnNumberToName(5 + i*4) // 从第5列开始,每个商户占4列 + endCol, _ := excelize.ColumnNumberToName(7 + i*4) mergeCell := startCol + "1:" + endCol + "1" mergeCells = append(mergeCells, mergeCell) } @@ -3173,6 +3185,7 @@ func demandDataExportOnShopAssistant(list []DemandData) (string, error) { title2 := []interface{}{"商品名称", "商品编号", "商品分类", "指导零售价"} for _, _ = range list[0].StoreList { title2 = append(title2, "上月销售数") + title2 = append(title2, "上周销售数") title2 = append(title2, "库存数量") title2 = append(title2, "需采购数") } @@ -3211,6 +3224,12 @@ func demandDataExportOnShopAssistant(list []DemandData) (string, error) { row = append(row, "") } + if v.LastWeekSales != 0 { + row = append(row, v.LastWeekSales) // 上周销售数 + } else { + row = append(row, "") + } + if v.StockCount != 0 { row = append(row, v.StockCount) // 库存数量 } else { @@ -3275,7 +3294,7 @@ func splitMergeCellCoordinates(cell string) (string, string) { // 计算 "需采购总数量","需采购总金额" 和 "备注" 列的坐标字符串 func computeExtraColumns(startCol string, storeCount int) (string, string, string) { // "需采购总数量" 列在商户列表结束后的下一列 - totalCountCol := convertColumnToLetters(convertLettersToColumn(startCol) + storeCount*3 + 1) + totalCountCol := convertColumnToLetters(convertLettersToColumn(startCol) + storeCount*4 + 1) // "需采购总金额" 列在 "需采购总数量" 列的下一列 totalAmountCol := convertColumnToLetters(convertLettersToColumn(totalCountCol) + 1) diff --git a/docs/docs.go b/docs/docs.go index 7d479a2..1b314f9 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -7474,6 +7474,10 @@ const docTemplate = `{ "description": "是否串码:1-串码类 2-非串码", "type": "integer" }, + "manufacturer_code": { + "description": "厂家编码", + "type": "string" + }, "member_discount": { "description": "会员优惠", "type": "number" @@ -7584,6 +7588,10 @@ const docTemplate = `{ "description": "是否串码:1-串码类 2-非串码", "type": "integer" }, + "manufacturer_code": { + "description": "厂家编码", + "type": "string" + }, "member_discount": { "description": "会员优惠", "type": "number" @@ -8480,6 +8488,10 @@ const docTemplate = `{ "description": "商品编号", "type": "string" }, + "erp_manufacturer_code": { + "description": "商品厂家编码", + "type": "string" + }, "erp_supplier_id": { "description": "主供应商id", "type": "integer" @@ -8816,6 +8828,10 @@ const docTemplate = `{ "description": "是否串码:1-串码类 2-非串码", "type": "integer" }, + "manufacturer_code": { + "description": "厂家编码", + "type": "string" + }, "member_discount": { "description": "会员优惠", "type": "number" diff --git a/docs/swagger.json b/docs/swagger.json index bd66c96..92bf0b9 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7463,6 +7463,10 @@ "description": "是否串码:1-串码类 2-非串码", "type": "integer" }, + "manufacturer_code": { + "description": "厂家编码", + "type": "string" + }, "member_discount": { "description": "会员优惠", "type": "number" @@ -7573,6 +7577,10 @@ "description": "是否串码:1-串码类 2-非串码", "type": "integer" }, + "manufacturer_code": { + "description": "厂家编码", + "type": "string" + }, "member_discount": { "description": "会员优惠", "type": "number" @@ -8469,6 +8477,10 @@ "description": "商品编号", "type": "string" }, + "erp_manufacturer_code": { + "description": "商品厂家编码", + "type": "string" + }, "erp_supplier_id": { "description": "主供应商id", "type": "integer" @@ -8805,6 +8817,10 @@ "description": "是否串码:1-串码类 2-非串码", "type": "integer" }, + "manufacturer_code": { + "description": "厂家编码", + "type": "string" + }, "member_discount": { "description": "会员优惠", "type": "number" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 749e907..c4b76aa 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -570,6 +570,9 @@ definitions: is_imei: description: 是否串码:1-串码类 2-非串码 type: integer + manufacturer_code: + description: 厂家编码 + type: string member_discount: description: 会员优惠 type: number @@ -649,6 +652,9 @@ definitions: is_imei: description: 是否串码:1-串码类 2-非串码 type: integer + manufacturer_code: + description: 厂家编码 + type: string member_discount: description: 会员优惠 type: number @@ -1314,6 +1320,9 @@ definitions: erp_commodity_serial_number: description: 商品编号 type: string + erp_manufacturer_code: + description: 商品厂家编码 + type: string erp_supplier_id: description: 主供应商id type: integer @@ -1557,6 +1566,9 @@ definitions: is_imei: description: 是否串码:1-串码类 2-非串码 type: integer + manufacturer_code: + description: 厂家编码 + type: string member_discount: description: 会员优惠 type: number