正在显示
18 个修改的文件
包含
519 行增加
和
9 行删除
| @@ -225,10 +225,10 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | @@ -225,10 +225,10 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | ||
| 225 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 225 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 226 | } else { | 226 | } else { |
| 227 | // 更新共创项目申请人计数 | 227 | // 更新共创项目申请人计数 |
| 228 | - cooperationProject.ApplicantCount = cooperationProject.ApplicantCount + 1 | ||
| 229 | - if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil { | ||
| 230 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 231 | - } | 228 | + //cooperationProject.ApplicantCount = cooperationProject.ApplicantCount + 1 |
| 229 | + //if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil { | ||
| 230 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 231 | + //} | ||
| 232 | if err := transactionContext.CommitTransaction(); err != nil { | 232 | if err := transactionContext.CommitTransaction(); err != nil { |
| 233 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 233 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 234 | } | 234 | } |
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | "encoding/json" | 6 | "encoding/json" |
| 7 | "fmt" | 7 | "fmt" |
| 8 | "github.com/linmadan/egglib-go/core/application" | 8 | "github.com/linmadan/egglib-go/core/application" |
| 9 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
| 9 | "github.com/linmadan/egglib-go/utils/tool_funs" | 10 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/dto" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/dto" |
| @@ -364,6 +365,14 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -364,6 +365,14 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
| 364 | if cooperationContract, err := cooperationContractRepository.Save(newCooperationContract); err != nil { | 365 | if cooperationContract, err := cooperationContractRepository.Save(newCooperationContract); err != nil { |
| 365 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 366 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 366 | } else { | 367 | } else { |
| 368 | + | ||
| 369 | + if err = cooperationContractService.UpdateCooperationProjectStaticsInfo(transactionContext, | ||
| 370 | + cooperationContract.Company.CompanyId, | ||
| 371 | + cooperationContract.Org.OrgId, | ||
| 372 | + cooperationContract.CooperationProjectNumber); err != nil { | ||
| 373 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 374 | + } | ||
| 375 | + | ||
| 367 | if err := transactionContext.CommitTransaction(); err != nil { | 376 | if err := transactionContext.CommitTransaction(); err != nil { |
| 368 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 377 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 369 | } | 378 | } |
| @@ -1504,6 +1513,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1504,6 +1513,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
| 1504 | if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil { | 1513 | if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil { |
| 1505 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error()) | 1514 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error()) |
| 1506 | } | 1515 | } |
| 1516 | + | ||
| 1517 | + if err = cooperationContractService.UpdateCooperationProjectStaticsInfo(transactionContext, | ||
| 1518 | + updateCooperationContractCommand.CompanyId, | ||
| 1519 | + updateCooperationContractCommand.OrgId, | ||
| 1520 | + updateCooperationContractCommand.CooperationProjectNumber); err != nil { | ||
| 1521 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1522 | + } | ||
| 1523 | + | ||
| 1507 | if err21 := transactionContext.CommitTransaction(); err21 != nil { | 1524 | if err21 := transactionContext.CommitTransaction(); err21 != nil { |
| 1508 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err21.Error()) | 1525 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err21.Error()) |
| 1509 | } | 1526 | } |
| @@ -1511,6 +1528,70 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1511,6 +1528,70 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
| 1511 | } | 1528 | } |
| 1512 | } | 1529 | } |
| 1513 | 1530 | ||
| 1531 | +// 更新共创项目统计数据(申请人数 、 合约数) | ||
| 1532 | +func (cooperationContractService *CooperationContractService) UpdateCooperationProjectStaticsInfo(transactionContext application.TransactionContext, | ||
| 1533 | + companyId, orgId int64, | ||
| 1534 | + cooperationProjectNumber string) error { | ||
| 1535 | + cooperationProjectRepository, _ := factory.CreateCooperationProjectRepository(map[string]interface{}{ | ||
| 1536 | + "transactionContext": transactionContext, | ||
| 1537 | + }) | ||
| 1538 | + project, err := cooperationProjectRepository.FindOne(map[string]interface{}{ | ||
| 1539 | + "companyId": companyId, | ||
| 1540 | + "orgId": orgId, | ||
| 1541 | + "cooperationProjectNumber": cooperationProjectNumber, | ||
| 1542 | + }) | ||
| 1543 | + if err != nil { | ||
| 1544 | + return err | ||
| 1545 | + } | ||
| 1546 | + | ||
| 1547 | + cooperationContractDao, _ := dao.NewCooperationContractDao(transactionContext.(*pg.TransactionContext)) | ||
| 1548 | + total, contracts, err := cooperationContractDao.Find(map[string]interface{}{ | ||
| 1549 | + "companyId": companyId, | ||
| 1550 | + "orgId": orgId, | ||
| 1551 | + "cooperationProjectNumber": cooperationProjectNumber, | ||
| 1552 | + "offsetLimitFlag": false, | ||
| 1553 | + }) | ||
| 1554 | + if err != nil { | ||
| 1555 | + return err | ||
| 1556 | + } | ||
| 1557 | + project.ContractCount = int32(total) | ||
| 1558 | + | ||
| 1559 | + // 共创合约数量 | ||
| 1560 | + cooperationContractIds := make([]int64, 0) | ||
| 1561 | + for i := range contracts { | ||
| 1562 | + cooperationContractIds = append(cooperationContractIds, contracts[i].CooperationContractId) | ||
| 1563 | + } | ||
| 1564 | + | ||
| 1565 | + // 承接人数量 | ||
| 1566 | + cooperationContractUndertakerRepository, _ := dao.NewCooperationContractUndertakerDao(transactionContext.(*pg.TransactionContext)) | ||
| 1567 | + _, underTakers, err := cooperationContractUndertakerRepository.Find(map[string]interface{}{ | ||
| 1568 | + "companyId": companyId, | ||
| 1569 | + "orgId": orgId, | ||
| 1570 | + "cooperationProjectNumber": cooperationProjectNumber, | ||
| 1571 | + "cooperationContractIds": cooperationContractIds, | ||
| 1572 | + "offsetLimitFlag": false, | ||
| 1573 | + }) | ||
| 1574 | + if err != nil { | ||
| 1575 | + return err | ||
| 1576 | + } | ||
| 1577 | + var count = 0 | ||
| 1578 | + for i := range underTakers { | ||
| 1579 | + item := underTakers[i] | ||
| 1580 | + count += 1 // 默认承接人 | ||
| 1581 | + if item.Undertaker.Referrer != nil && item.Undertaker.Referrer.UserBaseId != 0 { | ||
| 1582 | + count += 1 | ||
| 1583 | + } | ||
| 1584 | + if item.Undertaker.Salesman != nil && item.Undertaker.Salesman.UserBaseId != 0 { | ||
| 1585 | + count += 1 | ||
| 1586 | + } | ||
| 1587 | + } | ||
| 1588 | + project.ApplicantCount = int32(count) | ||
| 1589 | + if _, err := cooperationProjectRepository.Save(project); err != nil { | ||
| 1590 | + return err | ||
| 1591 | + } | ||
| 1592 | + return nil | ||
| 1593 | +} | ||
| 1594 | + | ||
| 1514 | func NewCooperationContractService(options map[string]interface{}) *CooperationContractService { | 1595 | func NewCooperationContractService(options map[string]interface{}) *CooperationContractService { |
| 1515 | newCooperationContractService := &CooperationContractService{} | 1596 | newCooperationContractService := &CooperationContractService{} |
| 1516 | return newCooperationContractService | 1597 | return newCooperationContractService |
| @@ -47,6 +47,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS | @@ -47,6 +47,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS | ||
| 47 | res, err = statisticsService.CompanyCooperationUsersStatistics(contractStatisticsQuery.QueryOptions) | 47 | res, err = statisticsService.CompanyCooperationUsersStatistics(contractStatisticsQuery.QueryOptions) |
| 48 | case domain_service.CompanyPaymentHistoryStatistics: | 48 | case domain_service.CompanyPaymentHistoryStatistics: |
| 49 | res, err = statisticsService.CompanyPaymentHistoryStatistics(contractStatisticsQuery.QueryOptions) | 49 | res, err = statisticsService.CompanyPaymentHistoryStatistics(contractStatisticsQuery.QueryOptions) |
| 50 | + case domain_service.CompanyCooperationProjectContracts: | ||
| 51 | + res, err = statisticsService.CompanyCooperationProjectContracts(contractStatisticsQuery.QueryOptions) | ||
| 50 | case domain_service.PaymentHistoryHistogramStatistics: | 52 | case domain_service.PaymentHistoryHistogramStatistics: |
| 51 | res, err = statisticsService.PaymentHistoryHistogramStatistics(contractStatisticsQuery.QueryOptions) | 53 | res, err = statisticsService.PaymentHistoryHistogramStatistics(contractStatisticsQuery.QueryOptions) |
| 52 | case domain_service.CooperationUserModeStatistics: | 54 | case domain_service.CooperationUserModeStatistics: |
| @@ -61,6 +63,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS | @@ -61,6 +63,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS | ||
| 61 | res, err = statisticsService.PersonCooperationContractStatistics(contractStatisticsQuery.QueryOptions) | 63 | res, err = statisticsService.PersonCooperationContractStatistics(contractStatisticsQuery.QueryOptions) |
| 62 | case domain_service.PersonCompanyPaymentHistoryStatistics: | 64 | case domain_service.PersonCompanyPaymentHistoryStatistics: |
| 63 | res, err = statisticsService.PersonCompanyPaymentHistoryStatistics(contractStatisticsQuery.QueryOptions) | 65 | res, err = statisticsService.PersonCompanyPaymentHistoryStatistics(contractStatisticsQuery.QueryOptions) |
| 66 | + case domain_service.PersonCooperationProjectSharedInfo: | ||
| 67 | + res, err = statisticsService.PersonCooperationProjectSharedInfo(contractStatisticsQuery.QueryOptions) | ||
| 64 | case domain_service.CreditAccountStatistics: | 68 | case domain_service.CreditAccountStatistics: |
| 65 | res, err = statisticsService.CreditAccountStatistics(contractStatisticsQuery.QueryOptions) | 69 | res, err = statisticsService.CreditAccountStatistics(contractStatisticsQuery.QueryOptions) |
| 66 | case domain_service.RelevantCooperationContractNumbers: | 70 | case domain_service.RelevantCooperationContractNumbers: |
| @@ -1021,6 +1021,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -1021,6 +1021,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 1021 | 1021 | ||
| 1022 | return map[string]interface{}{ | 1022 | return map[string]interface{}{ |
| 1023 | "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), |
| 1024 | + "dividendsEstimates": dividendsEstimatesSaved, | ||
| 1024 | }, nil | 1025 | }, nil |
| 1025 | } | 1026 | } |
| 1026 | } | 1027 | } |
| 1 | package domain | 1 | package domain |
| 2 | 2 | ||
| 3 | -import "time" | 3 | +import ( |
| 4 | + "strings" | ||
| 5 | + "time" | ||
| 6 | +) | ||
| 4 | 7 | ||
| 5 | // CooperationPersonStatisticsDto 共创人员信息统计 | 8 | // CooperationPersonStatisticsDto 共创人员信息统计 |
| 6 | type CooperationPersonStatisticsDto struct { | 9 | type CooperationPersonStatisticsDto struct { |
| @@ -15,3 +18,97 @@ type CooperationPersonStatisticsDto struct { | @@ -15,3 +18,97 @@ type CooperationPersonStatisticsDto struct { | ||
| 15 | // 共创人员姓名 | 18 | // 共创人员姓名 |
| 16 | UserName string `json:"userName"` | 19 | UserName string `json:"userName"` |
| 17 | } | 20 | } |
| 21 | + | ||
| 22 | +// 1.共创项目浏览详情 | ||
| 23 | + | ||
| 24 | +// 共创项目详情 | ||
| 25 | +type CooperationProjectSharedInfoDto struct { | ||
| 26 | + // 共创项目数据 | ||
| 27 | + Project interface{} `json:"project"` | ||
| 28 | + // 企业信息 | ||
| 29 | + Org *Org `json:"org"` | ||
| 30 | + // 企业关注状态 | ||
| 31 | + OrgStarred bool `json:"orgStarred"` | ||
| 32 | + // 合同参与人 | ||
| 33 | + ContractParticipant []*ContractParticipant `json:"contractParticipant"` | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +// 项目参与人 | ||
| 37 | +type ContractParticipant struct { | ||
| 38 | + // | ||
| 39 | + User *User `json:"-"` | ||
| 40 | + // 参与人 | ||
| 41 | + Participant interface{} `json:"participant"` | ||
| 42 | + // 合约数据 (合约名称、合约状态、合约附件) | ||
| 43 | + Contract interface{} `json:"contract"` | ||
| 44 | + // 订单金额 | ||
| 45 | + OrderAmount float64 `json:"orderAmount"` | ||
| 46 | + // 分红金额 () | ||
| 47 | + DividendsAmount float64 `json:"dividendsAmount"` | ||
| 48 | + // 合同内容 | ||
| 49 | + ContractContent string `json:"contractContent"` | ||
| 50 | + // 敏感标识 | ||
| 51 | + SensitiveFlag bool `json:"sensitiveFlag"` | ||
| 52 | + // 共创合约编号 | ||
| 53 | + primaryKey string `json:"key"` | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +func (u *User) SimpleCopy() map[string]interface{} { | ||
| 57 | + return map[string]interface{}{ | ||
| 58 | + "userId": u.UserId, | ||
| 59 | + //"userBaseId":u.UserBaseId, | ||
| 60 | + "userInfo": u.UserInfo, | ||
| 61 | + } | ||
| 62 | +} | ||
| 63 | +func (ut *Undertaker) ToUser() *User { | ||
| 64 | + return &User{UserId: ut.UserId, UserBaseId: ut.UserBaseId, UserInfo: ut.UserInfo} | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +func (ut *Referrer) ToUser() *User { | ||
| 68 | + return &User{UserId: ut.UserId, UserBaseId: ut.UserBaseId, UserInfo: ut.UserInfo} | ||
| 69 | +} | ||
| 70 | + | ||
| 71 | +func (ut *Salesman) ToUser() *User { | ||
| 72 | + return &User{UserId: ut.UserId, UserInfo: ut.UserInfo} | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +func NewContractParticipant(u *User, primaryKey string, attachments []*Attachment) *ContractParticipant { | ||
| 76 | + p := &ContractParticipant{ | ||
| 77 | + User: u, | ||
| 78 | + Participant: u.SimpleCopy(), | ||
| 79 | + primaryKey: primaryKey, | ||
| 80 | + } | ||
| 81 | + if len(attachments) > 0 { | ||
| 82 | + p.ContractContent = attachments[0].Name | ||
| 83 | + } | ||
| 84 | + return p | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +func (cp *ContractParticipant) Complete(userBaseId int64, sensitive bool) *ContractParticipant { | ||
| 88 | + cp.SensitiveFlag = false | ||
| 89 | + if sensitive { | ||
| 90 | + if cp.User.UserBaseId != userBaseId { | ||
| 91 | + cp.DividendsAmount = 0 | ||
| 92 | + cp.SensitiveFlag = true | ||
| 93 | + name := []byte(cp.User.UserInfo.UserName) | ||
| 94 | + for i := range name { | ||
| 95 | + if i == 0 { | ||
| 96 | + continue | ||
| 97 | + } | ||
| 98 | + name[i] = byte('*') | ||
| 99 | + } | ||
| 100 | + cp.User.UserInfo.UserName = string(name) | ||
| 101 | + cp.Participant = cp.User.SimpleCopy() | ||
| 102 | + } | ||
| 103 | + return cp | ||
| 104 | + } | ||
| 105 | + return cp | ||
| 106 | +} | ||
| 107 | + | ||
| 108 | +func (cp *ContractParticipant) CooperationContractNumber() string { | ||
| 109 | + sp := strings.Split(cp.primaryKey, "-") | ||
| 110 | + if len(sp) == 0 { | ||
| 111 | + return "" | ||
| 112 | + } | ||
| 113 | + return sp[0] | ||
| 114 | +} |
| @@ -44,6 +44,8 @@ type CooperationProject struct { | @@ -44,6 +44,8 @@ type CooperationProject struct { | ||
| 44 | CreatedAt time.Time `json:"createdAt"` | 44 | CreatedAt time.Time `json:"createdAt"` |
| 45 | // 共创申请人计数 | 45 | // 共创申请人计数 |
| 46 | ApplicantCount int32 `json:"applicantCount"` | 46 | ApplicantCount int32 `json:"applicantCount"` |
| 47 | + // 合约计数 | ||
| 48 | + ContractCount int32 `json:"contractCount"` | ||
| 47 | } | 49 | } |
| 48 | 50 | ||
| 49 | type CooperationProjectRepository interface { | 51 | type CooperationProjectRepository interface { |
| @@ -206,6 +206,9 @@ func (dao *CooperationContractDao) Find(queryOptions map[string]interface{}) (in | @@ -206,6 +206,9 @@ func (dao *CooperationContractDao) Find(queryOptions map[string]interface{}) (in | ||
| 206 | if cooperationModeNumber, ok := queryOptions["cooperationModeNumber"]; ok && cooperationModeNumber.(string) != "" { | 206 | if cooperationModeNumber, ok := queryOptions["cooperationModeNumber"]; ok && cooperationModeNumber.(string) != "" { |
| 207 | query.Where("cooperation_mode_number = ?", cooperationModeNumber) | 207 | query.Where("cooperation_mode_number = ?", cooperationModeNumber) |
| 208 | } | 208 | } |
| 209 | + if CooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && CooperationProjectNumber.(string) != "" { | ||
| 210 | + query.Where("cooperation_project_number = ?", CooperationProjectNumber) | ||
| 211 | + } | ||
| 209 | if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | 212 | if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { |
| 210 | query.Where("company->>'companyId' = '?'", companyId) | 213 | query.Where("company->>'companyId' = '?'", companyId) |
| 211 | } | 214 | } |
| @@ -43,6 +43,9 @@ func (repository *CooperationContractUndertakerDao) Find(queryOptions map[string | @@ -43,6 +43,9 @@ func (repository *CooperationContractUndertakerDao) Find(queryOptions map[string | ||
| 43 | return query, nil | 43 | return query, nil |
| 44 | }) | 44 | }) |
| 45 | } | 45 | } |
| 46 | + if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) > 0 { | ||
| 47 | + query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds)) | ||
| 48 | + } | ||
| 46 | if userId, ok := queryOptions["userId"]; ok && userId.(int64) != 0 { | 49 | if userId, ok := queryOptions["userId"]; ok && userId.(int64) != 0 { |
| 47 | query.WhereGroup(func(query *orm.Query) (*orm.Query, error) { | 50 | query.WhereGroup(func(query *orm.Query) (*orm.Query, error) { |
| 48 | query.WhereOr("user_id = ? ", userId) | 51 | query.WhereOr("user_id = ? ", userId) |
| @@ -211,6 +211,45 @@ func (dao *DividendsEstimateDao) DividendsEstimateStatistics(queryOptions map[st | @@ -211,6 +211,45 @@ func (dao *DividendsEstimateDao) DividendsEstimateStatistics(queryOptions map[st | ||
| 211 | return nil | 211 | return nil |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | +// CountDividendsEstimate 统计当前分红预算单总数 | ||
| 215 | +func (dao *DividendsEstimateDao) DividendsEstimateStatisticsGroup(queryOptions map[string]interface{}) (map[string]float64, error) { | ||
| 216 | + tx := dao.transactionContext.PgTx | ||
| 217 | + var dividendsEstimateModels []*models.DividendsEstimate | ||
| 218 | + query := tx.Model(÷ndsEstimateModels) | ||
| 219 | + query.Column("cooperation_contract_number") | ||
| 220 | + query.ColumnExpr("sum(dividends_amount) dividends_amount") | ||
| 221 | + //query.ColumnExpr(`sum((case when dividends_account_status =1 then dividends_amount else 0 end)) accounting `) | ||
| 222 | + //query.ColumnExpr(`sum((case when dividends_account_status =2 then dividends_amount else 0 end)) accounted `) | ||
| 223 | + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | ||
| 224 | + query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId) | ||
| 225 | + } | ||
| 226 | + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | ||
| 227 | + query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId) | ||
| 228 | + } | ||
| 229 | + if userBaseId, ok := queryOptions["userBaseId"]; ok && userBaseId.(int64) != 0 { | ||
| 230 | + query = query.Where(`dividends_user->>'userBaseId'='?'`, userBaseId) | ||
| 231 | + } | ||
| 232 | + if _, ok := queryOptions["beginTime"]; ok { | ||
| 233 | + query.Where(fmt.Sprintf("created_at>='%s' and created_at<'%s'", (queryOptions["beginTime"].(time.Time)).Format(time.RFC3339), (queryOptions["endTime"].(time.Time)).Format(time.RFC3339))) | ||
| 234 | + } | ||
| 235 | + if cooperationContractNumbers, ok := queryOptions["cooperationContractNumbers"]; ok && len(cooperationContractNumbers.([]string)) != 0 { | ||
| 236 | + query.Where("cooperation_contract_number in (?)", pg.In(cooperationContractNumbers)) | ||
| 237 | + } | ||
| 238 | + query.Where("is_canceled =false") | ||
| 239 | + | ||
| 240 | + query.Group("cooperation_contract_number") | ||
| 241 | + err := query.Select(÷ndsEstimateModels) | ||
| 242 | + if err != nil { | ||
| 243 | + return nil, err | ||
| 244 | + } | ||
| 245 | + response := make(map[string]float64) | ||
| 246 | + for i := range dividendsEstimateModels { | ||
| 247 | + response[dividendsEstimateModels[i].CooperationContractNumber] = dividendsEstimateModels[i].DividendsAmount | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + return response, nil | ||
| 251 | +} | ||
| 252 | + | ||
| 214 | func NewDividendsEstimateDao(transactionContext *pgTransaction.TransactionContext) (*DividendsEstimateDao, error) { | 253 | func NewDividendsEstimateDao(transactionContext *pgTransaction.TransactionContext) (*DividendsEstimateDao, error) { |
| 215 | if transactionContext == nil { | 254 | if transactionContext == nil { |
| 216 | return nil, fmt.Errorf("transactionContext参数不能为空") | 255 | return nil, fmt.Errorf("transactionContext参数不能为空") |
| @@ -84,9 +84,9 @@ func (dao *DividendsOrderDao) CalculateDividendsOrderAmount(queryOptions map[str | @@ -84,9 +84,9 @@ func (dao *DividendsOrderDao) CalculateDividendsOrderAmount(queryOptions map[str | ||
| 84 | if endTime, ok := queryOptions["endTime"]; ok { | 84 | if endTime, ok := queryOptions["endTime"]; ok { |
| 85 | query.Where("order_time< ?", endTime) | 85 | query.Where("order_time< ?", endTime) |
| 86 | } | 86 | } |
| 87 | - if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { | ||
| 88 | - query.Where("cooperation_contract_number = ?", cooperationContractNumber) | ||
| 89 | - } | 87 | + //if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { |
| 88 | + // query.Where("cooperation_contract_number = ?", cooperationContractNumber) | ||
| 89 | + //} | ||
| 90 | err := query.Select() | 90 | err := query.Select() |
| 91 | if err != nil { | 91 | if err != nil { |
| 92 | return 0, err | 92 | return 0, err |
| @@ -119,6 +119,41 @@ func (dao *DividendsOrderDao) CalculateGoodOrderAmount(queryOptions map[string]i | @@ -119,6 +119,41 @@ func (dao *DividendsOrderDao) CalculateGoodOrderAmount(queryOptions map[string]i | ||
| 119 | return orderGood.OrderGoodAmount, nil | 119 | return orderGood.OrderGoodAmount, nil |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | +// CalculateDividendsOrderAmount 计算分红订单金额 | ||
| 123 | +func (dao *DividendsOrderDao) CalculateGoodOrderAmountByGroup(queryOptions map[string]interface{}) (map[string]float64, error) { | ||
| 124 | + tx := dao.transactionContext.PgTx | ||
| 125 | + var orderGood = new(models.OrderGood) | ||
| 126 | + query := tx.Model(orderGood) | ||
| 127 | + var orderGoods = make([]*models.OrderGood, 0) | ||
| 128 | + query.Column("cooperation_contract_number") | ||
| 129 | + query.ColumnExpr("sum(case when dividends_order_number is null then -order_good_amount else order_good_amount end) as order_good_amount") | ||
| 130 | + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | ||
| 131 | + query.Where("company_id = '?'", companyId) | ||
| 132 | + } | ||
| 133 | + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | ||
| 134 | + query.Where("org_id = '?'", orgId) | ||
| 135 | + } | ||
| 136 | + if beginTime, ok := queryOptions["beginTime"]; ok { | ||
| 137 | + query.Where("order_time>= ?", beginTime) | ||
| 138 | + } | ||
| 139 | + if endTime, ok := queryOptions["endTime"]; ok { | ||
| 140 | + query.Where("order_time< ?", endTime) | ||
| 141 | + } | ||
| 142 | + if cooperationContractNumbers, ok := queryOptions["cooperationContractNumbers"]; ok && len(cooperationContractNumbers.([]string)) != 0 { | ||
| 143 | + query.Where("cooperation_contract_number in (?)", pg.In(cooperationContractNumbers)) | ||
| 144 | + } | ||
| 145 | + query.Group("cooperation_contract_number") | ||
| 146 | + err := query.Select(&orderGoods) | ||
| 147 | + if err != nil { | ||
| 148 | + return nil, err | ||
| 149 | + } | ||
| 150 | + response := make(map[string]float64) | ||
| 151 | + for i := range orderGoods { | ||
| 152 | + response[orderGoods[i].CooperationContractNumber] = orderGoods[i].OrderGoodAmount | ||
| 153 | + } | ||
| 154 | + return response, nil | ||
| 155 | +} | ||
| 156 | + | ||
| 122 | func NewOrderGoodDao(transactionContext *pgTransaction.TransactionContext) (*OrderGoodDao, error) { | 157 | func NewOrderGoodDao(transactionContext *pgTransaction.TransactionContext) (*OrderGoodDao, error) { |
| 123 | if transactionContext == nil { | 158 | if transactionContext == nil { |
| 124 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 159 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
| @@ -287,7 +287,10 @@ func LoadQueryOptions(queryOption map[string]interface{}, keys ...string) (map[s | @@ -287,7 +287,10 @@ func LoadQueryOptions(queryOption map[string]interface{}, keys ...string) (map[s | ||
| 287 | func LoadQueryObject(queryOption map[string]interface{}, obj interface{}) error { | 287 | func LoadQueryObject(queryOption map[string]interface{}, obj interface{}) error { |
| 288 | json.UnmarshalFromString(json.MarshalToString(queryOption), obj) | 288 | json.UnmarshalFromString(json.MarshalToString(queryOption), obj) |
| 289 | validation := validation.Validation{} | 289 | validation := validation.Validation{} |
| 290 | - _, err := validation.Valid(obj) | 290 | + result, err := validation.Valid(obj) |
| 291 | + if !result && len(validation.Errors) > 0 { | ||
| 292 | + return validation.Errors[0] | ||
| 293 | + } | ||
| 291 | return err | 294 | return err |
| 292 | } | 295 | } |
| 293 | 296 |
| 1 | package domain_service | 1 | package domain_service |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "fmt" | ||
| 4 | "github.com/go-pg/pg/v10" | 5 | "github.com/go-pg/pg/v10" |
| 5 | "github.com/linmadan/egglib-go/utils/tool_funs" | 6 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" |
| 7 | "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" |
| 8 | "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/infrastructure/service_gateway" | ||
| 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
| 10 | "time" | 13 | "time" |
| 11 | ) | 14 | ) |
| @@ -191,3 +194,227 @@ func (ptr *CooperationStatisticsService) PersonCompanyPaymentHistoryStatistics(q | @@ -191,3 +194,227 @@ func (ptr *CooperationStatisticsService) PersonCompanyPaymentHistoryStatistics(q | ||
| 191 | 194 | ||
| 192 | return retMap, nil | 195 | return retMap, nil |
| 193 | } | 196 | } |
| 197 | + | ||
| 198 | +// 个人 - 共创浏览 详情页 | ||
| 199 | +func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfo(queryOptions map[string]interface{}) (interface{}, error) { | ||
| 200 | + // 参数验证 | ||
| 201 | + var request = struct { | ||
| 202 | + UserBaseId int64 `json:"userBaseId"` | ||
| 203 | + // 项目ID | ||
| 204 | + ProjectId int64 `json:"projectId" valid:"Required"` | ||
| 205 | + // 敏感数据 | ||
| 206 | + Sensitive bool `json:"sensitive" valid:"Required"` | ||
| 207 | + }{} | ||
| 208 | + if err := LoadQueryObject(queryOptions, &request); err != nil { | ||
| 209 | + return nil, err | ||
| 210 | + } | ||
| 211 | + queryOptions = tool_funs.SimpleStructToMap(&request) | ||
| 212 | + var response = domain.CooperationProjectSharedInfoDto{ | ||
| 213 | + ContractParticipant: make([]*domain.ContractParticipant, 0), | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + projectRepository, _ := repository.NewCooperationProjectRepository(ptr.transactionContext) | ||
| 217 | + project, err := projectRepository.FindOne(map[string]interface{}{"cooperationProjectId": request.ProjectId}) | ||
| 218 | + if err != nil { | ||
| 219 | + return nil, fmt.Errorf("共创项目不存在") | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + // 0.共创项目数据 | ||
| 223 | + updateAt := project.UpdatedAt | ||
| 224 | + if project.UpdatedAt.IsZero() { | ||
| 225 | + updateAt = project.CreatedAt | ||
| 226 | + } | ||
| 227 | + response.Project = map[string]interface{}{ | ||
| 228 | + "cooperationProjectId": project.CooperationProjectId, | ||
| 229 | + "attachment": project.Attachment, | ||
| 230 | + "cooperationProjectDescription": project.CooperationProjectDescription, | ||
| 231 | + "updatedAt": updateAt.Unix() * 1000, | ||
| 232 | + } | ||
| 233 | + // 0.1 组织数据 | ||
| 234 | + response.Org = project.Org | ||
| 235 | + if request.UserBaseId != 0 { | ||
| 236 | + // 当前用户对于项目组织的关注状态 | ||
| 237 | + userServiceGateway := service_gateway.NewHttplibUserServiceGateway() | ||
| 238 | + userDetail, e := userServiceGateway.GetUserInfo(0, 0, request.UserBaseId) | ||
| 239 | + if e == nil && userDetail != nil { | ||
| 240 | + for i := range userDetail.Favorite.OrgItems { | ||
| 241 | + if userDetail.Favorite.OrgItems[i] == project.Org.OrgId { | ||
| 242 | + response.OrgStarred = true | ||
| 243 | + break | ||
| 244 | + } | ||
| 245 | + } | ||
| 246 | + } | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + // 0.2 合约数据 | ||
| 250 | + contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext) // repository.NewCooperationContractRepository(ptr.transactionContext) | ||
| 251 | + _, contracts, _ := contractRepository.Find(map[string]interface{}{"cooperationProjectNumber": project.CooperationProjectNumber, "companyId": project.Company.CompanyId, "orgId": project.Org.OrgId}) | ||
| 252 | + if len(contracts) == 0 { | ||
| 253 | + return response, nil | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + contractNumbers := make([]string, 0) | ||
| 257 | + mapContract := make(map[string]*domain.CooperationContract) | ||
| 258 | + for i := range contracts { | ||
| 259 | + contractNumbers = append(contractNumbers, contracts[i].CooperationContractNumber) | ||
| 260 | + mapContract[contracts[i].CooperationContractNumber] = contracts[i] | ||
| 261 | + } | ||
| 262 | + keyfun := func(num string, userBaseId int64) string { | ||
| 263 | + return num + "-" + fmt.Sprintf("%v", userBaseId) | ||
| 264 | + } | ||
| 265 | + | ||
| 266 | + // 1.项目的承接人 | ||
| 267 | + undertakerRepository, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext) | ||
| 268 | + _, undertakers, err := undertakerRepository.Find(map[string]interface{}{"cooperationContractNumbers": contractNumbers, "companyId": project.Company.CompanyId, "orgId": project.Org.OrgId}) | ||
| 269 | + userSorted := make([]string, 0) | ||
| 270 | + mapUser := make(map[string]*domain.ContractParticipant) | ||
| 271 | + for i := range undertakers { | ||
| 272 | + u := undertakers[i] | ||
| 273 | + key := keyfun(u.CooperationContractNumber, u.Undertaker.UserBaseId) | ||
| 274 | + userSorted = append(userSorted, key) | ||
| 275 | + mapUser[keyfun(u.CooperationContractNumber, u.Undertaker.UserBaseId)] = domain.NewContractParticipant(u.Undertaker.ToUser(), key, u.Undertaker.ContractAttachment) | ||
| 276 | + if u.Undertaker.Referrer != nil { | ||
| 277 | + key = keyfun(u.CooperationContractNumber, u.Undertaker.Referrer.UserBaseId) | ||
| 278 | + userSorted = append(userSorted, key) | ||
| 279 | + mapUser[keyfun(u.CooperationContractNumber, u.Undertaker.Referrer.UserBaseId)] = domain.NewContractParticipant(u.Undertaker.Referrer.ToUser(), key, u.Undertaker.ContractAttachment) | ||
| 280 | + } | ||
| 281 | + if u.Undertaker.Salesman != nil { | ||
| 282 | + userSorted = append(userSorted, keyfun(u.CooperationContractNumber, u.Undertaker.Salesman.UserBaseId)) | ||
| 283 | + mapUser[keyfun(u.CooperationContractNumber, u.Undertaker.Salesman.UserBaseId)] = domain.NewContractParticipant(u.Undertaker.Salesman.ToUser(), key, u.Undertaker.ContractAttachment) | ||
| 284 | + } | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + // 2.合约的订单金额 | ||
| 288 | + mapContractOrderAmount := make(map[string]float64) | ||
| 289 | + dividendsOrderDao, _ := dao.NewDividendsOrderDao(ptr.transactionContext) | ||
| 290 | + mapContractOrderAmount, _ = dividendsOrderDao.CalculateGoodOrderAmountByGroup(map[string]interface{}{ | ||
| 291 | + "cooperationContractNumbers": contractNumbers, "companyId": project.Company.CompanyId, "orgId": project.Org.OrgId, | ||
| 292 | + }) | ||
| 293 | + | ||
| 294 | + // 3.计算合约用户的分红预算金额 | ||
| 295 | + dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext) | ||
| 296 | + _, dividends, err := dividendsEstimateRepository.Find(map[string]interface{}{"cooperationContractNumbers": contractNumbers, "companyId": project.Company.CompanyId, "orgId": project.Org.OrgId, "dividendsAccountStatus": int32(1), "offsetLimit": false}) | ||
| 297 | + for i := range dividends { | ||
| 298 | + d := dividends[i] | ||
| 299 | + key := keyfun(d.CooperationContractNumber, d.DividendsUser.UserBaseId) | ||
| 300 | + if v, ok := mapUser[key]; ok { | ||
| 301 | + v.DividendsAmount += d.DividendsAmount | ||
| 302 | + } | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + for _, v := range mapUser { | ||
| 306 | + if v1, ok := mapContractOrderAmount[v.CooperationContractNumber()]; ok { | ||
| 307 | + v.OrderAmount = v1 | ||
| 308 | + } | ||
| 309 | + if v1, ok := mapContract[v.CooperationContractNumber()]; ok { | ||
| 310 | + v.Contract = map[string]interface{}{ | ||
| 311 | + "cooperationContractId": v1.CooperationContractId, | ||
| 312 | + "cooperationContractName": v1.CooperationContractName, | ||
| 313 | + "status": v1.Status, | ||
| 314 | + } | ||
| 315 | + } | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + for i := range userSorted { | ||
| 319 | + if v, ok := mapUser[userSorted[i]]; ok { | ||
| 320 | + response.ContractParticipant = append(response.ContractParticipant, v.Complete(request.UserBaseId, request.Sensitive)) | ||
| 321 | + } | ||
| 322 | + } | ||
| 323 | + return response, nil | ||
| 324 | +} | ||
| 325 | + | ||
| 326 | +// 个人 - 共创浏览 合约列表 | ||
| 327 | +func (ptr *CooperationStatisticsService) CompanyCooperationProjectContracts(queryOptions map[string]interface{}) (interface{}, error) { | ||
| 328 | + // 参数验证 | ||
| 329 | + var request = struct { | ||
| 330 | + Offset int `json:"offset"` | ||
| 331 | + Limit int `json:"limit"` | ||
| 332 | + // 项目ID | ||
| 333 | + ProjectId int64 `json:"projectId" valid:"Required"` | ||
| 334 | + }{} | ||
| 335 | + if err := LoadQueryObject(queryOptions, &request); err != nil { | ||
| 336 | + return nil, err | ||
| 337 | + } | ||
| 338 | + projectRepository, _ := repository.NewCooperationProjectRepository(ptr.transactionContext) | ||
| 339 | + project, err := projectRepository.FindOne(map[string]interface{}{"cooperationProjectId": request.ProjectId}) | ||
| 340 | + if err != nil { | ||
| 341 | + return nil, fmt.Errorf("共创项目不存在") | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + // 0.2 合约数据 | ||
| 345 | + contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext) // repository.NewCooperationContractRepository(ptr.transactionContext) | ||
| 346 | + _, contracts, _ := contractRepository.Find(map[string]interface{}{"cooperationProjectNumber": project.CooperationProjectNumber, | ||
| 347 | + "companyId": project.Company.CompanyId, | ||
| 348 | + "orgId": project.Org.OrgId, | ||
| 349 | + "limit": request.Limit, | ||
| 350 | + "offset": request.Offset, | ||
| 351 | + }) | ||
| 352 | + if len(contracts) == 0 { | ||
| 353 | + return nil, nil | ||
| 354 | + } | ||
| 355 | + | ||
| 356 | + contractNumbers := make([]string, 0) | ||
| 357 | + mapContract := make(map[string]*domain.CooperationContract) | ||
| 358 | + for i := range contracts { | ||
| 359 | + contractNumbers = append(contractNumbers, contracts[i].CooperationContractNumber) | ||
| 360 | + mapContract[contracts[i].CooperationContractNumber] = contracts[i] | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | + // 2.合约的订单金额 | ||
| 364 | + mapContractOrderAmount := make(map[string]float64) | ||
| 365 | + dividendsOrderDao, _ := dao.NewDividendsOrderDao(ptr.transactionContext) | ||
| 366 | + mapContractOrderAmount, _ = dividendsOrderDao.CalculateGoodOrderAmountByGroup(map[string]interface{}{ | ||
| 367 | + "cooperationContractNumbers": contractNumbers, "companyId": project.Company.CompanyId, "orgId": project.Org.OrgId, | ||
| 368 | + }) | ||
| 369 | + | ||
| 370 | + // 3.计算合约用户的分红预算金额 | ||
| 371 | + dividendsEstimateRepository, _ := dao.NewDividendsEstimateDao(ptr.transactionContext) //repository.NewDividendsEstimateRepository(ptr.transactionContext) | ||
| 372 | + mapDividends, err := dividendsEstimateRepository.DividendsEstimateStatisticsGroup(map[string]interface{}{"cooperationContractNumbers": contractNumbers, "companyId": project.Company.CompanyId, "orgId": project.Org.OrgId}) | ||
| 373 | + if err != nil { | ||
| 374 | + return nil, err | ||
| 375 | + } | ||
| 376 | + results := make([]interface{}, 0) | ||
| 377 | + for i := range contracts { | ||
| 378 | + item := contracts[i] | ||
| 379 | + | ||
| 380 | + resultItem := &searchContractDividendsResult{ | ||
| 381 | + CooperationContractId: item.CooperationContractId, | ||
| 382 | + CooperationContractName: item.CooperationContractName, | ||
| 383 | + CooperationContractNumber: item.CooperationContractNumber, | ||
| 384 | + Status: item.Status, | ||
| 385 | + CreatedAt: item.CreatedAt.Unix() * 1000, | ||
| 386 | + } | ||
| 387 | + if v, ok := mapContractOrderAmount[contracts[i].CooperationContractNumber]; ok { | ||
| 388 | + resultItem.DividendsOrderAmount = v | ||
| 389 | + } | ||
| 390 | + if v, ok := mapDividends[contracts[i].CooperationContractNumber]; ok { | ||
| 391 | + resultItem.DividendsAmount = v | ||
| 392 | + } | ||
| 393 | + results = append(results, resultItem) | ||
| 394 | + } | ||
| 395 | + return results, nil | ||
| 396 | +} | ||
| 397 | + | ||
| 398 | +// func(ptr *CooperationStatisticsService) | ||
| 399 | + | ||
| 400 | +// 个人 - 共创浏览 详情页 - 附件数据 | ||
| 401 | +func (ptr *CooperationStatisticsService) PersonCooperationProjectSharedInfoAttachment(queryOptions map[string]interface{}) (interface{}, error) { | ||
| 402 | + // 参数验证 | ||
| 403 | + var request = struct { | ||
| 404 | + UserBaseId int64 `json:"userBaseId"` | ||
| 405 | + // 用户 | ||
| 406 | + UserId int64 `json:"userId" valid:"Required"` | ||
| 407 | + // 项目ID | ||
| 408 | + ProjectId int64 `json:"projectId" valid:"Required"` | ||
| 409 | + // 合约ID | ||
| 410 | + ContractId int64 `json:"contractId" valid:"Required"` | ||
| 411 | + // 附件类型 1:合约附件 2:支付凭证 | ||
| 412 | + AttachType int `json:"attachType" valid:"Required"` | ||
| 413 | + }{} | ||
| 414 | + if err := LoadQueryObject(queryOptions, &request); err != nil { | ||
| 415 | + return nil, err | ||
| 416 | + } | ||
| 417 | + queryOptions = tool_funs.SimpleStructToMap(&request) | ||
| 418 | + var response = domain.CooperationProjectSharedInfoDto{} | ||
| 419 | + return response, nil | ||
| 420 | +} |
| @@ -34,6 +34,8 @@ const ( | @@ -34,6 +34,8 @@ const ( | ||
| 34 | CooperationUserModeStatistics = "CooperationUserModeStatistics" | 34 | CooperationUserModeStatistics = "CooperationUserModeStatistics" |
| 35 | // 公司 - 共创用户分红支付统计 | 35 | // 公司 - 共创用户分红支付统计 |
| 36 | CompanyPaymentHistoryStatistics = "CompanyPaymentHistoryStatistics" | 36 | CompanyPaymentHistoryStatistics = "CompanyPaymentHistoryStatistics" |
| 37 | + // 企业共创项目 - 合约列表 | ||
| 38 | + CompanyCooperationProjectContracts = "CompanyCooperationProjectContracts" | ||
| 37 | 39 | ||
| 38 | // 个人 - 共创企业统计 | 40 | // 个人 - 共创企业统计 |
| 39 | CooperationCompanyStatistics = "CooperationCompanyStatistics" | 41 | CooperationCompanyStatistics = "CooperationCompanyStatistics" |
| @@ -41,6 +43,8 @@ const ( | @@ -41,6 +43,8 @@ const ( | ||
| 41 | PersonCooperationContractStatistics = "PersonCooperationContractStatistics" | 43 | PersonCooperationContractStatistics = "PersonCooperationContractStatistics" |
| 42 | // 个人 - 企业支付统计 | 44 | // 个人 - 企业支付统计 |
| 43 | PersonCompanyPaymentHistoryStatistics = "PersonCompanyPaymentHistoryStatistics" | 45 | PersonCompanyPaymentHistoryStatistics = "PersonCompanyPaymentHistoryStatistics" |
| 46 | + // 个人 - 共创项目共享信息数据 | ||
| 47 | + PersonCooperationProjectSharedInfo = "PersonCooperationProjectSharedInfo" | ||
| 44 | 48 | ||
| 45 | // 账期结算单统计 | 49 | // 账期结算单统计 |
| 46 | CreditAccountStatistics = "CreditAccountStatistics" | 50 | CreditAccountStatistics = "CreditAccountStatistics" |
| @@ -47,4 +47,6 @@ type CooperationProject struct { | @@ -47,4 +47,6 @@ type CooperationProject struct { | ||
| 47 | CreatedAt time.Time `comment:"创建时间"` | 47 | CreatedAt time.Time `comment:"创建时间"` |
| 48 | // 申请人统计 | 48 | // 申请人统计 |
| 49 | ApplicantCount int32 `comment:"申请人统计"` | 49 | ApplicantCount int32 `comment:"申请人统计"` |
| 50 | + // 合约计数 | ||
| 51 | + ContractCount int32 `comment:"合约计数"` | ||
| 50 | } | 52 | } |
| @@ -42,5 +42,6 @@ func TransformToCooperationProjectDomainModelFromPgModels( | @@ -42,5 +42,6 @@ func TransformToCooperationProjectDomainModelFromPgModels( | ||
| 42 | DeletedAt: cooperationProjectModel.DeletedAt, | 42 | DeletedAt: cooperationProjectModel.DeletedAt, |
| 43 | CreatedAt: cooperationProjectModel.CreatedAt, | 43 | CreatedAt: cooperationProjectModel.CreatedAt, |
| 44 | ApplicantCount: cooperationProjectModel.ApplicantCount, | 44 | ApplicantCount: cooperationProjectModel.ApplicantCount, |
| 45 | + ContractCount: cooperationProjectModel.ContractCount, | ||
| 45 | }, nil | 46 | }, nil |
| 46 | } | 47 | } |
| @@ -49,6 +49,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -49,6 +49,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 49 | "deleted_at", | 49 | "deleted_at", |
| 50 | "created_at", | 50 | "created_at", |
| 51 | "applicant_count", | 51 | "applicant_count", |
| 52 | + "contract_count", | ||
| 52 | } | 53 | } |
| 53 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) | 54 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) |
| 54 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) | 55 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) |
| @@ -85,6 +86,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -85,6 +86,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 85 | &cooperationProject.DeletedAt, | 86 | &cooperationProject.DeletedAt, |
| 86 | &cooperationProject.CreatedAt, | 87 | &cooperationProject.CreatedAt, |
| 87 | &cooperationProject.ApplicantCount, | 88 | &cooperationProject.ApplicantCount, |
| 89 | + &cooperationProject.ContractCount, | ||
| 88 | ), | 90 | ), |
| 89 | fmt.Sprintf("INSERT INTO cooperation_projects (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), | 91 | fmt.Sprintf("INSERT INTO cooperation_projects (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), |
| 90 | cooperationProject.CooperationProjectId, | 92 | cooperationProject.CooperationProjectId, |
| @@ -107,6 +109,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -107,6 +109,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 107 | nil, | 109 | nil, |
| 108 | cooperationProject.CreatedAt, | 110 | cooperationProject.CreatedAt, |
| 109 | cooperationProject.ApplicantCount, | 111 | cooperationProject.ApplicantCount, |
| 112 | + cooperationProject.ContractCount, | ||
| 110 | ); err != nil { | 113 | ); err != nil { |
| 111 | return cooperationProject, err | 114 | return cooperationProject, err |
| 112 | } | 115 | } |
| @@ -133,6 +136,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -133,6 +136,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 133 | &cooperationProject.DeletedAt, | 136 | &cooperationProject.DeletedAt, |
| 134 | &cooperationProject.CreatedAt, | 137 | &cooperationProject.CreatedAt, |
| 135 | &cooperationProject.ApplicantCount, | 138 | &cooperationProject.ApplicantCount, |
| 139 | + &cooperationProject.ContractCount, | ||
| 136 | ), | 140 | ), |
| 137 | fmt.Sprintf("UPDATE cooperation_projects SET %s WHERE cooperation_project_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), | 141 | fmt.Sprintf("UPDATE cooperation_projects SET %s WHERE cooperation_project_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), |
| 138 | cooperationProject.CooperationProjectId, | 142 | cooperationProject.CooperationProjectId, |
| @@ -155,6 +159,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -155,6 +159,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 155 | nil, | 159 | nil, |
| 156 | cooperationProject.CreatedAt, | 160 | cooperationProject.CreatedAt, |
| 157 | cooperationProject.ApplicantCount, | 161 | cooperationProject.ApplicantCount, |
| 162 | + cooperationProject.ContractCount, | ||
| 158 | cooperationProject.Identify(), | 163 | cooperationProject.Identify(), |
| 159 | ); err != nil { | 164 | ); err != nil { |
| 160 | return cooperationProject, err | 165 | return cooperationProject, err |
| @@ -70,6 +70,9 @@ type UserDetail struct { | @@ -70,6 +70,9 @@ type UserDetail struct { | ||
| 70 | DeletedAt time.Time `json:"deletedAt"` | 70 | DeletedAt time.Time `json:"deletedAt"` |
| 71 | OrgName string `json:"orgName"` | 71 | OrgName string `json:"orgName"` |
| 72 | } `json:"userOrg"` | 72 | } `json:"userOrg"` |
| 73 | + Favorite struct { | ||
| 74 | + OrgItems []int64 `json:"orgItems"` | ||
| 75 | + } `json:"favorite"` | ||
| 73 | // 创建时间 | 76 | // 创建时间 |
| 74 | CreatedAt time.Time `json:"createdAt,omitempty"` | 77 | CreatedAt time.Time `json:"createdAt,omitempty"` |
| 75 | } | 78 | } |
-
请 注册 或 登录 后发表评论