作者 陈志颖

Merge branch 'dev-chenzhiying' into dev

@@ -308,7 +308,11 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -308,7 +308,11 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
308 } else { 308 } else {
309 cooperationModeRepository = value 309 cooperationModeRepository = value
310 } 310 }
311 - cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationContractCommand.CooperationModeNumber}) 311 + cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{
  312 + "companyId": createCooperationContractCommand.CompanyId,
  313 + "orgId": createCooperationContractCommand.OrgId,
  314 + "cooperationModeNumber": createCooperationContractCommand.CooperationModeNumber,
  315 + })
312 if err != nil { 316 if err != nil {
313 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") 317 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
314 } 318 }
@@ -775,6 +775,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -775,6 +775,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
775 OrderGoodId: orderGood.OrderGoodId, 775 OrderGoodId: orderGood.OrderGoodId,
776 OrderGoodAmount: orderGood.OrderGoodAmount, 776 OrderGoodAmount: orderGood.OrderGoodAmount,
777 PaymentStatus: int32(1), 777 PaymentStatus: int32(1),
  778 + CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
778 } 779 }
779 780
780 dividendsEstimates = append(dividendsEstimates, dividendsEstimate) 781 dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
@@ -829,6 +830,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -829,6 +830,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
829 OrderGoodId: orderGood.OrderGoodId, 830 OrderGoodId: orderGood.OrderGoodId,
830 OrderGoodAmount: orderGood.OrderGoodAmount, 831 OrderGoodAmount: orderGood.OrderGoodAmount,
831 PaymentStatus: int32(1), 832 PaymentStatus: int32(1),
  833 + CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
832 } 834 }
833 835
834 dividendsEstimates = append(dividendsEstimates, dividendsEstimate) 836 dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
@@ -1169,6 +1171,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives @@ -1169,6 +1171,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
1169 DeletedAt: time.Time{}, 1171 DeletedAt: time.Time{},
1170 UpdatedAt: time.Time{}, 1172 UpdatedAt: time.Time{},
1171 PaymentStatus: int32(1), 1173 PaymentStatus: int32(1),
  1174 + CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
1172 } 1175 }
1173 1176
1174 dividendsEstimates = append(dividendsEstimates, dividendsEstimate) 1177 dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
@@ -145,6 +145,10 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -145,6 +145,10 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
145 } 145 }
146 } 146 }
147 147
  148 + log.Logger.Info("查询到的合约", map[string]interface{}{
  149 + "cooperationContractsMap": cooperationContractsMap,
  150 + })
  151 +
148 // 订单时间转换 152 // 订单时间转换
149 orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64) 153 orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
150 if err != nil { 154 if err != nil {
@@ -163,9 +167,14 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -163,9 +167,14 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
163 ruleMatchedFlag := false 167 ruleMatchedFlag := false
164 if orderGood.CooperationContractNumber != "" { 168 if orderGood.CooperationContractNumber != "" {
165 // 校验共创合约激励类型是否正确 169 // 校验共创合约激励类型是否正确
166 - if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 { 170 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
  171 + if cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
167 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则") 172 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
168 } 173 }
  174 + } else {
  175 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
  176 + }
  177 +
169 // 校验产品关联合约的激励规则是否匹配订单时间 178 // 校验产品关联合约的激励规则是否匹配订单时间
170 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { 179 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
171 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { 180 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
@@ -43,6 +43,8 @@ type DividendsEstimate struct { @@ -43,6 +43,8 @@ type DividendsEstimate struct {
43 OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` 43 OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
44 // 共创项目合约编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001 44 // 共创项目合约编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
45 CooperationContractNumber string `json:"cooperationContractNumber"` 45 CooperationContractNumber string `json:"cooperationContractNumber"`
  46 + // 共创合约承接人id
  47 + CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"`
46 // 分红用户(共创参与) 48 // 分红用户(共创参与)
47 DividendsUser *User `json:"dividendsUser"` 49 DividendsUser *User `json:"dividendsUser"`
48 // 分红阶段 50 // 分红阶段
@@ -15,6 +15,7 @@ type DividendsEstimateDetail struct { @@ -15,6 +15,7 @@ type DividendsEstimateDetail struct {
15 OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号 15 OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号
16 IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功 16 IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功
17 Reason string `json:"reason"` // 错误原因 17 Reason string `json:"reason"` // 错误原因
  18 + CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` // 承接人记录ID
18 } 19 }
19 20
20 // GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号 21 // GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号
@@ -2,7 +2,7 @@ package domain @@ -2,7 +2,7 @@ package domain
2 2
3 // Undertaker 共创合约承接方值对象 3 // Undertaker 共创合约承接方值对象
4 type Undertaker struct { 4 type Undertaker struct {
5 - // 承接人id 5 + // 承接人记录ID
6 UndertakerId int64 `json:"undertakerId,string"` 6 UndertakerId int64 `json:"undertakerId,string"`
7 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 7 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
8 UserId int64 `json:"userId,string"` 8 UserId int64 `json:"userId,string"`
@@ -20,6 +20,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -20,6 +20,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
20 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 20 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
21 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 21 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
22 var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储 22 var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储
  23 + //var cooperationContactRepository domain.CooperationContractRepository // 合约仓储
23 24
24 // 分红预算单仓储初始化 25 // 分红预算单仓储初始化
25 if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { 26 if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil {
@@ -49,6 +50,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -49,6 +50,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
49 orderGoodRepository = repo 50 orderGoodRepository = repo
50 } 51 }
51 52
  53 + // 共创合约仓储初始化
  54 + //if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {
  55 + // return nil, err
  56 + //} else {
  57 + // cooperationContactRepository = repo
  58 + //}
  59 +
52 // 获取分红预算单 60 // 获取分红预算单
53 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ 61 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
54 "dividendsEstimateIds": dividendsEstimateIds, 62 "dividendsEstimateIds": dividendsEstimateIds,
@@ -61,18 +69,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -61,18 +69,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
61 for _, dividendsEstimate := range dividendsEstimates { 69 for _, dividendsEstimate := range dividendsEstimates {
62 if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销 70 if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
63 // 自定义查询 71 // 自定义查询
64 - queryOptions := make(map[string]interface{})  
65 -  
66 - queryOptions = map[string]interface{}{  
67 - "companyId": dividendsEstimate.Company.CompanyId,  
68 - "orgId": dividendsEstimate.Org.OrgId,  
69 - "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,  
70 - "dividendsParticipateTypes": []int32{1, 2, 3},  
71 - "offsetLimit": false,  
72 - "dividendsStage": dividendsEstimate.DividendsStage,  
73 - "dividendsTypes": []int32{1, 2},  
74 - }  
75 72
  73 + //queryOptions := map[string]interface{}{
  74 + // "companyId": dividendsEstimate.Company.CompanyId,
  75 + // "orgId": dividendsEstimate.Org.OrgId,
  76 + // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  77 + // "dividendsParticipateTypes": []int32{1, 2, 3},
  78 + // "offsetLimit": false,
  79 + // "dividendsStage": dividendsEstimate.DividendsStage,
  80 + // "dividendsTypes": []int32{1, 2},
  81 + //}
76 //参与分红类型,1承接人,2推荐人,3关联业务员 82 //参与分红类型,1承接人,2推荐人,3关联业务员
77 //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单 83 //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
78 // queryOptions = map[string]interface{}{ 84 // queryOptions = map[string]interface{}{
@@ -107,7 +113,17 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -107,7 +113,17 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
107 //} 113 //}
108 114
109 // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 115 // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
110 - if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil { 116 + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
  117 + "companyId": dividendsEstimate.Company.CompanyId,
  118 + "orgId": dividendsEstimate.Org.OrgId,
  119 + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  120 + "dividendsParticipateTypes": []int32{1, 2, 3},
  121 + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  122 + "offsetLimit": false,
  123 + "dividendsStage": dividendsEstimate.DividendsStage,
  124 + "dividendsTypes": []int32{1, 2},
  125 + "orderGoodId": dividendsEstimate.OrderGoodId,
  126 + }); err2 != nil {
111 return nil, err2 127 return nil, err2
112 } else { 128 } else {
113 if countRelative > 0 { 129 if countRelative > 0 {
@@ -125,19 +141,27 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -125,19 +141,27 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
125 } 141 }
126 } 142 }
127 } else if dividendsEstimate.DividendsType == 3 { // 3.金额激励 143 } else if dividendsEstimate.DividendsType == 3 { // 3.金额激励
128 - // 自定义查询  
129 - queryOptions := make(map[string]interface{})  
130 144
131 - queryOptions = map[string]interface{}{  
132 - "companyId": dividendsEstimate.Company.CompanyId,  
133 - "orgId": dividendsEstimate.Org.OrgId,  
134 - "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,  
135 - "dividendsParticipateTypes": []int32{1, 2, 3},  
136 - "offsetLimit": false,  
137 - "dividendsStage": dividendsEstimate.DividendsStage,  
138 - "dividendsType": int32(3),  
139 - } 145 + // 查询合约
  146 + //cooperationContract, err3 := cooperationContactRepository.FindOne(map[string]interface{}{
  147 + // "companyId": dividendsEstimate.Company.CompanyId,
  148 + // "orgId": dividendsEstimate.Org.OrgId,
  149 + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  150 + //})
  151 + //if err3 != nil {
  152 + // return nil, err3
  153 + //}
140 154
  155 + // 自定义查询
  156 + //queryOptions := map[string]interface{}{
  157 + // "companyId": dividendsEstimate.Company.CompanyId,
  158 + // "orgId": dividendsEstimate.Org.OrgId,
  159 + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  160 + // "dividendsParticipateTypes": []int32{1, 2, 3},
  161 + // "offsetLimit": false,
  162 + // "dividendsStage": dividendsEstimate.DividendsStage,
  163 + // "dividendsType": int32(3),
  164 + //}
141 //参与分红类型,1承接人,2推荐人,3关联业务员 165 //参与分红类型,1承接人,2推荐人,3关联业务员
142 //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单 166 //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
143 // queryOptions = map[string]interface{}{ 167 // queryOptions = map[string]interface{}{
@@ -172,7 +196,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -172,7 +196,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
172 //} 196 //}
173 197
174 // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 198 // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
175 - if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil { 199 + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
  200 + "companyId": dividendsEstimate.Company.CompanyId,
  201 + "orgId": dividendsEstimate.Org.OrgId,
  202 + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  203 + "cooperationContractUndertakerId": dividendsEstimate.CooperationContractUndertakerId,
  204 + "dividendsParticipateTypes": []int32{1, 2, 3},
  205 + "offsetLimit": false,
  206 + "dividendsStage": dividendsEstimate.DividendsStage,
  207 + "dividendsType": int32(3),
  208 + }); err2 != nil {
176 return nil, err2 209 return nil, err2
177 } else { 210 } else {
178 if countRelative > 0 { 211 if countRelative > 0 {
@@ -180,9 +213,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -180,9 +213,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
180 dividendsEstimatesRelative[i].IsCanceled = true 213 dividendsEstimatesRelative[i].IsCanceled = true
181 dividendsEstimatesRelative[i].Operator = operator 214 dividendsEstimatesRelative[i].Operator = operator
182 } 215 }
183 - dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)  
184 - if err3 != nil {  
185 - return nil, err3 216 + dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
  217 + if err4 != nil {
  218 + return nil, err4
186 } 219 }
187 dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) 220 dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
188 } 221 }
@@ -248,6 +248,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -248,6 +248,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
248 DividendsAmount: undertakerDividendsAmount, 248 DividendsAmount: undertakerDividendsAmount,
249 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, 249 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
250 IsSuccessfully: true, 250 IsSuccessfully: true,
  251 + CooperationContractUndertakerId: undertaker.UndertakerId,
251 }) 252 })
252 } 253 }
253 254
@@ -274,6 +275,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -274,6 +275,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
274 DividendsAmount: referrerDividendsAmount, 275 DividendsAmount: referrerDividendsAmount,
275 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, 276 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
276 IsSuccessfully: true, 277 IsSuccessfully: true,
  278 + CooperationContractUndertakerId: undertaker.UndertakerId,
277 }) 279 })
278 } 280 }
279 } 281 }
@@ -300,6 +302,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -300,6 +302,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
300 DividendsAmount: salesmanDividendsAmount, 302 DividendsAmount: salesmanDividendsAmount,
301 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, 303 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
302 IsSuccessfully: true, 304 IsSuccessfully: true,
  305 + CooperationContractUndertakerId: undertaker.UndertakerId,
303 }) 306 })
304 } 307 }
305 } 308 }
@@ -369,6 +372,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -369,6 +372,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
369 DividendsAmount: -undertakerDividendsAmount, 372 DividendsAmount: -undertakerDividendsAmount,
370 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, 373 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
371 IsSuccessfully: true, 374 IsSuccessfully: true,
  375 + CooperationContractUndertakerId: undertaker.UndertakerId,
372 }) 376 })
373 } 377 }
374 378
@@ -395,6 +399,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -395,6 +399,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
395 DividendsAmount: -referrerDividendsAmount, 399 DividendsAmount: -referrerDividendsAmount,
396 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, 400 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
397 IsSuccessfully: true, 401 IsSuccessfully: true,
  402 + CooperationContractUndertakerId: undertaker.UndertakerId,
398 }) 403 })
399 } 404 }
400 } 405 }
@@ -422,6 +427,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -422,6 +427,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
422 DividendsAmount: -salesmanDividendsAmount, 427 DividendsAmount: -salesmanDividendsAmount,
423 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, 428 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
424 IsSuccessfully: true, 429 IsSuccessfully: true,
  430 + CooperationContractUndertakerId: undertaker.UndertakerId,
425 }) 431 })
426 } 432 }
427 433
@@ -64,7 +64,6 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -64,7 +64,6 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
64 return nil, fmt.Errorf("承接人 " + undertaker.UserName + " 已分红") 64 return nil, fmt.Errorf("承接人 " + undertaker.UserName + " 已分红")
65 } else { 65 } else {
66 undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64() 66 undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64()
67 - //Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64()  
68 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 67 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
69 DividendsUser: &domain.User{ 68 DividendsUser: &domain.User{
70 UserId: undertaker.UserId, 69 UserId: undertaker.UserId,
@@ -83,6 +82,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -83,6 +82,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
83 DividendsParticipateType: 1, 82 DividendsParticipateType: 1,
84 DividendsStage: stage, 83 DividendsStage: stage,
85 DividendsAmount: undertakerDividendsAmount, 84 DividendsAmount: undertakerDividendsAmount,
  85 + CooperationContractUndertakerId: undertaker.UndertakerId,
86 }) 86 })
87 } 87 }
88 88
@@ -117,6 +117,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -117,6 +117,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
117 DividendsParticipateType: 3, 117 DividendsParticipateType: 3,
118 DividendsStage: stage, 118 DividendsStage: stage,
119 DividendsAmount: undertakerDividendsAmount, 119 DividendsAmount: undertakerDividendsAmount,
  120 + CooperationContractUndertakerId: undertaker.UndertakerId,
120 }) 121 })
121 } 122 }
122 123
@@ -153,6 +154,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -153,6 +154,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
153 DividendsParticipateType: 2, 154 DividendsParticipateType: 2,
154 DividendsStage: stage, 155 DividendsStage: stage,
155 DividendsAmount: undertakerDividendsAmount, 156 DividendsAmount: undertakerDividendsAmount,
  157 + CooperationContractUndertakerId: undertaker.UndertakerId,
156 }) 158 })
157 } 159 }
158 } 160 }
@@ -29,6 +29,8 @@ type DividendsEstimate struct { @@ -29,6 +29,8 @@ type DividendsEstimate struct {
29 OrderOrReturnedOrderNum string `comment:"分红订单号或退货单号"` 29 OrderOrReturnedOrderNum string `comment:"分红订单号或退货单号"`
30 // 共创项目合约编号 30 // 共创项目合约编号
31 CooperationContractNumber string `comment:"共创项目合约编号"` 31 CooperationContractNumber string `comment:"共创项目合约编号"`
  32 + // 共创合约承接人id
  33 + CooperationContractUndertakerId int64 `comment:"共创合约承接人ID"`
32 // 分红用户 34 // 分红用户
33 DividendsUser *domain.User `comment:"分红用户"` 35 DividendsUser *domain.User `comment:"分红用户"`
34 // 分红阶段 36 // 分红阶段
@@ -42,7 +44,7 @@ type DividendsEstimate struct { @@ -42,7 +44,7 @@ type DividendsEstimate struct {
42 // 操作时间 44 // 操作时间
43 OperateTime time.Time `comment:"操作时间"` 45 OperateTime time.Time `comment:"操作时间"`
44 // 取消状态 46 // 取消状态
45 - IsCanceled bool `comment:"取消状态" pg:",use_zero,default:false"` 47 + IsCanceled bool `comment:"取消状态" pg:",use_zero"`
46 // 产品ID 48 // 产品ID
47 OrderGoodId int64 `comment:"产品ID"` 49 OrderGoodId int64 `comment:"产品ID"`
48 // 创建时间 50 // 创建时间
@@ -20,6 +20,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel @@ -20,6 +20,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel
20 DividendsTypeName: dividendsEstimateModel.DividendsTypeName, 20 DividendsTypeName: dividendsEstimateModel.DividendsTypeName,
21 OrderOrReturnedOrderNum: dividendsEstimateModel.OrderOrReturnedOrderNum, 21 OrderOrReturnedOrderNum: dividendsEstimateModel.OrderOrReturnedOrderNum,
22 CooperationContractNumber: dividendsEstimateModel.CooperationContractNumber, 22 CooperationContractNumber: dividendsEstimateModel.CooperationContractNumber,
  23 + CooperationContractUndertakerId: dividendsEstimateModel.CooperationContractUndertakerId,
23 DividendsUser: dividendsEstimateModel.DividendsUser, 24 DividendsUser: dividendsEstimateModel.DividendsUser,
24 DividendsStage: dividendsEstimateModel.DividendsStage, 25 DividendsStage: dividendsEstimateModel.DividendsStage,
25 Org: dividendsEstimateModel.Org, 26 Org: dividendsEstimateModel.Org,
@@ -824,13 +824,13 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -824,13 +824,13 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
824 } 824 }
825 } 825 }
826 // 返回新增的合约 826 // 返回新增的合约
827 - cooperationContractSaved, err := repository.FindOne(map[string]interface{}{  
828 - "cooperationContractId": cooperationContract.CooperationContractId,  
829 - })  
830 - if err != nil {  
831 - return nil, err  
832 - }  
833 - return cooperationContractSaved, nil 827 + //cooperationContractSaved, err := repository.FindOne(map[string]interface{}{
  828 + // "cooperationContractId": cooperationContract.CooperationContractId,
  829 + //})
  830 + //if err != nil {
  831 + // return nil, err
  832 + //}
  833 + return cooperationContract, nil
834 } 834 }
835 835
836 func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) { 836 func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) {
@@ -48,6 +48,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -48,6 +48,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
48 "created_at", 48 "created_at",
49 "deleted_at", 49 "deleted_at",
50 "updated_at", 50 "updated_at",
  51 + "cooperation_contract_undertaker_id",
51 } 52 }
52 insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) 53 insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
53 insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) 54 insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
@@ -86,6 +87,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -86,6 +87,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
86 &dividendsEstimate.CreatedAt, 87 &dividendsEstimate.CreatedAt,
87 &dividendsEstimate.DeletedAt, 88 &dividendsEstimate.DeletedAt,
88 &dividendsEstimate.UpdatedAt, 89 &dividendsEstimate.UpdatedAt,
  90 + &dividendsEstimate.CooperationContractUndertakerId,
89 ), 91 ),
90 fmt.Sprintf("INSERT INTO dividends_estimates (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), 92 fmt.Sprintf("INSERT INTO dividends_estimates (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
91 dividendsEstimate.DividendsEstimateId, 93 dividendsEstimate.DividendsEstimateId,
@@ -110,6 +112,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -110,6 +112,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
110 dividendsEstimate.CreatedAt, 112 dividendsEstimate.CreatedAt,
111 nil, 113 nil,
112 dividendsEstimate.UpdatedAt, 114 dividendsEstimate.UpdatedAt,
  115 + dividendsEstimate.CooperationContractUndertakerId,
113 ); err != nil { 116 ); err != nil {
114 return dividendsEstimate, err 117 return dividendsEstimate, err
115 } 118 }
@@ -138,6 +141,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -138,6 +141,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
138 &dividendsEstimate.CreatedAt, 141 &dividendsEstimate.CreatedAt,
139 &dividendsEstimate.DeletedAt, 142 &dividendsEstimate.DeletedAt,
140 &dividendsEstimate.UpdatedAt, 143 &dividendsEstimate.UpdatedAt,
  144 + &dividendsEstimate.CooperationContractUndertakerId,
141 ), 145 ),
142 fmt.Sprintf("UPDATE dividends_estimates SET %s WHERE dividends_estimate_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), 146 fmt.Sprintf("UPDATE dividends_estimates SET %s WHERE dividends_estimate_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
143 dividendsEstimate.DividendsEstimateId, 147 dividendsEstimate.DividendsEstimateId,
@@ -162,6 +166,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -162,6 +166,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
162 dividendsEstimate.CreatedAt, 166 dividendsEstimate.CreatedAt,
163 nil, 167 nil,
164 dividendsEstimate.UpdatedAt, 168 dividendsEstimate.UpdatedAt,
  169 + dividendsEstimate.CooperationContractUndertakerId,
165 dividendsEstimate.Identify(), 170 dividendsEstimate.Identify(),
166 ); err != nil { 171 ); err != nil {
167 return dividendsEstimate, err 172 return dividendsEstimate, err
@@ -205,6 +210,7 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do @@ -205,6 +210,7 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do
205 CreatedAt: dividendsEstimate.CreatedAt, 210 CreatedAt: dividendsEstimate.CreatedAt,
206 DeletedAt: dividendsEstimate.DeletedAt, 211 DeletedAt: dividendsEstimate.DeletedAt,
207 UpdatedAt: dividendsEstimate.UpdatedAt, 212 UpdatedAt: dividendsEstimate.UpdatedAt,
  213 + CooperationContractUndertakerId: dividendsEstimate.CooperationContractUndertakerId,
208 }) 214 })
209 } 215 }
210 if len(dividendsEstimateModels) > 0 { 216 if len(dividendsEstimateModels) > 0 {
@@ -251,6 +257,7 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* @@ -251,6 +257,7 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*
251 CreatedAt: dividendsEstimate.CreatedAt, 257 CreatedAt: dividendsEstimate.CreatedAt,
252 DeletedAt: dividendsEstimate.DeletedAt, 258 DeletedAt: dividendsEstimate.DeletedAt,
253 UpdatedAt: time.Now(), 259 UpdatedAt: time.Now(),
  260 + CooperationContractUndertakerId: dividendsEstimate.CooperationContractUndertakerId,
254 }) 261 })
255 } 262 }
256 if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil { 263 if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil {
@@ -325,6 +332,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte @@ -325,6 +332,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
325 if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 { 332 if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
326 query.Where("cooperation_contract_number in (?)", pg.In(v)) 333 query.Where("cooperation_contract_number in (?)", pg.In(v))
327 } 334 }
  335 + if cooperationContractUndertakerId, ok := queryOptions["cooperationContractUndertakerId"]; ok && cooperationContractUndertakerId.(int64) != 0 {
  336 + query.Where("cooperation_contract_undertaker_id = ?", cooperationContractUndertakerId)
  337 + }
328 if dividendsParticipateType, ok := queryOptions["dividendsParticipateType"]; ok && dividendsParticipateType.(int32) != 0 { 338 if dividendsParticipateType, ok := queryOptions["dividendsParticipateType"]; ok && dividendsParticipateType.(int32) != 0 {
329 query.Where("dividends_participate_type = ?", dividendsParticipateType) 339 query.Where("dividends_participate_type = ?", dividendsParticipateType)
330 } 340 }
@@ -340,6 +350,10 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte @@ -340,6 +350,10 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
340 if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { 350 if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 {
341 query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId) 351 query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId)
342 } 352 }
  353 + if dividendsUserIds, ok := queryOptions["dividendsUserIds"]; ok && len(dividendsUserIds.([]int64)) > 0 {
  354 + newDividendsUserIds := utils.SliceItoa(dividendsUserIds.([]int64))
  355 + query.Where("dividends_user->>'userId' in (?)", pg.In(newDividendsUserIds))
  356 + }
343 if userBaseId, ok := queryOptions["userBaseId"]; ok && userBaseId.(int64) != 0 { 357 if userBaseId, ok := queryOptions["userBaseId"]; ok && userBaseId.(int64) != 0 {
344 query.Where(`dividends_user @> '{"userBaseId":"?"}'`, userBaseId) 358 query.Where(`dividends_user @> '{"userBaseId":"?"}'`, userBaseId)
345 } 359 }
@@ -45,7 +45,7 @@ func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, metho @@ -45,7 +45,7 @@ func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, metho
45 case "head": 45 case "head":
46 request = httplib.Head(url) 46 request = httplib.Head(url)
47 break 47 break
48 - default: 48 + :
49 request = httplib.Get(url) 49 request = httplib.Get(url)
50 } 50 }
51 return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout) 51 return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout)