作者 yangfu

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

…ion-cooperation into dev
... ... @@ -13,6 +13,7 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/moul/http2curl v1.0.0 // indirect
... ...
... ... @@ -138,6 +138,8 @@ github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
... ...
... ... @@ -11,6 +11,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"strconv"
"time"
)
... ... @@ -529,42 +530,43 @@ func (cooperationProjectService *CooperationProjectService) BatchEndCooperationP
}()
// 共创项目仓储初始化
//var cooperationProjectRepository domain.CooperationProjectRepository
//if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
// "transactionContext": transactionContext,
//}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// cooperationProjectRepository = value
//}
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
// 转换共创项目ID列表类型
//cooperationProjectIds, err := utils.SliceAtoi(batchEndCooperationProjectCommand.CooperationProjectIds)
//if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//}
//cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": batchEndCooperationProjectCommand.CooperationProjectId})
//if err != nil {
// 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(batchEndCooperationProjectCommand.CooperationProjectId)))
//}
//if err := cooperationProject.Update(tool_funs.SimpleStructToMap(batchEndCooperationProjectCommand)); err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
//
//if cooperationProject, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// return cooperationProject, nil
//}
return nil, nil
cooperationProjectIds, err := utils.SliceAtoi(batchEndCooperationProjectCommand.CooperationProjectIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if count, cooperationProjects, err := cooperationProjectRepository.Find(map[string]interface{}{
"cooperationProjectIds": cooperationProjectIds,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for i, _ := range cooperationProjects {
cooperationProjects[i].Status = 2
}
cooperationProjectsEnded, err := cooperationProjectRepository.UpdateMany(cooperationProjects)
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 map[string]interface{}{
"cooperationProjects": cooperationProjectsEnded,
}, nil
} else {
return map[string]interface{}{}, nil
}
}
}
func NewCooperationProjectService(options map[string]interface{}) *CooperationProjectService {
... ...
... ... @@ -46,6 +46,7 @@ type CooperationProject struct {
type CooperationProjectRepository interface {
Save(cooperationProject *CooperationProject) (*CooperationProject, error)
UpdateMany(cooperationProjects []*CooperationProject) ([]*CooperationProject, error)
Remove(cooperationProject *CooperationProject) (*CooperationProject, error)
FindOne(queryOptions map[string]interface{}) (*CooperationProject, error)
Find(queryOptions map[string]interface{}) (int64, []*CooperationProject, error)
... ...
... ... @@ -234,6 +234,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -155,6 +155,15 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
}
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
if offsetLimitFlag {
query.SetOffsetAndLimit(20)
}
... ...
... ... @@ -170,6 +170,15 @@ func (repository *CooperationContractRelevantRepository) Find(queryOptions map[s
var cooperationContractRelevantModels []*models.CooperationContractRelevant
cooperationContractRelevants := make([]*domain.CooperationContractRelevant, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractRelevantModels), queryOptions)
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -647,7 +647,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
// 返回新增的合约
cooperationContractSaved, err := repository.FindOne(map[string]interface{}{
"cooperationContractId":cooperationContract.CooperationContractId,
"cooperationContractId": cooperationContract.CooperationContractId,
})
if err != nil {
return nil, err
... ... @@ -910,6 +910,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
query.Where("incentives_type = ?", incentivesType)
}
... ...
... ... @@ -181,6 +181,15 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions)
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -178,6 +178,15 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf
if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {
query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName))
}
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"fmt"
"github.com/go-pg/pg/v10"
"time"
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
... ... @@ -156,6 +157,38 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain.
return cooperationProject, nil
}
func (repository *CooperationProjectRepository) UpdateMany(cooperationProjects []*domain.CooperationProject) ([]*domain.CooperationProject, error) {
tx := repository.transactionContext.PgTx
var cooperationProjectModels []*models.CooperationProject
for _, cooperationProject := range cooperationProjects {
cooperationProjectModels = append(cooperationProjectModels, &models.CooperationProject{
CooperationProjectId: cooperationProject.CooperationProjectId,
CooperationProjectNumber: cooperationProject.CooperationProjectNumber,
CooperationProjectDescription: cooperationProject.CooperationProjectDescription,
CooperationProjectName: cooperationProject.CooperationProjectName,
CooperationProjectPublishTime: cooperationProject.CooperationProjectPublishTime,
CooperationProjectPublisher: cooperationProject.CooperationProjectPublisher,
CooperationProjectSponsor: cooperationProject.CooperationProjectSponsor,
CooperationModeNumber: cooperationProject.CooperationProjectNumber,
Department: cooperationProject.Department,
CooperationProjectUndertakerTypes: cooperationProject.CooperationProjectUndertakerTypes,
Attachment: cooperationProject.Attachment,
Org: cooperationProject.Org,
Company: cooperationProject.Company,
Operator: cooperationProject.Operator,
OperateTime: time.Now(),
Status: cooperationProject.Status,
UpdatedAt: time.Now(),
DeletedAt: cooperationProject.DeletedAt,
CreatedAt: cooperationProject.CreatedAt,
})
}
if _, err := tx.Model(&cooperationProjectModels).WherePK().Update(); err != nil {
return nil, err
}
return cooperationProjects, nil
}
func (repository *CooperationProjectRepository) Remove(cooperationProject *domain.CooperationProject) (*domain.CooperationProject, error) {
tx := repository.transactionContext.PgTx
cooperationProjectModel := new(models.CooperationProject)
... ... @@ -199,6 +232,15 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
var cooperationProjectModels []*models.CooperationProject
cooperationProjects := make([]*domain.CooperationProject, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationProjectModels), queryOptions)
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
if v, ok := queryOptions["status"]; ok && v.(int32) > 0 {
query.Where("status =? ", v)
}
... ...
... ... @@ -204,6 +204,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
query.Where("payment_status = ?", paymentStatus)
}
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -286,6 +286,15 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
if dividendsEstimateIds, ok := queryOptions["dividendsEstimateIds"]; ok && len(dividendsEstimateIds.([]int64)) > 0 {
query.Where("dividends_estimate_id IN (?)", pg.In(dividendsEstimateIds))
}
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -165,6 +165,15 @@ func (repository *DividendsIncentivesRuleRepository) Find(queryOptions map[strin
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
dividendsIncentivesRules := make([]*domain.DividendsIncentivesRule, 0)
query := sqlbuilder.BuildQuery(tx.Model(&dividendsIncentivesRuleModels), queryOptions)
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -330,6 +330,15 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa
if dividendsOrderIds, ok := queryOptions["dividendsOrderIds"]; ok && len(dividendsOrderIds.([]int64)) > 0 {
query.Where("dividends_order_id IN (?)", pg.In(dividendsOrderIds.([]int64)))
}
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -342,6 +342,15 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
if dividendsReturnedCustomerName, ok := queryOptions["dividendsReturnedCustomerName"]; ok && dividendsReturnedCustomerName != "" {
query.Where("dividends_returned_customer_name like ?", fmt.Sprintf("%%%s%%", dividendsReturnedCustomerName))
}
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -165,6 +165,15 @@ func (repository *MoneyIncentivesRuleRepository) Find(queryOptions map[string]in
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
moneyIncentivesRules := make([]*domain.MoneyIncentivesRule, 0)
query := sqlbuilder.BuildQuery(tx.Model(&moneyIncentivesRuleModels), queryOptions)
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -178,6 +178,15 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
if orderGoodIds, ok := queryOptions["orderGoodIds"]; ok && len(orderGoodIds.([]int64)) > 0 {
query.Where("order_good_id IN (?)", pg.In(orderGoodIds))
}
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)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...