预警38
This commit is contained in:
parent
9959fb0977
commit
0a79405533
|
|
@ -9,10 +9,9 @@ import (
|
|||
"voucher/internal/pkg/lock"
|
||||
)
|
||||
|
||||
// RegisterTag 注册通知标签 stock.MchId 批次创建商户, stock.BatchNo 商品批次号
|
||||
func (this *VoucherBiz) RegisterTag(ctx context.Context, batchNo string) error {
|
||||
func (this *VoucherBiz) RegisterTag(ctx context.Context, id int32) error {
|
||||
|
||||
stock, err := this.ProductRepo.GetByBatchNo(ctx, batchNo)
|
||||
stock, err := this.ProductRepo.GetById(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
)
|
||||
|
||||
type ProductRepo interface {
|
||||
GetById(ctx context.Context, id int32) (*bo.ProductBo, error)
|
||||
FindWarningBudget(ctx context.Context, fun func(ctx context.Context, rows []*bo.ProductBo) error) error
|
||||
GetByBatchNo(ctx context.Context, batchNo string) (*bo.ProductBo, error)
|
||||
GetByProductNo(ctx context.Context, productNo string) (*bo.ProductBo, error)
|
||||
|
|
|
|||
|
|
@ -83,6 +83,23 @@ func (r *ProductRepoImpl) UpdateByWxResp(ctx context.Context, id int32, req *do.
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *ProductRepoImpl) GetById(ctx context.Context, id int32) (*bo.ProductBo, error) {
|
||||
|
||||
var item *model.Product
|
||||
|
||||
tx := r.db.DB(ctx).Model(model.Product{}).Where(model.Product{ID: id}).First(&item)
|
||||
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
|
||||
if tx.RowsAffected == 0 {
|
||||
return nil, gorm.ErrRecordNotFound
|
||||
}
|
||||
|
||||
return r.ToBo(item), nil
|
||||
}
|
||||
|
||||
func (r *ProductRepoImpl) GetByBatchNo(ctx context.Context, batchNo string) (*bo.ProductBo, error) {
|
||||
|
||||
var item *model.Product
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func NewHTTPServer(
|
|||
srv.Route("/voucher/").POST("notifyRetry/{id}", cmb.NotifyRetry)
|
||||
srv.Route("/voucher/").POST("queryOrder/{order_no}", cmb.QueryOrder)
|
||||
srv.Route("/voucher/").POST("queryStock/{product_no}", cmb.QueryStock)
|
||||
srv.Route("/voucher/").POST("registerTag/{batch_no}", cmb.RegisterTag)
|
||||
srv.Route("/voucher/").POST("registerTag/{id}", cmb.RegisterTag)
|
||||
srv.Route("/voucher/").POST("pushWechatQuery", cmb.PushWechatQuery)
|
||||
srv.Route("/voucher/").POST("timeSliceQueryPush", cmb.TimeSliceQueryPush)
|
||||
srv.Route("/voucher/").POST("pushWechatRetry/{batch_no}", cmb.PushWechatRetry)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/go-kratos/kratos/v2/transport/http"
|
||||
"github.com/robfig/cron"
|
||||
http2 "net/http"
|
||||
"strconv"
|
||||
v1 "voucher/api/v1"
|
||||
"voucher/internal/biz"
|
||||
"voucher/internal/biz/bo"
|
||||
|
|
@ -70,16 +71,21 @@ func (c *CmbService) OrderRetry(ctx context.Context, request *v1.OrderRetryReque
|
|||
|
||||
func (this *CmbService) RegisterTag(ctx http.Context) error {
|
||||
|
||||
batchNo := ctx.Vars().Get("batch_no")
|
||||
if batchNo == "" {
|
||||
return fmt.Errorf("batch_no is empty")
|
||||
id := ctx.Vars().Get("id")
|
||||
if id == "" {
|
||||
return fmt.Errorf("id is empty")
|
||||
}
|
||||
|
||||
if err := this.VoucherBiz.RegisterTag(ctx, batchNo); err != nil {
|
||||
int64Id, err := strconv.ParseInt(id, 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = this.VoucherBiz.RegisterTag(ctx, int32(int64Id)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ctx.JSON(http2.StatusOK, map[string]interface{}{
|
||||
"data": batchNo,
|
||||
"data": id,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue