作者 tangxuhui

更新

package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CreateDividendsOrderCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//客户名称
CustomerName string `json:"customerName" valid:"Required"`
//分红订单金额
DividendsOrderAmount float64 `json:"dividendsOrderAmount" valid:"Required"`
//分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber" valid:"Required"`
//分红订单原单号
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum" valid:"Required"`
//订单产生时间 时间戳 秒
OrderTime int64 `json:"orderTime" valid:"Required"`
//备注
Remarks string `json:"remarks" valid:"Required"`
//订单业务员uid
SalesmanUid string `json:"salesmanUid"`
//订单操作人uid
OperatorUid string `json:"operatorUid"`
//区域名称
RegionName string `json:"regionName"`
//订单产品列表
OrderGoods []struct {
CooperationContractNumber string `json:"cooperationContractNumber"` //关联的共创合约编号
DividendsOrderNumber string `json:"dividendsOrderNumber"` //关联分红订单号
OrderGoodAmount float64 `json:"orderGoodAmount"` //订单产品金额
OrderGoodExpense float64 `json:"orderGoodExpense"` //订单产品费用
OrderGoodName string `json:"orderGoodName"` //订单产品名称
OrderGoodPrice float64 `json:"orderGoodPrice"` //订单产品单价
OrderGoodQuantity int `json:"orderGoodQuantity"` //订单产品数量
} `json:"orderGoods"`
}
func (createDividendsOrderCommand *CreateDividendsOrderCommand) Valid(validation *validation.Validation) {
}
func (createDividendsOrderCommand *CreateDividendsOrderCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createDividendsOrderCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RemoveDividendsOrderCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 分红订单ID
DividendsOrderId []string `json:"dividendsOrderId" valid:"Required"`
}
func (removeDividendsOrderCommand *RemoveDividendsOrderCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeDividendsOrderCommand *RemoveDividendsOrderCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeDividendsOrderCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type UpdateDividendsOrderCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//分红订单
DividendsOrderID int `json:"dividendsOrderId"`
//客户名称
CustomerName string `json:"customerName" valid:"Required"`
//分红订单金额
DividendsOrderAmount float64 `json:"dividendsOrderAmount" valid:"Required"`
//分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber" valid:"Required"`
//分红订单原单号
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum" valid:"Required"`
//订单产生时间
OrderTime int64 `json:"orderTime" valid:"Required"`
//备注
Remarks string `json:"remarks" valid:"Required"`
//订单业务员uid
SalesmanUid string `json:"salesmanUid"`
//订单操作人uid
OperatorUid string `json:"operatorUid"`
//区域名称
RegionName string `json:"regionName"`
//订单产品列表
OrderGoods []struct {
CooperationContractNumber string `json:"cooperationContractNumber"` //关联的共创合约编号
DividendsOrderNumber string `json:"dividendsOrderNumber"` //关联分红订单号
OrderGoodAmount float64 `json:"orderGoodAmount"` //订单产品金额
OrderGoodExpense float64 `json:"orderGoodExpense"` //订单产品费用
OrderGoodName string `json:"orderGoodName"` //订单产品名称
OrderGoodPrice float64 `json:"orderGoodPrice"` //订单产品单价
OrderGoodQuantity int `json:"orderGoodQuantity"` //订单产品数量
} `json:"orderGoods"`
}
func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) Valid(validation *validation.Validation) {
}
func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateDividendsOrderCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type GetDividendsOrderQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 分红订单ID
DividendsOrderId int `json:"dividendsOrderId,string" valid:"Required"`
}
func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getDividendsOrderQuery *GetDividendsOrderQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getDividendsOrderQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
)
type ListDividendsOrdersQuery struct {
// 页码
PageNumber int `json:"pageNumber"`
// 每页限制
PageSize int `json:"pageSize"`
}
func (listDividendsOrdersQuery *ListDividendsOrdersQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listDividendsOrdersQuery *ListDividendsOrdersQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listDividendsOrdersQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type SearchDividendsOrderQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber,omitempty"`
// 客户名称
CustomerName string `json:"customerName,omitempty"`
// 页码
PageNumber int `json:"pageNumber"`
// 每页限制
PageSize int `json:"pageSize"`
}
func (searchDividendsOrderQuery *SearchDividendsOrderQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (searchDividendsOrderQuery *SearchDividendsOrderQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(searchDividendsOrderQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package service
import (
"strconv"
"time"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsOrder/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsOrder/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
// 分红订单实体对象
type DividendsOrderService struct {
}
// 创建分红订单实体对象
func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createDividendsOrderCommand *command.CreateDividendsOrderCommand) (interface{}, error) {
if err := createDividendsOrderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
orderGoods := []allied_creation_cooperation.DividendsOrderGoods{}
for _, v := range createDividendsOrderCommand.OrderGoods {
good := allied_creation_cooperation.DividendsOrderGoods{
CooperationContractNumber: v.CooperationContractNumber,
DividendsOrderNumber: v.DividendsOrderNumber,
OrderGoodAmount: v.OrderGoodAmount,
OrderGoodExpense: v.OrderGoodExpense,
OrderGoodName: v.OrderGoodName,
OrderGoodPrice: v.OrderGoodPrice,
OrderGoodQuantity: v.OrderGoodQuantity,
}
orderGoods = append(orderGoods, good)
}
t := time.Unix(createDividendsOrderCommand.OrderTime, 0)
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(createDividendsOrderCommand.Operator)
result, err := creationCooperationGateway.DividendsOrderAdd(allied_creation_cooperation.ReqDividendsOrderAdd{
CompanyId: int(createDividendsOrderCommand.Operator.CompanyId),
CustomerName: createDividendsOrderCommand.CustomerName,
DividendsOrderAmount: createDividendsOrderCommand.DividendsOrderAmount,
DividendsOrderNumber: createDividendsOrderCommand.DividendsOrderNumber,
DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
OperatorUid: int(createDividendsOrderCommand.Operator.UserId),
OrderTime: t,
Remarks: createDividendsOrderCommand.Remarks,
SalesmanUid: createDividendsOrderCommand.SalesmanUid,
RegionName: createDividendsOrderCommand.RegionName,
OrderGoods: orderGoods,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
data := struct {
DividendsOrderId int
command.CreateDividendsOrderCommand
}{
DividendsOrderId: result.DividendsOrderID,
CreateDividendsOrderCommand: *createDividendsOrderCommand,
}
return data, nil
}
// 返回分红订单实体对象
func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividendsOrderQuery *query.GetDividendsOrderQuery) (interface{}, error) {
if err := getDividendsOrderQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(getDividendsOrderQuery.Operator)
result, err := creationCooperationGateway.DividendsOrderGet(allied_creation_cooperation.ReqDividendsOrderGet{
DividendsOrderId: getDividendsOrderQuery.DividendsOrderId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
// 返回分红订单实体对象列表
// func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDividendsOrdersQuery *query.ListDividendsOrdersQuery) (int, interface{}, error) {
// if err := listDividendsOrdersQuery.ValidateQuery(); err != nil {
// return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
// }
// return 0, nil, nil
// }
// 移除分红订单实体对象
func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeDividendsOrderCommand *command.RemoveDividendsOrderCommand) (interface{}, error) {
if err := removeDividendsOrderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
dividendsOrderId := []int{}
for _, v := range removeDividendsOrderCommand.DividendsOrderId {
id, _ := strconv.Atoi(v)
dividendsOrderId = append(dividendsOrderId, id)
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeDividendsOrderCommand.Operator)
creationCooperationGateway.DividendsOrderRemove(allied_creation_cooperation.ReqDividendsOrderRemove{
DividendsOrderId: 0, ///TODO 改换为批量删除
})
return nil, nil
}
// 查询分红订单方法
func (dividendsOrderService *DividendsOrderService) SearchDividendsOrder(searchDividendsOrderQuery *query.SearchDividendsOrderQuery) (int, interface{}, error) {
if err := searchDividendsOrderQuery.ValidateQuery(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(searchDividendsOrderQuery.Operator)
result, err := creationCooperationGateway.DividendsOrderSearch(allied_creation_cooperation.ReqDividendsOrderSearch{
PageNumber: searchDividendsOrderQuery.PageNumber,
PageSize: searchDividendsOrderQuery.PageSize,
CustomerName: searchDividendsOrderQuery.CustomerName,
DividendsOrderNumber: searchDividendsOrderQuery.DividendsOrderNumber,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result.Gride.Total, result.Gride.List, nil
}
// 更新分红订单实体对象
func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateDividendsOrderCommand *command.UpdateDividendsOrderCommand) (interface{}, error) {
if err := updateDividendsOrderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
orderGoods := []allied_creation_cooperation.DividendsOrderGoods{}
for _, v := range updateDividendsOrderCommand.OrderGoods {
good := allied_creation_cooperation.DividendsOrderGoods{
CooperationContractNumber: v.CooperationContractNumber,
DividendsOrderNumber: v.DividendsOrderNumber,
OrderGoodAmount: v.OrderGoodAmount,
OrderGoodExpense: v.OrderGoodExpense,
OrderGoodName: v.OrderGoodName,
OrderGoodPrice: v.OrderGoodPrice,
OrderGoodQuantity: v.OrderGoodQuantity,
}
orderGoods = append(orderGoods, good)
}
t := time.Unix(updateDividendsOrderCommand.OrderTime, 0)
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateDividendsOrderCommand.Operator)
_, err := creationCooperationGateway.DividendsOrderUpdate(allied_creation_cooperation.ReqDividendsOrderUpdate{
DividendsOrderId: updateDividendsOrderCommand.DividendsOrderID,
CompanyId: int(updateDividendsOrderCommand.Operator.CompanyId),
CustomerName: updateDividendsOrderCommand.CustomerName,
DividendsOrderAmount: updateDividendsOrderCommand.DividendsOrderAmount,
DividendsOrderNumber: updateDividendsOrderCommand.DividendsOrderNumber,
DividendsOriginalOrderNum: updateDividendsOrderCommand.DividendsOriginalOrderNum,
OperatorUid: int(updateDividendsOrderCommand.Operator.UserId),
OrderTime: t,
Remarks: updateDividendsOrderCommand.Remarks,
SalesmanUid: updateDividendsOrderCommand.SalesmanUid,
RegionName: updateDividendsOrderCommand.RegionName,
OrderGoods: orderGoods,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return updateDividendsOrderCommand, nil
}
func NewDividendsOrderService(options map[string]interface{}) *DividendsOrderService {
newDividendsOrderService := &DividendsOrderService{}
return newDividendsOrderService
}
... ...
... ... @@ -72,14 +72,6 @@ type (
OrgName string `json:"orgName"`
}
} `json:"undertakers"`
// 相关人列表
// RelevantPeople []*domain.Relevant `cname:"相关人列表" json:"relevantPeople,omitempty"`
// 公司ID,通过集成REST上下文获取
// CompanyId int64 ` json:"companyId,string" `
// 组织机构ID
// OrgId int64 `json:"orgId,string" `
// 用户ID,
// UserId int64 `json:"userId,string" `
}
DataCooperationContractAdd struct {
... ...
... ... @@ -178,8 +178,8 @@ type (
//判断当前勾选的承接对象是否存在用户
type (
ReqCooperationProjectsCheck struct {
CooperationProjectId int
CooperationProjectUndertakerTypes []int
CooperationProjectId int `json:"cooperationProjectId"`
CooperationProjectUndertakerTypes []int `json:"cooperationProjectUndertakerTypes"`
}
DataCooperationProjectsCheck struct {
... ...
package allied_creation_cooperation
import "time"
//创建分红订单
type DividendsOrder struct {
Company struct {
CompanyID int `json:"companyId"`
CompanyLogo string `json:"companyLogo"`
CompanyName string `json:"companyName"`
} `json:"company"`
CustomerName string `json:"customerName"` //客户名字
DividendStatus int `json:"dividendStatus"` //分红订单分红状态,1待分红,2已分红,3部分分红
DividendTime string `json:"dividendTime"` //分红订单分红时间
DividendsOrderAmount float64 `json:"dividendsOrderAmount"` //分红订单金额
DividendsOrderID int `json:"dividendsOrderId"` //分红订单
DividendsOrderNumber int `json:"dividendsOrderNumber"` //分红订单号
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"` //分红订单原单号
OrderSalesman struct { //订单业务员
Department struct {
DepartmentID int `json:"departmentId"`
DepartmentName string `json:"departmentName"`
DepartmentNumber string `json:"departmentNumber"`
IsOrganization bool `json:"isOrganization"`
} `json:"department"`
Org struct {
OrgID int `json:"orgId"`
OrgName string `json:"orgName"`
} `json:"org"`
UserBaseID int `json:"userBaseId"`
UserID int `json:"userId"`
UserInfo struct {
UserAccount string `json:"userAccount"`
UserAvatar string `json:"userAvatar"`
UserEmail string `json:"userEmail"`
UserName string `json:"userName"`
UserPhone string `json:"userPhone"`
} `json:"userInfo"`
UserType int `json:"userType"`
} `json:"orderSalesman"`
OrderTime string `json:"orderTime"`
Org struct {
OrgID int `json:"orgId"`
OrgName string `json:"orgName"`
} `json:"org"`
Region struct {
RegionName string `json:"regionName"`
RegionNumber string `json:"regionNumber"`
}
}
type (
//订单产品
DividendsOrderGoods struct {
CooperationContractNumber string `json:"cooperationContractNumber"` //关联的共创合约编号
DividendsOrderNumber string `json:"dividendsOrderNumber"` //关联分红订单号
OrderGoodAmount float64 `json:"orderGoodAmount"` //订单产品金额
OrderGoodExpense float64 `json:"orderGoodExpense"` //订单产品费用
OrderGoodName string `json:"orderGoodName"` //订单产品名称
OrderGoodPrice float64 `json:"orderGoodPrice"` //订单产品单价
OrderGoodQuantity int `json:"orderGoodQuantity"` //订单产品数量
}
ReqDividendsOrderAdd struct {
CompanyId int `json:"companyId"`
CustomerName string `json:"customerName"` //客户名称
DividendsOrderAmount float64 `json:"dividendsOrderAmount"` //分红订单金额
DividendsOrderNumber string `json:"dividendsOrderNumber"` //分红订单号
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"` //分红订单原单号
OperatorUid int `json:"operatorUid"` //订单操作人id
OrderGoods []DividendsOrderGoods `json:"orderGoods"` //订单产品列表
OrderTime time.Time `json:"orderTime"` //订单产生时间
Remarks string `json:"remarks"` //备注
SalesmanUid string `json:"salesmanUid"` //订单业务员uid
UserId int `json:"userId"` //
RegionName string `json:"regionName"` //区域名称
}
DataDividendsOrderAdd struct {
DividendsOrderId int
DividendsOrder
}
)
//更新分红订单
type (
ReqDividendsOrderUpdate struct {
DividendsOrderId int
DividendsOrderId int `json:"dividendsOrderId"`
CompanyId int `json:"companyId"`
CustomerName string `json:"customerName"` //客户名称
DividendsOrderAmount float64 `json:"dividendsOrderAmount"` //分红订单金额
DividendsOrderNumber string `json:"dividendsOrderNumber"` //分红订单号
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"` //分红订单原单号
OperatorUid int `json:"operatorUid"` //订单操作人id
OrderGoods []DividendsOrderGoods `json:"orderGoods"` //订单产品列表
OrderTime time.Time `json:"orderTime"` //订单产生时间
Remarks string `json:"remarks"` //备注
SalesmanUid string `json:"salesmanUid"` //订单业务员uid
UserId int `json:"userId"` //
RegionName string `json:"regionName"` //区域名称
}
DataDividendsOrderUpdate struct {
DividendsOrder
}
)
//查询分红订单
type (
ReqDividendsOrderSearch struct {
CompanyId int `json:"companyId"`
CustomerName string `json:"customerName"`
DividendsOrderNumber string `json:"dividendsOrderNumber"`
OrgIds []int `json:"orgIds"`
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
UserId int `json:"userId"`
}
DataDividendsOrderSearch struct {
Gride struct {
Total int `json:"total"`
List []DividendsOrder `json:"list"`
} `json:"gride"`
}
)
... ... @@ -60,9 +155,10 @@ type (
//返回分红订单详情
type (
ReqDividendsOrderGet struct {
DividendsOrderId int
DividendsOrderId int `json:"dividendsOrderId"`
}
DataDividendsOrderGet struct {
DividendsOrder
}
)
... ...