diff --git a/controllers/client/live.go b/controllers/client/live.go index 3a657f0..939bfbe 100644 --- a/controllers/client/live.go +++ b/controllers/client/live.go @@ -20,7 +20,6 @@ type LiveCtl struct { func (t *LiveCtl) Detail() { activityId := t.MustGetInt64("activity_id") areaId := t.MustGetInt64("area_id") - //var userId int64 = 0 userId := t.MustGetUID() err := new(models.LiveViewer).Record(userId, activityId) @@ -72,6 +71,7 @@ func (t *LiveCtl) LoopQuery() { } // 发送红包 +// 维护一个队列进行循环, 遍历是否付款成功 func (t *LiveCtl) SendLiveRedPack() { userId := t.MustGetUID() // 用户 uid activityId := t.MustGetInt64("activity_id") // activity_id @@ -116,10 +116,6 @@ func (t *LiveCtl) SendLiveRedPack() { t.JSON(info) } -func (t *LiveCtl) QueryRedPack() { - -} - // 领取红包 func (t *LiveCtl) GetRedPack() { liveRedPackInfoId := t.MustGetInt64("live_red_pack_info_id") diff --git a/services/pay/transfer.go b/services/pay/transfer.go index f9b0a10..a708a0e 100644 --- a/services/pay/transfer.go +++ b/services/pay/transfer.go @@ -59,10 +59,17 @@ type RedPackResult struct { // 发送红包 func SendRedPack(sendName, openId, wishing, ip, actName, remark string, totalAmount, totalNum, scene int) (*RedPackResult, error) { + client, err := Client() + if err != nil { + return nil, err + } + mchBillNo := utils.RandomStr(28) nonceStr := utils.RandomStr(32) body := make(map[string]string, 0) + body["wxappid"] = client.AppId() + body["mch_id"] = client.MchId() body["nonce_str"] = nonceStr body["mch_billno"] = mchBillNo body["send_name"] = sendName @@ -74,10 +81,7 @@ func SendRedPack(sendName, openId, wishing, ip, actName, remark string, totalAmo body["act_name"] = actName body["remark"] = remark body["scene_id"] = fmt.Sprintf("PRODUCT_%d", scene) - body["ppid"] = Appid - body["mch_id"] = Mchid - client, err := Client() m, err := mmpaymkttransfers.SendRedPack(client, body) if err != nil { return nil, err diff --git a/test/pay_test.go b/test/pay_test.go index b7bb96c..6f89e1a 100644 --- a/test/pay_test.go +++ b/test/pay_test.go @@ -6,8 +6,17 @@ import ( "testing" ) +var openId = "o9XM41s_NN8Y0QK6_MbM-aYMV3TE" + func TestTransfer(t *testing.T) { - res, err := pay_service.Transfer("欧轩互动-转账测试", "127.0.0.1", "o9XM41s_NN8Y0QK6_MbM-aYMV3TE", 30) + res, err := pay_service.Transfer("欧轩互动-转账测试", "127.0.0.1", openId, 0.30*100) + fmt.Println(err) + fmt.Printf("%+v\n", res) +} + +func TestSendRedPack(t *testing.T) { + res, err := pay_service.SendRedPack("欧轩互动-红包测试", openId, "你好测试", "192.168.1.103", "tommy", + "哈哈哈哈哈", 1, 1, 1) fmt.Println(err) fmt.Printf("%+v\n", res) }