order query

This commit is contained in:
ziming 2025-04-29 11:15:38 +08:00
parent ffc56c74de
commit bc4c6451e5
5 changed files with 79 additions and 15 deletions

1
go.sum
View File

@ -133,6 +133,7 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=

View File

@ -266,15 +266,25 @@ func (v *VoucherBiz) UpdateOrderStatus(ctx context.Context, orderId uint64, stat
return fmt.Errorf("notice 未知券状态,orderId:%d,statuText:%s", orderId, status.GetText())
}
func (v *VoucherBiz) QueryOrder(ctx context.Context, orderNo string) (string, error) {
func (v *VoucherBiz) OrderQuery(ctx context.Context, orderNo string) (*bo.OrderBo, error) {
order, err3 := v.OrderRepo.GetByOrderNo(ctx, orderNo)
if err3 != nil {
return "", err3
return nil, err3
}
if order == nil || order.ID == 0 {
return "", fmt.Errorf("订单不存在:%s", orderNo)
return nil, fmt.Errorf("订单不存在:%s", orderNo)
}
return order, nil
}
func (v *VoucherBiz) QueryOrder(ctx context.Context, orderNo string) (string, error) {
order, err3 := v.OrderQuery(ctx, orderNo)
if err3 != nil {
return "", err3
}
status, err := v.WechatCpnRepo.Query(ctx, order)

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc v3.12.4
// protoc-gen-go v1.34.2
// protoc v4.24.3
// source: conf/conf.proto
package conf
@ -1429,7 +1429,7 @@ func file_conf_conf_proto_rawDescGZIP() []byte {
}
var file_conf_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
var file_conf_conf_proto_goTypes = []interface{}{
var file_conf_conf_proto_goTypes = []any{
(*Bootstrap)(nil), // 0: voucher.config.Bootstrap
(*Server)(nil), // 1: voucher.config.Server
(*Data)(nil), // 2: voucher.config.Data
@ -1484,7 +1484,7 @@ func file_conf_conf_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_conf_conf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*Bootstrap); i {
case 0:
return &v.state
@ -1496,7 +1496,7 @@ func file_conf_conf_proto_init() {
return nil
}
}
file_conf_conf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*Server); i {
case 0:
return &v.state
@ -1508,7 +1508,7 @@ func file_conf_conf_proto_init() {
return nil
}
}
file_conf_conf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*Data); i {
case 0:
return &v.state
@ -1520,7 +1520,7 @@ func file_conf_conf_proto_init() {
return nil
}
}
file_conf_conf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*RocketMQ); i {
case 0:
return &v.state
@ -1532,7 +1532,7 @@ func file_conf_conf_proto_init() {
return nil
}
}
file_conf_conf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*EventMap); i {
case 0:
return &v.state
@ -1544,7 +1544,7 @@ func file_conf_conf_proto_init() {
return nil
}
}
file_conf_conf_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[5].Exporter = func(v any, i int) any {
switch v := v.(*Wechat); i {
case 0:
return &v.state
@ -1556,7 +1556,7 @@ func file_conf_conf_proto_init() {
return nil
}
}
file_conf_conf_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[6].Exporter = func(v any, i int) any {
switch v := v.(*Cmb); i {
case 0:
return &v.state
@ -1568,7 +1568,7 @@ func file_conf_conf_proto_init() {
return nil
}
}
file_conf_conf_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[7].Exporter = func(v any, i int) any {
switch v := v.(*WechatNotifyMQ); i {
case 0:
return &v.state
@ -1580,7 +1580,7 @@ func file_conf_conf_proto_init() {
return nil
}
}
file_conf_conf_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
file_conf_conf_proto_msgTypes[8].Exporter = func(v any, i int) any {
switch v := v.(*Alarm); i {
case 0:
return &v.state

View File

@ -38,6 +38,7 @@ func NewHTTPServer(
srv.Route("/voucher/").GET("notifyRetry/{id}", cmb.NotifyRetry)
srv.Route("/voucher/").GET("queryOrder/{order_no}", cmb.QueryOrder)
srv.Route("/voucher/").GET("queryByOrderNo/{order_no}", cmb.QueryByOrderNo)
v1.RegisterCmbHTTPServer(srv, cmb)

View File

@ -90,3 +90,55 @@ func (this *CmbService) QueryOrder(ctx http.Context) error {
"data": str,
})
}
func (this *CmbService) QueryByOrderNo(ctx http.Context) error {
// 获取访问ip
ip := ctx.Request().Header.Get("X-Forwarded-For")
if len(ip) == 0 {
ip = ctx.Request().RemoteAddr
}
if ip != "117.175.169.61" && ip != "127.0.0.1" {
return fmt.Errorf("ip check fail,IP:%s", ip)
}
orderNo := ctx.Vars().Get("order_no")
if orderNo == "" {
return fmt.Errorf("orderNo is empty")
}
order, err := this.VoucherBiz.OrderQuery(ctx, orderNo)
if err != nil {
return err
}
msg := "# <font color='green'>" +
"<h1>订单查询</h1>" +
"</font> \n" +
"<font color='black'>" +
"查询结果" +
"[<font color='red'>%s</font>]悉知" +
"</font>"
s := "\n订单号:%s\n招行订单号:%s\n订单状态:%s\nopenid:%s\n微信券ID:%s\n商品编号:%s\n批次号:%s\n商户号:%s\nappId:%s\n订单创建时间:%s\n" +
"领取成功时间(成功即有该值):%s\n最后一次核销时间(核销即有该值):%s\n订单备注说明(失败说明):%s\n"
orderMsg := fmt.Sprintf(s,
orderNo,
order.OutBizNo,
order.Status.GetText(),
order.Account,
order.VoucherNo,
order.ProductNo,
order.BatchNo,
order.MerchantNo,
order.AppID,
order.CreateTime.Format("2006-01-02 15:04:05"),
order.ReceiveSuccessTime.Format("2006-01-02 15:04:05"),
order.LastUseTime.Format("2006-01-02 15:04:05"),
order.Remark,
)
str := fmt.Sprintf(msg, orderMsg)
return ctx.String(http2.StatusOK, str)
}