| | |
| | | ctx.OkWithDetailed(storeList) |
| | | } |
| | | |
| | | // ConfirmOutput |
| | | // @Tags SalesDetails |
| | | // @Summary 确认发货 |
| | | // @Produce application/json |
| | | // @Param object body request.ConfirmOutput true "明细编码" |
| | | // @Success 200 {object} response.ListResponse |
| | | // @Router /api/salesDetails/confirmOutput [post] |
| | | func (s *SalesDetailsApi) ConfirmOutput(c *gin.Context) { |
| | | var params request.ConfirmOutput |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | if len(params.Products) == 0 || params.SaleDetailNumber == "" { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "参数缺失") |
| | | return |
| | | } |
| | | var flag bool |
| | | for _, p := range params.Products { |
| | | if p.OutputAmount.GreaterThan(decimal.Zero) { |
| | | flag = true |
| | | } |
| | | } |
| | | if !flag { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "发货数量缺失") |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(nil) |
| | | } |
| | | |
| | | // GetDeliveryList |
| | | // @Tags SalesDetails |
| | | // @Summary 发货明细 |
| | |
| | | ) |
| | | |
| | | func (s SalesDetailsStatus) Valid() bool { |
| | | return s == WaitConfirmed || s == WaitOutbound || s == OverOutbound || s == OverCLose |
| | | return s == WaitConfirmed || s == WaitOutbound || s == OverOutbound || s == OverCLose || s == WaitDecompose || s == InStock |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/confirmOutput": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "确认发货", |
| | | "parameters": [ |
| | | { |
| | | "description": "明细编码", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.ConfirmOutput" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/response.ListResponse" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/delete": { |
| | | "delete": { |
| | | "produces": [ |
| | |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "获取产品发货信息", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "明细编码", |
| | | "name": "number", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/response.ListResponse" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/getSalesDetailsProductInfo/{number}": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "获取销售明细产品信息", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.ConfirmOutput": { |
| | | "type": "object", |
| | | "properties": { |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.ConfirmOutputProducts" |
| | | } |
| | | }, |
| | | "saleDetailNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.ConfirmOutputProducts": { |
| | | "type": "object", |
| | | "properties": { |
| | | "number": { |
| | | "description": "产品编号", |
| | | "type": "string" |
| | | }, |
| | | "outputAmount": { |
| | | "description": "本次发货数量", |
| | | "type": "number" |
| | | } |
| | | } |
| | | }, |
| | | "request.Contact": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/response.OutsourcingInfo" |
| | | } |
| | | }, |
| | | "productInfo": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/response.SalesDetailsProductInfo" |
| | | } |
| | | }, |
| | | "purchaseInfo": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesDetailsProductInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "订单数量", |
| | | "type": "number" |
| | | }, |
| | | "cost": { |
| | | "description": "产品成本", |
| | | "type": "string" |
| | | }, |
| | | "deliveryAmount": { |
| | | "description": "发货数量", |
| | | "type": "integer" |
| | | }, |
| | | "finishAmount": { |
| | | "description": "完成数量", |
| | | "type": "integer" |
| | | }, |
| | | "makeAmount": { |
| | | "description": "制造数量", |
| | | "type": "integer" |
| | | }, |
| | | "makeFinishAmount": { |
| | | "description": "制造完成数量", |
| | | "type": "integer" |
| | | }, |
| | | "margin": { |
| | | "description": "毛利率", |
| | | "type": "string" |
| | | }, |
| | | "outsourcingAmount": { |
| | | "description": "委外数量", |
| | | "type": "integer" |
| | | }, |
| | | "outsourcingFinishAmount": { |
| | | "description": "委外完成数量", |
| | | "type": "integer" |
| | | }, |
| | | "price": { |
| | | "description": "产品价格", |
| | | "type": "number" |
| | | }, |
| | | "productId": { |
| | | "type": "string" |
| | | }, |
| | | "productName": { |
| | | "type": "string" |
| | | }, |
| | | "profit": { |
| | | "description": "毛利", |
| | | "type": "string" |
| | | }, |
| | | "purchaseAmount": { |
| | | "description": "采购数量", |
| | | "type": "integer" |
| | | }, |
| | | "purchaseFinishAmount": { |
| | | "description": "采购完成数量", |
| | | "type": "integer" |
| | | }, |
| | | "specs": { |
| | | "description": "物料规格", |
| | | "type": "string" |
| | | }, |
| | | "total": { |
| | | "description": "产品总价", |
| | | "type": "number" |
| | | }, |
| | | "unit": { |
| | | "description": "单位", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesDetailsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/confirmOutput": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "确认发货", |
| | | "parameters": [ |
| | | { |
| | | "description": "明细编码", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.ConfirmOutput" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/response.ListResponse" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/delete": { |
| | | "delete": { |
| | | "produces": [ |
| | |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "获取产品发货信息", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "明细编码", |
| | | "name": "number", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/response.ListResponse" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/getSalesDetailsProductInfo/{number}": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "获取销售明细产品信息", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.ConfirmOutput": { |
| | | "type": "object", |
| | | "properties": { |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.ConfirmOutputProducts" |
| | | } |
| | | }, |
| | | "saleDetailNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.ConfirmOutputProducts": { |
| | | "type": "object", |
| | | "properties": { |
| | | "number": { |
| | | "description": "产品编号", |
| | | "type": "string" |
| | | }, |
| | | "outputAmount": { |
| | | "description": "本次发货数量", |
| | | "type": "number" |
| | | } |
| | | } |
| | | }, |
| | | "request.Contact": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/response.OutsourcingInfo" |
| | | } |
| | | }, |
| | | "productInfo": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/response.SalesDetailsProductInfo" |
| | | } |
| | | }, |
| | | "purchaseInfo": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesDetailsProductInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "订单数量", |
| | | "type": "number" |
| | | }, |
| | | "cost": { |
| | | "description": "产品成本", |
| | | "type": "string" |
| | | }, |
| | | "deliveryAmount": { |
| | | "description": "发货数量", |
| | | "type": "integer" |
| | | }, |
| | | "finishAmount": { |
| | | "description": "完成数量", |
| | | "type": "integer" |
| | | }, |
| | | "makeAmount": { |
| | | "description": "制造数量", |
| | | "type": "integer" |
| | | }, |
| | | "makeFinishAmount": { |
| | | "description": "制造完成数量", |
| | | "type": "integer" |
| | | }, |
| | | "margin": { |
| | | "description": "毛利率", |
| | | "type": "string" |
| | | }, |
| | | "outsourcingAmount": { |
| | | "description": "委外数量", |
| | | "type": "integer" |
| | | }, |
| | | "outsourcingFinishAmount": { |
| | | "description": "委外完成数量", |
| | | "type": "integer" |
| | | }, |
| | | "price": { |
| | | "description": "产品价格", |
| | | "type": "number" |
| | | }, |
| | | "productId": { |
| | | "type": "string" |
| | | }, |
| | | "productName": { |
| | | "type": "string" |
| | | }, |
| | | "profit": { |
| | | "description": "毛利", |
| | | "type": "string" |
| | | }, |
| | | "purchaseAmount": { |
| | | "description": "采购数量", |
| | | "type": "integer" |
| | | }, |
| | | "purchaseFinishAmount": { |
| | | "description": "采购完成数量", |
| | | "type": "integer" |
| | | }, |
| | | "specs": { |
| | | "description": "物料规格", |
| | | "type": "string" |
| | | }, |
| | | "total": { |
| | | "description": "产品总价", |
| | | "type": "number" |
| | | }, |
| | | "unit": { |
| | | "description": "单位", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesDetailsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | required: |
| | | - ids |
| | | type: object |
| | | request.ConfirmOutput: |
| | | properties: |
| | | products: |
| | | items: |
| | | $ref: '#/definitions/request.ConfirmOutputProducts' |
| | | type: array |
| | | saleDetailNumber: |
| | | type: string |
| | | type: object |
| | | request.ConfirmOutputProducts: |
| | | properties: |
| | | number: |
| | | description: 产品编号 |
| | | type: string |
| | | outputAmount: |
| | | description: 本次发货数量 |
| | | type: number |
| | | type: object |
| | | request.Contact: |
| | | properties: |
| | | birthday: |
| | |
| | | items: |
| | | $ref: '#/definitions/response.OutsourcingInfo' |
| | | type: array |
| | | productInfo: |
| | | items: |
| | | $ref: '#/definitions/response.SalesDetailsProductInfo' |
| | | type: array |
| | | purchaseInfo: |
| | | items: |
| | | $ref: '#/definitions/response.Purchase' |
| | |
| | | items: |
| | | $ref: '#/definitions/model.SaleType' |
| | | type: array |
| | | type: object |
| | | response.SalesDetailsProductInfo: |
| | | properties: |
| | | amount: |
| | | description: 订单数量 |
| | | type: number |
| | | cost: |
| | | description: 产品成本 |
| | | type: string |
| | | deliveryAmount: |
| | | description: 发货数量 |
| | | type: integer |
| | | finishAmount: |
| | | description: 完成数量 |
| | | type: integer |
| | | makeAmount: |
| | | description: 制造数量 |
| | | type: integer |
| | | makeFinishAmount: |
| | | description: 制造完成数量 |
| | | type: integer |
| | | margin: |
| | | description: 毛利率 |
| | | type: string |
| | | outsourcingAmount: |
| | | description: 委外数量 |
| | | type: integer |
| | | outsourcingFinishAmount: |
| | | description: 委外完成数量 |
| | | type: integer |
| | | price: |
| | | description: 产品价格 |
| | | type: number |
| | | productId: |
| | | type: string |
| | | productName: |
| | | type: string |
| | | profit: |
| | | description: 毛利 |
| | | type: string |
| | | purchaseAmount: |
| | | description: 采购数量 |
| | | type: integer |
| | | purchaseFinishAmount: |
| | | description: 采购完成数量 |
| | | type: integer |
| | | specs: |
| | | description: 物料规格 |
| | | type: string |
| | | total: |
| | | description: 产品总价 |
| | | type: number |
| | | unit: |
| | | description: 单位 |
| | | type: string |
| | | type: object |
| | | response.SalesDetailsResponse: |
| | | properties: |
| | |
| | | summary: 添加销售明细 |
| | | tags: |
| | | - SalesDetails |
| | | /api/salesDetails/confirmOutput: |
| | | post: |
| | | parameters: |
| | | - description: 明细编码 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.ConfirmOutput' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/response.ListResponse' |
| | | summary: 确认发货 |
| | | tags: |
| | | - SalesDetails |
| | | /api/salesDetails/delete: |
| | | delete: |
| | | parameters: |
| | |
| | | schema: |
| | | $ref: '#/definitions/response.ListResponse' |
| | | summary: 获取产品发货信息 |
| | | tags: |
| | | - SalesDetails |
| | | /api/salesDetails/getSalesDetailsProductInfo/{number}: |
| | | get: |
| | | parameters: |
| | | - description: 明细编码 |
| | | in: path |
| | | name: number |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/response.ListResponse' |
| | | summary: 获取销售明细产品信息 |
| | | tags: |
| | | - SalesDetails |
| | | /api/salesDetails/list: |
| | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "github.com/shopspring/decimal" |
| | | ) |
| | | |
| | | type AddSalesDetails struct { |
| | |
| | | ClientId int `json:"clientId"` //客户id |
| | | Number string `json:"number"` //销售明细单号 |
| | | } |
| | | |
| | | // ConfirmOutput 发货 |
| | | type ConfirmOutput struct { |
| | | SaleDetailNumber string `json:"saleDetailNumber"` |
| | | Products []ConfirmOutputProducts `json:"products"` |
| | | } |
| | | |
| | | type ConfirmOutputProducts struct { |
| | | Number string `json:"number"` //产品编号 |
| | | OutputAmount decimal.Decimal `json:"outputAmount"` //本次发货数量 |
| | | } |
| | |
| | | AvailableNumber string `json:"availableNumber"` //可用库存 |
| | | } |
| | | type OutputInfo struct { |
| | | Number string `json:"number"` |
| | | Name string `json:"name"` |
| | | Number string `json:"number"` //产品编码 |
| | | Name string `json:"name"` //产品名称 |
| | | OrderAmount string `json:"orderAmount"` //订单数量 |
| | | Unit string `json:"unit"` |
| | | Invoice string `json:"invoice"` //发货单 |
| | | Carrier string `json:"carrier"` //承运商 |
| | | Waybill string `json:"waybill"` //运单号 |
| | | SalePrice string `json:"salePrice"` //销售单价 |
| | | Valorem string `json:"valorem"` //价税合计 |
| | | Warehouse string `json:"warehouse"` |
| | | Amount string `json:"amount"` //在库数量 |
| | | Status int `json:"status"` //0就绪 1完成 |
| | | Specs string `json:"specs"` //规格 |
| | | CreateTime string `json:"createTime"` //创建时间 |
| | | Unit string `json:"unit"` //单位 |
| | | Invoice string `json:"invoice"` //发货单 |
| | | Carrier string `json:"carrier"` //承运商 |
| | | Waybill string `json:"waybill"` //运单号 |
| | | SalePrice string `json:"salePrice"` //销售单价 |
| | | Valorem string `json:"valorem"` //价税合计 |
| | | Warehouse string `json:"warehouse"` //仓库名称 |
| | | Amount string `json:"amount"` //发货数量 |
| | | Status int `json:"status"` //0就绪 1完成 |
| | | Specs string `json:"specs"` //规格 |
| | | CreateTime string `json:"createTime"` //创建时间 |
| | | } |
| | | |
| | | type StoreInfo struct { |
| | |
| | | |
| | | salesDetailsRouter.POST("getDeliveryPrepareInfo", salesDetailsApi.GetDeliveryPrepareInfo) // 发货准备 |
| | | salesDetailsRouter.POST("getDeliveryList", salesDetailsApi.GetDeliveryList) // 发货明细 |
| | | salesDetailsRouter.POST("confirmOutput", salesDetailsApi.ConfirmOutput) // 确认发货 |
| | | |
| | | } |
| | | } |
| | |
| | | return model.NewSalesDetailsSearch().SetId(saleDetailID).SetPreload(true).First() |
| | | } |
| | | |
| | | func (SalesDetailsService) GetSalesDetailsByNumber(number string) (*model.SalesDetails, error) { |
| | | return model.NewSalesDetailsSearch().SetNumber(number).SetPreload(true).First() |
| | | } |
| | | |
| | | func (SalesDetailsService) GetDeliveryOrder(saleDetailID int) ([]*model.DeliveryOrder, error) { |
| | | // get contact list |
| | | orders, err := model.NewDeliveryOrderSearch().SetSalesDetailsID(saleDetailID).FindAll() |