From efea3aaac3a6358cbe74891d47221b835a38d297 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 29 八月 2023 19:16:57 +0800
Subject: [PATCH] 增加开票金额,已付金额

---
 api/v1/purchase/purchase.go  |    3 +
 model/purchase/purchase.go   |    4 ++
 docs/swagger.yaml            |   15 +++++++
 docs/docs.go                 |   19 +++++++++
 service/purchase/purchase.go |    3 +
 docs/swagger.json            |   19 +++++++++
 6 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/api/v1/purchase/purchase.go b/api/v1/purchase/purchase.go
index 388ddd7..064dc74 100644
--- a/api/v1/purchase/purchase.go
+++ b/api/v1/purchase/purchase.go
@@ -1,6 +1,7 @@
 package purchase
 
 import (
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/mitchellh/mapstructure"
 	"go.uber.org/zap"
@@ -12,6 +13,7 @@
 	purchaserequest "srm/model/purchase/request"
 	"strconv"
 	"strings"
+	"time"
 
 	//"srm/model/purchase"
 
@@ -52,6 +54,7 @@
 	purchaseRecord.Status = purchase.OrderStatusConfirmed
 	purchaseRecord.HandledBy = "admin"
 	purchaseRecord.Creator = "admin"
+	purchaseRecord.Number = fmt.Sprintf("CG%v", time.Now().Unix())
 
 	if !purchaseRecord.WholeDiscountType.IsValid(purchaseRecord.TotalPrice, purchaseRecord.WholeDiscount) {
 		response.FailWithMessage("鏁村崟鎶樻墸鏁板�间笉姝g‘", c)
diff --git a/docs/docs.go b/docs/docs.go
index 00c67da..42749da 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -8456,6 +8456,10 @@
                     "description": "涓婚敭ID",
                     "type": "integer"
                 },
+                "invoiceAmount": {
+                    "description": "宸叉敹绁ㄩ噾棰�",
+                    "type": "number"
+                },
                 "name": {
                     "description": "閲囪喘鍚嶇О",
                     "type": "string"
@@ -8471,6 +8475,10 @@
                 "orderType": {
                     "description": "鍗曟嵁绫诲瀷",
                     "type": "string"
+                },
+                "paidAmount": {
+                    "description": "宸蹭粯閲戦",
+                    "type": "number"
                 },
                 "phone": {
                     "description": "鑱旂郴浜虹數璇�",
@@ -8507,6 +8515,10 @@
                     "description": "澶囨敞",
                     "type": "string"
                 },
+                "shouldPayAmount": {
+                    "description": "搴斾粯閲戦",
+                    "type": "number"
+                },
                 "signingDate": {
                     "description": "绛剧害鏃ユ湡",
                     "type": "string"
@@ -8528,6 +8540,10 @@
                 },
                 "totalPrice": {
                     "description": "浠风◣鍚堣",
+                    "type": "number"
+                },
+                "unInvoiceAmount": {
+                    "description": "鏈敹绁ㄩ噾棰�",
                     "type": "number"
                 },
                 "warehouse": {
@@ -8613,14 +8629,17 @@
         "purchase.WholeDiscountType": {
             "type": "integer",
             "enum": [
+                0,
                 1,
                 2
             ],
             "x-enum-comments": {
+                "WholeDiscountTypeDefault": "鏃犳姌鎵�",
                 "WholeDiscountTypeDiscount": "鐩存帴闄嶄环",
                 "WholeDiscountTypePercent": "鐧惧垎姣旈檷浠�"
             },
             "x-enum-varnames": [
+                "WholeDiscountTypeDefault",
                 "WholeDiscountTypePercent",
                 "WholeDiscountTypeDiscount"
             ]
diff --git a/docs/swagger.json b/docs/swagger.json
index af79a49..7710747 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -8447,6 +8447,10 @@
                     "description": "涓婚敭ID",
                     "type": "integer"
                 },
+                "invoiceAmount": {
+                    "description": "宸叉敹绁ㄩ噾棰�",
+                    "type": "number"
+                },
                 "name": {
                     "description": "閲囪喘鍚嶇О",
                     "type": "string"
@@ -8462,6 +8466,10 @@
                 "orderType": {
                     "description": "鍗曟嵁绫诲瀷",
                     "type": "string"
+                },
+                "paidAmount": {
+                    "description": "宸蹭粯閲戦",
+                    "type": "number"
                 },
                 "phone": {
                     "description": "鑱旂郴浜虹數璇�",
@@ -8498,6 +8506,10 @@
                     "description": "澶囨敞",
                     "type": "string"
                 },
+                "shouldPayAmount": {
+                    "description": "搴斾粯閲戦",
+                    "type": "number"
+                },
                 "signingDate": {
                     "description": "绛剧害鏃ユ湡",
                     "type": "string"
@@ -8519,6 +8531,10 @@
                 },
                 "totalPrice": {
                     "description": "浠风◣鍚堣",
+                    "type": "number"
+                },
+                "unInvoiceAmount": {
+                    "description": "鏈敹绁ㄩ噾棰�",
                     "type": "number"
                 },
                 "warehouse": {
@@ -8604,14 +8620,17 @@
         "purchase.WholeDiscountType": {
             "type": "integer",
             "enum": [
+                0,
                 1,
                 2
             ],
             "x-enum-comments": {
+                "WholeDiscountTypeDefault": "鏃犳姌鎵�",
                 "WholeDiscountTypeDiscount": "鐩存帴闄嶄环",
                 "WholeDiscountTypePercent": "鐧惧垎姣旈檷浠�"
             },
             "x-enum-varnames": [
+                "WholeDiscountTypeDefault",
                 "WholeDiscountTypePercent",
                 "WholeDiscountTypeDiscount"
             ]
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 265cc91..391b1de 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -725,6 +725,9 @@
       id:
         description: 涓婚敭ID
         type: integer
+      invoiceAmount:
+        description: 宸叉敹绁ㄩ噾棰�
+        type: number
       name:
         description: 閲囪喘鍚嶇О
         type: string
@@ -737,6 +740,9 @@
       orderType:
         description: 鍗曟嵁绫诲瀷
         type: string
+      paidAmount:
+        description: 宸蹭粯閲戦
+        type: number
       phone:
         description: 鑱旂郴浜虹數璇�
         type: string
@@ -761,6 +767,9 @@
       remark:
         description: 澶囨敞
         type: string
+      shouldPayAmount:
+        description: 搴斾粯閲戦
+        type: number
       signingDate:
         description: 绛剧害鏃ユ湡
         type: string
@@ -775,6 +784,9 @@
         type: integer
       totalPrice:
         description: 浠风◣鍚堣
+        type: number
+      unInvoiceAmount:
+        description: 鏈敹绁ㄩ噾棰�
         type: number
       warehouse:
         description: 鏀惰揣浠撳簱
@@ -834,13 +846,16 @@
     type: object
   purchase.WholeDiscountType:
     enum:
+    - 0
     - 1
     - 2
     type: integer
     x-enum-comments:
+      WholeDiscountTypeDefault: 鏃犳姌鎵�
       WholeDiscountTypeDiscount: 鐩存帴闄嶄环
       WholeDiscountTypePercent: 鐧惧垎姣旈檷浠�
     x-enum-varnames:
+    - WholeDiscountTypeDefault
     - WholeDiscountTypePercent
     - WholeDiscountTypeDiscount
   purchaserequest.AddPurchase:
diff --git a/model/purchase/purchase.go b/model/purchase/purchase.go
index d9f7acd..3163546 100644
--- a/model/purchase/purchase.go
+++ b/model/purchase/purchase.go
@@ -32,6 +32,10 @@
 	PriceAdjustmentType PriceAdjustmentType `json:"priceAdjustmentType" form:"priceAdjustmentType" gorm:"type:decimal(12,2);not null;default '';comment:浠锋牸璋冩暣"` //浠锋牸璋冩暣绫诲瀷
 	PriceAdjustment     decimal.Decimal     `json:"priceAdjustment" form:"priceAdjustment" gorm:"type:decimal(12,2);not null;default '';comment:浠锋牸璋冩暣"`         //浠锋牸璋冩暣鍊�
 	RealTotalPrice      decimal.Decimal     `json:"realTotalPrice" form:"realTotalPrice" gorm:"type:decimal(12,2);not null;default '';comment:鏈�缁堜环鏍�"`           //鏈�缁堜环鏍�
+	InvoiceAmount       decimal.Decimal     `json:"invoiceAmount" form:"invoiceAmount" gorm:"type:decimal(12,2);not null;default '';comment:宸叉敹绁ㄩ噾棰�"`            //宸叉敹绁ㄩ噾棰�
+	UnInvoiceAmount     decimal.Decimal     `json:"unInvoiceAmount" form:"unInvoiceAmount" gorm:"type:decimal(12,2);not null;default '';comment:鏈敹绁ㄩ噾棰�"`        //鏈敹绁ㄩ噾棰�
+	ShouldPayAmount     decimal.Decimal     `json:"shouldPayAmount" form:"shouldPayAmount" gorm:"type:decimal(12,2);not null;default '';comment:搴斾粯閲戦"`         //搴斾粯閲戦
+	PaidAmount          decimal.Decimal     `json:"paidAmount" form:"paidAmount" gorm:"type:decimal(12,2);not null;default '';comment:宸蹭粯閲戦"`                   //宸蹭粯閲戦
 }
 
 type OrderStatus int
diff --git a/service/purchase/purchase.go b/service/purchase/purchase.go
index 257fed3..ffa39d2 100644
--- a/service/purchase/purchase.go
+++ b/service/purchase/purchase.go
@@ -43,6 +43,9 @@
 		if !realTotalPrice.Equal(record.RealTotalPrice) {
 			return errors.New("鏈�缁堜环鏍艰绠楅敊璇�")
 		}
+		record.UnInvoiceAmount = record.RealTotalPrice
+		record.ShouldPayAmount = record.RealTotalPrice
+
 		err = tx.Create(&record).Error
 		if err != nil {
 			return err

--
Gitblit v1.8.0