|
@@ -2,11 +2,7 @@ package bus
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
- "fmt"
|
|
|
- "pay/db"
|
|
|
"pay/db/model"
|
|
|
- "pay/db/repo"
|
|
|
- "pay/log"
|
|
|
"pay/utils"
|
|
|
|
|
|
"github.com/nats-io/nats.go"
|
|
@@ -25,7 +21,7 @@ func (s *SinglePay) CreateQr() *comm.NatsMsgReplyer {
|
|
|
Entity: func() interface{} { return &pay.OrderMsg{} },
|
|
|
Cb2: func(_ *nats.Msg, entity interface{}) (interface{}, error) {
|
|
|
m := entity.(*pay.OrderMsg)
|
|
|
- pay := PayMod(int(*m.PayMod), SINGLE)
|
|
|
+ pay := PayMod(int(*m.PayMod))
|
|
|
ctx := context.Background()
|
|
|
res, err := pay.Pay(ctx, m)
|
|
|
return res, err
|
|
@@ -42,7 +38,7 @@ func (s *SinglePay) CloseOrder() *comm.NatsMsgReplyer {
|
|
|
Entity: func() interface{} { return &pay.OrderMsg{} },
|
|
|
Cb2: func(_ *nats.Msg, entity interface{}) (interface{}, error) {
|
|
|
m := entity.(*pay.OrderMsg)
|
|
|
- pay := PayMod(int(*m.PayMod), SINGLE)
|
|
|
+ pay := PayMod(int(*m.PayMod))
|
|
|
ctx := context.Background()
|
|
|
flag, err := pay.Close(ctx, m)
|
|
|
return flag, err
|
|
@@ -53,17 +49,17 @@ func (s *SinglePay) CloseOrder() *comm.NatsMsgReplyer {
|
|
|
// 退款
|
|
|
func (s *SinglePay) Refund() *comm.NatsMsgReplyer {
|
|
|
utils.ConsoleFormat(pay.PaySingleRefundApi)
|
|
|
-
|
|
|
+ refund := pay.ReFund{}
|
|
|
return &comm.NatsMsgReplyer{
|
|
|
Subject: pay.PaySingleRefundApi,
|
|
|
- Entity: func() interface{} { return &pay.ReFund{} },
|
|
|
+ Entity: func() interface{} { return &refund },
|
|
|
Cb2: func(_ *nats.Msg, entity interface{}) (interface{}, error) {
|
|
|
- refund := entity.(*model.ReFund)
|
|
|
+ refund := entity.(*pay.ReFund)
|
|
|
// ???适配缺失退款理由
|
|
|
if refund.Reason == "" {
|
|
|
refund.Reason = "默认退款"
|
|
|
}
|
|
|
- pay := PayMod(int(*refund.PayMode), SINGLE)
|
|
|
+ pay := PayMod(int(*refund.PayMod))
|
|
|
ctx := context.Background()
|
|
|
flag, err := pay.ReFundPay(ctx, refund)
|
|
|
return flag, err
|
|
@@ -80,43 +76,10 @@ func (s *SinglePay) RefundQuery() *comm.NatsMsgReplyer {
|
|
|
Entity: func() interface{} { return &model.ReFund{} },
|
|
|
Cb2: func(_ *nats.Msg, entity interface{}) (interface{}, error) {
|
|
|
m := entity.(*model.ReFund)
|
|
|
- pay := PayMod(int(*m.PayMode), SINGLE)
|
|
|
+ pay := PayMod(int(*m.PayMode))
|
|
|
ctx := context.Background()
|
|
|
status, err := pay.ReFundQuery(ctx, m)
|
|
|
return status, err
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-// 支付成功
|
|
|
-func (s *SinglePay) SuccPayStream() *comm.NatsStreamWather {
|
|
|
- res := &model.ResData{}
|
|
|
- // "queenshow-pay-succ#queenshow.paysucc#queenshow-paysucc-queue
|
|
|
- return &comm.NatsStreamWather{
|
|
|
- Stream: "queenshow-pay-succ",
|
|
|
- Topic: "queenshow.paysucc",
|
|
|
- Queue: "queenshow-paysucc-queue",
|
|
|
- AckWaitMinute: int64(1),
|
|
|
- Entity: func() interface{} { return res },
|
|
|
- Cb: func(msg *nats.Msg, entity interface{}) {
|
|
|
- defer func() {
|
|
|
- if err := recover(); err != nil {
|
|
|
- log.Info("系统异常", err)
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- session := &repo.RepoSession{Client: db.GMongoDb}
|
|
|
- fmt.Println(session.Client.Database.Name())
|
|
|
-
|
|
|
- // fmt.Println("===============购买结果返回=================")
|
|
|
- // log.Info("===============购买结果返回=================")
|
|
|
- // data := entity.(*model.ResData)
|
|
|
- // orderMsg := data.Data.(map[string]interface{})
|
|
|
- // flag, _ := Paied(data.Code, orderMsg["_id"].(string), int(orderMsg["payMode"].(float64)), session)
|
|
|
- // if flag {
|
|
|
- // msg.Ack()
|
|
|
- // }
|
|
|
- },
|
|
|
- }
|
|
|
-
|
|
|
-}
|