作者 陈志颖

feat:完成共创申请一键审核

... ... @@ -22,6 +22,8 @@ type OneClickApprovalCooperationApplicationCommand struct {
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
// 审核动作,1同意,2拒绝
Action int32 `cname:"审核动作" json:"action" valid:"Required"`
// 审核状态
CooperationApplicationStatus int32 `cname:"共创申请审核状态" json:"cooperationApplicationStatus"`
}
func (oneClickApprovalCooperationApplicationCommand *OneClickApprovalCooperationApplicationCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -236,7 +236,9 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return cooperationApplicationsApproved, nil
return map[string]interface{}{
"cooperationApplications": cooperationApplicationsApproved,
}, nil
} else {
return map[string]interface{}{}, nil
}
... ... @@ -258,10 +260,41 @@ func (cooperationApplicationService *CooperationApplicationService) OneClickAppr
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationApplicationRepository = value
}
// 查询共创申请
oneClickApprovalCooperationApplicationCommand.CooperationApplicationStatus = 1 // 待审核
if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(oneClickApprovalCooperationApplicationCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for i, _ := range cooperationApplications {
if oneClickApprovalCooperationApplicationCommand.Action == 1 {
cooperationApplications[i].CooperationApplicationStatus = 2
} else if oneClickApprovalCooperationApplicationCommand.Action == 2 {
cooperationApplications[i].CooperationApplicationStatus = 3
}
cooperationApplications[i].CooperationApplicationDescription = oneClickApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription
}
cooperationApplicationsApproved, err := cooperationApplicationRepository.UpdateMany(cooperationApplications)
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())
}
return cooperationApplicationsApproved, nil
} else {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未找到待审核的共创申请")
}
}
return nil, nil
}
// CreateCooperationApplication 创建共创申请服务
... ... @@ -434,6 +467,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ...
... ... @@ -331,7 +331,10 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) BatchRemoveD
dividendsReturnedOrderRepository = value
}
dividendsReturnedOrderIds, _ := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsReturnedOrderIds)
dividendsReturnedOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsReturnedOrderIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单号错误")
}
if count, dividendsReturnedOrders, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
"dividendsReturnedOrderIds": dividendsReturnedOrderIds,
}); err != nil {
... ...
... ... @@ -214,7 +214,6 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber))
}
// 共创项目名称查询
if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
query.Join("LEFT JOIN cooperation_projects AS a").
JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number").
... ... @@ -229,6 +228,12 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
if cooperationApplicationIds, ok := queryOptions["cooperationApplicationIds"]; ok && len(cooperationApplicationIds.([]int64)) > 0 {
query.Where("cooperation_application_id IN (?)", pg.In(cooperationApplicationIds))
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -319,7 +319,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str
// 获取订单产品
var orderGoodModels []*models.OrderGood
orderGoodModelQuery := tx.Model(&orderGoodModels)
if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil {
if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber).Select(); err != nil {
return nil, err
}
// 聚合分红退货单
... ... @@ -356,7 +356,7 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
// 获取订单产品
var orderGoodModels []*models.OrderGood
orderGoodModelQuery := tx.Model(&orderGoodModels)
if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil {
if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber).Select(); err != nil {
return 0, nil, err
}
if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels); err != nil {
... ...