cmb
This commit is contained in:
parent
6b65f24fa5
commit
a6c258fd29
|
|
@ -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
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue