liujiandao
2023-10-13 5fa1de02759b9646e8987312736699755990e960
bug修改
20个文件已修改
161 ■■■■ 已修改文件
api/v1/contact.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/saleChance.go 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesDetails.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/contract.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/followRecord.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/quotation.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/contact.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/contract.go 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/salesDetails.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/salesReturn.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/saleChance.go 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesDetails.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesReturn.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/subOrder.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/contact.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/salesDetails.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/salesReturn.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/contact.go
@@ -167,7 +167,7 @@
        return
    }
    contacts, total, errCode := contactService.GetContactList(params.Page, params.PageSize, params.SearchMap)
    contacts, total, errCode := contactService.GetContactList(params.Page, params.PageSize, params.SearchMap, params.ClientId)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
api/v1/saleChance.go
@@ -31,6 +31,17 @@
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method != 1 {
        count, err := model.NewSaleChanceSearch().SetNumber(saleChance.Number).Count()
        if err != nil {
            ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
            return
        }
        if count > 0 {
            ctx.FailWithMsg(ecode.UnknownErr, "销售机会编码已存在")
            return
        }
    }
    errCode = saleChanceService.AddSaleChance(&saleChance)
    if errCode != ecode.OK {
api/v1/salesDetails.go
@@ -166,7 +166,7 @@
        return
    }
    salesDetailss, total, errCode := salesDetailsService.GetSalesDetailsList(params.Page, params.PageSize, params.KeywordType, params.Keyword, params.SaleChanceId)
    salesDetailss, total, errCode := salesDetailsService.GetSalesDetailsList(params)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
docs/docs.go
@@ -11281,6 +11281,9 @@
                "codeStandID": {
                    "type": "string"
                },
                "contractName": {
                    "type": "string"
                },
                "created_at": {
                    "description": "The date when the item was created\nexample: 2023-08-10 15:48:25",
                    "type": "string"
@@ -13672,6 +13675,10 @@
                    "description": "编码id",
                    "type": "string"
                },
                "contractName": {
                    "description": "合同名称",
                    "type": "string"
                },
                "file": {
                    "type": "string"
                },
@@ -15526,6 +15533,10 @@
        "request.GetContactList": {
            "type": "object",
            "properties": {
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -15712,6 +15723,10 @@
        "request.GetSalesDetailsList": {
            "type": "object",
            "properties": {
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "keyword": {
                    "type": "string"
                },
@@ -15775,6 +15790,10 @@
        "request.GetSalesReturnList": {
            "type": "object",
            "properties": {
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "keyword": {
                    "type": "string"
                },
@@ -16737,6 +16756,10 @@
                    "description": "编码id",
                    "type": "string"
                },
                "contractName": {
                    "description": "合同名称",
                    "type": "string"
                },
                "file": {
                    "type": "string"
                },
docs/swagger.json
@@ -11269,6 +11269,9 @@
                "codeStandID": {
                    "type": "string"
                },
                "contractName": {
                    "type": "string"
                },
                "created_at": {
                    "description": "The date when the item was created\nexample: 2023-08-10 15:48:25",
                    "type": "string"
@@ -13660,6 +13663,10 @@
                    "description": "编码id",
                    "type": "string"
                },
                "contractName": {
                    "description": "合同名称",
                    "type": "string"
                },
                "file": {
                    "type": "string"
                },
@@ -15514,6 +15521,10 @@
        "request.GetContactList": {
            "type": "object",
            "properties": {
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -15700,6 +15711,10 @@
        "request.GetSalesDetailsList": {
            "type": "object",
            "properties": {
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "keyword": {
                    "type": "string"
                },
@@ -15763,6 +15778,10 @@
        "request.GetSalesReturnList": {
            "type": "object",
            "properties": {
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "keyword": {
                    "type": "string"
                },
@@ -16725,6 +16744,10 @@
                    "description": "编码id",
                    "type": "string"
                },
                "contractName": {
                    "description": "合同名称",
                    "type": "string"
                },
                "file": {
                    "type": "string"
                },
docs/swagger.yaml
@@ -738,6 +738,8 @@
        type: integer
      codeStandID:
        type: string
      contractName:
        type: string
      created_at:
        description: |-
          The date when the item was created
@@ -2348,6 +2350,9 @@
      codeStandID:
        description: 编码id
        type: string
      contractName:
        description: 合同名称
        type: string
      file:
        type: string
      member_id:
@@ -3601,6 +3606,9 @@
    type: object
  request.GetContactList:
    properties:
      clientId:
        description: 客户id
        type: integer
      page:
        description: 页码
        type: integer
@@ -3745,6 +3753,9 @@
    type: object
  request.GetSalesDetailsList:
    properties:
      clientId:
        description: 客户id
        type: integer
      keyword:
        type: string
      keywordType:
@@ -3791,6 +3802,9 @@
    type: object
  request.GetSalesReturnList:
    properties:
      clientId:
        description: 客户id
        type: integer
      keyword:
        type: string
      keywordType:
@@ -4450,6 +4464,9 @@
      codeStandID:
        description: 编码id
        type: string
      contractName:
        description: 合同名称
        type: string
      file:
        type: string
      id:
model/contract.go
@@ -8,6 +8,7 @@
type (
    Contract struct {
        Id                    int                   `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        ContractName          string                `json:"contractName" gorm:"column:contract_name;type:varchar(255);comment:合同名称"`
        ClientId              int                   `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"`
        Client                Client                `json:"client" gorm:"foreignKey:ClientId"`
        MemberId              int                   `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"`
model/followRecord.go
@@ -71,7 +71,7 @@
                    db = db.Where(key+" LIKE ?", "%"+v+"%")
                }
                if key == "name" {
                if key == "client_name" {
                    db = db.Joins("Client").Where("Client.name LIKE ?", "%"+v+"%")
                }
model/quotation.go
@@ -79,7 +79,7 @@
                    db = db.Joins("Member").Where("Member.username LIKE ?", "%"+v+"%")
                }
            case int:
            case float64:
                if key == "client_id" || key == "sale_chance_id" {
                    db = db.Where(key+" = ?", v)
                }
model/request/contact.go
@@ -34,6 +34,7 @@
type GetContactList struct {
    PageInfo
    SearchMap map[string]interface{} `json:"search_map"` // 搜索条件: map[string]interface{}{"name": "xxx"}; {"name": "客户名称", "phone": "手机号码", "detail_address":"详细地址", "next_visit_time":"下回回访日期", "member_name": "销售负责人", "client_status": "客户状态", "client_level": "重要级别", "is_first": "是否是首要联系人", "client_id": "clientId 用于返回首要联系人"}
    ClientId  int                    `json:"clientId"`   //客户id
}
type DeleteContact struct {
model/request/contract.go
@@ -7,14 +7,15 @@
}
type Contract struct {
    ClientId    int               `json:"client_id"`
    MemberId    int               `json:"member_id"`
    Number      string            `json:"number"`
    QuotationId int               `json:"quotation_id"`
    StatusId    int               `json:"status_id"`
    File        string            `json:"file"`
    CodeStandID string            `json:"codeStandID"` //编码id
    CodeRule    code.CodeStandard `json:"codeRule"`
    ContractName string            `json:"contractName"` //合同名称
    ClientId     int               `json:"client_id"`
    MemberId     int               `json:"member_id"`
    Number       string            `json:"number"`
    QuotationId  int               `json:"quotation_id"`
    StatusId     int               `json:"status_id"`
    File         string            `json:"file"`
    CodeStandID  string            `json:"codeStandID"` //编码id
    CodeRule     code.CodeStandard `json:"codeRule"`
}
type UpdateContract struct {
model/request/salesDetails.go
@@ -42,4 +42,5 @@
    KeywordType  constvar.SalesDetailsKeywordType `json:"keywordType"`
    Keyword      string                           `json:"keyword"`
    SaleChanceId int                              `json:"saleChanceId"` //销售机会id
    ClientId     int                              `json:"clientId"`     //客户id
}
model/request/salesReturn.go
@@ -38,4 +38,5 @@
    KeywordType constvar.SalesReturnKeywordType
    SourceType  constvar.SalesReturnSourceType `json:"sourceType"` // 源单类型(1销售明细)
    SourceId    int                            `json:"sourceId"`   // 源单id
    ClientId    int                            `json:"clientId"`   //客户id
}
model/saleChance.go
@@ -78,6 +78,9 @@
    if slf.Name != "" {
        db = db.Where("name = ?", slf.Name)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    if len(slf.SearchMap) > 0 {
        for key, value := range slf.SearchMap {
@@ -113,7 +116,7 @@
            case int:
            case float64:
                if key == "member_id" || key == "budget" || key == "projected_amount" {
                if key == "member_id" || key == "budget" || key == "projected_amount" || key == "client_id" {
                    db = db.Where(key+" = ?", v)
                }
            }
@@ -158,8 +161,15 @@
        db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
    }
    err := db.Preload("SaleType").Preload("RegularCustomers").Preload("SalesSources").Preload("Member").Preload("SaleStage").Preload("Possibility").Preload("CollectionProjections").Preload("Client").Preload("Contact.Province").Preload("Contact.City").Order("id desc").Find(&records).Error
    err := db.Preload("SaleType").Preload("RegularCustomers").Preload("SalesSources").Preload("Member").Preload("SaleStage").Preload("Possibility").Preload("CollectionProjections").Preload("Client").Preload("Province").Preload("City").Order("id desc").Find(&records).Error
    return records, total, err
}
func (slf *SaleChanceSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *SaleChanceSearch) SetId(id int) *SaleChanceSearch {
@@ -182,6 +192,11 @@
    return slf
}
func (slf *SaleChanceSearch) SetNumber(number string) *SaleChanceSearch {
    slf.Number = number
    return slf
}
func (slf *SaleChanceSearch) SetSearchMap(searchMap map[string]interface{}) *SaleChanceSearch {
    slf.SearchMap = searchMap
    return slf
model/salesDetails.go
@@ -75,6 +75,10 @@
        db = db.Where("sale_chance_id = ?", slf.SaleChanceId)
    }
    if slf.ClientId != 0 {
        db = db.Where("client_id = ?", slf.ClientId)
    }
    switch slf.KeywordType {
    case constvar.SalesDetailsKeywordTypeCustomerName:
        db = db.Joins("Client", clause.LeftJoin).Where("Client.name like ?", fmt.Sprintf("%%%s%%", slf.Keyword))
@@ -125,6 +129,11 @@
    return slf
}
func (slf *SalesDetailsSearch) SetClientId(clientId int) *SalesDetailsSearch {
    slf.ClientId = clientId
    return slf
}
func (slf *SalesDetailsSearch) SetSaleChanceId(saleChanceId int) *SalesDetailsSearch {
    slf.SaleChanceId = saleChanceId
    return slf
model/salesReturn.go
@@ -77,6 +77,9 @@
    if slf.SourceId != 0 {
        db = db.Where("source_id = ?", slf.SourceId)
    }
    if slf.ClientId != 0 {
        db = db.Where("client_id = ?", slf.ClientId)
    }
    if slf.Preload {
        db = db.Preload("Client").
            Preload("Member").
@@ -198,11 +201,17 @@
    slf.SourceType = sourceType
    return slf
}
func (slf *SalesReturnSearch) SetSourceId(sourceId int) *SalesReturnSearch {
    slf.SourceId = sourceId
    return slf
}
func (slf *SalesReturnSearch) SetClientId(clientId int) *SalesReturnSearch {
    slf.ClientId = clientId
    return slf
}
func (slf *SalesReturnSearch) UpdateByMap(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
model/subOrder.go
@@ -71,8 +71,9 @@
                    db = db.Joins("Member").Where("User.username LIKE ?", "%"+v+"%")
                }
            case int:
                if key == "master_order_id" {
                    db = db.Where("master_order_id = ?", v)
            case float64:
                if key == "client_id" || key == "master_order_id" {
                    db = db.Where(key+" = ?", v)
                }
            }
        }
service/contact.go
@@ -102,9 +102,9 @@
    return ecode.OK
}
func (ContactService) GetContactList(page, pageSize int, data map[string]interface{}) ([]*model.ContactDetail, int64, int) {
func (ContactService) GetContactList(page, pageSize int, data map[string]interface{}, clientId int) ([]*model.ContactDetail, int64, int) {
    // get contact list
    contacts, total, err := model.NewContactSearch(nil).SetPage(page, pageSize).SetSearchMap(data).FindAll()
    contacts, total, err := model.NewContactSearch(nil).SetPage(page, pageSize).SetSearchMap(data).SetClientId(clientId).FindAll()
    if err != nil {
        return nil, 0, ecode.ContactListErr
    }
service/salesDetails.go
@@ -1,8 +1,8 @@
package service
import (
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/model/request"
    "aps_crm/pkg/ecode"
    "github.com/shopspring/decimal"
    "gorm.io/gorm"
@@ -114,13 +114,14 @@
    return ecode.OK
}
func (SalesDetailsService) GetSalesDetailsList(page, pageSize int, keywordType constvar.SalesDetailsKeywordType, keyword string, saleChanceId int) ([]*model.SalesDetails, int64, int) {
func (SalesDetailsService) GetSalesDetailsList(params request.GetSalesDetailsList) ([]*model.SalesDetails, int64, int) {
    // get contact list
    contacts, total, err := model.NewSalesDetailsSearch().
        SetPreload(true).
        SetKeywordType(keywordType).
        SetSaleChanceId(saleChanceId).
        SetKeyword(keyword).SetPage(page, pageSize).FindAll()
        SetKeywordType(params.KeywordType).
        SetSaleChanceId(params.SaleChanceId).
        SetClientId(params.ClientId).
        SetKeyword(params.Keyword).SetPage(params.Page, params.PageSize).FindAll()
    if err != nil {
        return nil, 0, ecode.SalesDetailsListErr
    }
service/salesReturn.go
@@ -132,6 +132,7 @@
        SetPage(params.Page, params.PageSize).
        SetSourceId(params.SourceId).
        SetSourceType(params.SourceType).
        SetClientId(params.ClientId).
        SetPreload(true).
        FindAll()
    if err != nil {