From 73b6baf6af3d88cdcb0e2df7932a9bd96b0b85c5 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 01 七月 2024 22:32:34 +0800
Subject: [PATCH] 月度统计出入库按类型汇总报表定时任务和手动跑任务接口

---
 models/operation_details.go |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/models/operation_details.go b/models/operation_details.go
index ea37b72..8269f76 100644
--- a/models/operation_details.go
+++ b/models/operation_details.go
@@ -27,7 +27,12 @@
 		TotalNetWeight   decimal.Decimal `json:"totalNetWeight" gorm:"type:decimal(20,3);comment:鎬诲噣閲�"`
 		AuxiliaryAmount  decimal.Decimal `json:"auxiliaryAmount" gorm:"type:decimal(20,3);comment:杈呭姪鏁伴噺"`
 		AuxiliaryUnit    string          `json:"auxiliaryUnit" gorm:"type:varchar(191);comment:杈呭姪鍗曚綅"`
-		Note             string          `gorm:"type:varchar(1024);comment:澶囨敞" json:"note"`
+		Remark           string          `gorm:"type:varchar(1024);comment:澶囨敞" json:"remark"`
+		IsInternalOutput bool            `json:"isInternalOutput"` //鏄惁璋冩嫧浜х敓鐨勫嚭搴�
+		DealerType       string          `json:"dealerType"`       //鍑哄叆搴撶被鍨�
+
+		Cost      decimal.Decimal `json:"cost" `      //鎴愭湰鍗曚环
+		SalePrice decimal.Decimal `json:"salePrice" ` //閿�鍞崟浠�
 	}
 
 	OperationDetailsSearch struct {
@@ -308,3 +313,20 @@
 	}
 	return result, nil
 }
+
+type GroupByDealerTypeWarehouse struct {
+	DealerType string
+	ProductID  string
+	Sum        decimal.Decimal
+}
+
+func (slf *OperationDetailsSearch) GroupMultiSumAmount() ([]*GroupByDealerTypeWarehouse, error) {
+	var (
+		db     = slf.build()
+		result = make([]*GroupByDealerTypeWarehouse, 0)
+	)
+	if err := db.Select("sum(amount) as sum, dealer_type, product_id").Group("product_id, dealer_type").Scan(&result).Error; err != nil {
+		return nil, fmt.Errorf("select group err: %v", err)
+	}
+	return result, nil
+}

--
Gitblit v1.8.0