作者 陈志颖

feat:对接消息推送模块

... ... @@ -6,6 +6,7 @@ import (
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/event/subscriber"
"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"
... ... @@ -103,6 +104,17 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
creditAccountDao = value
}
// 账期结算消息推送领域服务初始化
var estimateDividendsService service.EstimateDividendsService
if value, err := factory.CreateEstimateDividendsService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
estimateDividendsService = value
_ = estimateDividendsService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 分红预算单仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err10 := factory.CreateDividendsEstimateRepository(map[string]interface{}{
... ... @@ -221,6 +233,23 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
if err14 := transactionContext.CommitTransaction(); err14 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err14.Error())
}
// 消息推送
var accountData []service.EstimateData
for _, detail := range creditAccount.AccountDetail {
accountData = append(accountData, service.EstimateData{
CreditAccountOrderNum: creditAccount.CreditAccountOrderNum,
SettlementAmount: fmt.Sprint(creditAccount.SettlementAmount),
CreditAccountId: creditAccount.CreditAccountId,
DividendsEstimateId: detail.DividendsEstimateOrderId,
DividendsEstimateOrderNumber: detail.DividendsEstimateOrderNumber,
UserId: creditAccount.Participator.UserId,
UserBaseId: creditAccount.Participator.UserBaseId,
OrgId: creditAccount.Org.OrgId,
CompanyId: creditAccount.Company.CompanyId,
})
}
return creditAccount, nil
}
}
... ... @@ -361,6 +390,17 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
dividendsEstimateRepository = value
}
// 账期支付消息推送领域服务初始化
var payCreditAccountService service.PayCreditAccountService
if value, err := factory.CreatePayCreditAccountService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
payCreditAccountService = value
_ = payCreditAccountService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 获取待支付的账期结算单
creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{
"creditAccountId": creditAccountId,
... ... @@ -406,6 +446,21 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
if err3 := transactionContext.CommitTransaction(); err3 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
}
// 支付消息推送
var payData []service.PayData
payData = append(payData, service.PayData{
CreditAccountOrderNum: creditAccountSaved.CreditAccountOrderNum,
SettlementAmount: fmt.Sprint(creditAccountSaved.SettlementAmount),
CreditAccountId: creditAccountSaved.CreditAccountId,
DividendsEstimateId: 0,
DividendsEstimateOrderNumber: "",
UserId: creditAccountSaved.Participator.UserId,
UserBaseId: creditAccountSaved.Participator.UserBaseId,
OrgId: creditAccountSaved.Org.OrgId,
CompanyId: creditAccountSaved.Company.CompanyId,
})
return creditAccountSaved, nil
}
}
... ...
... ... @@ -3,7 +3,6 @@ package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"github.com/linmadan/egglib-go/utils/tool_funs"
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command"
... ... @@ -542,6 +541,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 预算消息推送领域服务初始化
var informDividendsExpectedService service.InformDividendsExpectedService
if value, err := factory.CreateInformDividendsExpectedService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
informDividendsExpectedService = value
_ = informDividendsExpectedService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
... ... @@ -656,6 +666,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
cooperationContractRepository = 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
}
// 初始化确认业绩激励分红预算领域服务
var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{
... ... @@ -664,9 +684,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
confirmDividendsIncentivesEstimateService = value
_ = confirmDividendsIncentivesEstimateService.Subscribe(&subscriber.DividendsEstimateSubscriber{
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 统计成功预算的分红订单
... ... @@ -689,14 +706,21 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
var cooperationContractNumbers []string
orderGoodsMap := make(map[int64]*domain.OrderGood, 0)
// 获取订单产品合约编号
for _, orderGood := range orderGoods {
cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber)
orderGoodsMap[orderGood.OrderGoodId] = orderGood
}
newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers)
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
// 共创项目编号
var cooperationProjectNumbers []string
// 查询共创合约
startQueryContracts := time.Now()
... ... @@ -712,6 +736,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
if count > 0 {
for _, cooperationContractFound := range cooperationContractsFound {
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
cooperationProjectNumbers = append(cooperationProjectNumbers, cooperationContractFound.CooperationProjectNumber)
}
}
}
... ... @@ -720,6 +745,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
"report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"),
}, nil
}
newCooperationProjectNumbers := utils.RemoveDuplicationString(cooperationProjectNumbers)
fmt.Println("查询共创合约耗时:", time.Since(startQueryContracts))
// 统计当前企业分红预算单数
... ... @@ -996,6 +1024,24 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
fmt.Println("更新退货单耗时:", time.Since(startUpdateReturnedOrder))
// 查询共创项目
if len(newCooperationProjectNumbers) > 0 {
if countProject, cooperationProjectsFound, errFind := cooperationProjectRepository.Find(map[string]interface{}{
"cooperationProjectNumbers": newCooperationProjectNumbers,
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); errFind != nil {
return nil, errFind
} else {
if countProject > 0 {
for _, cooperationProjectFound := range cooperationProjectsFound {
cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound
}
}
}
}
startCommit := time.Now()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -1019,6 +1065,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
fmt.Println("函数执行完毕:", time.Since(start))
// 消息通知
var expectedData []service.ExpectedData
for _, dividendsEstimateSaved := range dividendsEstimatesSaved {
if dividendsEstimateSaved.DividendsParticipateType == 1 {
expectedData = append(expectedData, service.ExpectedData{
CreationContractId: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractId,
CreationContractName: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractName,
CreationContractNumber: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractNumber,
CreationProjectId: cooperationProjectsMap[cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationProjectNumber].CooperationProjectId,
CreationProjectName: cooperationProjectsMap[cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationProjectNumber].CooperationProjectName,
ProductName: orderGoodsMap[dividendsEstimateSaved.OrderGoodId].OrderGoodName,
UserId: dividendsEstimateSaved.DividendsUser.UserId,
UserBaseId: dividendsEstimateSaved.DividendsUser.UserBaseId,
OrgId: dividendsEstimateSaved.Org.OrgId,
CompanyId: dividendsEstimateSaved.Company.CompanyId,
DividendsEstimateId: dividendsEstimateSaved.DividendsEstimateId,
DividendsAmount: fmt.Sprint(dividendsEstimateSaved.DividendsAmount),
})
}
}
if err := informDividendsExpectedService.Expect(expectedData); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return map[string]interface{}{
"report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
}, nil
... ... @@ -1050,8 +1120,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
confirmMoneyIncentivesEstimateService = value
_ = confirmMoneyIncentivesEstimateService.Subscribe(&subscriber.DividendsEstimateSubscriber{
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
}
// 预算消息推送领域服务初始化
var informDividendsExpectedService service.InformDividendsExpectedService
if value, err := factory.CreateInformDividendsExpectedService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
informDividendsExpectedService = value
_ = informDividendsExpectedService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
... ... @@ -1065,6 +1143,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
cooperationContractRepository = 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
}
// 分红预算单DAO初始化
var dividendsEstimateDao *dao.DividendsEstimateDao
if value, err := factory.CreateDividendsEstimateDao(map[string]interface{}{
... ... @@ -1138,6 +1226,20 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationContractId, 10)))
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
"cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
"orgId": organization.OrgId,
"companyId": company.CompanyId,
})
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", cooperationContract.CooperationProjectNumber))
}
// 分红预算单
var dividendsEstimates []*domain.DividendsEstimate
// 统计当前分红预算单数
... ... @@ -1203,6 +1305,31 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 消息通知
var expectedData []service.ExpectedData
for _, dividendsEstimateSaved := range dividendsEstimatesSaved {
if dividendsEstimateSaved.DividendsParticipateType == 1 {
expectedData = append(expectedData, service.ExpectedData{
CreationContractId: cooperationContract.CooperationContractId,
CreationContractName: cooperationContract.CooperationContractName,
CreationContractNumber: cooperationContract.CooperationContractNumber,
CreationProjectId: cooperationProject.CooperationProjectId,
CreationProjectName: cooperationProject.CooperationProjectName,
ProductName: "",
UserId: dividendsEstimateSaved.DividendsUser.UserId,
UserBaseId: dividendsEstimateSaved.DividendsUser.UserBaseId,
OrgId: dividendsEstimateSaved.Org.OrgId,
CompanyId: dividendsEstimateSaved.Company.CompanyId,
DividendsEstimateId: dividendsEstimateSaved.DividendsEstimateId,
DividendsAmount: fmt.Sprint(dividendsEstimateSaved.DividendsAmount),
})
}
}
if err := informDividendsExpectedService.Expect(expectedData); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return dividendsEstimatesSaved, nil
}
return dividendsEstimatesSaved, nil
... ...
package subscriber
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type DividendsEstimateSubscriber struct {
TransactionContext *pgTransaction.TransactionContext
}
func (subscriber *DividendsEstimateSubscriber) HandleEvent(domainEvent coreDomain.DomainEvent) error {
return nil
}
func (subscriber *DividendsEstimateSubscriber) SubscribedToEventTypes() []string {
return []string{
//event.CONFERENCE_MESSAGE, // 日程预约消息通知
}
}
... ... @@ -140,10 +140,10 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
}
}
break
case event.DIVIDENDS_INFORM_EXPECTED: // 分红预算
dividendsInformExpectedEvent := domainEvent.(*event.DividendsInformExpected)
for _, expectedData := range dividendsInformExpectedEvent.DividendsInformExpectedData {
data, err6 := messageServiceGateway.InformExpectedDividends(
case event.INFORM_DIVIDENDS_EXPECTED: // 分红预算
dividendsInformExpectedEvent := domainEvent.(*event.InformDividendsExpected)
for _, expectedData := range dividendsInformExpectedEvent.DividendsExpectedInformData {
data, err6 := messageServiceGateway.InformDividendsExpected(
expectedData.CreationContractId,
expectedData.CreationContractName,
expectedData.CreationContractNumber,
... ... @@ -166,7 +166,6 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
log.Logger.Info("推送数据返回", data)
}
}
break
}
return nil
... ... @@ -179,6 +178,6 @@ func (subscriber *MessageServiceSubscriber) SubscribedToEventTypes() []string {
event.COOPERATION_APPLICATION_REJECTED, // 拒绝共创申请
event.CREDIT_ACCOUNT_PAID, // 账期支付
event.DIVIDENDS_ESTIMATED, // 账期结算
event.DIVIDENDS_INFORM_EXPECTED, // 分红预算
event.INFORM_DIVIDENDS_EXPECTED, // 分红预算
}
}
... ...
... ... @@ -73,5 +73,37 @@ func CreateRejectContractApplicationService(options map[string]interface{}) (*do
}
func CreateInformJoinCreationContractService(options map[string]interface{}) (*domain_service.InformJoinCreationContractService, error) {
//var transactionContext *pgTransaction.TransactionContext
//if value, ok := options["transactionContext"]; ok {
// transactionContext = value.(*pgTransaction.TransactionContext)
//}
//return domain_service.NewInformJoinCreationContractService(transactionContext)
return domain_service.NewInformJoinCreationContractService(nil)
}
func CreateEstimateDividendsService(options map[string]interface{}) (*domain_service.EstimateDividendsService, error) {
//var transactionContext *pgTransaction.TransactionContext
//if value, ok := options["transactionContext"]; ok {
// transactionContext = value.(*pgTransaction.TransactionContext)
//}
//return domain_service.NewEstimateDividendsService(transactionContext)
return domain_service.NewEstimateDividendsService(nil)
}
func CreateInformDividendsExpectedService(options map[string]interface{}) (*domain_service.InformDividendsExpectedService, error) {
//var transactionContext *pgTransaction.TransactionContext
//if value, ok := options["transactionContext"]; ok {
// transactionContext = value.(*pgTransaction.TransactionContext)
//}
//return domain_service.NewInformDividendsExpectedService(transactionContext)
return domain_service.NewInformDividendsExpectedService(nil)
}
func CreatePayCreditAccountService(options map[string]interface{}) (*domain_service.PayCreditAccountService, error) {
//var transactionContext *pgTransaction.TransactionContext
//if value, ok := options["transactionContext"]; ok {
// transactionContext = value.(*pgTransaction.TransactionContext)
//}
//return domain_service.NewPayCreditAccountService(transactionContext)
return domain_service.NewPayCreditAccountService(nil)
}
... ...
... ... @@ -2,9 +2,9 @@ package event
import coreDomain "github.com/linmadan/egglib-go/core/domain"
const DIVIDENDS_INFORM_EXPECTED = "dividends-inform-expected"
const INFORM_DIVIDENDS_EXPECTED = "inform-dividends-expected"
type DividendsInformExpectedData struct {
type DividendsExpectedInformData struct {
// 共创合约ID
CreationContractId int64 `json:"creationContractId"`
// 共创合约名称
... ... @@ -31,11 +31,11 @@ type DividendsInformExpectedData struct {
DividendsAmount string `json:"dividendsAmount"`
}
type DividendsInformExpected struct {
type InformDividendsExpected struct {
coreDomain.BaseEvent
DividendsInformExpectedData []DividendsInformExpectedData `json:"dividendsInformExpectedData"`
DividendsExpectedInformData []DividendsExpectedInformData `json:"dividendsExpectedInformData"`
}
func (event *DividendsInformExpected) EventType() string {
return DIVIDENDS_ESTIMATED
func (event *InformDividendsExpected) EventType() string {
return INFORM_DIVIDENDS_EXPECTED
}
... ...
package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type EstimateData struct {
CreditAccountOrderNum string
SettlementAmount string
CreditAccountId int64
DividendsEstimateId int64
DividendsEstimateOrderNumber string
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
}
type EstimateDividendsService interface {
coreDomain.DomainEventPublisher
Estimate([]EstimateData) error
}
... ...
package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type ExpectedData struct {
CreationContractId int64
CreationContractName string
CreationContractNumber string
CreationProjectId int64
CreationProjectName string
ProductName string
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
DividendsEstimateId int64
DividendsAmount string
}
type InformDividendsExpectedService interface {
coreDomain.DomainEventPublisher
Expect([]ExpectedData) error
}
... ...
package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type PayData struct {
CreditAccountOrderNum string
SettlementAmount string
CreditAccountId int64
DividendsEstimateId int64
DividendsEstimateOrderNumber string
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
}
type PayCreditAccountService interface {
coreDomain.DomainEventPublisher
Pay([]PayData) error
}
... ...
... ... @@ -12,6 +12,7 @@ type AgreeContractApplicationService struct {
//transactionContext *pgTransaction.TransactionContext
}
// 同意申请
func (service *AgreeContractApplicationService) Agree(data []service.AgreeData) error {
cooperationApplicationAgreedEvent := new(event.CooperationApplicationAgreed)
for _, cooperationApplicationAgreedData := range data {
... ...
package domain_service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type EstimateDividendsService struct {
coreDomain.BaseEventPublisher
//transactionContext *pgTransaction.TransactionContext
}
// 账期结算
func (service *EstimateDividendsService) Estimate(data []service.EstimateData) error {
dividendsEstimatedEvent := new(event.DividendsEstimated)
for _, dividendsEstimatedData := range data {
dividendsEstimatedEvent.DividendsEstimatedData = append(dividendsEstimatedEvent.DividendsEstimatedData, event.DividendsEstimatedData{
CreditAccountOrderNum: dividendsEstimatedData.CreditAccountOrderNum,
SettlementAmount: dividendsEstimatedData.SettlementAmount,
CreditAccountId: dividendsEstimatedData.CreditAccountId,
DividendsEstimateId: dividendsEstimatedData.DividendsEstimateId,
DividendsEstimateOrderNumber: dividendsEstimatedData.DividendsEstimateOrderNumber,
UserId: dividendsEstimatedData.UserId,
UserBaseId: dividendsEstimatedData.UserBaseId,
OrgId: dividendsEstimatedData.OrgId,
CompanyId: dividendsEstimatedData.CompanyId,
})
}
if err := service.Publish(dividendsEstimatedEvent); err != nil {
return err
}
return nil
}
func NewEstimateDividendsService(transactionContext *pgTransaction.TransactionContext) (*EstimateDividendsService, error) {
//if transactionContext == nil {
// return nil, fmt.Errorf("transactionContext参数不能为nil")
//} else {
// return &EstimateDividendsService{
// transactionContext: transactionContext,
// }, nil
//}
return &EstimateDividendsService{}, nil
}
... ...
package domain_service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type InformDividendsExpectedService struct {
coreDomain.BaseEventPublisher
//transactionContext *pgTransaction.TransactionContext
}
// 分红预算
func (service *InformDividendsExpectedService) Expect(data []service.ExpectedData) error {
dividendsExpectedInformEvent := new(event.InformDividendsExpected)
for _, dividendsExpectedInformedData := range data {
dividendsExpectedInformEvent.DividendsExpectedInformData = append(dividendsExpectedInformEvent.DividendsExpectedInformData, event.DividendsExpectedInformData{
CreationContractId: dividendsExpectedInformedData.CreationContractId,
CreationContractName: dividendsExpectedInformedData.CreationContractName,
CreationContractNumber: dividendsExpectedInformedData.CreationContractNumber,
CreationProjectId: dividendsExpectedInformedData.CreationProjectId,
CreationProjectName: dividendsExpectedInformedData.CreationProjectName,
ProductName: dividendsExpectedInformedData.ProductName,
UserId: dividendsExpectedInformedData.UserId,
UserBaseId: dividendsExpectedInformedData.UserBaseId,
OrgId: dividendsExpectedInformedData.OrgId,
CompanyId: dividendsExpectedInformedData.CompanyId,
DividendsEstimateId: dividendsExpectedInformedData.DividendsEstimateId,
DividendsAmount: dividendsExpectedInformedData.DividendsAmount,
})
}
if err := service.Publish(dividendsExpectedInformEvent); err != nil {
return err
}
return nil
}
func NewInformDividendsExpectedService(transactionContext *pgTransaction.TransactionContext) (*InformDividendsExpectedService, error) {
//if transactionContext == nil {
// return nil, fmt.Errorf("transactionContext参数不能为nil")
//} else {
// return &InformDividendsExpectedService{
// transactionContext: transactionContext,
// }, nil
//}
return &InformDividendsExpectedService{}, nil
}
... ...
... ... @@ -11,6 +11,7 @@ type InformJoinCreationContractService struct {
coreDomain.BaseEventPublisher
}
// 承接人加入共创
func (service *InformJoinCreationContractService) Join(data []service.JoinData) error {
creationContractInformJointEvent := new(event.CreationContractInformJoint)
for _, creationContractInformJointData := range data {
... ... @@ -34,5 +35,12 @@ func (service *InformJoinCreationContractService) Join(data []service.JoinData)
}
func NewInformJoinCreationContractService(transactionContext *pgTransaction.TransactionContext) (*InformJoinCreationContractService, error) {
//if transactionContext == nil {
// return nil, fmt.Errorf("transactionContext参数不能为nil")
//} else {
// return &InformJoinCreationContractService{
// transactionContext: transactionContext,
// }, nil
//}
return &InformJoinCreationContractService{}, nil
}
... ...
package domain_service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type PayCreditAccountService struct {
coreDomain.BaseEventPublisher
//transactionContext *pgTransaction.TransactionContext
}
// 账期支付
func (service *PayCreditAccountService) Pay(data []service.PayData) error {
creditAccountPaidEvent := new(event.CreditAccountPaid)
for _, creditAccountPaidData := range data {
creditAccountPaidEvent.CreditAccountPaidData = append(creditAccountPaidEvent.CreditAccountPaidData, event.CreditAccountPaidData{
CreditAccountOrderNum: creditAccountPaidData.CreditAccountOrderNum,
SettlementAmount: creditAccountPaidData.SettlementAmount,
CreditAccountId: creditAccountPaidData.CreditAccountId,
DividendsEstimateId: creditAccountPaidData.DividendsEstimateId,
DividendsEstimateOrderNumber: creditAccountPaidData.DividendsEstimateOrderNumber,
UserId: creditAccountPaidData.UserId,
UserBaseId: creditAccountPaidData.UserBaseId,
OrgId: creditAccountPaidData.OrgId,
CompanyId: creditAccountPaidData.CompanyId,
})
}
if err := service.Publish(creditAccountPaidEvent); err != nil {
return err
}
return nil
}
func NewPayCreditAccountService(transactionContext *pgTransaction.TransactionContext) (*PayCreditAccountService, error) {
//if transactionContext == nil {
// return nil, fmt.Errorf("transactionContext参数不能为nil")
//} else {
// return &PayCreditAccountService{
// transactionContext: transactionContext,
// }, nil
//}
return &PayCreditAccountService{}, nil
}
... ...
... ... @@ -12,6 +12,7 @@ type RejectContractApplicationService struct {
//transactionContext *pgTransaction.TransactionContext
}
// 拒绝申请
func (service *RejectContractApplicationService) Reject(data []service.RejectData) error {
cooperationApplicationRejectedEvent := new(event.CooperationApplicationRejected)
for _, cooperationApplicationRejectedData := range data {
... ...
... ... @@ -259,6 +259,9 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
query.Where("cooperation_project_number ilike ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber))
}
if cooperationProjectNumbers, ok := queryOptions["cooperationProjectNumbers"]; ok && len(cooperationProjectNumbers.([]string)) != 0 {
query.Where("cooperation_project_number in (?)", pg.In(cooperationProjectNumbers))
}
if keyword, ok := queryOptions["keyword"]; ok && keyword != "" {
query.Where("cooperation_project_description like ?", fmt.Sprintf("%%%s%%", keyword))
}
... ...
... ... @@ -76,36 +76,32 @@ func (serviceGateway *HttplibBasicServiceGateway) RejectCooperationApplication(
return data, err
}
// InformExpectedDividends 分红预算消息
func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends(
// InformJoinCreationContract 确认共创
func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
creationContractId int64,
creationContractName string,
creationContractNumber string,
creationProjectId int64,
creationProjectNumber string,
creationProjectName string,
productName string,
userId int64,
userBaseId int64,
orgId int64,
companyId int64,
dividendsEstimateId int64,
dividendsAmount string,
) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-expected-dividends"}, "/")
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-join-creation-contract"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["creationContractId"] = creationContractId
options["creationContractName"] = creationContractName
options["creationContractNumber"] = creationContractNumber
options["creationProjectId"] = creationProjectId
options["creationProjectNumber"] = creationProjectNumber
options["creationProjectName"] = creationProjectName
options["productName"] = productName
options["userId"] = userId
options["userBaseId"] = userBaseId
options["orgId"] = orgId
options["companyId"] = companyId
options["dividendsEstimateId"] = dividendsEstimateId
options["dividendsAmount"] = dividendsAmount
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
... ... @@ -119,32 +115,36 @@ func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends(
return data, err
}
// InformJoinCreationContract 确认共创
func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
// InformExpectedDividends 分红预算消息
func (serviceGateway *HttplibBasicServiceGateway) InformDividendsExpected(
creationContractId int64,
creationContractName string,
creationContractNumber string,
creationProjectId int64,
creationProjectNumber string,
creationProjectName string,
productName string,
userId int64,
userBaseId int64,
orgId int64,
companyId int64,
dividendsEstimateId int64,
dividendsAmount string,
) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-join-creation-contract"}, "/")
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-expected-dividends"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["creationContractId"] = creationContractId
options["creationContractName"] = creationContractName
options["creationContractNumber"] = creationContractNumber
options["creationProjectId"] = creationProjectId
options["creationProjectNumber"] = creationProjectNumber
options["creationProjectName"] = creationProjectName
options["productName"] = productName
options["userId"] = userId
options["userBaseId"] = userBaseId
options["orgId"] = orgId
options["companyId"] = companyId
options["dividendsEstimateId"] = dividendsEstimateId
options["dividendsAmount"] = dividendsAmount
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
... ... @@ -158,8 +158,8 @@ func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
return data, err
}
// PayCreditAccount 账期支付
func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount(
// DividendsEstimate 账期结算
func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate(
creditAccountOrderNum string,
settlementAmount string,
creditAccountId int64,
... ... @@ -170,7 +170,7 @@ func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount(
orgId int64,
companyId int64,
) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/notice-personal/credit-account/payment"}, "/")
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/credit-account/dividends-estimate"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["creditAccountOrderNum"] = creditAccountOrderNum
... ... @@ -195,8 +195,8 @@ func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount(
return data, err
}
// DividendsEstimate 分红预算
func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate(
// PayCreditAccount 账期支付
func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount(
creditAccountOrderNum string,
settlementAmount string,
creditAccountId int64,
... ... @@ -207,7 +207,7 @@ func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate(
orgId int64,
companyId int64,
) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/credit-account/dividends-estimate"}, "/")
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/notice-personal/credit-account/payment"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["creditAccountOrderNum"] = creditAccountOrderNum
... ...
... ... @@ -15,7 +15,7 @@ type UserServiceGateway interface {
type BasicServiceGateway interface {
AgreeCooperationApplication(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
RejectCooperationApplication(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
InformExpectedDividends(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectName string, productName string, userId int64, userBaseId int64, orgId int64, companyId int64, dividendsEstimateId int64, dividendsAmount string) (map[string]interface{}, error)
InformDividendsExpected(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectName string, productName string, userId int64, userBaseId int64, orgId int64, companyId int64, dividendsEstimateId int64, dividendsAmount string) (map[string]interface{}, error)
InformJoinCreationContract(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectNumber string, creationProjectName string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
PayCreditAccount(creditAccountOrderNum string, settlementAmount string, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
DividendsEstimate(creditAccountOrderNum string, settlementAmount string, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
... ...