animeic 1 年之前
父節點
當前提交
f6fc7cc808
共有 5 個文件被更改,包括 27 次插入2 次删除
  1. 二進制
      pay/__debug_bin
  2. 2 2
      pay/api/singleWechatPayCallback.go
  3. 1 0
      pay/assettest.log
  4. 1 0
      pay/bus/nats.go
  5. 23 0
      pay/bus/order.go

二進制
pay/__debug_bin


+ 2 - 2
pay/api/singleWechatPayCallback.go

@@ -44,9 +44,9 @@ func (a *SingleWechatPayCallback) CallBack(c *http.Request) (interface{}, error)
 
 	orderSlice := strings.Split(result.OutTradeNo, "_")
 	orderId, _ := primitive.ObjectIDFromHex(orderSlice[1])
-	var payMode int32 = 1
+	var payMod int32 = 1
 	// orderSlice[0] 代表来源 QS
-	res := &pay.OrderMsg{Id: orderId, PayMod: &payMode, Project: orderSlice[0]}
+	res := &pay.OrderMsg{Id: orderId, PayMod: &payMod, Project: orderSlice[0]}
 	if result.TradeState == "SUCCESS" {
 		fmt.Println("----------------success----------------------")
 		// err = bus.NatsCenter.PushMessage(comm.NewAppPaySuccSubject(orderSlice[0]), res)

+ 1 - 0
pay/assettest.log

@@ -39,3 +39,4 @@
 {"level":"info","timestamp":"2023-07-06 17:30:09","message":"[初始化支付客户端]","service_name":"assettest"}
 {"level":"error","timestamp":"2023-07-06 17:35:37","message":"{\"code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"msg\":\"Business Failed\",\"sub_code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"sub_msg\":\"商户协议状态非正常状态\"}","service_name":"assettest"}
 {"level":"info","timestamp":"2023-07-06 17:48:22","message":"[初始化支付客户端]","service_name":"assettest"}
+{"level":"info","timestamp":"2023-07-07 10:00:12","message":"[初始化支付客户端]","service_name":"assettest"}

+ 1 - 0
pay/bus/nats.go

@@ -27,6 +27,7 @@ func NewNatsBus(app *conf.AppConf) *comm.NatsBus {
 		GetPointAmount(),
 		PayOrderCreate(),
 		PayOrderDetail(),
+		PayOrderUpdate(),
 	})
 	NatsCenter = bus
 	return NatsCenter

+ 23 - 0
pay/bus/order.go

@@ -10,6 +10,7 @@ import (
 
 	"github.com/nats-io/nats.go"
 	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.mongodb.org/mongo-driver/mongo"
 	"infish.cn/comm"
 	"infish.cn/comm/pay"
 )
@@ -65,3 +66,25 @@ func getPayOrder(ctx context.Context, query map[string]interface{}) (order *pay.
 	order.RealAmount = &amount
 	return
 }
+
+// 更新订单
+func PayOrderUpdate() *comm.NatsMsgReplyer {
+	order := pay.Order{}
+	utils.ConsoleFormat(pay.PayOrderUpdateApi)
+	return &comm.NatsMsgReplyer{
+		Subject: pay.PayOrderUpdateApi,
+		Entity:  func() interface{} { return &order },
+		Cb2: func(_ *nats.Msg, entity interface{}) (interface{}, error) {
+			order := entity.(*pay.Order)
+			ctx := context.Background()
+			res, err := updateOrder(ctx, order)
+			return res, err
+		},
+	}
+}
+
+func updateOrder(ctx context.Context, order *pay.Order) (result *mongo.UpdateResult, err error) {
+	result, err = repo.RepoUpdateSetDoc(&repo.RepoSession{Ctx: ctx, Client: db.GMongoDb}, repo.CollectionOrder, order.Id.Hex(), &order)
+
+	return
+}