| | |
| | | package purchase |
| | | |
| | | import ( |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/mitchellh/mapstructure" |
| | | "go.uber.org/zap" |
| | | "gorm.io/gorm" |
| | | "srm/global" |
| | |
| | | purchaserequest "srm/model/purchase/request" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | | |
| | | //"srm/model/purchase" |
| | | |
| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data body purchaserequest.AddPurchase true "采购单用户名, 采购单手机号码" |
| | | // @Param data body purchaserequest.AddPurchase true "采购单,采购单产品" |
| | | // @Success 200 {object} response.Response{msg=string} "创建采购单" |
| | | // @Router /purchase/purchase [post] |
| | | func (e *PurchaseApi) CreatePurchase(c *gin.Context) { |
| | | var params purchaserequest.AddPurchase |
| | | err := c.ShouldBindJSON(¶ms) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("Add Purchase failed", zap.Error(err)) |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | |
| | | var purchaseRecord purchase.Purchase |
| | | if err := mapstructure.Decode(params.Purchase, &purchaseRecord); err != nil { |
| | | if err := utils.AssignTo(params.Purchase, &purchaseRecord); err != nil { |
| | | global.GVA_LOG.Error("Add Purchase failed", zap.Error(err)) |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | |
| | | purchaseRecord.Status = purchase.OrderStatusConfirmed |
| | | purchaseRecord.HandledBy = "admin" |
| | | purchaseRecord.Creator = "admin" |
| | | purchaseRecord.Number = fmt.Sprintf("CG%v", time.Now().Unix()) |
| | | purchaseRecord.Principal = "admin" |
| | | |
| | | if !purchaseRecord.WholeDiscountType.IsValid(purchaseRecord.TotalPrice, purchaseRecord.WholeDiscount) { |
| | | response.FailWithMessage("整单折扣数值不正确", c) |
| | | return |
| | | } |
| | | |
| | | if !purchaseRecord.PriceAdjustmentType.IsValid(purchaseRecord.TotalPrice, purchaseRecord.PriceAdjustment) { |
| | | response.FailWithMessage("价格调整数值不正确", c) |
| | | return |
| | | } |
| | | |
| | | err = service.NewPurchaseService().CreatePurchase(&purchaseRecord, params.ProductList) |
| | | |
| | | if err != nil { |
| | |
| | | return |
| | | } |
| | | global.GVA_LOG.Error("创建失败!", zap.Error(err)) |
| | | response.FailWithMessage("创建失败", c) |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | response.OkWithMessage("创建成功", c) |
| | |
| | | } |
| | | |
| | | var purchaseRecord purchase.Purchase |
| | | if err := mapstructure.Decode(params.Purchase, &purchaseRecord); err != nil { |
| | | if err := utils.AssignTo(params.Purchase, &purchaseRecord); err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | |
| | | response.FailWithMessage("获取失败", c) |
| | | return |
| | | } |
| | | response.OkWithDetailed(purchaseRes.PurchaseResponse{Purchase: data, ProductList: productList}, "获取成功", c) |
| | | respProductList := make([]*purchaseRes.PurchaseProducts, len(productList)) |
| | | err = utils.AssignTo(productList, &respProductList) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败", c) |
| | | return |
| | | } |
| | | for k, item := range productList { |
| | | respProductList[k].Amount = item.Amount |
| | | respProductList[k].Price = item.Price |
| | | respProductList[k].Total = item.Total |
| | | err = utils.AssignTo(item.Product, &respProductList[k]) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败", c) |
| | | return |
| | | } |
| | | } |
| | | |
| | | response.OkWithDetailed(purchaseRes.PurchaseResponse{Purchase: data, ProductList: respProductList}, "获取成功", c) |
| | | } |
| | | |
| | | // GetPurchaseList |
| | |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | PurchaseList, total, err := service.NewPurchaseService().GetPurchaseList(pageInfo) |
| | | purchaseList, total, err := service.NewPurchaseService().GetPurchaseList(pageInfo) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败"+err.Error(), c) |
| | | return |
| | | } |
| | | response.OkWithDetailed(response.PageResult{ |
| | | List: PurchaseList, |
| | | List: purchaseList, |
| | | Total: total, |
| | | Page: pageInfo.Page, |
| | | PageSize: pageInfo.PageSize, |
| | |
| | | } |
| | | |
| | | purchaseTypeList := make([]*purchase.PurchaseType, 0, len(params)) |
| | | if err := mapstructure.Decode(params, &purchaseTypeList); err != nil { |
| | | if err := utils.AssignTo(params, &purchaseTypeList); err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
New file |
| | |
| | | package purchase |
| | | |
| | | import ( |
| | | "context" |
| | | "github.com/gin-gonic/gin" |
| | | "go.uber.org/zap" |
| | | "srm/global" |
| | | "srm/model/common/request" |
| | | "srm/model/common/response" |
| | | "srm/model/purchase" |
| | | purchaseRes "srm/model/purchase/response" |
| | | "srm/proto/qualityinspect" |
| | | service "srm/service/purchase" |
| | | "srm/utils" |
| | | ) |
| | | |
| | | type QualityInspectApi struct{} |
| | | |
| | | // GetQualityInspectList |
| | | // @Tags QualityInspect |
| | | // @Summary 分页获取质检单列表 |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data query request.PageInfo true "页码, 每页大小" |
| | | // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页获取质检单列表,返回包括列表,总数,页码,每页数量" |
| | | // @Router /purchase/qualityInspectList [get] |
| | | func (e *QualityInspectApi) GetQualityInspectList(c *gin.Context) { |
| | | var pageInfo request.PageInfo |
| | | err := c.ShouldBindQuery(&pageInfo) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | err = utils.Verify(pageInfo, utils.PageInfoVerify) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | list, total, err := service.NewPurchaseService().GetPurchaseList(pageInfo) |
| | | purchaseList := list.([]*purchase.Purchase) |
| | | purchaseNumbers := make([]string, 0, len(purchaseList)) |
| | | for _, item := range purchaseList { |
| | | purchaseNumbers = append(purchaseNumbers, item.Number) |
| | | } |
| | | resultList := make([]*purchaseRes.QualityInspectList, 0, len(purchaseList)) |
| | | if len(purchaseList) == 0 { |
| | | err = utils.AssignTo(purchaseList, &resultList) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("mapStructure decode", zap.Error(err)) |
| | | response.FailWithMessage("内部错误", c) |
| | | return |
| | | } |
| | | |
| | | client := qualityinspect.NewQualityInspectServiceClient(qualityinspect.Conn) |
| | | inspectList, err := client.GetInspectList(context.Background(), &qualityinspect.GetInspectListRequest{ |
| | | PurchaseOrderId: purchaseNumbers, |
| | | }) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("GetInspectList", zap.Error(err)) |
| | | response.FailWithMessage("内部错误", c) |
| | | return |
| | | } |
| | | |
| | | inspectUnFinishedMap := make(map[string]bool, len(purchaseNumbers)) //默认完成 |
| | | for _, inspectItem := range inspectList.List { |
| | | if inspectItem.Status != qualityinspect.InspectStatus_InspectStatusInspectFinish { |
| | | inspectUnFinishedMap[inspectItem.PurchaseOrderId] = true |
| | | } |
| | | } |
| | | |
| | | for _, result := range resultList { |
| | | if inspectUnFinishedMap[result.Number] { |
| | | result.InspectStatus = "待质检" |
| | | } else { |
| | | result.InspectStatus = "已完成" |
| | | } |
| | | } |
| | | } |
| | | |
| | | response.OkWithDetailed(response.PageResult{ |
| | | List: resultList, |
| | | Total: total, |
| | | Page: pageInfo.Page, |
| | | PageSize: pageInfo.PageSize, |
| | | }, "获取成功", c) |
| | | } |
| | | |
| | | // |
| | | //// GetQualityInspect |
| | | //// @Tags QualityInspect |
| | | //// @Summary 获取单一质检单信息 |
| | | //// @Security ApiKeyAuth |
| | | //// @accept application/json |
| | | //// @Produce application/json |
| | | //// @Param id path int true "质检单ID" true "质检单ID" |
| | | //// @Success 200 {object} response.Response{data=QualityInspectRes.QualityInspectResponse,msg=string} "获取单一质检单信息,返回包括质检单详情" |
| | | //// @Router /purchase/qualityInspect/{id} [get] |
| | | //func (e *QualityInspectApi) GetQualityInspect(c *gin.Context) { |
| | | // id, _ := strconv.Atoi(c.Param("id")) |
| | | // if id == 0 { |
| | | // response.FailWithMessage("参数缺失", c) |
| | | // return |
| | | // } |
| | | // data, err := service.NewPurchaseService().GetPurchase(uint(id)) |
| | | // if err != nil { |
| | | // global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | // response.FailWithMessage("获取失败", c) |
| | | // return |
| | | // } |
| | | // productList, err := service.NewPurchaseService().GetPurchaseProductList(uint(id)) |
| | | // if err != nil { |
| | | // global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | // response.FailWithMessage("获取失败", c) |
| | | // return |
| | | // } |
| | | // respProductList := make([]*purchaseRes.PurchaseProducts, len(productList)) |
| | | // err = mapstructure.Decode(productList, &respProductList) |
| | | // if err != nil { |
| | | // global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | // response.FailWithMessage("获取失败", c) |
| | | // return |
| | | // } |
| | | // for k, item := range productList { |
| | | // respProductList[k].Amount = item.Amount |
| | | // respProductList[k].Price = item.Price |
| | | // respProductList[k].Total = item.Total |
| | | // err = mapstructure.Decode(item.Product, &respProductList[k]) |
| | | // if err != nil { |
| | | // global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | // response.FailWithMessage("获取失败", c) |
| | | // return |
| | | // } |
| | | // } |
| | | // |
| | | // response.OkWithDetailed(purchaseRes.PurchaseResponse{Purchase: data, ProductList: respProductList}, "获取成功", c) |
| | | //} |
| | |
| | | iplimit-time: 3600 |
| | | use-multipoint: false |
| | | use-redis: false |
| | | grpc-url: 192.168.20.118:9091 |
| | | grpc-url: 192.168.20.119:9091 |
| | | grpc-admin-url: 192.168.20.119:50051 |
| | | tencent-cos: |
| | | bucket: xxxxx-10005608 |
| | |
| | | "summary": "创建采购单", |
| | | "parameters": [ |
| | | { |
| | | "description": "采购单用户名, 采购单手机号码", |
| | | "description": "采购单,采购单产品", |
| | | "name": "data", |
| | | "in": "body", |
| | | "required": true, |
| | |
| | | "items": { |
| | | "$ref": "#/definitions/purchase.PurchaseType" |
| | | } |
| | | }, |
| | | "msg": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/purchase/qualityInspectList": { |
| | | "get": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "QualityInspect" |
| | | ], |
| | | "summary": "分页获取质检单列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "分页获取质检单列表,返回包括列表,总数,页码,每页数量", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/response.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.PageResult" |
| | | }, |
| | | "msg": { |
| | | "type": "string" |
| | |
| | | "OrderStatusCompleted" |
| | | ] |
| | | }, |
| | | "purchase.PriceAdjustmentType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "PriceAdjustmentTypeAdd": "增加", |
| | | "PriceAdjustmentTypeSub": "减少" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "PriceAdjustmentTypeAdd", |
| | | "PriceAdjustmentTypeSub" |
| | | ] |
| | | }, |
| | | "purchase.Purchase": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "invoiceAmount": { |
| | | "description": "已收票金额", |
| | | "type": "number" |
| | | }, |
| | | "name": { |
| | | "description": "采购名称", |
| | | "type": "string" |
| | |
| | | "description": "采购编号", |
| | | "type": "string" |
| | | }, |
| | | "orderSource": { |
| | | "description": "单据来源", |
| | | "type": "string" |
| | | }, |
| | | "orderType": { |
| | | "description": "单据类型", |
| | | "type": "string" |
| | | }, |
| | | "paidAmount": { |
| | | "description": "已付金额", |
| | | "type": "number" |
| | | }, |
| | | "phone": { |
| | | "description": "联系人电话", |
| | | "type": "string" |
| | | }, |
| | | "priceAdjustment": { |
| | | "description": "价格调整值", |
| | | "type": "number" |
| | | }, |
| | | "priceAdjustmentType": { |
| | | "description": "价格调整类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/purchase.PriceAdjustmentType" |
| | | } |
| | | ] |
| | | }, |
| | | "principal": { |
| | | "description": "采购负责人", |
| | | "type": "string" |
| | | }, |
| | | "purchaseType": { |
| | |
| | | "description": "采购数量", |
| | | "type": "number" |
| | | }, |
| | | "realTotalPrice": { |
| | | "description": "最终价格", |
| | | "type": "number" |
| | | }, |
| | | "remark": { |
| | | "description": "备注", |
| | | "type": "string" |
| | | }, |
| | | "shouldPayAmount": { |
| | | "description": "应付金额", |
| | | "type": "number" |
| | | }, |
| | | "signingDate": { |
| | | "description": "签约日期", |
| | |
| | | "supplierId": { |
| | | "description": "供应商id", |
| | | "type": "integer" |
| | | }, |
| | | "totalPrice": { |
| | | "description": "价税合计", |
| | | "type": "number" |
| | | }, |
| | | "unInvoiceAmount": { |
| | | "description": "未收票金额", |
| | | "type": "number" |
| | | }, |
| | | "warehouse": { |
| | | "description": "收货仓库", |
| | | "type": "string" |
| | | }, |
| | | "wholeDiscount": { |
| | | "description": "整单折扣值", |
| | | "type": "number" |
| | | }, |
| | | "wholeDiscountType": { |
| | | "description": "整单折扣类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/purchase.WholeDiscountType" |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "purchase.WholeDiscountType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "WholeDiscountTypeDiscount": "直接降价", |
| | | "WholeDiscountTypePercent": "百分比降价" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "WholeDiscountTypePercent", |
| | | "WholeDiscountTypeDiscount" |
| | | ] |
| | | }, |
| | | "purchaserequest.AddPurchase": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "description": "联系人电话", |
| | | "type": "string" |
| | | }, |
| | | "priceAdjustment": { |
| | | "description": "价格调整值", |
| | | "type": "number" |
| | | }, |
| | | "priceAdjustmentType": { |
| | | "description": "价格调整类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/purchase.PriceAdjustmentType" |
| | | } |
| | | ] |
| | | }, |
| | | "purchaseTypeId": { |
| | | "description": "采购类型id", |
| | | "type": "integer" |
| | | }, |
| | | "quantity": { |
| | | "description": "采购数量", |
| | | "type": "number" |
| | | }, |
| | | "realTotalPrice": { |
| | | "description": "最终价格", |
| | | "type": "number" |
| | | }, |
| | | "remark": { |
| | | "description": "备注", |
| | |
| | | "supplierId": { |
| | | "description": "供应商id", |
| | | "type": "integer" |
| | | }, |
| | | "totalPrice": { |
| | | "description": "价税合计", |
| | | "type": "number" |
| | | }, |
| | | "wholeDiscount": { |
| | | "description": "整单折扣值", |
| | | "type": "number" |
| | | }, |
| | | "wholeDiscountType": { |
| | | "description": "整单折扣类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/purchase.WholeDiscountType" |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.PurchaseProducts": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "采购数量", |
| | | "type": "number" |
| | | }, |
| | | "deliveryTime": { |
| | | "type": "integer" |
| | | }, |
| | | "modelNumber": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "price": { |
| | | "description": "采购单价", |
| | | "type": "number" |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "integer" |
| | | }, |
| | | "productType": { |
| | | "type": "string" |
| | | }, |
| | | "purchaseId": { |
| | | "description": "采购id", |
| | | "type": "integer" |
| | | }, |
| | | "purchasePrice": { |
| | | "type": "number" |
| | | }, |
| | | "shippingDuration": { |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "type": "string" |
| | | }, |
| | | "total": { |
| | | "description": "采购总价", |
| | | "type": "number" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.PurchaseResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "productList": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/purchase.PurchaseProducts" |
| | | "$ref": "#/definitions/response.PurchaseProducts" |
| | | } |
| | | }, |
| | | "purchase": { |
| | |
| | | "summary": "创建采购单", |
| | | "parameters": [ |
| | | { |
| | | "description": "采购单用户名, 采购单手机号码", |
| | | "description": "采购单,采购单产品", |
| | | "name": "data", |
| | | "in": "body", |
| | | "required": true, |
| | |
| | | "items": { |
| | | "$ref": "#/definitions/purchase.PurchaseType" |
| | | } |
| | | }, |
| | | "msg": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/purchase/qualityInspectList": { |
| | | "get": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "QualityInspect" |
| | | ], |
| | | "summary": "分页获取质检单列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "分页获取质检单列表,返回包括列表,总数,页码,每页数量", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/response.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.PageResult" |
| | | }, |
| | | "msg": { |
| | | "type": "string" |
| | |
| | | "OrderStatusCompleted" |
| | | ] |
| | | }, |
| | | "purchase.PriceAdjustmentType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "PriceAdjustmentTypeAdd": "增加", |
| | | "PriceAdjustmentTypeSub": "减少" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "PriceAdjustmentTypeAdd", |
| | | "PriceAdjustmentTypeSub" |
| | | ] |
| | | }, |
| | | "purchase.Purchase": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "invoiceAmount": { |
| | | "description": "已收票金额", |
| | | "type": "number" |
| | | }, |
| | | "name": { |
| | | "description": "采购名称", |
| | | "type": "string" |
| | |
| | | "description": "采购编号", |
| | | "type": "string" |
| | | }, |
| | | "orderSource": { |
| | | "description": "单据来源", |
| | | "type": "string" |
| | | }, |
| | | "orderType": { |
| | | "description": "单据类型", |
| | | "type": "string" |
| | | }, |
| | | "paidAmount": { |
| | | "description": "已付金额", |
| | | "type": "number" |
| | | }, |
| | | "phone": { |
| | | "description": "联系人电话", |
| | | "type": "string" |
| | | }, |
| | | "priceAdjustment": { |
| | | "description": "价格调整值", |
| | | "type": "number" |
| | | }, |
| | | "priceAdjustmentType": { |
| | | "description": "价格调整类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/purchase.PriceAdjustmentType" |
| | | } |
| | | ] |
| | | }, |
| | | "principal": { |
| | | "description": "采购负责人", |
| | | "type": "string" |
| | | }, |
| | | "purchaseType": { |
| | |
| | | "description": "采购数量", |
| | | "type": "number" |
| | | }, |
| | | "realTotalPrice": { |
| | | "description": "最终价格", |
| | | "type": "number" |
| | | }, |
| | | "remark": { |
| | | "description": "备注", |
| | | "type": "string" |
| | | }, |
| | | "shouldPayAmount": { |
| | | "description": "应付金额", |
| | | "type": "number" |
| | | }, |
| | | "signingDate": { |
| | | "description": "签约日期", |
| | |
| | | "supplierId": { |
| | | "description": "供应商id", |
| | | "type": "integer" |
| | | }, |
| | | "totalPrice": { |
| | | "description": "价税合计", |
| | | "type": "number" |
| | | }, |
| | | "unInvoiceAmount": { |
| | | "description": "未收票金额", |
| | | "type": "number" |
| | | }, |
| | | "warehouse": { |
| | | "description": "收货仓库", |
| | | "type": "string" |
| | | }, |
| | | "wholeDiscount": { |
| | | "description": "整单折扣值", |
| | | "type": "number" |
| | | }, |
| | | "wholeDiscountType": { |
| | | "description": "整单折扣类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/purchase.WholeDiscountType" |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "purchase.WholeDiscountType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "WholeDiscountTypeDiscount": "直接降价", |
| | | "WholeDiscountTypePercent": "百分比降价" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "WholeDiscountTypePercent", |
| | | "WholeDiscountTypeDiscount" |
| | | ] |
| | | }, |
| | | "purchaserequest.AddPurchase": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "description": "联系人电话", |
| | | "type": "string" |
| | | }, |
| | | "priceAdjustment": { |
| | | "description": "价格调整值", |
| | | "type": "number" |
| | | }, |
| | | "priceAdjustmentType": { |
| | | "description": "价格调整类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/purchase.PriceAdjustmentType" |
| | | } |
| | | ] |
| | | }, |
| | | "purchaseTypeId": { |
| | | "description": "采购类型id", |
| | | "type": "integer" |
| | | }, |
| | | "quantity": { |
| | | "description": "采购数量", |
| | | "type": "number" |
| | | }, |
| | | "realTotalPrice": { |
| | | "description": "最终价格", |
| | | "type": "number" |
| | | }, |
| | | "remark": { |
| | | "description": "备注", |
| | |
| | | "supplierId": { |
| | | "description": "供应商id", |
| | | "type": "integer" |
| | | }, |
| | | "totalPrice": { |
| | | "description": "价税合计", |
| | | "type": "number" |
| | | }, |
| | | "wholeDiscount": { |
| | | "description": "整单折扣值", |
| | | "type": "number" |
| | | }, |
| | | "wholeDiscountType": { |
| | | "description": "整单折扣类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/purchase.WholeDiscountType" |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.PurchaseProducts": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "采购数量", |
| | | "type": "number" |
| | | }, |
| | | "deliveryTime": { |
| | | "type": "integer" |
| | | }, |
| | | "modelNumber": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "price": { |
| | | "description": "采购单价", |
| | | "type": "number" |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "integer" |
| | | }, |
| | | "productType": { |
| | | "type": "string" |
| | | }, |
| | | "purchaseId": { |
| | | "description": "采购id", |
| | | "type": "integer" |
| | | }, |
| | | "purchasePrice": { |
| | | "type": "number" |
| | | }, |
| | | "shippingDuration": { |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "type": "string" |
| | | }, |
| | | "total": { |
| | | "description": "采购总价", |
| | | "type": "number" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.PurchaseResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "productList": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/purchase.PurchaseProducts" |
| | | "$ref": "#/definitions/response.PurchaseProducts" |
| | | } |
| | | }, |
| | | "purchase": { |
| | |
| | | - OrderStatusReceived |
| | | - OrderStatusStored |
| | | - OrderStatusCompleted |
| | | purchase.PriceAdjustmentType: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | type: integer |
| | | x-enum-comments: |
| | | PriceAdjustmentTypeAdd: 增加 |
| | | PriceAdjustmentTypeSub: 减少 |
| | | x-enum-varnames: |
| | | - PriceAdjustmentTypeAdd |
| | | - PriceAdjustmentTypeSub |
| | | purchase.Purchase: |
| | | properties: |
| | | contact: |
| | |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | | invoiceAmount: |
| | | description: 已收票金额 |
| | | type: number |
| | | name: |
| | | description: 采购名称 |
| | | type: string |
| | | number: |
| | | description: 采购编号 |
| | | type: string |
| | | orderSource: |
| | | description: 单据来源 |
| | | type: string |
| | | orderType: |
| | | description: 单据类型 |
| | | type: string |
| | | paidAmount: |
| | | description: 已付金额 |
| | | type: number |
| | | phone: |
| | | description: 联系人电话 |
| | | type: string |
| | | priceAdjustment: |
| | | description: 价格调整值 |
| | | type: number |
| | | priceAdjustmentType: |
| | | allOf: |
| | | - $ref: '#/definitions/purchase.PriceAdjustmentType' |
| | | description: 价格调整类型 |
| | | principal: |
| | | description: 采购负责人 |
| | | type: string |
| | | purchaseType: |
| | | $ref: '#/definitions/purchase.PurchaseType' |
| | |
| | | quantity: |
| | | description: 采购数量 |
| | | type: number |
| | | realTotalPrice: |
| | | description: 最终价格 |
| | | type: number |
| | | remark: |
| | | description: 备注 |
| | | type: string |
| | | shouldPayAmount: |
| | | description: 应付金额 |
| | | type: number |
| | | signingDate: |
| | | description: 签约日期 |
| | | type: string |
| | |
| | | supplierId: |
| | | description: 供应商id |
| | | type: integer |
| | | totalPrice: |
| | | description: 价税合计 |
| | | type: number |
| | | unInvoiceAmount: |
| | | description: 未收票金额 |
| | | type: number |
| | | warehouse: |
| | | description: 收货仓库 |
| | | type: string |
| | | wholeDiscount: |
| | | description: 整单折扣值 |
| | | type: number |
| | | wholeDiscountType: |
| | | allOf: |
| | | - $ref: '#/definitions/purchase.WholeDiscountType' |
| | | description: 整单折扣类型 |
| | | type: object |
| | | purchase.PurchaseProducts: |
| | | properties: |
| | |
| | | description: 排序 |
| | | type: integer |
| | | type: object |
| | | purchase.WholeDiscountType: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | type: integer |
| | | x-enum-comments: |
| | | WholeDiscountTypeDiscount: 直接降价 |
| | | WholeDiscountTypePercent: 百分比降价 |
| | | x-enum-varnames: |
| | | - WholeDiscountTypePercent |
| | | - WholeDiscountTypeDiscount |
| | | purchaserequest.AddPurchase: |
| | | properties: |
| | | productList: |
| | |
| | | phone: |
| | | description: 联系人电话 |
| | | type: string |
| | | priceAdjustment: |
| | | description: 价格调整值 |
| | | type: number |
| | | priceAdjustmentType: |
| | | allOf: |
| | | - $ref: '#/definitions/purchase.PriceAdjustmentType' |
| | | description: 价格调整类型 |
| | | purchaseTypeId: |
| | | description: 采购类型id |
| | | type: integer |
| | | quantity: |
| | | description: 采购数量 |
| | | type: number |
| | | realTotalPrice: |
| | | description: 最终价格 |
| | | type: number |
| | | remark: |
| | | description: 备注 |
| | | type: string |
| | |
| | | supplierId: |
| | | description: 供应商id |
| | | type: integer |
| | | totalPrice: |
| | | description: 价税合计 |
| | | type: number |
| | | wholeDiscount: |
| | | description: 整单折扣值 |
| | | type: number |
| | | wholeDiscountType: |
| | | allOf: |
| | | - $ref: '#/definitions/purchase.WholeDiscountType' |
| | | description: 整单折扣类型 |
| | | type: object |
| | | purchaserequest.PurchaseType: |
| | | properties: |
| | |
| | | $ref: '#/definitions/request.CasbinInfo' |
| | | type: array |
| | | type: object |
| | | response.PurchaseProducts: |
| | | properties: |
| | | amount: |
| | | description: 采购数量 |
| | | type: number |
| | | deliveryTime: |
| | | type: integer |
| | | modelNumber: |
| | | type: string |
| | | name: |
| | | type: string |
| | | number: |
| | | type: string |
| | | price: |
| | | description: 采购单价 |
| | | type: number |
| | | productId: |
| | | description: 产品id |
| | | type: integer |
| | | productType: |
| | | type: string |
| | | purchaseId: |
| | | description: 采购id |
| | | type: integer |
| | | purchasePrice: |
| | | type: number |
| | | shippingDuration: |
| | | type: integer |
| | | specifications: |
| | | type: string |
| | | total: |
| | | description: 采购总价 |
| | | type: number |
| | | unit: |
| | | type: string |
| | | type: object |
| | | response.PurchaseResponse: |
| | | properties: |
| | | productList: |
| | | items: |
| | | $ref: '#/definitions/purchase.PurchaseProducts' |
| | | $ref: '#/definitions/response.PurchaseProducts' |
| | | type: array |
| | | purchase: |
| | | $ref: '#/definitions/purchase.Purchase' |
| | |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 采购单用户名, 采购单手机号码 |
| | | - description: 采购单,采购单产品 |
| | | in: body |
| | | name: data |
| | | required: true |
| | |
| | | summary: 获取采购类型列表 |
| | | tags: |
| | | - Purchase |
| | | /purchase/qualityInspectList: |
| | | get: |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 关键字 |
| | | in: query |
| | | name: keyword |
| | | type: string |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | | type: integer |
| | | - description: 每页大小 |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 分页获取质检单列表,返回包括列表,总数,页码,每页数量 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/response.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.PageResult' |
| | | msg: |
| | | type: string |
| | | type: object |
| | | security: |
| | | - ApiKeyAuth: [] |
| | | summary: 分页获取质检单列表 |
| | | tags: |
| | | - QualityInspect |
| | | /purchase/submit/{id}: |
| | | post: |
| | | consumes: |
| | |
| | | |
| | | type Purchase struct { |
| | | global.GVA_MODEL |
| | | PurchaseTypeId int `json:"purchaseTypeId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购类型id |
| | | PurchaseType PurchaseType `json:"purchaseType" gorm:"foreignKey:PurchaseTypeId"` |
| | | SupplierId int `json:"supplierId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 供应商id |
| | | Supplier test.Supplier `json:"supplier" gorm:"foreignKey:SupplierId"` |
| | | Number string `json:"number" form:"number" gorm:"unique;type:varchar(255);not null;default '';comment:采购编号"` // 采购编号 |
| | | Name string `json:"name" form:"name" gorm:"type:varchar(255);not null;default '';comment:采购名称"` // 采购名称 |
| | | Quantity decimal.Decimal `json:"quantity" form:"quantity" gorm:"type:decimal(12,4);not null;comment:采购数量"` // 采购数量 |
| | | Contact string `json:"contact" form:"contact" gorm:"type:varchar(255);not null;default '';comment:联系人"` // 联系人 |
| | | Phone string `json:"phone" form:"phone" gorm:"type:varchar(255);not null;default '';comment:联系人电话"` // 联系人电话 |
| | | SigningDate string `json:"signingDate" form:"signingDate" gorm:"type:varchar(255);not null;default '';comment:签约日期"` // 签约日期 |
| | | DeliveryDate string `json:"deliveryDate" form:"deliveryDate" gorm:"type:varchar(255);not null;default '';comment:交付日期"` //交付日期 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null;default '';comment:备注"` //备注 |
| | | Status OrderStatus `json:"status" form:"status" gorm:"type:tinyint(1);not null;default 0;comment:状态"` //状态 |
| | | HandledBy string `json:"handledBy" form:"handledBy" gorm:"type:varchar(255);not null;default '';comment:经办人"` //经办人 |
| | | Creator string `json:"creator" form:"creator" gorm:"type:varchar(255);not null;default '';comment:制单人"` //制单人 |
| | | PurchaseTypeId int `json:"purchaseTypeId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购类型id |
| | | PurchaseType PurchaseType `json:"purchaseType" gorm:"foreignKey:PurchaseTypeId"` |
| | | OrderSource string `json:"orderSource" gorm:"type:varchar(255);not null;default '';comment:单据来源"` // 单据来源 |
| | | SupplierId int `json:"supplierId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 供应商id |
| | | Supplier test.Supplier `json:"supplier" gorm:"foreignKey:SupplierId"` |
| | | Number string `json:"number" form:"number" gorm:"unique;type:varchar(255);not null;default '';comment:采购编号"` // 采购编号 |
| | | Name string `json:"name" form:"name" gorm:"type:varchar(255);not null;default '';comment:采购名称"` // 采购名称 |
| | | Contact string `json:"contact" form:"contact" gorm:"type:varchar(255);not null;default '';comment:联系人"` // 联系人 |
| | | Phone string `json:"phone" form:"phone" gorm:"type:varchar(255);not null;default '';comment:联系人电话"` // 联系人电话 |
| | | SigningDate string `json:"signingDate" form:"signingDate" gorm:"type:varchar(255);not null;default '';comment:签约日期"` // 签约日期 |
| | | DeliveryDate string `json:"deliveryDate" form:"deliveryDate" gorm:"type:varchar(255);not null;default '';comment:交付日期"` //交付日期 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null;default '';comment:备注"` //备注 |
| | | Status OrderStatus `json:"status" form:"status" gorm:"type:tinyint(1);not null;default 0;comment:状态"` //状态 |
| | | HandledBy string `json:"handledBy" form:"handledBy" gorm:"type:varchar(255);not null;default '';comment:经办人"` //经办人 |
| | | Creator string `json:"creator" form:"creator" gorm:"type:varchar(255);not null;default '';comment:制单人"` //制单人 |
| | | Principal string `json:"principal" form:"principal" gorm:"type:varchar(255);not null;default '';comment:采购负责人"` //采购负责人 |
| | | OrderType string `json:"orderType" form:"orderType" gorm:"type:varchar(255);not null;default '';comment:单据类型"` //单据类型 |
| | | Warehouse string `json:"warehouse" form:"warehouse" gorm:"type:varchar(255);not null;default '';comment:收货仓库"` //收货仓库 |
| | | Quantity decimal.Decimal `json:"quantity" form:"quantity" gorm:"type:decimal(12,4);not null;comment:采购数量"` // 采购数量 |
| | | TotalPrice decimal.Decimal `json:"totalPrice" form:"totalPrice" gorm:"type:decimal(12,2);not null;default '';comment:价税合计"` //价税合计 |
| | | WholeDiscountType WholeDiscountType `json:"wholeDiscountType" form:"wholeDiscountType" gorm:"type:tinyint(1);not null;default '';comment:整单折扣"` //整单折扣类型 |
| | | WholeDiscount decimal.Decimal `json:"wholeDiscount" form:"wholeDiscount" gorm:"type:decimal(12,2);not null;default '';comment:整单折扣"` //整单折扣值 |
| | | PriceAdjustmentType PriceAdjustmentType `json:"priceAdjustmentType" form:"priceAdjustmentType" gorm:"type:tinyint(1);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 |
| | |
| | | OrderStatusStored OrderStatus = 3 //已入库 |
| | | OrderStatusCompleted OrderStatus = 4 //已完成 |
| | | ) |
| | | |
| | | type WholeDiscountType int |
| | | |
| | | const ( |
| | | WholeDiscountTypePercent WholeDiscountType = 1 //百分比降价 |
| | | WholeDiscountTypeDiscount WholeDiscountType = 2 //直接降价 |
| | | ) |
| | | |
| | | func (wdt WholeDiscountType) IsValid(totalPrice, value decimal.Decimal) bool { |
| | | if wdt == 0 { |
| | | return true |
| | | } |
| | | if wdt != WholeDiscountTypePercent && wdt != WholeDiscountTypeDiscount { |
| | | return false |
| | | } |
| | | if wdt == WholeDiscountTypeDiscount && value.GreaterThan(totalPrice) { |
| | | return false |
| | | } |
| | | if wdt == WholeDiscountTypePercent && totalPrice.Mul(value).Div(decimal.NewFromInt(100)).GreaterThan(totalPrice) { |
| | | return false |
| | | } |
| | | return true |
| | | } |
| | | |
| | | type PriceAdjustmentType int |
| | | |
| | | const ( |
| | | PriceAdjustmentTypeAdd PriceAdjustmentType = 1 //增加 |
| | | PriceAdjustmentTypeSub PriceAdjustmentType = 2 //减少 |
| | | ) |
| | | |
| | | func (pat PriceAdjustmentType) IsValid(totalPrice, value decimal.Decimal) bool { |
| | | if pat == 0 { |
| | | return true |
| | | } |
| | | if pat != PriceAdjustmentTypeAdd && pat != PriceAdjustmentTypeSub { |
| | | return false |
| | | } |
| | | if pat == PriceAdjustmentTypeSub && value.GreaterThan(totalPrice) { |
| | | return false |
| | | } |
| | | return true |
| | | } |
| | | |
| | | func (slf Purchase) CalcRealTotalPrice() decimal.Decimal { |
| | | totalPrice := slf.TotalPrice |
| | | if slf.WholeDiscountType == WholeDiscountTypePercent { |
| | | totalPrice = totalPrice.Mul(decimal.NewFromInt(1).Sub(slf.WholeDiscount.Div(decimal.NewFromInt(100)))) |
| | | } else if slf.WholeDiscountType == WholeDiscountTypeDiscount { |
| | | totalPrice = totalPrice.Sub(slf.WholeDiscount) |
| | | } |
| | | |
| | | if slf.PriceAdjustmentType == PriceAdjustmentTypeAdd { |
| | | totalPrice = totalPrice.Add(slf.PriceAdjustment) |
| | | } else if slf.PriceAdjustmentType == PriceAdjustmentTypeSub { |
| | | totalPrice = totalPrice.Sub(slf.PriceAdjustment) |
| | | } |
| | | return totalPrice.RoundCeil(2) |
| | | } |
| | |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | "srm/global" |
| | | "srm/model/test" |
| | | ) |
| | | |
| | | type PurchaseProducts struct { |
| | | global.GVA_MODEL |
| | | PurchaseId int `json:"purchaseId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购id |
| | | ProductId int `json:"productId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 产品id |
| | | Amount decimal.Decimal `json:"amount" form:"amount" gorm:"type:decimal(12,2);not null;default 0;comment:采购数量"` // 采购数量 |
| | | Price decimal.Decimal `json:"price" form:"price" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购单价"` // 采购单价 |
| | | Total decimal.Decimal `json:"total" form:"total" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购总价"` // 采购总价 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null; default '';comment:描述"` //描述 |
| | | Product test.Product `json:"-" gorm:"foreignKey:ProductId"` |
| | | Amount decimal.Decimal `json:"amount" form:"amount" gorm:"type:decimal(12,2);not null;default 0;comment:采购数量"` // 采购数量 |
| | | Price decimal.Decimal `json:"price" form:"price" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购单价"` // 采购单价 |
| | | Total decimal.Decimal `json:"total" form:"total" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购总价"` // 采购总价 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null; default '';comment:描述"` //描述 |
| | | } |
| | |
| | | package purchaserequest |
| | | |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | "srm/model/common/request" |
| | | "srm/model/purchase" |
| | | "time" |
| | |
| | | } |
| | | |
| | | type Purchase struct { |
| | | ID uint `gorm:"primarykey"` // 主键ID |
| | | PurchaseTypeId int `json:"purchaseTypeId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购类型id |
| | | SupplierId int `json:"supplierId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 供应商id |
| | | Number string `json:"number" form:"number" gorm:"unique;type:varchar(255);not null;default '';comment:采购编号"` // 采购编号 |
| | | Name string `json:"name" form:"name" gorm:"type:varchar(255);not null;default '';comment:采购名称"` // 采购名称 |
| | | Contact string `json:"contact" form:"contact" gorm:"type:varchar(255);not null;default '';comment:联系人"` // 联系人 |
| | | Phone string `json:"phone" form:"phone" gorm:"type:varchar(255);not null;default '';comment:联系人电话"` // 联系人电话 |
| | | SigningDate string `json:"signingDate" form:"signingDate" gorm:"type:varchar(255);not null;default '';comment:签约日期"` // 签约日期 |
| | | DeliveryDate string `json:"deliveryDate" form:"deliveryDate" gorm:"type:varchar(255);not null;default '';comment:交付日期"` //交付日期 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null;default '';comment:备注"` //备注 |
| | | Status purchase.OrderStatus `json:"status" form:"status" gorm:"type:tinyint(1);not null;default 0;comment:状态"` //状态 |
| | | ID uint `gorm:"primarykey"` // 主键ID |
| | | PurchaseTypeId int `json:"purchaseTypeId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购类型id |
| | | SupplierId int `json:"supplierId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 供应商id |
| | | Number string `json:"number" form:"number" gorm:"unique;type:varchar(255);not null;default '';comment:采购编号"` // 采购编号 |
| | | Name string `json:"name" form:"name" gorm:"type:varchar(255);not null;default '';comment:采购名称"` // 采购名称 |
| | | Contact string `json:"contact" form:"contact" gorm:"type:varchar(255);not null;default '';comment:联系人"` // 联系人 |
| | | Phone string `json:"phone" form:"phone" gorm:"type:varchar(255);not null;default '';comment:联系人电话"` // 联系人电话 |
| | | SigningDate string `json:"signingDate" form:"signingDate" gorm:"type:varchar(255);not null;default '';comment:签约日期"` // 签约日期 |
| | | DeliveryDate string `json:"deliveryDate" form:"deliveryDate" gorm:"type:varchar(255);not null;default '';comment:交付日期"` //交付日期 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null;default '';comment:备注"` //备注 |
| | | Status purchase.OrderStatus `json:"status" form:"status" gorm:"type:tinyint(1);not null;default 0;comment:状态"` //状态 |
| | | Quantity decimal.Decimal `json:"quantity" form:"quantity" gorm:"type:decimal(12,2);not null;default 0;comment:采购数量"` // 采购数量 |
| | | TotalPrice decimal.Decimal `json:"totalPrice" form:"totalPrice" gorm:"type:decimal(12,2);not null;default 0.00;comment:价税合计"` //价税合计 |
| | | WholeDiscountType purchase.WholeDiscountType `json:"wholeDiscountType" form:"wholeDiscountType" gorm:"type:decimal(12,2);not null;default 0.00;comment:整单折扣"` //整单折扣类型 |
| | | WholeDiscount decimal.Decimal `json:"wholeDiscount" form:"wholeDiscount" gorm:"type:decimal(12,2);not null;default 0;comment:整单折扣"` //整单折扣值 |
| | | PriceAdjustmentType purchase.PriceAdjustmentType `json:"priceAdjustmentType" form:"priceAdjustmentType" gorm:"type:decimal(12,2);not null;default 0;comment:价格调整类型"` //价格调整类型 |
| | | PriceAdjustment decimal.Decimal `json:"priceAdjustment" form:"priceAdjustment" gorm:"type:decimal(12,2);not null;default 0.00;comment:价格调整"` //价格调整值 |
| | | RealTotalPrice decimal.Decimal `json:"realTotalPrice" form:"realTotalPrice" gorm:"type:decimal(12,2);not null;default 0.00;comment:最终价格"` //最终价格 |
| | | } |
| | |
| | | package response |
| | | |
| | | import "srm/model/purchase" |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | "srm/model/purchase" |
| | | "srm/model/test" |
| | | ) |
| | | |
| | | type PurchaseResponse struct { |
| | | Purchase purchase.Purchase `json:"purchase"` |
| | | ProductList []*purchase.PurchaseProducts `json:"productList"` |
| | | Purchase purchase.Purchase `json:"purchase"` |
| | | ProductList []*PurchaseProducts `json:"productList"` |
| | | } |
| | | |
| | | type PurchaseProducts struct { |
| | | PurchaseId int `json:"purchaseId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购id |
| | | ProductId int `json:"productId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 产品id |
| | | Amount decimal.Decimal `json:"amount" form:"amount" gorm:"type:decimal(12,2);not null;default 0;comment:采购数量"` // 采购数量 |
| | | Price decimal.Decimal `json:"price" form:"price" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购单价"` // 采购单价 |
| | | Total decimal.Decimal `json:"total" form:"total" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购总价"` // 采购总价 |
| | | Name string `json:"name" form:"name" gorm:"column:name;comment:名称;size:255;"` |
| | | Number string `json:"number" form:"number" gorm:"column:number;comment:编码;size:255;"` |
| | | Unit string `json:"unit" form:"unit" gorm:"column:unit;comment:计量单位;size:255;"` |
| | | PurchasePrice *float64 `json:"purchasePrice" form:"purchasePrice" gorm:"column:purchase_price;comment:采购价格;"` |
| | | DeliveryTime *int `json:"deliveryTime" form:"deliveryTime" gorm:"column:delivery_time;comment:;size:11;"` |
| | | ShippingDuration *int `json:"shippingDuration" form:"shippingDuration" gorm:"column:shipping_duration;comment:物流时长;size:11;"` |
| | | Specifications string `json:"specifications" form:"specifications" gorm:"column:specifications;comment:规格;size:255;"` |
| | | ModelNumber string `json:"modelNumber" form:"modelNumber" gorm:"column:model_number;comment:型号;size:255;"` |
| | | ProductType string `json:"productType" form:"productType" gorm:"column:product_type;comment:产品类别;size:255;"` |
| | | } |
| | | |
| | | type QualityInspectList struct { |
| | | PurchaseTypeId int `json:"purchaseTypeId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购类型id |
| | | OrderSource string `json:"orderSource" gorm:"type:varchar(255);not null;default '';comment:单据来源"` // 单据来源 |
| | | SupplierId int `json:"supplierId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 供应商id |
| | | Supplier test.Supplier `json:"supplier" gorm:"foreignKey:SupplierId"` |
| | | Number string `json:"number" form:"number" gorm:"unique;type:varchar(255);not null;default '';comment:采购编号"` // 采购编号 |
| | | Name string `json:"name" form:"name" gorm:"type:varchar(255);not null;default '';comment:采购名称"` // 采购名称 |
| | | Contact string `json:"contact" form:"contact" gorm:"type:varchar(255);not null;default '';comment:联系人"` // 联系人 |
| | | Phone string `json:"phone" form:"phone" gorm:"type:varchar(255);not null;default '';comment:联系人电话"` // 联系人电话 |
| | | SigningDate string `json:"signingDate" form:"signingDate" gorm:"type:varchar(255);not null;default '';comment:签约日期"` // 签约日期 |
| | | DeliveryDate string `json:"deliveryDate" form:"deliveryDate" gorm:"type:varchar(255);not null;default '';comment:交付日期"` //交付日期 |
| | | Remark string `json:"remark" form:"remark" gorm:"type:varchar(1000);not null;default '';comment:备注"` //备注 |
| | | HandledBy string `json:"handledBy" form:"handledBy" gorm:"type:varchar(255);not null;default '';comment:经办人"` //经办人 |
| | | Creator string `json:"creator" form:"creator" gorm:"type:varchar(255);not null;default '';comment:制单人"` //制单人 |
| | | Principal string `json:"principal" form:"principal" gorm:"type:varchar(255);not null;default '';comment:采购负责人"` //采购负责人 |
| | | OrderType string `json:"orderType" form:"orderType" gorm:"type:varchar(255);not null;default '';comment:单据类型"` //单据类型 |
| | | Warehouse string `json:"warehouse" form:"warehouse" gorm:"type:varchar(255);not null;default '';comment:收货仓库"` //收货仓库 |
| | | Quantity decimal.Decimal `json:"quantity" form:"quantity" gorm:"type:decimal(12,4);not null;comment:采购数量"` // 采购数量 |
| | | InspectStatus string `json:"inspectStatus" form:"inspectStatus"` //检测结果 |
| | | } |
| | |
| | | double report_amount = 13; // 报检数量 |
| | | InspectMethod inspect_method = 14; // 检验方式 |
| | | double inspect_amount = 15; // 检验数量 |
| | | int32 status = 16; // 状态 |
| | | InspectStatus status = 16; // 状态 |
| | | string submit_id = 17; // 提交人ID |
| | | double reject_amount = 18; // 退货数量 |
| | | double exchange_amount = 19; // 换货数量 |
| | |
| | | } |
| | | |
| | | |
| | | // InspectStatus 检验状态 |
| | | enum InspectStatus { |
| | | InspectStatusNull = 0; |
| | | InspectStatusWaitInspect = 1; // 待检查 |
| | | InspectStatusAuditing = 2; // 审核中 |
| | | InspectStatusAuditFinish = 3; // 审核完成 |
| | | InspectStatusInspectFinish = 4; // 检查完成 |
| | | } |
| | | |
| | | |
| | | message SendPurchaseInspectResponse { |
| | | int32 Code = 1; |
| | |
| | | |
| | | |
| | | message GetInspectListRequest{ |
| | | int32 page = 1; |
| | | int32 pageSize = 2; |
| | | string keyword = 3; |
| | | repeated string purchase_order_id = 1; |
| | | } |
| | | |
| | | message GetInspectListResponse{ |
| | |
| | | return file_quality_inspect_proto_rawDescGZIP(), []int{2} |
| | | } |
| | | |
| | | // InspectStatus 检验状态 |
| | | type InspectStatus int32 |
| | | |
| | | const ( |
| | | InspectStatus_InspectStatusNull InspectStatus = 0 |
| | | InspectStatus_InspectStatusWaitInspect InspectStatus = 1 // 待检查 |
| | | InspectStatus_InspectStatusAuditing InspectStatus = 2 // 审核中 |
| | | InspectStatus_InspectStatusAuditFinish InspectStatus = 3 // 审核完成 |
| | | InspectStatus_InspectStatusInspectFinish InspectStatus = 4 // 检查完成 |
| | | ) |
| | | |
| | | // Enum value maps for InspectStatus. |
| | | var ( |
| | | InspectStatus_name = map[int32]string{ |
| | | 0: "InspectStatusNull", |
| | | 1: "InspectStatusWaitInspect", |
| | | 2: "InspectStatusAuditing", |
| | | 3: "InspectStatusAuditFinish", |
| | | 4: "InspectStatusInspectFinish", |
| | | } |
| | | InspectStatus_value = map[string]int32{ |
| | | "InspectStatusNull": 0, |
| | | "InspectStatusWaitInspect": 1, |
| | | "InspectStatusAuditing": 2, |
| | | "InspectStatusAuditFinish": 3, |
| | | "InspectStatusInspectFinish": 4, |
| | | } |
| | | ) |
| | | |
| | | func (x InspectStatus) Enum() *InspectStatus { |
| | | p := new(InspectStatus) |
| | | *p = x |
| | | return p |
| | | } |
| | | |
| | | func (x InspectStatus) String() string { |
| | | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) |
| | | } |
| | | |
| | | func (InspectStatus) Descriptor() protoreflect.EnumDescriptor { |
| | | return file_quality_inspect_proto_enumTypes[3].Descriptor() |
| | | } |
| | | |
| | | func (InspectStatus) Type() protoreflect.EnumType { |
| | | return &file_quality_inspect_proto_enumTypes[3] |
| | | } |
| | | |
| | | func (x InspectStatus) Number() protoreflect.EnumNumber { |
| | | return protoreflect.EnumNumber(x) |
| | | } |
| | | |
| | | // Deprecated: Use InspectStatus.Descriptor instead. |
| | | func (InspectStatus) EnumDescriptor() ([]byte, []int) { |
| | | return file_quality_inspect_proto_rawDescGZIP(), []int{3} |
| | | } |
| | | |
| | | type SendPurchaseInspectRequest struct { |
| | | state protoimpl.MessageState |
| | | sizeCache protoimpl.SizeCache |
| | |
| | | ReportAmount float64 `protobuf:"fixed64,13,opt,name=report_amount,json=reportAmount,proto3" json:"report_amount,omitempty"` // 报检数量 |
| | | InspectMethod InspectMethod `protobuf:"varint,14,opt,name=inspect_method,json=inspectMethod,proto3,enum=InspectMethod" json:"inspect_method,omitempty"` // 检验方式 |
| | | InspectAmount float64 `protobuf:"fixed64,15,opt,name=inspect_amount,json=inspectAmount,proto3" json:"inspect_amount,omitempty"` // 检验数量 |
| | | Status int32 `protobuf:"varint,16,opt,name=status,proto3" json:"status,omitempty"` // 状态 |
| | | Status InspectStatus `protobuf:"varint,16,opt,name=status,proto3,enum=InspectStatus" json:"status,omitempty"` // 状态 |
| | | SubmitId string `protobuf:"bytes,17,opt,name=submit_id,json=submitId,proto3" json:"submit_id,omitempty"` // 提交人ID |
| | | RejectAmount float64 `protobuf:"fixed64,18,opt,name=reject_amount,json=rejectAmount,proto3" json:"reject_amount,omitempty"` // 退货数量 |
| | | ExchangeAmount float64 `protobuf:"fixed64,19,opt,name=exchange_amount,json=exchangeAmount,proto3" json:"exchange_amount,omitempty"` // 换货数量 |
| | |
| | | return 0 |
| | | } |
| | | |
| | | func (x *QualityInspect) GetStatus() int32 { |
| | | func (x *QualityInspect) GetStatus() InspectStatus { |
| | | if x != nil { |
| | | return x.Status |
| | | } |
| | | return 0 |
| | | return InspectStatus_InspectStatusNull |
| | | } |
| | | |
| | | func (x *QualityInspect) GetSubmitId() string { |
| | |
| | | sizeCache protoimpl.SizeCache |
| | | unknownFields protoimpl.UnknownFields |
| | | |
| | | Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` |
| | | PageSize int32 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"` |
| | | Keyword string `protobuf:"bytes,3,opt,name=keyword,proto3" json:"keyword,omitempty"` |
| | | PurchaseOrderId []string `protobuf:"bytes,1,rep,name=purchase_order_id,json=purchaseOrderId,proto3" json:"purchase_order_id,omitempty"` |
| | | } |
| | | |
| | | func (x *GetInspectListRequest) Reset() { |
| | |
| | | return file_quality_inspect_proto_rawDescGZIP(), []int{3} |
| | | } |
| | | |
| | | func (x *GetInspectListRequest) GetPage() int32 { |
| | | func (x *GetInspectListRequest) GetPurchaseOrderId() []string { |
| | | if x != nil { |
| | | return x.Page |
| | | return x.PurchaseOrderId |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *GetInspectListRequest) GetPageSize() int32 { |
| | | if x != nil { |
| | | return x.PageSize |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *GetInspectListRequest) GetKeyword() string { |
| | | if x != nil { |
| | | return x.Keyword |
| | | } |
| | | return "" |
| | | return nil |
| | | } |
| | | |
| | | type GetInspectListResponse struct { |
| | |
| | | 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, |
| | | 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, |
| | | 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x51, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x73, |
| | | 0x70, 0x65, 0x63, 0x74, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0xbe, 0x06, 0x0a, 0x0e, 0x51, |
| | | 0x70, 0x65, 0x63, 0x74, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0xce, 0x06, 0x0a, 0x0e, 0x51, |
| | | 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x0a, |
| | | 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2f, 0x0a, |
| | | 0x0c, 0x69, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, |
| | |
| | | 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x73, |
| | | 0x70, 0x65, 0x63, 0x74, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, |
| | | 0x01, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, |
| | | 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, |
| | | 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0e, |
| | | 0x32, 0x0e, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, |
| | | 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x6d, |
| | | 0x69, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, |
| | | 0x6d, 0x69, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x5f, |
| | |
| | | 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, |
| | | 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, |
| | | 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, |
| | | 0x22, 0x61, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4c, 0x69, |
| | | 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, |
| | | 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, |
| | | 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, |
| | | 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, |
| | | 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, |
| | | 0x6f, 0x72, 0x64, 0x22, 0x79, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, |
| | | 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, |
| | | 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, |
| | | 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, |
| | | 0x4d, 0x73, 0x67, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, |
| | | 0x0b, 0x32, 0x0f, 0x2e, 0x51, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x73, 0x70, 0x65, |
| | | 0x63, 0x74, 0x52, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x74, 0x61, |
| | | 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x2a, 0x86, |
| | | 0x01, 0x0a, 0x0b, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, |
| | | 0x0a, 0x12, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, |
| | | 0x54, 0x79, 0x70, 0x65, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, |
| | | 0x74, 0x54, 0x79, 0x70, 0x65, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x65, 0x10, 0x01, 0x12, 0x17, 0x0a, |
| | | 0x13, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x50, 0x75, 0x72, 0x63, |
| | | 0x68, 0x61, 0x73, 0x65, 0x10, 0x02, 0x12, 0x18, 0x0a, 0x14, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, |
| | | 0x74, 0x54, 0x79, 0x70, 0x65, 0x4f, 0x75, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x10, 0x03, |
| | | 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, |
| | | 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x04, 0x2a, 0x6c, 0x0a, 0x0c, 0x4d, 0x61, 0x74, 0x65, 0x72, |
| | | 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x13, 0x44, 0x65, 0x66, 0x61, 0x75, |
| | | 0x6c, 0x74, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x10, 0x00, |
| | | 0x12, 0x13, 0x0a, 0x0f, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, |
| | | 0x52, 0x61, 0x77, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, |
| | | 0x6c, 0x54, 0x79, 0x70, 0x65, 0x53, 0x65, 0x6d, 0x69, 0x10, 0x02, 0x12, 0x18, 0x0a, 0x14, 0x4d, |
| | | 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, |
| | | 0x68, 0x65, 0x64, 0x10, 0x03, 0x2a, 0x56, 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, |
| | | 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x14, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, |
| | | 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x10, 0x00, |
| | | 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, |
| | | 0x64, 0x41, 0x6c, 0x6c, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, |
| | | 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x53, 0x70, 0x6f, 0x74, 0x10, 0x02, 0x32, 0xb0, 0x01, |
| | | 0x0a, 0x15, 0x51, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, |
| | | 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, 0x13, 0x53, 0x65, 0x6e, 0x64, 0x50, |
| | | 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x12, 0x1b, |
| | | 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x73, |
| | | 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x53, 0x65, |
| | | 0x6e, 0x64, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, |
| | | 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x47, |
| | | 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, |
| | | 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, |
| | | 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, |
| | | 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, |
| | | 0x42, 0x12, 0x5a, 0x10, 0x2e, 0x2f, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x69, 0x6e, 0x73, |
| | | 0x70, 0x65, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, |
| | | 0x22, 0x43, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4c, 0x69, |
| | | 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x11, 0x70, 0x75, 0x72, |
| | | 0x63, 0x68, 0x61, 0x73, 0x65, 0x5f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, |
| | | 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x4f, 0x72, |
| | | 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0x79, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, |
| | | 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, |
| | | 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, |
| | | 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, |
| | | 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, |
| | | 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x51, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x73, |
| | | 0x70, 0x65, 0x63, 0x74, 0x52, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, |
| | | 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, |
| | | 0x2a, 0x86, 0x01, 0x0a, 0x0b, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, |
| | | 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, |
| | | 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x70, |
| | | 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x65, 0x10, 0x01, 0x12, |
| | | 0x17, 0x0a, 0x13, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x50, 0x75, |
| | | 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x10, 0x02, 0x12, 0x18, 0x0a, 0x14, 0x49, 0x6e, 0x73, 0x70, |
| | | 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x4f, 0x75, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, |
| | | 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, |
| | | 0x65, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x04, 0x2a, 0x6c, 0x0a, 0x0c, 0x4d, 0x61, 0x74, |
| | | 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x13, 0x44, 0x65, 0x66, |
| | | 0x61, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, |
| | | 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, |
| | | 0x70, 0x65, 0x52, 0x61, 0x77, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x4d, 0x61, 0x74, 0x65, 0x72, |
| | | 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x53, 0x65, 0x6d, 0x69, 0x10, 0x02, 0x12, 0x18, 0x0a, |
| | | 0x14, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x46, 0x69, 0x6e, |
| | | 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0x03, 0x2a, 0x56, 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x70, 0x65, |
| | | 0x63, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x14, 0x44, 0x65, 0x66, 0x61, |
| | | 0x75, 0x6c, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, |
| | | 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, |
| | | 0x68, 0x6f, 0x64, 0x41, 0x6c, 0x6c, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x70, |
| | | 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x53, 0x70, 0x6f, 0x74, 0x10, 0x02, 0x2a, |
| | | 0x9d, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, |
| | | 0x73, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x74, 0x61, 0x74, |
| | | 0x75, 0x73, 0x4e, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x1c, 0x0a, 0x18, 0x49, 0x6e, 0x73, 0x70, |
| | | 0x65, 0x63, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x57, 0x61, 0x69, 0x74, 0x49, 0x6e, 0x73, |
| | | 0x70, 0x65, 0x63, 0x74, 0x10, 0x01, 0x12, 0x19, 0x0a, 0x15, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, |
| | | 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x41, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x10, |
| | | 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x74, 0x61, 0x74, |
| | | 0x75, 0x73, 0x41, 0x75, 0x64, 0x69, 0x74, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x10, 0x03, 0x12, |
| | | 0x1e, 0x0a, 0x1a, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, |
| | | 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x10, 0x04, 0x32, |
| | | 0xb0, 0x01, 0x0a, 0x15, 0x51, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x73, 0x70, 0x65, |
| | | 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, 0x13, 0x53, 0x65, 0x6e, |
| | | 0x64, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, |
| | | 0x12, 0x1b, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, |
| | | 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, |
| | | 0x53, 0x65, 0x6e, 0x64, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x73, 0x70, |
| | | 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, |
| | | 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, |
| | | 0x16, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, |
| | | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x73, |
| | | 0x70, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, |
| | | 0x22, 0x00, 0x42, 0x12, 0x5a, 0x10, 0x2e, 0x2f, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x69, |
| | | 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, |
| | | } |
| | | |
| | | var ( |
| | |
| | | return file_quality_inspect_proto_rawDescData |
| | | } |
| | | |
| | | var file_quality_inspect_proto_enumTypes = make([]protoimpl.EnumInfo, 3) |
| | | var file_quality_inspect_proto_enumTypes = make([]protoimpl.EnumInfo, 4) |
| | | var file_quality_inspect_proto_msgTypes = make([]protoimpl.MessageInfo, 5) |
| | | var file_quality_inspect_proto_goTypes = []interface{}{ |
| | | (InspectType)(0), // 0: InspectType |
| | | (MaterialType)(0), // 1: MaterialType |
| | | (InspectMethod)(0), // 2: InspectMethod |
| | | (*SendPurchaseInspectRequest)(nil), // 3: SendPurchaseInspectRequest |
| | | (*QualityInspect)(nil), // 4: QualityInspect |
| | | (*SendPurchaseInspectResponse)(nil), // 5: SendPurchaseInspectResponse |
| | | (*GetInspectListRequest)(nil), // 6: GetInspectListRequest |
| | | (*GetInspectListResponse)(nil), // 7: GetInspectListResponse |
| | | (InspectStatus)(0), // 3: InspectStatus |
| | | (*SendPurchaseInspectRequest)(nil), // 4: SendPurchaseInspectRequest |
| | | (*QualityInspect)(nil), // 5: QualityInspect |
| | | (*SendPurchaseInspectResponse)(nil), // 6: SendPurchaseInspectResponse |
| | | (*GetInspectListRequest)(nil), // 7: GetInspectListRequest |
| | | (*GetInspectListResponse)(nil), // 8: GetInspectListResponse |
| | | } |
| | | var file_quality_inspect_proto_depIdxs = []int32{ |
| | | 4, // 0: SendPurchaseInspectRequest.list:type_name -> QualityInspect |
| | | 5, // 0: SendPurchaseInspectRequest.list:type_name -> QualityInspect |
| | | 0, // 1: QualityInspect.inspect_type:type_name -> InspectType |
| | | 1, // 2: QualityInspect.material_type:type_name -> MaterialType |
| | | 2, // 3: QualityInspect.inspect_method:type_name -> InspectMethod |
| | | 4, // 4: GetInspectListResponse.List:type_name -> QualityInspect |
| | | 3, // 5: QualityInspectService.SendPurchaseInspect:input_type -> SendPurchaseInspectRequest |
| | | 6, // 6: QualityInspectService.GetInspectList:input_type -> GetInspectListRequest |
| | | 5, // 7: QualityInspectService.SendPurchaseInspect:output_type -> SendPurchaseInspectResponse |
| | | 7, // 8: QualityInspectService.GetInspectList:output_type -> GetInspectListResponse |
| | | 7, // [7:9] is the sub-list for method output_type |
| | | 5, // [5:7] is the sub-list for method input_type |
| | | 5, // [5:5] is the sub-list for extension type_name |
| | | 5, // [5:5] is the sub-list for extension extendee |
| | | 0, // [0:5] is the sub-list for field type_name |
| | | 3, // 4: QualityInspect.status:type_name -> InspectStatus |
| | | 5, // 5: GetInspectListResponse.List:type_name -> QualityInspect |
| | | 4, // 6: QualityInspectService.SendPurchaseInspect:input_type -> SendPurchaseInspectRequest |
| | | 7, // 7: QualityInspectService.GetInspectList:input_type -> GetInspectListRequest |
| | | 6, // 8: QualityInspectService.SendPurchaseInspect:output_type -> SendPurchaseInspectResponse |
| | | 8, // 9: QualityInspectService.GetInspectList:output_type -> GetInspectListResponse |
| | | 8, // [8:10] is the sub-list for method output_type |
| | | 6, // [6:8] is the sub-list for method input_type |
| | | 6, // [6:6] is the sub-list for extension type_name |
| | | 6, // [6:6] is the sub-list for extension extendee |
| | | 0, // [0:6] is the sub-list for field type_name |
| | | } |
| | | |
| | | func init() { file_quality_inspect_proto_init() } |
| | |
| | | File: protoimpl.DescBuilder{ |
| | | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), |
| | | RawDescriptor: file_quality_inspect_proto_rawDesc, |
| | | NumEnums: 3, |
| | | NumEnums: 4, |
| | | NumMessages: 5, |
| | | NumExtensions: 0, |
| | | NumServices: 1, |
| | |
| | | purchaseRouter.POST("purchaseType", PurchaseApi.SavePurchaseType) // 保存采购类型 |
| | | purchaseRouter.GET("purchaseTypeList", PurchaseApi.GetPurchaseTypeList) // 查询采购类型 |
| | | } |
| | | |
| | | qualityInspectRouter := Router.Group("purchase") |
| | | qualityInspectApi := purchase.QualityInspectApi{} |
| | | { |
| | | //qualityInspectRouter.GET("purchase/:id", qualityInspectApi.GetPurchase) // 获取单一采购单信息 |
| | | qualityInspectRouter.GET("qualityInspectList", qualityInspectApi.GetQualityInspectList) // 获取采购单列表 |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import ( |
| | | "context" |
| | | "errors" |
| | | "github.com/shopspring/decimal" |
| | | "github.com/spf13/cast" |
| | | "gorm.io/gorm" |
| | |
| | | //@param: params *purchaserequest.AddPurchase |
| | | //@return: err error |
| | | |
| | | func (slf *PurchaseService) CreatePurchase(params *purchase.Purchase, productList []*purchase.PurchaseProducts) (err error) { |
| | | func (slf *PurchaseService) CreatePurchase(record *purchase.Purchase, productList []*purchase.PurchaseProducts) (err error) { |
| | | err = DealPrice(record, productList) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | err = global.GVA_DB.Transaction(func(tx *gorm.DB) error { |
| | | var quantity decimal.Decimal |
| | | for _, product := range productList { |
| | | quantity = quantity.Add(product.Amount) |
| | | } |
| | | params.Quantity = quantity |
| | | err = tx.Create(¶ms).Error |
| | | err = tx.Create(&record).Error |
| | | if err != nil { |
| | | return err |
| | | } |
| | | for _, product := range productList { |
| | | product.PurchaseId = cast.ToInt(params.ID) |
| | | product.PurchaseId = cast.ToInt(record.ID) |
| | | } |
| | | return tx.Create(productList).Error |
| | | }) |
| | | |
| | | return err |
| | | } |
| | | |
| | | func DealPrice(record *purchase.Purchase, productList []*purchase.PurchaseProducts) error { |
| | | var quantity decimal.Decimal |
| | | var totalPrice decimal.Decimal |
| | | var realTotalPrice decimal.Decimal |
| | | for _, product := range productList { |
| | | quantity = quantity.Add(product.Amount) |
| | | totalPrice = totalPrice.Add(product.Price.Mul(product.Amount)) |
| | | } |
| | | record.Quantity = quantity |
| | | if !totalPrice.Equal(record.TotalPrice) { |
| | | return errors.New("价税总计计算错误") |
| | | } |
| | | realTotalPrice = record.CalcRealTotalPrice() |
| | | if !realTotalPrice.Equal(record.RealTotalPrice) { |
| | | return errors.New("最终价格计算错误") |
| | | } |
| | | record.UnInvoiceAmount = record.RealTotalPrice |
| | | record.ShouldPayAmount = record.RealTotalPrice |
| | | return nil |
| | | } |
| | | |
| | | //@function: DeletePurchase |
| | |
| | | //@return: err error |
| | | |
| | | func (slf *PurchaseService) UpdatePurchase(params *purchase.Purchase, productList []*purchase.PurchaseProducts) (err error) { |
| | | err = DealPrice(params, productList) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | err = global.GVA_DB.Transaction(func(tx *gorm.DB) error { |
| | | var quantity decimal.Decimal |
| | | for _, product := range productList { |
| | | quantity = quantity.Add(product.Amount) |
| | | } |
| | | params.Quantity = quantity |
| | | err = tx.Where("id = ?", params.ID).Updates(params).Error |
| | | if err != nil { |
| | | return err |
| | |
| | | Or("Product.name like ?", "%"+info.Keyword+"%"). |
| | | Or("supplier.name like ?", "%"+info.Keyword+"%") |
| | | } |
| | | var purchaseList []purchase.Purchase |
| | | var purchaseList []*purchase.Purchase |
| | | err = db.Count(&total).Error |
| | | if err != nil { |
| | | return purchaseList, total, err |
| | |
| | | func (slf *PurchaseService) GetPurchaseProductList(purchaseId uint) (list []*purchase.PurchaseProducts, err error) { |
| | | db := global.GVA_DB.Model(&purchase.PurchaseProducts{}) |
| | | list = make([]*purchase.PurchaseProducts, 0) |
| | | err = db.Where("purchase_id = ?", purchaseId).Find(&list).Error |
| | | err = db.Where("purchase_id = ?", purchaseId).Preload("Product").Find(&list).Error |
| | | return list, err |
| | | } |
| | | |
| | |
| | | continue |
| | | } |
| | | inspectOrder := &qualityinspect.QualityInspect{ |
| | | InspectType: qualityinspect.InspectType_InspectTypePurchase, |
| | | MaterialType: qualityinspect.MaterialType_MaterialTypeRaw, |
| | | MaterialName: product.Name, |
| | | MaterialId: product.Number, |
| | | MaterialTp: product.ModelNumber, |
| | | MaterialUnit: product.Unit, |
| | | Supplier: record.Supplier.Name, |
| | | WarehouseName: "采购总仓", |
| | | ReportAmount: productItem.Amount.InexactFloat64(), |
| | | InspectMethod: qualityinspect.InspectMethod_InspectMethodAll, |
| | | InspectAmount: productItem.Amount.InexactFloat64(), |
| | | InspectType: qualityinspect.InspectType_InspectTypePurchase, |
| | | MaterialType: qualityinspect.MaterialType_MaterialTypeRaw, |
| | | MaterialName: product.Name, |
| | | MaterialId: product.Number, |
| | | MaterialTp: product.ModelNumber, |
| | | MaterialUnit: product.Unit, |
| | | Supplier: record.Supplier.Name, |
| | | WarehouseName: "采购总仓", |
| | | ReportAmount: productItem.Amount.InexactFloat64(), |
| | | InspectMethod: qualityinspect.InspectMethod_InspectMethodAll, |
| | | InspectAmount: productItem.Amount.InexactFloat64(), |
| | | PurchaseOrderId: record.Number, |
| | | } |
| | | inspectOrders = append(inspectOrders, inspectOrder) |
| | | } |
| | | if len(inspectOrders) == 0 { |
| | | return nil |
| | | } |
| | | inspectRequest := qualityinspect.SendPurchaseInspectRequest{List: inspectOrders} |
| | | _, err = qualityinspect.NewQualityInspectServiceClient(qualityinspect.Conn).SendPurchaseInspect(context.Background(), &inspectRequest) |
| | |
| | | } |
| | | |
| | | func (slf *PurchaseService) SavePurchaseType(list []*purchase.PurchaseType) (err error) { |
| | | ids := make([]uint, 0) |
| | | newRecords := make([]*purchase.PurchaseType, 0) |
| | | for _, item := range list { |
| | | if item.ID != 0 { |
| | | ids = append(ids, item.ID) |
| | | } else { |
| | | newRecords = append(newRecords, item) |
| | | } |
| | | } |
| | | err = global.GVA_DB.Transaction(func(tx *gorm.DB) error { |
| | | err = tx.Where("1 = ?", 1).Delete(&purchase.PurchaseType{}).Error |
| | | err = tx.Where("id not in ?", ids).Delete(&purchase.PurchaseType{}).Error |
| | | if err != nil { |
| | | return err |
| | | } |
| | | for _, item := range list { |
| | | item.ID = 0 |
| | | if len(newRecords) > 0 { |
| | | err = tx.Create(newRecords).Error |
| | | if err != nil { |
| | | return err |
| | | } |
| | | } |
| | | return tx.Create(list).Error |
| | | |
| | | for _, item := range list { |
| | | if item.ID != 0 { |
| | | err = tx.Save(item).Error |
| | | if err != nil { |
| | | return err |
| | | } |
| | | } |
| | | } |
| | | return nil |
| | | }) |
| | | return err |
| | | } |
New file |
| | |
| | | package purchase |
| | | |
| | | // |
| | | //import ( |
| | | // "srm/global" |
| | | // "srm/model/common/request" |
| | | //) |
| | | // |
| | | //type QualityInspect struct{} |
| | | // |
| | | //func NewQualityInspect() *QualityInspect { |
| | | // return &QualityInspect{} |
| | | //} |
| | | // |
| | | ////@function: GetQualityInspect |
| | | ////@description: 获取采购单信息 |
| | | ////@param: id uint |
| | | ////@return: QualityInspect model.QualityInspect, err error |
| | | // |
| | | //func (slf *QualityInspect) GetQualityInspect(id uint) (QualityInspect QualityInspect.QualityInspect, err error) { |
| | | // err = global.GVA_DB.Where("id = ?", id).Preload("Supplier").First(&QualityInspect).Error |
| | | // return |
| | | //} |
| | | // |
| | | ////@function: GetQualityInspectList |
| | | ////@description: 分页获取采购单列表 |
| | | ////@param: info request.PageInfo |
| | | ////@return: list interface{}, total int64, err error |
| | | // |
| | | //func (slf *QualityInspect) GetQualityInspectList(info request.PageInfo) (list interface{}, total int64, err error) { |
| | | // limit := info.PageSize |
| | | // offset := info.PageSize * (info.Page - 1) |
| | | // db := global.GVA_DB.Model(&QualityInspect.QualityInspect{}) |
| | | // if info.Keyword != "" { |
| | | // db.Distinct("QualityInspects.id").Joins("left join QualityInspect_products on QualityInspect_products.QualityInspect_id = QualityInspects.id"). |
| | | // Joins("left join Product on Product.Id = QualityInspect_products.product_id"). |
| | | // Joins("left join supplier on supplier.Id = QualityInspects.supplier_id"). |
| | | // Where("QualityInspects.name like ?", "%"+info.Keyword+"%"). |
| | | // Or("Product.name like ?", "%"+info.Keyword+"%"). |
| | | // Or("supplier.name like ?", "%"+info.Keyword+"%") |
| | | // } |
| | | // var QualityInspectList []QualityInspect.QualityInspect |
| | | // err = db.Count(&total).Error |
| | | // if err != nil { |
| | | // return QualityInspectList, total, err |
| | | // } |
| | | // err = db.Limit(limit).Offset(offset).Find(&QualityInspectList).Error |
| | | // return QualityInspectList, total, err |
| | | //} |
| | | // |
| | | ////@function: GetQualityInspectProductList |
| | | ////@description: 分页获取采购单产品列表 |
| | | ////@param: QualityInspectId int |
| | | ////@return: list interface{}, err error |
| | | // |
| | | //func (slf *QualityInspect) GetQualityInspectProductList(QualityInspectId uint) (list []*QualityInspect.QualityInspectProducts, err error) { |
| | | // db := global.GVA_DB.Model(&QualityInspect.QualityInspectProducts{}) |
| | | // list = make([]*QualityInspect.QualityInspectProducts, 0) |
| | | // err = db.Where("QualityInspect_id = ?", QualityInspectId).Preload("Product").Find(&list).Error |
| | | // return list, err |
| | | //} |
New file |
| | |
| | | package utils |
| | | |
| | | import "encoding/json" |
| | | |
| | | func AssignTo(from interface{}, to interface{}) error { |
| | | data, err := json.Marshal(from) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | err = json.Unmarshal(data, to) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | return nil |
| | | } |