多笔立减金
This commit is contained in:
parent
d01900b519
commit
43bf445f8b
|
|
@ -3,21 +3,22 @@ package bo
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/go-playground/validator/v10"
|
||||||
"time"
|
"time"
|
||||||
"voucher/internal/biz/vo"
|
"voucher/internal/biz/vo"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConsumeInformation 定义消费信息结构体
|
// ConsumeInformation 定义消费信息结构体
|
||||||
type ConsumeInformation struct {
|
type ConsumeInformation struct {
|
||||||
ConsumeTime time.Time `json:"consume_time"` // 核销时间
|
ConsumeTime time.Time `json:"consume_time" validate:"required"` // 核销时间
|
||||||
ConsumeMchid string `json:"consume_mchid"` // 核销商户号
|
ConsumeMchid string `json:"consume_mchid"` // 核销商户号
|
||||||
TransactionID string `json:"transaction_id"` // 微信支付交易单号
|
TransactionID string `json:"transaction_id" validate:"required"` // 微信支付交易单号
|
||||||
ConsumeAmount int `json:"consume_amount"` // 核销金额(单位:分)
|
ConsumeAmount int `json:"consume_amount" validate:"required"` // 核销金额(单位:分)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PlainText 定义明文数据结构体
|
// PlainText 定义明文数据结构体
|
||||||
type PlainText struct {
|
type PlainText struct {
|
||||||
StockCreatorMchid string `json:"stock_creator_mchid"`
|
StockCreatorMchid string `json:"stock_creator_mchid" validate:"required"`
|
||||||
StockID string `json:"stock_id"`
|
StockID string `json:"stock_id"`
|
||||||
CouponID string `json:"coupon_id"`
|
CouponID string `json:"coupon_id"`
|
||||||
CouponName string `json:"coupon_name"`
|
CouponName string `json:"coupon_name"`
|
||||||
|
|
@ -32,14 +33,14 @@ type PlainText struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type WechatVoucherNotifyBo struct {
|
type WechatVoucherNotifyBo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id" validate:"required"`
|
||||||
CreateTime string `json:"create_time"`
|
CreateTime string `json:"create_time"`
|
||||||
ResourceType string `json:"resource_type"`
|
ResourceType string `json:"resource_type"`
|
||||||
EventType string `json:"event_type"`
|
EventType string `json:"event_type" validate:"required"`
|
||||||
Summary string `json:"summary"`
|
Summary string `json:"summary"`
|
||||||
OriginalType string `json:"original_type"`
|
OriginalType string `json:"original_type"`
|
||||||
AssociatedData string `json:"associated_data"`
|
AssociatedData string `json:"associated_data"`
|
||||||
PlainText PlainText `json:"plain_text"`
|
PlainText PlainText `json:"plain_text" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WechatVoucherNotifyBo) Str() (string, error) {
|
func (d *WechatVoucherNotifyBo) Str() (string, error) {
|
||||||
|
|
@ -51,3 +52,14 @@ func (d *WechatVoucherNotifyBo) Str() (string, error) {
|
||||||
|
|
||||||
return string(b), nil
|
return string(b), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *WechatVoucherNotifyBo) Validate() error {
|
||||||
|
|
||||||
|
if err := validator.New().Struct(c); err != nil {
|
||||||
|
for _, err = range err.(validator.ValidationErrors) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,11 @@ func (srv *TripartiteService) QiXingNotify(ctx http.Context) error {
|
||||||
return srv.ResponseErr(ctx, fmt.Sprintf("json unmarshal wxNotifyData error: %v", err))
|
return srv.ResponseErr(ctx, fmt.Sprintf("json unmarshal wxNotifyData error: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = wxNotifyData.Validate(); err != nil {
|
||||||
|
log.Errorf("qixing notify wxNotifyData validate err ip:%s,error:%v,body:%s", ip, err, string(bodyBytes))
|
||||||
|
return srv.ResponseErr(ctx, fmt.Sprintf("validate wxNotifyData error: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
err = srv.multiBiz.Notify(ctx, "qixing_"+wxNotifyData.PlainText.StockCreatorMchid, wxNotifyData)
|
err = srv.multiBiz.Notify(ctx, "qixing_"+wxNotifyData.PlainText.StockCreatorMchid, wxNotifyData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("qixing notify run err ip:%s,error:%v,body:%s", ip, err, string(bodyBytes))
|
log.Errorf("qixing notify run err ip:%s,error:%v,body:%s", ip, err, string(bodyBytes))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue