cmb
This commit is contained in:
parent
87acc327b8
commit
357bab2626
|
|
@ -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 *merchantexclusivecoupon.StockGetResponse, err error) {
|
||||
func (v *VoucherBiz) CmbProductQuery(ctx context.Context, productNo string) (reps *v1.CmbQueryProductReply, 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,11 +58,25 @@ func (v *VoucherBiz) CmbProductQuery(ctx context.Context, productNo string) (rep
|
|||
return fmt.Errorf("只支持微信")
|
||||
}
|
||||
|
||||
reps, err = v.WechatCpnRepo.QueryProduct(ctx, product.BatchNo)
|
||||
wechatResp, err := v.WechatCpnRepo.QueryProduct(ctx, product.BatchNo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// todo
|
||||
reps = &v1.CmbQueryProductReply{
|
||||
ActivityName: product.Name,
|
||||
ActivityId: product.ProductNo,
|
||||
Amount: *wechatResp.GoodsName,
|
||||
MinAmount: fmt.Sprintf("%d", *wechatResp.StockSendRule.MaxAmount),
|
||||
AvailableType: *wechatResp.GoodsName,
|
||||
AvailableDays: *wechatResp.GoodsName,
|
||||
StartTime: wechatResp.CouponUseRule.CouponAvailableTime.AvailableBeginTime.Format(time.DateTime),
|
||||
EndTime: wechatResp.CouponUseRule.CouponAvailableTime.AvailableEndTime.Format(time.DateTime),
|
||||
//AvailableStock: *wechatResp.SendCountInformation.TotalSendNum,
|
||||
Detail: *wechatResp.GoodsName,
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package vo
|
||||
|
||||
// CmbFuncName . 招行接口名称
|
||||
type CmbFuncName string
|
||||
|
||||
const (
|
||||
|
|
@ -12,6 +13,7 @@ func (s CmbFuncName) GetValue() string {
|
|||
return string(s)
|
||||
}
|
||||
|
||||
// CmbStatus . 券通知状态
|
||||
type CmbStatus string
|
||||
|
||||
const (
|
||||
|
|
@ -23,6 +25,7 @@ func (s CmbStatus) GetValue() string {
|
|||
return string(s)
|
||||
}
|
||||
|
||||
// CmbResponseStatus . 响应状态
|
||||
type CmbResponseStatus string
|
||||
|
||||
const (
|
||||
|
|
@ -33,3 +36,15 @@ const (
|
|||
func (s CmbResponseStatus) GetValue() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
// CmbAvailableType . 有效期形式,0:固定有效期,1:动态有效期
|
||||
type CmbAvailableType string
|
||||
|
||||
const (
|
||||
CmbAvailableTypeFixed CmbAvailableType = "0"
|
||||
CmbAvailableTypeDynamic CmbAvailableType = "1"
|
||||
)
|
||||
|
||||
func (s CmbAvailableType) GetValue() string {
|
||||
return string(s)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,21 +111,10 @@ func (s *VoucherService) cmbProductQuery(ctx http.Context) (*v1.CmbQueryProductR
|
|||
return nil, err
|
||||
}
|
||||
|
||||
wechatResp, err := s.VoucherBiz.CmbProductQuery(ctx, bizContent.ActivityId)
|
||||
reply, err := s.VoucherBiz.CmbProductQuery(ctx, bizContent.ActivityId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.CmbQueryProductReply{
|
||||
ActivityName: *wechatResp.GoodsName,
|
||||
ActivityId: "",
|
||||
Amount: "",
|
||||
MinAmount: "",
|
||||
AvailableType: "",
|
||||
AvailableDays: "",
|
||||
StartTime: "",
|
||||
EndTime: "",
|
||||
AvailableStock: "",
|
||||
Detail: "",
|
||||
}, nil
|
||||
return reply, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue