合并分支 'dev' 到 'test'
Dev 查看合并请求 !13
正在显示
8 个修改的文件
包含
101 行增加
和
34 行删除
| @@ -138,6 +138,26 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -138,6 +138,26 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
| 138 | department = data | 138 | department = data |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | + // 共创项目仓储初始化 | ||
| 142 | + var cooperationProjectRepository domain.CooperationProjectRepository | ||
| 143 | + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | ||
| 144 | + "transactionContext": transactionContext, | ||
| 145 | + }); err != nil { | ||
| 146 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 147 | + } else { | ||
| 148 | + cooperationProjectRepository = value | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + // 共创项目DAO初始化 | ||
| 152 | + var cooperationProjectDao *dao.CooperationProjectDao | ||
| 153 | + if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{ | ||
| 154 | + "transactionContext": transactionContext, | ||
| 155 | + }); err != nil { | ||
| 156 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 157 | + } else { | ||
| 158 | + cooperationProjectDao = value | ||
| 159 | + } | ||
| 160 | + | ||
| 141 | // 查找共创模式 | 161 | // 查找共创模式 |
| 142 | var cooperationModeRepository domain.CooperationModeRepository | 162 | var cooperationModeRepository domain.CooperationModeRepository |
| 143 | if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ | 163 | if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ |
| @@ -147,22 +167,17 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -147,22 +167,17 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
| 147 | } else { | 167 | } else { |
| 148 | cooperationModeRepository = value | 168 | cooperationModeRepository = value |
| 149 | } | 169 | } |
| 150 | - cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber}) | 170 | + cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{ |
| 171 | + "companyId": createCooperationProjectCommand.CompanyId, | ||
| 172 | + "orgId": createCooperationProjectCommand.OrgId, | ||
| 173 | + "cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber, | ||
| 174 | + }) | ||
| 151 | if err != nil { | 175 | if err != nil { |
| 152 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") | 176 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") |
| 153 | } | 177 | } |
| 154 | if cooperationMode == nil { | 178 | if cooperationMode == nil { |
| 155 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber)) | 179 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber)) |
| 156 | } else { | 180 | } else { |
| 157 | - // 共创项目DAO初始化 | ||
| 158 | - var cooperationProjectDao *dao.CooperationProjectDao | ||
| 159 | - if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{ | ||
| 160 | - "transactionContext": transactionContext, | ||
| 161 | - }); err != nil { | ||
| 162 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 163 | - } else { | ||
| 164 | - cooperationProjectDao = value | ||
| 165 | - } | ||
| 166 | // 生成共创项目编号 | 181 | // 生成共创项目编号 |
| 167 | projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber(map[string]interface{}{ | 182 | projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber(map[string]interface{}{ |
| 168 | "companyId": createCooperationProjectCommand.CompanyId, | 183 | "companyId": createCooperationProjectCommand.CompanyId, |
| @@ -172,21 +187,27 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -172,21 +187,27 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
| 172 | } | 187 | } |
| 173 | 188 | ||
| 174 | // 校验共创项目编号是否唯一 | 189 | // 校验共创项目编号是否唯一 |
| 175 | - numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{ | 190 | + numberAvailable, err := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{ |
| 176 | "companyId": createCooperationProjectCommand.CompanyId, | 191 | "companyId": createCooperationProjectCommand.CompanyId, |
| 177 | "orgId": createCooperationProjectCommand.OrgId, | 192 | "orgId": createCooperationProjectCommand.OrgId, |
| 178 | "cooperationProjectNumber": projectNumber, | 193 | "cooperationProjectNumber": projectNumber, |
| 179 | }) | 194 | }) |
| 195 | + if err != nil { | ||
| 196 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 197 | + } | ||
| 180 | if !numberAvailable { | 198 | if !numberAvailable { |
| 181 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常") | 199 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常") |
| 182 | } | 200 | } |
| 183 | 201 | ||
| 184 | // 校验共创项目名称是否唯一 | 202 | // 校验共创项目名称是否唯一 |
| 185 | - nameAvailable, _ := cooperationProjectDao.CheckProjectNameAvailable(map[string]interface{}{ | 203 | + nameAvailable, err := cooperationProjectDao.CheckProjectNameAvailable(map[string]interface{}{ |
| 186 | "companyId": createCooperationProjectCommand.CompanyId, | 204 | "companyId": createCooperationProjectCommand.CompanyId, |
| 187 | "orgId": createCooperationProjectCommand.OrgId, | 205 | "orgId": createCooperationProjectCommand.OrgId, |
| 188 | "cooperationProjectName": createCooperationProjectCommand.CooperationProjectName, | 206 | "cooperationProjectName": createCooperationProjectCommand.CooperationProjectName, |
| 189 | }) | 207 | }) |
| 208 | + if err != nil { | ||
| 209 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 210 | + } | ||
| 190 | if !nameAvailable { | 211 | if !nameAvailable { |
| 191 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目名称重复") | 212 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目名称重复") |
| 192 | } | 213 | } |
| @@ -212,14 +233,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -212,14 +233,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
| 212 | CreatedAt: time.Now(), | 233 | CreatedAt: time.Now(), |
| 213 | ApplicantCount: 0, | 234 | ApplicantCount: 0, |
| 214 | } | 235 | } |
| 215 | - var cooperationProjectRepository domain.CooperationProjectRepository | ||
| 216 | - if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | ||
| 217 | - "transactionContext": transactionContext, | ||
| 218 | - }); err != nil { | ||
| 219 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 220 | - } else { | ||
| 221 | - cooperationProjectRepository = value | ||
| 222 | - } | 236 | + |
| 223 | if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); err != nil { | 237 | if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); err != nil { |
| 224 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 238 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 225 | } else { | 239 | } else { |
| @@ -1364,9 +1364,22 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1364,9 +1364,22 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
| 1364 | cooperationContractRepository = value | 1364 | cooperationContractRepository = value |
| 1365 | } | 1365 | } |
| 1366 | 1366 | ||
| 1367 | - // TODO 阶段承接人列表 | 1367 | + // 分红预算仓储初始化 |
| 1368 | + var dividendsEstimateRepository domain.DividendsEstimateRepository | ||
| 1369 | + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | ||
| 1370 | + "transactionContext": transactionContext, | ||
| 1371 | + }); err != nil { | ||
| 1372 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1373 | + } else { | ||
| 1374 | + dividendsEstimateRepository = value | ||
| 1375 | + } | ||
| 1376 | + | ||
| 1377 | + // 阶段承接人列表 | ||
| 1368 | stageAndUndertaker := make([]*dto.StageAndUndertaker, 0) | 1378 | stageAndUndertaker := make([]*dto.StageAndUndertaker, 0) |
| 1369 | 1379 | ||
| 1380 | + // 阶段承接人map | ||
| 1381 | + stageUndertakerMap := make(map[int32][]*domain.Undertaker) | ||
| 1382 | + | ||
| 1370 | // 查找共创合约 | 1383 | // 查找共创合约 |
| 1371 | searchMoneyIncentivesEstimateQuery.IncentivesType = 2 | 1384 | searchMoneyIncentivesEstimateQuery.IncentivesType = 2 |
| 1372 | if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil { | 1385 | if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil { |
| @@ -1374,10 +1387,39 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1374,10 +1387,39 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
| 1374 | } else { | 1387 | } else { |
| 1375 | var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto | 1388 | var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto |
| 1376 | for _, cooperationContract := range cooperationContracts { | 1389 | for _, cooperationContract := range cooperationContracts { |
| 1377 | - // TODO 判断承接人是否已分红 | ||
| 1378 | - //for _, undertaker := range cooperationContract.Undertakers { | ||
| 1379 | - // | ||
| 1380 | - //} | 1390 | + for _, rule := range cooperationContract.MoneyIncentivesRules { |
| 1391 | + stageUndertakerMap[rule.MoneyIncentivesStage] = make([]*domain.Undertaker, 0) | ||
| 1392 | + } | ||
| 1393 | + for _, undertaker := range cooperationContract.Undertakers { | ||
| 1394 | + // 查询承接人分红预算单 | ||
| 1395 | + if countDividendsEstimates, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ | ||
| 1396 | + "cooperationContractNumber": cooperationContract.CooperationContractNumber, | ||
| 1397 | + "companyId": cooperationContract.Company.CompanyId, | ||
| 1398 | + "orgId": cooperationContract.Org.OrgId, | ||
| 1399 | + "dividendsUserId": undertaker.UserId, | ||
| 1400 | + }); err != nil { | ||
| 1401 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1402 | + } else { | ||
| 1403 | + if countDividendsEstimates > 0 { | ||
| 1404 | + for _, dividendsEstimate := range dividendsEstimates { | ||
| 1405 | + if dividendsEstimate.DividendsAccountStatus == 1 || dividendsEstimate.IsCanceled { // 分红预算单状态为待结算或已取消 | ||
| 1406 | + stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker) | ||
| 1407 | + } | ||
| 1408 | + } | ||
| 1409 | + } else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励 | ||
| 1410 | + for i, _ := range stageUndertakerMap { | ||
| 1411 | + stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker) | ||
| 1412 | + } | ||
| 1413 | + } | ||
| 1414 | + } | ||
| 1415 | + } | ||
| 1416 | + | ||
| 1417 | + for k, v := range stageUndertakerMap { | ||
| 1418 | + stageAndUndertaker = append(stageAndUndertaker, &dto.StageAndUndertaker{ | ||
| 1419 | + Stage: k, | ||
| 1420 | + Undertakers: v, | ||
| 1421 | + }) | ||
| 1422 | + } | ||
| 1381 | 1423 | ||
| 1382 | moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{} | 1424 | moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{} |
| 1383 | if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil { | 1425 | if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil { |
| @@ -169,7 +169,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD | @@ -169,7 +169,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD | ||
| 169 | // 校验产品关联合约的激励规则是否匹配订单时间 | 169 | // 校验产品关联合约的激励规则是否匹配订单时间 |
| 170 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 170 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
| 171 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 171 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
| 172 | - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | 172 | + if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
| 173 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) { | ||
| 173 | ruleMatchedFlag = true | 174 | ruleMatchedFlag = true |
| 174 | break | 175 | break |
| 175 | } | 176 | } |
| @@ -754,7 +755,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | @@ -754,7 +755,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | ||
| 754 | // 校验产品关联合约的激励规则是否匹配订单时间 | 755 | // 校验产品关联合约的激励规则是否匹配订单时间 |
| 755 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 756 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
| 756 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 757 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
| 757 | - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | 758 | + if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
| 759 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) { | ||
| 758 | ruleMatchedFlag = true | 760 | ruleMatchedFlag = true |
| 759 | break | 761 | break |
| 760 | } | 762 | } |
| @@ -1205,7 +1207,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD | @@ -1205,7 +1207,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD | ||
| 1205 | // 校验产品关联合约的激励规则是否匹配订单时间 | 1207 | // 校验产品关联合约的激励规则是否匹配订单时间 |
| 1206 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 1208 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
| 1207 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 1209 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
| 1208 | - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | 1210 | + if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
| 1211 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) { | ||
| 1209 | ruleMatchedFlag = true | 1212 | ruleMatchedFlag = true |
| 1210 | break | 1213 | break |
| 1211 | } | 1214 | } |
| @@ -176,7 +176,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide | @@ -176,7 +176,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide | ||
| 176 | // 校验产品关联合约的激励规则是否匹配订单时间 | 176 | // 校验产品关联合约的激励规则是否匹配订单时间 |
| 177 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 177 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
| 178 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 178 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
| 179 | - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | 179 | + if !(orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
| 180 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | ||
| 180 | ruleMatchedFlag = true | 181 | ruleMatchedFlag = true |
| 181 | break | 182 | break |
| 182 | } | 183 | } |
| @@ -795,6 +796,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide | @@ -795,6 +796,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide | ||
| 795 | orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则") | 796 | orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则") |
| 796 | } | 797 | } |
| 797 | } | 798 | } |
| 799 | + | ||
| 798 | orderGoods = append(orderGoods, &domain.OrderGood{ | 800 | orderGoods = append(orderGoods, &domain.OrderGood{ |
| 799 | OrderGoodId: 0, | 801 | OrderGoodId: 0, |
| 800 | OrderGoodAmount: orderGoodAmount, | 802 | OrderGoodAmount: orderGoodAmount, |
| @@ -1177,7 +1179,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | @@ -1177,7 +1179,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | ||
| 1177 | // 校验产品关联合约的激励规则是否匹配订单时间 | 1179 | // 校验产品关联合约的激励规则是否匹配订单时间 |
| 1178 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 1180 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
| 1179 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 1181 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
| 1180 | - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | 1182 | + if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
| 1183 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) { | ||
| 1181 | ruleMatchedFlag = true | 1184 | ruleMatchedFlag = true |
| 1182 | break | 1185 | break |
| 1183 | } | 1186 | } |
| @@ -118,7 +118,7 @@ func (dao *CooperationProjectDao) CheckProjectNameAvailable(queryOptions map[str | @@ -118,7 +118,7 @@ func (dao *CooperationProjectDao) CheckProjectNameAvailable(queryOptions map[str | ||
| 118 | if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | 118 | if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { |
| 119 | query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId) | 119 | query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId) |
| 120 | } | 120 | } |
| 121 | - query.Where("cooperation_project.status = ?", 1) | 121 | + query.Where("cooperation_project.status = ?", 1) |
| 122 | ok, err := query.Exists() | 122 | ok, err := query.Exists() |
| 123 | return !ok, err | 123 | return !ok, err |
| 124 | } | 124 | } |
| @@ -172,7 +172,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -172,7 +172,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
| 172 | // 匹配分红规则 | 172 | // 匹配分红规则 |
| 173 | var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule | 173 | var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule |
| 174 | for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules { | 174 | for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules { |
| 175 | - if dividendsOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) && dividendsOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) { | 175 | + if (dividendsOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) && |
| 176 | + (dividendsOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) { | ||
| 176 | dividendsIncentivesRuleMatched = dividendsIncentivesRule | 177 | dividendsIncentivesRuleMatched = dividendsIncentivesRule |
| 177 | break | 178 | break |
| 178 | } | 179 | } |
| @@ -302,7 +303,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -302,7 +303,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
| 302 | // 匹配分红规则 | 303 | // 匹配分红规则 |
| 303 | var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule | 304 | var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule |
| 304 | for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules { | 305 | for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules { |
| 305 | - if dividendsReturnedOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) && dividendsReturnedOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) { | 306 | + if (dividendsReturnedOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) && |
| 307 | + (dividendsReturnedOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) { | ||
| 306 | dividendsIncentivesRuleMatched = dividendsIncentivesRule | 308 | dividendsIncentivesRuleMatched = dividendsIncentivesRule |
| 307 | break | 309 | break |
| 308 | } | 310 | } |
| @@ -43,7 +43,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -43,7 +43,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
| 43 | 43 | ||
| 44 | // 判断金额激励阶段是否合法 | 44 | // 判断金额激励阶段是否合法 |
| 45 | currentTime := time.Now() | 45 | currentTime := time.Now() |
| 46 | - if moneyIncentivesRuleMatched.MoneyIncentivesStageStart.After(currentTime) { | 46 | + if currentTime.Before(moneyIncentivesRuleMatched.MoneyIncentivesStageStart) { |
| 47 | return nil, fmt.Errorf("还未到分红时间") | 47 | return nil, fmt.Errorf("还未到分红时间") |
| 48 | } | 48 | } |
| 49 | 49 |
| @@ -308,6 +308,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | @@ -308,6 +308,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | ||
| 308 | if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 { | 308 | if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 { |
| 309 | query.Where("cooperation_contract_number in (?)", pg.In(v)) | 309 | query.Where("cooperation_contract_number in (?)", pg.In(v)) |
| 310 | } | 310 | } |
| 311 | + if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { | ||
| 312 | + query.Where(`dividends_user @> '{"uid":"?"}'`, dividendsUserId) | ||
| 313 | + } | ||
| 311 | if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | 314 | if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { |
| 312 | query.Where("company->>'companyId' = '?'", companyId) | 315 | query.Where("company->>'companyId' = '?'", companyId) |
| 313 | } | 316 | } |
-
请 注册 或 登录 后发表评论