作者 yangfu

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

…ion-cooperation into dev
正在显示 39 个修改的文件 包含 594 行增加123 行删除
... ... @@ -18,27 +18,6 @@ import (
type CooperationApplicationService struct {
}
// ApprovalCooperationApplication 审核共创申请
func (cooperationApplicationService *CooperationApplicationService) ApprovalCooperationApplication(approvalCooperationApplicationCommand *command.ApprovalCooperationApplicationCommand) (interface{}, error) {
if err := approvalCooperationApplicationCommand.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()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// ApplyForCooperation 申请共创
func (cooperationApplicationService *CooperationApplicationService) ApplyForCooperation(applyForCooperationCommand *command.ApplyForCooperationCommand) (interface{}, error) {
if err := applyForCooperationCommand.ValidateCommand(); err != nil {
... ... @@ -68,8 +47,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", applyForCooperationCommand.CooperationProjectNumber))
} else {
}
// 用户REST服务初始化
... ... @@ -156,9 +133,73 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
}
}
// BatchApprovalCooperationApplication 一键审核共创申请
func (cooperationApplicationService *CooperationApplicationService) BatchApprovalCooperationApplication(batchApprovalCooperatioinApplicatonCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {
if err := batchApprovalCooperatioinApplicatonCommand.ValidateCommand(); err != nil {
// ApprovalCooperationApplication 审核共创申请
func (cooperationApplicationService *CooperationApplicationService) ApprovalCooperationApplication(approvalCooperationApplicationCommand *command.ApprovalCooperationApplicationCommand) (interface{}, error) {
if err := approvalCooperationApplicationCommand.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()
}()
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
}
cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": approvalCooperationApplicationCommand.CooperationApplicationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(approvalCooperationApplicationCommand.CooperationApplicationId, 10)))
}
if err := cooperationApplication.Update(tool_funs.SimpleStructToMap(approvalCooperationApplicationCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if cooperationApplicationSaved, err := cooperationApplicationRepository.Save(cooperationApplication); 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 cooperationApplicationSaved, nil
}
}
// BatchApprovalCooperationApplication 批量审核共创申请
func (cooperationApplicationService *CooperationApplicationService) BatchApprovalCooperationApplication(batchApprovalCooperationApplicationCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {
if err := batchApprovalCooperationApplicationCommand.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()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// OneClickApprovalCooperationApplication 一键审核共创申请
func (cooperationApplicationService *CooperationApplicationService) OneClickApprovalCooperationApplication(oneClickApprovalCooperationApplicationCommand *command.OneClickApprovalCooperationApplicationCommand) (interface{}, error) {
if err := oneClickApprovalCooperationApplicationCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
... ...
... ... @@ -540,6 +540,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"reflect"
"strings"
... ... @@ -9,10 +10,14 @@ import (
)
type PayCreditAccountCommand struct {
// 账期结算单ID
CreditAccountId string `cname:"账期结算单ID" json:"creditAccountId" valid:"Required"`
// 账期结算实付金额
ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"`
// 备注
Remarks string `cname:"备注" json:"remarks" valid:"Required"`
// 支付凭证附件
PaymentDocumentAttachment *domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -15,7 +15,7 @@ type SearchCreditAccountQuery struct {
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 账期结算单号
CreditAccountOrderNum string `cname:"账期结算单号" json:"creditAccountOrderNum"`
CreditAccountOrderNum string `cname:"账期结算单号" json:"creditAccountOrderNum,omitempty"`
// 参与人姓名
ParticipatorName string `cname:"参与人姓名" json:"participatorName,omitempty"`
// 公司ID,通过集成REST上下文获取
... ...
... ... @@ -229,10 +229,34 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 参数类型转换
creditAccountId, _ := strconv.ParseInt(payCreditAccountCommand.CreditAccountId, 10, 64)
var creditAccountRepository domain.CreditAccountRepository
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
creditAccountRepository = value
}
creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{"creditAccountId": creditAccountId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if creditAccount == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(creditAccountId, 10)))
}
if err := creditAccount.Update(tool_funs.SimpleStructToMap(payCreditAccountCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if creditAccount, err := creditAccountRepository.Save(creditAccount); 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 nil, nil
return creditAccount, nil
}
}
// RemoveCreditAccount 移除账期结算单服务
... ... @@ -290,10 +314,27 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred
defer func() {
_ = transactionContext.RollbackTransaction()
}()
var creditAccountRepository domain.CreditAccountRepository
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
creditAccountRepository = value
}
if count, creditAccounts, err := creditAccountRepository.Find(tool_funs.SimpleStructToMap(searchCreditAccountQuery)); 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 nil, nil
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": creditAccounts,
},
}, nil
}
}
// UpdateCreditAccount 更新账期结算单服务
... ...
... ... @@ -11,7 +11,7 @@ import (
// CancelDividendsEstimateCommand 取消分红预算
type CancelDividendsEstimateCommand struct {
// 承接人分红预算记录ID
DividendsEstimateId string `cname:"承接人分红预算记录ID" json:"dividendsEstimateId" valid:"Required"`
DividendsEstimateId int64 `cname:"承接人分红预算记录ID" json:"dividendsEstimateId" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
... ... @@ -20,6 +20,8 @@ type CancelDividendsEstimateCommand struct {
UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
// 状态
IsCanceled bool `cname:"是否取消" json:"isCanceled,omitempty"`
}
func (cancelDividendsEstimateCommand *CancelDividendsEstimateCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -8,6 +8,8 @@ import (
type StageAndUndertaker struct {
// 分红阶段
Stage int32 `json:"stage"`
// 共创承接人
Undertakers []*domain.Undertaker `json:"undertakers"`
}
type MoneyIncentivesEstimateDto struct {
... ... @@ -18,11 +20,11 @@ type MoneyIncentivesEstimateDto struct {
// 共创合约名称
CooperationContractName string `json:"cooperationContractName"`
// 共创模式或者合伙模式
CooperationMode *domain.CooperationMode `json:"cooperationMode"`
CooperationModeName string `json:"cooperationMode"`
// 共创合约发起部门
Department *domain.Department `json:"department"`
// 共创合约发起人
CooperationContractSponsor *domain.User `json:"cooperationContractSponsor"`
CooperationContractSponsorName string `json:"cooperationContractSponsor"`
// 创建合约时间
CreatedAt time.Time `json:"createdAt"`
// 阶段和承接人
... ... @@ -31,5 +33,15 @@ type MoneyIncentivesEstimateDto struct {
func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error {
dto.CooperationContractId = contract.CooperationContractId
dto.CooperationContractNumber = contract.CooperationContractNumber
dto.CooperationContractName = contract.CooperationContractName
dto.CooperationModeName = contract.CooperationMode.CooperationModeName
dto.Department = contract.Department
dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName
dto.CreatedAt = contract.CreatedAt
dto.StageAndUndertaker = &StageAndUndertaker{
Stage: 0,
Undertakers: []*domain.Undertaker{},
}
return nil
}
... ...
... ... @@ -22,6 +22,8 @@ type ListMoneyIncentivesEstimateQuery struct {
UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
// 激励方式
IncentivesType int32 `cname:"激励方式" json:"incentivesType,omitempty"`
}
func (listMoneyIncentivesEstimateQuery *ListMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -11,9 +11,9 @@ import (
// SearchDividendsEstimateQuery 查询分红预算单
type SearchDividendsEstimateQuery struct {
// 承接人分红预算单号
DividendsEstimateOrderNumber string `cname:"承接人分红预算单号" json:"dividendsEstimateOrderNumber" valid:"Required"`
DividendsEstimateOrderNumber string `cname:"承接人分红预算单号" json:"dividendsEstimateOrderNumber,omitempty"`
// 分红类型,1订单分红,2退货冲销,3金额激励
DividendsType int32 `cname:"分红类型" json:"dividendsType" valid:"Required"`
DividendsType int32 `cname:"分红类型" json:"dividendsType,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -26,6 +26,8 @@ type SearchMoneyIncentivesEstimateQuery struct {
PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"`
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 激励方式
IncentivesType int32 `cname:"激励方式" json:"incentivesType,omitempty"`
}
func (searchMoneyIncentivesEstimateQuery *SearchMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -5,10 +5,12 @@ import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"strconv"
"time"
)
... ... @@ -32,10 +34,76 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红订单仓储初始化
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsOrderRepository = value
}
// 分红退货单仓储初始化
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsReturnedOrderRepository = value
}
// 订单产品仓储初始化
var orderGoodRepository domain.OrderGoodRepository
if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
orderGoodRepository = value
}
// 获取订单产品
if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(listDividendsIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var dividendsIncentivesEstimateDtos []*dto.DividendsIncentivesEstimateDto
for _, orderGood := range orderGoods {
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
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())
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
return map[string]interface{}{
"total": count,
"list": dividendsIncentivesEstimateDtos,
}, nil
}
}
// ListMoneyIncentivesEstimate 返回金额激励分红预算信息列表
... ... @@ -53,10 +121,38 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找共创合约
listMoneyIncentivesEstimateQuery.IncentivesType = 2
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
for _, cooperationContract := range cooperationContracts {
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": moneyIncentivesEstimateDtos,
},
}, nil
}
}
// CancelDividendsEstimate 取消分红预算单
... ... @@ -74,10 +170,37 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红预算仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimateRepository = value
}
dividendsEstimate, err := dividendsEstimateRepository.FindOne(map[string]interface{}{"dividendsEstimateId": cancelDividendsEstimateCommand.DividendsEstimateId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsEstimate == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelDividendsEstimateCommand.DividendsEstimateId, 10)))
}
// TODO 校验是否能够取消
// 设置取消状态
cancelDividendsEstimateCommand.IsCanceled = true
if err := dividendsEstimate.Update(tool_funs.SimpleStructToMap(cancelDividendsEstimateCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if dividendsEstimate, err := dividendsEstimateRepository.Save(dividendsEstimate); 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 nil, nil
return dividendsEstimate, nil
}
}
// BatchCancelDividendsEstimate 批量取消分红预算单
... ... @@ -95,10 +218,37 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红预算仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimateRepository = value
}
dividendsEstimateIds, _ := utils.SliceAtoi(batchCancelEstimateCommand.DividendsEstimateIds)
if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
"dividendsEstimateIds": dividendsEstimateIds,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for i, _ := range dividendsEstimates {
dividendsEstimates[i].IsCanceled = true
}
dividendsEstimatesCanceled, err := dividendsEstimateRepository.UpdateMany(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())
}
return nil, nil
return dividendsEstimatesCanceled, nil
} else {
return map[string]interface{}{}, nil
}
}
}
// CreateDividendsEstimate 创建分红预算单 (预留)
... ... @@ -297,6 +447,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsEstimate(
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红预算仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -375,10 +526,28 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红预算仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimateRepository = value
}
if count, dividendsEstimates, err := dividendsEstimateRepository.Find(tool_funs.SimpleStructToMap(searchDividendsEstimateQuery)); 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 nil, nil
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": dividendsEstimates,
},
}, nil
}
}
// SearchDividendsIncentivesEstimate 查询业绩激励分红预算
... ... @@ -396,10 +565,76 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红订单仓储初始化
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsOrderRepository = value
}
// 分红退货单仓储初始化
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsReturnedOrderRepository = value
}
// 订单产品仓储初始化
var orderGoodRepository domain.OrderGoodRepository
if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
orderGoodRepository = value
}
// 获取订单产品
if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(searchDividendsIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var dividendsIncentivesEstimateDtos []*dto.DividendsIncentivesEstimateDto
for _, orderGood := range orderGoods {
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
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())
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
return map[string]interface{}{
"total": count,
"list": dividendsIncentivesEstimateDtos,
}, nil
}
}
// SearchMoneyIncentivesEstimate 查询金额激励分红预算
... ... @@ -417,10 +652,38 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找共创合约
searchMoneyIncentivesEstimateQuery.IncentivesType = 2
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
for _, cooperationContract := range cooperationContracts {
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": moneyIncentivesEstimateDtos,
},
}, nil
}
}
// UpdateDividendsEstimate 更新分红预算单(预留)
... ...
... ... @@ -35,8 +35,6 @@ type CreateDividendsOrderCommand struct {
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"`
// 订单产品列表
... ...
... ... @@ -83,15 +83,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
operator = data
}
// 获取业务员
commandSalesmanUid, _ := strconv.ParseInt(createDividendsOrderCommand.SalesmanUid, 10, 64)
var salesman *domain.Salesman
if data, err := userService.SalesmanFrom(createDividendsOrderCommand.CompanyId, createDividendsOrderCommand.OrgId, commandSalesmanUid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
salesman = data
}
// 分红订单DAO初始化
var dividendsOrderDao *dao.DividendsOrderDao
if value, err := factory.CreateDividendsOrderDao(map[string]interface{}{
... ... @@ -154,7 +145,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
DividendsOrderNumber: dividendsOrderNumber,
DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
DividendsOrderAmount: dividendsOrderAmount,
OrderSalesman: salesman,
OrderTime: orderTime,
DividendTime: time.Time{},
DividendStatus: 0,
... ... @@ -260,8 +250,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi
}
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": dividendsOrders,
"total": count, "list": dividendsOrders,
},
}, nil
}
... ...
... ... @@ -40,6 +40,7 @@ type CooperationApplication struct {
type CooperationApplicationRepository interface {
Save(cooperationApplication *CooperationApplication) (*CooperationApplication, error)
UpdateMany(cooperationApplications []*CooperationApplication) ([]*CooperationApplication, error)
Remove(cooperationApplication *CooperationApplication) (*CooperationApplication, error)
FindOne(queryOptions map[string]interface{}) (*CooperationApplication, error)
Find(queryOptions map[string]interface{}) (int64, []*CooperationApplication, error)
... ...
... ... @@ -36,6 +36,8 @@ type CooperationContract struct {
DividendsIncentivesRules []*DividendsIncentivesRule `json:"dividendsIncentivesRules"`
// 金额激励规则
MoneyIncentivesRules []*MoneyIncentivesRule `json:"moneyIncentivesRules"`
// 激励方式,1业绩分红激励,2金额激励
IncentivesType int32 `json:"incentivesType"`
// 共创承接人列表
Undertakers []*Undertaker `json:"undertakers"`
// 共创合约相关人列表
... ...
... ... @@ -42,6 +42,8 @@ type CreditAccount struct {
DeletedAt time.Time `json:"deletedAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
//备注
Remarks string `json:"remarks"`
}
type CreditAccountRepository interface {
... ... @@ -68,5 +70,14 @@ func (creditAccount *CreditAccount) Update(data map[string]interface{}) error {
if paymentStatus, ok := data["paymentStatus"]; ok {
creditAccount.PaymentStatus = paymentStatus.(int32)
}
if paymentDocumentAttachment, ok := data["paymentDocumentAttachment"]; ok {
creditAccount.PaymentDocumentAttachment = paymentDocumentAttachment.(*Attachment)
}
if remarks, ok := data["remarks"]; ok {
creditAccount.Remarks = remarks.(string)
}
if actuallyPaidAmount, ok := data["actuallyPaidAmount"]; ok {
creditAccount.ActuallyPaidAmount = actuallyPaidAmount.(float64)
}
return nil
}
... ...
... ... @@ -46,6 +46,8 @@ type DividendsEstimate struct {
Operator *User `json:"operator"`
// 操作时间
OperateTime time.Time `json:"operateTime"`
// 取消状态
IsCanceled bool `json:"isCanceled"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 删除时间
... ... @@ -94,5 +96,8 @@ func (dividendsEstimate *DividendsEstimate) Update(data map[string]interface{})
if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok {
dividendsEstimate.CooperationContractNumber = cooperationProjectNumber.(string)
}
if isCanceled, ok := data["isCanceled"]; ok {
dividendsEstimate.IsCanceled = isCanceled.(bool)
}
return nil
}
... ...
... ... @@ -12,9 +12,7 @@ type DividendsOrder struct {
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
// 分红订单金额
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
// 订单业务员
OrderSalesman *Salesman `json:"orderSalesman"`
// 订单产生时间
// 订单日期
OrderTime time.Time `json:"orderTime"`
// 分红订单分红时间
DividendTime time.Time `json:"dividendTime"`
... ... @@ -69,45 +67,6 @@ func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error
if dividendsOrderAmount, ok := data["dividendsOrderAmount"]; ok {
dividendsOrder.DividendsOrderAmount = dividendsOrderAmount.(float64)
}
if userId, ok := data["userId"]; ok {
dividendsOrder.OrderSalesman.UserId = userId.(int64)
}
if userBaseId, ok := data["userBaseId"]; ok {
dividendsOrder.OrderSalesman.UserBaseId = userBaseId.(int64)
}
if orgId, ok := data["orgId"]; ok {
dividendsOrder.OrderSalesman.Org.OrgId = orgId.(int64)
}
if orgName, ok := data["orgName"]; ok {
dividendsOrder.OrderSalesman.Org.OrgName = orgName.(string)
}
if companyId, ok := data["companyId"]; ok {
dividendsOrder.OrderSalesman.Org.Company.CompanyId = companyId.(int64)
}
if companyLogo, ok := data["companyLogo"]; ok {
dividendsOrder.OrderSalesman.Org.Company.CompanyLogo = companyLogo.(string)
}
if companyName, ok := data["companyName"]; ok {
dividendsOrder.OrderSalesman.Org.Company.CompanyName = companyName.(string)
}
if userAvatar, ok := data["userAvatar"]; ok {
dividendsOrder.OrderSalesman.UserInfo.UserAvatar = userAvatar.(string)
}
if userEmail, ok := data["userEmail"]; ok {
dividendsOrder.OrderSalesman.UserInfo.UserEmail = userEmail.(string)
}
if userName, ok := data["userName"]; ok {
dividendsOrder.OrderSalesman.UserInfo.UserName = userName.(string)
}
if userPhone, ok := data["userPhone"]; ok {
dividendsOrder.OrderSalesman.UserInfo.UserPhone = userPhone.(string)
}
if userAccount, ok := data["userAccount"]; ok {
dividendsOrder.OrderSalesman.UserInfo.UserAccount = userAccount.(string)
}
if userType, ok := data["userType"]; ok {
dividendsOrder.OrderSalesman.UserType = userType.(int32)
}
if orderTime, ok := data["orderTime"]; ok {
dividendsOrder.OrderTime = orderTime.(time.Time)
}
... ...
... ... @@ -16,6 +16,8 @@ type DividendsReturnedOrder struct {
DividendsOrderNumber string `json:"dividendsOrderNumber"`
// 退货客户姓名
DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"`
// 订单日期
OrderTime time.Time `json:"orderTime"`
// 退货日期
DividendsReturnedDate time.Time `json:"dividendsReturnedDate"`
// 退货区域
... ... @@ -60,9 +62,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} {
}
func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error {
if dividendsReturnedOrderNumber, ok := data["dividendsReturnedOrderNumber"]; ok {
dividendsReturnedOrder.DividendsReturnedOrderNumber = dividendsReturnedOrderNumber.(string)
}
if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok {
dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64)
}
... ...
... ... @@ -23,10 +23,12 @@ type CooperationContract struct {
CooperationContractSponsor *domain.User `comment:"共创合约发起人"`
// 共创模式编号
CooperationModeNumber string `comment:"共创模式编号"`
// 合约状态,1启用,2禁用
Status int32 `comment:"合约状态,1启用,2禁用"`
// 合约状态,1正常,2暂停
Status int32 `comment:"合约状态,1正常,2暂停"`
// 数据所属组织机构
Org *domain.Org `comment:"数据所属组织机构"`
// 激励方式,1业绩分红激励,2金额激励
IncentivesType int32 `comment:"激励方式"`
// 公司
Company *domain.Company `comment:"公司"`
// 共创合约发起部门
... ...
... ... @@ -23,8 +23,8 @@ type CreditAccount struct {
SettlementTime time.Time `comment:"共创账期结算时间"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 参与人uid,包括承接人、推荐人、关联业务员
Participator *domain.Participator `comment:"参与人uid,包括承接人、推荐人、关联业务员" pg:",array"`
// 参与人,包括承接人、推荐人、关联业务员
Participator *domain.Participator `comment:"参与人,包括承接人、推荐人、关联业务员"`
// 参与类型
ParticipateType string `comment:"参与类型,承接人,推荐人,业务员"`
// 结算明细
... ... @@ -45,4 +45,6 @@ type CreditAccount struct {
DeletedAt time.Time `comment:"删除时间"`
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 备注
Remarks string `comment:"备注"`
}
... ...
... ... @@ -37,6 +37,8 @@ type DividendsEstimate struct {
Operator *domain.User `comment:"操作人"`
// 操作时间
OperateTime time.Time `comment:"操作时间"`
// 取消状态
IsCanceled bool `comment:"取消状态"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 删除时间
... ...
... ... @@ -15,8 +15,6 @@ type DividendsOrder struct {
DividendsOriginalOrderNum string `comment:"分红订单原单号"`
// 分红订单金额
DividendsOrderAmount float64 `comment:"分红订单金额"`
// 订单业务员
OrderSalesman *domain.Salesman `comment:"订单业务员"`
// 订单产生时间
OrderTime time.Time `comment:"订单产生时间"`
// 分红订单分红时间
... ...
... ... @@ -19,6 +19,8 @@ type DividendsReturnedOrder struct {
DividendsOrderNumber string `comment:"关联分红订单号"`
// 退货客户姓名
DividendsReturnedCustomerName string `comment:"退货客户姓名"`
// 订单日期
OrderTime time.Time `comment:"订单日期"`
// 退货日期
DividendsReturnedDate time.Time `comment:"退货日期"`
// 退货区域
... ...
... ... @@ -118,6 +118,7 @@ func TransformToCooperationContractDomainModelFromPgModels(
RelevantPeople: relevantPeopleDomain,
Undertakers: undertakersDomain,
Status: cooperationContractModel.Status,
IncentivesType: cooperationContractModel.IncentivesType,
Org: cooperationContractModel.Org,
Company: cooperationContractModel.Company,
Department: cooperationContractModel.Department,
... ...
... ... @@ -26,5 +26,6 @@ func TransformToCreditAccountDomainModelFromPgModels(creditAccountModel *models.
CreatedAt: creditAccountModel.CreatedAt,
DeletedAt: creditAccountModel.DeletedAt,
UpdatedAt: creditAccountModel.UpdatedAt,
Remarks: creditAccountModel.Remarks,
}, nil
}
... ...
... ... @@ -22,6 +22,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel
Company: dividendsEstimateModel.Company,
Operator: dividendsEstimateModel.Operator,
OperateTime: dividendsEstimateModel.OperateTime,
IsCanceled: dividendsEstimateModel.IsCanceled,
CreatedAt: dividendsEstimateModel.CreatedAt,
DeletedAt: dividendsEstimateModel.DeletedAt,
UpdatedAt: dividendsEstimateModel.UpdatedAt,
... ...
... ... @@ -28,7 +28,6 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model
DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber,
DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum,
DividendsOrderAmount: dividendsOrderModel.DividendsOrderAmount,
OrderSalesman: dividendsOrderModel.OrderSalesman,
OrderTime: dividendsOrderModel.OrderTime,
DividendTime: dividendsOrderModel.DividendTime,
DividendStatus: dividendsOrderModel.DividendStatus,
... ...
... ... @@ -32,6 +32,7 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels(
OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum,
DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber,
DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName,
OrderTime: dividendsReturnedOrderModel.OrderTime,
DividendsReturnedDate: dividendsReturnedOrderModel.DividendsReturnedDate,
Region: dividendsReturnedOrderModel.Region,
Remarks: dividendsReturnedOrderModel.Remarks,
... ...
... ... @@ -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"
... ... @@ -141,6 +142,35 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
return cooperationApplication, nil
}
func (repository *CooperationApplicationRepository) UpdateMany(cooperationApplications []*domain.CooperationApplication) ([]*domain.CooperationApplication, error) {
tx := repository.transactionContext.PgTx
var cooperationApplicationModels []*models.CooperationApplication
for _, cooperationApplication := range cooperationApplications {
cooperationApplicationModels = append(cooperationApplicationModels, &models.CooperationApplication{
CooperationApplicationId: cooperationApplication.CooperationApplicationId,
CooperationApplicationApplicant: cooperationApplication.CooperationApplicationApplicant,
CooperationApplicationAttachment: cooperationApplication.CooperationApplicationAttachment,
CooperationApplicationDescription: cooperationApplication.CooperationApplicationDescription,
CooperationApplicationStatus: cooperationApplication.CooperationApplicationStatus,
CooperationApplicationVerifier: cooperationApplication.CooperationApplicationVerifier,
CooperationApplicationVerifyDescription: cooperationApplication.CooperationApplicationVerifyDescription,
CooperationApplicationVerifyTime: cooperationApplication.CooperationApplicationVerifyTime,
CooperationApplyTime: cooperationApplication.CooperationApplyTime,
CooperationProjectNumber: cooperationApplication.CooperationProject.CooperationProjectNumber,
Org: cooperationApplication.Org,
IsCanceled: cooperationApplication.IsCanceled,
Company: cooperationApplication.Company,
CreatedAt: cooperationApplication.CreatedAt,
DeletedAt: cooperationApplication.DeletedAt,
UpdatedAt: time.Now(),
})
}
if _, err := tx.Model(&cooperationApplicationModels).WherePK().Update(); err != nil {
return nil, err
}
return cooperationApplications, nil
}
func (repository *CooperationApplicationRepository) Remove(cooperationApplication *domain.CooperationApplication) (*domain.CooperationApplication, error) {
tx := repository.transactionContext.PgTx
cooperationApplicationModel := new(models.CooperationApplication)
... ... @@ -194,7 +224,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName))
}
if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 {
query.Where("cooperation_application_status = ?", cooperationApplicationStatus)
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
... ...
... ... @@ -38,6 +38,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
"cooperation_mode_number",
"status",
"org",
"incentives_type",
"company",
"operator",
"operate_time",
... ... @@ -70,6 +71,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
&cooperationContract.CooperationMode.CooperationModeNumber,
&cooperationContract.Status,
&cooperationContract.Org,
&cooperationContract.IncentivesType,
&cooperationContract.Company,
&cooperationContract.Operator,
&cooperationContract.OperateTime,
... ... @@ -88,6 +90,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
cooperationContract.CooperationMode.CooperationModeNumber,
cooperationContract.Status,
cooperationContract.Org,
cooperationContract.IncentivesType,
cooperationContract.Company,
cooperationContract.Operator,
cooperationContract.OperateTime,
... ... @@ -213,6 +216,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
&cooperationContract.CooperationMode.CooperationModeNumber,
&cooperationContract.Status,
&cooperationContract.Org,
&cooperationContract.IncentivesType,
&cooperationContract.Company,
&cooperationContract.Operator,
&cooperationContract.OperateTime,
... ... @@ -231,6 +235,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
cooperationContract.CooperationMode.CooperationModeNumber,
cooperationContract.Status,
cooperationContract.Org,
cooperationContract.IncentivesType,
cooperationContract.Company,
cooperationContract.Operator,
cooperationContract.OperateTime,
... ... @@ -826,7 +831,13 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
cooperationContracts := make([]*domain.CooperationContract, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractModels), queryOptions)
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
}
if cooperationContractName, ok := queryOptions["cooperationContactName"]; ok && cooperationContractName != "" {
query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
}
if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
query.Where(`(cooperation_contract.department->>'departmentName')::test LIKE ?`, fmt.Sprintf("%%%s%%", departmentName))
}
if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
... ... @@ -834,6 +845,15 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 {
query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds))
}
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 incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
query.Where("incentives_type = ?", incentivesType)
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -46,6 +46,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
"created_at",
"deleted_at",
"updated_at",
"remarks",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
... ... @@ -81,6 +82,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
&creditAccount.CreatedAt,
&creditAccount.DeletedAt,
&creditAccount.UpdatedAt,
&creditAccount.Remarks,
),
fmt.Sprintf("INSERT INTO credit_accounts (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
creditAccount.CreditAccountId,
... ... @@ -100,8 +102,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
creditAccount.Operator,
creditAccount.OperateTime,
creditAccount.CreatedAt,
creditAccount.DeletedAt,
nil,
creditAccount.UpdatedAt,
creditAccount.Remarks,
); err != nil {
return creditAccount, err
}
... ... @@ -127,6 +130,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
&creditAccount.CreatedAt,
&creditAccount.DeletedAt,
&creditAccount.UpdatedAt,
&creditAccount.Remarks,
),
fmt.Sprintf("UPDATE credit_accounts SET %s WHERE credit_account_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
creditAccount.CreditAccountId,
... ... @@ -146,8 +150,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
creditAccount.Operator,
creditAccount.OperateTime,
creditAccount.CreatedAt,
creditAccount.DeletedAt,
nil,
creditAccount.UpdatedAt,
creditAccount.Remarks,
creditAccount.Identify(),
); err != nil {
return creditAccount, err
... ... @@ -190,6 +195,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
var creditAccountModels []*models.CreditAccount
creditAccounts := make([]*domain.CreditAccount, 0)
query := sqlbuilder.BuildQuery(tx.Model(&creditAccountModels), queryOptions)
if creditAccountOrderNum, ok := queryOptions["creditAccountOrderNum"]; ok && creditAccountOrderNum != "" {
query.Where("credit_account_order_num ilike ?", fmt.Sprintf("%%%s%%", creditAccountOrderNum))
}
if participatorName, ok := queryOptions["participatorName"]; ok && participatorName != "" {
query.Where(`(credit_account.participator->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", participatorName))
}
if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
query.Where("payment_status = ?", paymentStatus)
}
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"
... ... @@ -42,6 +43,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
"company",
"operator",
"operate_time",
"is_canceled",
"created_at",
"deleted_at",
"updated_at",
... ... @@ -76,6 +78,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
&dividendsEstimate.Company,
&dividendsEstimate.Operator,
&dividendsEstimate.OperateTime,
&dividendsEstimate.IsCanceled,
&dividendsEstimate.CreatedAt,
&dividendsEstimate.DeletedAt,
&dividendsEstimate.UpdatedAt,
... ... @@ -96,8 +99,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
dividendsEstimate.Company,
dividendsEstimate.Operator,
dividendsEstimate.OperateTime,
dividendsEstimate.IsCanceled,
dividendsEstimate.CreatedAt,
dividendsEstimate.DeletedAt,
nil,
dividendsEstimate.UpdatedAt,
); err != nil {
return dividendsEstimate, err
... ... @@ -120,6 +124,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
&dividendsEstimate.Company,
&dividendsEstimate.Operator,
&dividendsEstimate.OperateTime,
&dividendsEstimate.IsCanceled,
&dividendsEstimate.CreatedAt,
&dividendsEstimate.DeletedAt,
&dividendsEstimate.UpdatedAt,
... ... @@ -140,8 +145,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
dividendsEstimate.Company,
dividendsEstimate.Operator,
dividendsEstimate.OperateTime,
dividendsEstimate.IsCanceled,
dividendsEstimate.CreatedAt,
dividendsEstimate.DeletedAt,
nil,
dividendsEstimate.UpdatedAt,
dividendsEstimate.Identify(),
); err != nil {
... ... @@ -152,7 +158,35 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
}
func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) {
panic("implement me")
tx := repository.transactionContext.PgTx
var dividendsEstimateModels []*models.DividendsEstimate
for _, dividendsEstimate := range dividendsEstimates {
dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{
DividendsEstimateId: dividendsEstimate.DividendsEstimateId,
DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus,
DividendsAmount: dividendsEstimate.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime,
DividendsParticipateType: dividendsEstimate.DividendsParticipateType,
DividendsType: dividendsEstimate.DividendsType,
OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
DividendsUser: dividendsEstimate.DividendsUser,
DividendsStage: dividendsEstimate.DividendsStage,
Org: dividendsEstimate.Org,
Company: dividendsEstimate.Company,
Operator: dividendsEstimate.Operator,
OperateTime: dividendsEstimate.OperateTime,
IsCanceled: dividendsEstimate.IsCanceled,
CreatedAt: dividendsEstimate.CreatedAt,
DeletedAt: dividendsEstimate.DeletedAt,
UpdatedAt: time.Now(),
})
}
if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil {
return nil, err
}
return dividendsEstimates, nil
}
func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) {
... ... @@ -189,6 +223,12 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
var dividendsEstimateModels []*models.DividendsEstimate
dividendsEstimates := make([]*domain.DividendsEstimate, 0)
query := sqlbuilder.BuildQuery(tx.Model(&dividendsEstimateModels), queryOptions)
if dividendsType, ok := queryOptions["dividendsType"]; ok && dividendsType.(int32) != 0 {
query.Where("dividends_type = ?", dividendsType)
}
if dividendsEstimateOrderNumber, ok := queryOptions["dividendsEstimateOrderNumber"]; ok && dividendsEstimateOrderNumber != "" {
query.Where("dividends_estimate_order_number ilike ?", fmt.Sprintf("%%%s%%", dividendsEstimateOrderNumber))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -33,7 +33,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
"dividends_order_number",
"dividends_original_order_num",
"dividends_order_amount",
"order_salesman",
"order_time",
"dividend_time",
"dividend_status",
... ... @@ -67,7 +66,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
&dividendsOrder.DividendsOrderNumber,
&dividendsOrder.DividendsOriginalOrderNum,
&dividendsOrder.DividendsOrderAmount,
&dividendsOrder.OrderSalesman,
&dividendsOrder.OrderTime,
&dividendsOrder.DividendTime,
&dividendsOrder.DividendStatus,
... ... @@ -87,7 +85,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
dividendsOrder.DividendsOrderNumber,
dividendsOrder.DividendsOriginalOrderNum,
dividendsOrder.DividendsOrderAmount,
dividendsOrder.OrderSalesman,
dividendsOrder.OrderTime,
dividendsOrder.DividendTime,
dividendsOrder.DividendStatus,
... ... @@ -131,7 +128,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
&dividendsOrder.DividendsOrderNumber,
&dividendsOrder.DividendsOriginalOrderNum,
&dividendsOrder.DividendsOrderAmount,
&dividendsOrder.OrderSalesman,
&dividendsOrder.OrderTime,
&dividendsOrder.DividendTime,
&dividendsOrder.DividendStatus,
... ... @@ -151,7 +147,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
dividendsOrder.DividendsOrderNumber,
dividendsOrder.DividendsOriginalOrderNum,
dividendsOrder.DividendsOrderAmount,
dividendsOrder.OrderSalesman,
dividendsOrder.OrderTime,
dividendsOrder.DividendTime,
dividendsOrder.DividendStatus,
... ...
... ... @@ -35,6 +35,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
"original_order_num",
"dividends_order_number",
"dividends_returned_customer_name",
"order_time",
"dividends_returned_date",
"region",
"remarks",
... ... @@ -69,6 +70,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
&dividendsReturnedOrder.OriginalOrderNum,
&dividendsReturnedOrder.DividendsOrderNumber,
&dividendsReturnedOrder.DividendsReturnedCustomerName,
&dividendsReturnedOrder.OrderTime,
&dividendsReturnedOrder.DividendsReturnedDate,
&dividendsReturnedOrder.Region,
&dividendsReturnedOrder.Remarks,
... ... @@ -89,6 +91,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
dividendsReturnedOrder.OriginalOrderNum,
dividendsReturnedOrder.DividendsOrderNumber,
dividendsReturnedOrder.DividendsReturnedCustomerName,
dividendsReturnedOrder.OrderTime,
dividendsReturnedOrder.DividendsReturnedDate,
dividendsReturnedOrder.Region,
dividendsReturnedOrder.Remarks,
... ... @@ -135,6 +138,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
&dividendsReturnedOrder.OriginalOrderNum,
&dividendsReturnedOrder.DividendsOrderNumber,
&dividendsReturnedOrder.DividendsReturnedCustomerName,
&dividendsReturnedOrder.OrderTime,
&dividendsReturnedOrder.DividendsReturnedDate,
&dividendsReturnedOrder.Region,
&dividendsReturnedOrder.Remarks,
... ... @@ -155,6 +159,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
dividendsReturnedOrder.OriginalOrderNum,
dividendsReturnedOrder.DividendsOrderNumber,
dividendsReturnedOrder.DividendsReturnedCustomerName,
dividendsReturnedOrder.OrderTime,
dividendsReturnedOrder.DividendsReturnedDate,
dividendsReturnedOrder.Region,
dividendsReturnedOrder.Remarks,
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"fmt"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
... ... @@ -164,6 +165,16 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
var orderGoodModels []*models.OrderGood
orderGoods := make([]*domain.OrderGood, 0)
query := sqlbuilder.BuildQuery(tx.Model(&orderGoodModels), queryOptions)
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
}
if orderOrReturnedOrderNum, ok := queryOptions["orderOrReturnedOrderNum"]; ok && orderOrReturnedOrderNum != "" {
query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
q.WhereOr("dividends_order_number ilike ?", fmt.Sprintf("%%%s%%", orderOrReturnedOrderNum))
q.WhereOr("dividends_returned_order_number ilike ?", fmt.Sprintf("%%%s%%", orderOrReturnedOrderNum))
return q, nil
})
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -62,6 +62,19 @@ func (controller *CooperationContractController) BatchApprovalCooperationApplica
controller.Response(data, err)
}
func (controller *CooperationApplicationController) OneClickApprovalCooperationApplication() {
cooperationApplicationService := service.NewCooperationApplicationService(nil)
oneClickApprovalCooperationApplicationCommand := &command.OneClickApprovalCooperationApplicationCommand{}
_ = controller.Unmarshal(oneClickApprovalCooperationApplicationCommand)
header := controller.GetRequestHeader(controller.Ctx)
oneClickApprovalCooperationApplicationCommand.CompanyId = header.CompanyId
oneClickApprovalCooperationApplicationCommand.OrgId = header.OrgId
oneClickApprovalCooperationApplicationCommand.UserId = header.UserId
oneClickApprovalCooperationApplicationCommand.UserBaseId = header.UserBaseId
data, err := cooperationApplicationService.OneClickApprovalCooperationApplication(oneClickApprovalCooperationApplicationCommand)
controller.Response(data, err)
}
func (controller *CooperationApplicationController) CreateCooperationApplication() {
cooperationApplicationService := service.NewCooperationApplicationService(nil)
createCooperationApplicationCommand := &command.CreateCooperationApplicationCommand{}
... ...
... ... @@ -81,7 +81,7 @@ func (controller *DividendsEstimateController) CancelDividendsEstimate() {
cancelDividendsEstimateCommand.OrgId = header.OrgId
cancelDividendsEstimateCommand.UserId = header.UserId
cancelDividendsEstimateCommand.UserBaseId = header.UserBaseId
dividendsEstimateId := controller.GetString(":dividendsEstimateId")
dividendsEstimateId, _ := controller.GetInt64(":dividendsEstimateId")
cancelDividendsEstimateCommand.DividendsEstimateId = dividendsEstimateId
data, err := dividendsEstimateService.CancelDividendsEstimate(cancelDividendsEstimateCommand)
controller.Response(data, err)
... ...
... ... @@ -7,9 +7,10 @@ import (
func init() {
web.Router("/cooperation-applications/apply-for-cooperation", &controllers.CooperationApplicationController{}, "Post:ApplyForCooperation") // 申请共创
web.Router("/cooperation-applications/cancel-application", &controllers.CooperationApplicationController{}, "Post:CancelCooperationApplication")
web.Router("/cooperation-applications/agree-cooperation-application", &controllers.CooperationApplicationController{}, "Post:ApprovalCooperationApplication") // 同意共创申请
web.Router("/cooperation-applications/batch-approval", &controllers.CooperationContractController{}, "Post:BatchApprovalCooperationApplication") // 一键审核
web.Router("/cooperation-applications/cancel-application", &controllers.CooperationApplicationController{}, "Post:CancelCooperationApplication") // 取消共创申请
web.Router("/cooperation-applications/approval-cooperation-application", &controllers.CooperationApplicationController{}, "Post:ApprovalCooperationApplication") // 同意共创申请
web.Router("/cooperation-applications/batch-approval", &controllers.CooperationContractController{}, "Post:BatchApprovalCooperationApplication") // 批量审核共创申请
web.Router("/cooperation-applications/oneclick-approval", &controllers.CooperationApplicationController{}, "Post:OneClickApprovalCooperationApplication") // 一键审核共创申请
web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Post:CreateCooperationApplication") // 新增共创申请
web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Put:UpdateCooperationApplication") // 编辑共创申请
web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Get:GetCooperationApplication") // 获取共创申请详情
... ...