预警12
This commit is contained in:
parent
e9c1c63a69
commit
144341501d
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"voucher/internal/biz/bo"
|
||||
|
|
@ -151,9 +152,26 @@ func (this *VoucherBiz) WarningSend(ctx context.Context, product *bo.ProductBo,
|
|||
return err
|
||||
}
|
||||
|
||||
buildTemplateParams(product, w)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildTemplateParams(product *bo.ProductBo, req *do.WxResp) map[string]string {
|
||||
return map[string]string{
|
||||
"stock_name": product.BatchName,
|
||||
"stock_no": product.ProductNo,
|
||||
"amount": strconv.Itoa(int(req.Amount)),
|
||||
"all_budget": strconv.Itoa(int(req.AllBudget)),
|
||||
"all_stock": strconv.Itoa(int(req.AllStock)),
|
||||
"used_stock": strconv.Itoa(int(req.UsedStock)),
|
||||
"used_budget": strconv.Itoa(int(req.UsedBudget)),
|
||||
"available_budget": strconv.Itoa(int(req.AvailableBudget)),
|
||||
"available_stock": strconv.Itoa(int(req.AvailableStock)),
|
||||
"budget_usage_rate": fmt.Sprintf("%.1f", req.StockUsageRate),
|
||||
}
|
||||
}
|
||||
|
||||
func formatAsCard(product *bo.ProductBo, req *do.WxResp) string {
|
||||
var card strings.Builder
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
"voucher/internal/biz/bo"
|
||||
"voucher/internal/biz/do"
|
||||
)
|
||||
|
||||
|
|
@ -43,20 +44,22 @@ func TestSendSMS(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWarningSend(t *testing.T) {
|
||||
req := do.WarningBudget{
|
||||
StockName: "招行2元立减金",
|
||||
StockId: "20627186",
|
||||
StockNo: "CMB20627186",
|
||||
req := &do.WxResp{
|
||||
Amount: 2,
|
||||
AllBudget: 70010,
|
||||
AllStock: 35005,
|
||||
UsedStock: 9390,
|
||||
UsedBudget: 18780,
|
||||
AvailableStock: 25615,
|
||||
RemainingBudget: 51230,
|
||||
AvailableBudget: 51230,
|
||||
StockUsageRate: 20,
|
||||
}
|
||||
params := buildTemplateParams(&req)
|
||||
|
||||
product := &bo.ProductBo{
|
||||
ProductNo: "CMB20627186",
|
||||
BatchName: "招行2元立减金",
|
||||
}
|
||||
params := buildTemplateParams(product, req)
|
||||
|
||||
js, _ := json.Marshal(params)
|
||||
|
||||
|
|
@ -75,16 +78,16 @@ func TestWarningSend(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func buildTemplateParams(req *do.WarningBudget) map[string]string {
|
||||
func buildTemplateParams(product *bo.ProductBo, req *do.WxResp) map[string]string {
|
||||
return map[string]string{
|
||||
"stock_name": req.StockName,
|
||||
"stock_no": req.StockNo,
|
||||
"stock_name": product.BatchName,
|
||||
"stock_no": product.ProductNo,
|
||||
"amount": strconv.Itoa(int(req.Amount)),
|
||||
"all_budget": strconv.Itoa(int(req.AllBudget)),
|
||||
"all_stock": strconv.Itoa(int(req.AllStock)),
|
||||
"used_stock": strconv.Itoa(int(req.UsedStock)),
|
||||
"used_budget": strconv.Itoa(int(req.UsedBudget)),
|
||||
"available_budget": strconv.Itoa(int(req.RemainingBudget)),
|
||||
"available_budget": strconv.Itoa(int(req.AvailableBudget)),
|
||||
"available_stock": strconv.Itoa(int(req.AvailableStock)),
|
||||
"budget_usage_rate": fmt.Sprintf("%.1f", req.StockUsageRate),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue