From a93fd95cd9bda756b227b7850f1e6aa52ced0ef8 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期五, 22 三月 2024 17:02:40 +0800
Subject: [PATCH] 保存质检信息

---
 api/v1/purchase/purchase.go  |    9 +
 docs/swagger.yaml            |   41 ++++++++++
 docs/docs.go                 |   70 +++++++++++++++++
 service/purchase/purchase.go |   15 +++
 docs/swagger.json            |   70 +++++++++++++++++
 5 files changed, 203 insertions(+), 2 deletions(-)

diff --git a/api/v1/purchase/purchase.go b/api/v1/purchase/purchase.go
index 316a704..26e101b 100644
--- a/api/v1/purchase/purchase.go
+++ b/api/v1/purchase/purchase.go
@@ -570,7 +570,7 @@
 // @Security  ApiKeyAuth
 // @accept    application/json
 // @Produce   application/json
-// @Param     data  body     purchaserequest.GetQualityInspectionInfo   true  "鍙傛暟"
+// @Param     data  body     purchaserequest.SaveQualityInspectionInfo   true  "鍙傛暟"
 // @Success   200   {object}  response.Response{data=[]purchase.PurchaseProductConfirm}  "鑾峰彇纭淇℃伅"
 // @Router    /purchase/savePurchaseQualityInspectionInfo [post]
 func (e *PurchaseApi) SavePurchaseQualityInspectionInfo(c *gin.Context) {
@@ -633,6 +633,11 @@
 			return
 		}
 	}
-
+	err = server.UpdatePurchaseStatus(params.PurchaseId, purchase.WaitInspection)
+	if err != nil {
+		global.GVA_LOG.Error("鐘舵�佹洿鏂板け璐�!", zap.Error(err))
+		response.FailWithMessage("鐘舵�佹洿鏂板け璐�", c)
+		return
+	}
 	response.OkWithMessage("璐ㄦ鎴愬姛", c)
 }
diff --git a/docs/docs.go b/docs/docs.go
index 5dc2a02..9d4195b 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2324,6 +2324,59 @@
                 }
             }
         },
+        "/purchase/savePurchaseQualityInspectionInfo": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Purchase"
+                ],
+                "summary": "淇濆瓨閲囪喘璐ㄦ淇℃伅淇℃伅",
+                "parameters": [
+                    {
+                        "description": "鍙傛暟",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/purchaserequest.SaveQualityInspectionInfo"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "鑾峰彇纭淇℃伅",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/response.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "array",
+                                            "items": {
+                                                "$ref": "#/definitions/purchase.PurchaseProductConfirm"
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
         "/purchase/submit": {
             "post": {
                 "security": [
@@ -4447,6 +4500,23 @@
                 }
             }
         },
+        "purchaserequest.SaveQualityInspectionInfo": {
+            "type": "object",
+            "properties": {
+                "ids": {
+                    "type": "array",
+                    "items": {
+                        "type": "integer"
+                    }
+                },
+                "purchaseId": {
+                    "type": "integer"
+                },
+                "status": {
+                    "type": "integer"
+                }
+            }
+        },
         "purchaserequest.UpdatePurchase": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 2cc58b6..bbbdb70 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2315,6 +2315,59 @@
                 }
             }
         },
+        "/purchase/savePurchaseQualityInspectionInfo": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Purchase"
+                ],
+                "summary": "淇濆瓨閲囪喘璐ㄦ淇℃伅淇℃伅",
+                "parameters": [
+                    {
+                        "description": "鍙傛暟",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/purchaserequest.SaveQualityInspectionInfo"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "鑾峰彇纭淇℃伅",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/response.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "array",
+                                            "items": {
+                                                "$ref": "#/definitions/purchase.PurchaseProductConfirm"
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
         "/purchase/submit": {
             "post": {
                 "security": [
@@ -4438,6 +4491,23 @@
                 }
             }
         },
+        "purchaserequest.SaveQualityInspectionInfo": {
+            "type": "object",
+            "properties": {
+                "ids": {
+                    "type": "array",
+                    "items": {
+                        "type": "integer"
+                    }
+                },
+                "purchaseId": {
+                    "type": "integer"
+                },
+                "status": {
+                    "type": "integer"
+                }
+            }
+        },
         "purchaserequest.UpdatePurchase": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index b8e9d72..0d8c756 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -797,6 +797,17 @@
         description: 鎺掑簭
         type: integer
     type: object
+  purchaserequest.SaveQualityInspectionInfo:
+    properties:
+      ids:
+        items:
+          type: integer
+        type: array
+      purchaseId:
+        type: integer
+      status:
+        type: integer
+    type: object
   purchaserequest.UpdatePurchase:
     properties:
       productList:
@@ -2506,6 +2517,36 @@
       summary: 纭鏀惰揣
       tags:
       - Purchase
+  /purchase/savePurchaseQualityInspectionInfo:
+    post:
+      consumes:
+      - application/json
+      parameters:
+      - description: 鍙傛暟
+        in: body
+        name: data
+        required: true
+        schema:
+          $ref: '#/definitions/purchaserequest.SaveQualityInspectionInfo'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: 鑾峰彇纭淇℃伅
+          schema:
+            allOf:
+            - $ref: '#/definitions/response.Response'
+            - properties:
+                data:
+                  items:
+                    $ref: '#/definitions/purchase.PurchaseProductConfirm'
+                  type: array
+              type: object
+      security:
+      - ApiKeyAuth: []
+      summary: 淇濆瓨閲囪喘璐ㄦ淇℃伅淇℃伅
+      tags:
+      - Purchase
   /purchase/submit:
     post:
       consumes:
diff --git a/service/purchase/purchase.go b/service/purchase/purchase.go
index cafe909..f77f0c2 100644
--- a/service/purchase/purchase.go
+++ b/service/purchase/purchase.go
@@ -401,3 +401,18 @@
 	err := global.GVA_DB.Model(&purchase.PurchaseQualityInspection{}).Where("id in (?)", ids).Find(&list).Error
 	return list, err
 }
+
+func (slf *PurchaseService) UpdatePurchaseStatus(purchaseId uint, status int) error {
+	var total int64
+	err := global.GVA_DB.Model(&purchase.PurchaseQualityInspection{}).Where("status = ?", status).Count(&total).Error
+	if err != nil {
+		return err
+	}
+	if total == 0 {
+		err = global.GVA_DB.Model(&purchase.Purchase{}).Where("id = ?", purchaseId).Updates(map[string]interface{}{"status": purchase.OrderStatusReceived}).Error
+		if err != nil {
+			return err
+		}
+	}
+	return nil
+}

--
Gitblit v1.8.0