36 lines
871 B
Go
36 lines
871 B
Go
|
package productlogic
|
|||
|
|
|||
|
import (
|
|||
|
"context"
|
|||
|
|
|||
|
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
|
|||
|
"code.30cm.net/digimon/app-cloudep-product-service/internal/svc"
|
|||
|
|
|||
|
"github.com/zeromicro/go-zero/core/logx"
|
|||
|
)
|
|||
|
|
|||
|
type DecSalesCountLogic struct {
|
|||
|
ctx context.Context
|
|||
|
svcCtx *svc.ServiceContext
|
|||
|
logx.Logger
|
|||
|
}
|
|||
|
|
|||
|
func NewDecSalesCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DecSalesCountLogic {
|
|||
|
return &DecSalesCountLogic{
|
|||
|
ctx: ctx,
|
|||
|
svcCtx: svcCtx,
|
|||
|
Logger: logx.WithContext(ctx),
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// DecSalesCount 減少賣出數量
|
|||
|
func (l *DecSalesCountLogic) DecSalesCount(in *product.IncDecSalesCountRequest) (*product.OKResp, error) {
|
|||
|
// TODO 有問題可以在這邊加瑣
|
|||
|
err := l.svcCtx.ProductItemUseCase.DecSalesCount(l.ctx, in.GetId(), in.GetCount())
|
|||
|
if err != nil {
|
|||
|
return nil, err
|
|||
|
}
|
|||
|
|
|||
|
return &product.OKResp{}, nil
|
|||
|
}
|