api/v1/followRecord.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
api/v1/quotation.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/business.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/client.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/contact.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/followRecord.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/jsonTime.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/masterOrder.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/plan.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/quotation.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/saleChance.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/salesRefund.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/salesReturn.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/serviceFeeManage.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
api/v1/followRecord.go
@@ -6,6 +6,7 @@ "aps_crm/model/response" "aps_crm/pkg/contextx" "aps_crm/pkg/ecode" "errors" "github.com/gin-gonic/gin" "time" ) @@ -172,25 +173,37 @@ // checkTimeFormat // 检查时间格式 func checkTimeFormat(t string) (*time.Time, error) { func checkTimeFormat(t string) (*model.CustomTime, error) { if t == "" { return nil, nil } location, err := time.LoadLocation("Asia/Shanghai") if err != nil { return nil, err } tt, err := time.Parse("2006-01-02T15:04:05.000Z", t) tt, err := time.Parse("2006-01-02", t) if err == nil { ret := tt.In(location) return &ret, nil tmp := model.CustomTime(ret) return &tmp, nil } tt, err = time.Parse("2006-01-02T15:04:05-07:00", t) tt, err = time.Parse("2006-01-02 15:04:05", t) if err == nil { ret := tt.In(location) return &ret, nil tmp := model.CustomTime(ret) return &tmp, nil } return nil, err //tt, err = time.Parse("2006-01-02T15:04:05-07:00", t) //if err == nil { // ret := tt.In(location) // return &ret, nil //} return nil, errors.New("invalid time format") } // List api/v1/quotation.go
@@ -98,7 +98,6 @@ ctx.Ok() } // checkQuotationParams func checkQuotationParams(quotation request.Quotation) (int, model.Quotation) { var errCode int @@ -129,6 +128,8 @@ errCode = ecode.InvalidParams return errCode, quotationModel } // 将时间字符转换为时间类型 quotationModel.ValidityDate = t quotationModel.ClientId = quotation.ClientId @@ -166,7 +167,7 @@ } ctx.OkWithDetailed(response.QuotationResponse{ List: quotations, List: quotations, Count: int(total), }) } } model/business.go
@@ -1,12 +1,10 @@ package model import "time" type ( Business struct { Representative string `json:"representative" gorm:"column:representative;type:varchar(255);comment:法人代表"` RegistrationTime *time.Time `json:"registration_time" gorm:"column:registration_time;type:datetime;default:1970-01-01 08:00:00;comment:注册时间"` RegisteredCapitalId int `json:"registered_capital_id" gorm:"column:registered_capital_id;type:int(11);comment:注册资金"` Representative string `json:"representative" gorm:"column:representative;type:varchar(255);comment:法人代表"` RegistrationTime *CustomTime `json:"registration_time" gorm:"column:registration_time;type:datetime;default:1970-01-01 08:00:00;comment:注册时间"` RegisteredCapitalId int `json:"registered_capital_id" gorm:"column:registered_capital_id;type:int(11);comment:注册资金"` RegisteredCapital RegisteredCapital IndustryId int `json:"industry_id" gorm:"column:industry_id;type:int(11);comment:所属行业"` Industry Industry model/client.go
@@ -26,8 +26,8 @@ ServiceMemberId int `json:"service_member_id" gorm:"column:service_member_id;type:int(11);comment:服务负责人ID"` DetailAddress string `json:"detail_address" gorm:"column:detail_address;type:varchar(255);comment:详细地址"` Remark string `json:"remark" gorm:"column:remark;type:varchar(255);comment:备注"` NextVisitTime *time.Time `json:"next_visit_time" gorm:"column:next_visit_time;type:datetime;comment:下次回访时间"` LatestServiceTime *time.Time `json:"latest_service_time" gorm:"column:latest_service_time;type:datetime;comment:最晚服务时间"` NextVisitTime *CustomTime `json:"next_visit_time" gorm:"column:next_visit_time;type:datetime;comment:下次回访时间"` LatestServiceTime *CustomTime `json:"latest_service_time" gorm:"column:latest_service_time;type:datetime;comment:最晚服务时间"` FollowRecord []FollowRecord `json:"follow_record" gorm:"foreignKey:ClientId"` Address Business model/contact.go
@@ -3,24 +3,23 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" ) type ( Contact struct { Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` Name string `json:"name" gorm:"column:name;type:varchar(255);comment:联系人姓名"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:联系人编号"` ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户ID"` Client Client `json:"-" gorm:"foreignKey:ClientId"` Position string `json:"position" gorm:"column:position;type:varchar(255);comment:职位"` Phone string `json:"phone" gorm:"column:phone;type:varchar(255);comment:电话"` MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:负责人ID"` IsFirst bool `json:"is_first" gorm:"column:is_first;type:tinyint(1);comment:是否首要联系人"` Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255);comment:微信"` Birthday *time.Time `json:"birthday" gorm:"column:birthday;type:datetime;comment:生日"` Email string `json:"email" gorm:"column:email;type:varchar(255);comment:邮箱"` Desc string `json:"desc" gorm:"column:desc;type:varchar(255);comment:备注"` Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` Name string `json:"name" gorm:"column:name;type:varchar(255);comment:联系人姓名"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:联系人编号"` ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户ID"` Client Client `json:"-" gorm:"foreignKey:ClientId"` Position string `json:"position" gorm:"column:position;type:varchar(255);comment:职位"` Phone string `json:"phone" gorm:"column:phone;type:varchar(255);comment:电话"` MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:负责人ID"` IsFirst bool `json:"is_first" gorm:"column:is_first;type:tinyint(1);comment:是否首要联系人"` Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255);comment:微信"` Birthday *CustomTime `json:"birthday" gorm:"column:birthday;type:datetime;comment:生日"` Email string `json:"email" gorm:"column:email;type:varchar(255);comment:邮箱"` Desc string `json:"desc" gorm:"column:desc;type:varchar(255);comment:备注"` Address gorm.Model `json:"-"` } model/followRecord.go
@@ -3,29 +3,28 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" ) type ( FollowRecord struct { Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户id"` ClientStatusId int `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:客户状态id"` MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:跟进人id"` Member User `json:"member" gorm:"foreignKey:MemberId"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:跟进编号"` ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:联系人id"` Topic string `json:"topic" gorm:"column:topic;type:varchar(255);comment:跟进主题"` Record string `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:跟进记录"` SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:销售机会id"` SalesLeadsId int `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:销售线索id"` ContactInformationId int `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:联系方式id"` FollowTime *time.Time `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:跟进时间"` NextFollowTime *time.Time `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:下次跟进时间"` Purpose string `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:跟进目的"` Content string `json:"content" gorm:"column:content;type:MEDIUMTEXT;comment:跟进内容"` Client Client `json:"client" gorm:"foreignKey:ClientId"` Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户id"` ClientStatusId int `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:客户状态id"` MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:跟进人id"` Member User `json:"member" gorm:"foreignKey:MemberId"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:跟进编号"` ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:联系人id"` Topic string `json:"topic" gorm:"column:topic;type:varchar(255);comment:跟进主题"` Record string `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:跟进记录"` SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:销售机会id"` SalesLeadsId int `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:销售线索id"` ContactInformationId int `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:联系方式id"` FollowTime *CustomTime `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:跟进时间"` NextFollowTime *CustomTime `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:下次跟进时间"` Purpose string `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:跟进目的"` Content string `json:"content" gorm:"column:content;type:MEDIUMTEXT;comment:跟进内容"` Client Client `json:"client" gorm:"foreignKey:ClientId"` Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` gorm.Model `json:"-"` } model/jsonTime.go
New file @@ -0,0 +1,52 @@ package model import ( "database/sql/driver" "encoding/json" "fmt" "time" ) type CustomTime time.Time const ctLayout = "2006-01-02 15:04:05" // 想要的时间格式 func (ct *CustomTime) MarshalJSON() ([]byte, error) { return json.Marshal(time.Time(*ct).Format(ctLayout)) } func (ct *CustomTime) UnmarshalJSON(b []byte) error { var s string if err := json.Unmarshal(b, &s); err != nil { return err } t, err := time.Parse(ctLayout, s) if err != nil { return err } *ct = CustomTime(t) return nil } // Scan 将数据库值扫描到Go中的CustomTime func (ct *CustomTime) Scan(value interface{}) error { if value == nil { *ct = CustomTime(time.Time{}) return nil } if t, ok := value.(time.Time); ok { *ct = CustomTime(t) return nil } return fmt.Errorf("can't scan %T into CustomTime", value) } // Value 将CustomTime的值转换为数据库值 func (ct CustomTime) Value() (driver.Value, error) { if time.Time(ct).IsZero() { return nil, nil } return time.Time(ct), nil } model/masterOrder.go
@@ -3,20 +3,19 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" ) type ( // MasterOrder 销售总单 MasterOrder 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 `json:"client_id" gorm:"column:client_id;type:int;comment:客户id"` Client Client `json:"client" gorm:"foreignKey:ClientId"` MemberId int `json:"member_id" gorm:"column:member_id;type:int;comment:负责人id"` StartTime *time.Time `json:"start_time" gorm:"column:start_time;type:datetime;comment:开始时间"` EndTime *time.Time `json:"end_time" gorm:"column:end_time;type:datetime;comment:结束时间"` Money float64 `json:"money" gorm:"column:money;type:decimal(10,2);comment:总金额"` Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售总单号"` ClientId int `json:"client_id" gorm:"column:client_id;type:int;comment:客户id"` Client Client `json:"client" gorm:"foreignKey:ClientId"` MemberId int `json:"member_id" gorm:"column:member_id;type:int;comment:负责人id"` StartTime *CustomTime `json:"start_time" gorm:"column:start_time;type:datetime;comment:开始时间"` EndTime *CustomTime `json:"end_time" gorm:"column:end_time;type:datetime;comment:结束时间"` Money float64 `json:"money" gorm:"column:money;type:decimal(10,2);comment:总金额"` gorm.Model `json:"-"` } model/plan.go
@@ -3,7 +3,6 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" ) type ( @@ -16,8 +15,8 @@ SubOrder SubOrder `json:"subOrder" gorm:"foreignKey:SubOrderId"` SalesDetailsId int `json:"salesDetailsId" gorm:"column:sales_details_id;type:int;comment:销售明细id"` SalesDetails SalesDetails `json:"salesDetails" gorm:"foreignKey:SalesDetailsId"` StartTime *time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"` EndTime *time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"` StartTime *CustomTime `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"` EndTime *CustomTime `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"` Content string `json:"content" gorm:"column:content;type:varchar(255);comment:计划内容"` File string `json:"file" gorm:"column:file;type:varchar(255);comment:附件"` gorm.Model `json:"-"` model/quotation.go
@@ -3,26 +3,25 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" ) type ( // Quotation 报价单 Quotation struct { Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` ClientId int `json:"client_id" gorm:"column:client_id;type:int;comment:客户id"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:报价单号"` QuotationStatusId int `json:"quotation_status_id" gorm:"column:quotation_status_id;type:int;comment:报价单状态id"` ValidityDate *time.Time `json:"validity_date" gorm:"column:validity_date;type:datetime;comment:有效期"` ContactId int `json:"contact_id" gorm:"column:contact_id;type:int;comment:联系人id"` MemberId int `json:"member_id" gorm:"column:member_id;type:int;comment:负责人id"` SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` Conditions string `json:"conditions" gorm:"column:conditions;type:text;comment:报价条件"` File string `json:"file" gorm:"column:file;type:varchar(255);comment:附件"` Client Client `json:"client" gorm:"foreignKey:ClientId"` Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` SaleChance SaleChance `json:"sale_chance" gorm:"foreignKey:SaleChanceId"` Products []Product `json:"products" gorm:"many2many:quotation_product"` Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` ClientId int `json:"client_id" gorm:"column:client_id;type:int;comment:客户id"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:报价单号"` QuotationStatusId int `json:"quotation_status_id" gorm:"column:quotation_status_id;type:int;comment:报价单状态id"` ValidityDate *CustomTime `json:"validity_date" gorm:"column:validity_date;type:datetime;comment:有效期"` ContactId int `json:"contact_id" gorm:"column:contact_id;type:int;comment:联系人id"` MemberId int `json:"member_id" gorm:"column:member_id;type:int;comment:负责人id"` SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` Conditions string `json:"conditions" gorm:"column:conditions;type:text;comment:报价条件"` File string `json:"file" gorm:"column:file;type:varchar(255);comment:附件"` Client Client `json:"client" gorm:"foreignKey:ClientId"` Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` SaleChance SaleChance `json:"sale_chance" gorm:"foreignKey:SaleChanceId"` Products []Product `json:"products" gorm:"many2many:quotation_product"` gorm.Model `json:"-"` } model/saleChance.go
@@ -3,7 +3,6 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" ) type ( @@ -23,7 +22,7 @@ Budget float64 `json:"budget" gorm:"column:budget;type:decimal(10,2);comment:预算"` ProjectedAmount float64 `json:"projected_amount" gorm:"column:projected_amount;type:decimal(10,2);comment:预计金额"` Currency int `json:"currency" gorm:"column:currency;type:int(11);comment:币种"` ExpectedTime *time.Time `json:"expected_time" gorm:"column:expected_time;type:datetime;comment:预计成交时间"` ExpectedTime *CustomTime `json:"expected_time" gorm:"column:expected_time;type:datetime;comment:预计成交时间"` StatusId int `json:"status_id" gorm:"column:status_id;type:int(11);comment:状态ID"` PainPoints string `json:"pain_points" gorm:"column:pain_points;type:text;comment:痛点"` WhetherEstablished string `json:"whether_established" gorm:"column:whether_established;type:text;comment:是否成立"` model/salesRefund.go
@@ -3,21 +3,20 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" ) type ( SalesRefund 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:退款单号"` MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` RefundDate *time.Time `json:"refundDate" gorm:"column:refund_date;type:datetime;comment:退款日期"` RefundMethod string `json:"refundMethod" gorm:"column:refund_method;type:varchar(255);comment:退款方式"` AccountId int `json:"accountId" gorm:"column:account_id;type:int;comment:账户"` IsInvoice int `json:"isInvoice" gorm:"column:is_invoice;type:int;comment:是否开票"` Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:退款原因"` Products []Product `json:"products" gorm:"many2many:salesRefund_product;"` 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:退款单号"` MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` RefundDate *CustomTime `json:"refundDate" gorm:"column:refund_date;type:datetime;comment:退款日期"` RefundMethod string `json:"refundMethod" gorm:"column:refund_method;type:varchar(255);comment:退款方式"` AccountId int `json:"accountId" gorm:"column:account_id;type:int;comment:账户"` IsInvoice int `json:"isInvoice" gorm:"column:is_invoice;type:int;comment:是否开票"` Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:退款原因"` Products []Product `json:"products" gorm:"many2many:salesRefund_product;"` gorm.Model `json:"-"` } model/salesReturn.go
@@ -3,20 +3,19 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" "time" ) type ( SalesReturn 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:退货单号"` Repository string `json:"repository" gorm:"column:repository;type:varchar(255);comment:仓库"` MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` ReturnDate *time.Time `json:"returnDate" gorm:"column:return_date;type:datetime;comment:退货日期"` SalesReturnStatus int `json:"salesReturnStatus" gorm:"column:sales_return_status;type:int;comment:退货状态"` Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:退货原因"` Products []Product `json:"products" gorm:"many2many:salesReturn_product;"` 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:退货单号"` Repository string `json:"repository" gorm:"column:repository;type:varchar(255);comment:仓库"` MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` ReturnDate *CustomTime `json:"returnDate" gorm:"column:return_date;type:datetime;comment:退货日期"` SalesReturnStatus int `json:"salesReturnStatus" gorm:"column:sales_return_status;type:int;comment:退货状态"` Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:退货原因"` Products []Product `json:"products" gorm:"many2many:salesReturn_product;"` } SalesReturnSearch struct { model/serviceFeeManage.go
@@ -9,13 +9,13 @@ type ( ServiceFeeManage struct { Id int `json:"id" gorm:"column:id;primaryKey;autoIncrement;not null"` ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户ID"` Client *Client `json:"client" gorm:"foreignKey:ClientId"` MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:员工ID"` LatestDate *time.Time `json:"latest_date" gorm:"column:latest_date;type:datetime;comment:最晚服务时间"` Remark string `json:"remark" gorm:"column:remark;type:varchar(255);comment:备注"` File string `json:"file" gorm:"column:file;type:varchar(255);comment:文件"` Id int `json:"id" gorm:"column:id;primaryKey;autoIncrement;not null"` ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户ID"` Client *Client `json:"client" gorm:"foreignKey:ClientId"` MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:员工ID"` LatestDate *CustomTime `json:"latest_date" gorm:"column:latest_date;type:datetime;comment:最晚服务时间"` Remark string `json:"remark" gorm:"column:remark;type:varchar(255);comment:备注"` File string `json:"file" gorm:"column:file;type:varchar(255);comment:文件"` gorm.Model `json:"-"` }