1.去掉对采购退货单的月结限制,实际跨月退货是算入当月的财务,不影响上个月的数据;
2.优化其他出入库汇总,key的条件加上了日期,避免因为同一个商品汇总后跨月导致看不到数据; 3.优化其他出入库汇总,其他出入库明细,增加sql中的门店筛选,提高接口响应效率;
This commit is contained in:
parent
9273d5ce56
commit
a61b6a0686
|
@ -62,11 +62,11 @@ func ErpPurchaseCreate(c *gin.Context) {
|
|||
|
||||
req.StoreId = erpPurchaseOrder.StoreId
|
||||
|
||||
// 判断对应的采购退货单是否在月结时间内
|
||||
if model.IsMonthEndClosed(*erpPurchaseOrder.AuditTime) {
|
||||
app.Error(c, http.StatusInternalServerError, errors.New("新增失败:对应订单财务已月结"), "新增失败:对应订单财务已月结")
|
||||
return
|
||||
}
|
||||
//// 判断对应的采购退货单是否在月结时间内
|
||||
//if model.IsMonthEndClosed(*erpPurchaseOrder.AuditTime) {
|
||||
// app.Error(c, http.StatusInternalServerError, errors.New("新增失败:对应订单财务已月结"), "新增失败:对应订单财务已月结")
|
||||
// return
|
||||
//}
|
||||
}
|
||||
|
||||
// 校验入参门店是否包含在用户所有门店中,是否过期
|
||||
|
|
|
@ -1514,21 +1514,21 @@ func (m *InventoryReportByOtherReq) ReportByOtherList(c *gin.Context) (*Inventor
|
|||
// 查询产品入库数据
|
||||
var err error
|
||||
var productList []ReportOtherDetailData
|
||||
productList, err = getProductOrderData()
|
||||
productList, err = getProductOrderData(m.StoreId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 查询盘点出入库数据
|
||||
var changeList []ReportOtherDetailData
|
||||
changeList, err = getChangeOrderData()
|
||||
changeList, err = getChangeOrderData(m.StoreId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 查询系统出库数据
|
||||
var systemList []ReportOtherDetailData
|
||||
systemList, err = getSystemOutData()
|
||||
systemList, err = getSystemOutData(m.StoreId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1541,8 +1541,16 @@ func (m *InventoryReportByOtherReq) ReportByOtherList(c *gin.Context) (*Inventor
|
|||
summaryMap := make(map[string]*ReportByOtherData)
|
||||
// 遍历切片
|
||||
for _, item := range allData {
|
||||
// 默认日期字符串为空
|
||||
dateStr := ""
|
||||
if item.StockTime != nil {
|
||||
// 格式化为 "yyyy-mm-dd"
|
||||
dateStr = item.StockTime.Format("2006-01-02")
|
||||
}
|
||||
|
||||
// 生成键
|
||||
key := fmt.Sprintf("%d_%d_%d", item.CommodityId, item.StoreId, item.Type)
|
||||
key := fmt.Sprintf("%d_%d_%d_%s", item.CommodityId, item.StoreId, item.Type, dateStr)
|
||||
|
||||
// 检查是否已经存在该键的汇总数据
|
||||
if summary, ok := summaryMap[key]; ok {
|
||||
// 如果已经存在,累加调拨数量和调拨金额
|
||||
|
@ -1805,21 +1813,21 @@ func (m *InventoryReportOtherDetailReq) ReportByOtherDetailList(c *gin.Context)
|
|||
// 查询产品入库数据
|
||||
var err error
|
||||
var productList []ReportOtherDetailData
|
||||
productList, err = getProductOrderData()
|
||||
productList, err = getProductOrderData(m.StoreId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 查询盘点出入库数据
|
||||
var changeList []ReportOtherDetailData
|
||||
changeList, err = getChangeOrderData()
|
||||
changeList, err = getChangeOrderData(m.StoreId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 查询系统出库数据
|
||||
var systemList []ReportOtherDetailData
|
||||
systemList, err = getSystemOutData()
|
||||
systemList, err = getSystemOutData(m.StoreId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1940,7 +1948,7 @@ func (m *InventoryReportOtherDetailReq) ReportByOtherDetailList(c *gin.Context)
|
|||
}
|
||||
|
||||
// 查询产品入库数据
|
||||
func getProductOrderData() ([]ReportOtherDetailData, error) {
|
||||
func getProductOrderData(storeList []uint32) ([]ReportOtherDetailData, error) {
|
||||
var productList []ReportOtherDetailData
|
||||
err := orm.Eloquent.Debug().Table("erp_inventory_product_order").
|
||||
Select("erp_inventory_product_order.serial_number, "+
|
||||
|
@ -1962,6 +1970,7 @@ func getProductOrderData() ([]ReportOtherDetailData, error) {
|
|||
Joins("JOIN erp_inventory_product_commodity "+
|
||||
"ON erp_inventory_product_commodity.product_order_id = erp_inventory_product_order.id").
|
||||
Where("erp_inventory_product_order.state = ?", ErpInventoryProductOrderFinished).
|
||||
Where("erp_inventory_product_order.store_id in ?", storeList).
|
||||
Find(&productList).Error // 查询已审核的订单
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1971,7 +1980,7 @@ func getProductOrderData() ([]ReportOtherDetailData, error) {
|
|||
}
|
||||
|
||||
// 查询盘点出入库数据
|
||||
func getChangeOrderData() ([]ReportOtherDetailData, error) {
|
||||
func getChangeOrderData(storeList []uint32) ([]ReportOtherDetailData, error) {
|
||||
var changeList []ReportOtherDetailData
|
||||
err := orm.Eloquent.Debug().Table("erp_inventory_change_order").
|
||||
Select("erp_inventory_change_order.serial_number, "+
|
||||
|
@ -1994,6 +2003,7 @@ func getChangeOrderData() ([]ReportOtherDetailData, error) {
|
|||
Joins("JOIN erp_inventory_change_commodity "+
|
||||
"ON erp_inventory_change_commodity.change_order_id = erp_inventory_change_order.id").
|
||||
Where("erp_inventory_change_order.state = ?", ErpInventoryChangeOrderFinished).
|
||||
Where("erp_inventory_change_order.store_id in ?", storeList).
|
||||
Find(&changeList).Error // 查询已审核的订单
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -2003,10 +2013,12 @@ func getChangeOrderData() ([]ReportOtherDetailData, error) {
|
|||
}
|
||||
|
||||
// 查询系统出库数据
|
||||
func getSystemOutData() ([]ReportOtherDetailData, error) {
|
||||
func getSystemOutData(storeList []uint32) ([]ReportOtherDetailData, error) {
|
||||
var stockCommodities []ErpStockCommodity
|
||||
err := orm.Eloquent.Table("erp_stock_commodity").
|
||||
Where("state = ?", SystemOut).Find(&stockCommodities).Error
|
||||
Where("state = ?", SystemOut).
|
||||
Where("store_id in ?", storeList).
|
||||
Find(&stockCommodities).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user