package cart

import (
	"context"
	"time"

	"bsm/full/module/ec/order/internal/models"
	pb "bsm/full/module/ec/order/pb"
	"git.apinb.com/bsm-sdk/core/service"
)

// 删除购物车中的商品
func Delete(ctx context.Context, in *pb.CartDelRequest) (reply *pb.StatusReply, err error) {
	// parse authorization meta.
	_, err = service.ParseMetaCtx(ctx, nil)
	if err != nil {
		return nil, err
	}

	err = models.DBService.Where("id in ?", in.Id).Delete(&models.OrderCart{}).Error
	if err != nil {
		return nil, err
	}

	return &pb.StatusReply{
		Code:    0,
		Message: "OK",
		Timeseq: time.Now().UnixNano(),
	}, nil

}
