作者 陈志颖

feat:共创项目详情服务完善

@@ -238,14 +238,39 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -238,14 +238,39 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
238 } else { 238 } else {
239 cooperationProjectDao = value 239 cooperationProjectDao = value
240 } 240 }
241 - // 获取可删除的承接对象类型  
242 - undertakerTypesUncheckedAvailable, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{  
243 - "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,  
244 - "cooperationProjectUndertakerTypes": cooperationProject.CooperationProjectUndertakerTypes, 241 +
  242 + // 可以去除勾选的承接人对象列表
  243 + var undertakerTypesUncheckedAvailable []int32
  244 +
  245 + // 判断承接对象是否存在员工
  246 + gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
  247 + "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
  248 + "user": true,
  249 + })
  250 + if err != nil {
  251 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  252 + }
  253 + if !gotUser {
  254 + undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 1)
  255 + }
  256 +
  257 + // 判断承接对象是否存在共创用户
  258 + gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
  259 + "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
  260 + "partner": true,
245 }) 261 })
246 if err != nil { 262 if err != nil {
247 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 263 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
248 } 264 }
  265 + if !gotPartner {
  266 + undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 2)
  267 + }
  268 +
  269 + // 判断承接人是否存在公开用户
  270 + if !gotUser && !gotPartner {
  271 + undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
  272 + }
  273 +
249 cooperationProjectDto := &dto.CooperationProjectsDto{} 274 cooperationProjectDto := &dto.CooperationProjectsDto{}
250 if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil { 275 if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil {
251 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 276 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -19,7 +19,7 @@ import ( @@ -19,7 +19,7 @@ import (
19 type DividendsOrderService struct { 19 type DividendsOrderService struct {
20 } 20 }
21 21
22 -// CreateDividendsOrder 创建分红订单实体对象 22 +// CreateDividendsOrder 新增分红订单实体对象
23 func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createDividendsOrderCommand *command.CreateDividendsOrderCommand) (interface{}, error) { 23 func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createDividendsOrderCommand *command.CreateDividendsOrderCommand) (interface{}, error) {
24 if err := createDividendsOrderCommand.ValidateCommand(); err != nil { 24 if err := createDividendsOrderCommand.ValidateCommand(); err != nil {
25 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 25 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -140,6 +140,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -140,6 +140,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
140 orderTimeInt, _ := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64) 140 orderTimeInt, _ := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
141 orderTime := utils.TransformTimestampToTime(orderTimeInt) 141 orderTime := utils.TransformTimestampToTime(orderTimeInt)
142 142
  143 + // 新增分红订单
143 newDividendsOrder := &domain.DividendsOrder{ 144 newDividendsOrder := &domain.DividendsOrder{
144 DividendsOrderId: 0, 145 DividendsOrderId: 0,
145 DividendsOrderNumber: dividendsOrderNumber, 146 DividendsOrderNumber: dividendsOrderNumber,
@@ -35,10 +35,42 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) { @@ -35,10 +35,42 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) {
35 } 35 }
36 } 36 }
37 37
38 -// CheckUndertakerTypesUncheckedAvailable TODO 校验项目承接对象是否可以删除  
39 -func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) {  
40 -  
41 - return []int32{}, nil 38 +// CheckUndertakerTypesUncheckedAvailable 校验项目承接对象是否可以删除
  39 +func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) (bool, error) {
  40 + tx := dao.transactionContext.PgTx
  41 + var cooperationContractModels []*models.CooperationContract
  42 + // 获取和项目关联的合约
  43 + query := tx.Model(&cooperationContractModels)
  44 + if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
  45 + query = query.Where("cooperation_project_number = ?", cooperationProjectNumber)
  46 + }
  47 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  48 + query = query.Where(`cooperation_contract.company @> '{"companyId":"?"}'`, companyId)
  49 + }
  50 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  51 + query = query.Where(`cooperation_contract.org @> '{"orgId":"?"}'`, orgId)
  52 + }
  53 + if user, ok := queryOptions["user"]; ok && user.(bool) != false {
  54 + query = query.Where("user_type = ?", 1)
  55 + }
  56 + if partner, ok := queryOptions["partner"]; ok && partner.(bool) != false {
  57 + query = query.Where("user_type = ?", 2)
  58 + }
  59 + if count, err := query.SelectAndCount(); err != nil {
  60 + return false, err
  61 + } else {
  62 + if count > 0 {
  63 + for _, cooperationContractModel := range cooperationContractModels {
  64 + // 获取合约相关承接人
  65 + var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
  66 + queryUndertaker := tx.Model(&cooperationContractUndertakerModels)
  67 + queryUndertaker.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber)
  68 + ok, err2 := queryUndertaker.Exists()
  69 + return !ok, err2
  70 + }
  71 + }
  72 + }
  73 + return false, nil
42 } 74 }
43 75
44 // CheckProjectNumberAvailable 校验项目编号唯一性 76 // CheckProjectNumberAvailable 校验项目编号唯一性
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type ContractUndertakerFeedback struct { 8 type ContractUndertakerFeedback struct {
9 tableName string `comment:"承接人反馈信息" pg:"contract_undertaker_feedbacks,alias:contract_undertaker_feedback"` 9 tableName string `comment:"承接人反馈信息" pg:"contract_undertaker_feedbacks,alias:contract_undertaker_feedback"`
10 // 合约承接方反馈记录ID 10 // 合约承接方反馈记录ID
11 - FeedbackId int64 `comment:"合约承接方反馈记录ID" pg:",pk:feedback_id"` 11 + FeedbackId int64 `comment:"合约承接方反馈记录ID" pg:",pk"`
12 // 合约承接方反馈内容附件 12 // 合约承接方反馈内容附件
13 FeedbackAttachment []*domain.Attachment `comment:"合约承接方反馈内容附件"` 13 FeedbackAttachment []*domain.Attachment `comment:"合约承接方反馈内容附件"`
14 // 合约承接方反馈内容 14 // 合约承接方反馈内容
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationApplication struct { 8 type CooperationApplication struct {
9 tableName string `comment:"共创申请实体" pg:"cooperation_applications,alias:cooperation_application"` 9 tableName string `comment:"共创申请实体" pg:"cooperation_applications,alias:cooperation_application"`
10 // 共创申请ID 10 // 共创申请ID
11 - CooperationApplicationId int64 `comment:"共创申请ID" pg:",pk:cooperation_application_id"` 11 + CooperationApplicationId int64 `comment:"共创申请ID" pg:",pk"`
12 // 共创申请人 12 // 共创申请人
13 CooperationApplicationApplicant *domain.User `comment:"共创申请人"` 13 CooperationApplicationApplicant *domain.User `comment:"共创申请人"`
14 // 共创申请描述附件 14 // 共创申请描述附件
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationContract struct { 8 type CooperationContract struct {
9 tableName string `comment:"共创项目合约实体" pg:"cooperation_contracts,alias:cooperation_contract"` 9 tableName string `comment:"共创项目合约实体" pg:"cooperation_contracts,alias:cooperation_contract"`
10 // 共创合约ID 10 // 共创合约ID
11 - CooperationContractId int64 `comment:"共创合约ID" pg:",pk:cooperation_contract_id"` 11 + CooperationContractId int64 `comment:"共创合约ID" pg:",pk"`
12 // 共创合约描述 12 // 共创合约描述
13 CooperationContractDescription string `comment:"共创合约描述"` 13 CooperationContractDescription string `comment:"共创合约描述"`
14 // 共创合约名称 14 // 共创合约名称
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationContractChangeLog struct { 8 type CooperationContractChangeLog struct {
9 tableName string `comment:"共创合约变更日志" pg:"cooperation_contract_change_logs,alias:cooperation_contract_change_log"` 9 tableName string `comment:"共创合约变更日志" pg:"cooperation_contract_change_logs,alias:cooperation_contract_change_log"`
10 // 共创合约变更记录id 10 // 共创合约变更记录id
11 - CooperationContractChangeLogId int64 `comment:"共创合约变更记录id" pg:",pk:cooperation_contract_change_log_id"` 11 + CooperationContractChangeLogId int64 `comment:"共创合约变更记录id" pg:",pk"`
12 // 激励规则 12 // 激励规则
13 IncentivesRule string `comment:"激励规则"` 13 IncentivesRule string `comment:"激励规则"`
14 // 激励规则明细 14 // 激励规则明细
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationContractRelevant struct { 8 type CooperationContractRelevant struct {
9 tableName string `comment:"共创合约相关人" pg:"cooperation_contract_relevants,alias:cooperation_contract_relevant"` 9 tableName string `comment:"共创合约相关人" pg:"cooperation_contract_relevants,alias:cooperation_contract_relevant"`
10 // 共创合约相关人id 10 // 共创合约相关人id
11 - CooperationContractRelevantId int64 `comment:"共创合约相关人id" pg:",pk:cooperation_contract_relevant_id"` 11 + CooperationContractRelevantId int64 `comment:"共创合约相关人id" pg:",pk"`
12 // 共创合约编号 12 // 共创合约编号
13 CooperationContractNumber string `comment:"共创合约编号"` 13 CooperationContractNumber string `comment:"共创合约编号"`
14 // 合约人userId 14 // 合约人userId
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationContractUndertaker struct { 8 type CooperationContractUndertaker struct {
9 tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"` 9 tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"`
10 // 共创合约承接人id 10 // 共创合约承接人id
11 - CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk:cooperation_contract_undertaker_id"` 11 + CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk"`
12 // 共创合约编号 12 // 共创合约编号
13 CooperationContractNumber string `comment:"共创合约编号"` 13 CooperationContractNumber string `comment:"共创合约编号"`
14 // 共创合约承接人uid 14 // 共创合约承接人uid
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationMode struct { 8 type CooperationMode struct {
9 tableName string `comment:"共创模式实体" pg:"cooperation_modes,alias:cooperation_mode"` 9 tableName string `comment:"共创模式实体" pg:"cooperation_modes,alias:cooperation_mode"`
10 // 共创模式ID 10 // 共创模式ID
11 - CooperationModeId int64 `comment:"共创模式ID" pg:",pk:cooperation_mode_id"` 11 + CooperationModeId int64 `comment:"共创模式ID" pg:",pk"`
12 // 共创模式编码,唯一确定 12 // 共创模式编码,唯一确定
13 CooperationModeNumber string `comment:"共创模式编码,唯一确定"` 13 CooperationModeNumber string `comment:"共创模式编码,唯一确定"`
14 // 模式名称,唯一确定 14 // 模式名称,唯一确定
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationProject struct { 8 type CooperationProject struct {
9 tableName string `comment:"共创项目实体" pg:"cooperation_projects,alias:cooperation_project"` 9 tableName string `comment:"共创项目实体" pg:"cooperation_projects,alias:cooperation_project"`
10 // 共创项目ID 10 // 共创项目ID
11 - CooperationProjectId int64 `comment:"共创项目ID" pg:",pk:cooperation_project_id"` 11 + CooperationProjectId int64 `comment:"共创项目ID" pg:",pk"`
12 // 共创项目编号 12 // 共创项目编号
13 CooperationProjectNumber string `comment:"共创项目编号"` 13 CooperationProjectNumber string `comment:"共创项目编号"`
14 // 共创项目描述 14 // 共创项目描述
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CreditAccount struct { 8 type CreditAccount struct {
9 tableName string `comment:"账期结算单实体" pg:"credit_accounts,alias:credit_account"` 9 tableName string `comment:"账期结算单实体" pg:"credit_accounts,alias:credit_account"`
10 // 账期结算单ID 10 // 账期结算单ID
11 - CreditAccountId int64 `comment:"账期结算单ID" pg:",pk:credit_account_id"` 11 + CreditAccountId int64 `comment:"账期结算单ID" pg:",pk"`
12 // 账期结算实付金额 12 // 账期结算实付金额
13 ActuallyPaidAmount float64 `comment:"账期结算实付金额"` 13 ActuallyPaidAmount float64 `comment:"账期结算实付金额"`
14 // 账期结算单号 14 // 账期结算单号
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type DividendsEstimate struct { 8 type DividendsEstimate struct {
9 tableName string `comment:"分红预算实体" pg:"dividends_estimates,alias:dividends_estimate"` 9 tableName string `comment:"分红预算实体" pg:"dividends_estimates,alias:dividends_estimate"`
10 // 承接人分红预算记录ID 10 // 承接人分红预算记录ID
11 - DividendsEstimateId int64 `comment:"承接人分红预算记录ID" pg:",pk:dividends_estimate_id"` 11 + DividendsEstimateId int64 `comment:"承接人分红预算记录ID" pg:",pk"`
12 // 分红结算状态 12 // 分红结算状态
13 DividendsAccountStatus int32 `comment:"分红结算状态"` 13 DividendsAccountStatus int32 `comment:"分红结算状态"`
14 // 分红金额 14 // 分红金额
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type DividendsIncentivesRule struct { 8 type DividendsIncentivesRule struct {
9 tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"` 9 tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"`
10 // 分红规则ID 10 // 分红规则ID
11 - DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk:dividends_incentives_rule_id"` 11 + DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk"`
12 // 关联的项目合约编号 12 // 关联的项目合约编号
13 CooperationContractNumber string `comment:"关联的项目合约编号"` 13 CooperationContractNumber string `comment:"关联的项目合约编号"`
14 // 推荐人抽成比例 14 // 推荐人抽成比例
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type DividendsOrder struct { 8 type DividendsOrder struct {
9 tableName string `comment:"分红订单实体" pg:"dividends_orders,alias:dividends_order"` 9 tableName string `comment:"分红订单实体" pg:"dividends_orders,alias:dividends_order"`
10 // 分红订单ID 10 // 分红订单ID
11 - DividendsOrderId int64 `comment:"分红订单ID" pg:",pk:dividends_order_id"` 11 + DividendsOrderId int64 `comment:"分红订单ID" pg:",pk"`
12 // 分红订单号 12 // 分红订单号
13 DividendsOrderNumber string `comment:"分红订单号"` 13 DividendsOrderNumber string `comment:"分红订单号"`
14 // 分红订单原单号 14 // 分红订单原单号
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type DividendsReturnedOrder struct { 8 type DividendsReturnedOrder struct {
9 tableName string `comment:"分红退货单实体" pg:"dividends_returned_orders,alias:dividends_returned_order"` 9 tableName string `comment:"分红退货单实体" pg:"dividends_returned_orders,alias:dividends_returned_order"`
10 // 分红退货单记录ID 10 // 分红退货单记录ID
11 - DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:",pk:dividends_returned_order_id"` 11 + DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:",pk"`
12 // 分红退货单号 12 // 分红退货单号
13 DividendsReturnedOrderNumber string `comment:"分红退货单号"` 13 DividendsReturnedOrderNumber string `comment:"分红退货单号"`
14 // 退货金额 14 // 退货金额
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type MoneyIncentivesRule struct { 8 type MoneyIncentivesRule struct {
9 tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"` 9 tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"`
10 // 金额激励规则ID 10 // 金额激励规则ID
11 - MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk:money_incentives_rule_id"` 11 + MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk"`
12 // 关联的共创合约编号 12 // 关联的共创合约编号
13 CooperationContractNumber string `comment:"关联的共创合约编号"` 13 CooperationContractNumber string `comment:"关联的共创合约编号"`
14 // 激励金额 14 // 激励金额
@@ -5,7 +5,7 @@ import "time" @@ -5,7 +5,7 @@ import "time"
5 type OrderGood struct { 5 type OrderGood struct {
6 tableName string `comment:"订单产品领域实体(包括分红订单、分红退货单)" pg:"order_goods,alias:order_good"` 6 tableName string `comment:"订单产品领域实体(包括分红订单、分红退货单)" pg:"order_goods,alias:order_good"`
7 // 订单产品 7 // 订单产品
8 - OrderGoodId int64 `comment:"订单产品" pg:",pk:order_good_id"` 8 + OrderGoodId int64 `comment:"订单产品" pg:",pk"`
9 // 订单产品金额 9 // 订单产品金额
10 OrderGoodAmount float64 `comment:"订单产品金额"` 10 OrderGoodAmount float64 `comment:"订单产品金额"`
11 // 订单产品名称 11 // 订单产品名称
@@ -13,24 +13,10 @@ func TransformToContractUndertakerFeedbackDomainModelFromPgModels( @@ -13,24 +13,10 @@ func TransformToContractUndertakerFeedbackDomainModelFromPgModels(
13 FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent, 13 FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent,
14 CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber, 14 CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber,
15 ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker, 15 ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker,
16 - //CooperationMode: &domain.CooperationMode{  
17 - // CooperationModeId: cooperationMode.CooperationModeId,  
18 - // CooperationModeNumber: cooperationMode.CooperationModeNumber,  
19 - // CooperationModeName: cooperationMode.CooperationModeName,  
20 - // Status: cooperationMode.Status,  
21 - // Org: cooperationMode.Org,  
22 - // Company: cooperationMode.Company,  
23 - // Remarks: cooperationMode.Remarks,  
24 - // Operator: cooperationMode.Operator,  
25 - // OperateTime: cooperationMode.OperateTime,  
26 - // UpdatedAt: cooperationMode.UpdatedAt,  
27 - // DeletedAt: cooperationMode.DeletedAt,  
28 - // CreatedAt: cooperationMode.CreatedAt,  
29 - //},  
30 - Org: contractUndertakerFeedbackModel.Org,  
31 - Company: contractUndertakerFeedbackModel.Company,  
32 - UpdatedAt: contractUndertakerFeedbackModel.UpdatedAt,  
33 - DeletedAt: contractUndertakerFeedbackModel.DeletedAt,  
34 - CreatedAt: contractUndertakerFeedbackModel.CreatedAt, 16 + Org: contractUndertakerFeedbackModel.Org,
  17 + Company: contractUndertakerFeedbackModel.Company,
  18 + UpdatedAt: contractUndertakerFeedbackModel.UpdatedAt,
  19 + DeletedAt: contractUndertakerFeedbackModel.DeletedAt,
  20 + CreatedAt: contractUndertakerFeedbackModel.CreatedAt,
35 }, nil 21 }, nil
36 } 22 }