From 251c3ff0282168c8cc44c48d27916b02e3498a7f Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 11 八月 2023 15:01:04 +0800
Subject: [PATCH] fix

---
 model/salesReturn.go      |   20 +-
 model/serviceFeeManage.go |  352 +++++++++++++++++++-------------------
 model/business.go         |    6 
 model/plan.go             |    6 
 model/salesRefund.go      |   25 +-
 model/client.go           |    4 
 model/saleChance.go       |    2 
 api/v1/followRecord.go    |   16 -
 model/quotation.go        |    2 
 model/contact.go          |   26 +-
 model/masterOrder.go      |   21 +-
 model/followRecord.go     |   36 ++--
 12 files changed, 256 insertions(+), 260 deletions(-)

diff --git a/api/v1/followRecord.go b/api/v1/followRecord.go
index e015177..fef5098 100644
--- a/api/v1/followRecord.go
+++ b/api/v1/followRecord.go
@@ -172,27 +172,25 @@
 
 // checkTimeFormat
 // 妫�鏌ユ椂闂存牸寮�
-func checkTimeFormat(t string) (time.Time, error) {
-	if t == "" {
-		t = "1900-01-01T00:00:00+08:00"
-	}
-
+func checkTimeFormat(t string) (*time.Time, error) {
 	location, err := time.LoadLocation("Asia/Shanghai")
 	if err != nil {
-		return time.Time{}, err
+		return nil, err
 	}
 
 	tt, err := time.Parse("2006-01-02T15:04:05.000Z", t)
 	if err == nil {
-		return tt.In(location), nil
+		ret := tt.In(location)
+		return &ret, nil
 	}
 
 	tt, err = time.Parse("2006-01-02T15:04:05-07:00", t)
 	if err == nil {
-		return tt.In(location), nil
+		ret := tt.In(location)
+		return &ret, nil
 	}
 
-	return time.Time{}, err
+	return nil, err
 }
 
 // List
diff --git a/model/business.go b/model/business.go
index 9420a5c..c26f7ee 100644
--- a/model/business.go
+++ b/model/business.go
@@ -4,9 +4,9 @@
 
 type (
 	Business struct {
-		Representative      string    `json:"representative" gorm:"column:representative;type:varchar(255);comment:娉曚汉浠h〃"`
-		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:娉曚汉浠h〃"`
+		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:娉ㄥ唽璧勯噾"`
 		RegisteredCapital   RegisteredCapital
 		IndustryId          int `json:"industry_id" gorm:"column:industry_id;type:int(11);comment:鎵�灞炶涓�"`
 		Industry            Industry
diff --git a/model/client.go b/model/client.go
index 7cec5b9..2dfb6e6 100644
--- a/model/client.go
+++ b/model/client.go
@@ -26,8 +26,8 @@
 		ServiceMemberId   int            `json:"service_member_id" gorm:"column:service_member_id;type:int(11);comment:鏈嶅姟璐熻矗浜篒D"`
 		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     *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:鏈�鏅氭湇鍔℃椂闂�"`
 		FollowRecord      []FollowRecord `json:"follow_record" gorm:"foreignKey:ClientId"`
 		Address
 		Business
diff --git a/model/contact.go b/model/contact.go
index 560db43..7907378 100644
--- a/model/contact.go
+++ b/model/contact.go
@@ -8,19 +8,19 @@
 
 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:璐熻矗浜篒D"`
-		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:璐熻矗浜篒D"`
+		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:澶囨敞"`
 		Address
 		gorm.Model `json:"-"`
 	}
diff --git a/model/followRecord.go b/model/followRecord.go
index 381ea2b..291eca4 100644
--- a/model/followRecord.go
+++ b/model/followRecord.go
@@ -8,24 +8,24 @@
 
 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:瀹㈡埛鐘舵�乮d"`
-		MemberId             int       `json:"member_id" gorm:"column:member_id;type:int(11);comment:璺熻繘浜篿d"`
-		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:鑱旂郴浜篿d"`
-		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:閿�鍞満浼歩d"`
-		SalesLeadsId         int       `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:閿�鍞嚎绱d"`
-		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:瀹㈡埛鐘舵�乮d"`
+		MemberId             int        `json:"member_id" gorm:"column:member_id;type:int(11);comment:璺熻繘浜篿d"`
+		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:鑱旂郴浜篿d"`
+		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:閿�鍞満浼歩d"`
+		SalesLeadsId         int        `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:閿�鍞嚎绱d"`
+		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"`
 		gorm.Model           `json:"-"`
 	}
 
diff --git a/model/masterOrder.go b/model/masterOrder.go
index 71f053e..090803f 100644
--- a/model/masterOrder.go
+++ b/model/masterOrder.go
@@ -9,14 +9,14 @@
 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:璐熻矗浜篿d"`
-		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:璐熻矗浜篿d"`
+		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:鎬婚噾棰�"`
 		gorm.Model `json:"-"`
 	}
 
@@ -24,12 +24,11 @@
 	MasterOrderSearch struct {
 		MasterOrder
 
-				Orm      *gorm.DB
+		Orm      *gorm.DB
 		Keyword  string
 		OrderBy  string
 		PageNum  int
 		PageSize int
-
 	}
 )
 
@@ -114,4 +113,4 @@
 func (slf *MasterOrderSearch) SetOrder(order string) *MasterOrderSearch {
 	slf.OrderBy = order
 	return slf
-}
\ No newline at end of file
+}
diff --git a/model/plan.go b/model/plan.go
index a8ccdda..96f5e22 100644
--- a/model/plan.go
+++ b/model/plan.go
@@ -16,8 +16,8 @@
 		SubOrder       SubOrder     `json:"subOrder" gorm:"foreignKey:SubOrderId"`
 		SalesDetailsId int          `json:"salesDetailsId" gorm:"column:sales_details_id;type:int;comment:閿�鍞槑缁唅d"`
 		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      *time.Time   `json:"startTime" gorm:"column:start_time;type:datetime;comment:寮�濮嬫椂闂�"`
+		EndTime        *time.Time   `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:"-"`
@@ -111,4 +111,4 @@
 func (slf *PlanSearch) SetOrder(order string) *PlanSearch {
 	slf.OrderBy = order
 	return slf
-}
\ No newline at end of file
+}
diff --git a/model/quotation.go b/model/quotation.go
index 5bb7078..34262bc 100644
--- a/model/quotation.go
+++ b/model/quotation.go
@@ -13,7 +13,7 @@
 		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:鎶ヤ环鍗曠姸鎬乮d"`
-		ValidityDate      time.Time  `json:"validity_date" gorm:"column:validity_date;type:datetime;comment:鏈夋晥鏈�"`
+		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:鑱旂郴浜篿d"`
 		MemberId          int        `json:"member_id" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
 		SaleChanceId      int        `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
diff --git a/model/saleChance.go b/model/saleChance.go
index 9efbc3d..f695f9d 100644
--- a/model/saleChance.go
+++ b/model/saleChance.go
@@ -23,7 +23,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          *time.Time             `json:"expected_time" gorm:"column:expected_time;type:datetime;comment:棰勮鎴愪氦鏃堕棿"`
 		StatusId              int                    `json:"status_id" gorm:"column:status_id;type:int(11);comment:鐘舵�両D"`
 		PainPoints            string                 `json:"pain_points" gorm:"column:pain_points;type:text;comment:鐥涚偣"`
 		WhetherEstablished    string                 `json:"whether_established" gorm:"column:whether_established;type:text;comment:鏄惁鎴愮珛"`
diff --git a/model/salesRefund.go b/model/salesRefund.go
index e34be5b..ef4dc92 100644
--- a/model/salesRefund.go
+++ b/model/salesRefund.go
@@ -8,28 +8,27 @@
 
 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:璐熻矗浜篿d"`
-		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:璐熻矗浜篿d"`
+		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;"`
 		gorm.Model   `json:"-"`
 	}
 
 	SalesRefundSearch struct {
 		SalesRefund
 
-				Orm      *gorm.DB
+		Orm      *gorm.DB
 		Keyword  string
 		OrderBy  string
 		PageNum  int
 		PageSize int
-
 	}
 )
 
@@ -114,4 +113,4 @@
 func (slf *SalesRefundSearch) SetOrder(order string) *SalesRefundSearch {
 	slf.OrderBy = order
 	return slf
-}
\ No newline at end of file
+}
diff --git a/model/salesReturn.go b/model/salesReturn.go
index 94e1232..aec6c31 100644
--- a/model/salesReturn.go
+++ b/model/salesReturn.go
@@ -8,15 +8,15 @@
 
 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:璐熻矗浜篿d"`
-		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:璐熻矗浜篿d"`
+		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;"`
 	}
 
 	SalesReturnSearch struct {
@@ -107,4 +107,4 @@
 func (slf *SalesReturnSearch) SetOrder(order string) *SalesReturnSearch {
 	slf.OrderBy = order
 	return slf
-}
\ No newline at end of file
+}
diff --git a/model/serviceFeeManage.go b/model/serviceFeeManage.go
index 16ec527..4ef85e8 100644
--- a/model/serviceFeeManage.go
+++ b/model/serviceFeeManage.go
@@ -1,176 +1,176 @@
-package model
-
-import (
-	"aps_crm/constvar"
-	"aps_crm/pkg/mysqlx"
-	"gorm.io/gorm"
-	"time"
-)
-
-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:鏂囦欢"`
-		gorm.Model `json:"-"`
-	}
-
-	ServiceFeeManageSearch struct {
-		ServiceFeeManage
-		Orm         *gorm.DB
-		QueryClass  constvar.ServiceFeeQueryClass
-		KeywordType constvar.ServiceFeeKeywordType
-		Keyword     string
-		OrderBy     string
-		PageNum     int
-		PageSize    int
-	}
-)
-
-func (ServiceFeeManage) TableName() string {
-	return "service_fee_manage"
-}
-
-func NewServiceFeeManageSearch(db *gorm.DB) *ServiceFeeManageSearch {
-	if db == nil {
-		db = mysqlx.GetDB()
-	}
-
-	return &ServiceFeeManageSearch{
-		Orm: db,
-	}
-}
-
-func (slf *ServiceFeeManageSearch) build() *gorm.DB {
-	var db = slf.Orm.Model(&ServiceFeeManage{})
-	if slf.Id != 0 {
-		db.Where("id = ?", slf.Id)
-	}
-	if slf.ClientId != 0 {
-		db.Where("client_id = ?", slf.ClientId)
-	}
-	switch slf.QueryClass {
-	case constvar.ServiceFeeQueryClassExpireLessThen60Days:
-		db = db.Where("latest_date > ? and latest_date < ?", time.Now(), time.Now().AddDate(0, 0, 60))
-	case constvar.ServiceFeeQueryClassExpireLessThen30Days:
-		db = db.Where("latest_date > ? and latest_date < ?", time.Now(), time.Now().AddDate(0, 0, 30))
-	case constvar.ServiceFeeQueryClassExpireAboutTo60Day:
-		db = db.Where("latest_date = ?", time.Now().AddDate(0, 0, -60))
-	case constvar.ServiceFeeQueryClassExpireAboutTo30Day:
-		db = db.Where("latest_date = ?", time.Now().AddDate(0, 0, -30))
-	case constvar.ServiceFeeQueryClassExpired:
-		db = db.Where("latest_date < ?", time.Now())
-	case constvar.ServiceFeeQueryClassNoService:
-		db = db.Where("latest_date < ?", time.Now().AddDate(0, 0, -60))
-
-	}
-
-	switch slf.KeywordType {
-	case constvar.ServiceFeeKeywordCustomerName:
-		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
-		db = db.Where("clients.name = ?", slf.Keyword)
-	case constvar.ServiceFeeKeywordCustomerType:
-		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
-		db = db.Where("clients.client_type_id = ?", slf.Keyword)
-	case constvar.ServiceFeeKeywordSalesPrincipal:
-		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
-		db = db.Where("clients.member_id = ?", slf.Keyword)
-	case constvar.ServiceFeeKeywordCustomerScale:
-		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
-		db = db.Where("clients.enterprise_scale_id = ?", slf.Keyword)
-	case constvar.ServiceFeeKeywordClientLevel:
-		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
-		db = db.Where("clients.client_level_id = ?", slf.Keyword)
-	case constvar.ServiceFeeKeywordCustomerNo:
-		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
-		db = db.Where("clients.number = ?", slf.Keyword)
-	case constvar.ServiceFeeKeywordCustomerStatus:
-		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
-		db = db.Where("clients.client_status_id = ?", slf.Keyword)
-	case constvar.ServiceFeeKeywordServiceEndDate:
-		db = db.Where("latest_date = ?", slf.Keyword)
-	case constvar.ServiceFeeKeywordProductName:
-		//todo
-	}
-
-	return db
-}
-
-func (slf *ServiceFeeManageSearch) Create(record *ServiceFeeManage) error {
-	var db = slf.build()
-	return db.Create(record).Error
-}
-
-func (slf *ServiceFeeManageSearch) Update(record *ServiceFeeManage) error {
-	var db = slf.build()
-	return db.Updates(record).Error
-}
-
-func (slf *ServiceFeeManageSearch) Delete() error {
-	var db = slf.build()
-	return db.Delete(&ServiceFeeManage{}).Error
-}
-
-func (slf *ServiceFeeManageSearch) SetId(id int) *ServiceFeeManageSearch {
-	slf.Id = id
-	return slf
-}
-
-func (slf *ServiceFeeManageSearch) SetKeywordType(keyword constvar.ServiceFeeKeywordType) *ServiceFeeManageSearch {
-	slf.KeywordType = keyword
-	return slf
-}
-
-func (slf *ServiceFeeManageSearch) SetQueryClass(queryClass constvar.ServiceFeeQueryClass) *ServiceFeeManageSearch {
-	slf.QueryClass = queryClass
-	return slf
-}
-
-func (slf *ServiceFeeManageSearch) SetKeyword(keyword string) *ServiceFeeManageSearch {
-	slf.Keyword = keyword
-	return slf
-}
-
-func (slf *ServiceFeeManageSearch) Find() (*ServiceFeeManage, error) {
-	var db = slf.build()
-	var record = new(ServiceFeeManage)
-	err := db.First(record).Error
-	return record, err
-}
-
-func (slf *ServiceFeeManageSearch) FindAll() ([]*ServiceFeeManage, int64, error) {
-	var db = slf.build()
-	var records = make([]*ServiceFeeManage, 0)
-	var total int64
-	if err := db.Count(&total).Error; err != nil {
-		return records, total, err
-	}
-	if slf.PageNum > 0 && slf.PageSize > 0 {
-		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
-	}
-
-	if slf.PageNum > 0 && slf.PageSize > 0 {
-		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
-	}
-
-	err := db.Preload("Client").Find(&records).Error
-	return records, total, err
-}
-
-func (slf *ServiceFeeManageSearch) SetPage(page, size int) *ServiceFeeManageSearch {
-	slf.PageNum, slf.PageSize = page, size
-	return slf
-}
-
-func (slf *ServiceFeeManageSearch) SetOrder(order string) *ServiceFeeManageSearch {
-	slf.OrderBy = order
-	return slf
-}
-func (slf *ServiceFeeManageSearch) SetIds(ids []int) *ServiceFeeManageSearch {
-	slf.Orm = slf.Orm.Where("id in (?)", ids)
-	return slf
-}
+package model
+
+import (
+	"aps_crm/constvar"
+	"aps_crm/pkg/mysqlx"
+	"gorm.io/gorm"
+	"time"
+)
+
+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:鏂囦欢"`
+		gorm.Model `json:"-"`
+	}
+
+	ServiceFeeManageSearch struct {
+		ServiceFeeManage
+		Orm         *gorm.DB
+		QueryClass  constvar.ServiceFeeQueryClass
+		KeywordType constvar.ServiceFeeKeywordType
+		Keyword     string
+		OrderBy     string
+		PageNum     int
+		PageSize    int
+	}
+)
+
+func (ServiceFeeManage) TableName() string {
+	return "service_fee_manage"
+}
+
+func NewServiceFeeManageSearch(db *gorm.DB) *ServiceFeeManageSearch {
+	if db == nil {
+		db = mysqlx.GetDB()
+	}
+
+	return &ServiceFeeManageSearch{
+		Orm: db,
+	}
+}
+
+func (slf *ServiceFeeManageSearch) build() *gorm.DB {
+	var db = slf.Orm.Model(&ServiceFeeManage{})
+	if slf.Id != 0 {
+		db.Where("id = ?", slf.Id)
+	}
+	if slf.ClientId != 0 {
+		db.Where("client_id = ?", slf.ClientId)
+	}
+	switch slf.QueryClass {
+	case constvar.ServiceFeeQueryClassExpireLessThen60Days:
+		db = db.Where("latest_date > ? and latest_date < ?", time.Now(), time.Now().AddDate(0, 0, 60))
+	case constvar.ServiceFeeQueryClassExpireLessThen30Days:
+		db = db.Where("latest_date > ? and latest_date < ?", time.Now(), time.Now().AddDate(0, 0, 30))
+	case constvar.ServiceFeeQueryClassExpireAboutTo60Day:
+		db = db.Where("latest_date = ?", time.Now().AddDate(0, 0, -60))
+	case constvar.ServiceFeeQueryClassExpireAboutTo30Day:
+		db = db.Where("latest_date = ?", time.Now().AddDate(0, 0, -30))
+	case constvar.ServiceFeeQueryClassExpired:
+		db = db.Where("latest_date < ?", time.Now())
+	case constvar.ServiceFeeQueryClassNoService:
+		db = db.Where("latest_date < ?", time.Now().AddDate(0, 0, -60))
+
+	}
+
+	switch slf.KeywordType {
+	case constvar.ServiceFeeKeywordCustomerName:
+		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
+		db = db.Where("clients.name = ?", slf.Keyword)
+	case constvar.ServiceFeeKeywordCustomerType:
+		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
+		db = db.Where("clients.client_type_id = ?", slf.Keyword)
+	case constvar.ServiceFeeKeywordSalesPrincipal:
+		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
+		db = db.Where("clients.member_id = ?", slf.Keyword)
+	case constvar.ServiceFeeKeywordCustomerScale:
+		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
+		db = db.Where("clients.enterprise_scale_id = ?", slf.Keyword)
+	case constvar.ServiceFeeKeywordClientLevel:
+		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
+		db = db.Where("clients.client_level_id = ?", slf.Keyword)
+	case constvar.ServiceFeeKeywordCustomerNo:
+		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
+		db = db.Where("clients.number = ?", slf.Keyword)
+	case constvar.ServiceFeeKeywordCustomerStatus:
+		db.Joins("left join clients on clients.id = service_fee_manage.client_id")
+		db = db.Where("clients.client_status_id = ?", slf.Keyword)
+	case constvar.ServiceFeeKeywordServiceEndDate:
+		db = db.Where("latest_date = ?", slf.Keyword)
+	case constvar.ServiceFeeKeywordProductName:
+		//todo
+	}
+
+	return db
+}
+
+func (slf *ServiceFeeManageSearch) Create(record *ServiceFeeManage) error {
+	var db = slf.build()
+	return db.Create(record).Error
+}
+
+func (slf *ServiceFeeManageSearch) Update(record *ServiceFeeManage) error {
+	var db = slf.build()
+	return db.Updates(record).Error
+}
+
+func (slf *ServiceFeeManageSearch) Delete() error {
+	var db = slf.build()
+	return db.Delete(&ServiceFeeManage{}).Error
+}
+
+func (slf *ServiceFeeManageSearch) SetId(id int) *ServiceFeeManageSearch {
+	slf.Id = id
+	return slf
+}
+
+func (slf *ServiceFeeManageSearch) SetKeywordType(keyword constvar.ServiceFeeKeywordType) *ServiceFeeManageSearch {
+	slf.KeywordType = keyword
+	return slf
+}
+
+func (slf *ServiceFeeManageSearch) SetQueryClass(queryClass constvar.ServiceFeeQueryClass) *ServiceFeeManageSearch {
+	slf.QueryClass = queryClass
+	return slf
+}
+
+func (slf *ServiceFeeManageSearch) SetKeyword(keyword string) *ServiceFeeManageSearch {
+	slf.Keyword = keyword
+	return slf
+}
+
+func (slf *ServiceFeeManageSearch) Find() (*ServiceFeeManage, error) {
+	var db = slf.build()
+	var record = new(ServiceFeeManage)
+	err := db.First(record).Error
+	return record, err
+}
+
+func (slf *ServiceFeeManageSearch) FindAll() ([]*ServiceFeeManage, int64, error) {
+	var db = slf.build()
+	var records = make([]*ServiceFeeManage, 0)
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		return records, total, err
+	}
+	if slf.PageNum > 0 && slf.PageSize > 0 {
+		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
+	}
+
+	if slf.PageNum > 0 && slf.PageSize > 0 {
+		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
+	}
+
+	err := db.Preload("Client").Find(&records).Error
+	return records, total, err
+}
+
+func (slf *ServiceFeeManageSearch) SetPage(page, size int) *ServiceFeeManageSearch {
+	slf.PageNum, slf.PageSize = page, size
+	return slf
+}
+
+func (slf *ServiceFeeManageSearch) SetOrder(order string) *ServiceFeeManageSearch {
+	slf.OrderBy = order
+	return slf
+}
+func (slf *ServiceFeeManageSearch) SetIds(ids []int) *ServiceFeeManageSearch {
+	slf.Orm = slf.Orm.Where("id in (?)", ids)
+	return slf
+}

--
Gitblit v1.8.0