作者 陈志颖

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

... ... @@ -238,14 +238,39 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
} else {
cooperationProjectDao = value
}
// 获取可删除的承接对象类型
undertakerTypesUncheckedAvailable, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"cooperationProjectUndertakerTypes": cooperationProject.CooperationProjectUndertakerTypes,
// 可以去除勾选的承接人对象列表
var undertakerTypesUncheckedAvailable []int32
// 判断承接对象是否存在员工
gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"user": true,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if !gotUser {
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 1)
}
// 判断承接对象是否存在共创用户
gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"partner": true,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if !gotPartner {
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 2)
}
// 判断承接人是否存在公开用户
if !gotUser && !gotPartner {
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
}
cooperationProjectDto := &dto.CooperationProjectsDto{}
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -19,7 +19,7 @@ import (
type DividendsOrderService struct {
}
// CreateDividendsOrder 创建分红订单实体对象
// CreateDividendsOrder 新增分红订单实体对象
func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createDividendsOrderCommand *command.CreateDividendsOrderCommand) (interface{}, error) {
if err := createDividendsOrderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -140,6 +140,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
orderTimeInt, _ := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
orderTime := utils.TransformTimestampToTime(orderTimeInt)
// 新增分红订单
newDividendsOrder := &domain.DividendsOrder{
DividendsOrderId: 0,
DividendsOrderNumber: dividendsOrderNumber,
... ...
... ... @@ -35,10 +35,42 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) {
}
}
// CheckUndertakerTypesUncheckedAvailable TODO 校验项目承接对象是否可以删除
func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) {
return []int32{}, nil
// CheckUndertakerTypesUncheckedAvailable 校验项目承接对象是否可以删除
func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) (bool, error) {
tx := dao.transactionContext.PgTx
var cooperationContractModels []*models.CooperationContract
// 获取和项目关联的合约
query := tx.Model(&cooperationContractModels)
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
query = query.Where("cooperation_project_number = ?", cooperationProjectNumber)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`cooperation_contract.company @> '{"companyId":"?"}'`, companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query = query.Where(`cooperation_contract.org @> '{"orgId":"?"}'`, orgId)
}
if user, ok := queryOptions["user"]; ok && user.(bool) != false {
query = query.Where("user_type = ?", 1)
}
if partner, ok := queryOptions["partner"]; ok && partner.(bool) != false {
query = query.Where("user_type = ?", 2)
}
if count, err := query.SelectAndCount(); err != nil {
return false, err
} else {
if count > 0 {
for _, cooperationContractModel := range cooperationContractModels {
// 获取合约相关承接人
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
queryUndertaker := tx.Model(&cooperationContractUndertakerModels)
queryUndertaker.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber)
ok, err2 := queryUndertaker.Exists()
return !ok, err2
}
}
}
return false, nil
}
// CheckProjectNumberAvailable 校验项目编号唯一性
... ...
... ... @@ -8,7 +8,7 @@ import (
type ContractUndertakerFeedback struct {
tableName string `comment:"承接人反馈信息" pg:"contract_undertaker_feedbacks,alias:contract_undertaker_feedback"`
// 合约承接方反馈记录ID
FeedbackId int64 `comment:"合约承接方反馈记录ID" pg:",pk:feedback_id"`
FeedbackId int64 `comment:"合约承接方反馈记录ID" pg:",pk"`
// 合约承接方反馈内容附件
FeedbackAttachment []*domain.Attachment `comment:"合约承接方反馈内容附件"`
// 合约承接方反馈内容
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationApplication struct {
tableName string `comment:"共创申请实体" pg:"cooperation_applications,alias:cooperation_application"`
// 共创申请ID
CooperationApplicationId int64 `comment:"共创申请ID" pg:",pk:cooperation_application_id"`
CooperationApplicationId int64 `comment:"共创申请ID" pg:",pk"`
// 共创申请人
CooperationApplicationApplicant *domain.User `comment:"共创申请人"`
// 共创申请描述附件
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationContract struct {
tableName string `comment:"共创项目合约实体" pg:"cooperation_contracts,alias:cooperation_contract"`
// 共创合约ID
CooperationContractId int64 `comment:"共创合约ID" pg:",pk:cooperation_contract_id"`
CooperationContractId int64 `comment:"共创合约ID" pg:",pk"`
// 共创合约描述
CooperationContractDescription string `comment:"共创合约描述"`
// 共创合约名称
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationContractChangeLog struct {
tableName string `comment:"共创合约变更日志" pg:"cooperation_contract_change_logs,alias:cooperation_contract_change_log"`
// 共创合约变更记录id
CooperationContractChangeLogId int64 `comment:"共创合约变更记录id" pg:",pk:cooperation_contract_change_log_id"`
CooperationContractChangeLogId int64 `comment:"共创合约变更记录id" pg:",pk"`
// 激励规则
IncentivesRule string `comment:"激励规则"`
// 激励规则明细
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationContractRelevant struct {
tableName string `comment:"共创合约相关人" pg:"cooperation_contract_relevants,alias:cooperation_contract_relevant"`
// 共创合约相关人id
CooperationContractRelevantId int64 `comment:"共创合约相关人id" pg:",pk:cooperation_contract_relevant_id"`
CooperationContractRelevantId int64 `comment:"共创合约相关人id" pg:",pk"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 合约人userId
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationContractUndertaker struct {
tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"`
// 共创合约承接人id
CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk:cooperation_contract_undertaker_id"`
CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 共创合约承接人uid
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationMode struct {
tableName string `comment:"共创模式实体" pg:"cooperation_modes,alias:cooperation_mode"`
// 共创模式ID
CooperationModeId int64 `comment:"共创模式ID" pg:",pk:cooperation_mode_id"`
CooperationModeId int64 `comment:"共创模式ID" pg:",pk"`
// 共创模式编码,唯一确定
CooperationModeNumber string `comment:"共创模式编码,唯一确定"`
// 模式名称,唯一确定
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationProject struct {
tableName string `comment:"共创项目实体" pg:"cooperation_projects,alias:cooperation_project"`
// 共创项目ID
CooperationProjectId int64 `comment:"共创项目ID" pg:",pk:cooperation_project_id"`
CooperationProjectId int64 `comment:"共创项目ID" pg:",pk"`
// 共创项目编号
CooperationProjectNumber string `comment:"共创项目编号"`
// 共创项目描述
... ...
... ... @@ -8,7 +8,7 @@ import (
type CreditAccount struct {
tableName string `comment:"账期结算单实体" pg:"credit_accounts,alias:credit_account"`
// 账期结算单ID
CreditAccountId int64 `comment:"账期结算单ID" pg:",pk:credit_account_id"`
CreditAccountId int64 `comment:"账期结算单ID" pg:",pk"`
// 账期结算实付金额
ActuallyPaidAmount float64 `comment:"账期结算实付金额"`
// 账期结算单号
... ...
... ... @@ -8,7 +8,7 @@ import (
type DividendsEstimate struct {
tableName string `comment:"分红预算实体" pg:"dividends_estimates,alias:dividends_estimate"`
// 承接人分红预算记录ID
DividendsEstimateId int64 `comment:"承接人分红预算记录ID" pg:",pk:dividends_estimate_id"`
DividendsEstimateId int64 `comment:"承接人分红预算记录ID" pg:",pk"`
// 分红结算状态
DividendsAccountStatus int32 `comment:"分红结算状态"`
// 分红金额
... ...
... ... @@ -8,7 +8,7 @@ import (
type DividendsIncentivesRule struct {
tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"`
// 分红规则ID
DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk:dividends_incentives_rule_id"`
DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk"`
// 关联的项目合约编号
CooperationContractNumber string `comment:"关联的项目合约编号"`
// 推荐人抽成比例
... ...
... ... @@ -8,7 +8,7 @@ import (
type DividendsOrder struct {
tableName string `comment:"分红订单实体" pg:"dividends_orders,alias:dividends_order"`
// 分红订单ID
DividendsOrderId int64 `comment:"分红订单ID" pg:",pk:dividends_order_id"`
DividendsOrderId int64 `comment:"分红订单ID" pg:",pk"`
// 分红订单号
DividendsOrderNumber string `comment:"分红订单号"`
// 分红订单原单号
... ...
... ... @@ -8,7 +8,7 @@ import (
type DividendsReturnedOrder struct {
tableName string `comment:"分红退货单实体" pg:"dividends_returned_orders,alias:dividends_returned_order"`
// 分红退货单记录ID
DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:",pk:dividends_returned_order_id"`
DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:",pk"`
// 分红退货单号
DividendsReturnedOrderNumber string `comment:"分红退货单号"`
// 退货金额
... ...
... ... @@ -8,7 +8,7 @@ import (
type MoneyIncentivesRule struct {
tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"`
// 金额激励规则ID
MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk:money_incentives_rule_id"`
MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk"`
// 关联的共创合约编号
CooperationContractNumber string `comment:"关联的共创合约编号"`
// 激励金额
... ...
... ... @@ -5,7 +5,7 @@ import "time"
type OrderGood struct {
tableName string `comment:"订单产品领域实体(包括分红订单、分红退货单)" pg:"order_goods,alias:order_good"`
// 订单产品
OrderGoodId int64 `comment:"订单产品" pg:",pk:order_good_id"`
OrderGoodId int64 `comment:"订单产品" pg:",pk"`
// 订单产品金额
OrderGoodAmount float64 `comment:"订单产品金额"`
// 订单产品名称
... ...
... ... @@ -13,24 +13,10 @@ func TransformToContractUndertakerFeedbackDomainModelFromPgModels(
FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent,
CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber,
ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker,
//CooperationMode: &domain.CooperationMode{
// CooperationModeId: cooperationMode.CooperationModeId,
// CooperationModeNumber: cooperationMode.CooperationModeNumber,
// CooperationModeName: cooperationMode.CooperationModeName,
// Status: cooperationMode.Status,
// Org: cooperationMode.Org,
// Company: cooperationMode.Company,
// Remarks: cooperationMode.Remarks,
// Operator: cooperationMode.Operator,
// OperateTime: cooperationMode.OperateTime,
// UpdatedAt: cooperationMode.UpdatedAt,
// DeletedAt: cooperationMode.DeletedAt,
// CreatedAt: cooperationMode.CreatedAt,
//},
Org: contractUndertakerFeedbackModel.Org,
Company: contractUndertakerFeedbackModel.Company,
UpdatedAt: contractUndertakerFeedbackModel.UpdatedAt,
DeletedAt: contractUndertakerFeedbackModel.DeletedAt,
CreatedAt: contractUndertakerFeedbackModel.CreatedAt,
Org: contractUndertakerFeedbackModel.Org,
Company: contractUndertakerFeedbackModel.Company,
UpdatedAt: contractUndertakerFeedbackModel.UpdatedAt,
DeletedAt: contractUndertakerFeedbackModel.DeletedAt,
CreatedAt: contractUndertakerFeedbackModel.CreatedAt,
}, nil
}
... ...