作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
正在显示 23 个修改的文件 包含 350 行增加106 行删除
... ... @@ -91,7 +91,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Crea
}
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractNumber": createContractUndertakerFeedbackCommand.CooperationContractNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createContractUndertakerFeedbackCommand.CooperationContractNumber))
... ... @@ -153,7 +153,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetC
}
contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": getContractUndertakerFeedbackQuery.FeedbackId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "合约反馈信息不存在")
}
if contractUndertakerFeedback == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getContractUndertakerFeedbackQuery.FeedbackId)))
... ... @@ -228,7 +228,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Remo
}
contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": removeContractUndertakerFeedbackCommand.FeedbackId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "反馈信息不存在")
}
if contractUndertakerFeedback == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeContractUndertakerFeedbackCommand.FeedbackId)))
... ... @@ -306,7 +306,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Upda
}
contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": updateContractUndertakerFeedbackCommand.FeedbackId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "反馈信息不存在")
}
if contractUndertakerFeedback == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateContractUndertakerFeedbackCommand.FeedbackId)))
... ...
... ... @@ -48,7 +48,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": applyForCooperationCommand.CooperationProjectId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(applyForCooperationCommand.CooperationProjectId, 10)))
... ... @@ -169,7 +169,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
// 获取共创申请
cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": approvalCooperationApplicationCommand.CooperationApplicationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创申请不存在")
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
... ... @@ -330,7 +330,7 @@ func (cooperationApplicationService *CooperationApplicationService) CreateCooper
}
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectNumber": createCooperationApplicationCommand.CooperationProjectNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationApplicationCommand.CooperationProjectNumber))
... ... @@ -445,7 +445,7 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati
}
cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": getCooperationApplicationQuery.CooperationApplicationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创申请不存在")
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationApplicationQuery.CooperationApplicationId, 10)))
... ... @@ -523,7 +523,7 @@ func (cooperationApplicationService *CooperationApplicationService) RemoveCooper
}
cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": removeCooperationApplicationCommand.CooperationApplicationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创申请不存在")
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationApplicationCommand.CooperationApplicationId, 10)))
... ... @@ -608,7 +608,7 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper
}
cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": updateCooperationApplicationCommand.CooperationApplicationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创申请不存在")
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateCooperationApplicationCommand.CooperationApplicationId, 10)))
... ... @@ -658,7 +658,7 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
}
cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": cooperationApplicationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创申请不存在")
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
... ...
... ... @@ -287,7 +287,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
}
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationContractCommand.CooperationModeNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationContractCommand.CooperationModeNumber))
... ... @@ -368,7 +368,7 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont
}
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": getCooperationContractQuery.CooperationContractId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractQuery.CooperationContractId, 10)))
... ... @@ -489,7 +489,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC
}
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": removeCooperationContractCommand.CooperationContractId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationContractCommand.CooperationContractId, 10)))
... ... @@ -603,7 +603,7 @@ func (cooperationContractService *CooperationContractService) OperateCooperation
// 获取共创合约
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": operateCooperationContractCommand.CooperationContractId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operateCooperationContractCommand.CooperationContractId)))
... ... @@ -632,6 +632,7 @@ func (cooperationContractService *CooperationContractService) OperateCooperation
Undertakers: "",
CooperationContractNumber: cooperationContractUpdated.CooperationContractNumber,
Company: cooperationContractUpdated.Company,
Org: cooperationContract.Org,
Operator: operator,
CreatedAt: time.Now(),
}
... ... @@ -731,6 +732,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper
Undertakers: "",
CooperationContractNumber: cooperationContractOperated.CooperationContractNumber,
Company: cooperationContractOperated.Company,
Org: cooperationContractOperated.Org,
Operator: operator,
CreatedAt: time.Now(),
}
... ... @@ -881,7 +883,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 获取待更新的共创合约
cooperationContract, err8 := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": updateCooperationContractCommand.CooperationContractId})
if err8 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err8.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
... ... @@ -1266,6 +1268,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
Undertakers: undertakerChange,
CooperationContractNumber: cooperationContractSaved.CooperationContractNumber,
Company: company,
Org: organization,
Operator: operator,
UpdatedAt: time.Time{},
CreatedAt: time.Now(),
... ...
... ... @@ -49,6 +49,22 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
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(createCooperationContractChangeLogCommand.CompanyId, createCooperationContractChangeLogCommand.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 {
... ... @@ -82,6 +98,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
Undertakers: createCooperationContractChangeLogCommand.Undertakers,
CooperationContractNumber: createCooperationContractChangeLogCommand.CooperationContractNumber,
Company: company,
Org: organization,
Operator: operator,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
... ... @@ -123,7 +140,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
}
cooperationContractChangeLog, err := cooperationContractChangeLogRepository.FindOne(map[string]interface{}{"cooperationContractChangeLogId": getCooperationContractChangeLogQuery.CooperationContractChangeLogId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约变更记录不存在")
}
if cooperationContractChangeLog == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractChangeLogQuery.CooperationContractChangeLogId, 10)))
... ... @@ -198,7 +215,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
}
cooperationContractChangeLog, err := cooperationContractChangeLogRepository.FindOne(map[string]interface{}{"cooperationContractChangeLogId": removeCooperationContractChangeLogCommand.CooperationContractChangeLogId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约变更记录不存在")
}
if cooperationContractChangeLog == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationContractChangeLogCommand.CooperationContractChangeLogId, 10)))
... ... @@ -276,7 +293,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
}
cooperationContractChangeLog, err := cooperationContractChangeLogRepository.FindOne(map[string]interface{}{"cooperationContractChangeLogId": updateCooperationContractChangeLogCommand.CooperationContractChangeLogId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约变更记录不存在")
}
if cooperationContractChangeLog == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateCooperationContractChangeLogCommand.CooperationContractChangeLogId, 10)))
... ...
... ... @@ -168,7 +168,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop
}
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": getCooperationModeQuery.CooperationModeId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationModeQuery.CooperationModeId, 10)))
... ... @@ -241,7 +241,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo
}
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": removeCooperationModeCommand.CooperationModeId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationModeCommand.CooperationModeId, 10)))
... ... @@ -379,7 +379,7 @@ func (cooperationModeService *CooperationModeService) UpdateCooperationMode(upda
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": updateCooperationModeCommand.CooperationModeId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateCooperationModeCommand.CooperationModeId, 10)))
... ... @@ -423,7 +423,7 @@ func (cooperationModeService *CooperationModeService) OperateCooperationMode(ope
cooperationModeId, _ := strconv.ParseInt(operateCooperationModeCommand.CooperationModeId, 10, 64)
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": cooperationModeId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationModeId, 10)))
... ...
... ... @@ -25,15 +25,15 @@ type CreateCooperationProjectCommand struct {
// 附件
Attachment []*domain.Attachment `cname:"附件" json:"attachment"`
// 所属部门Id
DepartmentId int64 `json:"departmentId,string"`
DepartmentId int64 `cname:"所属部门ID" json:"departmentId"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"companyId"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"`
OrgId int64 `cname:"组织机构ID" json:"orgId"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
}
func (createCooperationProjectCommand *CreateCooperationProjectCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -13,14 +13,6 @@ type ReleaseCooperationProjectCommand struct {
CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName" valid:"Required"`
// 共创模式ID
CooperationModeId int64 `cname:"共创模式ID" json:"cooperationModeId" valid:"Required"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
// 用户基本id
UserBaseId int64 `cname:"用户基本数据ID" json:"userBaseId" valid:"Required"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
// 共创项目发起人id
CooperationProjectSponsorId string `cname:"共创项目发起人UID" json:"cooperationProjectSponsorId" valid:"Required"`
// 部门ID,通过REST集成上下文获取
... ... @@ -29,6 +21,14 @@ type ReleaseCooperationProjectCommand struct {
CooperationProjectUndertakerType []int32 `cname:"共创项目承接对象" json:"cooperationProjectUndertakerType" valid:"Required"`
// 共创项目描述
CooperationProjectDescription string `cname:"共创项目描述" json:"cooperationProjectDescription" valid:"Required"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基本id
UserBaseId int64 `cname:"用户基本数据ID" json:"userBaseId"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId"`
}
func (releaseCooperationProjectCommand *ReleaseCooperationProjectCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -68,23 +68,23 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
// 获取操作人
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())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取操作人失败")
} else {
operator = data
}
// Sponsor
// 获取发起人
var sponsor *domain.User
if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.SponsorUid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取发起人失败")
} else {
sponsor = data
}
// Publisher
// 获取发布人
var publisher *domain.User
if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.PublisherUid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取发布人失败")
} else {
publisher = data
}
... ... @@ -100,7 +100,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createCooperationProjectCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司信息失败")
} else {
company = data
}
... ... @@ -116,15 +116,15 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
// 获取组织机构信息
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())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取组织机构信息失败")
} else {
organization = data
}
// 获取组织机构信息
// 获取部门信息
var department *domain.Org
if data, err := organizationService.OrgFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.DepartmentId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息失败")
} else {
department = data
}
... ... @@ -140,7 +140,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
}
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
}
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber))
... ...
... ... @@ -456,6 +456,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
_ = transactionContext.RollbackTransaction()
}()
// 订单产品ID类型转换
orderGoodIds, err := utils.SliceAtoi(confirmDividendsIncentivesEstimateCommand.OrderGoodIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -493,6 +494,22 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
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(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, confirmDividendsIncentivesEstimateCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
// 分红订单仓储初始化
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
... ... @@ -566,9 +583,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
for _, orderGood := range orderGoods {
dividendsEstimate := &domain.DividendsEstimate{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
dividendsOrder, err3 := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
if err3 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
... ... @@ -598,7 +615,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
DividendsStage: dividendsEstimateDetail.DividendsStage,
Org: organization,
Company: company,
Operator: nil,
Operator: operator,
OperateTime: time.Time{},
IsCanceled: false,
CreatedAt: time.Now(),
... ... @@ -641,7 +658,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
Org: organization,
Company: company,
Operator: nil,
Operator: operator,
OperateTime: time.Time{},
IsCanceled: false,
CreatedAt: time.Now(),
... ... @@ -670,16 +687,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// TODO 分析成功和失败原因
return dividendsEstimatesSaved, nil
return dividendsEstimatesSavedSuccessfully, nil
}
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"github.com/beego/beego/v2/core/validation"
"reflect"
"strings"
"time"
)
type OrderGoods struct {
... ... @@ -30,7 +31,7 @@ type CreateDividendsOrderCommand struct {
// 分红订单原单号
DividendsOriginalOrderNum string `cname:"源单号" json:"dividendsOriginalOrderNum" valid:"Required"`
// 订单时间
OrderTime string `cname:"订单时间" json:"orderTime" valid:"Required"`
OrderTime time.Time `cname:"订单时间" json:"orderTime" valid:"Required"`
// 备注
Remarks string `cname:"备注" json:"remarks" valid:"Required"`
// 订单区域名称
... ...
... ... @@ -2,14 +2,26 @@ package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"reflect"
"strings"
"time"
"github.com/beego/beego/v2/core/validation"
)
type ImportDividendsOrderCommand struct {
// 订单数据列表
DividendsOrderData []*DividendsOrderData `cname:"订单数据列表" json:"dividendsOrderData" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础信息id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
}
type DividendsOrderData struct {
// 客户名称
CustomerName string `cname:"客户名称" json:"customerName" valid:"Required"`
// 分红订单金额
... ... @@ -20,24 +32,16 @@ type ImportDividendsOrderCommand struct {
DividendsOriginalOrderNum string `cname:"分红订单原单号" json:"dividendsOriginalOrderNum" valid:"Required"`
// 订单产生时间
OrderTime time.Time `cname:"订单产生时间" json:"orderTime" valid:"Required"`
// 备注
Remarks string `cname:"备注" json:"remarks" valid:"Required"`
// 订单区域名称
RegionName string `cname:"订单区域名称" json:"regionName,omitempty"`
// 订单业务员uid
SalesmanUid string `cname:"订单业务员UID" json:"salesmanUid,omitempty"`
// 订单操作人uid
OperatorUid string `cname:"订单操作人UID" json:"operatorUid,omitempty"`
// 订单产品列表
OrderGoods []*OrderGoods `cname:"订单产品列表" json:"orderGoods,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
// 用户基础信息id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
// 订单操作人uid
OperatorUid string `cname:"订单操作人UID" json:"operatorUid,omitempty"`
// 备注
Remarks string `cname:"备注" json:"remarks,omitempty"`
}
func (importDividendsOrderCommand *ImportDividendsOrderCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -112,7 +112,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
}
// 获取订单产品
// 新增订单产品
var orderGoods []*domain.OrderGood
var dividendsOrderAmount float64
for _, orderGood := range createDividendsOrderCommand.OrderGoods {
... ... @@ -136,9 +136,9 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
}
// 订单时间转换
orderTimeInt, _ := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
orderTime := utils.TransformTimestampToTime(orderTimeInt)
//// 订单时间转换
//orderTimeInt, _ := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
//orderTime := utils.TransformTimestampToTime(orderTimeInt)
// 新增分红订单
newDividendsOrder := &domain.DividendsOrder{
... ... @@ -146,7 +146,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
DividendsOrderNumber: dividendsOrderNumber,
DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
DividendsOrderAmount: dividendsOrderAmount,
OrderTime: orderTime,
OrderTime: createDividendsOrderCommand.OrderTime,
DividendTime: time.Time{},
DividendStatus: domain.TO_BE_DIVIDEND,
Region: &domain.RegionInfo{
... ... @@ -162,6 +162,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
UpdatedAt: time.Time{},
OperateTime: time.Now(),
Operator: operator,
Remarks: createDividendsOrderCommand.Remarks,
}
// 分红订单仓储初始化
... ... @@ -183,6 +184,174 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
}
}
// ImportDividendsOrder 导入分红订单实体对象
func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importDividendsOrderCommand *command.ImportDividendsOrderCommand) (interface{}, error) {
if err := importDividendsOrderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = 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(importDividendsOrderCommand.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(importDividendsOrderCommand.CompanyId, importDividendsOrderCommand.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(importDividendsOrderCommand.CompanyId, importDividendsOrderCommand.OrgId, importDividendsOrderCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
operator = data
}
// 分红订单DAO初始化
var dividendsOrderDao *dao.DividendsOrderDao
if value, err := factory.CreateDividendsOrderDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
dividendsOrderDao = value
}
var dividendsOrderImportFailed []*domain.DividendsOrder
var dividendsOrderImportSuccesfully []*domain.DividendsOrder
for _, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
// 生成分红订单号
dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 校验分红订单编号是否唯一
numberAvailable, err := dividendsOrderDao.CheckDividendsOrderNumberAvailable(map[string]interface{}{
"companyId": importDividendsOrderCommand.CompanyId,
"orgId": importDividendsOrderCommand.OrgId,
"dividendsOrderNumber": dividendsOrderNumber,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if !numberAvailable {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
}
// 新增订单产品
var orderGoods []*domain.OrderGood
var dividendsOrderAmount float64
for _, orderGood := range dividendsOrder.OrderGoods {
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: 0,
OrderGoodAmount: orderGood.OrderGoodAmount,
OrderGoodName: orderGood.OrderGoodName,
OrderGoodPrice: orderGood.OrderGoodPrice,
OrderGoodQuantity: orderGood.OrderGoodQuantity,
DividendsOrderNumber: dividendsOrderNumber,
DividendsReturnedOrderNumber: "",
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodExpense: orderGood.OrderGoodExpense,
OrgId: importDividendsOrderCommand.OrgId,
CompanyId: importDividendsOrderCommand.CompanyId,
CreatedAt: time.Time{},
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
})
// 计算分红订单金额
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
}
// 新增分红订单
newDividendsOrder := &domain.DividendsOrder{
DividendsOrderId: 0,
DividendsOrderNumber: dividendsOrderNumber,
DividendsOriginalOrderNum: dividendsOrder.DividendsOriginalOrderNum,
DividendsOrderAmount: dividendsOrderAmount,
OrderTime: dividendsOrder.OrderTime,
DividendTime: time.Time{},
DividendStatus: domain.TO_BE_DIVIDEND,
Region: &domain.RegionInfo{
RegionNumber: "",
RegionName: dividendsOrder.RegionName,
},
CustomerName: dividendsOrder.CustomerName,
Goods: orderGoods,
Org: organization,
Company: company,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
OperateTime: time.Now(),
Operator: operator,
}
// 分红订单仓储初始化
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err1 := factory.CreateDividendsOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err1 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err1.Error())
} else {
dividendsOrderRepository = value
}
if dividendsOrderSaved, err2 := dividendsOrderRepository.Save(newDividendsOrder); err2 != nil {
dividendsOrderImportFailed = append(dividendsOrderImportFailed, newDividendsOrder)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
} else {
dividendsOrderImportSuccesfully = append(dividendsOrderImportSuccesfully, dividendsOrderSaved)
return dividendsOrderSaved, nil
}
}
if err3 := transactionContext.CommitTransaction(); err3 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
}
return nil, nil
}
// GetDividendsOrder 返回分红订单实体对象
func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividendsOrderQuery *query.GetDividendsOrderQuery) (interface{}, error) {
if err := getDividendsOrderQuery.ValidateQuery(); err != nil {
... ...
... ... @@ -2,36 +2,41 @@ package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"reflect"
"strings"
"time"
"github.com/beego/beego/v2/core/validation"
)
type ImportDividendsReturnedOrderCommand struct {
// DividendsReturnedOrderData 分红退货单数据
type DividendsReturnedOrderData struct {
// 退货金额
DividendsReturnedOrderRefund float64 `cname:"退货金额" json:"dividendsReturnedOrderRefund" valid:"Required"`
// 退货客户名称
DividendsReturnedCustomerName string `cname:"退货客户名称" json:"dividendsReturnedCustomerName" valid:"Required"`
// 来源单号,源单号,订单号
OriginalOrderNum string `cname:"来源单号" json:"originalOrderNum" valid:"Required"`
// 备注
Remarks string `cname:"备注" json:"remarks" valid:"Required"`
// 退货日期
DividendsReturnedDate time.Time `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"`
// 退货区域名称
RegionName string `cname:"退货区域名称" json:"regionName,omitempty"`
RegionName string `cname:"退货区域名称" json:"regionName"`
// 订单产品列表
OrderGoods []*OrderGoods `cname:"订单产品列表" json:"orderGoods,omitempty"`
OrderGoods []*OrderGoods `cname:"订单产品列表" json:"orderGoods"`
// 备注
Remarks string `cname:"备注" json:"remarks"`
}
type ImportDividendsReturnedOrderCommand struct {
// 分红退货单数据
DividendsReturnedOrderData []*DividendsReturnedOrderData `cname:"分红退货单数据列表" json:"dividendsReturnedOrderData" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"companyId"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"`
OrgId int64 `cname:"组织机构ID" json:"orgId"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
}
func (importDividendsReturnedOrderCommand *ImportDividendsReturnedOrderCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -14,13 +14,15 @@ type ListDividendsReturnedOrderQuery struct {
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"companyId"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"`
OrgId int64 `cname:"组织机构ID" json:"orgId"`
// 关联的组织机构列表
OrgIds []int64 `cname:"关联的组织机构列表" json:"orgIds"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
}
func (listDividendsReturnedOrderQuery *ListDividendsReturnedOrderQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -18,13 +18,13 @@ type SearchDividendsReturnedOrderQuery struct {
// 页面大小
PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"companyId"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"`
OrgId int64 `cname:"组织机构ID" json:"orgId"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
}
func (searchDividendsReturnedOrderQuery *SearchDividendsReturnedOrderQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -131,7 +131,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
newDividendsReturnedOrder := &domain.DividendsReturnedOrder{
DividendsReturnedOrderNumber: dividendsReturnedOrderNumber,
DividendsReturnedOrderRefund: 0,
DividendsReturnedOrderRefund: createDividendsReturnedOrderCommand.DividendsReturnedOrderRefund,
OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum,
DividendsOrderNumber: createDividendsReturnedOrderCommand.DividendsOrderNumber,
DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName,
... ...
... ... @@ -44,7 +44,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
// 获取合约
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractNumber": orderGood.CooperationContractNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.CooperationContractNumber))
... ... @@ -55,7 +55,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
"dividendsOrderNumber": orderGood.DividendsOrderNumber,
})
if err2 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
... ... @@ -68,6 +68,10 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
break
}
}
if dividendsIncentivesRuleMatched == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, "未匹配到分红规则")
}
// 计算分红
if dividendsIncentivesRuleMatched != nil {
for _, undertaker := range cooperationContract.Undertakers {
... ... @@ -143,7 +147,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
})
if err3 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单不存在")
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
... ...
... ... @@ -23,7 +23,7 @@ type CooperationContractChangeLog struct {
Company *domain.Company `comment:"公司"`
// 组织机构
Org *domain.Org `comment:"组织"`
// 操作人
//
Operator *domain.User `comment:"操作人"`
// 操作时间
OperatorTime time.Time `comment:"操作时间"`
... ...
... ... @@ -41,6 +41,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
"org",
"incentives_type",
"company",
"department",
"operator",
"operate_time",
"created_at",
... ... @@ -74,6 +75,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
&cooperationContract.Org,
&cooperationContract.IncentivesType,
&cooperationContract.Company,
&cooperationContract.Department,
&cooperationContract.Operator,
&cooperationContract.OperateTime,
&cooperationContract.CreatedAt,
... ... @@ -93,6 +95,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
cooperationContract.Org,
cooperationContract.IncentivesType,
cooperationContract.Company,
cooperationContract.Department,
cooperationContract.Operator,
cooperationContract.OperateTime,
cooperationContract.CreatedAt,
... ... @@ -226,6 +229,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
&cooperationContract.Org,
&cooperationContract.IncentivesType,
&cooperationContract.Company,
&cooperationContract.Department,
&cooperationContract.Operator,
&cooperationContract.OperateTime,
&cooperationContract.CreatedAt,
... ... @@ -245,6 +249,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
cooperationContract.Org,
cooperationContract.IncentivesType,
cooperationContract.Company,
cooperationContract.Department,
cooperationContract.Operator,
cooperationContract.OperateTime,
cooperationContract.CreatedAt,
... ... @@ -670,6 +675,7 @@ func (repository *CooperationContractRepository) UpdateOne(cooperationContract *
Status: cooperationContract.Status,
Org: cooperationContract.Org,
Company: cooperationContract.Company,
Department: cooperationContract.Department,
Operator: cooperationContract.Operator,
OperateTime: cooperationContract.OperateTime,
CreatedAt: cooperationContract.CreatedAt,
... ... @@ -698,6 +704,7 @@ func (repository *CooperationContractRepository) UpdateMany(cooperationContracts
Status: cooperationContract.Status,
Org: cooperationContract.Org,
Company: cooperationContract.Company,
Department: cooperationContract.Department,
Operator: cooperationContract.Operator,
OperateTime: cooperationContract.OperateTime,
CreatedAt: cooperationContract.CreatedAt,
... ...
... ... @@ -56,12 +56,12 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
tx := repository.transactionContext.PgTx
if dividendsEstimate.Identify() == nil {
//dividendsEstimateId, err := repository.nextIdentify()
//if err != nil {
// return dividendsEstimate, err
//} else {
// dividendsEstimate.DividendsEstimateId = dividendsEstimateId
//}
dividendsEstimateId, err := repository.nextIdentify()
if err != nil {
return dividendsEstimate, err
} else {
dividendsEstimate.DividendsEstimateId = dividendsEstimateId
}
if _, err := tx.QueryOne(
pg.Scan(
&dividendsEstimate.DividendsEstimateId,
... ...
... ... @@ -112,7 +112,10 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
DividendsOrderNumber: good.DividendsOrderNumber,
DividendsReturnedOrderNumber: good.DividendsReturnedOrderNumber,
CooperationContractNumber: good.CooperationContractNumber,
CompanyId: good.CompanyId,
OrgId: good.OrgId,
OrderGoodExpense: good.OrderGoodExpense,
OrderGoodDividendsStatus: good.OrderGoodDividendsStatus,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
... ... @@ -204,6 +207,7 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
OrderGoodExpense: goodDomain.OrderGoodExpense,
OrgId: goodDomain.OrgId,
CompanyId: goodDomain.CompanyId,
OrderGoodDividendsStatus: goodDomain.OrderGoodDividendsStatus,
CreatedAt: time.Time{},
DeletedAt: time.Time{},
UpdatedAt: time.Now(),
... ...
... ... @@ -121,6 +121,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
OrderGoodExpense: good.OrderGoodExpense,
OrgId: good.OrgId,
CompanyId: good.CompanyId,
OrderGoodDividendsStatus: good.OrderGoodDividendsStatus,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
... ... @@ -216,6 +217,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
OrderGoodExpense: goodDomain.OrderGoodExpense,
OrgId: goodDomain.OrgId,
CompanyId: goodDomain.CompanyId,
OrderGoodDividendsStatus: goodDomain.OrderGoodDividendsStatus,
CreatedAt: time.Time{},
DeletedAt: time.Time{},
UpdatedAt: time.Now(),
... ...
... ... @@ -23,6 +23,19 @@ func (controller *DividendsOrderController) CreateDividendsOrder() {
controller.Response(data, err)
}
func (controller *DividendsOrderController) ImportDividendsOrder() {
dividendsOrderService := service.NewDividendsOrderService(nil)
importDividendsOrderCommand := &command.ImportDividendsOrderCommand{}
_ = controller.Unmarshal(importDividendsOrderCommand)
header := controller.GetRequestHeader(controller.Ctx)
importDividendsOrderCommand.CompanyId = header.CompanyId
importDividendsOrderCommand.OrgId = header.OrgId
importDividendsOrderCommand.UserId = header.UserId
importDividendsOrderCommand.UserBaseId = header.UserBaseId
data, err := dividendsOrderService.ImportDividendsOrder(importDividendsOrderCommand)
controller.Response(data, err)
}
func (controller *DividendsOrderController) UpdateDividendsOrder() {
dividendsOrderService := service.NewDividendsOrderService(nil)
updateDividendsOrderCommand := &command.UpdateDividendsOrderCommand{}
... ...