liujiandao
2023-10-24 d8c708a30d938ceb87348257add9dc10926044df
编码规则需求功能开发2
21个文件已修改
307 ■■■■ 已修改文件
api/v1/client.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/code.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/invoice.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesRefund.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceOrder.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/client.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/contract.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/invoice.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/contract.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/invoice.go 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/salesDetails.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/serviceOrder.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesDetails.go 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesRefund.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceOrder.go 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/severity.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/invoice.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/salesRefund.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/client.go
@@ -41,7 +41,7 @@
        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
api/v1/code.go
@@ -122,6 +122,8 @@
        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
api/v1/invoice.go
@@ -34,6 +34,15 @@
        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 {
api/v1/salesRefund.go
@@ -160,7 +160,7 @@
    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
api/v1/serviceOrder.go
@@ -42,7 +42,7 @@
        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
docs/docs.go
@@ -11351,6 +11351,9 @@
                    "description": "客户id",
                    "type": "integer"
                },
                "codeStandID": {
                    "type": "string"
                },
                "courierCompany": {
                    "$ref": "#/definitions/model.CourierCompany"
                },
@@ -11386,6 +11389,9 @@
                "invoiceTypeId": {
                    "description": "发票类型id",
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "principalId": {
                    "description": "销售负责人id",
@@ -12205,6 +12211,12 @@
                        "$ref": "#/definitions/model.Product"
                    }
                },
                "quotation": {
                    "$ref": "#/definitions/model.Quotation"
                },
                "quotationId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
@@ -12322,9 +12334,6 @@
                        }
                    ]
                },
                "Source": {
                    "$ref": "#/definitions/model.SalesReturn"
                },
                "amountTotal": {
                    "description": "价税合计",
                    "type": "number"
@@ -12388,6 +12397,9 @@
                "refundTypeId": {
                    "description": "退款方式ID",
                    "type": "integer"
                },
                "salesReturn": {
                    "$ref": "#/definitions/model.SalesReturn"
                },
                "sourceId": {
                    "description": "源单id",
@@ -13007,6 +13019,10 @@
                "severity": {
                    "$ref": "#/definitions/model.Severity"
                },
                "severityId": {
                    "description": "严重程度id",
                    "type": "integer"
                },
                "solution": {
                    "description": "解决方法",
                    "type": "string"
@@ -13561,6 +13577,10 @@
                "quotation_id": {
                    "type": "integer"
                },
                "sendTime": {
                    "description": "发货时间s",
                    "type": "string"
                },
                "status_id": {
                    "type": "integer"
                }
@@ -13701,6 +13721,9 @@
                    "description": "客户id",
                    "type": "integer"
                },
                "codeStandID": {
                    "type": "string"
                },
                "courierCompanyId": {
                    "description": "物流公司",
                    "type": "integer"
@@ -13724,6 +13747,10 @@
                "invoiceTypeId": {
                    "description": "发票类型id",
                    "type": "integer"
                },
                "number": {
                    "description": "发票编号",
                    "type": "string"
                },
                "principalId": {
                    "description": "销售负责人id",
@@ -14330,6 +14357,9 @@
                        "$ref": "#/definitions/model.Product"
                    }
                },
                "quotationId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
@@ -14815,7 +14845,7 @@
                    "description": "服务方式id",
                    "type": "integer"
                },
                "severity": {
                "severityId": {
                    "description": "严重程度id",
                    "type": "integer"
                },
@@ -15890,6 +15920,9 @@
                        "$ref": "#/definitions/model.Product"
                    }
                },
                "quotationId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
@@ -16481,6 +16514,10 @@
                "quotation_id": {
                    "type": "integer"
                },
                "sendTime": {
                    "description": "发货时间s",
                    "type": "string"
                },
                "status_id": {
                    "type": "integer"
                }
@@ -16718,6 +16755,9 @@
                    "description": "客户id",
                    "type": "integer"
                },
                "codeStandID": {
                    "type": "string"
                },
                "courierCompanyId": {
                    "description": "物流公司",
                    "type": "integer"
@@ -16744,6 +16784,10 @@
                "invoiceTypeId": {
                    "description": "发票类型id",
                    "type": "integer"
                },
                "number": {
                    "description": "发票编号",
                    "type": "string"
                },
                "principalId": {
                    "description": "销售负责人id",
@@ -18196,7 +18240,7 @@
                    "description": "服务方式id",
                    "type": "integer"
                },
                "severity": {
                "severityId": {
                    "description": "严重程度id",
                    "type": "integer"
                },
docs/swagger.json
@@ -11339,6 +11339,9 @@
                    "description": "客户id",
                    "type": "integer"
                },
                "codeStandID": {
                    "type": "string"
                },
                "courierCompany": {
                    "$ref": "#/definitions/model.CourierCompany"
                },
@@ -11374,6 +11377,9 @@
                "invoiceTypeId": {
                    "description": "发票类型id",
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "principalId": {
                    "description": "销售负责人id",
@@ -12193,6 +12199,12 @@
                        "$ref": "#/definitions/model.Product"
                    }
                },
                "quotation": {
                    "$ref": "#/definitions/model.Quotation"
                },
                "quotationId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
@@ -12310,9 +12322,6 @@
                        }
                    ]
                },
                "Source": {
                    "$ref": "#/definitions/model.SalesReturn"
                },
                "amountTotal": {
                    "description": "价税合计",
                    "type": "number"
@@ -12376,6 +12385,9 @@
                "refundTypeId": {
                    "description": "退款方式ID",
                    "type": "integer"
                },
                "salesReturn": {
                    "$ref": "#/definitions/model.SalesReturn"
                },
                "sourceId": {
                    "description": "源单id",
@@ -12995,6 +13007,10 @@
                "severity": {
                    "$ref": "#/definitions/model.Severity"
                },
                "severityId": {
                    "description": "严重程度id",
                    "type": "integer"
                },
                "solution": {
                    "description": "解决方法",
                    "type": "string"
@@ -13549,6 +13565,10 @@
                "quotation_id": {
                    "type": "integer"
                },
                "sendTime": {
                    "description": "发货时间s",
                    "type": "string"
                },
                "status_id": {
                    "type": "integer"
                }
@@ -13689,6 +13709,9 @@
                    "description": "客户id",
                    "type": "integer"
                },
                "codeStandID": {
                    "type": "string"
                },
                "courierCompanyId": {
                    "description": "物流公司",
                    "type": "integer"
@@ -13712,6 +13735,10 @@
                "invoiceTypeId": {
                    "description": "发票类型id",
                    "type": "integer"
                },
                "number": {
                    "description": "发票编号",
                    "type": "string"
                },
                "principalId": {
                    "description": "销售负责人id",
@@ -14318,6 +14345,9 @@
                        "$ref": "#/definitions/model.Product"
                    }
                },
                "quotationId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
@@ -14803,7 +14833,7 @@
                    "description": "服务方式id",
                    "type": "integer"
                },
                "severity": {
                "severityId": {
                    "description": "严重程度id",
                    "type": "integer"
                },
@@ -15878,6 +15908,9 @@
                        "$ref": "#/definitions/model.Product"
                    }
                },
                "quotationId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
@@ -16469,6 +16502,10 @@
                "quotation_id": {
                    "type": "integer"
                },
                "sendTime": {
                    "description": "发货时间s",
                    "type": "string"
                },
                "status_id": {
                    "type": "integer"
                }
@@ -16706,6 +16743,9 @@
                    "description": "客户id",
                    "type": "integer"
                },
                "codeStandID": {
                    "type": "string"
                },
                "courierCompanyId": {
                    "description": "物流公司",
                    "type": "integer"
@@ -16732,6 +16772,10 @@
                "invoiceTypeId": {
                    "description": "发票类型id",
                    "type": "integer"
                },
                "number": {
                    "description": "发票编号",
                    "type": "string"
                },
                "principalId": {
                    "description": "销售负责人id",
@@ -18184,7 +18228,7 @@
                    "description": "服务方式id",
                    "type": "integer"
                },
                "severity": {
                "severityId": {
                    "description": "严重程度id",
                    "type": "integer"
                },
docs/swagger.yaml
@@ -895,6 +895,8 @@
      clientId:
        description: 客户id
        type: integer
      codeStandID:
        type: string
      courierCompany:
        $ref: '#/definitions/model.CourierCompany'
      courierCompanyId:
@@ -921,6 +923,8 @@
      invoiceTypeId:
        description: 发票类型id
        type: integer
      number:
        type: string
      principalId:
        description: 销售负责人id
        type: integer
@@ -1457,6 +1461,10 @@
        items:
          $ref: '#/definitions/model.Product'
        type: array
      quotation:
        $ref: '#/definitions/model.Quotation'
      quotationId:
        type: integer
      remark:
        type: string
      saleChance:
@@ -1533,8 +1541,6 @@
        allOf:
        - $ref: '#/definitions/model.RefundType'
        description: 退款方式
      Source:
        $ref: '#/definitions/model.SalesReturn'
      amountTotal:
        description: 价税合计
        type: number
@@ -1579,6 +1585,8 @@
      refundTypeId:
        description: 退款方式ID
        type: integer
      salesReturn:
        $ref: '#/definitions/model.SalesReturn'
      sourceId:
        description: 源单id
        type: integer
@@ -1996,6 +2004,9 @@
        type: integer
      severity:
        $ref: '#/definitions/model.Severity'
      severityId:
        description: 严重程度id
        type: integer
      solution:
        description: 解决方法
        type: string
@@ -2378,6 +2389,9 @@
        type: string
      quotation_id:
        type: integer
      sendTime:
        description: 发货时间s
        type: string
      status_id:
        type: integer
    type: object
@@ -2468,6 +2482,8 @@
      clientId:
        description: 客户id
        type: integer
      codeStandID:
        type: string
      courierCompanyId:
        description: 物流公司
        type: integer
@@ -2486,6 +2502,9 @@
      invoiceTypeId:
        description: 发票类型id
        type: integer
      number:
        description: 发票编号
        type: string
      principalId:
        description: 销售负责人id
        type: integer
@@ -2883,6 +2902,8 @@
        items:
          $ref: '#/definitions/model.Product'
        type: array
      quotationId:
        type: integer
      remark:
        type: string
      saleChanceId:
@@ -3221,7 +3242,7 @@
      serviceTypeId:
        description: 服务方式id
        type: integer
      severity:
      severityId:
        description: 严重程度id
        type: integer
      solution:
@@ -3975,6 +3996,8 @@
        items:
          $ref: '#/definitions/model.Product'
        type: array
      quotationId:
        type: integer
      remark:
        type: string
      saleChanceId:
@@ -4381,6 +4404,9 @@
        type: string
      quotation_id:
        type: integer
      sendTime:
        description: 发货时间s
        type: string
      status_id:
        type: integer
    type: object
@@ -4534,6 +4560,8 @@
      clientId:
        description: 客户id
        type: integer
      codeStandID:
        type: string
      courierCompanyId:
        description: 物流公司
        type: integer
@@ -4554,6 +4582,9 @@
      invoiceTypeId:
        description: 发票类型id
        type: integer
      number:
        description: 发票编号
        type: string
      principalId:
        description: 销售负责人id
        type: integer
@@ -5533,7 +5564,7 @@
      serviceTypeId:
        description: 服务方式id
        type: integer
      severity:
      severityId:
        description: 严重程度id
        type: integer
      solution:
model/client.go
@@ -71,6 +71,9 @@
    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 {
model/contract.go
@@ -22,6 +22,7 @@
        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
    }
model/invoice.go
@@ -12,6 +12,7 @@
    // 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
@@ -29,6 +30,7 @@
        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 销售发票搜索条件
@@ -76,6 +78,9 @@
    if slf.SourceId > 0 {
        db = db.Where("source_id = ?", slf.SourceId)
    }
    if slf.Number != "" {
        db.Where("number = ?", slf.Number)
    }
    return db
}
@@ -107,6 +112,35 @@
    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
model/request/contract.go
@@ -13,6 +13,7 @@
    StatusId     int    `json:"status_id"`
    File         string `json:"file"`
    CodeStandID  string `json:"codeStandID"` //编码id
    SendTime     string `json:"sendTime"`    //发货时间s
}
type UpdateContract struct {
model/request/invoice.go
@@ -6,36 +6,40 @@
)
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 {
model/request/salesDetails.go
@@ -29,6 +29,7 @@
    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 {
model/request/serviceOrder.go
@@ -20,7 +20,7 @@
    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"`                                                                              // 实际处理时间
model/salesDetails.go
@@ -41,6 +41,8 @@
        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
    }
@@ -107,7 +109,8 @@
            Preload("Member").
            Preload("SaleChance").
            Preload("WechatOrderStatus").
            Preload("Client")
            Preload("Client").
            Preload("Quotation")
    }
    return db
model/salesRefund.go
@@ -16,8 +16,8 @@
        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:退款日期"`
@@ -78,16 +78,16 @@
        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 {
@@ -212,7 +212,7 @@
}
func (slf *SalesRefundSearch) SetSourceId(id int) *SalesRefundSearch {
    slf.SourceId = id
    slf.SalesReturnId = id
    return slf
}
model/serviceOrder.go
@@ -38,7 +38,7 @@
        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"`
@@ -134,8 +134,8 @@
    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
@@ -220,7 +220,7 @@
}
func (slf *ServiceOrderSearch) SetNumber(number string) *ServiceOrderSearch {
    slf.Number = number
    slf.ServiceNumber = number
    return slf
}
model/severity.go
@@ -29,7 +29,7 @@
)
func (Severity) TableName() string {
    return "severity"
    return "severity_order"
}
func NewSeveritySearch() *SeveritySearch {
service/invoice.go
@@ -43,7 +43,7 @@
        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
service/salesRefund.go
@@ -12,7 +12,7 @@
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
    }
@@ -37,7 +37,7 @@
            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
@@ -73,7 +73,7 @@
    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
    }
@@ -90,7 +90,7 @@
        }
        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
        }
@@ -120,7 +120,7 @@
        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
    }
@@ -153,7 +153,7 @@
            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
@@ -168,7 +168,7 @@
    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).