作者 陈志颖

feat:添加参与人值对象

... ... @@ -10,13 +10,9 @@ import (
type ListCooperationModeQuery struct {
// 页面大小
PageNumber int32 `cname:"页面大小" json:"pageNumber,omitempty"`
PageNumber int64 `cname:"页面大小" json:"pageNumber,omitempty"`
// 页面大小
PageSize int32 `cname:"页面大小" json:"pageSize,omitempty"`
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
// 查询限制
Limit int `cname:"查询限制" json:"limit" valid:"Required"`
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -18,10 +18,10 @@ type CreditAccount struct {
SettlementAmount float64 `json:"settlementAmount"`
// 共创账期结算时间
SettlementTime time.Time `json:"settlementTime"`
// 共创合约编号
// 关联共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 参与人uid,包括承接人、推荐人、关联业务员
Participator []int64 `json:"participator"`
Participator *Participator `json:"participator"`
// 支付凭证附件
PaymentDocumentAttachment *Attachment `json:"paymentDocumentAttachment"`
// 数据所属组织机构
... ...
package domain
// Participator 共创参与人
type Participator struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId,string"`
// 用户基本id
UserBaseId int64 `json:"userBaseId,string"`
// 用户所属的组织机构
Org *Org `json:"org"`
// 用户关联的组织机构
Orgs []*Org `json:"orgs"`
// 用户所属的部门
Department *Department `json:"department"`
// 用户角色
Role *Role `json:"role"`
// 冗余字段,jsonb格式,不限制存放内容
UserInfo *UserInfo `json:"userInfo"`
// 用户类型,1员工,2共创用户,3公开
UserType int32 `json:"userType"`
// 状态
Status int32 `json:"status"`
// 公司
Company *Company `json:"company"`
}
... ...
... ... @@ -24,7 +24,7 @@ type CreditAccount struct {
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 参与人uid,包括承接人、推荐人、关联业务员
Participator []int64 `comment:"参与人uid,包括承接人、推荐人、关联业务员" pg:",array"`
Participator *domain.Participator `comment:"参与人uid,包括承接人、推荐人、关联业务员" pg:",array"`
// 支付凭证附件
PaymentDocumentAttachment *domain.Attachment `comment:"支付凭证附件"`
// 数据所属组织机构
... ...
... ... @@ -223,14 +223,28 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
); err != nil {
return cooperationContract, err
}
// 获取相关人列表
var cooperationContractRelevantModels []*models.CooperationContractRelevant
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels)
// 查找相关人列表
var cooperationContractRelevantFetched []*models.CooperationContractRelevant
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantFetched)
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
return nil, err
}
//var cooperationContractRelevantModelsUpdate []*models.CooperationContractRelevant // 待更新的相关人
// 待更新相关人
var cooperationContractRelevantPeopleToUpdate []*domain.Relevant
// 待添加相关人
var cooperationContractRelevantPeopleToAdd []*domain.Relevant
for _, relevant := range cooperationContract.RelevantPeople {
if relevant.RelevantId != 0 {
cooperationContractRelevantPeopleToUpdate = append(cooperationContractRelevantPeopleToUpdate, relevant)
} else {
cooperationContractRelevantPeopleToAdd = append(cooperationContractRelevantPeopleToAdd, relevant)
}
}
// 待删除相关人,对比待更新的和数据库已有的
//var cooperationContractRelevantModelsDelete []*models.CooperationContractRelevant // 待删除的相关人
//var cooperationContractRelevantModelsCreate []*models.CooperationContractRelevant // 待增加的相关人
... ... @@ -238,7 +252,8 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
var relevantIdsModify []int64
//var relevantIdsUpdate []int64
for _, cooperationContractRelevantModel := range cooperationContractRelevantModels {
// 待更新相关人id数组
for _, cooperationContractRelevantModel := range cooperationContractRelevantFetched {
relevantIdsHave = append(relevantIdsHave, cooperationContractRelevantModel.CooperationContractRelevantId)
}
... ...
... ... @@ -67,7 +67,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
&creditAccount.SettlementAmount,
&creditAccount.SettlementTime,
&creditAccount.CooperationContractNumber,
pg.Array(&creditAccount.Participator),
&creditAccount.Participator,
&creditAccount.PaymentDocumentAttachment,
&creditAccount.Org,
&creditAccount.Company,
... ... @@ -86,7 +86,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
creditAccount.SettlementAmount,
creditAccount.SettlementTime,
creditAccount.CooperationContractNumber,
pg.Array(creditAccount.Participator),
creditAccount.Participator,
creditAccount.PaymentDocumentAttachment,
creditAccount.Org,
creditAccount.Company,
... ... @@ -109,7 +109,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
&creditAccount.SettlementAmount,
&creditAccount.SettlementTime,
&creditAccount.CooperationContractNumber,
pg.Array(&creditAccount.Participator),
&creditAccount.Participator,
&creditAccount.PaymentDocumentAttachment,
&creditAccount.Org,
&creditAccount.Company,
... ... @@ -128,7 +128,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
creditAccount.SettlementAmount,
creditAccount.SettlementTime,
creditAccount.CooperationContractNumber,
pg.Array(creditAccount.Participator),
creditAccount.Participator,
creditAccount.PaymentDocumentAttachment,
creditAccount.Org,
creditAccount.Company,
... ...
... ... @@ -168,6 +168,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
return dividendsReturnedOrder, err
}
//TODO 新增、更新、删除分红退货单产品
}
return dividendsReturnedOrder, nil
}
... ...
package service_gateway
type HttplibMessageServiceGateway struct {
httplibBaseServiceGateway
}
... ...
... ... @@ -7,8 +7,8 @@ type UserTranslator struct {
func (translator *UserTranslator) ToRelevantFromRepresentation(data map[string]interface{}) (*domain.Relevant, error) {
return &domain.Relevant{
UserId: 0,
UserBaseId: 0,
UserId: data["userId"].(int64),
UserBaseId: data["userBaseId"].(int64),
Org: nil,
Orgs: nil,
Department: nil,
... ... @@ -22,8 +22,8 @@ func (translator *UserTranslator) ToRelevantFromRepresentation(data map[string]i
func (translator *UserTranslator) ToReferrerFromRepresentation(data map[string]interface{}) (*domain.Referrer, error) {
return &domain.Referrer{
UserId: 0,
UserBaseId: 0,
UserId: data["userId"].(int64),
UserBaseId: data["userBaseId"].(int64),
Role: nil,
Orgs: nil,
Org: nil,
... ... @@ -36,8 +36,8 @@ func (translator *UserTranslator) ToReferrerFromRepresentation(data map[string]i
func (translator *UserTranslator) ToUndertakerFromRepresentation(data map[string]interface{}) (*domain.Undertaker, error) {
return &domain.Undertaker{
UserId: 0,
UserBaseId: 0,
UserId: data["userId"].(int64),
UserBaseId: data["userBaseId"].(int64),
Org: nil,
Orgs: nil,
Department: nil,
... ... @@ -52,8 +52,8 @@ func (translator *UserTranslator) ToUndertakerFromRepresentation(data map[string
func (translator *UserTranslator) ToSalesmanFromRepresentation(data map[string]interface{}) (*domain.Salesman, error) {
return &domain.Salesman{
UserId: 0,
UserBaseId: 0,
UserId: data["userId"].(int64),
UserBaseId: data["userBaseId"].(int64),
Role: nil,
Orgs: nil,
Org: nil,
... ... @@ -66,8 +66,8 @@ func (translator *UserTranslator) ToSalesmanFromRepresentation(data map[string]i
func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]interface{}) (*domain.User, error) {
return &domain.User{
UserId: 0,
UserBaseId: 0,
UserId: data["userId"].(int64),
UserBaseId: data["userBaseId"].(int64),
Org: nil,
Orgs: nil,
Department: nil,
... ... @@ -81,8 +81,8 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]i
func (translator *UserTranslator) ToUserFromRepresentation(data map[string]interface{}) (*domain.User, error) {
return &domain.User{
UserId: 0,
UserBaseId: 0,
UserId: data["userId"].(int64),
UserBaseId: data["userBaseId"].(int64),
Org: nil,
Orgs: nil,
Department: nil,
... ...
package utils
// Intersect 返回两个数组的交集
func Intersect(nums1 []int64, nums2 []int64) []int64 {
if len(nums1) > len(nums2) {
return Intersect(nums2, nums1)
... ... @@ -18,3 +19,38 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 {
}
return intersection
}
////求交集
//func intersect(slice1, slice2 []int64) []int64 {
// m := make(map[int64]int)
// nn := make([]int64, 0)
// for _, v := range slice1 {
// m[v]++
// }
//
// for _, v := range slice2 {
// times, _ := m[v]
// if times == 1 {
// nn = append(nn, v)
// }
// }
// return nn
//}
// Difference 求差集 slice1-并集
func Difference(slice1, slice2 []int64) []int64 {
m := make(map[int64]int)
nn := make([]int64, 0)
inter := Intersect(slice1, slice2)
for _, v := range inter {
m[v]++
}
for _, value := range slice1 {
times, _ := m[value]
if times == 0 {
nn = append(nn, value)
}
}
return nn
}
... ...
... ... @@ -93,9 +93,9 @@ func (controller *CooperationModeController) ListCooperationMode() {
listCooperationModeQuery.OrgId = header.OrgId
listCooperationModeQuery.UserId = header.UserId
listCooperationModeQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt32("pageSize")
pageSize, _ := controller.GetInt64("pageSize")
listCooperationModeQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt32("pageNumber")
pageNumber, _ := controller.GetInt64("pageNumber")
listCooperationModeQuery.PageNumber = pageNumber
data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
controller.Response(data, err)
... ...