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.
		
		
		
		
		
			
		
			
				
					
					
						
							131 lines
						
					
					
						
							4.0 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							131 lines
						
					
					
						
							4.0 KiB
						
					
					
				| package service | |
| 
 | |
| import ( | |
| 	"context" | |
| 	"matchmaking-system/internal/pkg/flags" | |
| 	"matchmaking-system/internal/service/order" | |
| 	"matchmaking-system/internal/service/share" | |
| 
 | |
| 	v1 "matchmaking-system/api/matchmaking/v1/share" | |
| ) | |
| 
 | |
| // GetBotStockMysTrade | |
| // | |
| //	@Description: 马股订单列表 | |
| //	@receiver s | |
| //	@param ctx | |
| //	@param req | |
| //	@return *v1.GetMysBotStockMysTradeReply | |
| //	@return error | |
| func (s *ConduitService) GetBotStockMysTrade(ctx context.Context, req *v1.GetMysBotStockTradeRequest) (*v1.GetBotStockMysTradeReply, error) { | |
| 	if !share.VerificationMysBotStockTrade(req) { | |
| 		return share.BotStockMysTradeReply(false, flags.ErrIsParameter.Error(), req, nil, 0), nil | |
| 	} | |
| 
 | |
| 	stockTradeList, totalCount, err := s.my.BotStockMysTradeList(ctx, req.PageSize, req.PageCount, req.Status) | |
| 	if err != nil { | |
| 		return share.BotStockMysTradeReply(false, err.Error(), req, nil, 0), nil | |
| 	} | |
| 
 | |
| 	return share.BotStockMysTradeReply(true, flags.SetNull, req, stockTradeList, totalCount), nil | |
| } | |
| 
 | |
| // ShareMysPlaceOrder | |
| // | |
| //	@Description: 马股下单 | |
| //	@receiver s | |
| //	@param ctx | |
| //	@param req | |
| //	@return *v1.MysOrderReply | |
| //	@return error | |
| func (s *ConduitService) ShareMysPlaceOrder(ctx context.Context, req *v1.ShareMysOrderRequest) (*v1.MysOrderReply, error) { | |
| 	if !share.VerificationMysShareOrderQuery(req) { | |
| 		return share.SharePlaceMysOrderReply(false, flags.ErrIsParameter.Error(), flags.SetNull), nil | |
| 	} | |
| 
 | |
| 	orderId, err := s.my.ShareMysPlaceOrder(ctx, share.ShareMysOrderQuery(req)) | |
| 	if err != nil { | |
| 		return share.SharePlaceMysOrderReply(false, order.CheckShareError(err), flags.SetNull), nil | |
| 	} | |
| 
 | |
| 	return share.SharePlaceMysOrderReply(true, flags.SetNull, orderId), nil | |
| } | |
| 
 | |
| // ShareMysUpdateOrder | |
| // | |
| //	@Description: 马股设置止盈止损 | |
| //	@receiver s | |
| //	@param ctx | |
| //	@param req | |
| //	@return *v1.MysOrderReply | |
| //	@return error | |
| func (s *ConduitService) ShareMysUpdateOrder(ctx context.Context, req *v1.UpdateMysOrderRequest) (*v1.MysOrderReply, error) { | |
| 	if !share.VerificationMysStopOrderQuery(req) { | |
| 		return share.ShareUpdateMysOrderReply(false, flags.ErrIsParameter.Error(), req), nil | |
| 	} | |
| 
 | |
| 	_, err := s.my.ShareMysUpdateOrder(ctx, share.StopOrderMysQuery(req)) | |
| 	if err != nil { | |
| 		return share.ShareUpdateMysOrderReply(false, order.CheckShareError(err), req), nil | |
| 	} | |
| 
 | |
| 	return share.ShareUpdateMysOrderReply(true, flags.SetNull, req), nil | |
| } | |
| 
 | |
| // ShareMysPosition | |
| // | |
| //	@Description: 马股平仓 | |
| //	@receiver s | |
| //	@param ctx | |
| //	@param req | |
| //	@return *v1.MysOrderReply | |
| //	@return error | |
| func (s *ConduitService) ShareMysPosition(ctx context.Context, req *v1.CancelMysOrderRequest) (*v1.MysOrderReply, error) { | |
| 	if !share.VerificationMysSharePosition(req) { | |
| 		return share.ShareMysPositionOrderReply(false, flags.ErrIsParameter.Error(), req), nil | |
| 	} | |
| 
 | |
| 	_, err := s.my.ShareMysPosition(ctx, req.OrderId) | |
| 	if err != nil { | |
| 		return share.ShareMysPositionOrderReply(false, order.CheckShareError(err), req), nil | |
| 	} | |
| 
 | |
| 	return share.ShareMysPositionOrderReply(true, flags.SetNull, req), nil | |
| } | |
| 
 | |
| // ShareMysAllPosition | |
| // | |
| //	@Description: 马股一键平仓 | |
| //	@receiver s | |
| //	@param ctx | |
| //	@param req | |
| //	@return *v1.AllMysOrderReply | |
| //	@return error | |
| func (s *ConduitService) ShareMysAllPosition(ctx context.Context, req *v1.AllMysOrderRequest) (*v1.AllMysOrderReply, error) { | |
| 	if err := s.my.ShareMysAllPosition(ctx); err != nil { | |
| 		return share.ShareAllMysPositionRequest(false, order.CheckShareError(err)), nil | |
| 	} | |
| 
 | |
| 	return share.ShareAllMysPositionRequest(true, flags.SetNull), nil | |
| } | |
| 
 | |
| // ShareMysCancel | |
| // | |
| //	@Description: 马股撤单 | |
| //	@receiver s | |
| //	@param ctx | |
| //	@param req | |
| //	@return *v1.MysOrderReply | |
| //	@return error | |
| func (s *ConduitService) ShareMysCancel(ctx context.Context, req *v1.CancelMysOrderRequest) (*v1.MysOrderReply, error) { | |
| 	if !share.VerificationMysShareCancel(req) { | |
| 		return share.ShareMysCancelReply(false, flags.ErrIsParameter.Error(), req), nil | |
| 	} | |
| 
 | |
| 	_, err := s.my.ShareMysCancel(ctx, req.OrderId) | |
| 	if err != nil { | |
| 		return share.ShareMysCancelReply(false, order.CheckShareError(err), req), nil | |
| 	} | |
| 
 | |
| 	return share.ShareMysCancelReply(true, flags.SetNull, req), nil | |
| }
 | |
| 
 |