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