liujiandao
2024-03-22 a93fd95cd9bda756b227b7850f1e6aa52ced0ef8
保存质检信息
5个文件已修改
205 ■■■■■ 已修改文件
api/v1/purchase/purchase.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/purchase/purchase.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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)
}
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": {
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": {
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:
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
}