作者 陈志颖

fix conflict

正在显示 43 个修改的文件 包含 721 行增加279 行删除
@@ -11,6 +11,11 @@ @@ -11,6 +11,11 @@
11 - [APP端原型地址](https://9cnuol.axshare.com/) 11 - [APP端原型地址](https://9cnuol.axshare.com/)
12 - [WEB端原型地址](https://eq4yc2.axshare.com/) 12 - [WEB端原型地址](https://eq4yc2.axshare.com/)
13 13
  14 +## 开发环境服务地址
  15 +- [后端地址](http://allied-creation-cooperation-dev.fjmaimaimai.com/)
  16 +- [前端地址](http://allied-creation-standard-dev.fjmaimaimai.com/)
  17 +- [H5地址(app)](http://allied-creation-h5-dev.fjmaimaimai.com)
  18 +
14 ## 项目规范 19 ## 项目规范
15 - 领域描述语言文档位置:document/allied-creation-cooperation/ 20 - 领域描述语言文档位置:document/allied-creation-cooperation/
16 - GIT流程:里程碑->问题->功能分支->代码审查->合并分支 21 - GIT流程:里程碑->问题->功能分支->代码审查->合并分支
@@ -62,6 +62,8 @@ spec: @@ -62,6 +62,8 @@ spec:
62 value: "1" 62 value: "1"
63 - name: ERROR_BASE_CODE_MULTIPLE 63 - name: ERROR_BASE_CODE_MULTIPLE
64 value: "1000" 64 value: "1000"
  65 + - name: ENABLE_HTTPS
  66 + value: "true"
65 - name: ENABLE_KAFKA_LOG 67 - name: ENABLE_KAFKA_LOG
66 value: "false" 68 value: "false"
67 - name: USER_MODULE_HOST 69 - name: USER_MODULE_HOST
@@ -62,6 +62,8 @@ spec: @@ -62,6 +62,8 @@ spec:
62 value: "beego" 62 value: "beego"
63 - name: LOG_TYPE 63 - name: LOG_TYPE
64 value: "file" 64 value: "file"
  65 + - name: ENABLE_HTTPS
  66 + value: "true"
65 - name: ERROR_BASE_CODE 67 - name: ERROR_BASE_CODE
66 value: "1" 68 value: "1"
67 - name: ERROR_BASE_CODE_MULTIPLE 69 - name: ERROR_BASE_CODE_MULTIPLE
@@ -66,6 +66,8 @@ spec: @@ -66,6 +66,8 @@ spec:
66 value: "1" 66 value: "1"
67 - name: ERROR_BASE_CODE_MULTIPLE 67 - name: ERROR_BASE_CODE_MULTIPLE
68 value: "1000" 68 value: "1000"
  69 + - name: ENABLE_HTTPS
  70 + value: "true"
69 - name: ENABLE_KAFKA_LOG 71 - name: ENABLE_KAFKA_LOG
70 value: "false" 72 value: "false"
71 - name: USER_MODULE_HOST 73 - name: USER_MODULE_HOST
@@ -24,6 +24,10 @@ type OneClickApprovalCooperationApplicationCommand struct { @@ -24,6 +24,10 @@ type OneClickApprovalCooperationApplicationCommand struct {
24 Action int32 `cname:"审核动作" json:"action" valid:"Required"` 24 Action int32 `cname:"审核动作" json:"action" valid:"Required"`
25 // 审核状态 25 // 审核状态
26 CooperationApplicationStatus int32 `cname:"共创申请审核状态" json:"cooperationApplicationStatus"` 26 CooperationApplicationStatus int32 `cname:"共创申请审核状态" json:"cooperationApplicationStatus"`
  27 + // 查询限制
  28 + OffsetLimit bool `cname:"查询限制" json:"offsetLimit"`
  29 + // 是否取消标志
  30 + IsCanceled int32 `cname:"是否删除" json:"isCanceled"`
27 } 31 }
28 32
29 func (oneClickApprovalCooperationApplicationCommand *OneClickApprovalCooperationApplicationCommand) Valid(validation *validation.Validation) { 33 func (oneClickApprovalCooperationApplicationCommand *OneClickApprovalCooperationApplicationCommand) Valid(validation *validation.Validation) {
@@ -55,20 +55,20 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -55,20 +55,20 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
55 } 55 }
56 56
57 // 公司REST服务初始化 57 // 公司REST服务初始化
58 - var companyService service.CompanyService  
59 - if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {  
60 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
61 - } else {  
62 - companyService = value  
63 - } 58 + //var companyService service.CompanyService
  59 + //if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  60 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  61 + //} else {
  62 + // companyService = value
  63 + //}
64 64
65 // 组织机构REST服务初始化 65 // 组织机构REST服务初始化
66 - var organizationService service.OrgService  
67 - if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {  
68 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
69 - } else {  
70 - organizationService = value  
71 - } 66 + //var organizationService service.OrgService
  67 + //if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  68 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  69 + //} else {
  70 + // organizationService = value
  71 + //}
72 72
73 // 共创申请仓储初始化 73 // 共创申请仓储初始化
74 var cooperationApplicationRepository domain.CooperationApplicationRepository 74 var cooperationApplicationRepository domain.CooperationApplicationRepository
@@ -162,20 +162,20 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -162,20 +162,20 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
162 } 162 }
163 163
164 // 获取公司信息 164 // 获取公司信息
165 - var company *domain.Company  
166 - if data, err := companyService.CompanyFrom(applyForCooperationCommand.CompanyId); err != nil {  
167 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司信息失败")  
168 - } else {  
169 - company = data  
170 - } 165 + //var company *domain.Company
  166 + //if data, err := companyService.CompanyFrom(applyForCooperationCommand.CompanyId); err != nil {
  167 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司信息失败")
  168 + //} else {
  169 + // company = data
  170 + //}
171 171
172 // 获取组织机构信息 172 // 获取组织机构信息
173 - var organization *domain.Org  
174 - if data, err := organizationService.OrgFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId); err != nil {  
175 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取组织机构数据失败")  
176 - } else {  
177 - organization = data  
178 - } 173 + //var organization *domain.Org
  174 + //if data, err := organizationService.OrgFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId); err != nil {
  175 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取组织机构数据失败")
  176 + //} else {
  177 + // organization = data
  178 + //}
179 179
180 // 校验:同一个用户,不能多次申请同一个项目 180 // 校验:同一个用户,不能多次申请同一个项目
181 applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{ 181 applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{
@@ -211,9 +211,9 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -211,9 +211,9 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
211 CooperationApplicationVerifyTime: time.Time{}, 211 CooperationApplicationVerifyTime: time.Time{},
212 CooperationApplyTime: time.Now(), 212 CooperationApplyTime: time.Now(),
213 CooperationProject: cooperationProject, 213 CooperationProject: cooperationProject,
214 - Org: organization, 214 + Org: cooperationProject.Org,
215 IsCanceled: 1, 215 IsCanceled: 1,
216 - Company: company, 216 + Company: cooperationProject.Company,
217 CreatedAt: time.Now(), 217 CreatedAt: time.Now(),
218 DeletedAt: time.Time{}, 218 DeletedAt: time.Time{},
219 UpdatedAt: time.Time{}, 219 UpdatedAt: time.Time{},
@@ -371,6 +371,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova @@ -371,6 +371,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
371 // 获取共创申请 371 // 获取共创申请
372 if count, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{ 372 if count, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
373 "cooperationApplicationIds": cooperationApplicationIds, 373 "cooperationApplicationIds": cooperationApplicationIds,
  374 + "offsetLimit": false,
374 }); err != nil { 375 }); err != nil {
375 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 376 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
376 } else { 377 } else {
@@ -444,13 +445,18 @@ func (cooperationApplicationService *CooperationApplicationService) OneClickAppr @@ -444,13 +445,18 @@ func (cooperationApplicationService *CooperationApplicationService) OneClickAppr
444 // 获取审核人 445 // 获取审核人
445 var verifier *domain.User 446 var verifier *domain.User
446 if data, err := userService.UserFrom(oneClickApprovalCooperationApplicationCommand.CompanyId, oneClickApprovalCooperationApplicationCommand.OrgId, oneClickApprovalCooperationApplicationCommand.UserId); err != nil { 447 if data, err := userService.UserFrom(oneClickApprovalCooperationApplicationCommand.CompanyId, oneClickApprovalCooperationApplicationCommand.OrgId, oneClickApprovalCooperationApplicationCommand.UserId); err != nil {
447 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取申请人失败") 448 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取审核人失败")
448 } else { 449 } else {
449 verifier = data 450 verifier = data
450 } 451 }
451 452
452 // 查询共创申请 453 // 查询共创申请
453 oneClickApprovalCooperationApplicationCommand.CooperationApplicationStatus = 1 // 待审核 454 oneClickApprovalCooperationApplicationCommand.CooperationApplicationStatus = 1 // 待审核
  455 + oneClickApprovalCooperationApplicationCommand.OffsetLimit = false
  456 + oneClickApprovalCooperationApplicationCommand.IsCanceled = int32(1)
  457 + oneClickApprovalCooperationApplicationCommand.UserBaseId = 0
  458 + oneClickApprovalCooperationApplicationCommand.UserId = 0
  459 +
454 if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(oneClickApprovalCooperationApplicationCommand)); err != nil { 460 if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(oneClickApprovalCooperationApplicationCommand)); err != nil {
455 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 461 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
456 } else { 462 } else {
@@ -28,7 +28,7 @@ type UpdateCooperationContractCommand struct { @@ -28,7 +28,7 @@ type UpdateCooperationContractCommand struct {
28 // 金额激励规则列表 28 // 金额激励规则列表
29 MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"` 29 MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"`
30 // 承接方列表 30 // 承接方列表
31 - Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers" valid:"Required"` 31 + Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers"`
32 // 相关人UID列表 32 // 相关人UID列表
33 RelevantIds []string `cname:"相关人列表" json:"relevantIds,omitempty"` 33 RelevantIds []string `cname:"相关人列表" json:"relevantIds,omitempty"`
34 // 公司ID,通过集成REST上下文获取 34 // 公司ID,通过集成REST上下文获取
@@ -561,6 +561,7 @@ func (cooperationContractService *CooperationContractService) BatchRemoveCoopera @@ -561,6 +561,7 @@ func (cooperationContractService *CooperationContractService) BatchRemoveCoopera
561 cooperationContractIds, _ := utils.SliceAtoi(batchRemoveCooperationContractCommand.CooperationContractIds) 561 cooperationContractIds, _ := utils.SliceAtoi(batchRemoveCooperationContractCommand.CooperationContractIds)
562 if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{ 562 if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
563 "cooperationContractIds": cooperationContractIds, 563 "cooperationContractIds": cooperationContractIds,
  564 + "offsetLimit": false,
564 }); err != nil { 565 }); err != nil {
565 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 566 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
566 } else { 567 } else {
@@ -737,6 +738,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper @@ -737,6 +738,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper
737 } 738 }
738 if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{ 739 if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
739 "cooperationContractIds": cooperationContractIds, 740 "cooperationContractIds": cooperationContractIds,
  741 + "offsetLimit": false,
740 }); err != nil { 742 }); err != nil {
741 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 743 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
742 } else { 744 } else {
@@ -1203,7 +1205,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1203,7 +1205,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1203 // 保存共创合约变更记录 1205 // 保存共创合约变更记录
1204 var incentivesRuleChange string 1206 var incentivesRuleChange string
1205 var incentivesRuleChangeDetail string 1207 var incentivesRuleChangeDetail string
1206 - var undertakerChange string  
1207 1208
1208 // 规则变更,原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】 1209 // 规则变更,原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】
1209 if cooperationContractFound.IncentivesType != cooperationContract.IncentivesType { // 1.激励规则类型变更 1210 if cooperationContractFound.IncentivesType != cooperationContract.IncentivesType { // 1.激励规则类型变更
@@ -1380,6 +1381,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1380,6 +1381,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1380 } 1381 }
1381 1382
1382 /*********************************************** 承接人变更 *****************************************************/ 1383 /*********************************************** 承接人变更 *****************************************************/
  1384 + var undertakerChange string
1383 // 计算原合约哈希值 1385 // 计算原合约哈希值
1384 //cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers)) 1386 //cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers))
1385 var cooperationContractFoundBytes []byte 1387 var cooperationContractFoundBytes []byte
@@ -1439,7 +1441,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1439,7 +1441,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1439 UserPhone: "", 1441 UserPhone: "",
1440 } 1442 }
1441 } 1443 }
1442 - undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" 1444 + undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
1443 } 1445 }
1444 undertakerChangeTmp1 := "【" + undertakersOriginal + "】" 1446 undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
1445 1447
@@ -1476,7 +1478,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1476,7 +1478,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1476 UserPhone: "", 1478 UserPhone: "",
1477 } 1479 }
1478 } 1480 }
1479 - undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" 1481 + undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
1480 } 1482 }
1481 undertakerChangeTemp2 := "【" + undertakersChanged + "】" 1483 undertakerChangeTemp2 := "【" + undertakersChanged + "】"
1482 // 拼接承接人变更记录 1484 // 拼接承接人变更记录
@@ -328,6 +328,7 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode @@ -328,6 +328,7 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode
328 // 获取共创模式 328 // 获取共创模式
329 if count, cooperationModes, err := cooperationModeRepository.Find(map[string]interface{}{ 329 if count, cooperationModes, err := cooperationModeRepository.Find(map[string]interface{}{
330 "cooperationModeIds": cooperationModeIds, 330 "cooperationModeIds": cooperationModeIds,
  331 + "offsetLimit": false,
331 }); err != nil { 332 }); err != nil {
332 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 333 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
333 } else { 334 } else {
@@ -14,13 +14,13 @@ type GetCooperationProjectQuery struct { @@ -14,13 +14,13 @@ type GetCooperationProjectQuery struct {
14 // 共创项目编号 14 // 共创项目编号
15 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber"` 15 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber"`
16 // 公司ID,通过集成REST上下文获取 16 // 公司ID,通过集成REST上下文获取
17 - CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` 17 + CompanyId int64 `cname:"公司ID" json:"companyId"`
18 // 组织机构ID 18 // 组织机构ID
19 - OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"` 19 + OrgId int64 `cname:"组织机构ID" json:"orgId"`
20 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 20 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
21 - UserId int64 `cname:"用户ID" json:"userId" valid:"Required"` 21 + UserId int64 `cname:"用户ID" json:"userId"`
22 // 用户基础数据id 22 // 用户基础数据id
23 - UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"` 23 + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
24 } 24 }
25 25
26 func (getCooperationProjectQuery *GetCooperationProjectQuery) Valid(validation *validation.Validation) { 26 func (getCooperationProjectQuery *GetCooperationProjectQuery) Valid(validation *validation.Validation) {
@@ -52,6 +52,8 @@ type SearchCooperationProjectQuery struct { @@ -52,6 +52,8 @@ type SearchCooperationProjectQuery struct {
52 UserId int64 `cname:"用户ID" json:"userId"` 52 UserId int64 `cname:"用户ID" json:"userId"`
53 // 用户基础数据id 53 // 用户基础数据id
54 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"` 54 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
  55 + // 额外的查询条件 0:不需要额外查询 1:额外查询
  56 + SearchCooperationProjectExtQueriesFlag int `cname:"额外的查询条件标识" json:"searchCooperationProjectExtQueriesFlag"`
55 // 额外的查询条件 57 // 额外的查询条件
56 SearchCooperationProjectExtQueries []*SearchCooperationProjectExtQuery `cname:"额外的查询条件" json:"searchCooperationProjectExtQueries"` 58 SearchCooperationProjectExtQueries []*SearchCooperationProjectExtQuery `cname:"额外的查询条件" json:"searchCooperationProjectExtQueries"`
57 } 59 }
@@ -281,6 +281,16 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -281,6 +281,16 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
281 cooperationApplicationRepository = value 281 cooperationApplicationRepository = value
282 } 282 }
283 283
  284 + // 共创合约仓储初始化
  285 + var cooperationContractRepository domain.CooperationContractRepository
  286 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  287 + "transactionContext": transactionContext,
  288 + }); err != nil {
  289 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  290 + } else {
  291 + cooperationContractRepository = value
  292 + }
  293 +
284 var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery 294 var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery
285 if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询 295 if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询
286 getCooperationProjectQuerySpecific = &query.GetCooperationProjectQuery{ 296 getCooperationProjectQuerySpecific = &query.GetCooperationProjectQuery{
@@ -349,6 +359,47 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -349,6 +359,47 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
349 undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3) 359 undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
350 } 360 }
351 361
  362 + // 判断项目关联的合约承接人类型
  363 + undertakers := make([]*domain.Undertaker, 0)
  364 + if countContracts, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
  365 + "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
  366 + "companyId": cooperationProject.Company.CompanyId,
  367 + "orgId": cooperationProject.Org.OrgId,
  368 + "offsetLimit": false,
  369 + }); err != nil {
  370 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  371 + } else {
  372 + if countContracts > 0 {
  373 + for _, cooperationContract := range cooperationContracts {
  374 + undertakers = append(undertakers, cooperationContract.Undertakers...)
  375 + }
  376 + }
  377 + }
  378 +
  379 + var undertakerUserTypes []int32
  380 + for _, undertaker := range undertakers {
  381 + undertakerUserTypes = append(undertakerUserTypes, undertaker.UserType)
  382 + }
  383 +
  384 + undertakerUserTypes = utils.RemoveDuplicationInt32(undertakerUserTypes)
  385 +
  386 + for i, userType := range undertakerUserTypes {
  387 + if userType == 1025 {
  388 + undertakerUserTypes[i] = 2
  389 + }
  390 + }
  391 +
  392 + if utils.IsContain(undertakerUserTypes, int32(1)) && utils.IsContain(undertakerUserTypes, int32(2)) {
  393 + undertakerUserTypes = append(undertakerUserTypes, int32(3))
  394 + }
  395 +
  396 + // 取项目承接人和合约承接人的交集
  397 + newUndertakerTypesUncheckedAvailable := utils.Intersect32(undertakerTypesUncheckedAvailable, undertakerUserTypes)
  398 +
  399 + log.Logger.Info("承接人类型", map[string]interface{}{
  400 + "undertakerUserTypes": undertakerUserTypes,
  401 + })
  402 +
352 // 返回所有员工类型的申请通过人 403 // 返回所有员工类型的申请通过人
353 applicants := make([]*domain.User, 0) 404 applicants := make([]*domain.User, 0)
354 405
@@ -357,6 +408,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -357,6 +408,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
357 "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber, 408 "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber,
358 "companyId": cooperationProject.Company.CompanyId, 409 "companyId": cooperationProject.Company.CompanyId,
359 "orgId": cooperationProject.Org.OrgId, 410 "orgId": cooperationProject.Org.OrgId,
  411 + "offsetLimit": false,
360 }); err != nil { 412 }); err != nil {
361 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 413 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
362 } else { 414 } else {
@@ -375,7 +427,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -375,7 +427,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
375 } 427 }
376 428
377 cooperationProjectDto := &dto.CooperationProjectsDto{} 429 cooperationProjectDto := &dto.CooperationProjectsDto{}
378 - if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable, applicants); err != nil { 430 + if err := cooperationProjectDto.LoadDto(cooperationProject, nil, newUndertakerTypesUncheckedAvailable, applicants); err != nil {
379 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 431 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
380 } 432 }
381 if err := transactionContext.CommitTransaction(); err != nil { 433 if err := transactionContext.CommitTransaction(); err != nil {
@@ -639,6 +691,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -639,6 +691,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
639 } 691 }
640 } 692 }
641 } 693 }
  694 +
642 var undertakerTypes []int32 695 var undertakerTypes []int32
643 var k1, k2 int32 696 var k1, k2 int32
644 if len(applicantTypes) > 0 { 697 if len(applicantTypes) > 0 {
@@ -654,6 +707,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -654,6 +707,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
654 if k1 != 0 && k2 != 0 { 707 if k1 != 0 && k2 != 0 {
655 undertakerTypes = append(undertakerTypes, 3) 708 undertakerTypes = append(undertakerTypes, 3)
656 } 709 }
  710 +
657 // 校验可以修改的承接人(申请人)类型 711 // 校验可以修改的承接人(申请人)类型
658 for _, t := range undertakerTypes { 712 for _, t := range undertakerTypes {
659 if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) { 713 if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) {
@@ -766,6 +820,7 @@ func (cooperationProjectService *CooperationProjectService) BatchEndCooperationP @@ -766,6 +820,7 @@ func (cooperationProjectService *CooperationProjectService) BatchEndCooperationP
766 } 820 }
767 if count, cooperationProjects, err := cooperationProjectRepository.Find(map[string]interface{}{ 821 if count, cooperationProjects, err := cooperationProjectRepository.Find(map[string]interface{}{
768 "cooperationProjectIds": cooperationProjectIds, 822 "cooperationProjectIds": cooperationProjectIds,
  823 + "offsetLimit": false,
769 }); err != nil { 824 }); err != nil {
770 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 825 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
771 } else { 826 } else {
@@ -28,6 +28,8 @@ type SearchDividendsEstimateQuery struct { @@ -28,6 +28,8 @@ type SearchDividendsEstimateQuery struct {
28 PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"` 28 PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"`
29 // 页面大小 29 // 页面大小
30 PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` 30 PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
  31 + // 是否取消(删除)
  32 + IsCanceled bool `cname:"是否取消" json:"isCanceled,omitempty"`
31 } 33 }
32 34
33 func (searchDividendsEstimateQuery *SearchDividendsEstimateQuery) Valid(validation *validation.Validation) { 35 func (searchDividendsEstimateQuery *SearchDividendsEstimateQuery) Valid(validation *validation.Validation) {
@@ -343,6 +343,7 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -343,6 +343,7 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
343 // 获取分红预算 343 // 获取分红预算
344 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ 344 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
345 "dividendsEstimateIds": dividendsEstimateIds, 345 "dividendsEstimateIds": dividendsEstimateIds,
  346 + "offsetLimit": false,
346 }); err != nil { 347 }); err != nil {
347 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 348 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
348 } else { 349 } else {
@@ -520,6 +521,7 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat @@ -520,6 +521,7 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat
520 521
521 // ConfirmDividendsIncentivesEstimate 确定业绩激励分红预算 522 // ConfirmDividendsIncentivesEstimate 确定业绩激励分红预算
522 func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncentivesEstimate(confirmDividendsIncentivesEstimateCommand *command.ConfirmDividendsIncentivesEstimateCommand) (interface{}, error) { 523 func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncentivesEstimate(confirmDividendsIncentivesEstimateCommand *command.ConfirmDividendsIncentivesEstimateCommand) (interface{}, error) {
  524 + start := time.Now()
523 if err := confirmDividendsIncentivesEstimateCommand.ValidateCommand(); err != nil { 525 if err := confirmDividendsIncentivesEstimateCommand.ValidateCommand(); err != nil {
524 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 526 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
525 } 527 }
@@ -549,12 +551,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -549,12 +551,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
549 } 551 }
550 552
551 // 获取公司信息 553 // 获取公司信息
  554 + startGetCompany := time.Now()
552 var company *domain.Company 555 var company *domain.Company
553 if data, err := companyService.CompanyFrom(confirmDividendsIncentivesEstimateCommand.CompanyId); err != nil { 556 if data, err := companyService.CompanyFrom(confirmDividendsIncentivesEstimateCommand.CompanyId); err != nil {
554 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 557 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
555 } else { 558 } else {
556 company = data 559 company = data
557 } 560 }
  561 + fmt.Println("获取公司信息耗时:", time.Since(startGetCompany))
558 562
559 // 组织机构REST服务初始化 563 // 组织机构REST服务初始化
560 var organizationService service.OrgService 564 var organizationService service.OrgService
@@ -565,12 +569,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -565,12 +569,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
565 } 569 }
566 570
567 // 获取组织机构信息 571 // 获取组织机构信息
  572 + startGetOrg := time.Now()
568 var organization *domain.Org 573 var organization *domain.Org
569 if data, err := organizationService.OrgFrom(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil { 574 if data, err := organizationService.OrgFrom(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil {
570 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 575 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
571 } else { 576 } else {
572 organization = data 577 organization = data
573 } 578 }
  579 + fmt.Println("获取组织机构数据耗时:", time.Since(startGetOrg))
574 580
575 // 用户REST服务初始化 581 // 用户REST服务初始化
576 var userService service.UserService 582 var userService service.UserService
@@ -581,12 +587,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -581,12 +587,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
581 } 587 }
582 588
583 // 获取操作人 589 // 获取操作人
  590 + startGetOperator := time.Now()
584 var operator *domain.User 591 var operator *domain.User
585 if data, err := userService.OperatorFrom(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, confirmDividendsIncentivesEstimateCommand.UserId); err != nil { 592 if data, err := userService.OperatorFrom(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, confirmDividendsIncentivesEstimateCommand.UserId); err != nil {
586 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 593 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
587 } else { 594 } else {
588 operator = data 595 operator = data
589 } 596 }
  597 + fmt.Println("获取操作人耗时:", time.Since(startGetOperator))
590 598
591 // 订单产品仓储初始化 599 // 订单产品仓储初始化
592 var orderGoodRepository domain.OrderGoodRepository 600 var orderGoodRepository domain.OrderGoodRepository
@@ -638,6 +646,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -638,6 +646,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
638 dividendsReturnedOrderRepository = value 646 dividendsReturnedOrderRepository = value
639 } 647 }
640 648
  649 + // 共创合约仓储初始化
  650 + var cooperationContractRepository domain.CooperationContractRepository
  651 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  652 + "transactionContext": transactionContext,
  653 + }); err != nil {
  654 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  655 + } else {
  656 + cooperationContractRepository = value
  657 + }
  658 +
641 // 初始化确认业绩激励分红预算领域服务 659 // 初始化确认业绩激励分红预算领域服务
642 var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService 660 var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
643 if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{ 661 if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{
@@ -658,13 +676,52 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -658,13 +676,52 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
658 estimateFailedDividendsOrders := make(map[string]string) 676 estimateFailedDividendsOrders := make(map[string]string)
659 677
660 // 获取订单产品 678 // 获取订单产品
  679 + startGetOrderGoods := time.Now()
661 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{ 680 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
662 "orderGoodIds": orderGoodIds, 681 "orderGoodIds": orderGoodIds,
  682 + "offsetLimit": false,
663 }); err != nil { 683 }); err != nil {
664 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 684 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
665 } else { 685 } else {
  686 + fmt.Println("获取订单产品耗时:", time.Since(startGetOrderGoods))
  687 +
666 dividendsEstimates := make([]*domain.DividendsEstimate, 0) 688 dividendsEstimates := make([]*domain.DividendsEstimate, 0)
667 689
  690 + var cooperationContractNumbers []string
  691 +
  692 + // 获取订单产品合约编号
  693 + for _, orderGood := range orderGoods {
  694 + cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber)
  695 + }
  696 +
  697 + newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers)
  698 +
  699 + cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
  700 +
  701 + // 查询共创合约
  702 + startQueryContracts := time.Now()
  703 + if len(newCooperationContractNumbers) > 0 {
  704 + if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
  705 + "cooperationContractNumbers": newCooperationContractNumbers,
  706 + "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
  707 + "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
  708 + "offsetLimit": false,
  709 + }); err != nil {
  710 + return nil, err
  711 + } else {
  712 + if count > 0 {
  713 + for _, cooperationContractFound := range cooperationContractsFound {
  714 + cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
  715 + }
  716 + }
  717 + }
  718 + } else {
  719 + return map[string]interface{}{
  720 + "report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"),
  721 + }, nil
  722 + }
  723 + fmt.Println("查询共创合约耗时:", time.Since(startQueryContracts))
  724 +
668 // 统计当前企业分红预算单数 725 // 统计当前企业分红预算单数
669 count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{ 726 count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
670 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId, 727 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
@@ -674,14 +731,21 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -674,14 +731,21 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
674 } 731 }
675 732
676 var countDividendsEstimate int64 733 var countDividendsEstimate int64
677 - for _, orderGood := range orderGoods {  
678 - dividendsEstimate := &domain.DividendsEstimate{}  
679 - if orderGood.DividendsOrderNumber != "" { // 查询分红订单  
680 - // 临时方案 734 +
681 orderGoodsToConfirm := make([]*domain.OrderGood, 0) 735 orderGoodsToConfirm := make([]*domain.OrderGood, 0)
  736 + returnedOrderGoodsToConfirm := make([]*domain.OrderGood, 0)
  737 +
  738 + for _, orderGood := range orderGoods {
  739 + if orderGood.DividendsOrderNumber != "" {
682 orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood) 740 orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
683 - // 分红订单产品预算  
684 - if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm); err != nil { 741 + } else if orderGood.DividendsReturnedOrderNumber != "" {
  742 + returnedOrderGoodsToConfirm = append(returnedOrderGoodsToConfirm, orderGood)
  743 + }
  744 + }
  745 +
  746 + startConfirm := time.Now()
  747 + if len(orderGoodsToConfirm) > 0 { // 分红订单产品预算
  748 + if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
685 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 749 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
686 } else { 750 } else {
687 for _, dividendsEstimateDetail := range dividendsEstimateDetails { 751 for _, dividendsEstimateDetail := range dividendsEstimateDetails {
@@ -698,7 +762,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -698,7 +762,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
698 // 统计分红预算单数目 762 // 统计分红预算单数目
699 countDividendsEstimate = countDividendsEstimate + 1 763 countDividendsEstimate = countDividendsEstimate + 1
700 764
701 - dividendsEstimate = &domain.DividendsEstimate{ 765 + dividendsEstimate := &domain.DividendsEstimate{
702 DividendsEstimateId: 0, 766 DividendsEstimateId: 0,
703 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 767 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
704 DividendsAmount: dividendsEstimateDetail.DividendsAmount, 768 DividendsAmount: dividendsEstimateDetail.DividendsAmount,
@@ -707,8 +771,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -707,8 +771,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
707 DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType, 771 DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
708 DividendsType: domain.ORDER_DIVIDENDS, 772 DividendsType: domain.ORDER_DIVIDENDS,
709 DividendsTypeName: "订单分红", 773 DividendsTypeName: "订单分红",
710 - OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,  
711 - CooperationContractNumber: orderGood.CooperationContractNumber, 774 + OrderOrReturnedOrderNum: dividendsEstimateDetail.OrderOrReturnedOrderNumber,
  775 + CooperationContractNumber: dividendsEstimateDetail.CooperationContractNumber,
712 DividendsUser: dividendsEstimateDetail.DividendsUser, 776 DividendsUser: dividendsEstimateDetail.DividendsUser,
713 DividendsPercentage: dividendsEstimateDetail.DividendsPercentage, 777 DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
714 DividendsStage: dividendsEstimateDetail.DividendsStage, 778 DividendsStage: dividendsEstimateDetail.DividendsStage,
@@ -720,8 +784,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -720,8 +784,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
720 CreatedAt: time.Now(), 784 CreatedAt: time.Now(),
721 DeletedAt: time.Time{}, 785 DeletedAt: time.Time{},
722 UpdatedAt: time.Time{}, 786 UpdatedAt: time.Time{},
723 - OrderGoodId: orderGood.OrderGoodId,  
724 - OrderGoodAmount: orderGood.OrderGoodAmount, 787 + OrderGoodId: dividendsEstimateDetail.OrderGoodId,
  788 + OrderGoodAmount: dividendsEstimateDetail.OrderGoodAmount,
725 PaymentStatus: int32(1), 789 PaymentStatus: int32(1),
726 CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId, 790 CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
727 } 791 }
@@ -733,11 +797,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -733,11 +797,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
733 } 797 }
734 } 798 }
735 } 799 }
736 - } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单  
737 - orderGoodsToConfirm := make([]*domain.OrderGood, 0)  
738 - orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)  
739 - // 分红退货单产品预算  
740 - if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm); err != nil { 800 + } else if len(returnedOrderGoodsToConfirm) > 0 { // 退货单产品预算
  801 + if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(returnedOrderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
741 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 802 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
742 } else { 803 } else {
743 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails { 804 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
@@ -754,7 +815,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -754,7 +815,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
754 // 统计生成的预算单数量 815 // 统计生成的预算单数量
755 countDividendsEstimate = countDividendsEstimate + 1 816 countDividendsEstimate = countDividendsEstimate + 1
756 817
757 - dividendsEstimate = &domain.DividendsEstimate{ 818 + dividendsEstimate := &domain.DividendsEstimate{
758 DividendsEstimateId: 0, 819 DividendsEstimateId: 0,
759 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 820 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
760 DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount, 821 DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
@@ -763,8 +824,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -763,8 +824,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
763 DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType, 824 DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
764 DividendsType: domain.RETURN_WRITE_OFF, 825 DividendsType: domain.RETURN_WRITE_OFF,
765 DividendsTypeName: "退货冲销", 826 DividendsTypeName: "退货冲销",
766 - OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,  
767 - CooperationContractNumber: orderGood.CooperationContractNumber, 827 + OrderOrReturnedOrderNum: dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber,
  828 + CooperationContractNumber: dividendsReturnedEstimateDetail.CooperationContractNumber,
768 DividendsUser: dividendsReturnedEstimateDetail.DividendsUser, 829 DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
769 DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage, 830 DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
770 DividendsStage: dividendsReturnedEstimateDetail.DividendsStage, 831 DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
@@ -776,8 +837,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -776,8 +837,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
776 CreatedAt: time.Now(), 837 CreatedAt: time.Now(),
777 DeletedAt: time.Time{}, 838 DeletedAt: time.Time{},
778 UpdatedAt: time.Time{}, 839 UpdatedAt: time.Time{},
779 - OrderGoodId: orderGood.OrderGoodId,  
780 - OrderGoodAmount: orderGood.OrderGoodAmount, 840 + OrderGoodId: dividendsReturnedEstimateDetail.OrderGoodId,
  841 + OrderGoodAmount: dividendsReturnedEstimateDetail.OrderGoodAmount,
781 PaymentStatus: int32(1), 842 PaymentStatus: int32(1),
782 CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId, 843 CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
783 } 844 }
@@ -790,15 +851,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -790,15 +851,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
790 } 851 }
791 } 852 }
792 } 853 }
793 - }  
794 -  
795 - log.Logger.Info("新增的分红预算单", map[string]interface{}{  
796 - "dividendsEstimates": dividendsEstimates,  
797 - }) 854 + fmt.Println("订单分红耗时:", time.Since(startConfirm))
798 855
  856 + startInsert := time.Now()
799 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil { 857 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
800 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 858 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
801 } else { 859 } else {
  860 + fmt.Println("插入预算单耗时:", time.Since(startInsert))
802 // 获取产品ID 861 // 获取产品ID
803 orderGoodSavedIds := make([]int64, 0) 862 orderGoodSavedIds := make([]int64, 0)
804 for _, dividendsEstimate := range dividendsEstimates { 863 for _, dividendsEstimate := range dividendsEstimates {
@@ -806,10 +865,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -806,10 +865,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
806 } 865 }
807 866
808 // 更新订单产品分红状态 867 // 更新订单产品分红状态
  868 + startUpdateGoodStatus := time.Now()
809 var orderGoodsSaved []*domain.OrderGood 869 var orderGoodsSaved []*domain.OrderGood
810 if len(orderGoodSavedIds) > 0 { 870 if len(orderGoodSavedIds) > 0 {
  871 + // 订单产品ID去重
  872 + newOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodSavedIds)
811 if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{ 873 if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
812 - "orderGoodIds": orderGoodSavedIds, 874 + "orderGoodIds": newOrderGoodIds,
  875 + "offsetLimit": false,
813 }); err != nil { 876 }); err != nil {
814 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 877 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
815 } else { 878 } else {
@@ -824,6 +887,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -824,6 +887,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
824 } 887 }
825 } 888 }
826 } 889 }
  890 + fmt.Println("更新订单产品分红状态耗时:", time.Since(startUpdateGoodStatus))
827 891
828 // 分离分红订单和退货单 892 // 分离分红订单和退货单
829 dividendsOrderNumbers := make([]string, 0) 893 dividendsOrderNumbers := make([]string, 0)
@@ -840,20 +904,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -840,20 +904,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
840 } 904 }
841 } 905 }
842 906
843 - log.Logger.Info("分红订单", map[string]interface{}{  
844 - "dividendsOrderNumbers": dividendsOrderNumbers,  
845 - })  
846 -  
847 - log.Logger.Info("分红退货单", map[string]interface{}{  
848 - "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,  
849 - })  
850 -  
851 // 查找分红订单 907 // 查找分红订单
  908 + startUpdateOrder := time.Now()
852 if len(dividendsOrderNumbers) > 0 { 909 if len(dividendsOrderNumbers) > 0 {
853 if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{ 910 if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{
854 "dividendsOrderNumbers": dividendsOrderNumbers, 911 "dividendsOrderNumbers": dividendsOrderNumbers,
855 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId, 912 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
856 "orgId": confirmDividendsIncentivesEstimateCommand.OrgId, 913 "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
  914 + "offsetLimit": false,
857 }); err != nil { 915 }); err != nil {
858 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 916 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
859 } else { 917 } else {
@@ -890,13 +948,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -890,13 +948,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
890 } 948 }
891 } 949 }
892 } 950 }
  951 + fmt.Println("更新订单耗时:", time.Since(startUpdateOrder))
893 952
894 // 查找分红退货单 953 // 查找分红退货单
  954 + startUpdateReturnedOrder := time.Now()
895 if len(dividendsReturnedOrderNumbers) > 0 { 955 if len(dividendsReturnedOrderNumbers) > 0 {
896 if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ 956 if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
897 "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers, 957 "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,
898 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId, 958 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
899 "orgId": confirmDividendsIncentivesEstimateCommand.OrgId, 959 "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
  960 + "offsetLimit": false,
900 }); err != nil { 961 }); err != nil {
901 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 962 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
902 } else { 963 } else {
@@ -933,9 +994,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -933,9 +994,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
933 } 994 }
934 } 995 }
935 996
  997 + fmt.Println("更新退货单耗时:", time.Since(startUpdateReturnedOrder))
  998 +
  999 + startCommit := time.Now()
936 if err := transactionContext.CommitTransaction(); err != nil { 1000 if err := transactionContext.CommitTransaction(); err != nil {
937 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1001 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
938 } 1002 }
  1003 + fmt.Println("提交事务耗时:", time.Since(startCommit))
939 1004
940 // 统计成功的分红预算 1005 // 统计成功的分红预算
941 successfullyCount := len(dividendsEstimatesSaved) 1006 successfullyCount := len(dividendsEstimatesSaved)
@@ -952,6 +1017,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -952,6 +1017,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
952 failedReasonStr = "无" 1017 failedReasonStr = "无"
953 } 1018 }
954 1019
  1020 + fmt.Println("函数执行完毕:", time.Since(start))
  1021 +
955 return map[string]interface{}{ 1022 return map[string]interface{}{
956 "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr), 1023 "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
957 }, nil 1024 }, nil
@@ -1166,7 +1233,10 @@ func (dividendsEstimateService *DividendsEstimateService) GetDividendsEstimate(g @@ -1166,7 +1233,10 @@ func (dividendsEstimateService *DividendsEstimateService) GetDividendsEstimate(g
1166 } else { 1233 } else {
1167 dividendsEstimateRepository = value 1234 dividendsEstimateRepository = value
1168 } 1235 }
1169 - dividendsEstimate, err := dividendsEstimateRepository.FindOne(map[string]interface{}{"dividendsEstimateId": getDividendsEstimateQuery.DividendsEstimateId}) 1236 + dividendsEstimate, err := dividendsEstimateRepository.FindOne(map[string]interface{}{
  1237 + "dividendsEstimateId": getDividendsEstimateQuery.DividendsEstimateId,
  1238 + "isCanceled": false,
  1239 + })
1170 if err != nil { 1240 if err != nil {
1171 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1241 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1172 } 1242 }
@@ -1283,6 +1353,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat @@ -1283,6 +1353,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat
1283 } else { 1353 } else {
1284 dividendsEstimateRepository = value 1354 dividendsEstimateRepository = value
1285 } 1355 }
  1356 + searchDividendsEstimateQuery.IsCanceled = false
1286 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(tool_funs.SimpleStructToMap(searchDividendsEstimateQuery)); err != nil { 1357 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(tool_funs.SimpleStructToMap(searchDividendsEstimateQuery)); err != nil {
1287 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1358 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1288 } else { 1359 } else {
@@ -14,13 +14,13 @@ type GetDividendsOrderQuery struct { @@ -14,13 +14,13 @@ type GetDividendsOrderQuery struct {
14 // 分红订单编号 14 // 分红订单编号
15 DividendsOrderNumber string `cname:"分红订单编号" json:"dividendsOrderNumber,omitempty"` 15 DividendsOrderNumber string `cname:"分红订单编号" json:"dividendsOrderNumber,omitempty"`
16 // 公司ID,通过集成REST上下文获取 16 // 公司ID,通过集成REST上下文获取
17 - CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` 17 + CompanyId int64 `cname:"公司ID" json:"companyId"`
18 // 组织机构ID 18 // 组织机构ID
19 - OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"` 19 + OrgId int64 `cname:"组织机构ID" json:"orgId"`
20 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 20 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
21 - UserId int64 `cname:"用户ID" json:"userId" valid:"Required"` 21 + UserId int64 `cname:"用户ID" json:"userId"`
22 // 用户基础数据id 22 // 用户基础数据id
23 - UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"` 23 + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
24 } 24 }
25 25
26 func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) { 26 func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) {
@@ -406,8 +406,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -406,8 +406,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
406 v := reflect.ValueOf(dividendsOrder) 406 v := reflect.ValueOf(dividendsOrder)
407 for k := 0; k < t.NumField(); k++ { 407 for k := 0; k < t.NumField(); k++ {
408 //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()), ", yaml:", t.Field(k).Tag.Get("yaml")) 408 //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()), ", yaml:", t.Field(k).Tag.Get("yaml"))
409 - fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))  
410 - if t.Field(k).Name != "RegionName" && t.Field(k).Name != "Expense" { 409 + //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))
  410 + if t.Field(k).Name != "Expense" {
411 if v.Field(k).Interface() == "" { 411 if v.Field(k).Interface() == "" {
412 col := strconv.Itoa(k + 1) 412 col := strconv.Itoa(k + 1)
413 nullCell = append(nullCell, col) 413 nullCell = append(nullCell, col)
@@ -439,10 +439,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -439,10 +439,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
439 439
440 /***************************************************** 3.单元格类型校验 *********************************************/ 440 /***************************************************** 3.单元格类型校验 *********************************************/
441 typeError := make([]*domain.FailInfo, 0) 441 typeError := make([]*domain.FailInfo, 0)
442 - for _, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { // 行  
443 - var myRow []*domain.FailInfo 442 +
  443 + for j, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { // 行
444 t := reflect.TypeOf(dividendsOrder) 444 t := reflect.TypeOf(dividendsOrder)
445 v := reflect.ValueOf(dividendsOrder) 445 v := reflect.ValueOf(dividendsOrder)
  446 + var myRow []*domain.FailInfo
446 for k := 0; k < t.NumField(); k++ { // 列 447 for k := 0; k < t.NumField(); k++ { // 列
447 //r := strconv.Itoa(i + 1) 448 //r := strconv.Itoa(i + 1)
448 switch k { 449 switch k {
@@ -454,7 +455,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -454,7 +455,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
454 tmpRow := &domain.FailInfo{ 455 tmpRow := &domain.FailInfo{
455 FailReason: "订单日期格式错误,请输入正确的订单日期", 456 FailReason: "订单日期格式错误,请输入正确的订单日期",
456 } 457 }
457 - tmpRow.ImportDividendsOrderData = &dividendsOrder 458 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[j]
458 myRow = append(myRow, tmpRow) 459 myRow = append(myRow, tmpRow)
459 continue 460 continue
460 } 461 }
@@ -467,7 +468,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -467,7 +468,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
467 tmpRow := &domain.FailInfo{ 468 tmpRow := &domain.FailInfo{
468 FailReason: "行产品数量格式错误,产品数量必须整数", 469 FailReason: "行产品数量格式错误,产品数量必须整数",
469 } 470 }
470 - tmpRow.ImportDividendsOrderData = &dividendsOrder 471 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[j]
471 myRow = append(myRow, tmpRow) 472 myRow = append(myRow, tmpRow)
472 continue 473 continue
473 } 474 }
@@ -476,7 +477,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -476,7 +477,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
476 tmpRow := &domain.FailInfo{ 477 tmpRow := &domain.FailInfo{
477 FailReason: "产品数量必须大于0,请重新填写", 478 FailReason: "产品数量必须大于0,请重新填写",
478 } 479 }
479 - tmpRow.ImportDividendsOrderData = &dividendsOrder 480 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[j]
480 myRow = append(myRow, tmpRow) 481 myRow = append(myRow, tmpRow)
481 continue 482 continue
482 } 483 }
@@ -489,7 +490,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -489,7 +490,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
489 tmpRow := &domain.FailInfo{ 490 tmpRow := &domain.FailInfo{
490 FailReason: "产品价格格式错误,产品价格必须为数字类型", 491 FailReason: "产品价格格式错误,产品价格必须为数字类型",
491 } 492 }
492 - tmpRow.ImportDividendsOrderData = &dividendsOrder 493 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[j]
493 myRow = append(myRow, tmpRow) 494 myRow = append(myRow, tmpRow)
494 continue 495 continue
495 } 496 }
@@ -499,7 +500,16 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -499,7 +500,16 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
499 tmpRow := &domain.FailInfo{ 500 tmpRow := &domain.FailInfo{
500 FailReason: "产品价格超过最大限制,产品价格小数点前面不能超过十六位数字,并保留两位小数", 501 FailReason: "产品价格超过最大限制,产品价格小数点前面不能超过十六位数字,并保留两位小数",
501 } 502 }
502 - tmpRow.ImportDividendsOrderData = &dividendsOrder 503 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[j]
  504 + myRow = append(myRow, tmpRow)
  505 + continue
  506 + }
  507 + // 正负判断
  508 + if univalent < 0 {
  509 + tmpRow := &domain.FailInfo{
  510 + FailReason: "产品价格必须大于0,请重新填写",
  511 + }
  512 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[j]
503 myRow = append(myRow, tmpRow) 513 myRow = append(myRow, tmpRow)
504 continue 514 continue
505 } 515 }
@@ -513,7 +523,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -513,7 +523,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
513 tmpRow := &domain.FailInfo{ 523 tmpRow := &domain.FailInfo{
514 FailReason: "费用格式错误,费用必须为数字类型", 524 FailReason: "费用格式错误,费用必须为数字类型",
515 } 525 }
516 - tmpRow.ImportDividendsOrderData = &dividendsOrder 526 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[j]
517 myRow = append(myRow, tmpRow) 527 myRow = append(myRow, tmpRow)
518 log.Logger.Info("费用类型错误", map[string]interface{}{ 528 log.Logger.Info("费用类型错误", map[string]interface{}{
519 "tmpRow": tmpRow, 529 "tmpRow": tmpRow,
@@ -525,7 +535,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -525,7 +535,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
525 tmpRow := &domain.FailInfo{ 535 tmpRow := &domain.FailInfo{
526 FailReason: "费用超过最大限制,费用小数点前面不能超过十六位数字,并保留两位小数", 536 FailReason: "费用超过最大限制,费用小数点前面不能超过十六位数字,并保留两位小数",
527 } 537 }
528 - tmpRow.ImportDividendsOrderData = &dividendsOrder 538 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[j]
529 myRow = append(myRow, tmpRow) 539 myRow = append(myRow, tmpRow)
530 continue 540 continue
531 } 541 }
@@ -558,16 +568,17 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -558,16 +568,17 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
558 var dividendsOrderCommands = make(map[string]*command.CreateDividendsOrderCommand) 568 var dividendsOrderCommands = make(map[string]*command.CreateDividendsOrderCommand)
559 569
560 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { 570 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
561 - hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum + dividendsOrder.OrderTime)) 571 + hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum))
562 hashString := hex.EncodeToString(hashValue[:]) 572 hashString := hex.EncodeToString(hashValue[:])
  573 +
563 if _, ok := dividendsOrderCommands[hashString]; !ok { 574 if _, ok := dividendsOrderCommands[hashString]; !ok {
564 // 订单日期时间格式转换 575 // 订单日期时间格式转换
565 timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local) 576 timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
566 if err != nil { 577 if err != nil {
567 tmpRow := &domain.FailInfo{ 578 tmpRow := &domain.FailInfo{
568 FailReason: "无效的订单日期", 579 FailReason: "无效的订单日期",
  580 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
569 } 581 }
570 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
571 aggregateErrorList = append(aggregateErrorList, tmpRow) 582 aggregateErrorList = append(aggregateErrorList, tmpRow)
572 continue 583 continue
573 } 584 }
@@ -577,6 +588,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -577,6 +588,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
577 if err != nil { 588 if err != nil {
578 tmpRow := &domain.FailInfo{ 589 tmpRow := &domain.FailInfo{
579 FailReason: "产品数量类型错误", 590 FailReason: "产品数量类型错误",
  591 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
580 } 592 }
581 tmpRow.ImportDividendsOrderData = &dividendsOrder 593 tmpRow.ImportDividendsOrderData = &dividendsOrder
582 aggregateErrorList = append(aggregateErrorList, tmpRow) 594 aggregateErrorList = append(aggregateErrorList, tmpRow)
@@ -587,8 +599,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -587,8 +599,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
587 if err != nil { 599 if err != nil {
588 tmpRow := &domain.FailInfo{ 600 tmpRow := &domain.FailInfo{
589 FailReason: "产品价格类型错误", 601 FailReason: "产品价格类型错误",
  602 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
590 } 603 }
591 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
592 aggregateErrorList = append(aggregateErrorList, tmpRow) 604 aggregateErrorList = append(aggregateErrorList, tmpRow)
593 continue 605 continue
594 } 606 }
@@ -598,8 +610,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -598,8 +610,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
598 if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil { 610 if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
599 tmpRow := &domain.FailInfo{ 611 tmpRow := &domain.FailInfo{
600 FailReason: "费用类型错误", 612 FailReason: "费用类型错误",
  613 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
601 } 614 }
602 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
603 aggregateErrorList = append(aggregateErrorList, tmpRow) 615 aggregateErrorList = append(aggregateErrorList, tmpRow)
604 continue 616 continue
605 } else { 617 } else {
@@ -634,14 +646,26 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -634,14 +646,26 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
634 UserBaseId: importDividendsOrderCommand.UserBaseId, 646 UserBaseId: importDividendsOrderCommand.UserBaseId,
635 LineNumbers: []int{i}, // 记录行号 647 LineNumbers: []int{i}, // 记录行号
636 } 648 }
637 - } else { // 聚合同一笔订单产品 649 +
  650 + } else if _, exist := dividendsOrderCommands[hashString]; exist { // 聚合同一笔订单产品
  651 + // 订单日期时间格式转换
  652 + timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
  653 + if err != nil {
  654 + tmpRow := &domain.FailInfo{
  655 + FailReason: "无效的订单日期",
  656 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
  657 + }
  658 + aggregateErrorList = append(aggregateErrorList, tmpRow)
  659 + continue
  660 + }
  661 +
638 // 产品相关:产品名称,产品数量、产品价格、费用 662 // 产品相关:产品名称,产品数量、产品价格、费用
639 quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64) 663 quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
640 if err != nil { 664 if err != nil {
641 tmpRow := &domain.FailInfo{ 665 tmpRow := &domain.FailInfo{
642 FailReason: "产品数量类型错误", 666 FailReason: "产品数量类型错误",
  667 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
643 } 668 }
644 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
645 aggregateErrorList = append(aggregateErrorList, tmpRow) 669 aggregateErrorList = append(aggregateErrorList, tmpRow)
646 continue 670 continue
647 } 671 }
@@ -650,8 +674,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -650,8 +674,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
650 if err != nil { 674 if err != nil {
651 tmpRow := &domain.FailInfo{ 675 tmpRow := &domain.FailInfo{
652 FailReason: "产品价格类型错误", 676 FailReason: "产品价格类型错误",
  677 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
653 } 678 }
654 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
655 aggregateErrorList = append(aggregateErrorList, tmpRow) 679 aggregateErrorList = append(aggregateErrorList, tmpRow)
656 continue 680 continue
657 } 681 }
@@ -661,8 +685,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -661,8 +685,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
661 if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil { 685 if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
662 tmpRow := &domain.FailInfo{ 686 tmpRow := &domain.FailInfo{
663 FailReason: "费用类型错误", 687 FailReason: "费用类型错误",
  688 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
664 } 689 }
665 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
666 aggregateErrorList = append(aggregateErrorList, tmpRow) 690 aggregateErrorList = append(aggregateErrorList, tmpRow)
667 continue 691 continue
668 } else { 692 } else {
@@ -670,6 +694,29 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -670,6 +694,29 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
670 } 694 }
671 } 695 }
672 696
  697 + log.Logger.Info("订单时间1:", map[string]interface{}{
  698 + "timeValue": strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10),
  699 + })
  700 +
  701 + log.Logger.Info("订单时间2:", map[string]interface{}{
  702 + "timeValue": dividendsOrderCommands[hashString].OrderTime,
  703 + })
  704 +
  705 + if strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10) != dividendsOrderCommands[hashString].OrderTime {
  706 + log.Logger.Info("订单:", map[string]interface{}{
  707 + "order": dividendsOrder,
  708 + })
  709 + tmpRow := &domain.FailInfo{
  710 + FailReason: "同一来源单号的订单,订单日期必须相同",
  711 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
  712 + }
  713 + aggregateErrorList = append(aggregateErrorList, tmpRow)
  714 + log.Logger.Info("聚合订单错误:", map[string]interface{}{
  715 + "aggregateErrorList": aggregateErrorList,
  716 + })
  717 + continue
  718 + }
  719 +
673 dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{ 720 dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{
674 OrderGoodId: "0", 721 OrderGoodId: "0",
675 OrderGoodAmount: 0, 722 OrderGoodAmount: 0,
@@ -861,6 +908,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -861,6 +908,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
861 DividendsReturnedOrderNumber: "", 908 DividendsReturnedOrderNumber: "",
862 CooperationContractNumber: orderGood.CooperationContractNumber, 909 CooperationContractNumber: orderGood.CooperationContractNumber,
863 OrderGoodExpense: orderGood.OrderGoodExpense, 910 OrderGoodExpense: orderGood.OrderGoodExpense,
  911 + OrderGoodDividendsStatus: int32(1),
864 OrgId: importDividendsOrderCommand.OrgId, 912 OrgId: importDividendsOrderCommand.OrgId,
865 CompanyId: importDividendsOrderCommand.CompanyId, 913 CompanyId: importDividendsOrderCommand.CompanyId,
866 CreatedAt: time.Now(), 914 CreatedAt: time.Now(),
@@ -1077,6 +1125,7 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD @@ -1077,6 +1125,7 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD
1077 1125
1078 // BatchRemoveDividendsOrder 批量移除分红订单实体对象 1126 // BatchRemoveDividendsOrder 批量移除分红订单实体对象
1079 func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(batchRemoveDividendsOrderCommand *command.BatchRemoveDividendsOrderCommand) (interface{}, error) { 1127 func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(batchRemoveDividendsOrderCommand *command.BatchRemoveDividendsOrderCommand) (interface{}, error) {
  1128 + start := time.Now()
1080 if err := batchRemoveDividendsOrderCommand.ValidateCommand(); err != nil { 1129 if err := batchRemoveDividendsOrderCommand.ValidateCommand(); err != nil {
1081 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 1130 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
1082 } 1131 }
@@ -1121,18 +1170,42 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba @@ -1121,18 +1170,42 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
1121 dividendsEstimateRepository = value 1170 dividendsEstimateRepository = value
1122 } 1171 }
1123 1172
  1173 + // 分红预算单DAO初始化
  1174 + //var dividendsEstimateDao *dao.DividendsEstimateDao
  1175 + //if value, err := factory.CreateDividendsEstimateDao(map[string]interface{}{
  1176 + // "transactionContext": transactionContext,
  1177 + //}); err != nil {
  1178 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1179 + //} else {
  1180 + // dividendsEstimateDao = value
  1181 + //}
  1182 +
  1183 + // 分红退货单DAO初始化
  1184 + //var dividendsReturnedOrderDao *dao.DividendsReturnedOrderDao
  1185 + //if value, err := factory.CreateDividendsReturnedOrderDao(map[string]interface{}{
  1186 + // "transactionContext": transactionContext,
  1187 + //}); err != nil {
  1188 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1189 + //} else {
  1190 + // dividendsReturnedOrderDao = value
  1191 + //}
  1192 +
1124 dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds) 1193 dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
1125 if err != nil { 1194 if err != nil {
1126 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误") 1195 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
1127 } 1196 }
  1197 +
1128 if count, dividendsOrders, err := dividendsOrderRepository.Find(map[string]interface{}{ 1198 if count, dividendsOrders, err := dividendsOrderRepository.Find(map[string]interface{}{
1129 "dividendsOrderIds": dividendsOrderIds, 1199 "dividendsOrderIds": dividendsOrderIds,
  1200 + "offsetLimit": false,
1130 }); err != nil { 1201 }); err != nil {
1131 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1202 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1132 } else { 1203 } else {
  1204 + fmt.Println("截止目前耗时1:", time.Since(start))
1133 if count > 0 { 1205 if count > 0 {
1134 - // 校验分红订单是否有退货单关联  
1135 for _, dividendsOrder := range dividendsOrders { 1206 for _, dividendsOrder := range dividendsOrders {
  1207 + // 校验分红订单是否有关联的退货单
  1208 + startCount := time.Now()
1136 if countReturnedOrder, _, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ 1209 if countReturnedOrder, _, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
1137 "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber, 1210 "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber,
1138 "companyId": dividendsOrder.Company.CompanyId, 1211 "companyId": dividendsOrder.Company.CompanyId,
@@ -1145,13 +1218,29 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba @@ -1145,13 +1218,29 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
1145 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber)) 1218 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber))
1146 } 1219 }
1147 } 1220 }
  1221 + fmt.Println("退货单计数:", time.Since(startCount))
  1222 +
  1223 + //startCount := time.Now()
  1224 + //if returnedOrderExist, err := dividendsReturnedOrderDao.CheckDividendsReturnedOrderExist(map[string]interface{}{
  1225 + // "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber,
  1226 + // "companyId": dividendsOrder.Company.CompanyId,
  1227 + //}); err != nil {
  1228 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1229 + //} else {
  1230 + // if returnedOrderExist {
  1231 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber))
  1232 + // }
  1233 + //}
  1234 + //fmt.Println("退货单计数:", time.Since(startCount))
1148 1235
1149 // 校验分红订单是否有分红预算 1236 // 校验分红订单是否有分红预算
  1237 + startEstimateCount := time.Now()
1150 if countRelative, _, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ 1238 if countRelative, _, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
1151 "companyId": dividendsOrder.Company.CompanyId, 1239 "companyId": dividendsOrder.Company.CompanyId,
1152 "orgId": dividendsOrder.Org.OrgId, 1240 "orgId": dividendsOrder.Org.OrgId,
1153 "orderOrReturnedOrderNum": dividendsOrder.DividendsOrderNumber, 1241 "orderOrReturnedOrderNum": dividendsOrder.DividendsOrderNumber,
1154 - "offsetLimit": false, 1242 + "limit": 1,
  1243 + "offset": 0,
1155 "isCanceled": false, 1244 "isCanceled": false,
1156 }); err2 != nil { 1245 }); err2 != nil {
1157 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) 1246 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
@@ -1160,15 +1249,34 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba @@ -1160,15 +1249,34 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
1160 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber)) 1249 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber))
1161 } 1250 }
1162 } 1251 }
  1252 + fmt.Println("预算单计数:", time.Since(startEstimateCount))
  1253 +
  1254 + //startEstimateCount := time.Now()
  1255 + //if estimateOrderExist, err3 := dividendsEstimateDao.CheckDividendsEstimateOrderExist(map[string]interface{}{
  1256 + // "companyId": dividendsOrder.Company.CompanyId,
  1257 + // "orgId": dividendsOrder.Org.OrgId,
  1258 + // "orderOrReturnedOrderNum": dividendsOrder.DividendsOrderNumber,
  1259 + // "isCanceled": false,
  1260 + //}); err3 != nil {
  1261 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
  1262 + //} else {
  1263 + // if estimateOrderExist {
  1264 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber))
  1265 + // }
  1266 + //}
  1267 + //fmt.Println("预算单计数:", time.Since(startEstimateCount))
1163 } 1268 }
  1269 + fmt.Println("截止目前耗时2:", time.Since(start))
1164 1270
1165 dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders) 1271 dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders)
1166 if err != nil { 1272 if err != nil {
1167 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1273 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1168 } 1274 }
  1275 + fmt.Println("截止目前耗时3:", time.Since(start))
1169 if err := transactionContext.CommitTransaction(); err != nil { 1276 if err := transactionContext.CommitTransaction(); err != nil {
1170 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1277 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1171 } 1278 }
  1279 + fmt.Println("截止目前耗时4:", time.Since(start))
1172 return dividendsOrdersRemoved, nil 1280 return dividendsOrdersRemoved, nil
1173 } else { 1281 } else {
1174 return map[string]interface{}{}, nil 1282 return map[string]interface{}{}, nil
@@ -445,14 +445,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -445,14 +445,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
445 t := reflect.TypeOf(dividendsReturnedOrder) 445 t := reflect.TypeOf(dividendsReturnedOrder)
446 v := reflect.ValueOf(dividendsReturnedOrder) 446 v := reflect.ValueOf(dividendsReturnedOrder)
447 for k := 0; k < t.NumField(); k++ { 447 for k := 0; k < t.NumField(); k++ {
448 - fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))  
449 - if t.Field(k).Name != "RegionName" { 448 + //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))
  449 + //if t.Field(k).Name != "RegionName" {
450 if v.Field(k).Interface() == "" { 450 if v.Field(k).Interface() == "" {
451 col := strconv.Itoa(k + 1) 451 col := strconv.Itoa(k + 1)
452 nullCell = append(nullCell, col) 452 nullCell = append(nullCell, col)
453 nullFlag = true 453 nullFlag = true
454 } 454 }
455 - } 455 + //}
456 } 456 }
457 if nullFlag { 457 if nullFlag {
458 myRow := &domain.FailReturnedInfo{ 458 myRow := &domain.FailReturnedInfo{
@@ -478,10 +478,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -478,10 +478,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
478 478
479 /***************************************************** 3.单元格类型校验 *********************************************/ 479 /***************************************************** 3.单元格类型校验 *********************************************/
480 typeError := make([]*domain.FailReturnedInfo, 0) 480 typeError := make([]*domain.FailReturnedInfo, 0)
481 - for _, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行  
482 - var myRow []*domain.FailReturnedInfo 481 +
  482 + for j, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
483 t := reflect.TypeOf(dividendsReturnedOrder) 483 t := reflect.TypeOf(dividendsReturnedOrder)
484 v := reflect.ValueOf(dividendsReturnedOrder) 484 v := reflect.ValueOf(dividendsReturnedOrder)
  485 + var myRow []*domain.FailReturnedInfo
485 for k := 0; k < t.NumField(); k++ { // 列 486 for k := 0; k < t.NumField(); k++ { // 列
486 switch k { 487 switch k {
487 case 3: // 退货日期校验 488 case 3: // 退货日期校验
@@ -491,7 +492,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -491,7 +492,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
491 if !ok { 492 if !ok {
492 tmpRow := &domain.FailReturnedInfo{ 493 tmpRow := &domain.FailReturnedInfo{
493 FailReason: "退货日期格式错误,请输入正确的退货日期", 494 FailReason: "退货日期格式错误,请输入正确的退货日期",
494 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 495 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[j],
495 } 496 }
496 myRow = append(myRow, tmpRow) 497 myRow = append(myRow, tmpRow)
497 continue 498 continue
@@ -504,7 +505,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -504,7 +505,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
504 if !ok { 505 if !ok {
505 tmpRow := &domain.FailReturnedInfo{ 506 tmpRow := &domain.FailReturnedInfo{
506 FailReason: "订单日期格式错误,请输入正确的订单日期", 507 FailReason: "订单日期格式错误,请输入正确的订单日期",
507 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 508 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[j],
508 } 509 }
509 myRow = append(myRow, tmpRow) 510 myRow = append(myRow, tmpRow)
510 continue 511 continue
@@ -517,7 +518,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -517,7 +518,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
517 if err != nil { 518 if err != nil {
518 tmpRow := &domain.FailReturnedInfo{ 519 tmpRow := &domain.FailReturnedInfo{
519 FailReason: "退货数量格式错误,退货数量必须整数", 520 FailReason: "退货数量格式错误,退货数量必须整数",
520 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 521 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[j],
521 } 522 }
522 myRow = append(myRow, tmpRow) 523 myRow = append(myRow, tmpRow)
523 continue 524 continue
@@ -526,7 +527,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -526,7 +527,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
526 if orderGoodQuantity < 0 { 527 if orderGoodQuantity < 0 {
527 tmpRow := &domain.FailReturnedInfo{ 528 tmpRow := &domain.FailReturnedInfo{
528 FailReason: "退货数量必须大于0,请重新填写", 529 FailReason: "退货数量必须大于0,请重新填写",
529 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 530 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[j],
530 } 531 }
531 myRow = append(myRow, tmpRow) 532 myRow = append(myRow, tmpRow)
532 continue 533 continue
@@ -539,7 +540,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -539,7 +540,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
539 if typeErr != nil { 540 if typeErr != nil {
540 tmpRow := &domain.FailReturnedInfo{ 541 tmpRow := &domain.FailReturnedInfo{
541 FailReason: "退货价格格式错误,退货价格必须为数字类型", 542 FailReason: "退货价格格式错误,退货价格必须为数字类型",
542 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 543 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[j],
543 } 544 }
544 myRow = append(myRow, tmpRow) 545 myRow = append(myRow, tmpRow)
545 continue 546 continue
@@ -549,7 +550,17 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -549,7 +550,17 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
549 if univalent >= 1e16 { 550 if univalent >= 1e16 {
550 tmpRow := &domain.FailReturnedInfo{ 551 tmpRow := &domain.FailReturnedInfo{
551 FailReason: "退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数", 552 FailReason: "退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数",
552 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 553 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[j],
  554 + }
  555 + myRow = append(myRow, tmpRow)
  556 + continue
  557 + }
  558 +
  559 + // 正负判断
  560 + if univalent < 0 {
  561 + tmpRow := &domain.FailReturnedInfo{
  562 + FailReason: "退货价格必须大于0,请重新填写",
  563 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[j],
553 } 564 }
554 myRow = append(myRow, tmpRow) 565 myRow = append(myRow, tmpRow)
555 continue 566 continue
@@ -581,7 +592,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -581,7 +592,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
581 var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand) 592 var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand)
582 593
583 for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { 594 for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
584 - hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum + dividendsReturnedOrder.OrderTime)) 595 + hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum + dividendsReturnedOrder.DividendsReturnedDate))
585 hashString := hex.EncodeToString(hashValue[:]) 596 hashString := hex.EncodeToString(hashValue[:])
586 if _, ok := dividendsReturnedOrderCommands[hashString]; !ok { 597 if _, ok := dividendsReturnedOrderCommands[hashString]; !ok {
587 // 订单日期时间格式转换 598 // 订单日期时间格式转换
@@ -589,7 +600,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -589,7 +600,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
589 if err != nil { 600 if err != nil {
590 tmpRow := &domain.FailReturnedInfo{ 601 tmpRow := &domain.FailReturnedInfo{
591 FailReason: "无效的订单日期", 602 FailReason: "无效的订单日期",
592 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 603 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
593 } 604 }
594 aggregateErrorList = append(aggregateErrorList, tmpRow) 605 aggregateErrorList = append(aggregateErrorList, tmpRow)
595 continue 606 continue
@@ -600,7 +611,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -600,7 +611,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
600 if err != nil { 611 if err != nil {
601 tmpRow := &domain.FailReturnedInfo{ 612 tmpRow := &domain.FailReturnedInfo{
602 FailReason: "无效的退货日期", 613 FailReason: "无效的退货日期",
603 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 614 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
604 } 615 }
605 aggregateErrorList = append(aggregateErrorList, tmpRow) 616 aggregateErrorList = append(aggregateErrorList, tmpRow)
606 continue 617 continue
@@ -611,7 +622,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -611,7 +622,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
611 if err != nil { 622 if err != nil {
612 tmpRow := &domain.FailReturnedInfo{ 623 tmpRow := &domain.FailReturnedInfo{
613 FailReason: "产品数量类型错误", 624 FailReason: "产品数量类型错误",
614 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 625 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
615 } 626 }
616 aggregateErrorList = append(aggregateErrorList, tmpRow) 627 aggregateErrorList = append(aggregateErrorList, tmpRow)
617 continue 628 continue
@@ -621,7 +632,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -621,7 +632,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
621 if err != nil { 632 if err != nil {
622 tmpRow := &domain.FailReturnedInfo{ 633 tmpRow := &domain.FailReturnedInfo{
623 FailReason: "产品价格类型错误", 634 FailReason: "产品价格类型错误",
624 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 635 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
625 } 636 }
626 aggregateErrorList = append(aggregateErrorList, tmpRow) 637 aggregateErrorList = append(aggregateErrorList, tmpRow)
627 continue 638 continue
@@ -656,12 +667,23 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -656,12 +667,23 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
656 LineNumbers: []int{i}, // 记录行号 667 LineNumbers: []int{i}, // 记录行号
657 } 668 }
658 } else { // 聚合同一笔订单产品 669 } else { // 聚合同一笔订单产品
  670 + // 订单日期时间格式转换
  671 + timeValue, err := time.ParseInLocation("2006/01/02", dividendsReturnedOrder.OrderTime, time.Local)
  672 + if err != nil {
  673 + tmpRow := &domain.FailReturnedInfo{
  674 + FailReason: "无效的订单日期",
  675 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
  676 + }
  677 + aggregateErrorList = append(aggregateErrorList, tmpRow)
  678 + continue
  679 + }
  680 +
659 // 产品相关:产品名称,退货数量、退货价格 681 // 产品相关:产品名称,退货数量、退货价格
660 quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64) 682 quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64)
661 if err != nil { 683 if err != nil {
662 tmpRow := &domain.FailReturnedInfo{ 684 tmpRow := &domain.FailReturnedInfo{
663 FailReason: "产品数量类型错误", 685 FailReason: "产品数量类型错误",
664 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 686 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
665 } 687 }
666 aggregateErrorList = append(aggregateErrorList, tmpRow) 688 aggregateErrorList = append(aggregateErrorList, tmpRow)
667 continue 689 continue
@@ -671,7 +693,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -671,7 +693,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
671 if err != nil { 693 if err != nil {
672 tmpRow := &domain.FailReturnedInfo{ 694 tmpRow := &domain.FailReturnedInfo{
673 FailReason: "产品价格类型错误", 695 FailReason: "产品价格类型错误",
674 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 696 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
  697 + }
  698 + aggregateErrorList = append(aggregateErrorList, tmpRow)
  699 + continue
  700 + }
  701 +
  702 + if strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10) != dividendsReturnedOrderCommands[hashString].OrderTime {
  703 + tmpRow := &domain.FailReturnedInfo{
  704 + FailReason: "同一来源单号的退货单,订单日期必须相同",
  705 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
675 } 706 }
676 aggregateErrorList = append(aggregateErrorList, tmpRow) 707 aggregateErrorList = append(aggregateErrorList, tmpRow)
677 continue 708 continue
@@ -844,12 +875,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -844,12 +875,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
844 contractNumberExist := false 875 contractNumberExist := false
845 for _, cooperationContract := range cooperationContracts { 876 for _, cooperationContract := range cooperationContracts {
846 if orderGood.CooperationContractNumber == cooperationContract.CooperationContractNumber { 877 if orderGood.CooperationContractNumber == cooperationContract.CooperationContractNumber {
  878 + if cooperationContract.Status == 1 {
847 contractNumberExist = true 879 contractNumberExist = true
848 break 880 break
849 } 881 }
850 } 882 }
  883 + }
851 if !contractNumberExist { 884 if !contractNumberExist {
852 - orderGoodErrMap[dividendsReturnedOrder.OrderGoods[j].LineNumber] = "退货单产品关联的共创合约不存在" 885 + orderGoodErrMap[dividendsReturnedOrder.OrderGoods[j].LineNumber] = "退货单产品关联的共创合约不存在或已暂停"
853 continue 886 continue
854 } 887 }
855 888
@@ -1113,6 +1146,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) BatchRemoveD @@ -1113,6 +1146,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) BatchRemoveD
1113 } 1146 }
1114 if count, dividendsReturnedOrders, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ 1147 if count, dividendsReturnedOrders, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
1115 "dividendsReturnedOrderIds": dividendsReturnedOrderIds, 1148 "dividendsReturnedOrderIds": dividendsReturnedOrderIds,
  1149 + "offsetLimit": false,
1116 }); err != nil { 1150 }); err != nil {
1117 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1151 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1118 } else { 1152 } else {
@@ -17,6 +17,9 @@ var USER_MODULE_HOST = "http://127.0.0.1:8081" @@ -17,6 +17,9 @@ var USER_MODULE_HOST = "http://127.0.0.1:8081"
17 // BASIC_MODULE_HOST 基础服务模块 17 // BASIC_MODULE_HOST 基础服务模块
18 var BASIC_MODULE_HOST = "http://127.0.0.1:8080" 18 var BASIC_MODULE_HOST = "http://127.0.0.1:8080"
19 19
  20 +// ENABLE_HTTPS 是否开启https访问
  21 +var ENABLE_HTTPS = "false"
  22 +
20 func init() { 23 func init() {
21 if os.Getenv("LOG_TYPE") != "" { 24 if os.Getenv("LOG_TYPE") != "" {
22 LOG_TYPE = os.Getenv("LOG_TYPE") 25 LOG_TYPE = os.Getenv("LOG_TYPE")
@@ -39,4 +42,7 @@ func init() { @@ -39,4 +42,7 @@ func init() {
39 if os.Getenv("BASIC_MODULE_HOST") != "" { 42 if os.Getenv("BASIC_MODULE_HOST") != "" {
40 BASIC_MODULE_HOST = os.Getenv("BASIC_MODULE_HOST") 43 BASIC_MODULE_HOST = os.Getenv("BASIC_MODULE_HOST")
41 } 44 }
  45 + if os.Getenv("ENABLE_HTTPS") != "" {
  46 + ENABLE_HTTPS = os.Getenv("ENABLE_HTTPS")
  47 + }
42 } 48 }
@@ -78,6 +78,7 @@ type DividendsEstimateRepository interface { @@ -78,6 +78,7 @@ type DividendsEstimateRepository interface {
78 SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) 78 SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error)
79 UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) 79 UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error)
80 Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) 80 Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error)
  81 + BatchRemove(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error)
81 FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error) 82 FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error)
82 Find(queryOptions map[string]interface{}) (int64, []*DividendsEstimate, error) 83 Find(queryOptions map[string]interface{}) (int64, []*DividendsEstimate, error)
83 } 84 }
@@ -17,6 +17,9 @@ type DividendsEstimateDetail struct { @@ -17,6 +17,9 @@ type DividendsEstimateDetail struct {
17 IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功 17 IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功
18 Reason string `json:"reason"` // 错误原因 18 Reason string `json:"reason"` // 错误原因
19 CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` // 承接人记录ID 19 CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` // 承接人记录ID
  20 + CooperationContractNumber string `json:"cooperationContractNumber"`
  21 + OrderGoodId int64 `json:"orderGoodId"`
  22 + OrderGoodAmount float64 `json:"orderGoodAmount"`
20 } 23 }
21 24
22 // GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号 25 // GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号
@@ -43,5 +46,5 @@ func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividend @@ -43,5 +46,5 @@ func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividend
43 46
44 type ConfirmDividendsIncentivesEstimateService interface { 47 type ConfirmDividendsIncentivesEstimateService interface {
45 coreDomain.DomainEventPublisher 48 coreDomain.DomainEventPublisher
46 - Confirm(orderGoods []*domain.OrderGood) ([]*DividendsEstimateDetail, error) 49 + Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64, cooperationContractsMap map[string]*domain.CooperationContract) ([]*DividendsEstimateDetail, error)
47 } 50 }
@@ -144,6 +144,16 @@ func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOp @@ -144,6 +144,16 @@ func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOp
144 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { 144 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
145 query = query.Where(`A.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) 145 query = query.Where(`A.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
146 } 146 }
  147 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  148 + query.Where("A.company->>'companyId' = '?'", companyId)
  149 + }
  150 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  151 + query.Where("A.org->>'orgId' = '?'", orgId)
  152 + }
  153 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  154 + newOrgIds := utils.SliceItoa(orgIds.([]int64))
  155 + query.Where("A.org->>'orgId' in (?)", pg.In(newOrgIds))
  156 + }
147 query.Join("JOIN cooperation_contracts AS A ON A.cooperation_contract_number = cooperation_contract_undertaker.cooperation_contract_number") 157 query.Join("JOIN cooperation_contracts AS A ON A.cooperation_contract_number = cooperation_contract_undertaker.cooperation_contract_number")
148 query.Join("JOIN cooperation_modes AS B ON B.cooperation_mode_number = A.cooperation_mode_number") 158 query.Join("JOIN cooperation_modes AS B ON B.cooperation_mode_number = A.cooperation_mode_number")
149 query = query.Order("cooperation_contract_undertaker_id DESC") 159 query = query.Order("cooperation_contract_undertaker_id DESC")
@@ -147,9 +147,9 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma @@ -147,9 +147,9 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma
147 if v, ok := queryOptions["sortByActuallyPaidAmount"]; ok { 147 if v, ok := queryOptions["sortByActuallyPaidAmount"]; ok {
148 vInt := v.(int) 148 vInt := v.(int)
149 if vInt == 1 { 149 if vInt == 1 {
150 - query.Order("divides_amount asc") 150 + query.Order("actually_paid_amount asc")
151 } else { 151 } else {
152 - query.Order("divides_amount desc") 152 + query.Order("actually_paid_amount desc")
153 } 153 }
154 } 154 }
155 query.GroupExpr("participator->>'userId'") 155 query.GroupExpr("participator->>'userId'")
@@ -26,7 +26,7 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber(queryOptions ma @@ -26,7 +26,7 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber(queryOptions ma
26 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { 26 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
27 query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId) 27 query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId)
28 } 28 }
29 - if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 29 + if count, err := query.AllWithDeleted().Count(); err != nil {
30 return "", err 30 return "", err
31 } else { 31 } else {
32 if count < 1000 { 32 if count < 1000 {
@@ -68,6 +68,31 @@ func (dao *DividendsEstimateDao) CheckDividendsEstimateOrderNumberAvailable(quer @@ -68,6 +68,31 @@ func (dao *DividendsEstimateDao) CheckDividendsEstimateOrderNumberAvailable(quer
68 return !ok, err 68 return !ok, err
69 } 69 }
70 70
  71 +// CheckDividendsEstimateOrderExist 判断是否存在分红预算单
  72 +func (dao *DividendsEstimateDao) CheckDividendsEstimateOrderExist(queryOptions map[string]interface{}) (bool, error) {
  73 + tx := dao.transactionContext.PgTx
  74 + var dividendsEstimateModels []*models.DividendsEstimate
  75 + query := tx.Model(&dividendsEstimateModels)
  76 + if orderOrReturnedOrderNum, ok := queryOptions["orderOrReturnedOrderNum"]; ok && orderOrReturnedOrderNum != "" {
  77 + query = query.Where("order_or_returned_order_num = ?", orderOrReturnedOrderNum)
  78 + }
  79 + if isCanceled, ok := queryOptions["isCanceled"]; ok {
  80 + query.Where("is_canceled = ?", isCanceled.(bool))
  81 + }
  82 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  83 + query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId)
  84 + }
  85 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  86 + query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId)
  87 + }
  88 + count, err := query.Count()
  89 + if count > 0 {
  90 + return true, err
  91 + } else {
  92 + return false, err
  93 + }
  94 +}
  95 +
71 // UserEstimated 判断金额激励用户是否已分红(已生成分红预算单) 96 // UserEstimated 判断金额激励用户是否已分红(已生成分红预算单)
72 func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface{}) (bool, error) { 97 func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface{}) (bool, error) {
73 tx := dao.transactionContext.PgTx 98 tx := dao.transactionContext.PgTx
@@ -118,7 +143,7 @@ func (dao *DividendsEstimateDao) CountDividendsEstimate(queryOptions map[string] @@ -118,7 +143,7 @@ func (dao *DividendsEstimateDao) CountDividendsEstimate(queryOptions map[string]
118 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { 143 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
119 query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId) 144 query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId)
120 } 145 }
121 - if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 146 + if count, err := query.AllWithDeleted().Count(); err != nil {
122 return 0, err 147 return 0, err
123 } else { 148 } else {
124 return count, nil 149 return count, nil
@@ -104,7 +104,7 @@ func (dao *DividendsOrderDao) CountDividendsOrder(queryOptions map[string]interf @@ -104,7 +104,7 @@ func (dao *DividendsOrderDao) CountDividendsOrder(queryOptions map[string]interf
104 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) 104 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
105 query.Where("dividends_order.created_at >= ?", todayZeroTime) 105 query.Where("dividends_order.created_at >= ?", todayZeroTime)
106 query.Where("dividends_order.created_at < ?", nextDayZeroTime) 106 query.Where("dividends_order.created_at < ?", nextDayZeroTime)
107 - if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 107 + if count, err := query.AllWithDeleted().Count(); err != nil {
108 return 0, err 108 return 0, err
109 } else { 109 } else {
110 return count, nil 110 return count, nil
@@ -38,6 +38,28 @@ func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber(query @@ -38,6 +38,28 @@ func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber(query
38 } 38 }
39 } 39 }
40 40
  41 +// CheckDividendsEstimateOrderExist 判断是否存在分红预算单
  42 +func (dao *DividendsReturnedOrderDao) CheckDividendsReturnedOrderExist(queryOptions map[string]interface{}) (bool, error) {
  43 + tx := dao.transactionContext.PgTx
  44 + var dividendsReturnedOrderModels []*models.DividendsReturnedOrder
  45 + query := tx.Model(&dividendsReturnedOrderModels)
  46 + if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" {
  47 + query = query.Where("dividends_order_number = ?", dividendsOrderNumber)
  48 + }
  49 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  50 + query = query.Where(`dividends_returned_order.company @> '{"companyId":"?"}'`, companyId)
  51 + }
  52 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  53 + query = query.Where(`dividends_returned_order.org @> '{"orgId":"?"}'`, orgId)
  54 + }
  55 + count, err := query.Count()
  56 + if count > 0 {
  57 + return true, err
  58 + } else {
  59 + return false, err
  60 + }
  61 +}
  62 +
41 // CheckDividendsReturnedOrderNumberAvailable 校验分红订单是否唯一 63 // CheckDividendsReturnedOrderNumberAvailable 校验分红订单是否唯一
42 func (dao *DividendsReturnedOrderDao) CheckDividendsReturnedOrderNumberAvailable(queryOptions map[string]interface{}) (bool, error) { 64 func (dao *DividendsReturnedOrderDao) CheckDividendsReturnedOrderNumberAvailable(queryOptions map[string]interface{}) (bool, error) {
43 tx := dao.transactionContext.PgTx 65 tx := dao.transactionContext.PgTx
@@ -91,7 +113,7 @@ func (dao *DividendsReturnedOrderDao) CountDividendsReturnedOrder(queryOptions m @@ -91,7 +113,7 @@ func (dao *DividendsReturnedOrderDao) CountDividendsReturnedOrder(queryOptions m
91 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) 113 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
92 query.Where("dividends_returned_order.created_at >= ?", todayZeroTime) 114 query.Where("dividends_returned_order.created_at >= ?", todayZeroTime)
93 query.Where("dividends_returned_order.created_at < ?", nextDayZeroTime) 115 query.Where("dividends_returned_order.created_at < ?", nextDayZeroTime)
94 - if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 116 + if count, err := query.AllWithDeleted().Count(); err != nil {
95 return 0, err 117 return 0, err
96 } else { 118 } else {
97 return count, nil 119 return count, nil
@@ -32,7 +32,7 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte @@ -32,7 +32,7 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte
32 if v, ok := queryOptions["limit"]; ok { 32 if v, ok := queryOptions["limit"]; ok {
33 queryLimit += fmt.Sprintf("limit %v \n", v) 33 queryLimit += fmt.Sprintf("limit %v \n", v)
34 } 34 }
35 - sql := fmt.Sprintf(`select order_good_name good_name,sum(coalesce(order_good_amount,0)) good_amount from order_goods 35 + sql := fmt.Sprintf(`select order_good_name good_name,sum(coalesce(case when dividends_order_number is not null then order_good_amount else -order_good_amount end,0)) good_amount from order_goods
36 where company_id=? and org_id = ? and deleted_at is null %v 36 where company_id=? and org_id = ? and deleted_at is null %v
37 GROUP BY order_good_name 37 GROUP BY order_good_name
38 order by good_amount desc 38 order by good_amount desc
@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
11 ) 12 )
12 13
13 type CancelDividendsEstimateService struct { 14 type CancelDividendsEstimateService struct {
@@ -20,7 +21,12 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -20,7 +21,12 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
20 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 21 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
21 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 22 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
22 var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储 23 var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储
23 - //var cooperationContactRepository domain.CooperationContractRepository // 合约仓储 24 +
  25 + type orderGoodInfo struct {
  26 + OrderGoodId int64
  27 + CompanyId int64
  28 + OrgId int64
  29 + }
24 30
25 // 分红预算单仓储初始化 31 // 分红预算单仓储初始化
26 if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { 32 if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil {
@@ -50,16 +56,10 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -50,16 +56,10 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
50 orderGoodRepository = repo 56 orderGoodRepository = repo
51 } 57 }
52 58
53 - // 共创合约仓储初始化  
54 - //if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {  
55 - // return nil, err  
56 - //} else {  
57 - // cooperationContactRepository = repo  
58 - //}  
59 -  
60 // 获取分红预算单 59 // 获取分红预算单
61 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ 60 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
62 "dividendsEstimateIds": dividendsEstimateIds, 61 "dividendsEstimateIds": dividendsEstimateIds,
  62 + "offsetLimit": false,
63 }); err != nil { 63 }); err != nil {
64 return nil, err 64 return nil, err
65 } else { 65 } else {
@@ -67,6 +67,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -67,6 +67,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
67 var dividendsEstimatesCanceled []*domain.DividendsEstimate 67 var dividendsEstimatesCanceled []*domain.DividendsEstimate
68 var orderOrReturnOrderNums []string 68 var orderOrReturnOrderNums []string
69 var orderGoodIds []int64 69 var orderGoodIds []int64
  70 + orderGoodMaps := make(map[string][]int64, 0)
70 for _, dividendsEstimate := range dividendsEstimates { 71 for _, dividendsEstimate := range dividendsEstimates {
71 if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销 72 if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
72 // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 73 // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
@@ -90,7 +91,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -90,7 +91,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
90 // 获取相关订单/退货单号 91 // 获取相关订单/退货单号
91 orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum) 92 orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum)
92 orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId) 93 orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId)
  94 + orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum] = append(orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum], dividendsEstimatesRelative[i].OrderGoodId)
93 } 95 }
  96 + //dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.BatchRemove(dividendsEstimatesRelative)
94 dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) 97 dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
95 if err3 != nil { 98 if err3 != nil {
96 return nil, err3 99 return nil, err3
@@ -117,6 +120,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -117,6 +120,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
117 dividendsEstimatesRelative[i].IsCanceled = true 120 dividendsEstimatesRelative[i].IsCanceled = true
118 dividendsEstimatesRelative[i].Operator = operator 121 dividendsEstimatesRelative[i].Operator = operator
119 } 122 }
  123 + //dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.BatchRemove(dividendsEstimatesRelative)
120 dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) 124 dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
121 if err4 != nil { 125 if err4 != nil {
122 return nil, err4 126 return nil, err4
@@ -154,23 +158,26 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -154,23 +158,26 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
154 "companyId": dividendsEstimates[0].Company.CompanyId, 158 "companyId": dividendsEstimates[0].Company.CompanyId,
155 "orgId": dividendsEstimates[0].Org.OrgId, 159 "orgId": dividendsEstimates[0].Org.OrgId,
156 "dividendsOrderNumbers": orderNums, 160 "dividendsOrderNumbers": orderNums,
  161 + "offsetLimit": false,
157 }); err4 != nil { 162 }); err4 != nil {
158 return nil, err4 163 return nil, err4
159 } else { 164 } else {
160 - // orderGoodIds去重  
161 - newOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodIds)  
162 -  
163 if countDividendsOrder > 0 { 165 if countDividendsOrder > 0 {
164 for i, order := range orders { 166 for i, order := range orders {
165 - goods := make([]*domain.OrderGood, 0) 167 + // 取消分红的订单产品
  168 + newOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodMaps[order.DividendsOrderNumber])
  169 + var goodIds []int64
166 for _, good := range order.Goods { 170 for _, good := range order.Goods {
167 if good.OrderGoodDividendsStatus == 2 { 171 if good.OrderGoodDividendsStatus == 2 {
168 - goods = append(goods, good) 172 + goodIds = append(goodIds, good.OrderGoodId)
169 } 173 }
170 } 174 }
171 - if len(goods) == len(newOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,订单分红状态变更为未分红 175 + // goodIds去重
  176 + newGoodIds := utils.RemoveDuplicationInt64(goodIds)
  177 + log.Logger.Info("")
  178 + if len(newGoodIds) == len(newOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,订单分红状态变更为未分红
172 orders[i].DividendStatus = 1 179 orders[i].DividendStatus = 1
173 - } else if len(goods) > len(newOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,订单分红状态变更为部分分红 180 + } else if len(newGoodIds) > len(newOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,订单分红状态变更为部分分红
174 orders[i].DividendStatus = 3 181 orders[i].DividendStatus = 3
175 } 182 }
176 orders[i].DividendStatus = order.DividendStatus 183 orders[i].DividendStatus = order.DividendStatus
@@ -193,6 +200,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -193,6 +200,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
193 "orderGoodIds": orderGoodIds, 200 "orderGoodIds": orderGoodIds,
194 "companyId": dividendsEstimates[0].Company.CompanyId, 201 "companyId": dividendsEstimates[0].Company.CompanyId,
195 "orgId": dividendsEstimates[0].Org.OrgId, 202 "orgId": dividendsEstimates[0].Org.OrgId,
  203 + "offsetLimit": false,
196 }); err != nil { 204 }); err != nil {
197 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 205 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
198 } else { 206 } else {
@@ -216,24 +224,25 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -216,24 +224,25 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
216 "companyId": dividendsEstimates[0].Company.CompanyId, 224 "companyId": dividendsEstimates[0].Company.CompanyId,
217 "orgId": dividendsEstimates[0].Org.OrgId, 225 "orgId": dividendsEstimates[0].Org.OrgId,
218 "dividendsReturnedOrderNumbers": returnedOrderNums, 226 "dividendsReturnedOrderNumbers": returnedOrderNums,
  227 + "offsetLimit": false,
219 }); err5 != nil { 228 }); err5 != nil {
220 return nil, err5 229 return nil, err5
221 } else { 230 } else {
222 - // orderGoodIds去重  
223 - newReturnedOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodIds)  
224 -  
225 if countDividendsReturnedOrder > 0 { 231 if countDividendsReturnedOrder > 0 {
226 for i, returnedOrder := range returnedOrders { 232 for i, returnedOrder := range returnedOrders {
227 - goods := make([]*domain.OrderGood, 0) 233 + // 已取消的退货单产品
  234 + newReturnedOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodMaps[returnedOrder.DividendsReturnedOrderNumber])
  235 + var goodIds []int64
228 for _, good := range returnedOrder.Goods { 236 for _, good := range returnedOrder.Goods {
229 if good.OrderGoodDividendsStatus == 2 { 237 if good.OrderGoodDividendsStatus == 2 {
230 - goods = append(goods, good) 238 + goodIds = append(goodIds, good.OrderGoodId)
231 } 239 }
232 } 240 }
233 -  
234 - if len(goods) == len(newReturnedOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,退货单分红状态变更为未分红 241 + // goodIds去重
  242 + newGoodIds := utils.RemoveDuplicationInt64(goodIds)
  243 + if len(newGoodIds) == len(newReturnedOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,退货单分红状态变更为未分红
235 returnedOrders[i].DividendStatus = 1 244 returnedOrders[i].DividendStatus = 1
236 - } else if len(goods) > len(newReturnedOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,退货单分红状态变更为部分分红 245 + } else if len(newGoodIds) > len(newReturnedOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,退货单分红状态变更为部分分红
237 returnedOrders[i].DividendStatus = 3 246 returnedOrders[i].DividendStatus = 3
238 } 247 }
239 returnedOrders[i].DividendStatus = returnedOrder.DividendStatus 248 returnedOrders[i].DividendStatus = returnedOrder.DividendStatus
@@ -256,6 +265,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -256,6 +265,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
256 "orderGoodIds": orderGoodIds, 265 "orderGoodIds": orderGoodIds,
257 "companyId": dividendsEstimates[0].Company.CompanyId, 266 "companyId": dividendsEstimates[0].Company.CompanyId,
258 "orgId": dividendsEstimates[0].Org.OrgId, 267 "orgId": dividendsEstimates[0].Org.OrgId,
  268 + "offsetLimit": false,
259 }); err != nil { 269 }); err != nil {
260 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 270 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
261 } else { 271 } else {
@@ -8,7 +8,6 @@ import ( @@ -8,7 +8,6 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
11 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"  
12 ) 11 )
13 12
14 type ConfirmDividendsIncentivesEstimateService struct { 13 type ConfirmDividendsIncentivesEstimateService struct {
@@ -17,26 +16,10 @@ type ConfirmDividendsIncentivesEstimateService struct { @@ -17,26 +16,10 @@ type ConfirmDividendsIncentivesEstimateService struct {
17 } 16 }
18 17
19 // Confirm 确认业绩分红预算 18 // Confirm 确认业绩分红预算
20 -func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood) ([]*service.DividendsEstimateDetail, error) {  
21 - var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储  
22 - var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储 19 +func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64, cooperationContractsMap map[string]*domain.CooperationContract) ([]*service.DividendsEstimateDetail, error) {
23 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 20 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
24 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 21 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
25 22
26 - // 共创合约仓储初始化  
27 - if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {  
28 - return nil, err  
29 - } else {  
30 - cooperationContractRepository = repo  
31 - }  
32 -  
33 - // 共创项目仓储初始化  
34 - if repo, err := repository.NewCooperationProjectRepository(domainService.transactionContext); err != nil {  
35 - return nil, err  
36 - } else {  
37 - cooperationProjectRepository = repo  
38 - }  
39 -  
40 // 分红订单仓储初始化 23 // 分红订单仓储初始化
41 if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil { 24 if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil {
42 return nil, err 25 return nil, err
@@ -54,17 +37,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -54,17 +37,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
54 // 确认业绩分红预算 37 // 确认业绩分红预算
55 var dividendsEstimateDetails []*service.DividendsEstimateDetail 38 var dividendsEstimateDetails []*service.DividendsEstimateDetail
56 for _, orderGood := range orderGoods { 39 for _, orderGood := range orderGoods {
57 - log.Logger.Info("业绩分红预算产品", map[string]interface{}{  
58 - "orderGood": orderGood,  
59 - })  
60 -  
61 - // 获取合约  
62 - cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{  
63 - "cooperationContractNumber": orderGood.CooperationContractNumber,  
64 - "companyId": orderGood.CompanyId,  
65 - "orgId": orderGood.OrgId,  
66 - })  
67 - if err != nil { 40 + if orderGood.CooperationContractNumber == "" {
68 var orderNumber string 41 var orderNumber string
69 if orderGood.DividendsOrderNumber != "" { 42 if orderGood.DividendsOrderNumber != "" {
70 orderNumber = orderGood.DividendsOrderNumber 43 orderNumber = orderGood.DividendsOrderNumber
@@ -78,11 +51,14 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -78,11 +51,14 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
78 DividendsAmount: 0, 51 DividendsAmount: 0,
79 OrderOrReturnedOrderNumber: orderNumber, 52 OrderOrReturnedOrderNumber: orderNumber,
80 IsSuccessfully: false, 53 IsSuccessfully: false,
81 - Reason: "共创合约错误", 54 + Reason: "产品未关联合约,不能进行分红预算",
82 }) 55 })
83 continue 56 continue
84 } 57 }
85 - if cooperationContract == nil { 58 +
  59 + // 获取合约
  60 + var cooperationContract *domain.CooperationContract
  61 + if _, ok := cooperationContractsMap[orderGood.CooperationContractNumber]; !ok {
86 var orderNumber string 62 var orderNumber string
87 if orderGood.DividendsOrderNumber != "" { 63 if orderGood.DividendsOrderNumber != "" {
88 orderNumber = orderGood.DividendsOrderNumber 64 orderNumber = orderGood.DividendsOrderNumber
@@ -100,9 +76,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -100,9 +76,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
100 }) 76 })
101 continue 77 continue
102 } else { 78 } else {
103 - log.Logger.Info("产品相关的合约", map[string]interface{}{  
104 - "cooperationContract": cooperationContract,  
105 - }) 79 + cooperationContract = cooperationContractsMap[orderGood.CooperationContractNumber]
106 if cooperationContract.Status == 2 { 80 if cooperationContract.Status == 2 {
107 var orderNumber string 81 var orderNumber string
108 if orderGood.DividendsOrderNumber != "" { 82 if orderGood.DividendsOrderNumber != "" {
@@ -123,51 +97,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -123,51 +97,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
123 } 97 }
124 } 98 }
125 99
126 - // 获取共创项目  
127 - if cooperationContract.CooperationProjectNumber != "" {  
128 - cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{  
129 - "cooperationProjectNumber": cooperationContract.CooperationProjectNumber,  
130 - "companyId": cooperationContract.Company.CompanyId,  
131 - "orgId": cooperationContract.Org.OrgId,  
132 - })  
133 - if err != nil {  
134 - var orderNumber string  
135 - if orderGood.DividendsOrderNumber != "" {  
136 - orderNumber = orderGood.DividendsOrderNumber  
137 - } else {  
138 - orderNumber = orderGood.DividendsReturnedOrderNumber  
139 - }  
140 - dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{  
141 - DividendsUser: nil,  
142 - DividendsParticipateType: 0,  
143 - DividendsStage: 0,  
144 - DividendsAmount: 0,  
145 - OrderOrReturnedOrderNumber: orderNumber,  
146 - IsSuccessfully: false,  
147 - Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "查询错误",  
148 - })  
149 - continue  
150 - }  
151 - if cooperationProject == nil {  
152 - var orderNumber string  
153 - if orderGood.DividendsOrderNumber != "" {  
154 - orderNumber = orderGood.DividendsOrderNumber  
155 - } else {  
156 - orderNumber = orderGood.DividendsReturnedOrderNumber  
157 - }  
158 - dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{  
159 - DividendsUser: nil,  
160 - DividendsParticipateType: 0,  
161 - DividendsStage: 0,  
162 - DividendsAmount: 0,  
163 - OrderOrReturnedOrderNumber: orderNumber,  
164 - IsSuccessfully: false,  
165 - Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",  
166 - })  
167 - continue  
168 - }  
169 - }  
170 -  
171 if orderGood.DividendsOrderNumber != "" { // 获取分红订单 100 if orderGood.DividendsOrderNumber != "" { // 获取分红订单
172 // 获取分红订单 101 // 获取分红订单
173 dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{ 102 dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{
@@ -250,6 +179,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -250,6 +179,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
250 IsSuccessfully: true, 179 IsSuccessfully: true,
251 CooperationContractUndertakerId: undertaker.UndertakerId, 180 CooperationContractUndertakerId: undertaker.UndertakerId,
252 DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage, 181 DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
  182 + CooperationContractNumber: orderGood.CooperationContractNumber,
  183 + OrderGoodId: orderGood.OrderGoodId,
  184 + OrderGoodAmount: orderGood.OrderGoodAmount,
253 }) 185 })
254 } 186 }
255 // 添加推荐人分红预算信息详情 187 // 添加推荐人分红预算信息详情
@@ -277,6 +209,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -277,6 +209,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
277 IsSuccessfully: true, 209 IsSuccessfully: true,
278 CooperationContractUndertakerId: undertaker.UndertakerId, 210 CooperationContractUndertakerId: undertaker.UndertakerId,
279 DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage, 211 DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
  212 + CooperationContractNumber: orderGood.CooperationContractNumber,
  213 + OrderGoodId: orderGood.OrderGoodId,
  214 + OrderGoodAmount: orderGood.OrderGoodAmount,
280 }) 215 })
281 } 216 }
282 } 217 }
@@ -305,6 +240,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -305,6 +240,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
305 IsSuccessfully: true, 240 IsSuccessfully: true,
306 CooperationContractUndertakerId: undertaker.UndertakerId, 241 CooperationContractUndertakerId: undertaker.UndertakerId,
307 DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage, 242 DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
  243 + CooperationContractNumber: orderGood.CooperationContractNumber,
  244 + OrderGoodId: orderGood.OrderGoodId,
  245 + OrderGoodAmount: orderGood.OrderGoodAmount,
308 }) 246 })
309 } 247 }
310 } 248 }
@@ -350,6 +288,18 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -350,6 +288,18 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
350 } 288 }
351 } 289 }
352 // 计算分红 290 // 计算分红
  291 + if len(cooperationContract.Undertakers) <= 0 {
  292 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  293 + DividendsUser: nil,
  294 + DividendsParticipateType: 0,
  295 + DividendsStage: 0,
  296 + DividendsAmount: 0,
  297 + OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
  298 + IsSuccessfully: false,
  299 + Reason: "合约承接人不存在",
  300 + })
  301 + continue
  302 + } else {
353 for _, undertaker := range cooperationContract.Undertakers { 303 for _, undertaker := range cooperationContract.Undertakers {
354 // 添加承接人分红退货预算信息详情 304 // 添加承接人分红退货预算信息详情
355 if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 { 305 if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
@@ -376,6 +326,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -376,6 +326,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
376 IsSuccessfully: true, 326 IsSuccessfully: true,
377 CooperationContractUndertakerId: undertaker.UndertakerId, 327 CooperationContractUndertakerId: undertaker.UndertakerId,
378 DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage, 328 DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
  329 + CooperationContractNumber: orderGood.CooperationContractNumber,
  330 + OrderGoodId: orderGood.OrderGoodId,
  331 + OrderGoodAmount: orderGood.OrderGoodAmount,
379 }) 332 })
380 } 333 }
381 334
@@ -404,6 +357,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -404,6 +357,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
404 IsSuccessfully: true, 357 IsSuccessfully: true,
405 CooperationContractUndertakerId: undertaker.UndertakerId, 358 CooperationContractUndertakerId: undertaker.UndertakerId,
406 DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage, 359 DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
  360 + CooperationContractNumber: orderGood.CooperationContractNumber,
  361 + OrderGoodId: orderGood.OrderGoodId,
  362 + OrderGoodAmount: orderGood.OrderGoodAmount,
407 }) 363 })
408 } 364 }
409 } 365 }
@@ -433,12 +389,17 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -433,12 +389,17 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
433 IsSuccessfully: true, 389 IsSuccessfully: true,
434 CooperationContractUndertakerId: undertaker.UndertakerId, 390 CooperationContractUndertakerId: undertaker.UndertakerId,
435 DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage, 391 DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
  392 + CooperationContractNumber: orderGood.CooperationContractNumber,
  393 + OrderGoodId: orderGood.OrderGoodId,
  394 + OrderGoodAmount: orderGood.OrderGoodAmount,
436 }) 395 })
437 } 396 }
438 } 397 }
439 } 398 }
440 } 399 }
441 } 400 }
  401 + }
  402 +
442 return dividendsEstimateDetails, nil 403 return dividendsEstimateDetails, nil
443 } 404 }
444 405
@@ -68,7 +68,7 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions @@ -68,7 +68,7 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions
68 // 2.计算百分比 68 // 2.计算百分比
69 var totalAmount float64 69 var totalAmount float64
70 for i := range goods { 70 for i := range goods {
71 - goods[i].Rank = int32(i + 1) 71 + goods[i].Rank = int32(i+1) + int32(request.Offset)
72 totalAmount += goods[i].GoodAmount 72 totalAmount += goods[i].GoodAmount
73 } 73 }
74 for i := range goods { 74 for i := range goods {
@@ -655,8 +655,16 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query @@ -655,8 +655,16 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
655 // 按关联相关人过滤 655 // 按关联相关人过滤
656 var contractNumbers []string 656 var contractNumbers []string
657 var err error 657 var err error
  658 + var retMap = map[string]interface{}{
  659 + "xAxis": map[string]interface{}{
  660 + "data": []string{},
  661 + },
  662 + "source": map[string]interface{}{
  663 + "value": []float64{},
  664 + },
  665 + }
658 if request.UserBaseId > 0 { 666 if request.UserBaseId > 0 {
659 - var retMap = make([]interface{}, 0) 667 +
660 contractNumbers, err = ptr.getUnderTakerContracts(map[string]interface{}{"userId": request.UserId}) 668 contractNumbers, err = ptr.getUnderTakerContracts(map[string]interface{}{"userId": request.UserId})
661 if len(contractNumbers) == 0 { 669 if len(contractNumbers) == 0 {
662 return retMap, nil 670 return retMap, nil
@@ -666,7 +674,6 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query @@ -666,7 +674,6 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
666 } 674 }
667 queryOptions["cooperationContractNumbers"] = contractNumbers 675 queryOptions["cooperationContractNumbers"] = contractNumbers
668 } else if request.UserId > 0 && request.OrgId > 0 { 676 } else if request.UserId > 0 && request.OrgId > 0 {
669 - var retMap = make([]interface{}, 0)  
670 contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"userId": request.UserId}) 677 contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"userId": request.UserId})
671 if len(contractNumbers) == 0 { 678 if len(contractNumbers) == 0 {
672 return retMap, nil 679 return retMap, nil
@@ -693,7 +700,13 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query @@ -693,7 +700,13 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
693 } 700 }
694 queryOptions["paymentBeginTime"] = item.BeginTime 701 queryOptions["paymentBeginTime"] = item.BeginTime
695 queryOptions["paymentEndTime"] = item.EndTime 702 queryOptions["paymentEndTime"] = item.EndTime
696 - if err := creditAccountDao.DividendsStatistics(queryOptions, dividends); err != nil { 703 + if err := creditAccountDao.DividendsStatistics(map[string]interface{}{
  704 + "orgId": request.OrgId,
  705 + "userBaseId": request.UserBaseId,
  706 + "cooperationContractNumbers": contractNumbers,
  707 + "paymentBeginTime": item.BeginTime,
  708 + "paymentEndTime": item.EndTime,
  709 + }, dividends); err != nil {
697 return nil, err 710 return nil, err
698 } 711 }
699 values = append(values, dividends.Paid) 712 values = append(values, dividends.Paid)
@@ -367,6 +367,10 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s @@ -367,6 +367,10 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
367 if a.DividendsPercentage > 0 { 367 if a.DividendsPercentage > 0 {
368 item["dividendsRatio"] = a.DividendsPercentage 368 item["dividendsRatio"] = a.DividendsPercentage
369 } 369 }
  370 + // 金额激励承接人分红比例百分百,业务员 推荐人按设定的比例
  371 + if a.DividendsType == 3 && a.DividendsPercentage == 0 {
  372 + item["dividendsRatio"] = 100
  373 + }
370 dividends = append(dividends, item) 374 dividends = append(dividends, item)
371 } 375 }
372 res["dividends"] = dividends 376 res["dividends"] = dividends
@@ -424,7 +428,12 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st @@ -424,7 +428,12 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
424 if err := dividendsEstimateDao.DividendsEstimateStatistics(queryOptions, allDividendsEstimate); err != nil { 428 if err := dividendsEstimateDao.DividendsEstimateStatistics(queryOptions, allDividendsEstimate); err != nil {
425 return nil, err 429 return nil, err
426 } 430 }
427 - if err := creditAccountDao.DividendsStatistics(queryOptions, allDividends); err != nil { 431 + if err := creditAccountDao.DividendsStatistics(map[string]interface{}{
  432 + "companyId": request.CompanyId,
  433 + "orgId": request.OrgId,
  434 + "userBaseId": request.UserBaseId,
  435 + "cooperationContractNumbers": contractNumbers,
  436 + }, allDividends); err != nil {
428 return nil, err 437 return nil, err
429 } 438 }
430 allDividendsEstimate.Paid = allDividends.Paid 439 allDividendsEstimate.Paid = allDividends.Paid
@@ -437,10 +446,10 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st @@ -437,10 +446,10 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
437 if err := creditAccountDao.DividendsStatistics(map[string]interface{}{ 446 if err := creditAccountDao.DividendsStatistics(map[string]interface{}{
438 "companyId": request.CompanyId, 447 "companyId": request.CompanyId,
439 "orgId": request.OrgId, 448 "orgId": request.OrgId,
440 - "userId": request.UserId,  
441 "userBaseId": request.UserBaseId, 449 "userBaseId": request.UserBaseId,
442 "paymentBeginTime": queryOptions["beginTime"], 450 "paymentBeginTime": queryOptions["beginTime"],
443 "paymentEndTime": queryOptions["endTime"], 451 "paymentEndTime": queryOptions["endTime"],
  452 + "cooperationContractNumbers": contractNumbers,
444 }, annualDividends); err != nil { 453 }, annualDividends); err != nil {
445 return nil, err 454 return nil, err
446 } 455 }
@@ -453,10 +462,10 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st @@ -453,10 +462,10 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
453 if err := creditAccountDao.DividendsStatistics(map[string]interface{}{ 462 if err := creditAccountDao.DividendsStatistics(map[string]interface{}{
454 "companyId": request.CompanyId, 463 "companyId": request.CompanyId,
455 "orgId": request.OrgId, 464 "orgId": request.OrgId,
456 - "userId": request.UserId,  
457 "userBaseId": request.UserBaseId, 465 "userBaseId": request.UserBaseId,
458 "paymentBeginTime": queryOptions["beginTime"], 466 "paymentBeginTime": queryOptions["beginTime"],
459 "paymentEndTime": queryOptions["endTime"], 467 "paymentEndTime": queryOptions["endTime"],
  468 + "cooperationContractNumbers": contractNumbers,
460 }, quarterDividends); err != nil { 469 }, quarterDividends); err != nil {
461 return nil, err 470 return nil, err
462 } 471 }
@@ -9,7 +9,6 @@ import ( @@ -9,7 +9,6 @@ import (
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
10 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 10 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
12 -  
13 rawlog "log" 12 rawlog "log"
14 ) 13 )
15 14
@@ -15,9 +15,9 @@ func TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationC @@ -15,9 +15,9 @@ func TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationC
15 Company: cooperationContractChangeLogModel.Company, 15 Company: cooperationContractChangeLogModel.Company,
16 Org: cooperationContractChangeLogModel.Org, 16 Org: cooperationContractChangeLogModel.Org,
17 Operator: cooperationContractChangeLogModel.Operator, 17 Operator: cooperationContractChangeLogModel.Operator,
18 - OperatorTime: cooperationContractChangeLogModel.OperatorTime, 18 + OperatorTime: cooperationContractChangeLogModel.OperatorTime.Local(),
19 UpdatedAt: cooperationContractChangeLogModel.UpdatedAt, 19 UpdatedAt: cooperationContractChangeLogModel.UpdatedAt,
20 DeletedAt: cooperationContractChangeLogModel.DeletedAt, 20 DeletedAt: cooperationContractChangeLogModel.DeletedAt,
21 - CreatedAt: cooperationContractChangeLogModel.CreatedAt, 21 + CreatedAt: cooperationContractChangeLogModel.CreatedAt.Local(),
22 }, nil 22 }, nil
23 } 23 }
@@ -164,9 +164,11 @@ func (repository *CooperationApplicationRepository) UpdateMany(cooperationApplic @@ -164,9 +164,11 @@ func (repository *CooperationApplicationRepository) UpdateMany(cooperationApplic
164 UpdatedAt: time.Now(), 164 UpdatedAt: time.Now(),
165 }) 165 })
166 } 166 }
  167 + if len(cooperationApplicationModels) > 0 {
167 if _, err := tx.Model(&cooperationApplicationModels).WherePK().Update(); err != nil { 168 if _, err := tx.Model(&cooperationApplicationModels).WherePK().Update(); err != nil {
168 return nil, err 169 return nil, err
169 } 170 }
  171 + }
170 return cooperationApplications, nil 172 return cooperationApplications, nil
171 } 173 }
172 174
@@ -51,7 +51,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -51,7 +51,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
51 updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "cooperationContract_id") 51 updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "cooperationContract_id")
52 updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields) 52 updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
53 tx := repository.transactionContext.PgTx 53 tx := repository.transactionContext.PgTx
54 - if cooperationContract.Identify() == nil { 54 + if cooperationContract.Identify() == nil { // 新增合约
55 cooperationContractId, err := repository.nextIdentify() 55 cooperationContractId, err := repository.nextIdentify()
56 if err != nil { 56 if err != nil {
57 return cooperationContract, err 57 return cooperationContract, err
@@ -256,7 +256,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -256,7 +256,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
256 return nil, err 256 return nil, err
257 } 257 }
258 } 258 }
259 - } else { 259 + } else { // 编辑合约
260 if _, err := tx.QueryOne( 260 if _, err := tx.QueryOne(
261 pg.Scan( 261 pg.Scan(
262 &cooperationContract.CooperationContractId, 262 &cooperationContract.CooperationContractId,
@@ -823,13 +823,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -823,13 +823,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
823 } 823 }
824 } 824 }
825 } 825 }
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 cooperationContract, nil 826 return cooperationContract, nil
834 } 827 }
835 828
@@ -1111,7 +1104,8 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string @@ -1111,7 +1104,8 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string
1111 if err := cooperationContractUndertakerQuery. 1104 if err := cooperationContractUndertakerQuery.
1112 Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). 1105 Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
1113 Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). 1106 Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
1114 - Where("cooperation_contract_id = ?", cooperationContractModel.CooperationContractId). 1107 + //Where("cooperation_contract_id = ?", cooperationContractModel.CooperationContractId).
  1108 + Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
1115 Select(); err != nil { 1109 Select(); err != nil {
1116 return nil, fmt.Errorf("合约承接人不存在") 1110 return nil, fmt.Errorf("合约承接人不存在")
1117 } 1111 }
@@ -1149,6 +1143,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -1149,6 +1143,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
1149 if cooperationContractName, ok := queryOptions["cooperationContractName"]; ok && cooperationContractName != "" { 1143 if cooperationContractName, ok := queryOptions["cooperationContractName"]; ok && cooperationContractName != "" {
1150 query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName)) 1144 query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
1151 } 1145 }
  1146 + if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
  1147 + query.Where("cooperation_project_number = ?", cooperationProjectNumber)
  1148 + }
1152 if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" { 1149 if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
1153 query.Where(`(cooperation_contract.department->>'departmentName')::text LIKE ?`, fmt.Sprintf("%%%s%%", departmentName)) 1150 query.Where(`(cooperation_contract.department->>'departmentName')::text LIKE ?`, fmt.Sprintf("%%%s%%", departmentName))
1154 } 1151 }
@@ -276,7 +276,9 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int @@ -276,7 +276,9 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
276 return q, nil 276 return q, nil
277 }) 277 })
278 } 278 }
  279 + if searchCooperationProjectExtQueriesFlag, ok := queryOptions["searchCooperationProjectExtQueriesFlag"]; ok && searchCooperationProjectExtQueriesFlag.(int) != 0 {
279 if searchCooperationProjectExtQueries, ok := queryOptions["searchCooperationProjectExtQueries"]; ok && len(searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery)) > 0 { 280 if searchCooperationProjectExtQueries, ok := queryOptions["searchCooperationProjectExtQueries"]; ok && len(searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery)) > 0 {
  281 + query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
280 for _, searchCooperationProjectExtQuery := range searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery) { 282 for _, searchCooperationProjectExtQuery := range searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery) {
281 query.WhereOrGroup(func(q *orm.Query) (*orm.Query, error) { 283 query.WhereOrGroup(func(q *orm.Query) (*orm.Query, error) {
282 if searchCooperationProjectExtQuery.ExtCompanyId != 0 { 284 if searchCooperationProjectExtQuery.ExtCompanyId != 0 {
@@ -300,6 +302,12 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int @@ -300,6 +302,12 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
300 return q, nil 302 return q, nil
301 }) 303 })
302 } 304 }
  305 + query.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, 3) //公开
  306 + return q, nil
  307 + })
  308 + } else {
  309 + query.Where(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, 3) //公开
  310 + }
303 } 311 }
304 if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" { 312 if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
305 query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName)) 313 query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName))
@@ -223,15 +223,16 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do @@ -223,15 +223,16 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do
223 if _, err := tx.Model(&dividendsEstimateModels).Insert(); err != nil { 223 if _, err := tx.Model(&dividendsEstimateModels).Insert(); err != nil {
224 return nil, err 224 return nil, err
225 } 225 }
226 - var dividendsEstimatesSaved []*domain.DividendsEstimate  
227 - for _, dividendsEstimateModel := range dividendsEstimateModels {  
228 - if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {  
229 - return dividendsEstimates, err  
230 - } else {  
231 - dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimate)  
232 - }  
233 - }  
234 - return dividendsEstimatesSaved, nil 226 + //var dividendsEstimatesSaved []*domain.DividendsEstimate
  227 + //for _, dividendsEstimateModel := range dividendsEstimateModels {
  228 + // if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {
  229 + // return dividendsEstimates, err
  230 + // } else {
  231 + // dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimate)
  232 + // }
  233 + //}
  234 + //return dividendsEstimatesSaved, nil
  235 + return dividendsEstimates, nil
235 } 236 }
236 return nil, nil 237 return nil, nil
237 } 238 }
@@ -270,15 +271,16 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* @@ -270,15 +271,16 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*
270 if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil { 271 if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil {
271 return nil, err 272 return nil, err
272 } 273 }
273 - var dividendsEstimatesUpdated []*domain.DividendsEstimate  
274 - for _, dividendsEstimateModel := range dividendsEstimateModels {  
275 - if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {  
276 - return dividendsEstimates, err  
277 - } else {  
278 - dividendsEstimatesUpdated = append(dividendsEstimatesUpdated, dividendsEstimate)  
279 - }  
280 - }  
281 - return dividendsEstimatesUpdated, nil 274 + //var dividendsEstimatesUpdated []*domain.DividendsEstimate
  275 + //for _, dividendsEstimateModel := range dividendsEstimateModels {
  276 + // if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {
  277 + // return dividendsEstimates, err
  278 + // } else {
  279 + // dividendsEstimatesUpdated = append(dividendsEstimatesUpdated, dividendsEstimate)
  280 + // }
  281 + //}
  282 + //return dividendsEstimatesUpdated, nil
  283 + return dividendsEstimates, nil
282 } 284 }
283 285
284 func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) { 286 func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) {
@@ -291,6 +293,21 @@ func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain. @@ -291,6 +293,21 @@ func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.
291 return dividendsEstimate, nil 293 return dividendsEstimate, nil
292 } 294 }
293 295
  296 +func (repository *DividendsEstimateRepository) BatchRemove(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) {
  297 + tx := repository.transactionContext.PgTx
  298 + var dividendsEstimateModels []*models.DividendsEstimate
  299 + for _, dividendsEstimate := range dividendsEstimates {
  300 + dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{
  301 + DividendsEstimateId: dividendsEstimate.Identify().(int64),
  302 + })
  303 + }
  304 + if _, err := tx.Model(&dividendsEstimateModels).WherePK().Delete(); err != nil {
  305 + return dividendsEstimates, err
  306 + } else {
  307 + return dividendsEstimates, nil
  308 + }
  309 +}
  310 +
294 func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsEstimate, error) { 311 func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsEstimate, error) {
295 tx := repository.transactionContext.PgTx 312 tx := repository.transactionContext.PgTx
296 dividendsEstimateModel := new(models.DividendsEstimate) 313 dividendsEstimateModel := new(models.DividendsEstimate)
@@ -299,6 +316,9 @@ func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]i @@ -299,6 +316,9 @@ func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]i
299 if orderOrReturnedOrderNum, ok := queryOptions["orderOrReturnedOrderNum"]; ok && orderOrReturnedOrderNum != "" { 316 if orderOrReturnedOrderNum, ok := queryOptions["orderOrReturnedOrderNum"]; ok && orderOrReturnedOrderNum != "" {
300 query.Where("order_or_returned_order_num = ?", orderOrReturnedOrderNum) 317 query.Where("order_or_returned_order_num = ?", orderOrReturnedOrderNum)
301 } 318 }
  319 + if isCanceled, ok := queryOptions["isCanceled"]; ok {
  320 + query.Where("is_canceled = ?", isCanceled.(bool))
  321 + }
302 if err := query.First(); err != nil { 322 if err := query.First(); err != nil {
303 if err.Error() == "pg: no rows in result set" { 323 if err.Error() == "pg: no rows in result set" {
304 return nil, fmt.Errorf("分红预算单不存在") 324 return nil, fmt.Errorf("分红预算单不存在")
@@ -490,15 +490,6 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai @@ -490,15 +490,6 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai
490 } else { 490 } else {
491 for _, dividendsOrder := range dividendsOrders { 491 for _, dividendsOrder := range dividendsOrders {
492 // 删除订单产品 492 // 删除订单产品
493 - //var orderGoodModels []*models.OrderGood  
494 - //if _, err := tx.Model(&orderGoodModels).  
495 - // Where("company_id = ?", dividendsOrder.Company.CompanyId).  
496 - // Where("org_id = ?", dividendsOrder.Org.OrgId).  
497 - // Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).WherePK().Delete(); err != nil {  
498 - // return nil, err  
499 - //}  
500 -  
501 - // 删除订单产品  
502 var orderGoodModels []*models.OrderGood 493 var orderGoodModels []*models.OrderGood
503 orderGoodQuery := tx.Model(&orderGoodModels) 494 orderGoodQuery := tx.Model(&orderGoodModels)
504 if err := orderGoodQuery. 495 if err := orderGoodQuery.
@@ -30,6 +30,26 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 { @@ -30,6 +30,26 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 {
30 return intersection 30 return intersection
31 } 31 }
32 32
  33 +// Intersect32 返回两个数组的交集
  34 +func Intersect32(nums1 []int32, nums2 []int32) []int32 {
  35 + if len(nums1) > len(nums2) {
  36 + return Intersect32(nums2, nums1)
  37 + }
  38 + m := map[int32]int32{}
  39 + for _, num := range nums1 {
  40 + m[num]++
  41 + }
  42 +
  43 + var intersection []int32
  44 + for _, num := range nums2 {
  45 + if m[num] > 0 {
  46 + intersection = append(intersection, num)
  47 + m[num]--
  48 + }
  49 + }
  50 + return intersection
  51 +}
  52 +
33 // Difference 求差集 slice1-并集 53 // Difference 求差集 slice1-并集
34 func Difference(slice1, slice2 []int64) []int64 { 54 func Difference(slice1, slice2 []int64) []int64 {
35 m := make(map[int64]int) 55 m := make(map[int64]int)
@@ -144,6 +164,36 @@ func RemoveDuplicationInt64(arr []int64) []int64 { @@ -144,6 +164,36 @@ func RemoveDuplicationInt64(arr []int64) []int64 {
144 return arr[:j] 164 return arr[:j]
145 } 165 }
146 166
  167 +func RemoveDuplicationString(arr []string) []string {
  168 + set := make(map[string]struct{}, len(arr))
  169 + j := 0
  170 + for _, v := range arr {
  171 + _, ok := set[v]
  172 + if ok {
  173 + continue
  174 + }
  175 + set[v] = struct{}{}
  176 + arr[j] = v
  177 + j++
  178 + }
  179 + return arr[:j]
  180 +}
  181 +
  182 +func RemoveDuplicationInt32(arr []int32) []int32 {
  183 + set := make(map[int32]struct{}, len(arr))
  184 + j := 0
  185 + for _, v := range arr {
  186 + _, ok := set[v]
  187 + if ok {
  188 + continue
  189 + }
  190 + set[v] = struct{}{}
  191 + arr[j] = v
  192 + j++
  193 + }
  194 + return arr[:j]
  195 +}
  196 +
147 // IsContain 判断int32数组是否包含 197 // IsContain 判断int32数组是否包含
148 func IsContain(items []int32, item int32) bool { 198 func IsContain(items []int32, item int32) bool {
149 for _, eachItem := range items { 199 for _, eachItem := range items {
@@ -50,7 +50,8 @@ func (logger *BeegoLog) Debug(msg string, appends ...map[string]interface{}) { @@ -50,7 +50,8 @@ func (logger *BeegoLog) Debug(msg string, appends ...map[string]interface{}) {
50 logs.Debug(msg, make(map[string]interface{}, 0)) 50 logs.Debug(msg, make(map[string]interface{}, 0))
51 } else { 51 } else {
52 var out bytes.Buffer 52 var out bytes.Buffer
53 - err := json.Indent(&out, appendsJson, "", " ") 53 + //err := json.Indent(&out, appendsJson, "", " ")
  54 + err := json.Compact(&out, appendsJson)
54 if err != nil { 55 if err != nil {
55 fmt.Println(msg) 56 fmt.Println(msg)
56 return 57 return
@@ -65,7 +66,8 @@ func (logger *BeegoLog) Info(msg string, appends ...map[string]interface{}) { @@ -65,7 +66,8 @@ func (logger *BeegoLog) Info(msg string, appends ...map[string]interface{}) {
65 logs.Info(msg, make(map[string]interface{}, 0)) 66 logs.Info(msg, make(map[string]interface{}, 0))
66 } else { 67 } else {
67 var out bytes.Buffer 68 var out bytes.Buffer
68 - err := json.Indent(&out, appendsJson, "", " ") 69 + //err := json.Indent(&out, appendsJson, "", " ")
  70 + err := json.Compact(&out, appendsJson)
69 if err != nil { 71 if err != nil {
70 fmt.Println(msg) 72 fmt.Println(msg)
71 return 73 return
@@ -32,7 +32,16 @@ func init() { @@ -32,7 +32,16 @@ func init() {
32 } 32 }
33 } 33 }
34 //https支持 34 //https支持
  35 + if os.Getenv("ENABLE_HTTPS") != "" {
  36 + enableHTTPS := os.Getenv("ENABLE_HTTPS")
  37 + if enableHTTPS == "true" {
35 web.BConfig.Listen.EnableHTTPS = true 38 web.BConfig.Listen.EnableHTTPS = true
  39 + } else {
  40 + web.BConfig.Listen.EnableHTTPS = false
  41 + }
  42 + } else {
  43 + web.BConfig.Listen.EnableHTTPS = false
  44 + }
36 web.BConfig.Listen.HTTPSPort = 443 45 web.BConfig.Listen.HTTPSPort = 443
37 web.BConfig.Listen.HTTPSCertFile = "./config/fjmaimaimai.com_bundle.crt" 46 web.BConfig.Listen.HTTPSCertFile = "./config/fjmaimaimai.com_bundle.crt"
38 web.BConfig.Listen.HTTPSKeyFile = "./config/fjmaimaimai.com.key" 47 web.BConfig.Listen.HTTPSKeyFile = "./config/fjmaimaimai.com.key"
@@ -55,14 +55,18 @@ func (controller *CooperationProjectController) GetCooperationProject() { @@ -55,14 +55,18 @@ func (controller *CooperationProjectController) GetCooperationProject() {
55 cooperationProjectService := service.NewCooperationProjectService(nil) 55 cooperationProjectService := service.NewCooperationProjectService(nil)
56 getCooperationProjectQuery := &query.GetCooperationProjectQuery{} 56 getCooperationProjectQuery := &query.GetCooperationProjectQuery{}
57 header := controller.GetRequestHeader(controller.Ctx) 57 header := controller.GetRequestHeader(controller.Ctx)
58 - getCooperationProjectQuery.CompanyId = header.CompanyId  
59 - getCooperationProjectQuery.OrgId = header.OrgId 58 + //getCooperationProjectQuery.CompanyId = header.CompanyId
  59 + //getCooperationProjectQuery.OrgId = header.OrgId
60 getCooperationProjectQuery.UserId = header.UserId 60 getCooperationProjectQuery.UserId = header.UserId
61 getCooperationProjectQuery.UserBaseId = header.UserBaseId 61 getCooperationProjectQuery.UserBaseId = header.UserBaseId
62 cooperationProjectId, _ := controller.GetInt64(":cooperationProjectId") 62 cooperationProjectId, _ := controller.GetInt64(":cooperationProjectId")
63 getCooperationProjectQuery.CooperationProjectId = cooperationProjectId 63 getCooperationProjectQuery.CooperationProjectId = cooperationProjectId
64 cooperationProjectNumber := controller.GetString("cooperationProjectNumber") 64 cooperationProjectNumber := controller.GetString("cooperationProjectNumber")
65 getCooperationProjectQuery.CooperationProjectNumber = cooperationProjectNumber 65 getCooperationProjectQuery.CooperationProjectNumber = cooperationProjectNumber
  66 + companyId, _ := controller.GetInt64("companyId")
  67 + getCooperationProjectQuery.CompanyId = companyId
  68 + orgId, _ := controller.GetInt64("orgId")
  69 + getCooperationProjectQuery.OrgId = orgId
66 data, err := cooperationProjectService.GetCooperationProject(getCooperationProjectQuery) 70 data, err := cooperationProjectService.GetCooperationProject(getCooperationProjectQuery)
67 controller.Response(data, err) 71 controller.Response(data, err)
68 } 72 }
@@ -55,14 +55,18 @@ func (controller *DividendsOrderController) GetDividendsOrder() { @@ -55,14 +55,18 @@ func (controller *DividendsOrderController) GetDividendsOrder() {
55 dividendsOrderService := service.NewDividendsOrderService(nil) 55 dividendsOrderService := service.NewDividendsOrderService(nil)
56 getDividendsOrderQuery := &query.GetDividendsOrderQuery{} 56 getDividendsOrderQuery := &query.GetDividendsOrderQuery{}
57 header := controller.GetRequestHeader(controller.Ctx) 57 header := controller.GetRequestHeader(controller.Ctx)
58 - getDividendsOrderQuery.CompanyId = header.CompanyId  
59 - getDividendsOrderQuery.OrgId = header.OrgId 58 + //getDividendsOrderQuery.CompanyId = header.CompanyId
  59 + //getDividendsOrderQuery.OrgId = header.OrgId
60 getDividendsOrderQuery.UserId = header.UserId 60 getDividendsOrderQuery.UserId = header.UserId
61 getDividendsOrderQuery.UserBaseId = header.UserBaseId 61 getDividendsOrderQuery.UserBaseId = header.UserBaseId
62 dividendsOrderId, _ := controller.GetInt64(":dividendsOrderId") 62 dividendsOrderId, _ := controller.GetInt64(":dividendsOrderId")
63 getDividendsOrderQuery.DividendsOrderId = dividendsOrderId 63 getDividendsOrderQuery.DividendsOrderId = dividendsOrderId
64 dividendsOrderNumber := controller.GetString("dividendsOrderNumber") 64 dividendsOrderNumber := controller.GetString("dividendsOrderNumber")
65 getDividendsOrderQuery.DividendsOrderNumber = dividendsOrderNumber 65 getDividendsOrderQuery.DividendsOrderNumber = dividendsOrderNumber
  66 + companyId, _ := controller.GetInt64("companyId")
  67 + getDividendsOrderQuery.CompanyId = companyId
  68 + orgId, _ := controller.GetInt64("orgId")
  69 + getDividendsOrderQuery.OrgId = orgId
66 data, err := dividendsOrderService.GetDividendsOrder(getDividendsOrderQuery) 70 data, err := dividendsOrderService.GetDividendsOrder(getDividendsOrderQuery)
67 controller.Response(data, err) 71 controller.Response(data, err)
68 } 72 }