This commit is contained in:
李子铭 2025-03-05 09:44:59 +08:00
parent 6b65f24fa5
commit a6c258fd29
2 changed files with 27 additions and 8 deletions

View File

@ -4,9 +4,9 @@ import (
"context"
"errors"
"fmt"
"github.com/wechatpay-apiv3/wechatpay-go/services/merchantexclusivecoupon"
"gorm.io/gorm"
"time"
v1 "voucher/api/v1"
"voucher/internal/biz/bo"
"voucher/internal/pkg/lock"
)
@ -45,7 +45,7 @@ func (v *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (or
return
}
func (v *VoucherBiz) CmbProductQuery(ctx context.Context, productNo string) (reps *v1.CmbQueryProductReply, err error) {
func (v *VoucherBiz) CmbProductQuery(ctx context.Context, productNo string) (reps *merchantexclusivecoupon.StockGetResponse, err error) {
err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("cmb_product_query_%s", productNo), func(ctx context.Context) error {
@ -58,13 +58,11 @@ func (v *VoucherBiz) CmbProductQuery(ctx context.Context, productNo string) (rep
return fmt.Errorf("只支持微信")
}
_, err = v.WechatCpnRepo.QueryProduct(ctx, product.BatchNo)
reps, err = v.WechatCpnRepo.QueryProduct(ctx, product.BatchNo)
if err != nil {
return err
}
// 数据构造返回
return nil
})

View File

@ -92,10 +92,31 @@ func (s *VoucherService) cmbProductQuery(ctx http.Context) error {
return err
}
s.VoucherBiz.CmbProductQuery(ctx, req.ActivityId)
// todo 签名验证
q, err := s.VoucherBiz.CmbProductQuery(ctx, req.ActivityId)
if err != nil {
return err
}
rep := &v1.CmbQueryProductReply{}
// 数据构造 加签 返回
rep := &v1.CmbQueryProductReply{
RespCode: "",
RespMsg: "",
Date: "",
KeyAlias: "",
CmbKeyAlias: "",
EncryptBody: "",
Sign: "",
ActivityName: "",
ActivityId: *q.StockId,
Amount: "",
MinAmount: "",
AvailableType: "",
AvailableDays: "",
StartTime: "",
EndTime: "",
AvailableStock: "",
Detail: "",
}
return ctx.JSON(200, rep)
}