You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.7 KiB
115 lines
3.7 KiB
2 months ago
|
package service
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
v1 "matchmaking-system/api/matchmaking/v1/block"
|
||
|
"matchmaking-system/internal/pkg/flags"
|
||
|
"matchmaking-system/internal/service/block"
|
||
|
"matchmaking-system/internal/service/order"
|
||
|
)
|
||
|
|
||
|
// GetBotStockBlockTrade
|
||
|
//
|
||
|
// @Description: 大宗交易订单列表
|
||
|
// @receiver s
|
||
|
// @param ctx
|
||
|
// @param req
|
||
|
// @return *v1.GetBotStockBlockTradeReply
|
||
|
// @return error
|
||
|
func (s *ConduitService) GetBotStockBlockTrade(ctx context.Context, req *v1.GetBotStockBlockTradeRequest) (*v1.GetBotStockBlockTradeReply, error) {
|
||
|
if !block.VerificationBotStockBlockTrade(req) {
|
||
|
return block.BotStockBlockTradeReply(false, flags.ErrIsParameter.Error(), req, nil, 0), nil
|
||
|
}
|
||
|
|
||
|
stockTradeList, totalCount, err := s.bl.BotStockBlockTradeList(ctx, req.PageSize, req.PageCount, req.Type, req.Status)
|
||
|
if err != nil {
|
||
|
return block.BotStockBlockTradeReply(false, err.Error(), req, nil, 0), nil
|
||
|
}
|
||
|
|
||
|
return block.BotStockBlockTradeReply(true, flags.SetNull, req, stockTradeList, totalCount), nil
|
||
|
}
|
||
|
|
||
|
// ShareBlockPlaceOrder
|
||
|
//
|
||
|
// @Description: 大宗交易股下单
|
||
|
// @receiver s
|
||
|
// @param ctx
|
||
|
// @param req
|
||
|
// @return *v1.OrderBlockReply
|
||
|
// @return error
|
||
|
func (s *ConduitService) ShareBlockPlaceOrder(ctx context.Context, req *v1.OrderBlockRequest) (*v1.OrderBlockReply, error) {
|
||
|
if !block.VerificationShareBlockOrderQuery(req) {
|
||
|
return block.ShareBlockPlaceOrderReply(false, flags.ErrIsParameter.Error(), flags.SetNull), nil
|
||
|
}
|
||
|
|
||
|
orderId, err := s.bl.ShareBlockPlaceOrder(ctx, block.ShareBlockOrderQuery(req))
|
||
|
if err != nil {
|
||
|
return block.ShareBlockPlaceOrderReply(false, order.CheckShareError(err), flags.SetNull), nil
|
||
|
}
|
||
|
|
||
|
return block.ShareBlockPlaceOrderReply(true, flags.SetNull, orderId), nil
|
||
|
}
|
||
|
|
||
|
// ShareBlockUpdateOrder
|
||
|
//
|
||
|
// @Description: 大宗交易股设置止盈止损
|
||
|
// @receiver s
|
||
|
// @param ctx
|
||
|
// @param req
|
||
|
// @return *v1.OrderBlockReply
|
||
|
// @return error
|
||
|
func (s *ConduitService) ShareBlockUpdateOrder(ctx context.Context, req *v1.UpdateBlockOrderRequest) (*v1.OrderBlockReply, error) {
|
||
|
if !block.VerificationStopOrderBlockQuery(req) {
|
||
|
return block.ShareBlockUpdateOrderReply(false, flags.ErrIsParameter.Error(), req), nil
|
||
|
}
|
||
|
|
||
|
_, err := s.bl.ShareBlockUpdateOrder(ctx, block.StopOrderBlockQuery(req))
|
||
|
if err != nil {
|
||
|
return block.ShareBlockUpdateOrderReply(false, order.CheckShareError(err), req), nil
|
||
|
}
|
||
|
|
||
|
return block.ShareBlockUpdateOrderReply(true, flags.SetNull, req), nil
|
||
|
}
|
||
|
|
||
|
// ShareBlockPosition
|
||
|
//
|
||
|
// @Description: 大宗交易股平仓
|
||
|
// @receiver s
|
||
|
// @param ctx
|
||
|
// @param req
|
||
|
// @return *v1.OrderBlockReply
|
||
|
// @return error
|
||
|
func (s *ConduitService) ShareBlockPosition(ctx context.Context, req *v1.CancelBlockOrderRequest) (*v1.OrderBlockReply, error) {
|
||
|
if !block.VerificationShareBlockPosition(req) {
|
||
|
return block.ShareBlockPositionOrderReply(false, flags.ErrIsParameter.Error(), req), nil
|
||
|
}
|
||
|
|
||
|
_, err := s.bl.ShareBlockPosition(ctx, req.OrderId, req.Type)
|
||
|
if err != nil {
|
||
|
return block.ShareBlockPositionOrderReply(false, order.CheckShareError(err), req), nil
|
||
|
}
|
||
|
|
||
|
return block.ShareBlockPositionOrderReply(true, flags.SetNull, req), nil
|
||
|
}
|
||
|
|
||
|
// ShareBlockCancel
|
||
|
//
|
||
|
// @Description: 大宗交易股撤单
|
||
|
// @receiver s
|
||
|
// @param ctx
|
||
|
// @param req
|
||
|
// @return *v1.OrderBlockReply
|
||
|
// @return error
|
||
|
func (s *ConduitService) ShareBlockCancel(ctx context.Context, req *v1.CancelBlockOrderRequest) (*v1.OrderBlockReply, error) {
|
||
|
if !block.VerificationShareBlockCancel(req) {
|
||
|
return block.ShareBlockCancelReply(false, flags.ErrIsParameter.Error(), req), nil
|
||
|
}
|
||
|
|
||
|
_, err := s.bl.ShareBlockCancel(ctx, req.OrderId, req.Type)
|
||
|
if err != nil {
|
||
|
return block.ShareBlockCancelReply(false, order.CheckShareError(err), req), nil
|
||
|
}
|
||
|
|
||
|
return block.ShareBlockCancelReply(true, flags.SetNull, req), nil
|
||
|
}
|