| | |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "errors" |
| | | "github.com/gin-gonic/gin" |
| | | "time" |
| | | ) |
| | |
| | | |
| | | // 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 |
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | |
| | | // checkQuotationParams |
| | | func checkQuotationParams(quotation request.Quotation) (int, model.Quotation) { |
| | | var errCode int |
| | |
| | | return errCode, quotationModel |
| | | } |
| | | |
| | | // 将时间字符转换为时间类型 |
| | | |
| | | quotationModel.ValidityDate = t |
| | | quotationModel.ClientId = quotation.ClientId |
| | | quotationModel.QuotationStatusId = quotation.QuotationStatusId |
| | |
| | | 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:注册时间"` |
| | | 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:所属行业"` |
| | |
| | | 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 |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | 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:生日"` |
| | | 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 |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | 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:下次跟进时间"` |
| | | 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"` |
New file |
| | |
| | | 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 |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | 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:结束时间"` |
| | | 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:"-"` |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | 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:"-"` |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | 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:有效期"` |
| | | 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"` |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | 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:是否成立"` |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | 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:退款日期"` |
| | | 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:是否开票"` |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | 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:退货日期"` |
| | | 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;"` |
| | |
| | | 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:最晚服务时间"` |
| | | 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:"-"` |