From 5cafdb6d2cb674ffedefe0d04f6f3cc868cd2de7 Mon Sep 17 00:00:00 2001
From: lishihai <dslsh@dscom>
Date: 星期四, 20 六月 2024 10:24:20 +0800
Subject: [PATCH] 概述->新建或编辑(出库/入库)信息,编辑的时候显示保存的成本单价和销售单价

---
 controllers/operation.go |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/controllers/operation.go b/controllers/operation.go
index f6bbcdb..98f633a 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -269,11 +269,30 @@
 	if int(params.Status) != 0 {
 		search.SetStatus(params.Status)
 	}
+	materials, err := models.NewMaterialSearch().FindNotTotal()
+	if err != nil {
+		util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
+		return
+	}
+	costMap := make(map[string]decimal.Decimal)
+	salePriceMap := make(map[string]decimal.Decimal)
+	for _, material := range materials {
+		costMap[material.ID] = material.Cost
+		salePriceMap[material.ID] = material.SalePrice
+	}
 	list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find()
 	if err != nil {
 		util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
 		return
 	}
+	for _, v := range list {
+		for _, v1 := range v.Details {
+			//v1.SalePrice = decimal.NewFromFloat(1.2345)
+			//v1.Cost = decimal.NewFromFloat(9.678)
+			v1.SalePrice = v1.Cost
+			v1.Cost = v1.SalePrice
+		}
+	}
 
 	util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
 }

--
Gitblit v1.8.0