| | |
| | | product.PredictionAmount = product.Amount.Add(reorderAmount.TotalAmount) |
| | | |
| | | var statisticsList []*request.ProductStatistics |
| | | if err := models.NewOperationSearch().Orm. |
| | | Table("wms_operation"). |
| | | if err := models.NewOperationSearch().Orm.Table("wms_operation"). |
| | | InnerJoins("INNER JOIN wms_operation_details on wms_operation_details.operation_id=wms_operation.id"). |
| | | Select("SUM(wms_operation_details.amount) as total_amount,wms_operation.base_operation_type"). |
| | | Where("wms_operation_details.product_id=? and wms_operation.`status`=? and wms_operation.base_operation_type in (?)", product.ID, constvar.OperationStatus_Finish, []constvar.BaseOperationType{constvar.BaseOperationTypeIncoming, constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeDisuse}). |
| | |
| | | product.OutputAmount = product.OutputAmount.Add(v.TotalAmount) |
| | | } |
| | | } |
| | | reorderRules, rulesTotal, err := models.NewReorderRuleSearch().SetProductId(product.ID).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "重订货规则统计失败") |
| | | return |
| | | } |
| | | if rulesTotal == 1 { |
| | | product.MinInventoryRule = reorderRules[0].MinInventory |
| | | product.MaxInventoryRule = reorderRules[0].MaxInventory |
| | | } |
| | | product.ReorderRuleNum = rulesTotal |
| | | } |
| | | util.ResponseFormatList(c, code.Success, products, int(total)) |
| | | } |