互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.5 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package test
  2. import (
  3. "fmt"
  4. "github.com/chanxuehong/wechat/mch/core"
  5. "hudongzhuanjia/libs/im"
  6. "hudongzhuanjia/logger"
  7. im_service "hudongzhuanjia/services/im"
  8. pay_service "hudongzhuanjia/services/pay"
  9. "hudongzhuanjia/utils"
  10. "math"
  11. "testing"
  12. "time"
  13. )
  14. var openId = "o9XM41s_NN8Y0QK6_MbM-aYMV3TE"
  15. func TestTransfer(t *testing.T) {
  16. res, err := pay_service.Transfer("欧轩互动-转账测试", openId, utils.RandomStr(32), 0.30*100)
  17. fmt.Println(err)
  18. fmt.Printf("%+v\n", res)
  19. }
  20. func TestSendRedPack(t *testing.T) {
  21. res, err := pay_service.SendRedPack("欧轩互动-红包测试", openId,
  22. "你好测试", "tommy",
  23. "哈哈哈哈哈", 1, 1, 1)
  24. fmt.Println(err)
  25. fmt.Printf("%+v\n", res)
  26. }
  27. func TestQueryOrder(t *testing.T) {
  28. //outTradeNo := "Dn13Gl6A6dB6aOae7syqtXSwUvCZ3mta"
  29. outTradeNo := "6PM9n5WDSX47frNfQ9OxWEKe8u6ChBos"
  30. res, err := pay_service.OrderQuery(outTradeNo)
  31. fmt.Println(err)
  32. fmt.Printf("%+v\n", res)
  33. }
  34. func TestClose(t *testing.T) {
  35. pay_service.Close("jGrqipGJdcxQz4uwSTQqrtnJ4rJE6Mx9")
  36. }
  37. func TestTimeExpire(t *testing.T) {
  38. now := time.Now()
  39. t1 := "202004174430"
  40. t2 := core.FormatTime(time.Now())
  41. t3, _ := core.ParseTime(t1)
  42. fmt.Println(t1, t2)
  43. fmt.Println(t1 > t2)
  44. fmt.Println(t3.Unix() > now.Unix())
  45. fmt.Println(t1, t2, core.FormatTime(t3))
  46. fmt.Println(t3.Unix(), now.Unix())
  47. }
  48. func TestSendNotice(t *testing.T) {
  49. for {
  50. err := im_service.SendGroupCustomMessage(4, 118, im_service.NoticeReward,
  51. map[string]interface{}{
  52. "amount": 20.01,
  53. "content": "恭喜你发出",
  54. "timestamp": time.Now().Unix(),
  55. })
  56. fmt.Print(err)
  57. }
  58. }
  59. func TestGenSig(t *testing.T) {
  60. fmt.Print(im.GenSig("admin"))
  61. }
  62. // 地球半径,单位米
  63. const R = 6367000
  64. //const R = 6378.137
  65. func rad(d float64) float64 {
  66. return d * math.Pi / 180.0
  67. }
  68. // lonA, latA分别为A点的纬度和经度
  69. // lonB, latB分别为B点的纬度和经度
  70. // 返回的距离单位为米
  71. func Sphere(lonA, latA, lonB, latB float64) float64 {
  72. c := math.Sin(latA)*math.Sin(latB)*math.Cos(lonA-lonB) + math.Cos(latA)*math.Cos(latB)
  73. return R * math.Acos(c) * math.Pi / 180
  74. }
  75. func TestSphere(t *testing.T) {
  76. lonA, latA := 43.653887, 108.197424
  77. lonB, latB := 42.901128, 107.562718
  78. a := Sphere(lonA, latA, lonB, latB)
  79. fmt.Print(a / 1000.0)
  80. }
  81. func TestMy(t *testing.T) {
  82. a := `SELECT
  83. shop_id ,
  84. shop_name ,
  85. lng ,
  86. lat ,
  87. POWER(lat - 40.05748 , 2) + POWER(lng - 116.30759 , 2) * POWER(COS((lat + 40.05748) / 2) , 2) AS distance
  88. FROM
  89. shop_list
  90. HAVING
  91. distance < 1000
  92. ORDER BY
  93. distance
  94. LIMIT 100;
  95. `
  96. fmt.Print(a)
  97. }
  98. func TestLogger(t *testing.T) {
  99. var i = 0
  100. for {
  101. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  102. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  103. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  104. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  105. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  106. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  107. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  108. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  109. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  110. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  111. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  112. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  113. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  114. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  115. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  116. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  117. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  118. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  119. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  120. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  121. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  122. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  123. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  124. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  125. i++
  126. if i > 10000000000 {
  127. break
  128. }
  129. }
  130. }
  131. func TestSendGroupMessage(t *testing.T) {
  132. err := im_service.SendGroupCustomMessage("admin", 314, im_service.NoticeLotteryDrawRollStart,
  133. map[string]interface{}{
  134. "lottery_draw_ladder_id": 1,
  135. "timestamp": time.Now().Unix(),
  136. "roll_num": 1,
  137. "desc": "开始滚动",
  138. "number": 1,
  139. })
  140. if err != nil {
  141. t.Error(err)
  142. }
  143. }