From 8c6f6a6dcfffaf21f21f25992c074c52fa0f490d Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Fri, 1 Sep 2023 11:28:42 +0800 Subject: [PATCH] update --- app/db/db_qrcode_with_batch_records.go | 2 +- app/hdl/hdl_demo.go | 12 ++++++++---- app/hdl/hdl_wx.go | 23 +++++++++++++++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/app/db/db_qrcode_with_batch_records.go b/app/db/db_qrcode_with_batch_records.go index 1df6e55..16d822a 100644 --- a/app/db/db_qrcode_with_batch_records.go +++ b/app/db/db_qrcode_with_batch_records.go @@ -60,7 +60,7 @@ func (qrcodeWithBatchRecordsDb *QrcodeWithBatchRecordsDb) FindQrcodeWithBatchRec return } func (qrcodeWithBatchRecordsDb *QrcodeWithBatchRecordsDb) UpdateQrcodeWithBatchRecord(m *model.QrcodeWithBatchRecords) (int64, error) { - affected, err := qrcodeWithBatchRecordsDb.Db.Where("id =?", m.Id).FindAndCount(&m) + affected, err := qrcodeWithBatchRecordsDb.Db.Where("id =?", m.Id).Update(m) if err != nil { return 0, err } diff --git a/app/hdl/hdl_demo.go b/app/hdl/hdl_demo.go index b3040bd..3e14b42 100644 --- a/app/hdl/hdl_demo.go +++ b/app/hdl/hdl_demo.go @@ -26,14 +26,18 @@ func Demo(c *gin.Context) { } func Demo1(c *gin.Context) { - post, err := utils.CurlPost("http://pay.izhyin.com/wx/redPackage/index", map[string]string{ - "re_openid": "oLAbGuMC5o6fJRcLSicj0MENGoEo", - "amount": "100.00", - }, nil) + DealCallBack("oLAbGuMC5o6fJRcLSicj0MENGoEo", "1692603601358587_sVxAbe") + post, err := utils.CurlPost("http://pay.com/wx/redPackage/index", utils.SerializeStr(map[string]string{ + "openid": "oLAbGuMC5o6fJRcLSicj0MENGoEo", + "amount": "100.00", + }), nil) if err != nil { fmt.Println(err) } + fmt.Println(post) + e.OutSuc(c, post, nil) + //eg := commDb.DBs[c.GetString("mid")] //sess := eg.NewSession() ////r, err := eg.Table("user_profile").Where("uid=21699").Incr("fin_valid", 10).Exec() diff --git a/app/hdl/hdl_wx.go b/app/hdl/hdl_wx.go index a43fb60..28d8090 100644 --- a/app/hdl/hdl_wx.go +++ b/app/hdl/hdl_wx.go @@ -214,26 +214,41 @@ func DealCallBack(openId, ticket string) error { } //4、发送微信红包 - post, err := utils.CurlPost("http://pay.izhyin.com/wx/redPackage/index", map[string]string{ + post, err := utils.CurlPost("http://pay.izhyin.com/wx/redPackage/index", utils.SerializeStr(map[string]string{ "openid": openId, "amount": utils.Float64ToStr(utils.StrToFloat64(qrcodeWithBatchRecord.Amount) * 100), - }, nil) + }), nil) + if err != nil { + return err + } utils.FilePutContents("send_redPackage", utils.SerializeStr(map[string]interface{}{ "args": map[string]string{ "openid": openId, "amount": utils.Float64ToStr(utils.StrToFloat64(qrcodeWithBatchRecord.Amount) * 100), }, - "resp": post, + "resp": string(post), })) + + var result struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` + } + err = json.Unmarshal(post, &result) if err != nil { return err } + var data md.SendRedPackageResp - err = json.Unmarshal(post, &data) + err = json.Unmarshal(utils.Serialize(result.Data), &data) if err != nil { return err } + utils.FilePutContents("send_redPackage", utils.SerializeStr(map[string]interface{}{ + "data": data, + })) + if data.ReturnCode != "SUCCESS" || data.ResultCode != "SUCCESS" { return errors.New(data.ReturnMsg) }