1.优化excel导出,门店经营、商品零售毛利汇总、零售明细等页面支持敏感字段配置隐藏或展示;

This commit is contained in:
chenlin 2024-07-22 10:39:22 +08:00
parent 6fb8697585
commit 1212d9dd1e
9 changed files with 787 additions and 201 deletions

View File

@ -1472,7 +1472,7 @@ func checkRoleMenu(c *gin.Context, menuName string) (bool, error) {
}
// InventoryDetailListExport 导出库存商品列表
func InventoryDetailListExport(list []ErpStockCommodity, exportPurchasePrice bool, exportStaffCostPrice bool) (string, error) {
func InventoryDetailListExport(list []ErpStockCommodity, c *gin.Context) (string, error) {
file := excelize.NewFile()
streamWriter, err := file.NewStreamWriter("Sheet1")
if err != nil {
@ -1481,9 +1481,17 @@ func InventoryDetailListExport(list []ErpStockCommodity, exportPurchasePrice boo
}
url := ExportUrl
fileName := time.Now().Format(TimeFormat) + "商品" + ".xlsx"
fileName := time.Now().Format(TimeFormat) + "库存详情" + ".xlsx"
fmt.Println("url fileName:", url+fileName)
// 判断是否有入库采购价、入库员工成本价的权限
exportPurchasePrice, _ := checkRoleMenu(c, PurchasePrice)
exportStaffCostPrice, _ := checkRoleMenu(c, EmployeeCostPrice)
fmt.Println("exportPurchasePrice is:", exportPurchasePrice)
fmt.Println("exportStaffCostPrice is:", exportStaffCostPrice)
logger.Info("exportPurchasePrice is:", logger.Field("exportPurchasePrice", exportPurchasePrice))
logger.Info("exportStaffCostPrice is:", logger.Field("exportStaffCostPrice", exportStaffCostPrice))
// 设置标题行
title := []interface{}{"商品编号", "商品名称", "商品分类", "是否串码", "商品串码", "所属门店", "供应商", "首次入库时间", "首次入库方式",
"首次入库订单编号", "最近入库时间"}
@ -2429,14 +2437,8 @@ func (m *ErpStockCommodityListReq) GetDetailList(c *gin.Context, nType uint32) (
return resp, err
}
ErpStockCommodityListSetAge(commodities)
// 判断是否有入库采购价、入库员工成本价的权限
purchasePriceFlag, _ := checkRoleMenu(c, PurchasePrice)
employeeCostPriceFlag, _ := checkRoleMenu(c, EmployeeCostPrice)
fmt.Println("purchasePriceFlag is:", purchasePriceFlag)
fmt.Println("employeeCostPriceFlag is:", employeeCostPriceFlag)
logger.Info("purchasePriceFlag is:", logger.Field("purchasePriceFlag", purchasePriceFlag))
logger.Info("employeeCostPriceFlag is:", logger.Field("employeeCostPriceFlag", purchasePriceFlag))
listExport, err := InventoryDetailListExport(commodities, purchasePriceFlag, employeeCostPriceFlag)
listExport, err := InventoryDetailListExport(commodities, c)
if err != nil {
//logger.Error("list export err:", err)
}

View File

@ -159,7 +159,7 @@ func (m *ErpDecisionReportReq) DecisionReportList(c *gin.Context) (*ErpDecisionR
return nil, err
}
if len(m.StoreId) != 1 || (len(m.StoreId) == 1 && m.IsExport == 1) { // 查询所有门店数据
if len(m.StoreId) != 1 && m.IsExport != 1 { // 查询所有门店数据
// 剔除商品id重复的数据
var trimCommodities []ErpStock
tempCommodityMap := make(map[uint32]ErpStock)

File diff suppressed because it is too large Load Diff

View File

@ -8,12 +8,33 @@ import (
)
const (
PurchasePrice = "erp:stock:stockDetails:list:purchasePrice" // 入库采购价
EmployeeCostPrice = "erp:stock:stockDetails:list:employeeCostPrice" // 入库员工成本价
PurchasePrice = "erp:stock:stockDetails:list:purchasePrice" // 库存详情-入库采购价
EmployeeCostPrice = "erp:stock:stockDetails:list:employeeCostPrice" // 库存详情-入库员工成本价
PriceMenu = "erp:purchase:purchaseDetails:list:price" // 采购/退货价
EmployeePriceMenu = "erp:purchase:purchaseDetails:list:employee_price" // 员工成本价
DifferencePriceMenu = "erp:purchase:purchaseDetails:list:difference_price" // 差额
SalesProfitMenu = "erp:retail:storeMangement:salesProfit" // 门店经营-销售毛利
StaffProfitMenu = "erp:retail:storeMangement:staffProfit" // 门店经营-员工毛利
SalesCostMenu = "erp:retail:retailRemittance:salesCost" // 商品零售毛利汇总-销售成本
EmployeeCostMenu = "erp:retail:retailRemittance:staffCost" // 商品零售毛利汇总-员工成本
SalesMarginMenu = "erp:retail:retailRemittance:salesMargin" // 商品零售毛利汇总-销售毛利
EmployeeMarginMenu = "erp:retail:retailRemittance:employeeMargin" // 商品零售毛利汇总-员工毛利
GrossMarginsMenu = "erp:retail:retailRemittance:grossMargins" // 商品零售毛利汇总-销售毛利率
EmployeeGrossMarginsMenu = "erp:retail:retailRemittance:employeeGrossMargins" // 商品零售毛利汇总-员工毛利率
DetailWholesalePriceMenu = "erp:retail:reportForm:retailDetails:wholesalePrice" // 零售明细-采购单价
DetailEmployeeCostMenu = "erp:retail:reportForm:retailDetails:staffPrice" // 零售明细-员工成本价
DetailSalesProfitMenu = "erp:retail:reportForm:retailDetails:salesProfit" // 零售明细-销售毛利
DetailStaffProfitMenu = "erp:retail:reportForm:retailDetails:staffProfit" // 零售明细-员工毛利
DetailTotalSalesProfitMenu = "erp:retail:reportForm:retailDetails:totalSales" // 零售明细-订单总销售毛利
DetailTotalStaffProfitMenu = "erp:retail:reportForm:retailDetails:totalStaff" // 零售明细-订单总员工毛利
DetailSalesProfitPerMenu = "erp:retail:reportForm:retailDetails:salesProfitPer" // 零售明细-销售毛利提成
DetailStaffProfitPerMenu = "erp:retail:reportForm:retailDetails:staffProfitPer" // 零售明细-员工毛利提成
DetailSalesmanPerMenu = "erp:retail:reportForm:retailDetails:salesmanPer" // 零售明细-销售员提成
DetailStorePerMenu = "erp:retail:reportForm:retailDetails:storePer" // 零售明细-门店提成
)
type Menu struct {

View File

@ -5843,19 +5843,7 @@ func GetReportDetail(req *ErpPurchaseReportDetailReq, c *gin.Context) (*ErpPurch
if req.IsExport == 1 {
resp.List = reportList
// 判断是否有入库采购价、入库员工成本价的权限
priceFlag, _ := checkRoleMenu(c, PriceMenu)
employeePriceFlag, _ := checkRoleMenu(c, EmployeePriceMenu)
differencePriceFlag, _ := checkRoleMenu(c, DifferencePriceMenu)
fmt.Println("priceFlag is:", priceFlag)
fmt.Println("employeePriceFlag is:", employeePriceFlag)
fmt.Println("differencePriceFlag is:", differencePriceFlag)
logger.Info("priceFlag is:", logger.Field("priceFlag", priceFlag))
logger.Info("employeePriceFlag is:", logger.Field("employeePriceFlag", employeePriceFlag))
logger.Info("differencePriceFlag is:", logger.Field("differencePriceFlag", differencePriceFlag))
filePath, err := reportDetailExport(resp, priceFlag, employeePriceFlag, differencePriceFlag)
filePath, err := reportDetailExport(resp, c)
if err != nil {
return nil, err
}
@ -5903,8 +5891,7 @@ func calculatePrices(list []ReportDetailData) (price, employeePrice, rejectPrice
}
// 导出采购明细excel
func reportDetailExport(req *ErpPurchaseReportDetailResp, exportPrice bool,
exportEmployeePrice bool, exportDifferencePrice bool) (string, error) {
func reportDetailExport(req *ErpPurchaseReportDetailResp, c *gin.Context) (string, error) {
file := excelize.NewFile()
fSheet := "Sheet1"
@ -5912,6 +5899,17 @@ func reportDetailExport(req *ErpPurchaseReportDetailResp, exportPrice bool,
fileName := time.Now().Format(TimeFormat) + "采购明细" + ".xlsx"
fmt.Println("url fileName:", url+fileName)
// 判断是否有入库采购价、入库员工成本价的权限
exportPrice, _ := checkRoleMenu(c, PriceMenu)
exportEmployeePrice, _ := checkRoleMenu(c, EmployeePriceMenu)
exportDifferencePrice, _ := checkRoleMenu(c, DifferencePriceMenu)
fmt.Println("exportPrice is:", exportPrice)
fmt.Println("exportEmployeePrice is:", exportEmployeePrice)
fmt.Println("exportDifferencePrice is:", exportDifferencePrice)
logger.Info("exportPrice is:", logger.Field("exportPrice", exportPrice))
logger.Info("exportEmployeePrice is:", logger.Field("exportEmployeePrice", exportEmployeePrice))
logger.Info("exportDifferencePrice is:", logger.Field("exportDifferencePrice", exportDifferencePrice))
nEndCount := 0
// 组合标题栏数据
title := []interface{}{"单据编号", "单据类型", "出/入库时间", "店铺名称", "供应商", "商品名称", "商品分类", "是否串码", "串码"}

View File

@ -133,6 +133,8 @@ const StoreDateTimeFormat = "2006.01.02"
const (
ExportUrl = "https://admin.deovo.com/load/export/"
//ExportUrl = "https://dev.admin.deovo.com/load/export/" // dev环境
//ExportUrl = "/Users/max/Documents/" // 本地环境
)
type UserInvite struct {

View File

@ -5725,6 +5725,18 @@ const docTemplate = `{
"description": "门店id",
"name": "storeId",
"in": "query"
},
{
"type": "string",
"description": "店员兑换码",
"name": "shopper_code",
"in": "query"
},
{
"type": "string",
"description": "是否导出1-导出",
"name": "is_export",
"in": "query"
}
],
"responses": {
@ -9627,6 +9639,14 @@ const docTemplate = `{
"description": "总员工成本:商品员工成本价之和",
"type": "number"
},
"total_employee_gross_margins": {
"description": "总员工毛利率: 员工毛利/销售/退货金额",
"type": "string"
},
"total_employee_margin": {
"description": "总员工毛利:销售金额/实际退货金额-员工成本",
"type": "number"
},
"total_gross_margins": {
"description": "销售毛利率:销售毛利/销售/退货金额",
"type": "string"
@ -15135,6 +15155,14 @@ const docTemplate = `{
"description": "员工成本:商品员工成本价之和",
"type": "number"
},
"employee_gross_margins": {
"description": "员工毛利率: 零售销售时:员工毛利/销售金额 零售退货时:员工毛利/退货金额",
"type": "string"
},
"employee_margin": {
"description": "员工毛利:零售销售时:销售金额-员工成本 零售退货时:实际退货金额-员工成本",
"type": "number"
},
"erp_category_id": {
"description": "分类id",
"type": "integer"
@ -16110,6 +16138,10 @@ const docTemplate = `{
"description": "总条数",
"type": "integer"
},
"export_url": {
"description": "导出excel路径",
"type": "string"
},
"list": {
"description": "采购报表信息",
"type": "array",

View File

@ -5714,6 +5714,18 @@
"description": "门店id",
"name": "storeId",
"in": "query"
},
{
"type": "string",
"description": "店员兑换码",
"name": "shopper_code",
"in": "query"
},
{
"type": "string",
"description": "是否导出1-导出",
"name": "is_export",
"in": "query"
}
],
"responses": {
@ -9616,6 +9628,14 @@
"description": "总员工成本:商品员工成本价之和",
"type": "number"
},
"total_employee_gross_margins": {
"description": "总员工毛利率: 员工毛利/销售/退货金额",
"type": "string"
},
"total_employee_margin": {
"description": "总员工毛利:销售金额/实际退货金额-员工成本",
"type": "number"
},
"total_gross_margins": {
"description": "销售毛利率:销售毛利/销售/退货金额",
"type": "string"
@ -15124,6 +15144,14 @@
"description": "员工成本:商品员工成本价之和",
"type": "number"
},
"employee_gross_margins": {
"description": "员工毛利率: 零售销售时:员工毛利/销售金额 零售退货时:员工毛利/退货金额",
"type": "string"
},
"employee_margin": {
"description": "员工毛利:零售销售时:销售金额-员工成本 零售退货时:实际退货金额-员工成本",
"type": "number"
},
"erp_category_id": {
"description": "分类id",
"type": "integer"
@ -16099,6 +16127,10 @@
"description": "总条数",
"type": "integer"
},
"export_url": {
"description": "导出excel路径",
"type": "string"
},
"list": {
"description": "采购报表信息",
"type": "array",

View File

@ -2546,6 +2546,12 @@ definitions:
total_employee_cost:
description: 总员工成本:商品员工成本价之和
type: number
total_employee_gross_margins:
description: '总员工毛利率: 员工毛利/销售/退货金额'
type: string
total_employee_margin:
description: 总员工毛利:销售金额/实际退货金额-员工成本
type: number
total_gross_margins:
description: 销售毛利率:销售毛利/销售/退货金额
type: string
@ -6524,6 +6530,12 @@ definitions:
employee_cost:
description: 员工成本:商品员工成本价之和
type: number
employee_gross_margins:
description: '员工毛利率: 零售销售时:员工毛利/销售金额 零售退货时:员工毛利/退货金额'
type: string
employee_margin:
description: 员工毛利:零售销售时:销售金额-员工成本 零售退货时:实际退货金额-员工成本
type: number
erp_category_id:
description: 分类id
type: integer
@ -7228,6 +7240,9 @@ definitions:
count:
description: 总条数
type: integer
export_url:
description: 导出excel路径
type: string
list:
description: 采购报表信息
items:
@ -11569,6 +11584,14 @@ paths:
in: query
name: storeId
type: string
- description: 店员兑换码
in: query
name: shopper_code
type: string
- description: 是否导出1-导出
in: query
name: is_export
type: string
responses:
"200":
description: OK