作者 陈志颖

feat:新增领域值对象

正在显示 45 个修改的文件 包含 960 行增加153 行删除
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 10
11 type RemoveContractUndertakerFeedbackCommand struct { 11 type RemoveContractUndertakerFeedbackCommand struct {
12 // 合约承接方反馈记录ID 12 // 合约承接方反馈记录ID
13 - FeedbackId int64 `cname:"合约承接方反馈记录ID" json:"feedbackId,string" valid:"Required"` 13 + FeedbackId string `cname:"合约承接方反馈记录ID" json:"feedbackId" valid:"Required"`
14 // 承接人uid 14 // 承接人uid
15 UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"` 15 UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"`
16 // 公司ID,通过集成REST上下文获取 16 // 公司ID,通过集成REST上下文获取
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 10
11 type GetContractUndertakerFeedbackQuery struct { 11 type GetContractUndertakerFeedbackQuery struct {
12 // 合约承接方反馈记录ID 12 // 合约承接方反馈记录ID
13 - FeedbackId int64 `cname:"合约承接方反馈记录ID" json:"feedbackId,string" valid:"Required"` 13 + FeedbackId string `cname:"合约承接方反馈记录ID" json:"feedbackId" valid:"Required"`
14 // 承接人uid 14 // 承接人uid
15 UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"` 15 UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"`
16 // 公司ID,通过集成REST上下文获取 16 // 公司ID,通过集成REST上下文获取
@@ -10,11 +10,11 @@ import ( @@ -10,11 +10,11 @@ import (
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
11 ) 11 )
12 12
13 -// 共创合约服务 13 +// CooperationContractService 共创合约服务
14 type CooperationContractService struct { 14 type CooperationContractService struct {
15 } 15 }
16 16
17 -// 创建共创合约服务 17 +// CreateCooperationContract 创建共创合约服务
18 func (cooperationContractService *CooperationContractService) CreateCooperationContract(createCooperationContractCommand *command.CreateCooperationContractCommand) (interface{}, error) { 18 func (cooperationContractService *CooperationContractService) CreateCooperationContract(createCooperationContractCommand *command.CreateCooperationContractCommand) (interface{}, error) {
19 if err := createCooperationContractCommand.ValidateCommand(); err != nil { 19 if err := createCooperationContractCommand.ValidateCommand(); err != nil {
20 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 20 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -30,11 +30,11 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -30,11 +30,11 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
30 transactionContext.RollbackTransaction() 30 transactionContext.RollbackTransaction()
31 }() 31 }()
32 32
33 - userServiceGateway, err := factory.CreateUserServiceGateway(nil)  
34 - if err != nil {  
35 - fmt.Println(err.Error())  
36 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
37 - } 33 + //userServiceGateway, err := factory.CreateUserServiceGateway(nil)
  34 + //if err != nil {
  35 + // fmt.Println(err.Error())
  36 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  37 + //}
38 38
39 //userServiceGateway.GetUser(createCooperationContractCommand.SponsorUid) 39 //userServiceGateway.GetUser(createCooperationContractCommand.SponsorUid)
40 40
@@ -73,7 +73,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -73,7 +73,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
73 } 73 }
74 } 74 }
75 75
76 -// 返回共创合约服务 76 +// GetCooperationContract 返回共创合约服务
77 func (cooperationContractService *CooperationContractService) GetCooperationContract(getCooperationContractQuery *query.GetCooperationContractQuery) (interface{}, error) { 77 func (cooperationContractService *CooperationContractService) GetCooperationContract(getCooperationContractQuery *query.GetCooperationContractQuery) (interface{}, error) {
78 if err := getCooperationContractQuery.ValidateQuery(); err != nil { 78 if err := getCooperationContractQuery.ValidateQuery(); err != nil {
79 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 79 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -110,7 +110,7 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont @@ -110,7 +110,7 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont
110 } 110 }
111 } 111 }
112 112
113 -// 返回共创合约服务列表 113 +// ListCooperationContract 返回共创合约服务列表
114 func (cooperationContractService *CooperationContractService) ListCooperationContract(listCooperationContractQuery *query.ListCooperationContractQuery) (interface{}, error) { 114 func (cooperationContractService *CooperationContractService) ListCooperationContract(listCooperationContractQuery *query.ListCooperationContractQuery) (interface{}, error) {
115 if err := listCooperationContractQuery.ValidateQuery(); err != nil { 115 if err := listCooperationContractQuery.ValidateQuery(); err != nil {
116 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 116 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -146,7 +146,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon @@ -146,7 +146,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
146 } 146 }
147 } 147 }
148 148
149 -// 移除共创合约服务 149 +// RemoveCooperationContract 移除共创合约服务
150 func (cooperationContractService *CooperationContractService) RemoveCooperationContract(removeCooperationContractCommand *command.RemoveCooperationContractCommand) (interface{}, error) { 150 func (cooperationContractService *CooperationContractService) RemoveCooperationContract(removeCooperationContractCommand *command.RemoveCooperationContractCommand) (interface{}, error) {
151 if err := removeCooperationContractCommand.ValidateCommand(); err != nil { 151 if err := removeCooperationContractCommand.ValidateCommand(); err != nil {
152 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 152 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -186,7 +186,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC @@ -186,7 +186,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC
186 } 186 }
187 } 187 }
188 188
189 -// 查询共创合约 189 +// SearchCooperationContract 查询共创合约
190 func (cooperationContractService *CooperationContractService) SearchCooperationContract(searchCooperationContractQuery *query.SearchCooperationContractQuery) (interface{}, error) { 190 func (cooperationContractService *CooperationContractService) SearchCooperationContract(searchCooperationContractQuery *query.SearchCooperationContractQuery) (interface{}, error) {
191 if err := searchCooperationContractQuery.ValidateQuery(); err != nil { 191 if err := searchCooperationContractQuery.ValidateQuery(); err != nil {
192 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 192 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -207,7 +207,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC @@ -207,7 +207,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
207 return nil, nil 207 return nil, nil
208 } 208 }
209 209
210 -// 根据承接人返回共创项目合约 210 +// SearchCooperationContractByUndertaker 根据承接人返回共创项目合约
211 func (cooperationContractService *CooperationContractService) SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery *query.SearchCooperationContractByUndertakerQuery) (interface{}, error) { 211 func (cooperationContractService *CooperationContractService) SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery *query.SearchCooperationContractByUndertakerQuery) (interface{}, error) {
212 if err := searchCooperationContractByUndertakerQuery.ValidateQuery(); err != nil { 212 if err := searchCooperationContractByUndertakerQuery.ValidateQuery(); err != nil {
213 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 213 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -228,7 +228,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC @@ -228,7 +228,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
228 return nil, nil 228 return nil, nil
229 } 229 }
230 230
231 -// 更新共创合约服务 231 +// UpdateCooperationContract 更新共创合约服务
232 func (cooperationContractService *CooperationContractService) UpdateCooperationContract(updateCooperationContractCommand *command.UpdateCooperationContractCommand) (interface{}, error) { 232 func (cooperationContractService *CooperationContractService) UpdateCooperationContract(updateCooperationContractCommand *command.UpdateCooperationContractCommand) (interface{}, error) {
233 if err := updateCooperationContractCommand.ValidateCommand(); err != nil { 233 if err := updateCooperationContractCommand.ValidateCommand(); err != nil {
234 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 234 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  1 +package dto
  2 +
  3 +// CooperationModeStatisticsDto 共创模式统计
  4 +type CooperationModeStatisticsDto struct {
  5 + // 共创人数统计
  6 + CooperationPeople float64 `json:"cooperationPeople"`
  7 + // 分红预算统计
  8 + DividendsEstimate float64 `json:"dividendsEstimate"`
  9 + // 订单金额统计
  10 + OrderAmount float64 `json:"orderAmount"`
  11 +}
@@ -10,11 +10,11 @@ import ( @@ -10,11 +10,11 @@ import (
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
11 ) 11 )
12 12
13 -// 共创项目服务 13 +// CooperationProjectService 共创项目服务
14 type CooperationProjectService struct { 14 type CooperationProjectService struct {
15 } 15 }
16 16
17 -// 判断当前勾选的承接对象是否存在用户 17 +// CheckUndertaker 判断当前勾选的承接对象是否存在用户
18 func (cooperationProjectService *CooperationProjectService) CheckUndertaker(checkUndertakerQuery *query.CheckUndertakerQuery) (interface{}, error) { 18 func (cooperationProjectService *CooperationProjectService) CheckUndertaker(checkUndertakerQuery *query.CheckUndertakerQuery) (interface{}, error) {
19 if err := checkUndertakerQuery.ValidateQuery(); err != nil { 19 if err := checkUndertakerQuery.ValidateQuery(); err != nil {
20 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 20 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -35,7 +35,7 @@ func (cooperationProjectService *CooperationProjectService) CheckUndertaker(chec @@ -35,7 +35,7 @@ func (cooperationProjectService *CooperationProjectService) CheckUndertaker(chec
35 return nil, nil 35 return nil, nil
36 } 36 }
37 37
38 -// 创建共创项目服务 38 +// CreateCooperationProject 创建共创项目服务
39 func (cooperationProjectService *CooperationProjectService) CreateCooperationProject(createCooperationProjectCommand *command.CreateCooperationProjectCommand) (interface{}, error) { 39 func (cooperationProjectService *CooperationProjectService) CreateCooperationProject(createCooperationProjectCommand *command.CreateCooperationProjectCommand) (interface{}, error) {
40 if err := createCooperationProjectCommand.ValidateCommand(); err != nil { 40 if err := createCooperationProjectCommand.ValidateCommand(); err != nil {
41 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 41 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -53,12 +53,12 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -53,12 +53,12 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
53 newCooperationProject := &domain.CooperationProject{ 53 newCooperationProject := &domain.CooperationProject{
54 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName, 54 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
55 CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType, 55 CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType,
56 - SponsorUid: createCooperationProjectCommand.SponsorUid,  
57 - PublisherUid: createCooperationProjectCommand.PublisherUid,  
58 - CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,  
59 - CompanyId: createCooperationProjectCommand.CompanyId,  
60 - OrgId: createCooperationProjectCommand.OrgId,  
61 - UserId: createCooperationProjectCommand.UserId, 56 + //SponsorUid: createCooperationProjectCommand.SponsorUid,
  57 + //PublisherUid: createCooperationProjectCommand.PublisherUid,
  58 + CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
  59 + //CompanyId: createCooperationProjectCommand.CompanyId,
  60 + //OrgId: createCooperationProjectCommand.OrgId,
  61 + //UserId: createCooperationProjectCommand.UserId,
62 } 62 }
63 var cooperationProjectRepository domain.CooperationProjectRepository 63 var cooperationProjectRepository domain.CooperationProjectRepository
64 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ 64 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
@@ -78,7 +78,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -78,7 +78,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
78 } 78 }
79 } 79 }
80 80
81 -// 返回共创项目服务 81 +// GetCooperationProject 返回共创项目服务
82 func (cooperationProjectService *CooperationProjectService) GetCooperationProject(getCooperationProjectQuery *query.GetCooperationProjectQuery) (interface{}, error) { 82 func (cooperationProjectService *CooperationProjectService) GetCooperationProject(getCooperationProjectQuery *query.GetCooperationProjectQuery) (interface{}, error) {
83 if err := getCooperationProjectQuery.ValidateQuery(); err != nil { 83 if err := getCooperationProjectQuery.ValidateQuery(); err != nil {
84 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 84 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -115,7 +115,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -115,7 +115,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
115 } 115 }
116 } 116 }
117 117
118 -// 返回共创项目服务列表 118 +// ListCooperationProject 返回共创项目服务列表
119 func (cooperationProjectService *CooperationProjectService) ListCooperationProject(listCooperationProjectQuery *query.ListCooperationProjectQuery) (interface{}, error) { 119 func (cooperationProjectService *CooperationProjectService) ListCooperationProject(listCooperationProjectQuery *query.ListCooperationProjectQuery) (interface{}, error) {
120 if err := listCooperationProjectQuery.ValidateQuery(); err != nil { 120 if err := listCooperationProjectQuery.ValidateQuery(); err != nil {
121 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 121 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -151,7 +151,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje @@ -151,7 +151,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
151 } 151 }
152 } 152 }
153 153
154 -// 发布共创项目 154 +// ReleaseCooperationProject 发布共创项目
155 func (cooperationProjectService *CooperationProjectService) ReleaseCooperationProject(releaseCooperationProjectCommand *command.ReleaseCooperationProjectCommand) (interface{}, error) { 155 func (cooperationProjectService *CooperationProjectService) ReleaseCooperationProject(releaseCooperationProjectCommand *command.ReleaseCooperationProjectCommand) (interface{}, error) {
156 if err := releaseCooperationProjectCommand.ValidateCommand(); err != nil { 156 if err := releaseCooperationProjectCommand.ValidateCommand(); err != nil {
157 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 157 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -172,7 +172,7 @@ func (cooperationProjectService *CooperationProjectService) ReleaseCooperationPr @@ -172,7 +172,7 @@ func (cooperationProjectService *CooperationProjectService) ReleaseCooperationPr
172 return nil, nil 172 return nil, nil
173 } 173 }
174 174
175 -// 移除共创项目服务 175 +// RemoveCooperationProject 移除共创项目服务
176 func (cooperationProjectService *CooperationProjectService) RemoveCooperationProject(removeCooperationProjectCommand *command.RemoveCooperationProjectCommand) (interface{}, error) { 176 func (cooperationProjectService *CooperationProjectService) RemoveCooperationProject(removeCooperationProjectCommand *command.RemoveCooperationProjectCommand) (interface{}, error) {
177 if err := removeCooperationProjectCommand.ValidateCommand(); err != nil { 177 if err := removeCooperationProjectCommand.ValidateCommand(); err != nil {
178 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 178 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -212,7 +212,7 @@ func (cooperationProjectService *CooperationProjectService) RemoveCooperationPro @@ -212,7 +212,7 @@ func (cooperationProjectService *CooperationProjectService) RemoveCooperationPro
212 } 212 }
213 } 213 }
214 214
215 -// 查询共创项目 215 +// SearchCooperationProject 查询共创项目
216 func (cooperationProjectService *CooperationProjectService) SearchCooperationProject(searchCooperationProjectQuery *query.SearchCooperationProjectQuery) (interface{}, error) { 216 func (cooperationProjectService *CooperationProjectService) SearchCooperationProject(searchCooperationProjectQuery *query.SearchCooperationProjectQuery) (interface{}, error) {
217 if err := searchCooperationProjectQuery.ValidateQuery(); err != nil { 217 if err := searchCooperationProjectQuery.ValidateQuery(); err != nil {
218 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 218 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -233,7 +233,7 @@ func (cooperationProjectService *CooperationProjectService) SearchCooperationPro @@ -233,7 +233,7 @@ func (cooperationProjectService *CooperationProjectService) SearchCooperationPro
233 return nil, nil 233 return nil, nil
234 } 234 }
235 235
236 -// 更新共创项目服务 236 +// UpdateCooperationProject 更新共创项目服务
237 func (cooperationProjectService *CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) { 237 func (cooperationProjectService *CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
238 if err := updateCooperationProjectCommand.ValidateCommand(); err != nil { 238 if err := updateCooperationProjectCommand.ValidateCommand(); err != nil {
239 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 239 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -85,3 +85,19 @@ func CreateCreditAccountRepository(options map[string]interface{}) (domain.Credi @@ -85,3 +85,19 @@ func CreateCreditAccountRepository(options map[string]interface{}) (domain.Credi
85 } 85 }
86 return repository.NewCreditAccountRepository(transactionContext) 86 return repository.NewCreditAccountRepository(transactionContext)
87 } 87 }
  88 +
  89 +func CreateDividendsOrderRepository(options map[string]interface{}) (domain.DividendsOrderRepository, error) {
  90 + var transactionContext *pg.TransactionContext
  91 + if value, ok := options["transactionContext"]; ok {
  92 + transactionContext = value.(*pg.TransactionContext)
  93 + }
  94 + return repository.NewDividendsOrderRepository(transactionContext)
  95 +}
  96 +
  97 +func CreateDividendsReturnedOrderRepository(options map[string]interface{}) (domain.DividendsReturnedOrderRepository, error) {
  98 + var transactionContext *pg.TransactionContext
  99 + if value, ok := options["transactionContext"]; ok {
  100 + transactionContext = value.(*pg.TransactionContext)
  101 + }
  102 + return repository.NewDividendsReturnedOrderRepository(transactionContext)
  103 +}
  1 +package domain
  2 +
  3 +// AnnualDividendsExpenseDto 企业年度分红总支出
  4 +type AnnualDividendsExpenseDto struct {
  5 + // 总支出
  6 + TotalExpense float64 `json:"totalExpense"`
  7 + // 企业分红支出明细
  8 + DividendsExpenseDetail *DividendsExpenseDetail `json:"dividendsExpenseDetail"`
  9 +}
1 package domain 1 package domain
2 2
3 -// 附件对象 3 +// Attachment 附件对象
4 type Attachment struct { 4 type Attachment struct {
5 // 附件文件类型,jpg,pdf 5 // 附件文件类型,jpg,pdf
6 FileType string `json:"fileType"` 6 FileType string `json:"fileType"`
1 package domain 1 package domain
2 2
3 -// 公司值对象 3 +// Company 公司值对象
4 type Company struct { 4 type Company struct {
5 // 公司ID,通过集成REST上下文获取 5 // 公司ID,通过集成REST上下文获取
6 CompanyId int64 `json:"companyId,string"` 6 CompanyId int64 `json:"companyId,string"`
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 承接人反馈信息 5 +// ContractUndertakerFeedback 承接人反馈信息
6 type ContractUndertakerFeedback struct { 6 type ContractUndertakerFeedback struct {
7 // 合约承接方反馈记录ID 7 // 合约承接方反馈记录ID
8 FeedbackId int64 `json:"feedbackId,string"` 8 FeedbackId int64 `json:"feedbackId,string"`
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 共创申请实体 5 +// CooperationApplication 共创申请实体
6 type CooperationApplication struct { 6 type CooperationApplication struct {
7 // 共创申请ID 7 // 共创申请ID
8 CooperationApplicationId int64 `json:"cooperationApplicationId,string"` 8 CooperationApplicationId int64 `json:"cooperationApplicationId,string"`
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 共创项目合约实体 5 +// CooperationContract 共创项目合约实体
6 type CooperationContract struct { 6 type CooperationContract struct {
7 // 共创合约ID 7 // 共创合约ID
8 CooperationContractId int64 `json:"cooperationContractId,string"` 8 CooperationContractId int64 `json:"cooperationContractId,string"`
  1 +package domain
  2 +
  3 +// CooperationContractByUndertaker 根据承接人返回共创项目合约
  4 +type CooperationContractByUndertaker struct {
  5 + // 共创合约ID
  6 + CooperationContractId int64 `json:"cooperationContractId,string"`
  7 + // 共创合约描述
  8 + CooperationContractDescription string `json:"cooperationContractDescription"`
  9 + // 共创合约编号
  10 + CooperationContractNumber string `json:"cooperationContractNumber"`
  11 + // 共创合约名称
  12 + CooperationContractName string `json:"cooperationContractName"`
  13 + // 共创模式
  14 + CooperationMode *CooperationMode `json:"cooperationMode"`
  15 + // 共创合约发起人
  16 + CooperationContractSponsor *User `json:"cooperationContractSponsor"`
  17 + // 状态
  18 + Status int32 `json:"status"`
  19 + // 共创合约承接人
  20 + ContractUndertaker *User `json:"contractUndertaker"`
  21 +}
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 共创合约变更日志 5 +// CooperationContractChangeLog 共创合约变更日志
6 type CooperationContractChangeLog struct { 6 type CooperationContractChangeLog struct {
7 // 共创合约变更日志 7 // 共创合约变更日志
8 CooperationContractChangeLogId int64 `json:"cooperationContractChangeLogId,string"` 8 CooperationContractChangeLogId int64 `json:"cooperationContractChangeLogId,string"`
  1 +package domain
  2 +
  3 +// CooperationGoodsStatisticsDto 共创产品统计
  4 +type CooperationGoodsStatisticsDto struct {
  5 + // 共创产品总金额统计
  6 + GoodAmount float64 `json:"goodAmount"`
  7 + // 共创产品名称
  8 + GoodName string `json:"goodName"`
  9 + // 共创产品在TOP5中的占比统计
  10 + GoodRatio float64 `json:"goodRatio"`
  11 + // 排名
  12 + Rank int32 `json:"rank"`
  13 +}
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 共创模式实体 5 +// CooperationMode 共创模式实体
6 type CooperationMode struct { 6 type CooperationMode struct {
7 // 共创模式ID 7 // 共创模式ID
8 CooperationModeId int64 `json:"cooperationModeId,string"` 8 CooperationModeId int64 `json:"cooperationModeId,string"`
@@ -54,30 +54,6 @@ func (cooperationMode *CooperationMode) Update(data map[string]interface{}) erro @@ -54,30 +54,6 @@ func (cooperationMode *CooperationMode) Update(data map[string]interface{}) erro
54 if status, ok := data["status"]; ok { 54 if status, ok := data["status"]; ok {
55 cooperationMode.Status = status.(int32) 55 cooperationMode.Status = status.(int32)
56 } 56 }
57 - if orgId, ok := data["orgId"]; ok {  
58 - cooperationMode.Org.OrgId = orgId.(int64)  
59 - }  
60 - if orgName, ok := data["orgName"]; ok {  
61 - cooperationMode.Org.OrgName = orgName.(string)  
62 - }  
63 - if companyId, ok := data["companyId"]; ok {  
64 - cooperationMode.Org.Company.CompanyId = companyId.(int64)  
65 - }  
66 - if companyLogo, ok := data["companyLogo"]; ok {  
67 - cooperationMode.Org.Company.CompanyLogo = companyLogo.(string)  
68 - }  
69 - if companyName, ok := data["companyName"]; ok {  
70 - cooperationMode.Org.Company.CompanyName = companyName.(string)  
71 - }  
72 - if companyId, ok := data["companyId"]; ok {  
73 - cooperationMode.Company.CompanyId = companyId.(int64)  
74 - }  
75 - if companyLogo, ok := data["companyLogo"]; ok {  
76 - cooperationMode.Company.CompanyLogo = companyLogo.(string)  
77 - }  
78 - if companyName, ok := data["companyName"]; ok {  
79 - cooperationMode.Company.CompanyName = companyName.(string)  
80 - }  
81 if remarks, ok := data["remarks"]; ok { 57 if remarks, ok := data["remarks"]; ok {
82 cooperationMode.Remarks = remarks.(string) 58 cooperationMode.Remarks = remarks.(string)
83 } 59 }
@@ -87,83 +63,14 @@ func (cooperationMode *CooperationMode) Update(data map[string]interface{}) erro @@ -87,83 +63,14 @@ func (cooperationMode *CooperationMode) Update(data map[string]interface{}) erro
87 if userBaseId, ok := data["userBaseId"]; ok { 63 if userBaseId, ok := data["userBaseId"]; ok {
88 cooperationMode.Operator.UserBaseId = userBaseId.(int64) 64 cooperationMode.Operator.UserBaseId = userBaseId.(int64)
89 } 65 }
90 - if orgId, ok := data["orgId"]; ok {  
91 - cooperationMode.Operator.Org.OrgId = orgId.(int64)  
92 - }  
93 - if orgName, ok := data["orgName"]; ok {  
94 - cooperationMode.Operator.Org.OrgName = orgName.(string)  
95 - }  
96 - if companyId, ok := data["companyId"]; ok {  
97 - cooperationMode.Operator.Org.Company.CompanyId = companyId.(int64)  
98 - }  
99 - if companyLogo, ok := data["companyLogo"]; ok {  
100 - cooperationMode.Operator.Org.Company.CompanyLogo = companyLogo.(string)  
101 - }  
102 - if companyName, ok := data["companyName"]; ok {  
103 - cooperationMode.Operator.Org.Company.CompanyName = companyName.(string)  
104 - }  
105 if orgs, ok := data["orgs"]; ok { 66 if orgs, ok := data["orgs"]; ok {
106 cooperationMode.Operator.Orgs = orgs.([]*Org) 67 cooperationMode.Operator.Orgs = orgs.([]*Org)
107 } 68 }
108 - if departmentId, ok := data["departmentId"]; ok {  
109 - cooperationMode.Operator.Department.DepartmentId = departmentId.(int64)  
110 - }  
111 - if departmentName, ok := data["departmentName"]; ok {  
112 - cooperationMode.Operator.Department.DepartmentName = departmentName.(string)  
113 - }  
114 - if departmentNumber, ok := data["departmentNumber"]; ok {  
115 - cooperationMode.Operator.Department.DepartmentNumber = departmentNumber.(string)  
116 - }  
117 - if isOrganization, ok := data["isOrganization"]; ok {  
118 - cooperationMode.Operator.Department.IsOrganization = isOrganization.(bool)  
119 - }  
120 if roleId, ok := data["roleId"]; ok { 69 if roleId, ok := data["roleId"]; ok {
121 cooperationMode.Operator.Role.RoleId = roleId.(int64) 70 cooperationMode.Operator.Role.RoleId = roleId.(int64)
122 } 71 }
123 if roleName, ok := data["roleName"]; ok { 72 if roleName, ok := data["roleName"]; ok {
124 cooperationMode.Operator.Role.RoleName = roleName.(string) 73 cooperationMode.Operator.Role.RoleName = roleName.(string)
125 } 74 }
126 - if userAvatar, ok := data["userAvatar"]; ok {  
127 - cooperationMode.Operator.UserInfo.UserAvatar = userAvatar.(string)  
128 - }  
129 - if userEmail, ok := data["userEmail"]; ok {  
130 - cooperationMode.Operator.UserInfo.UserEmail = userEmail.(string)  
131 - }  
132 - if userName, ok := data["userName"]; ok {  
133 - cooperationMode.Operator.UserInfo.UserName = userName.(string)  
134 - }  
135 - if userPhone, ok := data["userPhone"]; ok {  
136 - cooperationMode.Operator.UserInfo.UserPhone = userPhone.(string)  
137 - }  
138 - if userAccount, ok := data["userAccount"]; ok {  
139 - cooperationMode.Operator.UserInfo.UserAccount = userAccount.(string)  
140 - }  
141 - if userType, ok := data["userType"]; ok {  
142 - cooperationMode.Operator.UserType = userType.(int32)  
143 - }  
144 - if status, ok := data["status"]; ok {  
145 - cooperationMode.Operator.Status = status.(int32)  
146 - }  
147 - if companyId, ok := data["companyId"]; ok {  
148 - cooperationMode.Operator.Company.CompanyId = companyId.(int64)  
149 - }  
150 - if companyLogo, ok := data["companyLogo"]; ok {  
151 - cooperationMode.Operator.Company.CompanyLogo = companyLogo.(string)  
152 - }  
153 - if companyName, ok := data["companyName"]; ok {  
154 - cooperationMode.Operator.Company.CompanyName = companyName.(string)  
155 - }  
156 - if operateTime, ok := data["operateTime"]; ok {  
157 - cooperationMode.OperateTime = operateTime.(time.Time)  
158 - }  
159 - if updatedAt, ok := data["updatedAt"]; ok {  
160 - cooperationMode.UpdatedAt = updatedAt.(time.Time)  
161 - }  
162 - if deletedAt, ok := data["deletedAt"]; ok {  
163 - cooperationMode.DeletedAt = deletedAt.(time.Time)  
164 - }  
165 - if createdAt, ok := data["createdAt"]; ok {  
166 - cooperationMode.CreatedAt = createdAt.(time.Time)  
167 - }  
168 return nil 75 return nil
169 } 76 }
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// CooperationPersonStatisticsDto 共创人员信息统计
  6 +type CooperationPersonStatisticsDto struct {
  7 + // 共创时间
  8 + CooperationTime time.Time `json:"cooperationTime"`
  9 + // 合伙类型,即共创模式
  10 + CooperationTypes []*CooperationMode `json:"cooperationTypes"`
  11 + // 分红明细
  12 + DividendsDetails *DividendsDetails `json:"dividendsDetails"`
  13 + // 订单明细
  14 + OrderDetails *OrderDetails `json:"orderDetails"`
  15 + // 共创人员姓名
  16 + UserName string `json:"userName"`
  17 +}
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 共创项目实体 5 +// CooperationProject 共创项目实体
6 type CooperationProject struct { 6 type CooperationProject struct {
7 // 共创项目ID 7 // 共创项目ID
8 CooperationProjectId int64 `json:"cooperationProjectId,string"` 8 CooperationProjectId int64 `json:"cooperationProjectId,string"`
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 账期结算单实体 5 +// CreditAccount 账期结算单实体
6 type CreditAccount struct { 6 type CreditAccount struct {
7 // 账期结算单ID 7 // 账期结算单ID
8 CreditAccountId int64 `json:"creditAccountId,string"` 8 CreditAccountId int64 `json:"creditAccountId,string"`
1 package domain 1 package domain
2 2
3 -// 部门值对象 3 +// Department 部门值对象
4 type Department struct { 4 type Department struct {
5 // 部门ID,通过REST集成上下文获取 5 // 部门ID,通过REST集成上下文获取
6 DepartmentId int64 `json:"departmentId,string"` 6 DepartmentId int64 `json:"departmentId,string"`
1 package domain 1 package domain
2 2
3 -// 分红明细 3 +// DividendsDetails 分红明细
4 type DividendsDetails struct { 4 type DividendsDetails struct {
5 // 分红支出 5 // 分红支出
6 DividendsExpense float64 `json:"dividendsExpense"` 6 DividendsExpense float64 `json:"dividendsExpense"`
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 分红预算实体 5 +// DividendsEstimate 分红预算实体
6 type DividendsEstimate struct { 6 type DividendsEstimate struct {
7 // 承接人分红预算记录ID 7 // 承接人分红预算记录ID
8 DividendsEstimateId int64 `json:"dividendsEstimateId,string"` 8 DividendsEstimateId int64 `json:"dividendsEstimateId,string"`
1 package domain 1 package domain
2 2
3 -// 具体分红类型支出 3 +// DividendsExpenseByType 具体分红类型支出
4 type DividendsExpenseByType struct { 4 type DividendsExpenseByType struct {
5 // 具体分红类型支出 5 // 具体分红类型支出
6 DividendsExpenseByType string `json:"dividendsExpenseByType"` 6 DividendsExpenseByType string `json:"dividendsExpenseByType"`
  1 +package domain
  2 +
  3 +// DividendsExpenseDetail 企业分红支出明细
  4 +type DividendsExpenseDetail struct {
  5 + // 待结算
  6 + ToBeAccounted float64 `json:"toBeAccounted"`
  7 + // 已结算
  8 + Accounted float64 `json:"accounted"`
  9 + // 已支付
  10 + Paid float64 `json:"paid"`
  11 +}
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 金额激励规则实体 5 +// DividendsIncentivesRule 金额激励规则实体
6 type DividendsIncentivesRule struct { 6 type DividendsIncentivesRule struct {
7 // 分红规则ID 7 // 分红规则ID
8 DividendsIncentivesRuleId int64 `json:"dividendsIncentivesRuleId,string"` 8 DividendsIncentivesRuleId int64 `json:"dividendsIncentivesRuleId,string"`
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// 分红订单实体
  6 +type DividendsOrder struct {
  7 + // 分红订单ID
  8 + DividendsOrderId int64 `json:"dividendsOrderId,string"`
  9 + // 分红订单号
  10 + DividendsOrderNumber int64 `json:"dividendsOrderNumber,string"`
  11 + // 分红订单原单号
  12 + DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
  13 + // 分红订单金额
  14 + DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
  15 + // 订单业务员
  16 + OrderSalesman *User `json:"orderSalesman"`
  17 + // 订单产生时间
  18 + OrderTime time.Time `json:"orderTime"`
  19 + // 分红订单分红时间
  20 + DividendTime time.Time `json:"dividendTime"`
  21 + // 分红订单分红状态,1待分红,2已分红,3部分分红
  22 + DividendStatus int32 `json:"dividendStatus"`
  23 + // 区域
  24 + Region *RegionInfo `json:"region"`
  25 + // 客户姓名
  26 + CustomerName string `json:"customerName"`
  27 + // 数据所属组织机构
  28 + Org *Org `json:"org"`
  29 + // 公司
  30 + Company *Company `json:"company"`
  31 + // 创建时间
  32 + CreatedAt time.Time `json:"createdAt"`
  33 + // 删除时间
  34 + DeletedAt time.Time `json:"deletedAt"`
  35 + // 更新时间
  36 + UpdatedAt time.Time `json:"updatedAt"`
  37 + // 操作时间
  38 + OperateTime time.Time `json:"operateTime"`
  39 + // 操作人
  40 + Operator *User `json:"operator"`
  41 +}
  42 +
  43 +type DividendsOrderRepository interface {
  44 + Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
  45 + Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
  46 + FindOne(queryOptions map[string]interface{}) (*DividendsOrder, error)
  47 + Find(queryOptions map[string]interface{}) (int64, []*DividendsOrder, error)
  48 +}
  49 +
  50 +func (dividendsOrder *DividendsOrder) Identify() interface{} {
  51 + if dividendsOrder.DividendsOrderId == 0 {
  52 + return nil
  53 + }
  54 + return dividendsOrder.DividendsOrderId
  55 +}
  56 +
  57 +func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error {
  58 + if dividendsOrderNumber, ok := data["dividendsOrderNumber"]; ok {
  59 + dividendsOrder.DividendsOrderNumber = dividendsOrderNumber.(int64)
  60 + }
  61 + if dividendsOriginalOrderNum, ok := data["dividendsOriginalOrderNum"]; ok {
  62 + dividendsOrder.DividendsOriginalOrderNum = dividendsOriginalOrderNum.(string)
  63 + }
  64 + if dividendsOrderAmount, ok := data["dividendsOrderAmount"]; ok {
  65 + dividendsOrder.DividendsOrderAmount = dividendsOrderAmount.(float64)
  66 + }
  67 + if userId, ok := data["userId"]; ok {
  68 + dividendsOrder.OrderSalesman.UserId = userId.(int64)
  69 + }
  70 + if userBaseId, ok := data["userBaseId"]; ok {
  71 + dividendsOrder.OrderSalesman.UserBaseId = userBaseId.(int64)
  72 + }
  73 + if orgId, ok := data["orgId"]; ok {
  74 + dividendsOrder.OrderSalesman.Org.OrgId = orgId.(int64)
  75 + }
  76 + if orgName, ok := data["orgName"]; ok {
  77 + dividendsOrder.OrderSalesman.Org.OrgName = orgName.(string)
  78 + }
  79 + if companyId, ok := data["companyId"]; ok {
  80 + dividendsOrder.OrderSalesman.Org.Company.CompanyId = companyId.(int64)
  81 + }
  82 + if companyLogo, ok := data["companyLogo"]; ok {
  83 + dividendsOrder.OrderSalesman.Org.Company.CompanyLogo = companyLogo.(string)
  84 + }
  85 + if companyName, ok := data["companyName"]; ok {
  86 + dividendsOrder.OrderSalesman.Org.Company.CompanyName = companyName.(string)
  87 + }
  88 + if roleId, ok := data["roleId"]; ok {
  89 + dividendsOrder.OrderSalesman.Role.RoleId = roleId.(int64)
  90 + }
  91 + if roleName, ok := data["roleName"]; ok {
  92 + dividendsOrder.OrderSalesman.Role.RoleName = roleName.(string)
  93 + }
  94 + if userAvatar, ok := data["userAvatar"]; ok {
  95 + dividendsOrder.OrderSalesman.UserInfo.UserAvatar = userAvatar.(string)
  96 + }
  97 + if userEmail, ok := data["userEmail"]; ok {
  98 + dividendsOrder.OrderSalesman.UserInfo.UserEmail = userEmail.(string)
  99 + }
  100 + if userName, ok := data["userName"]; ok {
  101 + dividendsOrder.OrderSalesman.UserInfo.UserName = userName.(string)
  102 + }
  103 + if userPhone, ok := data["userPhone"]; ok {
  104 + dividendsOrder.OrderSalesman.UserInfo.UserPhone = userPhone.(string)
  105 + }
  106 + if userAccount, ok := data["userAccount"]; ok {
  107 + dividendsOrder.OrderSalesman.UserInfo.UserAccount = userAccount.(string)
  108 + }
  109 + if userType, ok := data["userType"]; ok {
  110 + dividendsOrder.OrderSalesman.UserType = userType.(int32)
  111 + }
  112 + if status, ok := data["status"]; ok {
  113 + dividendsOrder.OrderSalesman.Status = status.(int32)
  114 + }
  115 + if orderTime, ok := data["orderTime"]; ok {
  116 + dividendsOrder.OrderTime = orderTime.(time.Time)
  117 + }
  118 + if dividendTime, ok := data["dividendTime"]; ok {
  119 + dividendsOrder.DividendTime = dividendTime.(time.Time)
  120 + }
  121 + if dividendStatus, ok := data["dividendStatus"]; ok {
  122 + dividendsOrder.DividendStatus = dividendStatus.(int32)
  123 + }
  124 + if regionNumber, ok := data["regionNumber"]; ok {
  125 + dividendsOrder.Region.RegionNumber = regionNumber.(string)
  126 + }
  127 + if regionName, ok := data["regionName"]; ok {
  128 + dividendsOrder.Region.RegionName = regionName.(string)
  129 + }
  130 + if customerName, ok := data["customerName"]; ok {
  131 + dividendsOrder.CustomerName = customerName.(string)
  132 + }
  133 + return nil
  134 +}
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// DividendsReturnedOrder 分红退货单实体
  6 +type DividendsReturnedOrder struct {
  7 + // 分红退货单记录ID
  8 + DividendsReturnedOrderId int64 `json:"dividendsReturnedOrderId"`
  9 + // 分红退货单号
  10 + DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber"`
  11 + // 退货金额
  12 + DividendsReturnedOrderRefund float64 `json:"dividendsReturnedOrderRefund"`
  13 + // 源单号(原始订单号)
  14 + OriginalOrderNum string `json:"originalOrderNum"`
  15 + // 关联分红订单号
  16 + DividendsOrderNumber int64 `json:"dividendsOrderNumber,string"`
  17 + // 退货客户姓名
  18 + DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"`
  19 + // 退货日期
  20 + DividendsReturnedDate time.Time `json:"dividendsReturnedDate"`
  21 + // 退货区域
  22 + Region *RegionInfo `json:"region"`
  23 + // 备注
  24 + Remarks string `json:"remarks"`
  25 + // 分红订单分红状态,1待分红,2已分红,3部分分红
  26 + DividendStatus int32 `json:"dividendStatus"`
  27 + // 分红订单分红时间
  28 + DividendTime time.Time `json:"dividendTime"`
  29 + // 数据所属组织机构
  30 + Org *Org `json:"org"`
  31 + // 公司
  32 + Company *Company `json:"company"`
  33 + // 创建时间
  34 + CreatedAt time.Time `json:"createdAt"`
  35 + // 删除时间
  36 + DeletedAt time.Time `json:"deletedAt"`
  37 + // 更新时间
  38 + UpdatedAt time.Time `json:"updatedAt"`
  39 + // 操作人
  40 + Operator *User `json:"operator"`
  41 + // 操作时间
  42 + OperateTime time.Time `json:"operateTime"`
  43 +}
  44 +
  45 +type DividendsReturnedOrderRepository interface {
  46 + Save(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error)
  47 + Remove(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error)
  48 + FindOne(queryOptions map[string]interface{}) (*DividendsReturnedOrder, error)
  49 + Find(queryOptions map[string]interface{}) (int64, []*DividendsReturnedOrder, error)
  50 +}
  51 +
  52 +func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} {
  53 + if dividendsReturnedOrder.DividendsReturnedOrderId == 0 {
  54 + return nil
  55 + }
  56 + return dividendsReturnedOrder.DividendsReturnedOrderId
  57 +}
  58 +
  59 +func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error {
  60 + if dividendsReturnedOrderNumber, ok := data["dividendsReturnedOrderNumber"]; ok {
  61 + dividendsReturnedOrder.DividendsReturnedOrderNumber = dividendsReturnedOrderNumber.(string)
  62 + }
  63 + if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok {
  64 + dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64)
  65 + }
  66 + if originalOrderNum, ok := data["originalOrderNum"]; ok {
  67 + dividendsReturnedOrder.OriginalOrderNum = originalOrderNum.(string)
  68 + }
  69 + if dividendsOrderNumber, ok := data["dividendsOrderNumber"]; ok {
  70 + dividendsReturnedOrder.DividendsOrderNumber = dividendsOrderNumber.(int64)
  71 + }
  72 + if dividendsReturnedCustomerName, ok := data["dividendsReturnedCustomerName"]; ok {
  73 + dividendsReturnedOrder.DividendsReturnedCustomerName = dividendsReturnedCustomerName.(string)
  74 + }
  75 + if dividendsReturnedDate, ok := data["dividendsReturnedDate"]; ok {
  76 + dividendsReturnedOrder.DividendsReturnedDate = dividendsReturnedDate.(time.Time)
  77 + }
  78 + if regionNumber, ok := data["regionNumber"]; ok {
  79 + dividendsReturnedOrder.Region.RegionNumber = regionNumber.(string)
  80 + }
  81 + if regionName, ok := data["regionName"]; ok {
  82 + dividendsReturnedOrder.Region.RegionName = regionName.(string)
  83 + }
  84 + if remarks, ok := data["remarks"]; ok {
  85 + dividendsReturnedOrder.Remarks = remarks.(string)
  86 + }
  87 + if dividendStatus, ok := data["dividendStatus"]; ok {
  88 + dividendsReturnedOrder.DividendStatus = dividendStatus.(int32)
  89 + }
  90 + if dividendTime, ok := data["dividendTime"]; ok {
  91 + dividendsReturnedOrder.DividendTime = dividendTime.(time.Time)
  92 + }
  93 + if orgId, ok := data["orgId"]; ok {
  94 + dividendsReturnedOrder.Org.OrgId = orgId.(int64)
  95 + }
  96 + if roleId, ok := data["roleId"]; ok {
  97 + dividendsReturnedOrder.Operator.Role.RoleId = roleId.(int64)
  98 + }
  99 + if roleName, ok := data["roleName"]; ok {
  100 + dividendsReturnedOrder.Operator.Role.RoleName = roleName.(string)
  101 + }
  102 + if userType, ok := data["userType"]; ok {
  103 + dividendsReturnedOrder.Operator.UserType = userType.(int32)
  104 + }
  105 + if status, ok := data["status"]; ok {
  106 + dividendsReturnedOrder.Operator.Status = status.(int32)
  107 + }
  108 + return nil
  109 +}
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -// 金额激励规则实体 5 +// MoneyIncentivesRule 金额激励规则实体
6 type MoneyIncentivesRule struct { 6 type MoneyIncentivesRule struct {
7 // 金额激励规则ID 7 // 金额激励规则ID
8 MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string"` 8 MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string"`
  1 +package domain
  2 +
  3 +// 订单明细
  4 +type OrderDetails struct {
  5 + // 订单金额统计
  6 + OrderAmount float64 `json:"orderAmount"`
  7 + // 具体订单类型的金额明细
  8 + OrderAmountByTypes []*OrderAmountByType `json:"orderAmountByTypes"`
  9 +}
1 package domain 1 package domain
2 2
3 -// 组织机构值对象 3 +// Org 组织机构值对象
4 type Org struct { 4 type Org struct {
5 // 组织机构ID 5 // 组织机构ID
6 OrgId int64 `json:"orgId,string"` 6 OrgId int64 `json:"orgId,string"`
1 package domain 1 package domain
2 2
3 -// 推荐人值对象 3 +// Referrer 推荐人值对象
4 type Referrer struct { 4 type Referrer struct {
5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
6 UserId int64 `json:"userId,string"` 6 UserId int64 `json:"userId,string"`
1 package domain 1 package domain
2 2
3 -// 区域信息值对象 3 +// RegionInfo 区域信息值对象
4 type RegionInfo struct { 4 type RegionInfo struct {
5 // 区域编号 5 // 区域编号
6 RegionNumber string `json:"regionNumber"` 6 RegionNumber string `json:"regionNumber"`
1 package domain 1 package domain
2 2
3 -// 共创合约相关人值对象 3 +// Relevant 共创合约相关人值对象
4 type Relevant struct { 4 type Relevant struct {
5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
6 UserId int64 `json:"userId,string"` 6 UserId int64 `json:"userId,string"`
1 package domain 1 package domain
2 2
3 -// 用户角色值对象 3 +// Role 用户角色值对象
4 type Role struct { 4 type Role struct {
5 // 角色ID 5 // 角色ID
6 RoleId int64 `json:"roleId,string"` 6 RoleId int64 `json:"roleId,string"`
1 package domain 1 package domain
2 2
3 -// 业务员值对象 3 +// Salesman 业务员值对象
4 type Salesman struct { 4 type Salesman struct {
5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
6 UserId int64 `json:"userId,string"` 6 UserId int64 `json:"userId,string"`
1 package domain 1 package domain
2 2
3 -// 共创合约承接方值对象 3 +// Undertaker 共创合约承接方值对象
4 type Undertaker struct { 4 type Undertaker struct {
5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
6 UserId int64 `json:"userId,string"` 6 UserId int64 `json:"userId,string"`
1 package domain 1 package domain
2 2
3 -// 用户第三方服务防腐模型 3 +// User 用户第三方服务防腐模型
4 type User struct { 4 type User struct {
5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
6 UserId int64 `json:"userId,string"` 6 UserId int64 `json:"userId,string"`
1 package domain 1 package domain
2 2
3 -// 用户信息值对象 3 +// UserInfo 用户信息值对象
4 type UserInfo struct { 4 type UserInfo struct {
5 // 用户头像 5 // 用户头像
6 UserAvatar string `json:"userAvatar"` 6 UserAvatar string `json:"userAvatar"`
  1 +package models
  2 +
  3 +type DividendsOrder struct {
  4 + tableName string `comment:"分红订单实体" pg:"dividends_orders,alias:dividends_order"`
  5 + // 分红订单ID
  6 + DividendsOrderId int64 `comment:"分红订单ID" pg:"pk:dividends_order_id"`
  7 + // 分红订单号
  8 + DividendsOrderNumber int64 `comment:"分红订单号"`
  9 + // 分红订单原单号
  10 + DividendsOriginalOrderNum string `comment:"分红订单原单号"`
  11 + // 分红订单金额
  12 + DividendsOrderAmount float64 `comment:"分红订单金额"`
  13 + // 订单业务员
  14 + OrderSalesman *User `comment:"订单业务员"`
  15 + // 订单产生时间
  16 + OrderTime time.Time `comment:"订单产生时间"`
  17 + // 分红订单分红时间
  18 + DividendTime time.Time `comment:"分红订单分红时间"`
  19 + // 分红订单分红状态,1待分红,2已分红,3部分分红
  20 + DividendStatus int32 `comment:"分红订单分红状态,1待分红,2已分红,3部分分红"`
  21 + // 区域
  22 + Region *RegionInfo `comment:"区域"`
  23 + // 客户姓名
  24 + CustomerName string `comment:"客户姓名"`
  25 + // 数据所属组织机构
  26 + Org *Org `comment:"数据所属组织机构"`
  27 + // 公司
  28 + Company *Company `comment:"公司"`
  29 + // 创建时间
  30 + CreatedAt time.Time `comment:"创建时间"`
  31 + // 删除时间
  32 + DeletedAt time.Time `comment:"删除时间"`
  33 + // 更新时间
  34 + UpdatedAt time.Time `comment:"更新时间"`
  35 + // 操作时间
  36 + OperateTime time.Time `comment:"操作时间"`
  37 + // 操作人
  38 + Operator *User `comment:"操作人"`
  39 +}
  1 +package models
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  5 + "time"
  6 +)
  7 +
  8 +type DividendsReturnedOrder struct {
  9 + tableName string `comment:"分红退货单实体" pg:"dividends_returned_orders,alias:dividends_returned_order"`
  10 + // 分红退货单记录ID
  11 + DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:"pk:dividends_returned_order_id"`
  12 + // 分红退货单号
  13 + DividendsReturnedOrderNumber string `comment:"分红退货单号"`
  14 + // 退货金额
  15 + DividendsReturnedOrderRefund float64 `comment:"退货金额"`
  16 + // 源单号(原始订单号)
  17 + OriginalOrderNum string `comment:"源单号(原始订单号)"`
  18 + // 关联分红订单号
  19 + DividendsOrderNumber int64 `comment:"关联分红订单号"`
  20 + // 退货客户姓名
  21 + DividendsReturnedCustomerName string `comment:"退货客户姓名"`
  22 + // 退货日期
  23 + DividendsReturnedDate time.Time `comment:"退货日期"`
  24 + // 退货区域
  25 + Region *domain.RegionInfo `comment:"退货区域"`
  26 + // 备注
  27 + Remarks string `comment:"备注"`
  28 + // 分红订单分红状态,1待分红,2已分红,3部分分红
  29 + DividendStatus int32 `comment:"分红订单分红状态,1待分红,2已分红,3部分分红"`
  30 + // 分红订单分红时间
  31 + DividendTime time.Time `comment:"分红订单分红时间"`
  32 + // 数据所属组织机构
  33 + Org *domain.Org `comment:"数据所属组织机构"`
  34 + // 公司
  35 + Company *domain.Company `comment:"公司"`
  36 + // 创建时间
  37 + CreatedAt time.Time `comment:"创建时间"`
  38 + // 删除时间
  39 + DeletedAt time.Time `comment:"删除时间"`
  40 + // 更新时间
  41 + UpdatedAt time.Time `comment:"更新时间"`
  42 + // 操作人
  43 + Operator *domain.User `comment:"操作人"`
  44 + // 操作时间
  45 + OperateTime time.Time `comment:"操作时间"`
  46 +}
  1 +package transform
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
  6 +)
  7 +
  8 +func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *models.DividendsOrder) (*domain.DividendsOrder, error) {
  9 + return &domain.DividendsOrder{
  10 + DividendsOrderId: dividendsOrderModel.DividendsOrderId,
  11 + DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber,
  12 + DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum,
  13 + DividendsOrderAmount: dividendsOrderModel.DividendsOrderAmount,
  14 + OrderSalesman: dividendsOrderModel.OrderSalesman,
  15 + OrderTime: dividendsOrderModel.OrderTime,
  16 + DividendTime: dividendsOrderModel.DividendTime,
  17 + DividendStatus: dividendsOrderModel.DividendStatus,
  18 + Region: dividendsOrderModel.Region,
  19 + CustomerName: dividendsOrderModel.CustomerName,
  20 + Org: dividendsOrderModel.Org,
  21 + Company: dividendsOrderModel.Company,
  22 + CreatedAt: dividendsOrderModel.CreatedAt,
  23 + DeletedAt: dividendsOrderModel.DeletedAt,
  24 + UpdatedAt: dividendsOrderModel.UpdatedAt,
  25 + OperateTime: dividendsOrderModel.OperateTime,
  26 + Operator: dividendsOrderModel.Operator,
  27 + }, nil
  28 +}
  1 +package transform
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
  6 +)
  7 +
  8 +func TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel *models.DividendsReturnedOrder) (*domain.DividendsReturnedOrder, error) {
  9 + return &domain.DividendsReturnedOrder{
  10 + DividendsReturnedOrderId: dividendsReturnedOrderModel.DividendsReturnedOrderId,
  11 + DividendsReturnedOrderNumber: dividendsReturnedOrderModel.DividendsReturnedOrderNumber,
  12 + DividendsReturnedOrderRefund: dividendsReturnedOrderModel.DividendsReturnedOrderRefund,
  13 + OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum,
  14 + DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber,
  15 + DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName,
  16 + DividendsReturnedDate: dividendsReturnedOrderModel.DividendsReturnedDate,
  17 + Region: dividendsReturnedOrderModel.Region,
  18 + Remarks: dividendsReturnedOrderModel.Remarks,
  19 + DividendStatus: dividendsReturnedOrderModel.DividendStatus,
  20 + DividendTime: dividendsReturnedOrderModel.DividendTime,
  21 + Org: dividendsReturnedOrderModel.Org,
  22 + Company: dividendsReturnedOrderModel.Company,
  23 + CreatedAt: dividendsReturnedOrderModel.CreatedAt,
  24 + DeletedAt: dividendsReturnedOrderModel.DeletedAt,
  25 + UpdatedAt: dividendsReturnedOrderModel.UpdatedAt,
  26 + Operator: dividendsReturnedOrderModel.Operator,
  27 + OperateTime: dividendsReturnedOrderModel.OperateTime,
  28 + }, nil
  29 +}
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
  7 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  8 + "github.com/linmadan/egglib-go/utils/snowflake"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform"
  12 +)
  13 +
  14 +type DividendsOrderRepository struct {
  15 + transactionContext *pgTransaction.TransactionContext
  16 +}
  17 +
  18 +func (repository *DividendsOrderRepository) nextIdentify() (int64, error) {
  19 + IdWorker, err := snowflake.NewIdWorker(1)
  20 + if err != nil {
  21 + return 0, err
  22 + }
  23 + id, err := IdWorker.NextId()
  24 + return id, err
  25 +}
  26 +func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.DividendsOrder) (*domain.DividendsOrder, error) {
  27 + sqlBuildFields := []string{
  28 + "dividends_order_id",
  29 + "dividends_order_number",
  30 + "dividends_original_order_num",
  31 + "dividends_order_amount",
  32 + "order_salesman",
  33 + "order_time",
  34 + "dividend_time",
  35 + "dividend_status",
  36 + "region",
  37 + "customer_name",
  38 + "org",
  39 + "company",
  40 + "created_at",
  41 + "deleted_at",
  42 + "updated_at",
  43 + "operate_time",
  44 + "operator",
  45 + }
  46 + insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
  47 + insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
  48 + returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
  49 + updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "dividendsOrder_id")
  50 + updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
  51 + tx := repository.transactionContext.PgTx
  52 + if dividendsOrder.Identify() == nil {
  53 + dividendsOrderId, err := repository.nextIdentify()
  54 + if err != nil {
  55 + return dividendsOrder, err
  56 + } else {
  57 + dividendsOrder.DividendsOrderId = dividendsOrderId
  58 + }
  59 + if _, err := tx.QueryOne(
  60 + pg.Scan(
  61 + &dividendsOrder.DividendsOrderId,
  62 + &dividendsOrder.DividendsOrderNumber,
  63 + &dividendsOrder.DividendsOriginalOrderNum,
  64 + &dividendsOrder.DividendsOrderAmount,
  65 + &dividendsOrder.OrderSalesman,
  66 + &dividendsOrder.OrderTime,
  67 + &dividendsOrder.DividendTime,
  68 + &dividendsOrder.DividendStatus,
  69 + &dividendsOrder.Region,
  70 + &dividendsOrder.CustomerName,
  71 + &dividendsOrder.Org,
  72 + &dividendsOrder.Company,
  73 + &dividendsOrder.CreatedAt,
  74 + &dividendsOrder.DeletedAt,
  75 + &dividendsOrder.UpdatedAt,
  76 + &dividendsOrder.OperateTime,
  77 + &dividendsOrder.Operator,
  78 + ),
  79 + fmt.Sprintf("INSERT INTO dividends_orders (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
  80 + dividendsOrder.DividendsOrderId,
  81 + dividendsOrder.DividendsOrderNumber,
  82 + dividendsOrder.DividendsOriginalOrderNum,
  83 + dividendsOrder.DividendsOrderAmount,
  84 + dividendsOrder.OrderSalesman,
  85 + dividendsOrder.OrderTime,
  86 + dividendsOrder.DividendTime,
  87 + dividendsOrder.DividendStatus,
  88 + dividendsOrder.Region,
  89 + dividendsOrder.CustomerName,
  90 + dividendsOrder.Org,
  91 + dividendsOrder.Company,
  92 + dividendsOrder.CreatedAt,
  93 + dividendsOrder.DeletedAt,
  94 + dividendsOrder.UpdatedAt,
  95 + dividendsOrder.OperateTime,
  96 + dividendsOrder.Operator,
  97 + ); err != nil {
  98 + return dividendsOrder, err
  99 + }
  100 + } else {
  101 + if _, err := tx.QueryOne(
  102 + pg.Scan(
  103 + &dividendsOrder.DividendsOrderId,
  104 + &dividendsOrder.DividendsOrderNumber,
  105 + &dividendsOrder.DividendsOriginalOrderNum,
  106 + &dividendsOrder.DividendsOrderAmount,
  107 + &dividendsOrder.OrderSalesman,
  108 + &dividendsOrder.OrderTime,
  109 + &dividendsOrder.DividendTime,
  110 + &dividendsOrder.DividendStatus,
  111 + &dividendsOrder.Region,
  112 + &dividendsOrder.CustomerName,
  113 + &dividendsOrder.Org,
  114 + &dividendsOrder.Company,
  115 + &dividendsOrder.CreatedAt,
  116 + &dividendsOrder.DeletedAt,
  117 + &dividendsOrder.UpdatedAt,
  118 + &dividendsOrder.OperateTime,
  119 + &dividendsOrder.Operator,
  120 + ),
  121 + fmt.Sprintf("UPDATE dividends_orders SET %s WHERE dividends_order_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
  122 + dividendsOrder.DividendsOrderId,
  123 + dividendsOrder.DividendsOrderNumber,
  124 + dividendsOrder.DividendsOriginalOrderNum,
  125 + dividendsOrder.DividendsOrderAmount,
  126 + dividendsOrder.OrderSalesman,
  127 + dividendsOrder.OrderTime,
  128 + dividendsOrder.DividendTime,
  129 + dividendsOrder.DividendStatus,
  130 + dividendsOrder.Region,
  131 + dividendsOrder.CustomerName,
  132 + dividendsOrder.Org,
  133 + dividendsOrder.Company,
  134 + dividendsOrder.CreatedAt,
  135 + dividendsOrder.DeletedAt,
  136 + dividendsOrder.UpdatedAt,
  137 + dividendsOrder.OperateTime,
  138 + dividendsOrder.Operator,
  139 + dividendsOrder.Identify(),
  140 + ); err != nil {
  141 + return dividendsOrder, err
  142 + }
  143 + }
  144 + return dividendsOrder, nil
  145 +}
  146 +func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.DividendsOrder) (*domain.DividendsOrder, error) {
  147 + tx := repository.transactionContext.PgTx
  148 + dividendsOrderModel := new(models.DividendsOrder)
  149 + dividendsOrderModel.DividendsOrderId = dividendsOrder.Identify().(int64)
  150 + if _, err := tx.Model(dividendsOrderModel).WherePK().Delete(); err != nil {
  151 + return dividendsOrder, err
  152 + }
  153 + return dividendsOrder, nil
  154 +}
  155 +func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsOrder, error) {
  156 + tx := repository.transactionContext.PgTx
  157 + dividendsOrderModel := new(models.DividendsOrder)
  158 + query := sqlbuilder.BuildQuery(tx.Model(dividendsOrderModel), queryOptions)
  159 + query.SetWhereByQueryOption("dividends_order.dividends_order_id = ?", "dividendsOrderId")
  160 + if err := query.First(); err != nil {
  161 + if err.Error() == "pg: no rows in result set" {
  162 + return nil, fmt.Errorf("没有此资源")
  163 + } else {
  164 + return nil, err
  165 + }
  166 + }
  167 + if dividendsOrderModel.DividendsOrderId == 0 {
  168 + return nil, nil
  169 + } else {
  170 + return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel)
  171 + }
  172 +}
  173 +func (repository *DividendsOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsOrder, error) {
  174 + tx := repository.transactionContext.PgTx
  175 + var dividendsOrderModels []*models.DividendsOrder
  176 + dividendsOrders := make([]*domain.DividendsOrder, 0)
  177 + query := sqlbuilder.BuildQuery(tx.Model(&dividendsOrderModels), queryOptions)
  178 + query.SetOffsetAndLimit(20)
  179 + query.SetOrderDirect("dividends_order_id", "DESC")
  180 + if count, err := query.SelectAndCount(); err != nil {
  181 + return 0, dividendsOrders, err
  182 + } else {
  183 + for _, dividendsOrderModel := range dividendsOrderModels {
  184 + if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel); err != nil {
  185 + return 0, dividendsOrders, err
  186 + } else {
  187 + dividendsOrders = append(dividendsOrders, dividendsOrder)
  188 + }
  189 + }
  190 + return int64(count), dividendsOrders, nil
  191 + }
  192 +}
  193 +func NewDividendsOrderRepository(transactionContext *pgTransaction.TransactionContext) (*DividendsOrderRepository, error) {
  194 + if transactionContext == nil {
  195 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  196 + } else {
  197 + return &DividendsOrderRepository{
  198 + transactionContext: transactionContext,
  199 + }, nil
  200 + }
  201 +}
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/go-pg/pg/v10"
  6 +
  7 + "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
  8 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  9 + "github.com/linmadan/egglib-go/utils/snowflake"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
  12 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform"
  13 +)
  14 +
  15 +type DividendsReturnedOrderRepository struct {
  16 + transactionContext *pgTransaction.TransactionContext
  17 +}
  18 +
  19 +func (repository *DividendsReturnedOrderRepository) nextIdentify() (int64, error) {
  20 + IdWorker, err := snowflake.NewIdWorker(1)
  21 + if err != nil {
  22 + return 0, err
  23 + }
  24 + id, err := IdWorker.NextId()
  25 + return id, err
  26 +}
  27 +func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder *domain.DividendsReturnedOrder) (*domain.DividendsReturnedOrder, error) {
  28 + sqlBuildFields := []string{
  29 + "dividends_returned_order_id",
  30 + "dividends_returned_order_number",
  31 + "dividends_returned_order_refund",
  32 + "original_order_num",
  33 + "dividends_order_number",
  34 + "dividends_returned_customer_name",
  35 + "dividends_returned_date",
  36 + "region",
  37 + "remarks",
  38 + "dividend_status",
  39 + "dividend_time",
  40 + "org",
  41 + "company",
  42 + "created_at",
  43 + "deleted_at",
  44 + "updated_at",
  45 + "operator",
  46 + "operate_time",
  47 + }
  48 + insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
  49 + insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
  50 + returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
  51 + updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "dividendsReturnedOrder_id")
  52 + updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
  53 + tx := repository.transactionContext.PgTx
  54 + if dividendsReturnedOrder.Identify() == nil {
  55 + dividendsReturnedOrderId, err := repository.nextIdentify()
  56 + if err != nil {
  57 + return dividendsReturnedOrder, err
  58 + } else {
  59 + dividendsReturnedOrder.DividendsReturnedOrderId = dividendsReturnedOrderId
  60 + }
  61 + if _, err := tx.QueryOne(
  62 + pg.Scan(
  63 + &dividendsReturnedOrder.DividendsReturnedOrderId,
  64 + &dividendsReturnedOrder.DividendsReturnedOrderNumber,
  65 + &dividendsReturnedOrder.DividendsReturnedOrderRefund,
  66 + &dividendsReturnedOrder.OriginalOrderNum,
  67 + &dividendsReturnedOrder.DividendsOrderNumber,
  68 + &dividendsReturnedOrder.DividendsReturnedCustomerName,
  69 + &dividendsReturnedOrder.DividendsReturnedDate,
  70 + &dividendsReturnedOrder.Region,
  71 + &dividendsReturnedOrder.Remarks,
  72 + &dividendsReturnedOrder.DividendStatus,
  73 + &dividendsReturnedOrder.DividendTime,
  74 + &dividendsReturnedOrder.Org,
  75 + &dividendsReturnedOrder.Company,
  76 + &dividendsReturnedOrder.CreatedAt,
  77 + &dividendsReturnedOrder.DeletedAt,
  78 + &dividendsReturnedOrder.UpdatedAt,
  79 + &dividendsReturnedOrder.Operator,
  80 + &dividendsReturnedOrder.OperateTime,
  81 + ),
  82 + fmt.Sprintf("INSERT INTO dividends_returned_orders (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
  83 + dividendsReturnedOrder.DividendsReturnedOrderId,
  84 + dividendsReturnedOrder.DividendsReturnedOrderNumber,
  85 + dividendsReturnedOrder.DividendsReturnedOrderRefund,
  86 + dividendsReturnedOrder.OriginalOrderNum,
  87 + dividendsReturnedOrder.DividendsOrderNumber,
  88 + dividendsReturnedOrder.DividendsReturnedCustomerName,
  89 + dividendsReturnedOrder.DividendsReturnedDate,
  90 + dividendsReturnedOrder.Region,
  91 + dividendsReturnedOrder.Remarks,
  92 + dividendsReturnedOrder.DividendStatus,
  93 + dividendsReturnedOrder.DividendTime,
  94 + dividendsReturnedOrder.Org,
  95 + dividendsReturnedOrder.Company,
  96 + dividendsReturnedOrder.CreatedAt,
  97 + dividendsReturnedOrder.DeletedAt,
  98 + dividendsReturnedOrder.UpdatedAt,
  99 + dividendsReturnedOrder.Operator,
  100 + dividendsReturnedOrder.OperateTime,
  101 + ); err != nil {
  102 + return dividendsReturnedOrder, err
  103 + }
  104 + } else {
  105 + if _, err := tx.QueryOne(
  106 + pg.Scan(
  107 + &dividendsReturnedOrder.DividendsReturnedOrderId,
  108 + &dividendsReturnedOrder.DividendsReturnedOrderNumber,
  109 + &dividendsReturnedOrder.DividendsReturnedOrderRefund,
  110 + &dividendsReturnedOrder.OriginalOrderNum,
  111 + &dividendsReturnedOrder.DividendsOrderNumber,
  112 + &dividendsReturnedOrder.DividendsReturnedCustomerName,
  113 + &dividendsReturnedOrder.DividendsReturnedDate,
  114 + &dividendsReturnedOrder.Region,
  115 + &dividendsReturnedOrder.Remarks,
  116 + &dividendsReturnedOrder.DividendStatus,
  117 + &dividendsReturnedOrder.DividendTime,
  118 + &dividendsReturnedOrder.Org,
  119 + &dividendsReturnedOrder.Company,
  120 + &dividendsReturnedOrder.CreatedAt,
  121 + &dividendsReturnedOrder.DeletedAt,
  122 + &dividendsReturnedOrder.UpdatedAt,
  123 + &dividendsReturnedOrder.Operator,
  124 + &dividendsReturnedOrder.OperateTime,
  125 + ),
  126 + fmt.Sprintf("UPDATE dividends_returned_orders SET %s WHERE dividends_returned_order_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
  127 + dividendsReturnedOrder.DividendsReturnedOrderId,
  128 + dividendsReturnedOrder.DividendsReturnedOrderNumber,
  129 + dividendsReturnedOrder.DividendsReturnedOrderRefund,
  130 + dividendsReturnedOrder.OriginalOrderNum,
  131 + dividendsReturnedOrder.DividendsOrderNumber,
  132 + dividendsReturnedOrder.DividendsReturnedCustomerName,
  133 + dividendsReturnedOrder.DividendsReturnedDate,
  134 + dividendsReturnedOrder.Region,
  135 + dividendsReturnedOrder.Remarks,
  136 + dividendsReturnedOrder.DividendStatus,
  137 + dividendsReturnedOrder.DividendTime,
  138 + dividendsReturnedOrder.Org,
  139 + dividendsReturnedOrder.Company,
  140 + dividendsReturnedOrder.CreatedAt,
  141 + dividendsReturnedOrder.DeletedAt,
  142 + dividendsReturnedOrder.UpdatedAt,
  143 + dividendsReturnedOrder.Operator,
  144 + dividendsReturnedOrder.OperateTime,
  145 + dividendsReturnedOrder.Identify(),
  146 + ); err != nil {
  147 + return dividendsReturnedOrder, err
  148 + }
  149 + }
  150 + return dividendsReturnedOrder, nil
  151 +}
  152 +func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrder *domain.DividendsReturnedOrder) (*domain.DividendsReturnedOrder, error) {
  153 + tx := repository.transactionContext.PgTx
  154 + dividendsReturnedOrderModel := new(models.DividendsReturnedOrder)
  155 + dividendsReturnedOrderModel.DividendsReturnedOrderId = dividendsReturnedOrder.Identify().(int64)
  156 + if _, err := tx.Model(dividendsReturnedOrderModel).WherePK().Delete(); err != nil {
  157 + return dividendsReturnedOrder, err
  158 + }
  159 + return dividendsReturnedOrder, nil
  160 +}
  161 +func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsReturnedOrder, error) {
  162 + tx := repository.transactionContext.PgTx
  163 + dividendsReturnedOrderModel := new(models.DividendsReturnedOrder)
  164 + query := sqlbuilder.BuildQuery(tx.Model(dividendsReturnedOrderModel), queryOptions)
  165 + query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_id = ?", "dividendsReturnedOrderId")
  166 + if err := query.First(); err != nil {
  167 + if err.Error() == "pg: no rows in result set" {
  168 + return nil, fmt.Errorf("没有此资源")
  169 + } else {
  170 + return nil, err
  171 + }
  172 + }
  173 + if dividendsReturnedOrderModel.DividendsReturnedOrderId == 0 {
  174 + return nil, nil
  175 + } else {
  176 + return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel)
  177 + }
  178 +}
  179 +func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsReturnedOrder, error) {
  180 + tx := repository.transactionContext.PgTx
  181 + var dividendsReturnedOrderModels []*models.DividendsReturnedOrder
  182 + dividendsReturnedOrders := make([]*domain.DividendsReturnedOrder, 0)
  183 + query := sqlbuilder.BuildQuery(tx.Model(&dividendsReturnedOrderModels), queryOptions)
  184 + query.SetOffsetAndLimit(20)
  185 + query.SetOrderDirect("dividends_returned_order_id", "DESC")
  186 + if count, err := query.SelectAndCount(); err != nil {
  187 + return 0, dividendsReturnedOrders, err
  188 + } else {
  189 + for _, dividendsReturnedOrderModel := range dividendsReturnedOrderModels {
  190 + if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel); err != nil {
  191 + return 0, dividendsReturnedOrders, err
  192 + } else {
  193 + dividendsReturnedOrders = append(dividendsReturnedOrders, dividendsReturnedOrder)
  194 + }
  195 + }
  196 + return int64(count), dividendsReturnedOrders, nil
  197 + }
  198 +}
  199 +func NewDividendsReturnedOrderRepository(transactionContext *pgTransaction.TransactionContext) (*DividendsReturnedOrderRepository, error) {
  200 + if transactionContext == nil {
  201 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  202 + } else {
  203 + return &DividendsReturnedOrderRepository{
  204 + transactionContext: transactionContext,
  205 + }, nil
  206 + }
  207 +}
@@ -23,8 +23,8 @@ func (controller *ContractUndertakerFeedbackController) UpdateContractUndertaker @@ -23,8 +23,8 @@ func (controller *ContractUndertakerFeedbackController) UpdateContractUndertaker
23 contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil) 23 contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
24 updateContractUndertakerFeedbackCommand := &command.UpdateContractUndertakerFeedbackCommand{} 24 updateContractUndertakerFeedbackCommand := &command.UpdateContractUndertakerFeedbackCommand{}
25 controller.Unmarshal(updateContractUndertakerFeedbackCommand) 25 controller.Unmarshal(updateContractUndertakerFeedbackCommand)
26 - contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")  
27 - updateContractUndertakerFeedbackCommand.ContractUndertakerFeedbackId = contractUndertakerFeedbackId 26 + contractUndertakerFeedbackId := controller.GetString(":contractUndertakerFeedbackId")
  27 + updateContractUndertakerFeedbackCommand.FeedbackId = contractUndertakerFeedbackId
28 data, err := contractUndertakerFeedbackService.UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand) 28 data, err := contractUndertakerFeedbackService.UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand)
29 controller.Response(data, err) 29 controller.Response(data, err)
30 } 30 }
@@ -32,8 +32,8 @@ func (controller *ContractUndertakerFeedbackController) UpdateContractUndertaker @@ -32,8 +32,8 @@ func (controller *ContractUndertakerFeedbackController) UpdateContractUndertaker
32 func (controller *ContractUndertakerFeedbackController) GetContractUndertakerFeedback() { 32 func (controller *ContractUndertakerFeedbackController) GetContractUndertakerFeedback() {
33 contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil) 33 contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
34 getContractUndertakerFeedbackQuery := &query.GetContractUndertakerFeedbackQuery{} 34 getContractUndertakerFeedbackQuery := &query.GetContractUndertakerFeedbackQuery{}
35 - contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")  
36 - getContractUndertakerFeedbackQuery.ContractUndertakerFeedbackId = contractUndertakerFeedbackId 35 + contractUndertakerFeedbackId := controller.GetString(":contractUndertakerFeedbackId")
  36 + getContractUndertakerFeedbackQuery.FeedbackId = contractUndertakerFeedbackId
37 data, err := contractUndertakerFeedbackService.GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery) 37 data, err := contractUndertakerFeedbackService.GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery)
38 controller.Response(data, err) 38 controller.Response(data, err)
39 } 39 }
@@ -42,8 +42,8 @@ func (controller *ContractUndertakerFeedbackController) RemoveContractUndertaker @@ -42,8 +42,8 @@ func (controller *ContractUndertakerFeedbackController) RemoveContractUndertaker
42 contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil) 42 contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
43 removeContractUndertakerFeedbackCommand := &command.RemoveContractUndertakerFeedbackCommand{} 43 removeContractUndertakerFeedbackCommand := &command.RemoveContractUndertakerFeedbackCommand{}
44 controller.Unmarshal(removeContractUndertakerFeedbackCommand) 44 controller.Unmarshal(removeContractUndertakerFeedbackCommand)
45 - contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")  
46 - removeContractUndertakerFeedbackCommand.ContractUndertakerFeedbackId = contractUndertakerFeedbackId 45 + contractUndertakerFeedbackId := controller.GetString(":contractUndertakerFeedbackId")
  46 + removeContractUndertakerFeedbackCommand.FeedbackId = contractUndertakerFeedbackId
47 data, err := contractUndertakerFeedbackService.RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand) 47 data, err := contractUndertakerFeedbackService.RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand)
48 controller.Response(data, err) 48 controller.Response(data, err)
49 } 49 }