多笔立减
This commit is contained in:
parent
085d3ddb73
commit
4b17fbd9bf
|
|
@ -9,13 +9,13 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
"voucher/internal/biz/do"
|
||||
"voucher/internal/conf"
|
||||
"voucher/internal/data"
|
||||
)
|
||||
|
||||
func SendCoupon() {
|
||||
|
||||
bc := &conf.Bootstrap{
|
||||
var bc = &conf.Bootstrap{
|
||||
Wechat: &conf.Wechat{
|
||||
MchID: "1710953361",
|
||||
MchCertificateSerialNumber: "6006B8208815DB5EAC5BF2E783CB9D34082C3772",
|
||||
|
|
@ -24,6 +24,8 @@ func SendCoupon() {
|
|||
},
|
||||
}
|
||||
|
||||
func SendCoupon() {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
dir, err := os.Getwd()
|
||||
|
|
@ -70,15 +72,6 @@ func SendCoupon() {
|
|||
|
||||
func QueryCoupon() {
|
||||
|
||||
bc := &conf.Bootstrap{
|
||||
Wechat: &conf.Wechat{
|
||||
MchID: "1710953361",
|
||||
MchCertificateSerialNumber: "6006B8208815DB5EAC5BF2E783CB9D34082C3772",
|
||||
WechatPayPublicKeyID: "PUB_KEY_ID_0117109533612025031800326400002563",
|
||||
Name: "蓝色兄弟-new",
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
dir, err := os.Getwd()
|
||||
|
|
@ -145,15 +138,6 @@ func QueryCoupon() {
|
|||
|
||||
func QueryProduct() {
|
||||
|
||||
bc := &conf.Bootstrap{
|
||||
Wechat: &conf.Wechat{
|
||||
MchID: "1710953361",
|
||||
MchCertificateSerialNumber: "6006B8208815DB5EAC5BF2E783CB9D34082C3772",
|
||||
WechatPayPublicKeyID: "PUB_KEY_ID_0117109533612025031800326400002563",
|
||||
Name: "蓝色兄弟-new",
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
dir, err := os.Getwd()
|
||||
|
|
@ -176,7 +160,7 @@ func QueryProduct() {
|
|||
}
|
||||
|
||||
req := cashcoupons.QueryStockRequest{
|
||||
StockId: core.String("20811630"),
|
||||
StockId: core.String("20847510"),
|
||||
StockCreatorMchid: core.String("1652465541"),
|
||||
}
|
||||
|
||||
|
|
@ -201,20 +185,49 @@ func QueryProduct() {
|
|||
fmt.Printf("\n已发券金额:%d", *resp.DistributedCoupons*couponAmount)
|
||||
fmt.Printf("\n剩余库存:%d", availableStock)
|
||||
fmt.Printf("\n剩余预算:%d", availableStock*couponAmount)
|
||||
|
||||
fmt.Printf("\nWxResp:%+v", WxResp(resp))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func QueryCallback() {
|
||||
func WxResp(wxResp *cashcoupons.Stock) (reps *do.WxResp) {
|
||||
|
||||
bc := &conf.Bootstrap{
|
||||
Wechat: &conf.Wechat{
|
||||
MchID: "1710953361",
|
||||
MchCertificateSerialNumber: "6006B8208815DB5EAC5BF2E783CB9D34082C3772",
|
||||
WechatPayPublicKeyID: "PUB_KEY_ID_0117109533612025031800326400002563",
|
||||
Name: "蓝色兄弟-new",
|
||||
},
|
||||
availableStock := *wxResp.StockUseRule.MaxCoupons - *wxResp.DistributedCoupons
|
||||
couponAmount := *wxResp.StockUseRule.FixedNormalCoupon.CouponAmount / 100
|
||||
|
||||
remainingBudget := availableStock * couponAmount
|
||||
|
||||
stockUsageRate := float64(*wxResp.DistributedCoupons) / float64(*wxResp.StockUseRule.MaxCoupons) * 100
|
||||
|
||||
req := &do.WxResp{
|
||||
Amount: couponAmount,
|
||||
AllBudget: *wxResp.StockUseRule.MaxAmount / 100,
|
||||
AllStock: *wxResp.StockUseRule.MaxCoupons,
|
||||
UsedStock: *wxResp.DistributedCoupons,
|
||||
UsedBudget: *wxResp.DistributedCoupons * couponAmount,
|
||||
AvailableStock: availableStock,
|
||||
AvailableBudget: remainingBudget,
|
||||
StockUsageRate: stockUsageRate,
|
||||
}
|
||||
|
||||
inputFormat := time.RFC3339
|
||||
|
||||
if wxResp.AvailableBeginTime != nil {
|
||||
availableBeginTime, _ := time.Parse(inputFormat, *wxResp.AvailableBeginTime)
|
||||
req.StartTime = &availableBeginTime
|
||||
}
|
||||
|
||||
if wxResp.AvailableEndTime != nil {
|
||||
availableEndTime, _ := time.Parse(inputFormat, *wxResp.AvailableEndTime)
|
||||
req.EndTime = &availableEndTime
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
func QueryCallback() {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
dir, err := os.Getwd()
|
||||
|
|
|
|||
Loading…
Reference in New Issue