1、优化经营日报表接口,增加销售数量字段;

2、优化零售明细和零售毛利汇总接口,店员只能看自己的业绩数据;
This commit is contained in:
chenlin 2024-11-13 16:24:43 +08:00
parent d33ea3a622
commit 3e118b8d5d
4 changed files with 27 additions and 3 deletions

View File

@ -3224,6 +3224,9 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq, c *gin.Context) (*ErpOrderR
if showConfig.ShowAll == "OFF" { if showConfig.ShowAll == "OFF" {
qs = qs.Where("is_print = ? or retail_type = ?", HavePrinted, RetailTypeRejected) qs = qs.Where("is_print = ? or retail_type = ?", HavePrinted, RetailTypeRejected)
} }
if tools.GetRoleName(c) == "shopper" {
qs = qs.Where("JSON_CONTAINS(salesman_list, ?)", fmt.Sprintf(`{"userId":%d}`, tools.GetUserId(c)))
}
var result []struct { var result []struct {
ErpOrderCommodity ErpOrderCommodity
@ -5008,10 +5011,16 @@ func queryRetailDetailCommon(req *ErpOrderRetailDetailReq, c *gin.Context) (*Erp
return nil, errors.New("用户未绑定门店") return nil, errors.New("用户未绑定门店")
} }
} }
if req.Salesman != 0 { // 销售员 if tools.GetRoleName(c) == "shopper" {
qs = qs.Where("JSON_CONTAINS(salesman_list, ?)", fmt.Sprintf(`{"userId":%d}`, req.Salesman)) qs = qs.Where("JSON_CONTAINS(salesman_list, ?)", fmt.Sprintf(`{"userId":%d}`, tools.GetUserId(c)))
totalPerQs = totalPerQs.Where("erp_order_sales.uid = ?", req.Salesman) totalPerQs = totalPerQs.Where("erp_order_sales.uid = ?", tools.GetUserId(c))
} else {
if req.Salesman != 0 { // 销售员
qs = qs.Where("JSON_CONTAINS(salesman_list, ?)", fmt.Sprintf(`{"userId":%d}`, req.Salesman))
totalPerQs = totalPerQs.Where("erp_order_sales.uid = ?", req.Salesman)
}
} }
if req.CashierId != 0 { // 支付方式 if req.CashierId != 0 { // 支付方式
qs = qs.Where("JSON_CONTAINS(cashier_list, ?)", fmt.Sprintf(`{"cashier_id":%d}`, req.CashierId)) qs = qs.Where("JSON_CONTAINS(cashier_list, ?)", fmt.Sprintf(`{"cashier_id":%d}`, req.CashierId))
qs = qs.Where("retail_type=?", RetailTypeSale) qs = qs.Where("retail_type=?", RetailTypeSale)
@ -6498,6 +6507,7 @@ type ErpOrderDailyReportResp struct {
Total int `json:"total"` // 总条数(总订单数) Total int `json:"total"` // 总条数(总订单数)
PageIndex int `json:"pageIndex"` // 页码 PageIndex int `json:"pageIndex"` // 页码
PageSize int `json:"pageSize"` // 每页展示条数 PageSize int `json:"pageSize"` // 每页展示条数
TotalCount int32 `json:"total_count"` // 合计总销售数量
TotalAmount float64 `json:"total_amount"` // 合计总金额 TotalAmount float64 `json:"total_amount"` // 合计总金额
TotalSalesProfit float64 `json:"total_sales_profit"` // 合计总毛利(销售毛利;店员看员工毛利) TotalSalesProfit float64 `json:"total_sales_profit"` // 合计总毛利(销售毛利;店员看员工毛利)
List []DailyReport `json:"list"` // 零售明细 List []DailyReport `json:"list"` // 零售明细
@ -6583,6 +6593,7 @@ func QueryOrderDailyReport(req *ErpOrderDailyReportReq, c *gin.Context) (*ErpOrd
} }
var nTotalAmount, nTotalSalesProfit float64 var nTotalAmount, nTotalSalesProfit float64
var nTotalCount int32
var storeDataList []DailyReport var storeDataList []DailyReport
for _, store := range storeList { for _, store := range storeList {
var categoryDataList []CategorySalesData var categoryDataList []CategorySalesData
@ -6596,6 +6607,7 @@ func QueryOrderDailyReport(req *ErpOrderDailyReportReq, c *gin.Context) (*ErpOrd
if item.StoreId == store && containsCategory(displayCategories, item.ErpCategoryId) { if item.StoreId == store && containsCategory(displayCategories, item.ErpCategoryId) {
nTotalAmount += item.Amount nTotalAmount += item.Amount
nStoreAmount += item.Amount nStoreAmount += item.Amount
nTotalCount += item.Count
if showFlag { // 员工毛利 if showFlag { // 员工毛利
nTotalSalesProfit += item.StaffProfit nTotalSalesProfit += item.StaffProfit
@ -6644,6 +6656,7 @@ func QueryOrderDailyReport(req *ErpOrderDailyReportReq, c *gin.Context) (*ErpOrd
resp.Total = len(storeDataList) resp.Total = len(storeDataList)
resp.PageIndex = req.PageIndex resp.PageIndex = req.PageIndex
resp.PageSize = req.PageSize resp.PageSize = req.PageSize
resp.TotalCount = nTotalCount
resp.TotalAmount = tools.RoundToTwoDecimalPlaces(nTotalAmount) resp.TotalAmount = tools.RoundToTwoDecimalPlaces(nTotalAmount)
resp.TotalSalesProfit = tools.RoundToTwoDecimalPlaces(nTotalSalesProfit) resp.TotalSalesProfit = tools.RoundToTwoDecimalPlaces(nTotalSalesProfit)

View File

@ -9755,6 +9755,10 @@ const docTemplate = `{
"description": "合计总金额", "description": "合计总金额",
"type": "number" "type": "number"
}, },
"total_count": {
"description": "合计总销售数量",
"type": "integer"
},
"total_sales_profit": { "total_sales_profit": {
"description": "合计总毛利(销售毛利;店员看员工毛利)", "description": "合计总毛利(销售毛利;店员看员工毛利)",
"type": "number" "type": "number"

View File

@ -9744,6 +9744,10 @@
"description": "合计总金额", "description": "合计总金额",
"type": "number" "type": "number"
}, },
"total_count": {
"description": "合计总销售数量",
"type": "integer"
},
"total_sales_profit": { "total_sales_profit": {
"description": "合计总毛利(销售毛利;店员看员工毛利)", "description": "合计总毛利(销售毛利;店员看员工毛利)",
"type": "number" "type": "number"

View File

@ -2490,6 +2490,9 @@ definitions:
total_amount: total_amount:
description: 合计总金额 description: 合计总金额
type: number type: number
total_count:
description: 合计总销售数量
type: integer
total_sales_profit: total_sales_profit:
description: 合计总毛利(销售毛利;店员看员工毛利) description: 合计总毛利(销售毛利;店员看员工毛利)
type: number type: number