| | |
| | | return |
| | | } |
| | | |
| | | count, err := model.NewClientSearch(nil).SetNumber(params.Number).Count() |
| | | count, err := model.NewClientSearch(nil).SetNumber(client.Number).Count() |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败") |
| | | return |
| | |
| | | id, err = model.NewServiceOrderSearch().MaxAutoIncr() |
| | | case constvar.CodeStandardTypeServerFollow: |
| | | id, err = model.NewServiceFollowupSearch().MaxAutoIncr() |
| | | case constvar.CodeStandardTypeSaleInvoice: |
| | | id, err = model.NewInvoiceSearch().MaxAutoIncr() |
| | | default: |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码规则不存在") |
| | | return |
| | |
| | | ctx.Fail(ecode.ParamsErr) |
| | | return |
| | | } |
| | | count, err := model.NewInvoiceSearch().SetNumber(invoice.Number).Count() |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败") |
| | | return |
| | | } |
| | | if count > 0 { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码已存在") |
| | | return |
| | | } |
| | | |
| | | errCode := service.NewInvoiceService().AddInvoice(&invoice) |
| | | if errCode != ecode.OK { |
| | |
| | | salesRefundRes.Reason = salesRefund.Reason |
| | | salesRefundRes.Products = salesRefund.Products |
| | | salesRefundRes.SourceType = salesRefund.SourceType |
| | | salesRefundRes.SourceId = salesRefund.SourceId |
| | | salesRefundRes.SalesReturnId = salesRefund.SourceId |
| | | salesRefundRes.CodeStandID = salesRefund.CodeStandID |
| | | |
| | | return ecode.OK, salesRefundRes |
| | |
| | | return |
| | | } |
| | | |
| | | count, err := model.NewServiceOrderSearch().SetNumber(serviceOrder.Number).Count() |
| | | count, err := model.NewServiceOrderSearch().SetNumber(serviceOrder.ServiceNumber).Count() |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败") |
| | | return |
| | |
| | | "description": "客户id", |
| | | "type": "integer" |
| | | }, |
| | | "codeStandID": { |
| | | "type": "string" |
| | | }, |
| | | "courierCompany": { |
| | | "$ref": "#/definitions/model.CourierCompany" |
| | | }, |
| | |
| | | "invoiceTypeId": { |
| | | "description": "发票类型id", |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "principalId": { |
| | | "description": "销售负责人id", |
| | |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "quotation": { |
| | | "$ref": "#/definitions/model.Quotation" |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "Source": { |
| | | "$ref": "#/definitions/model.SalesReturn" |
| | | }, |
| | | "amountTotal": { |
| | | "description": "价税合计", |
| | | "type": "number" |
| | |
| | | "refundTypeId": { |
| | | "description": "退款方式ID", |
| | | "type": "integer" |
| | | }, |
| | | "salesReturn": { |
| | | "$ref": "#/definitions/model.SalesReturn" |
| | | }, |
| | | "sourceId": { |
| | | "description": "源单id", |
| | |
| | | "severity": { |
| | | "$ref": "#/definitions/model.Severity" |
| | | }, |
| | | "severityId": { |
| | | "description": "严重程度id", |
| | | "type": "integer" |
| | | }, |
| | | "solution": { |
| | | "description": "解决方法", |
| | | "type": "string" |
| | |
| | | "quotation_id": { |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "description": "发货时间s", |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | } |
| | |
| | | "description": "客户id", |
| | | "type": "integer" |
| | | }, |
| | | "codeStandID": { |
| | | "type": "string" |
| | | }, |
| | | "courierCompanyId": { |
| | | "description": "物流公司", |
| | | "type": "integer" |
| | |
| | | "invoiceTypeId": { |
| | | "description": "发票类型id", |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "description": "发票编号", |
| | | "type": "string" |
| | | }, |
| | | "principalId": { |
| | | "description": "销售负责人id", |
| | |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "description": "服务方式id", |
| | | "type": "integer" |
| | | }, |
| | | "severity": { |
| | | "severityId": { |
| | | "description": "严重程度id", |
| | | "type": "integer" |
| | | }, |
| | |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "quotation_id": { |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "description": "发货时间s", |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | } |
| | |
| | | "description": "客户id", |
| | | "type": "integer" |
| | | }, |
| | | "codeStandID": { |
| | | "type": "string" |
| | | }, |
| | | "courierCompanyId": { |
| | | "description": "物流公司", |
| | | "type": "integer" |
| | |
| | | "invoiceTypeId": { |
| | | "description": "发票类型id", |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "description": "发票编号", |
| | | "type": "string" |
| | | }, |
| | | "principalId": { |
| | | "description": "销售负责人id", |
| | |
| | | "description": "服务方式id", |
| | | "type": "integer" |
| | | }, |
| | | "severity": { |
| | | "severityId": { |
| | | "description": "严重程度id", |
| | | "type": "integer" |
| | | }, |
| | |
| | | "description": "客户id", |
| | | "type": "integer" |
| | | }, |
| | | "codeStandID": { |
| | | "type": "string" |
| | | }, |
| | | "courierCompany": { |
| | | "$ref": "#/definitions/model.CourierCompany" |
| | | }, |
| | |
| | | "invoiceTypeId": { |
| | | "description": "发票类型id", |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "principalId": { |
| | | "description": "销售负责人id", |
| | |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "quotation": { |
| | | "$ref": "#/definitions/model.Quotation" |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "Source": { |
| | | "$ref": "#/definitions/model.SalesReturn" |
| | | }, |
| | | "amountTotal": { |
| | | "description": "价税合计", |
| | | "type": "number" |
| | |
| | | "refundTypeId": { |
| | | "description": "退款方式ID", |
| | | "type": "integer" |
| | | }, |
| | | "salesReturn": { |
| | | "$ref": "#/definitions/model.SalesReturn" |
| | | }, |
| | | "sourceId": { |
| | | "description": "源单id", |
| | |
| | | "severity": { |
| | | "$ref": "#/definitions/model.Severity" |
| | | }, |
| | | "severityId": { |
| | | "description": "严重程度id", |
| | | "type": "integer" |
| | | }, |
| | | "solution": { |
| | | "description": "解决方法", |
| | | "type": "string" |
| | |
| | | "quotation_id": { |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "description": "发货时间s", |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | } |
| | |
| | | "description": "客户id", |
| | | "type": "integer" |
| | | }, |
| | | "codeStandID": { |
| | | "type": "string" |
| | | }, |
| | | "courierCompanyId": { |
| | | "description": "物流公司", |
| | | "type": "integer" |
| | |
| | | "invoiceTypeId": { |
| | | "description": "发票类型id", |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "description": "发票编号", |
| | | "type": "string" |
| | | }, |
| | | "principalId": { |
| | | "description": "销售负责人id", |
| | |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "description": "服务方式id", |
| | | "type": "integer" |
| | | }, |
| | | "severity": { |
| | | "severityId": { |
| | | "description": "严重程度id", |
| | | "type": "integer" |
| | | }, |
| | |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "remark": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "quotation_id": { |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "description": "发货时间s", |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | } |
| | |
| | | "description": "客户id", |
| | | "type": "integer" |
| | | }, |
| | | "codeStandID": { |
| | | "type": "string" |
| | | }, |
| | | "courierCompanyId": { |
| | | "description": "物流公司", |
| | | "type": "integer" |
| | |
| | | "invoiceTypeId": { |
| | | "description": "发票类型id", |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "description": "发票编号", |
| | | "type": "string" |
| | | }, |
| | | "principalId": { |
| | | "description": "销售负责人id", |
| | |
| | | "description": "服务方式id", |
| | | "type": "integer" |
| | | }, |
| | | "severity": { |
| | | "severityId": { |
| | | "description": "严重程度id", |
| | | "type": "integer" |
| | | }, |
| | |
| | | clientId: |
| | | description: 客户id |
| | | type: integer |
| | | codeStandID: |
| | | type: string |
| | | courierCompany: |
| | | $ref: '#/definitions/model.CourierCompany' |
| | | courierCompanyId: |
| | |
| | | invoiceTypeId: |
| | | description: 发票类型id |
| | | type: integer |
| | | number: |
| | | type: string |
| | | principalId: |
| | | description: 销售负责人id |
| | | type: integer |
| | |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | quotation: |
| | | $ref: '#/definitions/model.Quotation' |
| | | quotationId: |
| | | type: integer |
| | | remark: |
| | | type: string |
| | | saleChance: |
| | |
| | | allOf: |
| | | - $ref: '#/definitions/model.RefundType' |
| | | description: 退款方式 |
| | | Source: |
| | | $ref: '#/definitions/model.SalesReturn' |
| | | amountTotal: |
| | | description: 价税合计 |
| | | type: number |
| | |
| | | refundTypeId: |
| | | description: 退款方式ID |
| | | type: integer |
| | | salesReturn: |
| | | $ref: '#/definitions/model.SalesReturn' |
| | | sourceId: |
| | | description: 源单id |
| | | type: integer |
| | |
| | | type: integer |
| | | severity: |
| | | $ref: '#/definitions/model.Severity' |
| | | severityId: |
| | | description: 严重程度id |
| | | type: integer |
| | | solution: |
| | | description: 解决方法 |
| | | type: string |
| | |
| | | type: string |
| | | quotation_id: |
| | | type: integer |
| | | sendTime: |
| | | description: 发货时间s |
| | | type: string |
| | | status_id: |
| | | type: integer |
| | | type: object |
| | |
| | | clientId: |
| | | description: 客户id |
| | | type: integer |
| | | codeStandID: |
| | | type: string |
| | | courierCompanyId: |
| | | description: 物流公司 |
| | | type: integer |
| | |
| | | invoiceTypeId: |
| | | description: 发票类型id |
| | | type: integer |
| | | number: |
| | | description: 发票编号 |
| | | type: string |
| | | principalId: |
| | | description: 销售负责人id |
| | | type: integer |
| | |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | quotationId: |
| | | type: integer |
| | | remark: |
| | | type: string |
| | | saleChanceId: |
| | |
| | | serviceTypeId: |
| | | description: 服务方式id |
| | | type: integer |
| | | severity: |
| | | severityId: |
| | | description: 严重程度id |
| | | type: integer |
| | | solution: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | quotationId: |
| | | type: integer |
| | | remark: |
| | | type: string |
| | | saleChanceId: |
| | |
| | | type: string |
| | | quotation_id: |
| | | type: integer |
| | | sendTime: |
| | | description: 发货时间s |
| | | type: string |
| | | status_id: |
| | | type: integer |
| | | type: object |
| | |
| | | clientId: |
| | | description: 客户id |
| | | type: integer |
| | | codeStandID: |
| | | type: string |
| | | courierCompanyId: |
| | | description: 物流公司 |
| | | type: integer |
| | |
| | | invoiceTypeId: |
| | | description: 发票类型id |
| | | type: integer |
| | | number: |
| | | description: 发票编号 |
| | | type: string |
| | | principalId: |
| | | description: 销售负责人id |
| | | type: integer |
| | |
| | | serviceTypeId: |
| | | description: 服务方式id |
| | | type: integer |
| | | severity: |
| | | severityId: |
| | | description: 严重程度id |
| | | type: integer |
| | | solution: |
| | |
| | | if slf.Name != "" { |
| | | db.Where("name = ?", slf.Name) |
| | | } |
| | | if slf.Number != "" { |
| | | db.Where("number = ?", slf.Number) |
| | | } |
| | | |
| | | if len(slf.SearchMap) > 0 { |
| | | for key, value := range slf.SearchMap { |
| | |
| | | File string `json:"file" gorm:"column:file;type:varchar(255);comment:合同文件"` |
| | | CreatedAt *CustomTime `json:"created_at" gorm:"column:created_at;type:datetime;comment:创建时间"` |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | //SendTime string `json:"sendTime" gorm:"column:send_time;type:varchar(255);comment:发货时间"` |
| | | gormModel |
| | | } |
| | | |
| | |
| | | // Invoice 销售发票 |
| | | Invoice struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:发票编号"` |
| | | ClientId int `gorm:"client_id" json:"clientId"` // 客户id |
| | | Client Client `gorm:"foreignKey:ClientId"` |
| | | InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 发票类型id |
| | |
| | | CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 物流公司 |
| | | CourierCompany CourierCompany `gorm:"foreignKey:CourierCompanyId"` |
| | | Products []*Product `json:"products" gorm:"many2many:invoice_product;"` |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | } |
| | | |
| | | // InvoiceSearch 销售发票搜索条件 |
| | |
| | | if slf.SourceId > 0 { |
| | | db = db.Where("source_id = ?", slf.SourceId) |
| | | } |
| | | if slf.Number != "" { |
| | | db.Where("number = ?", slf.Number) |
| | | } |
| | | |
| | | return db |
| | | } |
| | |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *InvoiceSearch) Count() (int64, error) { |
| | | var db = slf.build() |
| | | var total int64 |
| | | err := db.Count(&total).Error |
| | | return total, err |
| | | } |
| | | |
| | | func (slf *InvoiceSearch) MaxAutoIncr() (int, error) { |
| | | type Result struct { |
| | | Max int |
| | | } |
| | | |
| | | var ( |
| | | result Result |
| | | db = slf.build() |
| | | ) |
| | | |
| | | err := db.Select("MAX(id) as max").Scan(&result).Error |
| | | if err != nil { |
| | | return result.Max, fmt.Errorf("max err: %v", err) |
| | | } |
| | | return result.Max, nil |
| | | } |
| | | |
| | | func (slf *InvoiceSearch) SetNumber(number string) *InvoiceSearch { |
| | | slf.Number = number |
| | | return slf |
| | | } |
| | | |
| | | func (slf *InvoiceSearch) SetId(id int) *InvoiceSearch { |
| | | slf.Id = id |
| | | return slf |
| | |
| | | StatusId int `json:"status_id"` |
| | | File string `json:"file"` |
| | | CodeStandID string `json:"codeStandID"` //编码id |
| | | SendTime string `json:"sendTime"` //发货时间s |
| | | } |
| | | |
| | | type UpdateContract struct { |
| | |
| | | ) |
| | | |
| | | type AddInvoice struct { |
| | | ClientId int `gorm:"client_id" json:"clientId"` // 客户id |
| | | InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 发票类型id |
| | | PrincipalId int `gorm:"principal_id" json:"principalId"` // 销售负责人id |
| | | Subject string `gorm:"subject" json:"subject"` // 主题 |
| | | InvoiceStatusId int `gorm:"invoice_status_id" json:"invoiceStatusId"` // 发票状态id |
| | | SourceType constvar.InvoiceSourceType `gorm:"source_type" json:"sourceType"` // 源单类型(1销售明细单2服务合同) |
| | | SourceId int `gorm:"source_id" json:"sourceId"` // 源单id |
| | | TaxpayerIdNumber string `gorm:"taxpayer_id_number" json:"taxpayerIdNumber"` // 纳税识别号 |
| | | InvoiceNumber string `gorm:"invoice_number" json:"invoiceNumber"` // 发票号码 |
| | | InvoiceDate string `gorm:"invoice_date" json:"invoiceDate"` // 开票日期 |
| | | CourierNumber string `gorm:"courier_number" json:"courierNumber"` // 物流单号 |
| | | CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 物流公司 |
| | | Products []model.Product `json:"products"` //发票对应产品,从相应源单里获取 |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:发票编号"` //发票编号 |
| | | ClientId int `gorm:"client_id" json:"clientId"` // 客户id |
| | | InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 发票类型id |
| | | PrincipalId int `gorm:"principal_id" json:"principalId"` // 销售负责人id |
| | | Subject string `gorm:"subject" json:"subject"` // 主题 |
| | | InvoiceStatusId int `gorm:"invoice_status_id" json:"invoiceStatusId"` // 发票状态id |
| | | SourceType constvar.InvoiceSourceType `gorm:"source_type" json:"sourceType"` // 源单类型(1销售明细单2服务合同) |
| | | SourceId int `gorm:"source_id" json:"sourceId"` // 源单id |
| | | TaxpayerIdNumber string `gorm:"taxpayer_id_number" json:"taxpayerIdNumber"` // 纳税识别号 |
| | | InvoiceNumber string `gorm:"invoice_number" json:"invoiceNumber"` // 发票号码 |
| | | InvoiceDate string `gorm:"invoice_date" json:"invoiceDate"` // 开票日期 |
| | | CourierNumber string `gorm:"courier_number" json:"courierNumber"` // 物流单号 |
| | | CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 物流公司 |
| | | Products []model.Product `json:"products"` //发票对应产品,从相应源单里获取 |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | } |
| | | |
| | | type UpdateInvoice struct { |
| | | Id int `json:"id" binding:"required"` |
| | | ClientId int `gorm:"client_id" json:"clientId"` // 客户id |
| | | InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 发票类型id |
| | | PrincipalId int `gorm:"principal_id" json:"principalId"` // 销售负责人id |
| | | Subject string `gorm:"subject" json:"subject"` // 主题 |
| | | InvoiceStatusId int `gorm:"invoice_status_id" json:"invoiceStatusId"` // 发票状态id |
| | | SourceType int `gorm:"source_type" json:"sourceType"` // 源单类型(1销售明细单2服务合同) |
| | | SourceId int `gorm:"source_id" json:"sourceId"` // 源单id |
| | | TaxpayerIdNumber string `gorm:"taxpayer_id_number" json:"taxpayerIdNumber"` // 纳税识别号 |
| | | InvoiceNumber string `gorm:"invoice_number" json:"invoiceNumber"` // 发票号码 |
| | | InvoiceDate int `gorm:"invoice_date" json:"invoiceDate"` // 开票日期 |
| | | CourierNumber string `gorm:"courier_number" json:"courierNumber"` // 物流单号 |
| | | CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 物流公司 |
| | | Products []model.Product `json:"products"` //发票对应产品,从相应源单里获取 |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:发票编号"` //发票编号 |
| | | ClientId int `gorm:"client_id" json:"clientId"` // 客户id |
| | | InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 发票类型id |
| | | PrincipalId int `gorm:"principal_id" json:"principalId"` // 销售负责人id |
| | | Subject string `gorm:"subject" json:"subject"` // 主题 |
| | | InvoiceStatusId int `gorm:"invoice_status_id" json:"invoiceStatusId"` // 发票状态id |
| | | SourceType int `gorm:"source_type" json:"sourceType"` // 源单类型(1销售明细单2服务合同) |
| | | SourceId int `gorm:"source_id" json:"sourceId"` // 源单id |
| | | TaxpayerIdNumber string `gorm:"taxpayer_id_number" json:"taxpayerIdNumber"` // 纳税识别号 |
| | | InvoiceNumber string `gorm:"invoice_number" json:"invoiceNumber"` // 发票号码 |
| | | InvoiceDate int `gorm:"invoice_date" json:"invoiceDate"` // 开票日期 |
| | | CourierNumber string `gorm:"courier_number" json:"courierNumber"` // 物流单号 |
| | | CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 物流公司 |
| | | Products []model.Product `json:"products"` //发票对应产品,从相应源单里获取 |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | } |
| | | |
| | | type GetInvoiceList struct { |
| | |
| | | LogisticCost float64 `json:"logisticCost" gorm:"column:logistic_cost;type:decimal(10,2);comment:物流费用"` |
| | | CodeStandID string `json:"codeStandID"` //编码id |
| | | DeliverType int `json:"deliverType"` //交付类型:1.一次发货,2.多次发货 |
| | | QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"` |
| | | } |
| | | |
| | | type UpdateSalesDetails struct { |
| | |
| | | AppointmentTime string `gorm:"appointment_time" json:"appointmentTime"` // 预约上门时间 |
| | | SaleChanceId int `gorm:"sale_leads" json:"saleChanceId"` // 销售机会id |
| | | FaultTypeId int `gorm:"severity_id" json:"faultTypeId"` // 故障类别id |
| | | SeverityId int `gorm:"severity_id" json:"severity"` // 严重程度id |
| | | SeverityId int `gorm:"severity_id" json:"severityId"` // 严重程度id |
| | | ServiceOrderStatusId int `gorm:"column:service_order_status_id;type:int;not null;default:0;comment:服务单状态id" json:"serviceOrderStatusId"` // 处理状态 |
| | | ExpectTime string `gorm:"expect_time" json:"expectTime"` // 希望处理时间 |
| | | RealTime string `gorm:"real_time" json:"realTime"` // 实际处理时间 |
| | |
| | | AmountTotal decimal.Decimal `gorm:"column:amount_total;type:decimal(12,2);comment:价税合计" json:"amountTotal"` // 价税合计 |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | DeliverType int `json:"deliverType" gorm:"column:deliver_type;type:int;comment:交付类型(1.一次发货,2.多次发货)"` |
| | | QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"` |
| | | Quotation Quotation `json:"quotation" gorm:"foreignKey:QuotationId"` |
| | | CrmModel |
| | | } |
| | | |
| | |
| | | Preload("Member"). |
| | | Preload("SaleChance"). |
| | | Preload("WechatOrderStatus"). |
| | | Preload("Client") |
| | | Preload("Client"). |
| | | Preload("Quotation") |
| | | } |
| | | |
| | | return db |
| | |
| | | Client Client `json:"client" gorm:"foreignKey:ClientId"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:退款单号"` |
| | | SourceType constvar.RefundSourceType `gorm:"column:source_type;type:int;not null;default 0;comment:来源类型(1销售退货)" json:"sourceType"` // 来源类型(1销售退货) |
| | | SourceId int `gorm:"column:source_id;type:int;not null;default 0;comment:源单id " json:"sourceId"` // 源单id |
| | | Source SalesReturn `gorm:"foreignKey:SourceId" json:"Source"` |
| | | SalesReturnId int `gorm:"column:source_id;type:int;not null;default 0;comment:源单id " json:"sourceId"` // 源单id |
| | | SalesReturn SalesReturn `gorm:"foreignKey:SalesReturnId" json:"salesReturn"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | Member User `json:"member" gorm:"foreignKey:MemberId"` |
| | | RefundDate string `json:"refundDate" gorm:"column:refund_date;type:varchar(255);comment:退款日期"` |
| | |
| | | db = db.Where("source_type = ?", slf.SourceType) |
| | | } |
| | | |
| | | if slf.SourceId != 0 { |
| | | db = db.Where("source_id = ?", slf.SourceId) |
| | | if slf.SalesReturnId != 0 { |
| | | db = db.Where("source_id = ?", slf.SalesReturnId) |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Preload("Client"). |
| | | Preload("PaymentType"). |
| | | Preload("BankAccount"). |
| | | Preload("Source"). |
| | | Preload("Products") |
| | | Preload("Products"). |
| | | Preload("SalesReturn") |
| | | } |
| | | if slf.KeywordType != "" { |
| | | switch slf.KeywordType { |
| | |
| | | } |
| | | |
| | | func (slf *SalesRefundSearch) SetSourceId(id int) *SalesRefundSearch { |
| | | slf.SourceId = id |
| | | slf.SalesReturnId = id |
| | | return slf |
| | | } |
| | | |
| | |
| | | SaleChance SaleChance `gorm:"foreignKey:SaleChanceId"` |
| | | FaultTypeId int `gorm:"column:severity_id;type:int;not null;default:0;comment:故障类别id" json:"faultTypeId"` // 故障类别id |
| | | FaultType FaultType `gorm:"foreignKey:FaultTypeId"` |
| | | SeverityId int `gorm:"column:severity_id;type:int;not null;default:0;comment:严重程度id" json:"severity"` // 严重程度id |
| | | SeverityId int `gorm:"column:severity_order_id;type:int;not null;default:0;comment:严重程度id" json:"severityId"` // 严重程度id |
| | | Severity Severity `gorm:"foreignKey:SeverityId"` |
| | | ServiceOrderStatusId int `gorm:"column:service_order_status_id;type:int;not null;default:0;comment:服务单状态id" json:"serviceOrderStatusId"` // 处理状态 |
| | | ServiceOrderStatus ServiceOrderStatus `gorm:"foreignKey:ServiceOrderStatusId"` |
| | |
| | | if len(slf.ServiceManIds) > 0 { |
| | | db = db.Where("service_man_id in ?", slf.ServiceManIds) |
| | | } |
| | | if slf.Number != "" { |
| | | db = db.Where("number = ?", slf.Number) |
| | | if slf.ServiceNumber != "" { |
| | | db = db.Where("service_number = ?", slf.ServiceNumber) |
| | | } |
| | | |
| | | return db |
| | |
| | | } |
| | | |
| | | func (slf *ServiceOrderSearch) SetNumber(number string) *ServiceOrderSearch { |
| | | slf.Number = number |
| | | slf.ServiceNumber = number |
| | | return slf |
| | | } |
| | | |
| | |
| | | ) |
| | | |
| | | func (Severity) TableName() string { |
| | | return "severity" |
| | | return "severity_order" |
| | | } |
| | | |
| | | func NewSeveritySearch() *SeveritySearch { |
| | |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | } else if invoice.SourceType == constvar.InvoiceSourceTypeServiceContract { //更新销售明细已开票金额 |
| | | } else if invoice.SourceType == constvar.InvoiceSourceTypeSaleDetail { //更新销售明细已开票金额 |
| | | salesDetails, err := model.NewSalesDetailsSearch().SetId(invoice.SourceId).SetPreload(true).First() |
| | | if err != nil { |
| | | return ecode.DBErr |
| | |
| | | type SalesRefundService struct{} |
| | | |
| | | func (SalesRefundService) AddSalesRefund(salesRefund *model.SalesRefund) int { |
| | | salesReturnRecord, err := model.NewSalesReturnSearch().SetId(salesRefund.SourceId).SetPreload(true).First() |
| | | salesReturnRecord, err := model.NewSalesReturnSearch().SetId(salesRefund.SalesReturnId).SetPreload(true).First() |
| | | if err != nil { |
| | | return ecode.SalesReturnNotExist |
| | | } |
| | |
| | | return errors.New("退货产品对应总价超出应退总价") |
| | | } |
| | | salesReturnRecord.AmountShouldRefund = salesReturnRecord.AmountTotal.Sub(salesReturnRecord.AmountHasRefund).Round(2) |
| | | err = model.NewSalesReturnSearch().SetId(salesRefund.SourceId).Update(salesReturnRecord) |
| | | err = model.NewSalesReturnSearch().SetId(salesRefund.SalesReturnId).Update(salesReturnRecord) |
| | | if err != nil { |
| | | code = ecode.DBErr |
| | | return err |
| | |
| | | if err != nil { |
| | | return ecode.SalesRefundNotExist |
| | | } |
| | | salesReturnRecord, err := model.NewSalesReturnSearch().SetId(refund.SourceId).SetPreload(true).First() |
| | | salesReturnRecord, err := model.NewSalesReturnSearch().SetId(refund.SalesReturnId).SetPreload(true).First() |
| | | if err != nil { |
| | | return ecode.SalesReturnNotExist |
| | | } |
| | |
| | | } |
| | | salesReturnRecord.AmountHasRefund = salesReturnRecord.AmountHasRefund.Sub(amount).Round(2) |
| | | salesReturnRecord.AmountShouldRefund = salesReturnRecord.AmountTotal.Sub(salesReturnRecord.AmountHasRefund).Round(2) |
| | | err = model.NewSalesReturnSearch().SetId(refund.SourceId).Update(salesReturnRecord) |
| | | err = model.NewSalesReturnSearch().SetId(refund.SalesReturnId).Update(salesReturnRecord) |
| | | if err != nil { |
| | | return err |
| | | } |
| | |
| | | return ecode.SalesRefundNotExist |
| | | } |
| | | |
| | | salesReturnRecord, err := model.NewSalesReturnSearch().SetId(salesRefund.SourceId).SetPreload(true).First() |
| | | salesReturnRecord, err := model.NewSalesReturnSearch().SetId(salesRefund.SalesReturnId).SetPreload(true).First() |
| | | if err != nil { |
| | | return ecode.SalesReturnNotExist |
| | | } |
| | |
| | | return errors.New("退货产品对应总价超出应退总价") |
| | | } |
| | | |
| | | err = model.NewSalesReturnSearch().SetId(salesRefund.SourceId).Update(salesReturnRecord) |
| | | err = model.NewSalesReturnSearch().SetId(salesRefund.SalesReturnId).Update(salesReturnRecord) |
| | | if err != nil { |
| | | code = ecode.DBErr |
| | | return err |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesRefundService) GetSalesRefundList(page, pageSize int, keywordType constvar.SalesRefundKeywordType, keyword string, sourceId int, memberIds []int) ([]*model.SalesRefund, int64, int) { |
| | | func (SalesRefundService) GetSalesRefundList(page, pageSize int, keywordType constvar.SalesRefundKeywordType, keyword string, sourceId int, memberIds []int) ([]*model.SalesRefund, int64, int) { |
| | | // get contact list |
| | | contacts, total, err := model.NewSalesRefundSearch(). |
| | | SetKeywordType(keywordType). |