animeic 1 년 전
부모
커밋
f54912b8a7
3개의 변경된 파일30개의 추가작업 그리고 0개의 파일을 삭제
  1. 25 0
      pay/api/point.go
  2. 3 0
      pay/assettest.log
  3. 2 0
      pay/bus/order.go

+ 25 - 0
pay/api/point.go

@@ -2,6 +2,8 @@ package api
 
 import (
 	"errors"
+	"fmt"
+	"pay/bus"
 	"pay/db/repo"
 	"pay/log"
 	"time"
@@ -19,6 +21,29 @@ func PayPoint(r *GinRouter) {
 	r.GET("/point/detail/:id", PayDetail)
 	r.POSTJWT("/point/update", UpdatePay)
 
+	r.POST("pay/succ/test", PaySuccTest)
+	r.POST("pay/fail/test", PayFailTest)
+
+}
+
+func PaySuccTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	orderId, _ := primitive.ObjectIDFromHex("64a67e3783648284a3eebeef")
+	var payMode int32 = 1
+	res := &pay.OrderMsg{Id: orderId, PayMod: &payMode, Project: "QS"}
+
+	fmt.Println("----------------success-----------------------")
+	err := bus.NatsCenter.PushMessage(pay.NewAppPaySuccSubject("QS"), res)
+	return err, nil
+
+}
+func PayFailTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	orderId, _ := primitive.ObjectIDFromHex("64a67e3783648284a3eebeef")
+	var payMode int32 = 1
+	res := &pay.OrderMsg{Id: orderId, PayMod: &payMode, Project: "QS"}
+
+	fmt.Println("----------------fail-----------------------")
+	err := bus.NatsCenter.PushMessage(pay.NewAppPayFailSubject("QS"), res)
+	return err, nil
 }
 
 func CreatePay(c *gin.Context, apictx *ApiSession) (interface{}, error) {

+ 3 - 0
pay/assettest.log

@@ -40,3 +40,6 @@
 {"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"}
+{"level":"info","timestamp":"2023-07-07 14:21:10","message":"[初始化支付客户端]","service_name":"assettest"}
+{"level":"info","timestamp":"2023-07-07 14:36:21","message":"[初始化支付客户端]","service_name":"assettest"}
+{"level":"info","timestamp":"2023-07-07 14:47:56","message":"[初始化支付客户端]","service_name":"assettest"}

+ 2 - 0
pay/bus/order.go

@@ -7,6 +7,7 @@ import (
 	"pay/db/repo"
 	"pay/utils"
 	"strconv"
+	"time"
 
 	"github.com/nats-io/nats.go"
 	"go.mongodb.org/mongo-driver/bson/primitive"
@@ -84,6 +85,7 @@ func PayOrderUpdate() *comm.NatsMsgReplyer {
 }
 
 func updateOrder(ctx context.Context, order *pay.Order) (result *mongo.UpdateResult, err error) {
+	order.UpdateTime = time.Now()
 	result, err = repo.RepoUpdateSetDoc(&repo.RepoSession{Ctx: ctx, Client: db.GMongoDb}, repo.CollectionOrder, order.Id.Hex(), &order)
 
 	return