正在显示
11 个修改的文件
包含
110 行增加
和
32 行删除
@@ -10,13 +10,9 @@ import ( | @@ -10,13 +10,9 @@ import ( | ||
10 | 10 | ||
11 | type ListCooperationModeQuery struct { | 11 | type ListCooperationModeQuery struct { |
12 | // 页面大小 | 12 | // 页面大小 |
13 | - PageNumber int32 `cname:"页面大小" json:"pageNumber,omitempty"` | 13 | + PageNumber int64 `cname:"页面大小" json:"pageNumber,omitempty"` |
14 | // 页面大小 | 14 | // 页面大小 |
15 | - PageSize int32 `cname:"页面大小" json:"pageSize,omitempty"` | ||
16 | - // 查询偏离量 | ||
17 | - Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
18 | - // 查询限制 | ||
19 | - Limit int `cname:"查询限制" json:"limit" valid:"Required"` | 15 | + PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` |
20 | // 公司ID,通过集成REST上下文获取 | 16 | // 公司ID,通过集成REST上下文获取 |
21 | CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | 17 | CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` |
22 | // 组织机构ID | 18 | // 组织机构ID |
@@ -18,10 +18,10 @@ type CreditAccount struct { | @@ -18,10 +18,10 @@ type CreditAccount struct { | ||
18 | SettlementAmount float64 `json:"settlementAmount"` | 18 | SettlementAmount float64 `json:"settlementAmount"` |
19 | // 共创账期结算时间 | 19 | // 共创账期结算时间 |
20 | SettlementTime time.Time `json:"settlementTime"` | 20 | SettlementTime time.Time `json:"settlementTime"` |
21 | - // 共创合约编号 | 21 | + // 关联共创合约编号 |
22 | CooperationContractNumber string `json:"cooperationContractNumber"` | 22 | CooperationContractNumber string `json:"cooperationContractNumber"` |
23 | // 参与人uid,包括承接人、推荐人、关联业务员 | 23 | // 参与人uid,包括承接人、推荐人、关联业务员 |
24 | - Participator []int64 `json:"participator"` | 24 | + Participator *Participator `json:"participator"` |
25 | // 支付凭证附件 | 25 | // 支付凭证附件 |
26 | PaymentDocumentAttachment *Attachment `json:"paymentDocumentAttachment"` | 26 | PaymentDocumentAttachment *Attachment `json:"paymentDocumentAttachment"` |
27 | // 数据所属组织机构 | 27 | // 数据所属组织机构 |
pkg/domain/participator.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +// Participator 共创参与人 | ||
4 | +type Participator struct { | ||
5 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
6 | + UserId int64 `json:"userId,string"` | ||
7 | + // 用户基本id | ||
8 | + UserBaseId int64 `json:"userBaseId,string"` | ||
9 | + // 用户所属的组织机构 | ||
10 | + Org *Org `json:"org"` | ||
11 | + // 用户关联的组织机构 | ||
12 | + Orgs []*Org `json:"orgs"` | ||
13 | + // 用户所属的部门 | ||
14 | + Department *Department `json:"department"` | ||
15 | + // 用户角色 | ||
16 | + Role *Role `json:"role"` | ||
17 | + // 冗余字段,jsonb格式,不限制存放内容 | ||
18 | + UserInfo *UserInfo `json:"userInfo"` | ||
19 | + // 用户类型,1员工,2共创用户,3公开 | ||
20 | + UserType int32 `json:"userType"` | ||
21 | + // 状态 | ||
22 | + Status int32 `json:"status"` | ||
23 | + // 公司 | ||
24 | + Company *Company `json:"company"` | ||
25 | +} |
@@ -24,7 +24,7 @@ type CreditAccount struct { | @@ -24,7 +24,7 @@ type CreditAccount struct { | ||
24 | // 共创合约编号 | 24 | // 共创合约编号 |
25 | CooperationContractNumber string `comment:"共创合约编号"` | 25 | CooperationContractNumber string `comment:"共创合约编号"` |
26 | // 参与人uid,包括承接人、推荐人、关联业务员 | 26 | // 参与人uid,包括承接人、推荐人、关联业务员 |
27 | - Participator []int64 `comment:"参与人uid,包括承接人、推荐人、关联业务员" pg:",array"` | 27 | + Participator *domain.Participator `comment:"参与人uid,包括承接人、推荐人、关联业务员" pg:",array"` |
28 | // 支付凭证附件 | 28 | // 支付凭证附件 |
29 | PaymentDocumentAttachment *domain.Attachment `comment:"支付凭证附件"` | 29 | PaymentDocumentAttachment *domain.Attachment `comment:"支付凭证附件"` |
30 | // 数据所属组织机构 | 30 | // 数据所属组织机构 |
@@ -223,14 +223,28 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -223,14 +223,28 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
223 | ); err != nil { | 223 | ); err != nil { |
224 | return cooperationContract, err | 224 | return cooperationContract, err |
225 | } | 225 | } |
226 | - // 获取相关人列表 | ||
227 | - var cooperationContractRelevantModels []*models.CooperationContractRelevant | ||
228 | - cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels) | 226 | + |
227 | + // 查找相关人列表 | ||
228 | + var cooperationContractRelevantFetched []*models.CooperationContractRelevant | ||
229 | + cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantFetched) | ||
229 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 230 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
230 | return nil, err | 231 | return nil, err |
231 | } | 232 | } |
232 | 233 | ||
233 | - //var cooperationContractRelevantModelsUpdate []*models.CooperationContractRelevant // 待更新的相关人 | 234 | + // 待更新相关人 |
235 | + var cooperationContractRelevantPeopleToUpdate []*domain.Relevant | ||
236 | + // 待添加相关人 | ||
237 | + var cooperationContractRelevantPeopleToAdd []*domain.Relevant | ||
238 | + for _, relevant := range cooperationContract.RelevantPeople { | ||
239 | + if relevant.RelevantId != 0 { | ||
240 | + cooperationContractRelevantPeopleToUpdate = append(cooperationContractRelevantPeopleToUpdate, relevant) | ||
241 | + } else { | ||
242 | + cooperationContractRelevantPeopleToAdd = append(cooperationContractRelevantPeopleToAdd, relevant) | ||
243 | + } | ||
244 | + } | ||
245 | + | ||
246 | + // 待删除相关人,对比待更新的和数据库已有的 | ||
247 | + | ||
234 | //var cooperationContractRelevantModelsDelete []*models.CooperationContractRelevant // 待删除的相关人 | 248 | //var cooperationContractRelevantModelsDelete []*models.CooperationContractRelevant // 待删除的相关人 |
235 | //var cooperationContractRelevantModelsCreate []*models.CooperationContractRelevant // 待增加的相关人 | 249 | //var cooperationContractRelevantModelsCreate []*models.CooperationContractRelevant // 待增加的相关人 |
236 | 250 | ||
@@ -238,7 +252,8 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -238,7 +252,8 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
238 | var relevantIdsModify []int64 | 252 | var relevantIdsModify []int64 |
239 | //var relevantIdsUpdate []int64 | 253 | //var relevantIdsUpdate []int64 |
240 | 254 | ||
241 | - for _, cooperationContractRelevantModel := range cooperationContractRelevantModels { | 255 | + // 待更新相关人id数组 |
256 | + for _, cooperationContractRelevantModel := range cooperationContractRelevantFetched { | ||
242 | relevantIdsHave = append(relevantIdsHave, cooperationContractRelevantModel.CooperationContractRelevantId) | 257 | relevantIdsHave = append(relevantIdsHave, cooperationContractRelevantModel.CooperationContractRelevantId) |
243 | } | 258 | } |
244 | 259 |
@@ -67,7 +67,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -67,7 +67,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
67 | &creditAccount.SettlementAmount, | 67 | &creditAccount.SettlementAmount, |
68 | &creditAccount.SettlementTime, | 68 | &creditAccount.SettlementTime, |
69 | &creditAccount.CooperationContractNumber, | 69 | &creditAccount.CooperationContractNumber, |
70 | - pg.Array(&creditAccount.Participator), | 70 | + &creditAccount.Participator, |
71 | &creditAccount.PaymentDocumentAttachment, | 71 | &creditAccount.PaymentDocumentAttachment, |
72 | &creditAccount.Org, | 72 | &creditAccount.Org, |
73 | &creditAccount.Company, | 73 | &creditAccount.Company, |
@@ -86,7 +86,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -86,7 +86,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
86 | creditAccount.SettlementAmount, | 86 | creditAccount.SettlementAmount, |
87 | creditAccount.SettlementTime, | 87 | creditAccount.SettlementTime, |
88 | creditAccount.CooperationContractNumber, | 88 | creditAccount.CooperationContractNumber, |
89 | - pg.Array(creditAccount.Participator), | 89 | + creditAccount.Participator, |
90 | creditAccount.PaymentDocumentAttachment, | 90 | creditAccount.PaymentDocumentAttachment, |
91 | creditAccount.Org, | 91 | creditAccount.Org, |
92 | creditAccount.Company, | 92 | creditAccount.Company, |
@@ -109,7 +109,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -109,7 +109,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
109 | &creditAccount.SettlementAmount, | 109 | &creditAccount.SettlementAmount, |
110 | &creditAccount.SettlementTime, | 110 | &creditAccount.SettlementTime, |
111 | &creditAccount.CooperationContractNumber, | 111 | &creditAccount.CooperationContractNumber, |
112 | - pg.Array(&creditAccount.Participator), | 112 | + &creditAccount.Participator, |
113 | &creditAccount.PaymentDocumentAttachment, | 113 | &creditAccount.PaymentDocumentAttachment, |
114 | &creditAccount.Org, | 114 | &creditAccount.Org, |
115 | &creditAccount.Company, | 115 | &creditAccount.Company, |
@@ -128,7 +128,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -128,7 +128,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
128 | creditAccount.SettlementAmount, | 128 | creditAccount.SettlementAmount, |
129 | creditAccount.SettlementTime, | 129 | creditAccount.SettlementTime, |
130 | creditAccount.CooperationContractNumber, | 130 | creditAccount.CooperationContractNumber, |
131 | - pg.Array(creditAccount.Participator), | 131 | + creditAccount.Participator, |
132 | creditAccount.PaymentDocumentAttachment, | 132 | creditAccount.PaymentDocumentAttachment, |
133 | creditAccount.Org, | 133 | creditAccount.Org, |
134 | creditAccount.Company, | 134 | creditAccount.Company, |
@@ -168,6 +168,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder | @@ -168,6 +168,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder | ||
168 | return dividendsReturnedOrder, err | 168 | return dividendsReturnedOrder, err |
169 | } | 169 | } |
170 | //TODO 新增、更新、删除分红退货单产品 | 170 | //TODO 新增、更新、删除分红退货单产品 |
171 | + | ||
171 | } | 172 | } |
172 | return dividendsReturnedOrder, nil | 173 | return dividendsReturnedOrder, nil |
173 | } | 174 | } |
@@ -7,8 +7,8 @@ type UserTranslator struct { | @@ -7,8 +7,8 @@ type UserTranslator struct { | ||
7 | 7 | ||
8 | func (translator *UserTranslator) ToRelevantFromRepresentation(data map[string]interface{}) (*domain.Relevant, error) { | 8 | func (translator *UserTranslator) ToRelevantFromRepresentation(data map[string]interface{}) (*domain.Relevant, error) { |
9 | return &domain.Relevant{ | 9 | return &domain.Relevant{ |
10 | - UserId: 0, | ||
11 | - UserBaseId: 0, | 10 | + UserId: data["userId"].(int64), |
11 | + UserBaseId: data["userBaseId"].(int64), | ||
12 | Org: nil, | 12 | Org: nil, |
13 | Orgs: nil, | 13 | Orgs: nil, |
14 | Department: nil, | 14 | Department: nil, |
@@ -22,8 +22,8 @@ func (translator *UserTranslator) ToRelevantFromRepresentation(data map[string]i | @@ -22,8 +22,8 @@ func (translator *UserTranslator) ToRelevantFromRepresentation(data map[string]i | ||
22 | 22 | ||
23 | func (translator *UserTranslator) ToReferrerFromRepresentation(data map[string]interface{}) (*domain.Referrer, error) { | 23 | func (translator *UserTranslator) ToReferrerFromRepresentation(data map[string]interface{}) (*domain.Referrer, error) { |
24 | return &domain.Referrer{ | 24 | return &domain.Referrer{ |
25 | - UserId: 0, | ||
26 | - UserBaseId: 0, | 25 | + UserId: data["userId"].(int64), |
26 | + UserBaseId: data["userBaseId"].(int64), | ||
27 | Role: nil, | 27 | Role: nil, |
28 | Orgs: nil, | 28 | Orgs: nil, |
29 | Org: nil, | 29 | Org: nil, |
@@ -36,8 +36,8 @@ func (translator *UserTranslator) ToReferrerFromRepresentation(data map[string]i | @@ -36,8 +36,8 @@ func (translator *UserTranslator) ToReferrerFromRepresentation(data map[string]i | ||
36 | 36 | ||
37 | func (translator *UserTranslator) ToUndertakerFromRepresentation(data map[string]interface{}) (*domain.Undertaker, error) { | 37 | func (translator *UserTranslator) ToUndertakerFromRepresentation(data map[string]interface{}) (*domain.Undertaker, error) { |
38 | return &domain.Undertaker{ | 38 | return &domain.Undertaker{ |
39 | - UserId: 0, | ||
40 | - UserBaseId: 0, | 39 | + UserId: data["userId"].(int64), |
40 | + UserBaseId: data["userBaseId"].(int64), | ||
41 | Org: nil, | 41 | Org: nil, |
42 | Orgs: nil, | 42 | Orgs: nil, |
43 | Department: nil, | 43 | Department: nil, |
@@ -52,8 +52,8 @@ func (translator *UserTranslator) ToUndertakerFromRepresentation(data map[string | @@ -52,8 +52,8 @@ func (translator *UserTranslator) ToUndertakerFromRepresentation(data map[string | ||
52 | 52 | ||
53 | func (translator *UserTranslator) ToSalesmanFromRepresentation(data map[string]interface{}) (*domain.Salesman, error) { | 53 | func (translator *UserTranslator) ToSalesmanFromRepresentation(data map[string]interface{}) (*domain.Salesman, error) { |
54 | return &domain.Salesman{ | 54 | return &domain.Salesman{ |
55 | - UserId: 0, | ||
56 | - UserBaseId: 0, | 55 | + UserId: data["userId"].(int64), |
56 | + UserBaseId: data["userBaseId"].(int64), | ||
57 | Role: nil, | 57 | Role: nil, |
58 | Orgs: nil, | 58 | Orgs: nil, |
59 | Org: nil, | 59 | Org: nil, |
@@ -66,8 +66,8 @@ func (translator *UserTranslator) ToSalesmanFromRepresentation(data map[string]i | @@ -66,8 +66,8 @@ func (translator *UserTranslator) ToSalesmanFromRepresentation(data map[string]i | ||
66 | 66 | ||
67 | func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]interface{}) (*domain.User, error) { | 67 | func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]interface{}) (*domain.User, error) { |
68 | return &domain.User{ | 68 | return &domain.User{ |
69 | - UserId: 0, | ||
70 | - UserBaseId: 0, | 69 | + UserId: data["userId"].(int64), |
70 | + UserBaseId: data["userBaseId"].(int64), | ||
71 | Org: nil, | 71 | Org: nil, |
72 | Orgs: nil, | 72 | Orgs: nil, |
73 | Department: nil, | 73 | Department: nil, |
@@ -81,8 +81,8 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]i | @@ -81,8 +81,8 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]i | ||
81 | 81 | ||
82 | func (translator *UserTranslator) ToUserFromRepresentation(data map[string]interface{}) (*domain.User, error) { | 82 | func (translator *UserTranslator) ToUserFromRepresentation(data map[string]interface{}) (*domain.User, error) { |
83 | return &domain.User{ | 83 | return &domain.User{ |
84 | - UserId: 0, | ||
85 | - UserBaseId: 0, | 84 | + UserId: data["userId"].(int64), |
85 | + UserBaseId: data["userBaseId"].(int64), | ||
86 | Org: nil, | 86 | Org: nil, |
87 | Orgs: nil, | 87 | Orgs: nil, |
88 | Department: nil, | 88 | Department: nil, |
1 | package utils | 1 | package utils |
2 | 2 | ||
3 | +// Intersect 返回两个数组的交集 | ||
3 | func Intersect(nums1 []int64, nums2 []int64) []int64 { | 4 | func Intersect(nums1 []int64, nums2 []int64) []int64 { |
4 | if len(nums1) > len(nums2) { | 5 | if len(nums1) > len(nums2) { |
5 | return Intersect(nums2, nums1) | 6 | return Intersect(nums2, nums1) |
@@ -18,3 +19,38 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 { | @@ -18,3 +19,38 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 { | ||
18 | } | 19 | } |
19 | return intersection | 20 | return intersection |
20 | } | 21 | } |
22 | + | ||
23 | +////求交集 | ||
24 | +//func intersect(slice1, slice2 []int64) []int64 { | ||
25 | +// m := make(map[int64]int) | ||
26 | +// nn := make([]int64, 0) | ||
27 | +// for _, v := range slice1 { | ||
28 | +// m[v]++ | ||
29 | +// } | ||
30 | +// | ||
31 | +// for _, v := range slice2 { | ||
32 | +// times, _ := m[v] | ||
33 | +// if times == 1 { | ||
34 | +// nn = append(nn, v) | ||
35 | +// } | ||
36 | +// } | ||
37 | +// return nn | ||
38 | +//} | ||
39 | + | ||
40 | +// Difference 求差集 slice1-并集 | ||
41 | +func Difference(slice1, slice2 []int64) []int64 { | ||
42 | + m := make(map[int64]int) | ||
43 | + nn := make([]int64, 0) | ||
44 | + inter := Intersect(slice1, slice2) | ||
45 | + for _, v := range inter { | ||
46 | + m[v]++ | ||
47 | + } | ||
48 | + | ||
49 | + for _, value := range slice1 { | ||
50 | + times, _ := m[value] | ||
51 | + if times == 0 { | ||
52 | + nn = append(nn, value) | ||
53 | + } | ||
54 | + } | ||
55 | + return nn | ||
56 | +} |
@@ -93,9 +93,9 @@ func (controller *CooperationModeController) ListCooperationMode() { | @@ -93,9 +93,9 @@ func (controller *CooperationModeController) ListCooperationMode() { | ||
93 | listCooperationModeQuery.OrgId = header.OrgId | 93 | listCooperationModeQuery.OrgId = header.OrgId |
94 | listCooperationModeQuery.UserId = header.UserId | 94 | listCooperationModeQuery.UserId = header.UserId |
95 | listCooperationModeQuery.UserBaseId = header.UserBaseId | 95 | listCooperationModeQuery.UserBaseId = header.UserBaseId |
96 | - pageSize, _ := controller.GetInt32("pageSize") | 96 | + pageSize, _ := controller.GetInt64("pageSize") |
97 | listCooperationModeQuery.PageSize = pageSize | 97 | listCooperationModeQuery.PageSize = pageSize |
98 | - pageNumber, _ := controller.GetInt32("pageNumber") | 98 | + pageNumber, _ := controller.GetInt64("pageNumber") |
99 | listCooperationModeQuery.PageNumber = pageNumber | 99 | listCooperationModeQuery.PageNumber = pageNumber |
100 | data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery) | 100 | data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery) |
101 | controller.Response(data, err) | 101 | controller.Response(data, err) |
-
请 注册 或 登录 后发表评论