package logic

import (
	"app.yhyue.com/moapp/jybase/common"
	"context"
	"jyBXCore/rpc/type/bxcore"
	"net/http"

	"jyBXCore/api/internal/svc"
	"jyBXCore/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateBidStatusLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
	r      *http.Request
}

func NewUpdateBidStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *UpdateBidStatusLogic {
	return &UpdateBidStatusLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
		r:      r,
	}
}

func (l *UpdateBidStatusLogic) UpdateBidStatus(req *types.UpdateBidStatusReq) (resp *types.CommonResp, err error) {
	defer common.Catch()
	res, err := l.svcCtx.BxCore.UpdateBidStatus(l.ctx, &bxcore.UpdateBidStatusReq{
		EntId:         req.EntId,
		EntUserId:     req.EntUserId,
		PositionId:    req.PositionId,
		PositionType:  req.PositionType,
		AppId:         req.AppId,
		MgoUserId:     req.MgoUserId,
		AccountId:     req.AccountId,
		UserId:        req.UserId,
		NewUserId:     req.NewUserId,
		BidType:       req.BidType,
		BidStage:      req.BidStage,
		ChannelName:   req.ChannelName,
		ChannelPerson: req.ChannelPerson,
		ChannelPhone:  req.ChannelPhone,
		IsWin:         req.IsWin,
		Winner:        req.Winner,
		Sid:           req.Sid,
		EntAccountId:  req.EntAccountId,
		Phone:         req.Phone,
	})
	if err != nil {
		return &types.CommonResp{
			Err_code: -1,
			Err_msg:  "更新失败",
			Data:     false,
		}, nil
	}
	return &types.CommonResp{
		Err_code: res.ErrCode,
		Err_msg:  res.ErrMsg,
		Data:     res.Data,
	}, nil
}
