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

View File

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

View File

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

View File

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