From 1944391ccf352b09383ea660ae3519a378b4b27f Mon Sep 17 00:00:00 2001 From: li Date: Sat, 28 May 2022 15:24:17 +0800 Subject: [PATCH] fix: --- controller/activity.go | 4 +- controller/cb_goods_stock.go | 2 +- controller/cb_rent_order.go | 2 +- controller/game_test.go | 92 ++++++++++++++++++++++++++++++++++++ controller/order.go | 8 ++-- controller/user.go | 10 ++-- lib/wxpay/wx_pay.go | 12 ++--- 7 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 controller/game_test.go diff --git a/controller/activity.go b/controller/activity.go index a379da9..45c70ac 100644 --- a/controller/activity.go +++ b/controller/activity.go @@ -17,7 +17,7 @@ func UserRedeemCodeList(c *gin.Context) { } codeList, err := model.UserRedeemCodeList(uc.Uid) if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } @@ -41,7 +41,7 @@ func UserConvertRedeemCode(c *gin.Context) { } err := model.UserRedeemCodeConvert(uc.Uid, req.SerialCode) if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } diff --git a/controller/cb_goods_stock.go b/controller/cb_goods_stock.go index a1593ea..e4e8912 100644 --- a/controller/cb_goods_stock.go +++ b/controller/cb_goods_stock.go @@ -47,7 +47,7 @@ func CooperativeGameCardGoodsStockAdds(c *gin.Context) { } err := cardGoods.Adds(req.Cards) if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } diff --git a/controller/cb_rent_order.go b/controller/cb_rent_order.go index 4230723..93d4410 100644 --- a/controller/cb_rent_order.go +++ b/controller/cb_rent_order.go @@ -24,7 +24,7 @@ func CooperativeRentCardOrderList(c *gin.Context) { req.AssistantUid = uc.Uid list, count, err := req.List() if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } diff --git a/controller/game_test.go b/controller/game_test.go new file mode 100644 index 0000000..d6a8f4d --- /dev/null +++ b/controller/game_test.go @@ -0,0 +1,92 @@ +package controller + +import ( + "encoding/json" + "encoding/xml" + "fmt" + "github.com/codinl/go-logger" + "mh-server/lib/wxpay" + "testing" +) + +func TestPushWXPayNoticeTest(t *testing.T) { + PushWXPayNoticeTest() +} + +func PushWXPayNoticeTest() { + // body := []byte(` + // + // + // + // + // + // + // + // + // + // + // + // + // + // + //69900 + // + // + //`) + body := []byte(` + + + + + +6000 + + + + + + + + + + + + + + + + + +69900 + + +`) + var notifyInfo wxpay.WechatNotifyInfo + err := xml.Unmarshal(body, ¬ifyInfo) + if err != nil { + logger.Error(err) + } + //ret := WXPayNoticeResp{ + // ReturnCode: "FAIL", + //} + + //fmt.Println("notifyInfo:", notifyInfo) + //fmt.Printf("notifyInfo:%#v", notifyInfo) + notifyInfoJson, _ := json.Marshal(¬ifyInfo) + + fmt.Println("notifyInfoJson:", string(notifyInfoJson)) + //correctSign, err := PayCallBackHandle(notifyInfo, config.AppConfig.WxMchSecret) + correctSign, err := PayCallBackHandle(notifyInfo, "DeovoMingHuiRengTianTang45675456") + if err != nil { + logger.Error("PushWXPayNotice sign create fail") + return + } + if notifyInfo.Sign != correctSign { + fmt.Println("Sign-----:", notifyInfo.Sign) + fmt.Println("correctSign:", correctSign) + logger.Error("PushWXPayNotice sign verification fail") + return + } + fmt.Println("Sign:", notifyInfo.Sign) + fmt.Println("correctSign:", correctSign) +} diff --git a/controller/order.go b/controller/order.go index 67da50d..f9be8f1 100644 --- a/controller/order.go +++ b/controller/order.go @@ -385,14 +385,14 @@ func RentCardOrderCreate(c *gin.Context) { err := model.GameCardGoodsInventoryReduction(req.GameCardList, req.StoreId, tx) if err != nil { tx.Rollback() - logger.Error("inventory reduction err:%s", err.Error()) + logger.Error("inventory reduction err:", err.Error()) RespJson(c, status.InternalServerError, nil) return } err = order.CreatOrderCard(req.GameCardList, req.StoreId, tx) if err != nil { tx.Rollback() - logger.Error("inventory reduction err:%s", err.Error()) + logger.Error("inventory reduction err:", err.Error()) RespJson(c, status.InternalServerError, nil) return } @@ -450,14 +450,14 @@ func RentCardOrderCreate(c *gin.Context) { err = order.CreatOrderCard(req.GameCardList, req.StoreId, begin) if err != nil { begin.Rollback() - logger.Error("inventory reduction err:%s", err.Error()) + logger.Error("inventory reduction err:", err.Error()) RespJson(c, status.InternalServerError, nil) return } err = begin.Commit().Error if err != nil { begin.Rollback() - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } diff --git a/controller/user.go b/controller/user.go index 8712aeb..afb5d4e 100644 --- a/controller/user.go +++ b/controller/user.go @@ -600,7 +600,7 @@ func RefundDeposit(c *gin.Context) { resp, err := model.MemberExpireDelaying(uc.Uid) if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } @@ -641,7 +641,7 @@ func UserDepositRefundRecordList(c *gin.Context) { resp, err := model.GetDepositRefundRecordList(uc.Uid) if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } @@ -670,7 +670,7 @@ func UserMemberExpireDelayingInfo(c *gin.Context) { resp, err := model.MemberExpireDelaying(uc.Uid) if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } @@ -739,7 +739,7 @@ func MemberConfigList(c *gin.Context) { resp, err := model.MemberConfigInfo() if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } @@ -997,7 +997,7 @@ func InviteMemberReportList(c *gin.Context) { } list, totalPage, err := req.List() if err != nil { - logger.Errorf("err:", err) + logger.Errorf("err:%#v", err) RespJson(c, status.InternalServerError, nil) return } diff --git a/lib/wxpay/wx_pay.go b/lib/wxpay/wx_pay.go index d347a2a..07d494a 100644 --- a/lib/wxpay/wx_pay.go +++ b/lib/wxpay/wx_pay.go @@ -243,13 +243,9 @@ type ( CouponFee uint `xml:"coupon_fee,CDATA" json:"coupon_fee"` CouponCount uint `xml:"coupon_count,CDATA" json:"coupon_count"` - CouponType0 uint `xml:"coupon_type_0,CDATA" json:"coupon_type"` - CouponId0 string `xml:"coupon_id_0,CDATA" json:"coupon_id"` - CouponFee0 uint `xml:"coupon_fee_0,CDATA" json:"coupon_fee0"` - //CouponCount string `json:"coupon_count"` - //CouponFee string `json:"coupon_fee"` - //CouponFee0 string `json:"coupon_fee_0"` - //CouponId0 string `json:"coupon_id_0"` + CouponType0 uint `xml:"coupon_type_0,CDATA" json:"coupon_type_0"` + CouponId0 string `xml:"coupon_id_0,CDATA" json:"coupon_id_0"` + CouponFee0 uint `xml:"coupon_fee_0,CDATA" json:"coupon_fee_0"` CouponFee1 uint `xml:"coupon_fee_1,CDATA" json:"coupon_fee_1"` CouponId1 string `xml:"coupon_id_1,CDATA" json:"coupon_id_1"` @@ -259,6 +255,8 @@ type ( CouponId3 string `xml:"coupon_id_3,CDATA" json:"coupon_id_3"` CouponFee4 uint `xml:"coupon_fee_4,CDATA" json:"coupon_fee_4"` CouponId4 string `xml:"coupon_id_4,CDATA" json:"coupon_id_4"` + CouponFee5 uint `xml:"coupon_fee_5,CDATA" json:"coupon_fee_5"` + CouponId5 string `xml:"coupon_id_5,CDATA" json:"coupon_id_5"` TransactionId string `xml:"transaction_id,CDATA" json:"transaction_id"` OutTradeNo string `xml:"out_trade_no,CDATA" json:"out_trade_no"`