add
SalesDetails 销售明细单
add, Delete, update, list
| | |
| | | QuotationApi |
| | | MasterOrderApi |
| | | SubOrderApi |
| | | SalesDetailsApi |
| | | } |
| | | |
| | | var ApiGroup = new(Group) |
| | |
| | | quotationService = service.ServiceGroup.QuotationService |
| | | masterOrderService = service.ServiceGroup.MasterOrderService |
| | | subOrderService = service.ServiceGroup.SubOrderService |
| | | salesDetailsService = service.ServiceGroup.SalesDetailsService |
| | | ) |
New file |
| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | ) |
| | | |
| | | type SalesDetailsApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags SalesDetails |
| | | // @Summary 添加销售明细 |
| | | // @Produce application/json |
| | | // @Param object body request.AddSalesDetails true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/salesDetails/add [post] |
| | | func (s *SalesDetailsApi) Add(c *gin.Context) { |
| | | var params request.AddSalesDetails |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode, salesDetails := checkSalesDetailsParams(params.SalesDetails) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | errCode = salesDetailsService.AddSalesDetails(&salesDetails) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags SalesDetails |
| | | // @Summary 删除销售明细 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/salesDetails/delete/{id} [delete] |
| | | func (s *SalesDetailsApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := salesDetailsService.DeleteSalesDetails(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags SalesDetails |
| | | // @Summary 更新销售明细 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateSalesDetails true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/salesDetails/update [put] |
| | | func (s *SalesDetailsApi) Update(c *gin.Context) { |
| | | var params request.UpdateSalesDetails |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode, salesDetails := checkSalesDetailsParams(params.SalesDetails) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | errCode = salesDetailsService.UpdateSalesDetails(&salesDetails) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags SalesDetails |
| | | // @Summary 获取销售明细列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.SalesDetailsResponse} |
| | | // @Router /api/salesDetails/list [get] |
| | | func (s *SalesDetailsApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | list, errCode := salesDetailsService.GetSalesDetailsList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.SalesDetailsResponse{ |
| | | List: list, |
| | | }) |
| | | } |
| | | |
| | | func checkSalesDetailsParams(salesDetails request.SalesDetails) (errCode int, salesDetailsModel model.SalesDetails) { |
| | | if salesDetails.ClientId == 0 { |
| | | return ecode.InvalidParams, salesDetailsModel |
| | | } |
| | | |
| | | if salesDetails.Number == "" { |
| | | return ecode.InvalidParams, salesDetailsModel |
| | | } |
| | | |
| | | if salesDetails.MemberId == 0 { |
| | | return ecode.InvalidParams, salesDetailsModel |
| | | } |
| | | |
| | | if salesDetails.SignTime == "" { |
| | | return ecode.InvalidParams, salesDetailsModel |
| | | } |
| | | |
| | | t, err := checkTimeFormat(salesDetails.SignTime) |
| | | if err != nil { |
| | | return ecode.InvalidParams, salesDetailsModel |
| | | } |
| | | |
| | | t, err = checkTimeFormat(salesDetails.DeliveryDate) |
| | | if err != nil { |
| | | return ecode.InvalidParams, salesDetailsModel |
| | | } |
| | | |
| | | salesDetailsModel.ClientId = salesDetails.ClientId |
| | | salesDetailsModel.Number = salesDetails.Number |
| | | salesDetailsModel.SaleChanceId = salesDetails.SaleChanceId |
| | | salesDetailsModel.SaleType = salesDetails.SaleType |
| | | salesDetailsModel.SignTime = t |
| | | salesDetailsModel.MemberId = salesDetails.MemberId |
| | | salesDetailsModel.DeliveryDate = t |
| | | salesDetailsModel.WechatOrderStatus = salesDetails.WechatOrderStatus |
| | | salesDetailsModel.Address = salesDetails.Address |
| | | salesDetailsModel.Phone = salesDetails.Phone |
| | | salesDetailsModel.Remark = salesDetails.Remark |
| | | salesDetailsModel.Addressee = salesDetails.Addressee |
| | | salesDetailsModel.Conditions = salesDetails.Conditions |
| | | salesDetailsModel.Products = salesDetails.Products |
| | | |
| | | return ecode.OK, salesDetailsModel |
| | | } |
| | |
| | | // @Tags SubOrder |
| | | // @Summary 获取子订单列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Success 200 {object} contextx.Response{data=response.SubOrderResponse} |
| | | // @Router /api/subOrder/list [get] |
| | | func (s *SubOrderApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "添加销售明细", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSalesDetails" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "删除销售明细", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "获取销售明细列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SalesDetailsResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "更新销售明细", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSalesDetails" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SubOrderResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.SalesDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | | "address": { |
| | | "type": "string" |
| | | }, |
| | | "addressee": { |
| | | "type": "string" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "conditions": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryDate": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "phone": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "saleType": { |
| | | "type": "integer" |
| | | }, |
| | | "signTime": { |
| | | "type": "string" |
| | | }, |
| | | "wechatOrderStatus": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.SalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SubOrder": { |
| | | "type": "object", |
| | | "properties": { |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "masterOrderId": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSalesDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | | "salesDetails": { |
| | | "$ref": "#/definitions/request.SalesDetails" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "userName": { |
| | | "type": "string", |
| | | "example": "用户名" |
| | | } |
| | | } |
| | | }, |
| | | "request.SalesDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | | "address": { |
| | | "type": "string" |
| | | }, |
| | | "addressee": { |
| | | "type": "string" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "conditions": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryDate": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "phone": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "saleType": { |
| | | "type": "integer" |
| | | }, |
| | | "signTime": { |
| | | "type": "string" |
| | | }, |
| | | "wechatOrderStatus": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSalesDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "salesDetails": { |
| | | "$ref": "#/definitions/request.SalesDetails" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesDetailsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SalesDetails" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesLeadsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SubOrderResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SubOrder" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.UserResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "添加销售明细", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSalesDetails" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "删除销售明细", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "获取销售明细列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SalesDetailsResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesDetails/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesDetails" |
| | | ], |
| | | "summary": "更新销售明细", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSalesDetails" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SubOrderResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.SalesDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | | "address": { |
| | | "type": "string" |
| | | }, |
| | | "addressee": { |
| | | "type": "string" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "conditions": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryDate": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "phone": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "saleType": { |
| | | "type": "integer" |
| | | }, |
| | | "signTime": { |
| | | "type": "string" |
| | | }, |
| | | "wechatOrderStatus": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.SalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SubOrder": { |
| | | "type": "object", |
| | | "properties": { |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "masterOrderId": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSalesDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | | "salesDetails": { |
| | | "$ref": "#/definitions/request.SalesDetails" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "userName": { |
| | | "type": "string", |
| | | "example": "用户名" |
| | | } |
| | | } |
| | | }, |
| | | "request.SalesDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | | "address": { |
| | | "type": "string" |
| | | }, |
| | | "addressee": { |
| | | "type": "string" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "conditions": { |
| | | "type": "string" |
| | | }, |
| | | "deliveryDate": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "phone": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "saleType": { |
| | | "type": "integer" |
| | | }, |
| | | "signTime": { |
| | | "type": "string" |
| | | }, |
| | | "wechatOrderStatus": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSalesDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "salesDetails": { |
| | | "$ref": "#/definitions/request.SalesDetails" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesDetailsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SalesDetails" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesLeadsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SubOrderResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SubOrder" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.UserResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.SalesDetails: |
| | | properties: |
| | | address: |
| | | type: string |
| | | addressee: |
| | | type: string |
| | | clientId: |
| | | type: integer |
| | | conditions: |
| | | type: string |
| | | deliveryDate: |
| | | type: string |
| | | id: |
| | | type: integer |
| | | memberId: |
| | | type: integer |
| | | number: |
| | | type: string |
| | | phone: |
| | | type: string |
| | | products: |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | remark: |
| | | type: string |
| | | saleChanceId: |
| | | type: integer |
| | | saleType: |
| | | type: integer |
| | | signTime: |
| | | type: string |
| | | wechatOrderStatus: |
| | | type: integer |
| | | type: object |
| | | model.SalesLeads: |
| | | properties: |
| | | city: |
| | |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.SubOrder: |
| | | properties: |
| | | clientId: |
| | | type: integer |
| | | id: |
| | | type: integer |
| | | masterOrderId: |
| | | type: integer |
| | | memberId: |
| | | type: integer |
| | | number: |
| | | type: string |
| | | products: |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | type: object |
| | | model.User: |
| | | properties: |
| | |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddSalesDetails: |
| | | properties: |
| | | salesDetails: |
| | | $ref: '#/definitions/request.SalesDetails' |
| | | type: object |
| | | request.AddSalesLeads: |
| | | properties: |
| | | city_id: |
| | |
| | | userName: |
| | | example: 用户名 |
| | | type: string |
| | | type: object |
| | | request.SalesDetails: |
| | | properties: |
| | | address: |
| | | type: string |
| | | addressee: |
| | | type: string |
| | | clientId: |
| | | type: integer |
| | | conditions: |
| | | type: string |
| | | deliveryDate: |
| | | type: string |
| | | id: |
| | | type: integer |
| | | memberId: |
| | | type: integer |
| | | number: |
| | | type: string |
| | | phone: |
| | | type: string |
| | | products: |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | remark: |
| | | type: string |
| | | saleChanceId: |
| | | type: integer |
| | | saleType: |
| | | type: integer |
| | | signTime: |
| | | type: string |
| | | wechatOrderStatus: |
| | | type: integer |
| | | type: object |
| | | request.SetCity: |
| | | properties: |
| | |
| | | required: |
| | | - sale_types |
| | | type: object |
| | | request.UpdateSalesDetails: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | salesDetails: |
| | | $ref: '#/definitions/request.SalesDetails' |
| | | type: object |
| | | request.UpdateSalesLeads: |
| | | properties: |
| | | city_id: |
| | |
| | | $ref: '#/definitions/model.SaleType' |
| | | type: array |
| | | type: object |
| | | response.SalesDetailsResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SalesDetails' |
| | | type: array |
| | | type: object |
| | | response.SalesLeadsResponse: |
| | | properties: |
| | | list: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SalesSources' |
| | | type: array |
| | | type: object |
| | | response.SubOrderResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SubOrder' |
| | | type: array |
| | | type: object |
| | | response.UserResponse: |
| | |
| | | summary: 更新销售类型 |
| | | tags: |
| | | - SaleType |
| | | /api/salesDetails/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddSalesDetails' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加销售明细 |
| | | tags: |
| | | - SalesDetails |
| | | /api/salesDetails/delete/{id}: |
| | | delete: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 删除销售明细 |
| | | tags: |
| | | - SalesDetails |
| | | /api/salesDetails/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.SalesDetailsResponse' |
| | | type: object |
| | | summary: 获取销售明细列表 |
| | | tags: |
| | | - SalesDetails |
| | | /api/salesDetails/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateSalesDetails' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新销售明细 |
| | | tags: |
| | | - SalesDetails |
| | | /api/salesLeads/add: |
| | | post: |
| | | parameters: |
| | |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.SubOrderResponse' |
| | | type: object |
| | | summary: 获取子订单列表 |
| | | tags: |
| | | - SubOrder |
| | |
| | | MasterOrder{}, |
| | | SubOrder{}, |
| | | Product{}, |
| | | SalesDetails{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package request |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | ) |
| | | |
| | | type AddSalesDetails struct { |
| | | SalesDetails SalesDetails `json:"salesDetails"` |
| | | } |
| | | |
| | | type SalesDetails struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售子单号"` |
| | | SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` |
| | | SaleType int `json:"saleType" gorm:"column:sale_type;type:int;comment:销售类型"` |
| | | SignTime string `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签单时间"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | DeliveryDate string `json:"deliveryDate" gorm:"column:delivery_date;type:datetime;comment:交货日期"` |
| | | WechatOrderStatus int `json:"wechatOrderStatus" gorm:"column:wechat_order_status;type:int;comment:微信订单状态"` |
| | | Address string `json:"address" gorm:"column:address;type:varchar(255);comment:地址"` |
| | | Phone string `json:"phone" gorm:"column:phone;type:varchar(255);comment:电话"` |
| | | Addressee string `json:"addressee" gorm:"column:addressee;type:varchar(255);comment:收件人"` |
| | | Conditions string `json:"conditions" gorm:"column:conditions;type:text;comment:条件"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | Products []model.Product `json:"products" gorm:"many2many:salesDetails_product;"` |
| | | } |
| | | |
| | | type UpdateSalesDetails struct { |
| | | Id int `json:"id"` |
| | | SalesDetails SalesDetails `json:"salesDetails"` |
| | | } |
| | |
| | | SubOrderResponse struct { |
| | | List []*model.SubOrder `json:"list"` |
| | | } |
| | | |
| | | SalesDetailsResponse struct { |
| | | List []*model.SalesDetails `json:"list"` |
| | | } |
| | | ) |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | | SalesDetails struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售子单号"` |
| | | SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` |
| | | SaleType int `json:"saleType" gorm:"column:sale_type;type:int;comment:销售类型"` |
| | | SignTime time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签单时间"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | DeliveryDate time.Time `json:"deliveryDate" gorm:"column:delivery_date;type:datetime;comment:交货日期"` |
| | | WechatOrderStatus int `json:"wechatOrderStatus" gorm:"column:wechat_order_status;type:int;comment:微信订单状态"` |
| | | Address string `json:"address" gorm:"column:address;type:varchar(255);comment:地址"` |
| | | Phone string `json:"phone" gorm:"column:phone;type:varchar(255);comment:电话"` |
| | | Addressee string `json:"addressee" gorm:"column:addressee;type:varchar(255);comment:收件人"` |
| | | Conditions string `json:"conditions" gorm:"column:conditions;type:text;comment:条件"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | Products []Product `json:"products" gorm:"many2many:salesDetails_product;"` |
| | | } |
| | | |
| | | SalesDetailsSearch struct { |
| | | SalesDetails |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (SalesDetails) TableName() string { |
| | | return "sales_details" |
| | | } |
| | | |
| | | func NewSalesDetailsSearch() *SalesDetailsSearch { |
| | | return &SalesDetailsSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&SalesDetails{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) Create(record *SalesDetails) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&SalesDetails{}).Error |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) Update(record *SalesDetails) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) SetId(id int) *SalesDetailsSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) Find() (*SalesDetails, error) { |
| | | var db = slf.build() |
| | | var record = new(SalesDetails) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) FindAll() ([]*SalesDetails, error) { |
| | | var db = slf.build() |
| | | var records = make([]*SalesDetails, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | |
| | | SubOrderUpdateErr = 2700005 // 更新子订单失败 |
| | | SubOrderDeleteErr = 2700006 // 删除子订单失败 |
| | | |
| | | SalesDetailsExist = 2800001 // 销售明细已存在 |
| | | SalesDetailsNotExist = 2800002 // 销售明细不存在 |
| | | SalesDetailsListErr = 2800003 // 获取销售明细列表失败 |
| | | SalesDetailsSetErr = 2800004 // 设置销售明细失败 |
| | | SalesDetailsUpdateErr = 2800005 // 更新销售明细失败 |
| | | SalesDetailsDeleteErr = 2800006 // 删除销售明细失败 |
| | | |
| | | ) |
| | |
| | | QuotationRouter |
| | | MasterOrderRouter |
| | | SubOrderRouter |
| | | SalesDetailsRouter |
| | | } |
| | | |
| | | func InitRouter() *gin.Engine { |
| | |
| | | routerGroup.InitQuotationRouter(PrivateGroup) // 注册quotation路由 |
| | | routerGroup.InitMasterOrderRouter(PrivateGroup) // 注册masterOrder路由 |
| | | routerGroup.InitSubOrderRouter(PrivateGroup) // 注册subOrder路由 |
| | | routerGroup.InitSalesDetailsRouter(PrivateGroup) // 注册salesDetails路由 |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type SalesDetailsRouter struct{} |
| | | |
| | | func (s *SalesDetailsRouter) InitSalesDetailsRouter(router *gin.RouterGroup) { |
| | | salesDetailsRouter := router.Group("salesDetails") |
| | | salesDetailsApi := v1.ApiGroup.SalesDetailsApi |
| | | { |
| | | salesDetailsRouter.POST("add", salesDetailsApi.Add) // 添加销售明细 |
| | | salesDetailsRouter.DELETE("delete/:id", salesDetailsApi.Delete) // 删除销售明细 |
| | | salesDetailsRouter.PUT("update", salesDetailsApi.Update) // 更新销售明细 |
| | | salesDetailsRouter.GET("list", salesDetailsApi.List) // 获取销售明细列表 |
| | | } |
| | | } |
| | |
| | | QuotationService |
| | | MasterOrderService |
| | | SubOrderService |
| | | SalesDetailsService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type SalesDetailsService struct{} |
| | | |
| | | func (SalesDetailsService) AddSalesDetails(salesDetails *model.SalesDetails) int { |
| | | err := model.NewSalesDetailsSearch().Create(salesDetails) |
| | | if err != nil { |
| | | return ecode.SalesDetailsExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesDetailsService) DeleteSalesDetails(id int) int { |
| | | _, err := model.NewSalesDetailsSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.SalesDetailsNotExist |
| | | } |
| | | |
| | | err = model.NewSalesDetailsSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.SalesDetailsNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesDetailsService) GetSalesDetailsList() ([]*model.SalesDetails, int) { |
| | | list, err := model.NewSalesDetailsSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.SalesDetailsListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (SalesDetailsService) UpdateSalesDetails(salesDetails *model.SalesDetails) int { |
| | | // check salesDetails exist |
| | | _, err := model.NewSalesDetailsSearch().SetId(salesDetails.Id).Find() |
| | | if err != nil { |
| | | return ecode.SalesDetailsNotExist |
| | | } |
| | | |
| | | err = model.NewSalesDetailsSearch().SetId(salesDetails.Id).Update(salesDetails) |
| | | if err != nil { |
| | | return ecode.SalesDetailsSetErr |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |