1.优化excel导出,门店经营、商品零售毛利汇总、零售明细等页面支持敏感字段配置隐藏或展示;
This commit is contained in:
parent
6fb8697585
commit
1212d9dd1e
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -300,6 +300,8 @@ type ErpOrderRetailMarginResp struct {
|
|||
TotalEmployeeCost float64 `json:"total_employee_cost"` // 总员工成本:商品员工成本价之和
|
||||
TotalSalesMargin float64 `json:"total_sales_margin"` // 总销售毛利:销售/退货金额-销售成本
|
||||
TotalGrossMargins string `json:"total_gross_margins"` // 销售毛利率:销售毛利/销售/退货金额
|
||||
TotalEmployeeMargin float64 `json:"total_employee_margin"` // 总员工毛利:销售金额/实际退货金额-员工成本
|
||||
TotalEmployeeGrossMargins string `json:"total_employee_gross_margins"` // 总员工毛利率: 员工毛利/销售/退货金额
|
||||
ExportUrl string `json:"export_url"`
|
||||
}
|
||||
|
||||
|
@ -318,6 +320,8 @@ type RetailMarginData struct {
|
|||
EmployeeCost float64 `json:"employee_cost"` // 员工成本:商品员工成本价之和
|
||||
SalesMargin float64 `json:"sales_margin"` // 销售毛利:销售/退货金额-销售成本
|
||||
GrossMargins string `json:"gross_margins"` // 销售毛利率:销售毛利/销售/退货金额
|
||||
EmployeeMargin float64 `json:"employee_margin"` // 员工毛利:零售销售时:销售金额-员工成本 零售退货时:实际退货金额-员工成本
|
||||
EmployeeGrossMargins string `json:"employee_gross_margins"` // 员工毛利率: 零售销售时:员工毛利/销售金额 零售退货时:员工毛利/退货金额
|
||||
}
|
||||
|
||||
// ErpOrderRetailDetailReq 零售明细汇总入参
|
||||
|
@ -2249,7 +2253,7 @@ func QueryStoreManageData(req *ErpOrderStoreManageDataReq, c *gin.Context) (*Erp
|
|||
}
|
||||
|
||||
finalStoreManageDataList = constructFinalStoreManageDataList(storeManageDataList, req)
|
||||
filePath, err := storeManageDataExport(finalStoreManageDataList, storeName)
|
||||
filePath, err := storeManageDataExport(finalStoreManageDataList, storeName, c)
|
||||
if err != nil {
|
||||
logger.Error("StoreManageDataExport err:", logger.Field("err", err))
|
||||
return nil, err
|
||||
|
@ -2328,7 +2332,7 @@ func constructFinalStoreManageDataList(storeManageDataList []StoreManageData, re
|
|||
}
|
||||
|
||||
// StoreManageDataExport 导出门店经营数据
|
||||
func storeManageDataExport(list []StoreManageData, storeName string) (string, error) {
|
||||
func storeManageDataExport(list []StoreManageData, storeName string, c *gin.Context) (string, error) {
|
||||
file := excelize.NewFile()
|
||||
fSheet := "Sheet1"
|
||||
|
||||
|
@ -2336,7 +2340,26 @@ func storeManageDataExport(list []StoreManageData, storeName string) (string, er
|
|||
fileName := time.Now().Format(TimeFormat) + storeName + "经营数据" + ".xlsx"
|
||||
fmt.Println("url fileName:", url+fileName)
|
||||
|
||||
title := []interface{}{"时间", "销售额", "推广费", "销售毛利", "员工毛利", "销售数量"}
|
||||
// 判断是否有入销售毛利、员工毛利的权限
|
||||
flag1, _ := checkRoleMenu(c, SalesProfitMenu)
|
||||
flag2, _ := checkRoleMenu(c, StaffProfitMenu)
|
||||
fmt.Println("flag1 is:", flag1)
|
||||
fmt.Println("flag2 is:", flag2)
|
||||
logger.Info("flag1 is:", logger.Field("flag1", flag1))
|
||||
logger.Info("flag2 is:", logger.Field("flag2", flag2))
|
||||
|
||||
nEndCount := 0
|
||||
title := []interface{}{"时间", "销售额", "推广费"}
|
||||
if flag1 { // 销售毛利
|
||||
title = append(title, "销售毛利")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag2 { // 员工毛利
|
||||
title = append(title, "员工毛利")
|
||||
nEndCount += 1
|
||||
}
|
||||
title = append(title, "销售数量")
|
||||
|
||||
for i, _ := range title {
|
||||
cell, _ := excelize.CoordinatesToCellName(1+i, 1)
|
||||
err := file.SetCellValue(fSheet, cell, title[i])
|
||||
|
@ -2352,11 +2375,17 @@ func storeManageDataExport(list []StoreManageData, storeName string) (string, er
|
|||
list[rowId].Date,
|
||||
list[rowId].TotalSalesAmount,
|
||||
list[rowId].PromotionFee,
|
||||
list[rowId].SalesProfit,
|
||||
list[rowId].StaffProfit,
|
||||
list[rowId].Count,
|
||||
}
|
||||
|
||||
// 控制是否导出
|
||||
if flag1 { // 销售毛利
|
||||
row = append(row, list[rowId].SalesProfit)
|
||||
}
|
||||
if flag2 { // 员工毛利
|
||||
row = append(row, list[rowId].StaffProfit)
|
||||
}
|
||||
row = append(row, list[rowId].Count)
|
||||
|
||||
for j, _ := range row {
|
||||
cell, _ := excelize.CoordinatesToCellName(1+j, nExcelStartRow+2)
|
||||
err := file.SetCellValue(fSheet, cell, row[j])
|
||||
|
@ -2380,7 +2409,15 @@ func storeManageDataExport(list []StoreManageData, storeName string) (string, er
|
|||
// 设置单元格大小
|
||||
file.SetColWidth("Sheet1", "A", "A", 18)
|
||||
|
||||
endRow := fmt.Sprintf("F"+"%d", nExcelStartRow+1)
|
||||
var endRow string
|
||||
switch nEndCount {
|
||||
case 1:
|
||||
endRow = fmt.Sprintf("E"+"%d", nExcelStartRow+1)
|
||||
case 2:
|
||||
endRow = fmt.Sprintf("F"+"%d", nExcelStartRow+1)
|
||||
default:
|
||||
endRow = fmt.Sprintf("D"+"%d", nExcelStartRow+1)
|
||||
}
|
||||
// 应用样式到整个表格
|
||||
_ = file.SetCellStyle("Sheet1", "A1", endRow, style)
|
||||
|
||||
|
@ -2393,21 +2430,54 @@ func storeManageDataExport(list []StoreManageData, storeName string) (string, er
|
|||
}
|
||||
|
||||
// retailMarginDataExport 导出商品零售毛利汇总数据
|
||||
func retailMarginDataExport(req *ErpOrderRetailMarginResp) (string, error) {
|
||||
func retailMarginDataExport(req *ErpOrderRetailMarginResp, c *gin.Context) (string, error) {
|
||||
file := excelize.NewFile()
|
||||
streamWriter, err := file.NewStreamWriter("Sheet1")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fSheet := "Sheet1"
|
||||
|
||||
url := ExportUrl
|
||||
fileName := time.Now().Format(TimeFormat) + "商品零售毛利汇总" + ".xlsx"
|
||||
fmt.Println("url fileName:", url+fileName)
|
||||
|
||||
title := []interface{}{"店铺名称", "零售类型", "商品名称", "商品分类", "数量", "销售/退货金额", "销售成本", "销售毛利", "销售毛利率"}
|
||||
cell, _ := excelize.CoordinatesToCellName(1, 1)
|
||||
if err = streamWriter.SetRow(cell, title); err != nil {
|
||||
fmt.Println(err)
|
||||
nEndCount := 0
|
||||
title := []interface{}{"店铺名称", "零售类型", "商品名称", "商品分类", "数量", "销售/退货金额"}
|
||||
// 判断是否有权限
|
||||
flag1, _ := checkRoleMenu(c, SalesCostMenu)
|
||||
flag2, _ := checkRoleMenu(c, EmployeeCostMenu)
|
||||
flag3, _ := checkRoleMenu(c, SalesMarginMenu)
|
||||
flag4, _ := checkRoleMenu(c, EmployeeMarginMenu)
|
||||
flag5, _ := checkRoleMenu(c, GrossMarginsMenu)
|
||||
flag6, _ := checkRoleMenu(c, EmployeeGrossMarginsMenu)
|
||||
if flag1 {
|
||||
title = append(title, "销售成本")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag2 {
|
||||
title = append(title, "员工成本")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag3 {
|
||||
title = append(title, "销售毛利")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag4 {
|
||||
title = append(title, "员工毛利")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag5 {
|
||||
title = append(title, "销售毛利率")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag6 {
|
||||
title = append(title, "员工毛利率")
|
||||
nEndCount += 1
|
||||
}
|
||||
|
||||
for i, _ := range title {
|
||||
cell, _ := excelize.CoordinatesToCellName(1+i, 1)
|
||||
err := file.SetCellValue(fSheet, cell, title[i])
|
||||
if err != nil {
|
||||
logger.Errorf("file set value err:", err)
|
||||
}
|
||||
}
|
||||
|
||||
var row []interface{}
|
||||
|
@ -2429,35 +2499,106 @@ func retailMarginDataExport(req *ErpOrderRetailMarginResp) (string, error) {
|
|||
req.List[rowId].ErpCategoryName,
|
||||
req.List[rowId].Count,
|
||||
req.List[rowId].SalesAmount,
|
||||
req.List[rowId].SalesCost,
|
||||
req.List[rowId].SalesMargin,
|
||||
req.List[rowId].GrossMargins,
|
||||
}
|
||||
|
||||
cell, _ := excelize.CoordinatesToCellName(1, nExcelStartRow+2)
|
||||
if err := streamWriter.SetRow(cell, row); err != nil {
|
||||
fmt.Println(err)
|
||||
if flag1 { // 销售成本
|
||||
row = append(row, req.List[rowId].SalesCost)
|
||||
}
|
||||
if flag2 { // 员工成本
|
||||
row = append(row, req.List[rowId].EmployeeCost)
|
||||
}
|
||||
if flag3 { // 销售毛利
|
||||
row = append(row, req.List[rowId].SalesMargin)
|
||||
}
|
||||
if flag4 { // 员工毛利
|
||||
row = append(row, req.List[rowId].EmployeeMargin)
|
||||
}
|
||||
if flag5 { // 销售毛利率
|
||||
row = append(row, req.List[rowId].GrossMargins)
|
||||
}
|
||||
if flag6 { // 员工毛利率
|
||||
row = append(row, req.List[rowId].EmployeeGrossMargins)
|
||||
}
|
||||
|
||||
for j, _ := range row {
|
||||
cell, _ := excelize.CoordinatesToCellName(1+j, nExcelStartRow+2)
|
||||
err := file.SetCellValue(fSheet, cell, row[j])
|
||||
if err != nil {
|
||||
logger.Error("file set value err:", logger.Field("err", err))
|
||||
}
|
||||
}
|
||||
nExcelStartRow++
|
||||
}
|
||||
|
||||
totalData := "汇总 记录数:" + strconv.FormatInt(int64(req.TotalCount), 10)
|
||||
end := []interface{}{totalData, "", "", "", req.TotalCount, fmt.Sprintf("%.2f", req.TotalSalesAmount),
|
||||
fmt.Sprintf("%.2f", req.TotalSalesCost),
|
||||
fmt.Sprintf("%.2f", req.TotalSalesMargin),
|
||||
req.TotalGrossMargins}
|
||||
cell, _ = excelize.CoordinatesToCellName(1, nExcelStartRow+2)
|
||||
if err := streamWriter.SetRow(cell, end); err != nil {
|
||||
fmt.Println(err)
|
||||
end := []interface{}{totalData, "", "", "", req.TotalCount, fmt.Sprintf("%.2f", req.TotalSalesAmount)}
|
||||
|
||||
if flag1 { // 销售成本
|
||||
end = append(end, req.TotalSalesCost)
|
||||
}
|
||||
if flag2 { // 员工成本
|
||||
end = append(end, req.TotalEmployeeCost)
|
||||
}
|
||||
if flag3 { // 销售毛利
|
||||
end = append(end, req.TotalSalesMargin)
|
||||
}
|
||||
if flag4 { // 员工毛利
|
||||
end = append(end, req.TotalEmployeeMargin)
|
||||
}
|
||||
if flag5 { // 销售毛利率
|
||||
end = append(end, req.TotalGrossMargins)
|
||||
}
|
||||
if flag6 { // 员工毛利率
|
||||
end = append(end, req.TotalEmployeeGrossMargins)
|
||||
}
|
||||
|
||||
if err := streamWriter.Flush(); err != nil {
|
||||
fmt.Println(err)
|
||||
for i, _ := range end {
|
||||
cell, _ := excelize.CoordinatesToCellName(1+i, nExcelStartRow+2)
|
||||
err := file.SetCellValue(fSheet, cell, end[i])
|
||||
if err != nil {
|
||||
logger.Error("file set value err:", logger.Field("err", err))
|
||||
}
|
||||
}
|
||||
|
||||
// 设置所有单元格的样式: 居中、加边框
|
||||
style, _ := file.NewStyle(`{"alignment":{"horizontal":"center","vertical":"center"},
|
||||
"border":[{"type":"left","color":"000000","style":1},
|
||||
{"type":"top","color":"000000","style":1},
|
||||
{"type":"right","color":"000000","style":1},
|
||||
{"type":"bottom","color":"000000","style":1}]}`)
|
||||
|
||||
//设置单元格高度
|
||||
file.SetRowHeight("Sheet1", 1, 30)
|
||||
// 设置单元格大小
|
||||
file.SetColWidth("Sheet1", "A", "A", 26)
|
||||
file.SetColWidth("Sheet1", "C", "C", 45)
|
||||
file.SetColWidth("Sheet1", "F", "F", 15)
|
||||
|
||||
var endRow string
|
||||
switch nEndCount {
|
||||
case 1:
|
||||
endRow = fmt.Sprintf("G"+"%d", nExcelStartRow+2)
|
||||
case 2:
|
||||
endRow = fmt.Sprintf("H"+"%d", nExcelStartRow+2)
|
||||
case 3:
|
||||
endRow = fmt.Sprintf("I"+"%d", nExcelStartRow+2)
|
||||
case 4:
|
||||
endRow = fmt.Sprintf("J"+"%d", nExcelStartRow+2)
|
||||
case 5:
|
||||
endRow = fmt.Sprintf("K"+"%d", nExcelStartRow+2)
|
||||
case 6:
|
||||
endRow = fmt.Sprintf("L"+"%d", nExcelStartRow+2)
|
||||
default:
|
||||
endRow = fmt.Sprintf("F"+"%d", nExcelStartRow+2)
|
||||
}
|
||||
// 应用样式到整个表格
|
||||
_ = file.SetCellStyle("Sheet1", "A1", endRow, style)
|
||||
|
||||
fmt.Println("save fileName:", config.ExportConfig.Path+fileName)
|
||||
if err := file.SaveAs(config.ExportConfig.Path + fileName); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
return url + fileName, nil
|
||||
}
|
||||
|
||||
|
@ -2609,19 +2750,21 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
|
|||
key := fmt.Sprintf("%d_%d_%s", item.StoreID, item.ErpCommodityId, item.RetailType)
|
||||
|
||||
var nCount int32
|
||||
var salesAmount, salesCost, employeeCost, salesMargin float64
|
||||
var salesAmount, salesCost, employeeCost, salesMargin, employeeMargin float64
|
||||
if item.RetailType == RetailTypeRejected {
|
||||
nCount = -int32(item.Count)
|
||||
salesAmount = -item.RejectedAmount // 退货订单要以实际退货金额为准
|
||||
salesCost = -item.WholesalePrice * float64(item.Count)
|
||||
employeeCost = -(item.WholesalePrice + item.StaffCostPrice) * float64(item.Count)
|
||||
salesMargin = -(item.ReceivedAmount - item.WholesalePrice*float64(item.Count))
|
||||
employeeMargin = -(item.ReceivedAmount - (item.WholesalePrice+item.StaffCostPrice)*float64(item.Count))
|
||||
} else {
|
||||
nCount = int32(item.Count)
|
||||
salesAmount = item.ReceivedAmount
|
||||
salesCost = item.WholesalePrice * float64(item.Count)
|
||||
employeeCost = (item.WholesalePrice + item.StaffCostPrice) * float64(item.Count)
|
||||
salesMargin = item.ReceivedAmount - item.WholesalePrice*float64(item.Count)
|
||||
employeeMargin = item.ReceivedAmount - (item.WholesalePrice+item.StaffCostPrice)*float64(item.Count)
|
||||
}
|
||||
// 检查是否已经处理过这个组合的数据
|
||||
if existingData, ok := processedData[key]; ok {
|
||||
|
@ -2631,6 +2774,7 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
|
|||
existingData.SalesCost += salesCost
|
||||
existingData.SalesMargin += salesMargin
|
||||
existingData.EmployeeCost += employeeCost
|
||||
existingData.EmployeeMargin += employeeMargin
|
||||
|
||||
// 处理数据,四舍五入保留2位小数
|
||||
existingData.SalesAmount = math.Round(existingData.SalesAmount*100) / 100
|
||||
|
@ -2640,8 +2784,10 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
|
|||
|
||||
if existingData.SalesAmount == 0 {
|
||||
existingData.GrossMargins = "--"
|
||||
existingData.EmployeeGrossMargins = "--"
|
||||
} else {
|
||||
existingData.GrossMargins = float64ToPercentage(existingData.SalesMargin / existingData.SalesAmount)
|
||||
existingData.EmployeeGrossMargins = float64ToPercentage(existingData.EmployeeMargin / existingData.SalesAmount)
|
||||
}
|
||||
} else {
|
||||
// 如果不存在,说明是新数据,直接添加到列表中
|
||||
|
@ -2659,18 +2805,22 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
|
|||
EmployeeCost: (item.WholesalePrice + item.StaffCostPrice) * float64(item.Count),
|
||||
SalesMargin: item.ReceivedAmount - item.WholesalePrice*float64(item.Count),
|
||||
GrossMargins: "--",
|
||||
EmployeeMargin: item.ReceivedAmount - (item.WholesalePrice+item.StaffCostPrice)*float64(item.Count),
|
||||
EmployeeGrossMargins: "--",
|
||||
//GrossMargins: float64ToPercentage((item.ReceivedAmount - float64(int32(item.WholesalePrice)*item.Total)) / item.ReceivedAmount),
|
||||
}
|
||||
if item.ReceivedAmount != 0 {
|
||||
data.GrossMargins = float64ToPercentage((item.ReceivedAmount - item.WholesalePrice*float64(item.Count)) / item.ReceivedAmount)
|
||||
data.EmployeeGrossMargins = float64ToPercentage((item.ReceivedAmount - (item.WholesalePrice+item.StaffCostPrice)*float64(item.Count)) / item.ReceivedAmount)
|
||||
}
|
||||
|
||||
// 如果是拒绝的销售,进行相应的处理
|
||||
// 如果是零售退货订单,进行相应的处理
|
||||
if data.RetailType == RetailTypeRejected {
|
||||
data.SalesAmount = -data.SalesAmount
|
||||
data.SalesCost = -data.SalesCost
|
||||
data.SalesMargin = -data.SalesMargin
|
||||
data.EmployeeCost = -data.EmployeeCost
|
||||
data.EmployeeMargin = -data.EmployeeMargin
|
||||
}
|
||||
|
||||
// 处理数据,四舍五入保留2位小数
|
||||
|
@ -2678,6 +2828,7 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
|
|||
data.SalesCost = math.Round(data.SalesCost*100) / 100
|
||||
data.SalesMargin = math.Round(data.SalesMargin*100) / 100
|
||||
data.EmployeeCost = math.Round(data.EmployeeCost*100) / 100
|
||||
data.EmployeeMargin = math.Round(data.EmployeeMargin*100) / 100
|
||||
|
||||
// 将新数据添加到 map 中
|
||||
processedData[key] = data
|
||||
|
@ -2696,6 +2847,7 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
|
|||
resp.TotalSalesCost += data.SalesCost
|
||||
resp.TotalSalesMargin += data.SalesMargin
|
||||
resp.TotalEmployeeCost += data.EmployeeCost
|
||||
resp.TotalEmployeeMargin += data.EmployeeMargin
|
||||
}
|
||||
|
||||
// 处理数据,四舍五入保留2位小数
|
||||
|
@ -2703,10 +2855,13 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
|
|||
resp.TotalSalesCost = math.Round(resp.TotalSalesCost*100) / 100
|
||||
resp.TotalSalesMargin = math.Round(resp.TotalSalesMargin*100) / 100
|
||||
resp.TotalEmployeeCost = math.Round(resp.TotalEmployeeCost*100) / 100
|
||||
resp.TotalEmployeeMargin = math.Round(resp.TotalEmployeeMargin*100) / 100
|
||||
if resp.TotalSalesAmount != 0 {
|
||||
resp.TotalGrossMargins = float64ToPercentage(resp.TotalSalesMargin / resp.TotalSalesAmount)
|
||||
resp.TotalEmployeeGrossMargins = float64ToPercentage(resp.TotalEmployeeMargin / resp.TotalSalesAmount)
|
||||
} else {
|
||||
resp.TotalGrossMargins = "--"
|
||||
resp.TotalEmployeeGrossMargins = "--"
|
||||
}
|
||||
|
||||
// 对列表按照您想要的顺序进行排序
|
||||
|
@ -2728,12 +2883,13 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
|
|||
resp.List = list
|
||||
|
||||
if req.IsExport == 1 { //导出excel
|
||||
filePath, err := retailMarginDataExport(resp)
|
||||
filePath, err := retailMarginDataExport(resp, c)
|
||||
if err != nil {
|
||||
logger.Error("StoreManageDataExport err:", logger.Field("err", err))
|
||||
return nil, err
|
||||
}
|
||||
resp.ExportUrl = filePath
|
||||
resp.List = nil
|
||||
} else {
|
||||
// 计算分页所需的切片索引
|
||||
startIndex := page * req.PageSize
|
||||
|
@ -3055,7 +3211,7 @@ func retailDetailExportBack(list []ErpOrder, sumData RetailDetailTotalData) (str
|
|||
}
|
||||
|
||||
// 导出零售明细报表excel-不合并
|
||||
func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData) (string, error) {
|
||||
func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData, c *gin.Context) (string, error) {
|
||||
file := excelize.NewFile()
|
||||
fSheet := "Sheet1"
|
||||
|
||||
|
@ -3063,10 +3219,68 @@ func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData) (string,
|
|||
fileName := time.Now().Format(TimeFormat) + "零售明细" + ".xlsx"
|
||||
fmt.Println("url fileName:", url+fileName)
|
||||
|
||||
// 判断是否有权限
|
||||
flag1, _ := checkRoleMenu(c, DetailWholesalePriceMenu)
|
||||
flag2, _ := checkRoleMenu(c, DetailEmployeeCostMenu)
|
||||
flag3, _ := checkRoleMenu(c, DetailSalesProfitMenu)
|
||||
flag4, _ := checkRoleMenu(c, DetailStaffProfitMenu)
|
||||
flag5, _ := checkRoleMenu(c, DetailTotalSalesProfitMenu)
|
||||
flag6, _ := checkRoleMenu(c, DetailTotalStaffProfitMenu)
|
||||
flag7, _ := checkRoleMenu(c, DetailSalesProfitPerMenu)
|
||||
flag8, _ := checkRoleMenu(c, DetailStaffProfitPerMenu)
|
||||
flag9, _ := checkRoleMenu(c, DetailSalesmanPerMenu)
|
||||
flag10, _ := checkRoleMenu(c, DetailStorePerMenu)
|
||||
|
||||
nEndCount := 0
|
||||
title := []interface{}{"订单编号", "订单类型", "用户ID", "客户手机号", "审核时间", "店铺", "银联流水号", "销售员", "商品分类", "商品名称",
|
||||
"供应商", "是否串码", "商品串码", "是否赠送", "销售数量", "指导零售价", "零售价", "零售优惠", "会员优惠", "实际零售价/退货价",
|
||||
"采购单价", "员工成本价", "销售毛利", "员工毛利", "订单总指导零售价", "订单总优惠", "订单实收", "【扫码付", "现金收款", "pos机收款",
|
||||
"商场积分抵扣", "其他付款方式】", "订单总销售毛利", "订单总员工毛利", "销售毛利提成", "员工毛利提成", "销售员提成", "门店提成", "备注"}
|
||||
"供应商", "是否串码", "商品串码", "是否赠送", "销售数量", "指导零售价", "零售价", "零售优惠", "会员优惠", "实际零售价/退货价"}
|
||||
|
||||
if flag1 { // 采购单价
|
||||
title = append(title, "采购单价")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag2 { // 员工成本价
|
||||
title = append(title, "员工成本价")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag3 { // 销售毛利
|
||||
title = append(title, "销售毛利")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag4 { // 员工毛利
|
||||
title = append(title, "员工毛利")
|
||||
nEndCount += 1
|
||||
}
|
||||
|
||||
title = append(title, "订单总指导零售价", "订单总优惠", "订单实收", "【扫码付", "现金收款", "pos机收款",
|
||||
"商场积分抵扣", "其他付款方式】")
|
||||
if flag5 { // 订单总销售毛利
|
||||
title = append(title, "订单总销售毛利")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag6 { // 订单总员工毛利
|
||||
title = append(title, "订单总员工毛利")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag7 { // 销售毛利提成
|
||||
title = append(title, "销售毛利提成")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag8 { // 员工毛利提成
|
||||
title = append(title, "员工毛利提成")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag9 { // 销售员提成
|
||||
title = append(title, "销售员提成")
|
||||
nEndCount += 1
|
||||
}
|
||||
if flag10 { // 门店提成
|
||||
title = append(title, "门店提成")
|
||||
nEndCount += 1
|
||||
}
|
||||
|
||||
title = append(title, "备注")
|
||||
|
||||
for i, _ := range title {
|
||||
cell, _ := excelize.CoordinatesToCellName(1+i, 1)
|
||||
err := file.SetCellValue(fSheet, cell, title[i])
|
||||
|
@ -3165,26 +3379,73 @@ func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData) (string,
|
|||
list[i].Commodities[rowId].SaleDiscount,
|
||||
list[i].Commodities[rowId].MemberDiscount,
|
||||
nAmount,
|
||||
list[i].Commodities[rowId].WholesalePrice,
|
||||
list[i].Commodities[rowId].WholesalePrice + list[i].Commodities[rowId].StaffCostPrice,
|
||||
list[i].Commodities[rowId].SalesProfit,
|
||||
list[i].Commodities[rowId].StaffProfit,
|
||||
list[i].TotalRetailPrice,
|
||||
list[i].TotalDiscount,
|
||||
list[i].TotalAmount,
|
||||
cashierData.ScanAmount, // 扫码付
|
||||
cashierData.CashAmount, // 现金收款
|
||||
cashierData.PosAmount, // pos机收款
|
||||
cashierData.StoreVmAmount, // 商场积分抵扣
|
||||
cashierData.OtherAmount, // 其他付款方式
|
||||
list[i].TotalSalesProfit,
|
||||
list[i].TotalStaffProfit,
|
||||
nSalesProfitPer, // 销售毛利提成
|
||||
nStaffProfitPer, // 员工毛利提成
|
||||
nSalesmanPer, // 销售员提成
|
||||
list[i].StorePer,
|
||||
list[i].Commodities[rowId].Remark,
|
||||
//list[i].Commodities[rowId].WholesalePrice,
|
||||
//list[i].Commodities[rowId].WholesalePrice + list[i].Commodities[rowId].StaffCostPrice,
|
||||
//list[i].Commodities[rowId].SalesProfit,
|
||||
//list[i].Commodities[rowId].StaffProfit,
|
||||
|
||||
//list[i].TotalRetailPrice,
|
||||
//list[i].TotalDiscount,
|
||||
//list[i].TotalAmount,
|
||||
//cashierData.ScanAmount, // 扫码付
|
||||
//cashierData.CashAmount, // 现金收款
|
||||
//cashierData.PosAmount, // pos机收款
|
||||
//cashierData.StoreVmAmount, // 商场积分抵扣
|
||||
//cashierData.OtherAmount, // 其他付款方式
|
||||
|
||||
//list[i].TotalSalesProfit,
|
||||
//list[i].TotalStaffProfit,
|
||||
//nSalesProfitPer, // 销售毛利提成
|
||||
//nStaffProfitPer, // 员工毛利提成
|
||||
//nSalesmanPer, // 销售员提成
|
||||
//list[i].StorePer,
|
||||
|
||||
//list[i].Commodities[rowId].Remark,
|
||||
}
|
||||
|
||||
// 控制是否导出
|
||||
if flag1 { // 采购单价
|
||||
row = append(row, list[i].Commodities[rowId].WholesalePrice)
|
||||
}
|
||||
if flag2 { // 员工成本价
|
||||
row = append(row, list[i].Commodities[rowId].WholesalePrice+list[i].Commodities[rowId].StaffCostPrice)
|
||||
}
|
||||
if flag3 { // 销售毛利
|
||||
row = append(row, list[i].Commodities[rowId].SalesProfit)
|
||||
}
|
||||
if flag4 { // 员工毛利
|
||||
row = append(row, list[i].Commodities[rowId].StaffProfit)
|
||||
}
|
||||
|
||||
row = append(row, list[i].TotalRetailPrice)
|
||||
row = append(row, list[i].TotalDiscount)
|
||||
row = append(row, list[i].TotalAmount)
|
||||
row = append(row, cashierData.ScanAmount)
|
||||
row = append(row, cashierData.CashAmount)
|
||||
row = append(row, cashierData.PosAmount)
|
||||
row = append(row, cashierData.StoreVmAmount)
|
||||
row = append(row, cashierData.OtherAmount)
|
||||
|
||||
if flag5 { // 订单总销售毛利
|
||||
row = append(row, list[i].TotalSalesProfit)
|
||||
}
|
||||
if flag6 { // 订单总员工毛利
|
||||
row = append(row, list[i].TotalStaffProfit)
|
||||
}
|
||||
if flag7 { // 销售毛利提成
|
||||
row = append(row, nSalesProfitPer)
|
||||
}
|
||||
if flag8 { // 员工毛利提成
|
||||
row = append(row, nStaffProfitPer)
|
||||
}
|
||||
if flag9 { // 销售员提成
|
||||
row = append(row, nSalesmanPer)
|
||||
}
|
||||
if flag10 { // 门店提成
|
||||
row = append(row, list[i].StorePer)
|
||||
}
|
||||
|
||||
row = append(row, list[i].Commodities[rowId].Remark)
|
||||
} else {
|
||||
if len(list[i].Salesman) == 2 && rowId == 1 {
|
||||
row = []interface{}{
|
||||
|
@ -3208,26 +3469,73 @@ func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData) (string,
|
|||
list[i].Commodities[rowId].SaleDiscount,
|
||||
list[i].Commodities[rowId].MemberDiscount,
|
||||
nAmount,
|
||||
list[i].Commodities[rowId].WholesalePrice,
|
||||
list[i].Commodities[rowId].WholesalePrice + list[i].Commodities[rowId].StaffCostPrice,
|
||||
list[i].Commodities[rowId].SalesProfit,
|
||||
list[i].Commodities[rowId].StaffProfit,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
math.Round(list[i].Salesman[1].SalesProfitPer*100) / 100, // 销售毛利提成
|
||||
math.Round(list[i].Salesman[1].StaffProfitPer*100) / 100, // 员工毛利提成
|
||||
math.Round(list[i].Salesman[1].SalesmanPer*100) / 100, // 销售员提成
|
||||
"",
|
||||
"",
|
||||
|
||||
//list[i].Commodities[rowId].WholesalePrice,
|
||||
//list[i].Commodities[rowId].WholesalePrice + list[i].Commodities[rowId].StaffCostPrice,
|
||||
//list[i].Commodities[rowId].SalesProfit,
|
||||
//list[i].Commodities[rowId].StaffProfit,
|
||||
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
|
||||
//"",
|
||||
//"",
|
||||
//math.Round(list[i].Salesman[1].SalesProfitPer*100) / 100, // 销售毛利提成
|
||||
//math.Round(list[i].Salesman[1].StaffProfitPer*100) / 100, // 员工毛利提成
|
||||
//math.Round(list[i].Salesman[1].SalesmanPer*100) / 100, // 销售员提成
|
||||
//"",
|
||||
|
||||
//"",
|
||||
}
|
||||
// 控制是否导出
|
||||
if flag1 { // 采购单价
|
||||
row = append(row, list[i].Commodities[rowId].WholesalePrice)
|
||||
}
|
||||
if flag2 { // 员工成本价
|
||||
row = append(row, list[i].Commodities[rowId].WholesalePrice+list[i].Commodities[rowId].StaffCostPrice)
|
||||
}
|
||||
if flag3 { // 销售毛利
|
||||
row = append(row, list[i].Commodities[rowId].SalesProfit)
|
||||
}
|
||||
if flag4 { // 员工毛利
|
||||
row = append(row, list[i].Commodities[rowId].StaffProfit)
|
||||
}
|
||||
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
|
||||
if flag5 { // 订单总销售毛利
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag6 { // 订单总员工毛利
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag7 { // 销售毛利提成
|
||||
row = append(row, math.Round(list[i].Salesman[1].SalesProfitPer*100)/100)
|
||||
}
|
||||
if flag8 { // 员工毛利提成
|
||||
row = append(row, math.Round(list[i].Salesman[1].StaffProfitPer*100)/100)
|
||||
}
|
||||
if flag9 { // 销售员提成
|
||||
row = append(row, math.Round(list[i].Salesman[1].SalesmanPer*100)/100)
|
||||
}
|
||||
if flag10 { // 门店提成
|
||||
row = append(row, "")
|
||||
}
|
||||
|
||||
row = append(row, "")
|
||||
} else {
|
||||
row = []interface{}{
|
||||
"",
|
||||
|
@ -3250,26 +3558,73 @@ func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData) (string,
|
|||
list[i].Commodities[rowId].SaleDiscount,
|
||||
list[i].Commodities[rowId].MemberDiscount,
|
||||
nAmount,
|
||||
list[i].Commodities[rowId].WholesalePrice,
|
||||
list[i].Commodities[rowId].WholesalePrice + list[i].Commodities[rowId].StaffCostPrice,
|
||||
list[i].Commodities[rowId].SalesProfit,
|
||||
list[i].Commodities[rowId].StaffProfit,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"", // 销售毛利提成
|
||||
"", // 员工毛利提成
|
||||
"", // 销售员提成
|
||||
"",
|
||||
"",
|
||||
|
||||
//list[i].Commodities[rowId].WholesalePrice,
|
||||
//list[i].Commodities[rowId].WholesalePrice + list[i].Commodities[rowId].StaffCostPrice,
|
||||
//list[i].Commodities[rowId].SalesProfit,
|
||||
//list[i].Commodities[rowId].StaffProfit,
|
||||
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
|
||||
//"",
|
||||
//"",
|
||||
//"", // 销售毛利提成
|
||||
//"", // 员工毛利提成
|
||||
//"", // 销售员提成
|
||||
//"",
|
||||
|
||||
//"",
|
||||
}
|
||||
// 控制是否导出
|
||||
if flag1 { // 采购单价
|
||||
row = append(row, list[i].Commodities[rowId].WholesalePrice)
|
||||
}
|
||||
if flag2 { // 员工成本价
|
||||
row = append(row, list[i].Commodities[rowId].WholesalePrice+list[i].Commodities[rowId].StaffCostPrice)
|
||||
}
|
||||
if flag3 { // 销售毛利
|
||||
row = append(row, list[i].Commodities[rowId].SalesProfit)
|
||||
}
|
||||
if flag4 { // 员工毛利
|
||||
row = append(row, list[i].Commodities[rowId].StaffProfit)
|
||||
}
|
||||
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
|
||||
if flag5 { // 订单总销售毛利
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag6 { // 订单总员工毛利
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag7 { // 销售毛利提成
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag8 { // 员工毛利提成
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag9 { // 销售员提成
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag10 { // 门店提成
|
||||
row = append(row, "")
|
||||
}
|
||||
|
||||
row = append(row, "")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3304,26 +3659,73 @@ func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData) (string,
|
|||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
math.Round(list[i].Salesman[1].SalesProfitPer*100) / 100, // 销售毛利提成
|
||||
math.Round(list[i].Salesman[1].StaffProfitPer*100) / 100, // 员工毛利提成
|
||||
math.Round(list[i].Salesman[1].SalesmanPer*100) / 100, // 销售员提成
|
||||
"",
|
||||
"",
|
||||
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
//"",
|
||||
|
||||
//"",
|
||||
//"",
|
||||
//math.Round(list[i].Salesman[1].SalesProfitPer*100) / 100, // 销售毛利提成
|
||||
//math.Round(list[i].Salesman[1].StaffProfitPer*100) / 100, // 员工毛利提成
|
||||
//math.Round(list[i].Salesman[1].SalesmanPer*100) / 100, // 销售员提成
|
||||
//"",
|
||||
|
||||
//"",
|
||||
}
|
||||
// 控制是否导出
|
||||
if flag1 { // 采购单价
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag2 { // 员工成本价
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag3 { // 销售毛利
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag4 { // 员工毛利
|
||||
row = append(row, "")
|
||||
}
|
||||
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
row = append(row, "")
|
||||
|
||||
if flag5 { // 订单总销售毛利
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag6 { // 订单总员工毛利
|
||||
row = append(row, "")
|
||||
}
|
||||
if flag7 { // 销售毛利提成
|
||||
row = append(row, math.Round(list[i].Salesman[1].SalesProfitPer*100)/100)
|
||||
}
|
||||
if flag8 { // 员工毛利提成
|
||||
row = append(row, math.Round(list[i].Salesman[1].StaffProfitPer*100)/100)
|
||||
}
|
||||
if flag9 { // 销售员提成
|
||||
row = append(row, math.Round(list[i].Salesman[1].SalesmanPer*100)/100)
|
||||
}
|
||||
if flag10 { // 门店提成
|
||||
row = append(row, "")
|
||||
}
|
||||
|
||||
row = append(row, "")
|
||||
|
||||
for j, _ := range row {
|
||||
cell, _ := excelize.CoordinatesToCellName(1+j, nExcelStartRow+2)
|
||||
|
@ -3345,25 +3747,74 @@ func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData) (string,
|
|||
sumData.SaleDiscount,
|
||||
sumData.MemberDiscount,
|
||||
sumData.Amount,
|
||||
sumData.WholesalePrice,
|
||||
sumData.StaffPrice,
|
||||
sumData.SalesProfit,
|
||||
sumData.StaffProfit,
|
||||
sumData.TotalRetailPrice,
|
||||
sumData.TotalDiscount,
|
||||
sumData.TotalAmount,
|
||||
sumData.ScanAmount, // 扫码付
|
||||
sumData.CashAmount, // 现金收款
|
||||
sumData.PosAmount, // pos机收款
|
||||
sumData.StoreVmAmount, // 商场积分抵扣
|
||||
sumData.OtherAmount, // 其他付款方式
|
||||
sumData.TotalSalesProfit,
|
||||
sumData.TotalStaffProfit,
|
||||
sumData.TotalSalesProfitPer, // 销售毛利提成
|
||||
sumData.TotalStaffProfitPer, // 员工毛利提成
|
||||
sumData.SalesmanPer, // 销售员提成
|
||||
sumData.StorePer,
|
||||
""}
|
||||
|
||||
//sumData.WholesalePrice,
|
||||
//sumData.StaffPrice,
|
||||
//sumData.SalesProfit,
|
||||
//sumData.StaffProfit,
|
||||
|
||||
//sumData.TotalRetailPrice,
|
||||
//sumData.TotalDiscount,
|
||||
//sumData.TotalAmount,
|
||||
//sumData.ScanAmount, // 扫码付
|
||||
//sumData.CashAmount, // 现金收款
|
||||
//sumData.PosAmount, // pos机收款
|
||||
//sumData.StoreVmAmount, // 商场积分抵扣
|
||||
//sumData.OtherAmount, // 其他付款方式
|
||||
|
||||
//sumData.TotalSalesProfit,
|
||||
//sumData.TotalStaffProfit,
|
||||
//sumData.TotalSalesProfitPer, // 销售毛利提成
|
||||
//sumData.TotalStaffProfitPer, // 员工毛利提成
|
||||
//sumData.SalesmanPer, // 销售员提成
|
||||
//sumData.StorePer,
|
||||
|
||||
//""
|
||||
}
|
||||
|
||||
// 控制是否导出
|
||||
if flag1 { // 采购单价
|
||||
end = append(end, sumData.WholesalePrice)
|
||||
}
|
||||
if flag2 { // 员工成本价
|
||||
end = append(end, sumData.StaffPrice)
|
||||
}
|
||||
if flag3 { // 销售毛利
|
||||
end = append(end, sumData.SalesProfit)
|
||||
}
|
||||
if flag4 { // 员工毛利
|
||||
end = append(end, sumData.StaffProfit)
|
||||
}
|
||||
|
||||
end = append(end, sumData.TotalRetailPrice)
|
||||
end = append(end, sumData.TotalDiscount)
|
||||
end = append(end, sumData.TotalAmount)
|
||||
end = append(end, sumData.ScanAmount)
|
||||
end = append(end, sumData.CashAmount)
|
||||
end = append(end, sumData.PosAmount)
|
||||
end = append(end, sumData.StoreVmAmount)
|
||||
end = append(end, sumData.OtherAmount)
|
||||
|
||||
if flag5 { // 订单总销售毛利
|
||||
end = append(end, sumData.TotalSalesProfit)
|
||||
}
|
||||
if flag6 { // 订单总员工毛利
|
||||
end = append(end, sumData.TotalStaffProfit)
|
||||
}
|
||||
if flag7 { // 销售毛利提成
|
||||
end = append(end, sumData.TotalSalesProfitPer)
|
||||
}
|
||||
if flag8 { // 员工毛利提成
|
||||
end = append(end, sumData.TotalStaffProfitPer)
|
||||
}
|
||||
if flag9 { // 销售员提成
|
||||
end = append(end, sumData.SalesmanPer)
|
||||
}
|
||||
if flag10 { // 门店提成
|
||||
end = append(end, sumData.StorePer)
|
||||
}
|
||||
|
||||
end = append(end, "")
|
||||
|
||||
for i, _ := range end {
|
||||
cell, _ := excelize.CoordinatesToCellName(1+i, nExcelStartRow+2)
|
||||
|
@ -3378,7 +3829,32 @@ func retailDetailExport(list []ErpOrder, sumData RetailDetailTotalData) (string,
|
|||
// 设置单元格的样式: 居中、加边框、自动换行
|
||||
style1, _ := file.NewStyle(`{"alignment":{"horizontal":"center","vertical":"center","wrap_text":true}}`)
|
||||
|
||||
endRow := fmt.Sprintf("AL%d", nExcelStartRow+2)
|
||||
var endRow string
|
||||
switch nEndCount {
|
||||
case 1:
|
||||
endRow = fmt.Sprintf("AD"+"%d", nExcelStartRow+2)
|
||||
case 2:
|
||||
endRow = fmt.Sprintf("AE"+"%d", nExcelStartRow+2)
|
||||
case 3:
|
||||
endRow = fmt.Sprintf("AF"+"%d", nExcelStartRow+2)
|
||||
case 4:
|
||||
endRow = fmt.Sprintf("AG"+"%d", nExcelStartRow+2)
|
||||
case 5:
|
||||
endRow = fmt.Sprintf("AH"+"%d", nExcelStartRow+2)
|
||||
case 6:
|
||||
endRow = fmt.Sprintf("AI"+"%d", nExcelStartRow+2)
|
||||
case 7:
|
||||
endRow = fmt.Sprintf("AJ"+"%d", nExcelStartRow+2)
|
||||
case 8:
|
||||
endRow = fmt.Sprintf("AK"+"%d", nExcelStartRow+2)
|
||||
case 9:
|
||||
endRow = fmt.Sprintf("AL"+"%d", nExcelStartRow+2)
|
||||
case 10:
|
||||
endRow = fmt.Sprintf("AM"+"%d", nExcelStartRow+2)
|
||||
default:
|
||||
endRow = fmt.Sprintf("AC"+"%d", nExcelStartRow+2)
|
||||
}
|
||||
//endRow := fmt.Sprintf("AL%d", nExcelStartRow+2)
|
||||
// 应用样式到整个表格
|
||||
_ = file.SetCellStyle("Sheet1", "A1", endRow, style)
|
||||
|
||||
|
@ -3664,7 +4140,7 @@ func queryRetailDetailByJoin(req *ErpOrderRetailDetailReq, c *gin.Context) (*Erp
|
|||
|
||||
orders := packData(result)
|
||||
erpOrderSetBankTrxNo(orders)
|
||||
fileUrl, err := retailDetailExport(orders, sumData)
|
||||
fileUrl, err := retailDetailExport(orders, sumData, c)
|
||||
if err != nil {
|
||||
logger.Error("retailDetailExport err:", logger.Field("err", err))
|
||||
return resp, err
|
||||
|
@ -4037,7 +4513,7 @@ func queryRetailDetailCommon(req *ErpOrderRetailDetailReq, c *gin.Context) (*Erp
|
|||
erpOrderListSetSalesman(orders)
|
||||
erpOrderSetBankTrxNo(orders)
|
||||
|
||||
fileUrl, err := retailDetailExport(orders, sumData)
|
||||
fileUrl, err := retailDetailExport(orders, sumData, c)
|
||||
if err != nil {
|
||||
logger.Error("retailDetailExport err:", logger.Field("err", err))
|
||||
return resp, err
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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{}{"单据编号", "单据类型", "出/入库时间", "店铺名称", "供应商", "商品名称", "商品分类", "是否串码", "串码"}
|
||||
|
|
|
@ -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 {
|
||||
|
|
32
docs/docs.go
32
docs/docs.go
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user