作者 陈志颖

fix:分红订单参数调整

... ... @@ -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(batchApprovalCooperationApplicatonCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {
if err := batchApprovalCooperationApplicatonCommand.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)
... ...
... ... @@ -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,
... ...
... ... @@ -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)
... ...
... ... @@ -12,8 +12,6 @@ type DividendsOrder struct {
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
// 分红订单金额
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
// 订单业务员
OrderSalesman *Salesman `json:"orderSalesman"`
// 订单日期
OrderTime time.Time `json:"orderTime"`
// 分红订单分红时间
... ... @@ -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)
}
... ...
... ... @@ -15,8 +15,6 @@ type DividendsOrder struct {
DividendsOriginalOrderNum string `comment:"分红订单原单号"`
// 分红订单金额
DividendsOrderAmount float64 `comment:"分红订单金额"`
// 订单业务员
OrderSalesman *domain.Salesman `comment:"订单业务员"`
// 订单产生时间
OrderTime time.Time `comment:"订单产生时间"`
// 分红订单分红时间
... ...
... ... @@ -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,
... ...
... ... @@ -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)
... ...
... ... @@ -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,
... ...
... ... @@ -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{}
... ...
... ... @@ -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") // 获取共创申请详情
... ...