作者 陈志颖

fix:修复合约查询

... ... @@ -281,6 +281,16 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
cooperationApplicationRepository = value
}
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery
if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询
getCooperationProjectQuerySpecific = &query.GetCooperationProjectQuery{
... ... @@ -349,6 +359,37 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
}
// TODO 判断项目关联的合约承接人类型
undertakers := make([]*domain.Undertaker, 0)
if countContracts, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
"offsetLimit": false,
}); err != nil {
} else {
if countContracts > 0 {
for _, cooperationContract := range cooperationContracts {
undertakers = append(undertakers, cooperationContract.Undertakers...)
}
}
}
var undertakerUserTypes []int32
for _, undertaker := range undertakers {
undertakerUserTypes = append(undertakerUserTypes, undertaker.UserType)
}
undertakerUserTypes = utils.RemoveDuplicationInt32(undertakerUserTypes)
for i, userType := range undertakerUserTypes {
if userType == 1025 {
undertakerUserTypes[i] = 2
}
}
log.Logger.Info("承接人类型", map[string]interface{}{
"undertakerUserTypes": undertakerUserTypes,
})
// 返回所有员工类型的申请通过人
applicants := make([]*domain.User, 0)
... ... @@ -357,6 +398,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
"cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber,
"companyId": cooperationProject.Company.CompanyId,
"orgId": cooperationProject.Org.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -521,6 +521,7 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat
// ConfirmDividendsIncentivesEstimate 确定业绩激励分红预算
func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncentivesEstimate(confirmDividendsIncentivesEstimateCommand *command.ConfirmDividendsIncentivesEstimateCommand) (interface{}, error) {
start := time.Now() // 获取当前时间
if err := confirmDividendsIncentivesEstimateCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -676,10 +677,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
var countDividendsEstimate int64
for _, orderGood := range orderGoods {
dividendsEstimate := &domain.DividendsEstimate{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
// 临时方案
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红订单产品预算
... ... @@ -957,6 +958,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
failedReasonStr = "无"
}
elapsed := time.Since(start)
fmt.Println("该函数执行完成耗时:", elapsed)
return map[string]interface{}{
"report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
}, nil
... ...
... ... @@ -144,6 +144,16 @@ func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOp
if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
query = query.Where(`A.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("A.company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("A.org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
newOrgIds := utils.SliceItoa(orgIds.([]int64))
query.Where("A.org->>'orgId' in (?)", pg.In(newOrgIds))
}
query.Join("JOIN cooperation_contracts AS A ON A.cooperation_contract_number = cooperation_contract_undertaker.cooperation_contract_number")
query.Join("JOIN cooperation_modes AS B ON B.cooperation_mode_number = A.cooperation_mode_number")
query = query.Order("cooperation_contract_undertaker_id DESC")
... ...
... ... @@ -144,6 +144,21 @@ func RemoveDuplicationInt64(arr []int64) []int64 {
return arr[:j]
}
func RemoveDuplicationInt32(arr []int32) []int32 {
set := make(map[int32]struct{}, len(arr))
j := 0
for _, v := range arr {
_, ok := set[v]
if ok {
continue
}
set[v] = struct{}{}
arr[j] = v
j++
}
return arr[:j]
}
// IsContain 判断int32数组是否包含
func IsContain(items []int32, item int32) bool {
for _, eachItem := range items {
... ...