1、优化零售退货单反审核失败问题;
2、新建零售退货订单拆分非串码商品时,同步拆分退货数量和退货金额字段;零售列表合并非串码商品时,同步合并退货数量和退货金额字段;修复后解决商品零售毛利汇总退货单多个相同非串码商品退货金额统计不准确的问题; 3、产品库存汇总(按门店)总金额四舍五入; 4、门店经营增加汇总数据。
This commit is contained in:
parent
9c72b52723
commit
40666e03c4
|
@ -207,6 +207,7 @@ func ErpOrderAudit(c *gin.Context) {
|
|||
}
|
||||
|
||||
var checkReq model.ErpOrderCreateReq
|
||||
checkReq.StoreId = erpOrder.StoreId
|
||||
checkReq.ErpOrderCommodities = commodity
|
||||
err = model.CheckOrderCommodityStock(&checkReq)
|
||||
if err != nil {
|
||||
|
|
|
@ -262,11 +262,16 @@ type ErpOrderStoreManageDataReq struct {
|
|||
|
||||
// ErpOrderStoreManageDataResp 查询门店经营出参
|
||||
type ErpOrderStoreManageDataResp struct {
|
||||
List []StoreManageData `json:"list"`
|
||||
Total int `json:"total"` // 总条数
|
||||
PageIndex int `json:"pageIndex"` // 页码
|
||||
PageSize int `json:"pageSize"` // 每页展示条数
|
||||
ExportUrl string `json:"export_url"`
|
||||
List []StoreManageData `json:"list"`
|
||||
Total int `json:"total"` // 总条数
|
||||
PageIndex int `json:"pageIndex"` // 页码
|
||||
PageSize int `json:"pageSize"` // 每页展示条数
|
||||
ExportUrl string `json:"export_url"`
|
||||
TotalSalesAmount float64 `json:"total_sales_amount"` // 总销售额
|
||||
TotalPromotionFee float64 `json:"total_promotion_fee"` // 总推广费
|
||||
TotalSalesProfit float64 `json:"total_sales_profit"` // 总销售毛利
|
||||
TotalStaffProfit float64 `json:"total_staff_profit"` // 总员工毛利
|
||||
TotalCount int64 `json:"total_count"` // 总销售数量
|
||||
}
|
||||
|
||||
// StoreManageData 门店经营数据
|
||||
|
@ -1483,6 +1488,8 @@ func mergeOrderCommodities(orderCommodities []ErpOrderCommodity) []ErpOrderCommo
|
|||
existingCommodity.SaleDiscount += commodity.SaleDiscount
|
||||
existingCommodity.MemberDiscount += commodity.MemberDiscount
|
||||
existingCommodity.ReceivedAmount += commodity.ReceivedAmount
|
||||
existingCommodity.RejectedCount += commodity.RejectedCount
|
||||
existingCommodity.RejectedAmount += commodity.RejectedAmount
|
||||
stockCommodityID, _ := tools.StringToInt(commodity.ErpStockCommodityID)
|
||||
if stockCommodityID > 0 {
|
||||
existingCommodity.ErpStockCommodityID = strings.Join([]string{existingCommodity.ErpStockCommodityID, commodity.ErpStockCommodityID}, ",")
|
||||
|
@ -2372,7 +2379,26 @@ func QueryStoreManageData(req *ErpOrderStoreManageDataReq, c *gin.Context) (*Erp
|
|||
}
|
||||
qs.Where("state = ?", ErpOrderStateAudited)
|
||||
|
||||
// 查询数据
|
||||
// 查询汇总数据
|
||||
var summary struct {
|
||||
TotalSalesAmount float64
|
||||
TotalPromotionFee float64
|
||||
TotalSalesProfit float64
|
||||
TotalStaffProfit float64
|
||||
TotalCount int64
|
||||
}
|
||||
err = qs.Select("SUM(CASE WHEN retail_type = 'sale' THEN total_amount ELSE -total_amount END) AS total_sales_amount, " +
|
||||
"SUM(CASE WHEN retail_type = 'sale' THEN total_discount ELSE -total_discount END) AS total_promotion_fee, " +
|
||||
"SUM(CASE WHEN retail_type = 'sale' THEN total_sales_profit ELSE -total_sales_profit END) AS total_sales_profit, " +
|
||||
"SUM(CASE WHEN retail_type = 'sale' THEN total_staff_profit ELSE -total_staff_profit END) AS total_staff_profit, " +
|
||||
"SUM(CASE WHEN retail_type = 'sale' THEN total_count ELSE -total_count END) AS total_count").
|
||||
Find(&summary).Error
|
||||
if err != nil {
|
||||
logger.Error("QueryStoreManageData summary err:", logger.Field("err", err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 查询分页数据
|
||||
if req.SortType == "asc" {
|
||||
err = qs.Select("DATE_FORMAT(maker_time, '%Y-%m-%d') AS date, " +
|
||||
"SUM(CASE WHEN retail_type = 'sale' THEN total_discount ELSE -total_discount END) AS promotion_fee, " +
|
||||
|
@ -2401,6 +2427,13 @@ func QueryStoreManageData(req *ErpOrderStoreManageDataReq, c *gin.Context) (*Erp
|
|||
|
||||
finalStoreManageDataList := constructFinalStoreManageDataList(storeManageDataList, req)
|
||||
|
||||
// 汇总数据赋值给响应
|
||||
resp.TotalSalesAmount = math.Round(summary.TotalSalesAmount*100) / 100
|
||||
resp.TotalPromotionFee = math.Round(summary.TotalPromotionFee*100) / 100
|
||||
resp.TotalSalesProfit = math.Round(summary.TotalSalesProfit*100) / 100
|
||||
resp.TotalStaffProfit = math.Round(summary.TotalStaffProfit*100) / 100
|
||||
resp.TotalCount = summary.TotalCount
|
||||
|
||||
if req.IsExport == 1 { //导出excel
|
||||
storeName := "所有门店"
|
||||
if req.StoreId != 0 {
|
||||
|
@ -2413,7 +2446,7 @@ func QueryStoreManageData(req *ErpOrderStoreManageDataReq, c *gin.Context) (*Erp
|
|||
}
|
||||
|
||||
finalStoreManageDataList = constructFinalStoreManageDataList(storeManageDataList, req)
|
||||
filePath, err := storeManageDataExport(finalStoreManageDataList, storeName, c)
|
||||
filePath, err := storeManageDataExport(finalStoreManageDataList, storeName, summary, c)
|
||||
if err != nil {
|
||||
logger.Error("StoreManageDataExport err:", logger.Field("err", err))
|
||||
return nil, err
|
||||
|
@ -2492,7 +2525,13 @@ func constructFinalStoreManageDataList(storeManageDataList []StoreManageData, re
|
|||
}
|
||||
|
||||
// StoreManageDataExport 导出门店经营数据
|
||||
func storeManageDataExport(list []StoreManageData, storeName string, c *gin.Context) (string, error) {
|
||||
func storeManageDataExport(list []StoreManageData, storeName string, summary struct {
|
||||
TotalSalesAmount float64
|
||||
TotalPromotionFee float64
|
||||
TotalSalesProfit float64
|
||||
TotalStaffProfit float64
|
||||
TotalCount int64
|
||||
}, c *gin.Context) (string, error) {
|
||||
file := excelize.NewFile()
|
||||
fSheet := "Sheet1"
|
||||
|
||||
|
@ -2556,6 +2595,25 @@ func storeManageDataExport(list []StoreManageData, storeName string, c *gin.Cont
|
|||
nExcelStartRow++
|
||||
}
|
||||
|
||||
totalData := "汇总 记录数:" + strconv.FormatInt(int64(len(list)), 10)
|
||||
end := []interface{}{totalData, summary.TotalSalesAmount, summary.TotalPromotionFee}
|
||||
|
||||
if flag1 { // 销售毛利
|
||||
end = append(end, summary.TotalSalesProfit)
|
||||
}
|
||||
if flag2 { // 员工毛利
|
||||
end = append(end, summary.TotalStaffProfit)
|
||||
}
|
||||
end = append(end, summary.TotalCount)
|
||||
|
||||
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},
|
||||
|
@ -2572,11 +2630,11 @@ func storeManageDataExport(list []StoreManageData, storeName string, c *gin.Cont
|
|||
var endRow string
|
||||
switch nEndCount {
|
||||
case 1:
|
||||
endRow = fmt.Sprintf("E"+"%d", nExcelStartRow+1)
|
||||
endRow = fmt.Sprintf("E"+"%d", nExcelStartRow+2)
|
||||
case 2:
|
||||
endRow = fmt.Sprintf("F"+"%d", nExcelStartRow+1)
|
||||
endRow = fmt.Sprintf("F"+"%d", nExcelStartRow+2)
|
||||
default:
|
||||
endRow = fmt.Sprintf("D"+"%d", nExcelStartRow+1)
|
||||
endRow = fmt.Sprintf("D"+"%d", nExcelStartRow+2)
|
||||
}
|
||||
// 应用样式到整个表格
|
||||
_ = file.SetCellStyle("Sheet1", "A1", endRow, style)
|
||||
|
@ -5457,10 +5515,12 @@ func checkOrderData(req *ErpOrderCreateReq, c *gin.Context) (*ErpOrder, error) {
|
|||
//// 单个商品退货金额
|
||||
//req.ErpOrderCommodities[i].RejectedAmount = req.ErpOrderCommodities[i].RejectedAmount / float64(req.ErpOrderCommodities[i].Count)
|
||||
|
||||
for j := 0; j < int(req.ErpOrderCommodities[i].Count); j++ {
|
||||
for j := 0; j < int(req.ErpOrderCommodities[i].RejectedCount); j++ {
|
||||
stockIdList, _ := stringToIntArray(req.ErpOrderCommodities[i].ErpStockCommodityID)
|
||||
temp := req.ErpOrderCommodities[i]
|
||||
temp.RejectedAmount = req.ErpOrderCommodities[i].RejectedAmount / float64(req.ErpOrderCommodities[i].RejectedCount)
|
||||
temp.Count = 1
|
||||
temp.RejectedCount = 1
|
||||
if len(stockIdList) > j {
|
||||
temp.ErpStockCommodityID = fmt.Sprintf("%d", stockIdList[j])
|
||||
}
|
||||
|
|
|
@ -388,6 +388,7 @@ func (m *InventoryReportByProductReq) ReportByProductList(c *gin.Context) (*Inve
|
|||
resp.TotalEffectiveAmount = sumData.TotalEffectiveAmount
|
||||
resp.TotalTransferAmount = sumData.TotalTransferAmount
|
||||
resp.TotalAmount = resp.TotalEffectiveAmount + resp.TotalTransferAmount
|
||||
resp.TotalAmount = math.Round(resp.TotalAmount*100) / 100
|
||||
resp.Total = uint32(len(reportList))
|
||||
resp.List = reportList
|
||||
|
||||
|
|
20
docs/docs.go
20
docs/docs.go
|
@ -9997,6 +9997,26 @@ const docTemplate = `{
|
|||
"total": {
|
||||
"description": "总条数",
|
||||
"type": "integer"
|
||||
},
|
||||
"total_count": {
|
||||
"description": "总销售数量",
|
||||
"type": "integer"
|
||||
},
|
||||
"total_promotion_fee": {
|
||||
"description": "总推广费",
|
||||
"type": "number"
|
||||
},
|
||||
"total_sales_amount": {
|
||||
"description": "总销售额",
|
||||
"type": "number"
|
||||
},
|
||||
"total_sales_profit": {
|
||||
"description": "总销售毛利",
|
||||
"type": "number"
|
||||
},
|
||||
"total_staff_profit": {
|
||||
"description": "总员工毛利",
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -9986,6 +9986,26 @@
|
|||
"total": {
|
||||
"description": "总条数",
|
||||
"type": "integer"
|
||||
},
|
||||
"total_count": {
|
||||
"description": "总销售数量",
|
||||
"type": "integer"
|
||||
},
|
||||
"total_promotion_fee": {
|
||||
"description": "总推广费",
|
||||
"type": "number"
|
||||
},
|
||||
"total_sales_amount": {
|
||||
"description": "总销售额",
|
||||
"type": "number"
|
||||
},
|
||||
"total_sales_profit": {
|
||||
"description": "总销售毛利",
|
||||
"type": "number"
|
||||
},
|
||||
"total_staff_profit": {
|
||||
"description": "总员工毛利",
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2708,6 +2708,21 @@ definitions:
|
|||
total:
|
||||
description: 总条数
|
||||
type: integer
|
||||
total_count:
|
||||
description: 总销售数量
|
||||
type: integer
|
||||
total_promotion_fee:
|
||||
description: 总推广费
|
||||
type: number
|
||||
total_sales_amount:
|
||||
description: 总销售额
|
||||
type: number
|
||||
total_sales_profit:
|
||||
description: 总销售毛利
|
||||
type: number
|
||||
total_staff_profit:
|
||||
description: 总员工毛利
|
||||
type: number
|
||||
type: object
|
||||
models.ErpPurchaseAuditReq:
|
||||
properties:
|
||||
|
|
Loading…
Reference in New Issue
Block a user