作者 tangxuhui

更新

... ... @@ -15,7 +15,7 @@ type EndCooperationProjectCommand struct {
}
func (endCooperationProjectCommand *EndCooperationProjectCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (endCooperationProjectCommand *EndCooperationProjectCommand) ValidateCommand() error {
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type ReleaseCooperationProjectCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 共创项目名称
CooperationProjectName string `json:"cooperationProjectName" valid:"Required"`
// 共创模式ID
CooperationModeId int64 `json:"cooperationModeId" valid:"Required"`
// 手机号码
Phone string `json:"phone" valid:"Required"`
// 共创模式状态,1启用,2禁用
Status int32 `json:"status" valid:"Required"`
// 用户编号
UsersCode string `json:"usersCode" valid:"Required"`
// 用户编号
UsersId int64 `json:"usersId" valid:"Required"`
// 用户姓名
UsersName string `json:"usersName" valid:"Required"`
// 邮箱
Email string `json:"email" valid:"Required"`
// 共创公司
CooperationCompany string `json:"cooperationCompany" valid:"Required"`
// 共创公司到期时间
CooperationDeadline string `json:"cooperationDeadline" valid:"Required"`
// 共创项目承接对象,1员工,2共创用户,3公开,可以多选
CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType" valid:"Required"`
// 共创项目描述
CooperationProjectDescription string `json:"cooperationProjectDescription" valid:"Required"`
}
func (releaseCooperationProjectCommand *ReleaseCooperationProjectCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (releaseCooperationProjectCommand *ReleaseCooperationProjectCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(releaseCooperationProjectCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ... @@ -15,7 +15,7 @@ type RemoveCooperationProjectCommand struct {
}
func (removeCooperationProjectCommand *RemoveCooperationProjectCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeCooperationProjectCommand *RemoveCooperationProjectCommand) ValidateCommand() error {
... ...
... ... @@ -29,7 +29,7 @@ type UpdateCooperationProjectCommand struct {
}
func (updateCooperationProjectCommand *UpdateCooperationProjectCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateCooperationProjectCommand *UpdateCooperationProjectCommand) ValidateCommand() error {
... ...
... ... @@ -47,7 +47,7 @@ func (cooperationProjectService *CooperationProjectService) EndCooperationProjec
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
//creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator)
//TODO
//TODO 等待接口
return nil, nil
}
... ... @@ -64,7 +64,6 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
// 返回共创项目管理列表
... ...
... ... @@ -75,15 +75,6 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen
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 {
... ...
package command
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
type CreateDividendsReturnedOrderCommand struct {
//操作人
Operator domain.Operator `json:"-"`
allied_creation_cooperation.ReqDividendsReturnedOrderAdd
}
... ...
package command
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
type RemoveDividendsReturnedOrderCommand struct {
//操作人
Operator domain.Operator `json:"-"`
allied_creation_cooperation.ReqDividendsReturnedOrderRemove
}
... ...
package command
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
type UpdateDividendsReturnedOrderCommand struct {
//操作人
Operator domain.Operator `json:"-"`
allied_creation_cooperation.ReqDividendsReturnedOrderUpdate
}
... ...
package query
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type GetDividendsReturnedOrderQuery struct {
//操作人
Operator domain.Operator `json:"-"`
DividendsReturnedOrderID int `json:"dividendsReturnedOrderId"` //分红退货单记录id
}
... ...
package query
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type SearchDividendsReturnedOrderQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 退货客户姓名
DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName,omitempty"`
// 分红退货单号
DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber,omitempty"`
// 查询偏离量
PageNumber int `json:"pageNumber"`
// 每页
PageSize int `json:"pageSize"`
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsReturnedOrder/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsReturnedOrder/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
// 分红退货单服务
type DividendsReturnedOrderService struct {
}
// 创建分红退货单服务
func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDividendsReturnedOrder(createDividendsReturnedOrderCommand *command.CreateDividendsReturnedOrderCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(createDividendsReturnedOrderCommand.Operator)
_, err := creationCooperationGateway.DividendsReturnedOrderAdd(createDividendsReturnedOrderCommand.ReqDividendsReturnedOrderAdd)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return createDividendsReturnedOrderCommand, nil
}
// 返回分红退货单服务
func (dividendsReturnedOrderService *DividendsReturnedOrderService) GetDividendsReturnedOrder(getDividendsReturnedOrderQuery *query.GetDividendsReturnedOrderQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(getDividendsReturnedOrderQuery.Operator)
result, err := creationCooperationGateway.DividendsReturnedOrderGet(allied_creation_cooperation.ReqDividendsReturnedOrderGet{
DividendsReturnedOrderId: getDividendsReturnedOrderQuery.DividendsReturnedOrderID,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
// 移除分红退货单服务
func (dividendsReturnedOrderService *DividendsReturnedOrderService) RemoveDividendsReturnedOrder(removeDividendsReturnedOrderCommand *command.RemoveDividendsReturnedOrderCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeDividendsReturnedOrderCommand.Operator)
_, err := creationCooperationGateway.DividendsReturnedOrderRemove(removeDividendsReturnedOrderCommand.ReqDividendsReturnedOrderRemove)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return removeDividendsReturnedOrderCommand, nil
}
// 查找分红退货单
func (dividendsReturnedOrderService *DividendsReturnedOrderService) SearchDividendsReturnedOrder(searchDividendsReturnedOrderQuery *query.SearchDividendsReturnedOrderQuery) (int, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(searchDividendsReturnedOrderQuery.Operator)
result, err := creationCooperationGateway.DividendsReturnedOrderSearch(allied_creation_cooperation.ReqDividendsReturnedOrderSearch{
PageNumber: searchDividendsReturnedOrderQuery.PageNumber,
PageSize: searchDividendsReturnedOrderQuery.PageSize,
DividendsReturnedOrderNumber: searchDividendsReturnedOrderQuery.DividendsReturnedOrderNumber,
DividendsReturnedCustomerName: searchDividendsReturnedOrderQuery.DividendsReturnedCustomerName,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result.Total, result.List, nil
}
// 更新分红退货单服务
func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDividendsReturnedOrder(updateDividendsReturnedOrderCommand *command.UpdateDividendsReturnedOrderCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateDividendsReturnedOrderCommand.Operator)
_, err := creationCooperationGateway.DividendsReturnedOrderUpdate(updateDividendsReturnedOrderCommand.ReqDividendsReturnedOrderUpdate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return updateDividendsReturnedOrderCommand, nil
}
func NewDividendsReturnedOrderService(options map[string]interface{}) *DividendsReturnedOrderService {
newDividendsReturnedOrderService := &DividendsReturnedOrderService{}
return newDividendsReturnedOrderService
}
... ...
package allied_creation_cooperation
import (
"encoding/json"
"fmt"
"strconv"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
//DividendsReturnedOrderAdd 创建分红退货单
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderAdd(param ReqDividendsReturnedOrderAdd) (*DataDividendsReturnedOrderAdd, error) {
url := gateway.baseUrL + "/dividends-returned-orders"
method := "POST"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:创建分红退货单。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求创建分红退货单失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取创建分红退货单失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:创建分红退货单。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析创建分红退货单:%w", err)
}
var data DataDividendsReturnedOrderAdd
err = gateway.GetResponseData(result, &data)
return &data, err
}
// DividendsReturnedOrderUpdate 更新分红退货单
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderUpdate(param ReqDividendsReturnedOrderUpdate) (
*DataDividendsReturnedOrderUpdate, error) {
url := gateway.baseUrL + "/dividends-returned-orders/" + strconv.Itoa(param.DividendsReturnedOrderID)
method := "PUT"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:更新分红退货单。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求更新分红退货单失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取更新分红退货单失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:更新分红退货单。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析更新分红退货单:%w", err)
}
var data DataDividendsReturnedOrderUpdate
err = gateway.GetResponseData(result, &data)
return &data, err
}
// DividendsReturnedOrderSearch 查找分红退货单
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderSearch(param ReqDividendsReturnedOrderSearch) (*DataDividendsReturnedOrderSearch, error) {
url := gateway.baseUrL + "/dividends-returned-orders/search"
method := "POST"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:查找分红退货单。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求查找分红退货单失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取查找分红退货单失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:查找分红退货单。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析查找分红退货单:%w", err)
}
var data DataDividendsReturnedOrderSearch
err = gateway.GetResponseData(result, &data)
return &data, err
}
// DividendsReturnedOrderRemove 移除分红退货单
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderRemove(param ReqDividendsReturnedOrderRemove) (
*DataDividendsReturnedOrderRemove, error) {
url := gateway.baseUrL + "/dividends-returned-orders/" + strconv.Itoa(param.DividendsReturnedOrderID)
method := "DELETE"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:移除分红退货单。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求移除分红退货单失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取移除分红退货单失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:移除分红退货单。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析移除分红退货单:%w", err)
}
var data DataDividendsReturnedOrderRemove
err = gateway.GetResponseData(result, &data)
return &data, err
}
// DividendsReturnedOrders 返回分红退货单列表
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderList(param ReqDividendsReturnedOrderList) (*DataDividendsReturnedOrderList, error) {
url := gateway.baseUrL + "/dividends-returned-orders"
method := "GET"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:返回分红退货单列表。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回分红退货单列表失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回分红退货单列表失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:返回分红退货单列表。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析返回分红退货单列表:%w", err)
}
var data DataDividendsReturnedOrderList
err = gateway.GetResponseData(result, &data)
return &data, err
}
// DividendsReturnedOrderGet 返回分红退货单详情
func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderGet(param ReqDividendsReturnedOrderGet) (*DataDividendsReturnedOrderGet, error) {
url := gateway.baseUrL + "/dividends-returned-orders" + strconv.Itoa(param.DividendsReturnedOrderId)
method := "GET"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:返回分红退货单详情。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回分红退货单详情失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回分红退货单详情失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:返回分红退货单详情。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析返回分红退货单详情:%w", err)
}
var data DataDividendsReturnedOrderGet
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
package allied_creation_cooperation
import "time"
//创建分红退货单
type (
DividendsReturnedOrderGoods struct {
CooperationContractNumber string `json:"cooperationContractNumber"` //关联的共创合约编号
OrderGoodAmount float64 `json:"orderGoodAmount"` //订单产品金额
OrderGoodName string `json:"orderGoodName"` //订单产品名称
OrderGoodPrice float64 `json:"orderGoodPrice"` //订单产品单价
OrderGoodQuantity int `json:"orderGoodQuantity"` //订单产品数量
}
DividendsReturnedOrder struct {
// 公司
Company struct {
CompanyID int `json:"companyId"`
CompanyLogo string `json:"companyLogo"`
CompanyName string `json:"companyName"`
} `json:"company"`
CreatedAt time.Time `json:"createdAt"`
DividendStatus int `json:"dividendStatus"` // 分红订单分红状态,1待分红,2已分红,3部分分红
DividendTime time.Time `json:"dividendTime"` //分红订单分红时间
DividendsOrderNumber int `json:"dividendsOrderNumber"` //关联分红订单号
DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"` //退货客户姓名
DividendsReturnedDate time.Time `json:"dividendsReturnedDate"` //退货日期
DividendsReturnedOrderID string `json:"dividendsReturnedOrderId"` //分红退货单记录id
DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber"` //分红退货单号
DividendsReturnedOrderRefund float64 `json:"dividendsReturnedOrderRefund"` //退货金额
OperateTime string `json:"operateTime"` //操作时间
OriginalOrderNum string `json:"originalOrderNum"` //源单号(原始订单号)
Remarks string `json:"remarks"` //备注
UpdatedAt string `json:"updatedAt"`
//更新时间
Org struct {
OrgID int `json:"orgId"` //
OrgName string `json:"orgName"` //
} `json:"org"` //归属组织机构
Region struct {
RegionName string `json:"regionName"`
RegionNumber string `json:"regionNumber"` //区域编码
} `json:"region"` //区域信息
Goods []DividendsReturnedOrderGoods `json:"goods"` //货品
}
ReqDividendsReturnedOrderAdd struct {
CustomerName string `json:"customerName"`
DividendsOrderAmount string `json:"dividendsOrderAmount"`
DividendsOrderNumber string `json:"dividendsOrderNumber"`
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
OrderGoods []DividendsReturnedOrderGoods `json:"orderGoods"`
OrderTime time.Time `json:"orderTime"`
OrgId int `json:"orgId"`
Remarks string `json:"remarks"`
SalesmanUid string `json:"salesmanUid"`
RegionName string `json:"regionName"`
}
DataDividendsReturnedOrderAdd struct {
}
)
//更新分红退货单
type (
ReqDividendsReturnedOrderUpdate struct {
DividendsReturnedOrderID int `json:"dividendsReturnedOrderId"` //分红退货单记录id
CustomerName string `json:"customerName"`
DividendsOrderAmount string `json:"dividendsOrderAmount"`
DividendsOrderNumber string `json:"dividendsOrderNumber"`
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
OrderGoods []DividendsReturnedOrderGoods `json:"orderGoods"`
OrderTime time.Time `json:"orderTime"`
OrgId int `json:"orgId"`
Remarks string `json:"remarks"`
SalesmanUid string `json:"salesmanUid"`
RegionName string `json:"regionName"`
}
DataDividendsReturnedOrderUpdate struct {
}
)
//查找分红退货单
type (
ReqDividendsReturnedOrderSearch struct {
CompanyId int `json:"companyId"`
OrgId int `json:"orgId"`
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber"`
DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"`
UserId int `json:"userId"`
}
DataDividendsReturnedOrderSearch struct {
Total int `json:"total"`
List []DividendsReturnedOrder `json:"list"`
}
)
//移除分红退货单
type (
ReqDividendsReturnedOrderRemove struct {
DividendsReturnedOrderID int `json:"dividendsReturnedOrderId"` //分红退货单记录id
}
DataDividendsReturnedOrderRemove struct {
}
)
//返回分红退货单列表
type (
ReqDividendsReturnedOrderList struct {
}
DataDividendsReturnedOrderList struct {
}
)
//返回分红退货单详情
type (
ReqDividendsReturnedOrderGet struct {
DividendsReturnedOrderId int `json:"dividendsReturnedOrderId"`
}
DataDividendsReturnedOrderGet struct {
DividendsReturnedOrder
}
)
... ...