作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !59
... ... @@ -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,43 @@ 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
}
}
if utils.IsContain(undertakerUserTypes, int32(1)) && utils.IsContain(undertakerUserTypes, int32(2)) {
undertakerUserTypes = append(undertakerUserTypes, int32(3))
}
newUndertakerTypesUncheckedAvailable := utils.Intersect32(undertakerTypesUncheckedAvailable, undertakerUserTypes)
log.Logger.Info("承接人类型", map[string]interface{}{
"undertakerUserTypes": undertakerUserTypes,
})
// 返回所有员工类型的申请通过人
applicants := make([]*domain.User, 0)
... ... @@ -357,6 +404,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 {
... ... @@ -375,7 +423,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
}
cooperationProjectDto := &dto.CooperationProjectsDto{}
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable, applicants); err != nil {
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, newUndertakerTypesUncheckedAvailable, applicants); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -639,6 +687,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
}
}
}
var undertakerTypes []int32
var k1, k2 int32
if len(applicantTypes) > 0 {
... ... @@ -654,6 +703,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
if k1 != 0 && k2 != 0 {
undertakerTypes = append(undertakerTypes, 3)
}
// 校验可以修改的承接人(申请人)类型
for _, t := range undertakerTypes {
if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) {
... ...
... ... @@ -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")
... ...
... ... @@ -30,6 +30,26 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 {
return intersection
}
// Intersect32 返回两个数组的交集
func Intersect32(nums1 []int32, nums2 []int32) []int32 {
if len(nums1) > len(nums2) {
return Intersect32(nums2, nums1)
}
m := map[int32]int32{}
for _, num := range nums1 {
m[num]++
}
var intersection []int32
for _, num := range nums2 {
if m[num] > 0 {
intersection = append(intersection, num)
m[num]--
}
}
return intersection
}
// Difference 求差集 slice1-并集
func Difference(slice1, slice2 []int64) []int64 {
m := make(map[int64]int)
... ... @@ -144,6 +164,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 {
... ...