作者 陈志颖

feat:应用服务集成REST服务

... ... @@ -8,13 +8,15 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"time"
)
// 共创合约反馈服务
// ContractUndertakerFeedbackService 共创合约反馈服务
type ContractUndertakerFeedbackService struct {
}
// 创建共创合约反馈服务
// CreateContractUndertakerFeedback 创建共创合约反馈服务
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) CreateContractUndertakerFeedback(createContractUndertakerFeedbackCommand *command.CreateContractUndertakerFeedbackCommand) (interface{}, error) {
if err := createContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -27,17 +29,69 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Crea
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取承接人
var undertaker *domain.Undertaker
if data, err := userService.UndertakerFrom(createContractUndertakerFeedbackCommand.CompanyId, createContractUndertakerFeedbackCommand.OrgId, createContractUndertakerFeedbackCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
undertaker = data
}
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createContractUndertakerFeedbackCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(createContractUndertakerFeedbackCommand.CompanyId, createContractUndertakerFeedbackCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organization = data
}
newContractUndertakerFeedback := &domain.ContractUndertakerFeedback{
FeedbackAttachment: createContractUndertakerFeedbackCommand.FeedbackAttachment,
FeedbackContent: createContractUndertakerFeedbackCommand.FeedbackContent,
CooperationContractNumber: createContractUndertakerFeedbackCommand.CooperationContractNumber,
//UnderTakerUid: createContractUndertakerFeedbackCommand.UnderTakerUid,
//CompanyId: createContractUndertakerFeedbackCommand.CompanyId,
//OrgId: createContractUndertakerFeedbackCommand.OrgId,
//UserId: createContractUndertakerFeedbackCommand.UserId,
ContractUndertaker: undertaker,
Company: company,
Org: organization,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
}
var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -56,7 +110,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Crea
}
}
// 返回共创合约反馈服务
// GetContractUndertakerFeedback 返回共创合约反馈服务
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery *query.GetContractUndertakerFeedbackQuery) (interface{}, error) {
if err := getContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -69,7 +123,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetC
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
... ... @@ -93,7 +147,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetC
}
}
// 返回共创合约反馈服务列表
// ListContractUndertakerFeedback 返回共创合约反馈服务列表
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) ListContractUndertakerFeedback(listContractUndertakerFeedbackQuery *query.ListContractUndertakerFeedbackQuery) (interface{}, error) {
if err := listContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -106,7 +160,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) List
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
... ... @@ -129,7 +183,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) List
}
}
// 移除共创合约反馈服务
// RemoveContractUndertakerFeedback 移除共创合约反馈服务
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand *command.RemoveContractUndertakerFeedbackCommand) (interface{}, error) {
if err := removeContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -142,7 +196,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Remo
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
... ... @@ -169,7 +223,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Remo
}
}
// 查询共创承接方反馈信息
// SearchContractUndertakerFeedback 查询共创承接方反馈信息
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) SearchContractUndertakerFeedback(searchContractUndertakerFeedbackQuery *query.SearchContractUndertakerFeedbackQuery) (interface{}, error) {
if err := searchContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -182,7 +236,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Sear
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -190,7 +244,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Sear
return nil, nil
}
// 更新共创合约反馈服务
// UpdateContractUndertakerFeedback 更新共创合约反馈服务
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand *command.UpdateContractUndertakerFeedbackCommand) (interface{}, error) {
if err := updateContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -203,7 +257,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Upda
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"strconv"
)
// CooperationApplicationService 共创申请服务
... ... @@ -27,7 +28,7 @@ func (cooperationApplicationService *CooperationApplicationService) AgreeCoopera
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -48,7 +49,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -69,7 +70,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -90,7 +91,7 @@ func (cooperationApplicationService *CooperationApplicationService) CreateCooper
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
newCooperationApplication := &domain.CooperationApplication{
//ApplicantUid: createCooperationApplicationCommand.ApplicantUid,
... ... @@ -132,7 +133,7 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
... ... @@ -147,7 +148,7 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationApplicationQuery.CooperationApplicationId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationApplicationQuery.CooperationApplicationId, 10)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -169,7 +170,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
... ... @@ -205,7 +206,7 @@ func (cooperationApplicationService *CooperationApplicationService) RejectCooper
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -226,7 +227,7 @@ func (cooperationApplicationService *CooperationApplicationService) RemoveCooper
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
... ... @@ -241,7 +242,7 @@ func (cooperationApplicationService *CooperationApplicationService) RemoveCooper
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationApplicationCommand.CooperationApplicationId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationApplicationCommand.CooperationApplicationId, 10)))
}
if cooperationApplication, err := cooperationApplicationRepository.Remove(cooperationApplication); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -266,7 +267,7 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -287,7 +288,7 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
... ...
... ... @@ -27,7 +27,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
//userServiceGateway, err := factory.CreateUserServiceGateway(nil)
... ...
... ... @@ -8,13 +8,16 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"strconv"
"time"
)
// 共创合约变更日志
// CooperationContractChangeLogService 共创合约变更日志
type CooperationContractChangeLogService struct {
}
// 创建共创合约变更日志
// CreateCooperationContractChangeLog 创建共创合约变更日志
func (cooperationContractChangeLogService *CooperationContractChangeLogService) CreateCooperationContractChangeLog(createCooperationContractChangeLogCommand *command.CreateCooperationContractChangeLogCommand) (interface{}, error) {
if err := createCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -27,17 +30,52 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createCooperationContractChangeLogCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取操作者
var operator *domain.User
if data, err := userService.OperatorFrom(createCooperationContractChangeLogCommand.CompanyId, createCooperationContractChangeLogCommand.OrgId, createCooperationContractChangeLogCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
IncentivesRule: createCooperationContractChangeLogCommand.IncentivesRule,
IncentivesRuleDetail: createCooperationContractChangeLogCommand.IncentivesRuleDetail,
OperationType: createCooperationContractChangeLogCommand.OperationType,
Undertakers: createCooperationContractChangeLogCommand.Undertakers,
CooperationContractNumber: createCooperationContractChangeLogCommand.CooperationContractNumber,
//CompanyId: createCooperationContractChangeLogCommand.CompanyId,
//OrgId: createCooperationContractChangeLogCommand.OrgId,
//UserId: createCooperationContractChangeLogCommand.UserId,
Company: company,
Operator: operator,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
}
var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
... ... @@ -57,7 +95,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
}
}
// 返回共创合约变更日志
// GetCooperationContractChangeLog 返回共创合约变更日志
func (cooperationContractChangeLogService *CooperationContractChangeLogService) GetCooperationContractChangeLog(getCooperationContractChangeLogQuery *query.GetCooperationContractChangeLogQuery) (interface{}, error) {
if err := getCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -70,7 +108,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
... ... @@ -85,7 +123,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationContractChangeLog == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationContractChangeLogQuery.CooperationContractChangeLogId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractChangeLogQuery.CooperationContractChangeLogId, 10)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -94,7 +132,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
}
}
// 返回共创合约变更日志列表
// ListCooperationContractChangeLog 返回共创合约变更日志列表
func (cooperationContractChangeLogService *CooperationContractChangeLogService) ListCooperationContractChangeLog(listCooperationContractChangeLogQuery *query.ListCooperationContractChangeLogQuery) (interface{}, error) {
if err := listCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -107,7 +145,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
... ... @@ -130,7 +168,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
}
}
// 移除共创合约变更日志
// RemoveCooperationContractChangeLog 移除共创合约变更日志
func (cooperationContractChangeLogService *CooperationContractChangeLogService) RemoveCooperationContractChangeLog(removeCooperationContractChangeLogCommand *command.RemoveCooperationContractChangeLogCommand) (interface{}, error) {
if err := removeCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -143,7 +181,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
... ... @@ -158,7 +196,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationContractChangeLog == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationContractChangeLogCommand.CooperationContractChangeLogId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationContractChangeLogCommand.CooperationContractChangeLogId, 10)))
}
if cooperationContractChangeLog, err := cooperationContractChangeLogRepository.Remove(cooperationContractChangeLog); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -170,7 +208,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
}
}
// 共创合约变更记录搜索
// SearchCooperationContractChangeLog 共创合约变更记录搜索
func (cooperationContractChangeLogService *CooperationContractChangeLogService) SearchCooperationContractChangeLog(searchCooperationContractChangeLogQuery *query.SearchCooperationContractChangeLogQuery) (interface{}, error) {
if err := searchCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -183,7 +221,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -191,7 +229,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, nil
}
// 更新共创合约变更日志
// UpdateCooperationContractChangeLog 更新共创合约变更日志
func (cooperationContractChangeLogService *CooperationContractChangeLogService) UpdateCooperationContractChangeLog(updateCooperationContractChangeLogCommand *command.UpdateCooperationContractChangeLogCommand) (interface{}, error) {
if err := updateCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -204,7 +242,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
... ...
... ... @@ -8,13 +8,16 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationMode/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"strconv"
"time"
)
// 共创模式服务
// CooperationModeService 共创模式服务
type CooperationModeService struct {
}
// 创建共创模式服务
// CreateCooperationMode 创建共创模式服务
func (cooperationModeService *CooperationModeService) CreateCooperationMode(createCooperationModeCommand *command.CreateCooperationModeCommand) (interface{}, error) {
if err := createCooperationModeCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -27,15 +30,68 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取承接人
var operator *domain.User
if data, err := userService.OperatorFrom(createCooperationModeCommand.CompanyId, createCooperationModeCommand.OrgId, createCooperationModeCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createCooperationModeCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(createCooperationModeCommand.CompanyId, createCooperationModeCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organization = data
}
newCooperationMode := &domain.CooperationMode{
CooperationModeName: createCooperationModeCommand.CooperationModeName,
CooperationModeNumber: createCooperationModeCommand.CooperationModeNumber,
Remarks: createCooperationModeCommand.Remarks,
//CompanyId: createCooperationModeCommand.CompanyId,
//OrgId: createCooperationModeCommand.OrgId,
//UserId: createCooperationModeCommand.UserId,
Company: company,
Org: organization,
Operator: operator,
OperateTime: time.Now(),
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
}
var cooperationModeRepository domain.CooperationModeRepository
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
... ... @@ -55,7 +111,7 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea
}
}
// 返回共创模式服务
// GetCooperationMode 返回共创模式服务
func (cooperationModeService *CooperationModeService) GetCooperationMode(getCooperationModeQuery *query.GetCooperationModeQuery) (interface{}, error) {
if err := getCooperationModeQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -68,7 +124,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationModeRepository domain.CooperationModeRepository
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
... ... @@ -83,7 +139,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationModeQuery.CooperationModeId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationModeQuery.CooperationModeId, 10)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -92,7 +148,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop
}
}
// 返回共创模式服务列表
// ListCooperationMode 返回共创模式服务列表
func (cooperationModeService *CooperationModeService) ListCooperationMode(listCooperationModeQuery *query.ListCooperationModeQuery) (interface{}, error) {
if err := listCooperationModeQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -105,7 +161,7 @@ func (cooperationModeService *CooperationModeService) ListCooperationMode(listCo
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationModeRepository domain.CooperationModeRepository
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
... ... @@ -128,7 +184,7 @@ func (cooperationModeService *CooperationModeService) ListCooperationMode(listCo
}
}
// 移除共创模式服务
// RemoveCooperationMode 移除共创模式服务
func (cooperationModeService *CooperationModeService) RemoveCooperationMode(removeCooperationModeCommand *command.RemoveCooperationModeCommand) (interface{}, error) {
if err := removeCooperationModeCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -141,7 +197,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationModeRepository domain.CooperationModeRepository
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
... ... @@ -156,7 +212,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationModeCommand.CooperationModeId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationModeCommand.CooperationModeId, 10)))
}
if cooperationMode, err := cooperationModeRepository.Remove(cooperationMode); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -168,7 +224,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo
}
}
// 查询共创模式
// SearchCooperationMode 查询共创模式
func (cooperationModeService *CooperationModeService) SearchCooperationMode(searchCooperationModeQuery *query.SearchCooperationModeQuery) (interface{}, error) {
if err := searchCooperationModeQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -181,7 +237,7 @@ func (cooperationModeService *CooperationModeService) SearchCooperationMode(sear
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -189,7 +245,7 @@ func (cooperationModeService *CooperationModeService) SearchCooperationMode(sear
return nil, nil
}
// 更新共创模式服务
// UpdateCooperationMode 更新共创模式服务
func (cooperationModeService *CooperationModeService) UpdateCooperationMode(updateCooperationModeCommand *command.UpdateCooperationModeCommand) (interface{}, error) {
if err := updateCooperationModeCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -202,7 +258,7 @@ func (cooperationModeService *CooperationModeService) UpdateCooperationMode(upda
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationModeRepository domain.CooperationModeRepository
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
... ...
... ... @@ -8,6 +8,9 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"strconv"
"time"
)
// CooperationProjectService 共创项目服务
... ... @@ -27,7 +30,7 @@ func (cooperationProjectService *CooperationProjectService) CheckUndertaker(chec
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -48,17 +51,88 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取操作人
var operator *domain.User
if data, err := userService.OperatorFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
// Sponsor
var sponsor *domain.User
if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
sponsor = data
}
// Publisher
var publisher *domain.User
if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
publisher = data
}
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createCooperationProjectCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organization = data
}
newCooperationProject := &domain.CooperationProject{
CooperationProjectNumber: "",
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType,
//SponsorUid: createCooperationProjectCommand.SponsorUid,
//PublisherUid: createCooperationProjectCommand.PublisherUid,
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
//CompanyId: createCooperationProjectCommand.CompanyId,
//OrgId: createCooperationProjectCommand.OrgId,
//UserId: createCooperationProjectCommand.UserId,
CooperationProjectSponsor: sponsor,
CooperationProjectPublisher: publisher,
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
Company: company,
Org: organization,
Operator: operator,
OperateTime: time.Now(),
Status: 0,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
}
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
... ... @@ -91,7 +165,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
... ... @@ -106,7 +180,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationProjectQuery.CooperationProjectId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationProjectQuery.CooperationProjectId, 10)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -128,7 +202,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
... ... @@ -164,7 +238,7 @@ func (cooperationProjectService *CooperationProjectService) ReleaseCooperationPr
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -185,7 +259,7 @@ func (cooperationProjectService *CooperationProjectService) RemoveCooperationPro
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
... ... @@ -200,7 +274,7 @@ func (cooperationProjectService *CooperationProjectService) RemoveCooperationPro
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationProjectCommand.CooperationProjectId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationProjectCommand.CooperationProjectId, 10)))
}
if cooperationProject, err := cooperationProjectRepository.Remove(cooperationProject); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -225,7 +299,7 @@ func (cooperationProjectService *CooperationProjectService) SearchCooperationPro
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -246,7 +320,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
... ...
... ... @@ -8,13 +8,16 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"strconv"
"time"
)
// 账期结算单服务
// CreditAccountService 账期结算单服务
type CreditAccountService struct {
}
// 创建账期结算单服务
// CreateCreditAccount 创建账期结算单服务
func (creditAccountService *CreditAccountService) CreateCreditAccount(createCreditAccountCommand *command.CreateCreditAccountCommand) (interface{}, error) {
if err := createCreditAccountCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -27,13 +30,76 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createCreditAccountCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(createCreditAccountCommand.CompanyId, createCreditAccountCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organization = data
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取操作人
var operator *domain.User
if data, err := userService.OperatorFrom(createCreditAccountCommand.CompanyId, createCreditAccountCommand.OrgId, createCreditAccountCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
newCreditAccount := &domain.CreditAccount{
//CompanyId: createCreditAccountCommand.CompanyId,
//OrgId: createCreditAccountCommand.OrgId,
//UserId: createCreditAccountCommand.UserId,
ActuallyPaidAmount: 0,
CreditAccountOrderNum: "",
PaymentStatus: 0,
PaymentTime: time.Time{},
SettlementAmount: 0,
SettlementTime: time.Time{},
CooperationContractNumber: "",
Participator: nil,
PaymentDocumentAttachment: nil,
Org: organization,
Company: company,
Operator: operator,
OperateTime: time.Now(),
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
}
var creditAccountRepository domain.CreditAccountRepository
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -52,7 +118,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
}
}
// 账期结算单排名
// CreditAccountRanking 账期结算单排名
func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAccountRankingQuery *query.CreditAccountRankingQuery) (interface{}, error) {
if err := creditAccountRankingQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -65,7 +131,7 @@ func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAcc
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -73,7 +139,7 @@ func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAcc
return nil, nil
}
// 返回账期结算单服务
// GetCreditAccount 返回账期结算单服务
func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAccountQuery *query.GetCreditAccountQuery) (interface{}, error) {
if err := getCreditAccountQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -86,7 +152,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var creditAccountRepository domain.CreditAccountRepository
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
... ... @@ -101,7 +167,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if creditAccount == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCreditAccountQuery.CreditAccountId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCreditAccountQuery.CreditAccountId, 10)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -110,7 +176,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco
}
}
// 返回账期结算单服务列表
// ListCreditAccount 返回账期结算单服务列表
func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAccountQuery *query.ListCreditAccountQuery) (interface{}, error) {
if err := listCreditAccountQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -123,7 +189,7 @@ func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAc
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var creditAccountRepository domain.CreditAccountRepository
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
... ... @@ -146,7 +212,7 @@ func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAc
}
}
// 支付账期结算(支付分红)
// PayCreditAccount 支付账期结算(支付分红)
func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAccountCommand *command.PayCreditAccountCommand) (interface{}, error) {
if err := payCreditAccountCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -159,7 +225,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -167,7 +233,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
return nil, nil
}
// 移除账期结算单服务
// RemoveCreditAccount 移除账期结算单服务
func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCreditAccountCommand *command.RemoveCreditAccountCommand) (interface{}, error) {
if err := removeCreditAccountCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -180,7 +246,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var creditAccountRepository domain.CreditAccountRepository
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
... ... @@ -195,7 +261,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if creditAccount == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCreditAccountCommand.CreditAccountId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCreditAccountCommand.CreditAccountId, 10)))
}
if creditAccount, err := creditAccountRepository.Remove(creditAccount); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -207,7 +273,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred
}
}
// 查询账期结算单
// SearchCreditAccount 查询账期结算单
func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCreditAccountQuery *query.SearchCreditAccountQuery) (interface{}, error) {
if err := searchCreditAccountQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -220,7 +286,7 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -228,7 +294,7 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred
return nil, nil
}
// 更新账期结算单服务
// UpdateCreditAccount 更新账期结算单服务
func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCreditAccountCommand *command.UpdateCreditAccountCommand) (interface{}, error) {
if err := updateCreditAccountCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -241,7 +307,7 @@ func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCred
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var creditAccountRepository domain.CreditAccountRepository
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
... ... @@ -256,7 +322,7 @@ func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCred
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if creditAccount == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCreditAccountCommand.CreditAccountId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateCreditAccountCommand.CreditAccountId, 10)))
}
if err := creditAccount.Update(tool_funs.SimpleStructToMap(updateCreditAccountCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -8,6 +8,9 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"strconv"
"time"
)
// DividendsEstimateService 分红预算服务
... ... @@ -27,7 +30,7 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -48,13 +51,77 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createDividendsEstimateCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(createDividendsEstimateCommand.CompanyId, createDividendsEstimateCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organization = data
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取操作人
var operator *domain.User
if data, err := userService.OperatorFrom(createDividendsEstimateCommand.CompanyId, createDividendsEstimateCommand.OrgId, createDividendsEstimateCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
newDividendsEstimate := &domain.DividendsEstimate{
//CompanyId: createDividendsEstimateCommand.CompanyId,
//OrgId: createDividendsEstimateCommand.OrgId,
//UserId: createDividendsEstimateCommand.UserId,
DividendsEstimateId: 0,
DividendsAccountStatus: 0,
DividendsAmount: 0,
DividendsEstimateOrderNumber: "",
DividendsEstimateTime: time.Time{},
DividendsParticipateType: 0,
DividendsType: 0,
OrderOrReturnedOrderNum: "",
CooperationProjectNumber: "",
DividendsUser: nil,
Org: organization,
Company: company,
Operator: operator,
OperateTime: time.Time{},
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
}
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -86,7 +153,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -107,7 +174,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentive
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -128,7 +195,7 @@ func (dividendsEstimateService *DividendsEstimateService) GetDividendsEstimate(g
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
... ... @@ -165,7 +232,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsEstimate(
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
... ... @@ -201,7 +268,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -222,7 +289,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentives(li
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -243,7 +310,7 @@ func (dividendsEstimateService *DividendsEstimateService) RemoveDividendsEstimat
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
... ... @@ -258,7 +325,7 @@ func (dividendsEstimateService *DividendsEstimateService) RemoveDividendsEstimat
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsEstimate == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeDividendsEstimateCommand.DividendsEstimateId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeDividendsEstimateCommand.DividendsEstimateId, 10)))
}
if dividendsEstimate, err := dividendsEstimateRepository.Remove(dividendsEstimate); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -283,7 +350,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -304,7 +371,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -325,7 +392,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentives(
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -346,7 +413,7 @@ func (dividendsEstimateService *DividendsEstimateService) UpdateDividendsEstimat
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
... ... @@ -361,7 +428,7 @@ func (dividendsEstimateService *DividendsEstimateService) UpdateDividendsEstimat
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsEstimate == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsEstimateCommand.DividendsEstimateId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateDividendsEstimateCommand.DividendsEstimateId, 10)))
}
if err := dividendsEstimate.Update(tool_funs.SimpleStructToMap(updateDividendsEstimateCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -8,6 +8,9 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"strconv"
"time"
)
// DividendsOrderService 分红订单实体对象
... ... @@ -27,22 +30,86 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createDividendsOrderCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(createDividendsOrderCommand.CompanyId, createDividendsOrderCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organization = data
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取操作人
var operator *domain.User
if data, err := userService.OperatorFrom(createDividendsOrderCommand.CompanyId, createDividendsOrderCommand.OrgId, createDividendsOrderCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
// 获取业务员
commandSalesmanUid, _ := strconv.ParseInt(createDividendsOrderCommand.SalesmanUid, 10, 64)
var salesman *domain.Salesman
if data, err := userService.SalesmanFrom(createDividendsOrderCommand.CompanyId, createDividendsOrderCommand.OrgId, commandSalesmanUid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
salesman = data
}
newDividendsOrder := &domain.DividendsOrder{
CustomerName: createDividendsOrderCommand.CustomerName,
DividendsOrderAmount: createDividendsOrderCommand.DividendsOrderAmount,
DividendsOrderNumber: createDividendsOrderCommand.DividendsOrderNumber,
DividendsOrderNumber: "",
DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
OrderTime: createDividendsOrderCommand.OrderTime,
//Remarks: createDividendsOrderCommand.Remarks,
//SalesmanUid: createDividendsOrderCommand.SalesmanUid,
//OperatorUid: createDividendsOrderCommand.OperatorUid,
//OrderGoods: createDividendsOrderCommand.OrderGoods,
//CompanyId: createDividendsOrderCommand.CompanyId,
//OrgId: createDividendsOrderCommand.OrgId,
//UserId: createDividendsOrderCommand.UserId,
DividendsOrderAmount: createDividendsOrderCommand.DividendsOrderAmount,
OrderSalesman: salesman,
OrderTime: time.Time{},
DividendTime: time.Time{},
DividendStatus: 0,
Region: nil,
CustomerName: "",
Goods: nil,
Org: organization,
Company: company,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
OperateTime: time.Time{},
Operator: operator,
}
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -74,7 +141,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
... ... @@ -89,7 +156,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDividendsOrderQuery.DividendsOrderId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getDividendsOrderQuery.DividendsOrderId, 10)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -111,7 +178,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -132,7 +199,7 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
... ... @@ -172,7 +239,7 @@ func (dividendsOrderService *DividendsOrderService) SearchDividendsOrder(searchD
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -193,7 +260,7 @@ func (dividendsOrderService *DividendsOrderService) SearchDividendsOrderNumber(s
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -214,7 +281,7 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
... ...
... ... @@ -8,6 +8,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"time"
)
// DividendsReturnedOrderService 分红退货单服务
... ... @@ -27,20 +29,78 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createDividendsReturnedOrderCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(createDividendsReturnedOrderCommand.CompanyId, createDividendsReturnedOrderCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organization = data
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取操作人
var operator *domain.User
if data, err := userService.OperatorFrom(createDividendsReturnedOrderCommand.CompanyId, createDividendsReturnedOrderCommand.OrgId, createDividendsReturnedOrderCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
newDividendsReturnedOrder := &domain.DividendsReturnedOrder{
DividendsReturnedOrderRefund: createDividendsReturnedOrderCommand.DividendsReturnedOrderRefund,
DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName,
OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum,
Remarks: createDividendsReturnedOrderCommand.Remarks,
DividendsReturnedDate: createDividendsReturnedOrderCommand.DividendsReturnedDate,
//RegionName: createDividendsReturnedOrderCommand.RegionName,
//OrderGoods: createDividendsReturnedOrderCommand.OrderGoods,
//CompanyId: createDividendsReturnedOrderCommand.CompanyId,
//OrgId: createDividendsReturnedOrderCommand.OrgId,
//UserId: createDividendsReturnedOrderCommand.UserId,
DividendsReturnedOrderNumber: "",
DividendsReturnedOrderRefund: 0,
OriginalOrderNum: "",
DividendsOrderNumber: 0,
DividendsReturnedCustomerName: "",
DividendsReturnedDate: time.Time{},
Region: nil,
Goods: nil,
Remarks: "",
DividendStatus: 0,
DividendTime: time.Time{},
Org: organization,
Company: company,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
Operator: operator,
OperateTime: time.Time{},
}
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -72,7 +132,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) GetDividends
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
... ... @@ -109,7 +169,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -130,7 +190,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ListDividend
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
... ... @@ -166,7 +226,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) RemoveDivide
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
... ... @@ -206,7 +266,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) SearchDivide
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -227,7 +287,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
... ...
... ... @@ -17,6 +17,6 @@ func CreateDepartmentService(options map[string]interface{}) (service.Department
return domain_service.NewDepartmentService()
}
func CreateOrganization(options map[string]interface{}) (service.OrgService, error) {
func CreateOrganizationService(options map[string]interface{}) (service.OrgService, error) {
return domain_service.NewOrganizationService()
}
... ...
... ... @@ -13,7 +13,7 @@ type ContractUndertakerFeedback struct {
// 共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 共创合约承接人
ContractUndertaker *User `json:"contractUndertaker"`
ContractUndertaker *Undertaker `json:"contractUndertaker"`
// 共创模式
CooperationMode *CooperationMode `json:"cooperationMode"`
// 数据所属组织机构
... ...
... ... @@ -13,7 +13,7 @@ type DividendsOrder struct {
// 分红订单金额
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
// 订单业务员
OrderSalesman *User `json:"orderSalesman"`
OrderSalesman *Salesman `json:"orderSalesman"`
// 订单产生时间
OrderTime time.Time `json:"orderTime"`
// 分红订单分红时间
... ...
... ... @@ -3,9 +3,10 @@ package service
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
type UserService interface {
ReferrerFrom(companyId int64, orgId int64, userId int64) (*domain.Referrer, error)
UndertakerFrom(companyId int64, orgId int64, userId int64) (*domain.Undertaker, error)
RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error)
SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error)
OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error)
UserFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取用户
ReferrerFrom(companyId int64, orgId int64, userId int64) (*domain.Referrer, error) // 获取推荐人
UndertakerFrom(companyId int64, orgId int64, userId int64) (*domain.Undertaker, error) // 获取承接人
RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error) // 获取相关人
SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error) // 获取业务员
OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取操作人
}
... ...
... ... @@ -9,6 +9,26 @@ import (
type UserService struct {
}
// UserFrom 获取普通用户
func (service *UserService) UserFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) {
var returnData *domain.User
if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
return nil, err
} else {
if user, err := userAdaptor.ToParticipator(companyId, orgId, userId, "User"); err != nil {
return nil, err
} else {
if user != nil {
err := json.Unmarshal(user.([]byte), returnData)
if err != nil {
return nil, err
}
}
return returnData, nil
}
}
}
// ReferrerFrom 获取推荐人
func (service *UserService) ReferrerFrom(companyId int64, orgId int64, userId int64) (*domain.Referrer, error) {
var returnData *domain.Referrer
... ...
... ... @@ -223,15 +223,15 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
return nil, err
}
var cooperationContractRelevantModelsUpdate []*models.CooperationContractRelevant // 待更新的相关人
var cooperationContractRelevantModelsDelete []*models.CooperationContractRelevant // 待删除的相关人
var cooperationContractRelevantModelsCreate []*models.CooperationContractRelevant // 待增加的相关人
for _, cooperationContractRelevantModels := range cooperationContractRelevantModels {
for _, cooperationContractRelevantDomain := range cooperationContract.RelevantPeople {
}
}
//var cooperationContractRelevantModelsUpdate []*models.CooperationContractRelevant // 待更新的相关人
//var cooperationContractRelevantModelsDelete []*models.CooperationContractRelevant // 待删除的相关人
//var cooperationContractRelevantModelsCreate []*models.CooperationContractRelevant // 待增加的相关人
//
//for _, cooperationContractRelevantModels := range cooperationContractRelevantModels {
// for _, cooperationContractRelevantDomain := range cooperationContract.RelevantPeople {
//
// }
//}
// 更新的相关人
... ...
... ... @@ -49,6 +49,12 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId
return map[string]interface{}{}, nil
}
return operator, nil
case "User":
user, err := userTranslator.ToUserFromRepresentation(response)
if err != nil {
return map[string]interface{}{}, nil
}
return user, nil
}
}
}
... ...
... ... @@ -79,6 +79,21 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]i
}, nil
}
func (translator *UserTranslator) ToUserFromRepresentation(data map[string]interface{}) (*domain.User, error) {
return &domain.User{
UserId: 0,
UserBaseId: 0,
Org: nil,
Orgs: nil,
Department: nil,
Role: nil,
UserInfo: nil,
UserType: 0,
Status: 0,
Company: nil,
}, nil
}
func NewUserTranslator() (*UserTranslator, error) {
return &UserTranslator{}, nil
}
... ...