互动
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.

145 lines
4.1 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
  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, "你好测试", "192.168.1.103", "tommy",
  22. "哈哈哈哈哈", 1, 1, 1)
  23. fmt.Println(err)
  24. fmt.Printf("%+v\n", res)
  25. }
  26. func TestQueryOrder(t *testing.T) {
  27. //outTradeNo := "Dn13Gl6A6dB6aOae7syqtXSwUvCZ3mta"
  28. outTradeNo := "6PM9n5WDSX47frNfQ9OxWEKe8u6ChBos"
  29. res, err := pay_service.OrderQuery(outTradeNo)
  30. fmt.Println(err)
  31. fmt.Printf("%+v\n", res.Query)
  32. }
  33. func TestClose(t *testing.T) {
  34. pay_service.Close("jGrqipGJdcxQz4uwSTQqrtnJ4rJE6Mx9")
  35. }
  36. func TestTimeExpire(t *testing.T) {
  37. now := time.Now()
  38. t1 := "202004174430"
  39. t2 := core.FormatTime(time.Now())
  40. t3, _ := core.ParseTime(t1)
  41. fmt.Println(t1, t2)
  42. fmt.Println(t1 > t2)
  43. fmt.Println(t3.Unix() > now.Unix())
  44. fmt.Println(t1, t2, core.FormatTime(t3))
  45. fmt.Println(t3.Unix(), now.Unix())
  46. }
  47. func TestSendNotice(t *testing.T) {
  48. for {
  49. err := im_service.SendGroupCustomMessage(4, 118, im_service.NoticeReward,
  50. map[string]interface{}{
  51. "amount": 20.01,
  52. "content": "恭喜你发出",
  53. "timestamp": time.Now().Unix(),
  54. })
  55. fmt.Print(err)
  56. }
  57. }
  58. func TestGenSig(t *testing.T) {
  59. fmt.Print(im.GenSig("admin"))
  60. }
  61. // 地球半径,单位米
  62. const R = 6367000
  63. //const R = 6378.137
  64. func rad(d float64) float64 {
  65. return d * math.Pi / 180.0
  66. }
  67. // lonA, latA分别为A点的纬度和经度
  68. // lonB, latB分别为B点的纬度和经度
  69. // 返回的距离单位为米
  70. func Sphere(lonA, latA, lonB, latB float64) float64 {
  71. c := math.Sin(latA)*math.Sin(latB)*math.Cos(lonA-lonB) + math.Cos(latA)*math.Cos(latB)
  72. return R * math.Acos(c) * math.Pi / 180
  73. }
  74. func TestSphere(t *testing.T) {
  75. lonA, latA := 43.653887, 108.197424
  76. lonB, latB := 42.901128, 107.562718
  77. a := Sphere(lonA, latA, lonB, latB)
  78. fmt.Print(a / 1000.0)
  79. }
  80. func TestMy(t *testing.T) {
  81. a := `SELECT
  82. shop_id ,
  83. shop_name ,
  84. lng ,
  85. lat ,
  86. POWER(lat - 40.05748 , 2) + POWER(lng - 116.30759 , 2) * POWER(COS((lat + 40.05748) / 2) , 2) AS distance
  87. FROM
  88. shop_list
  89. HAVING
  90. distance < 1000
  91. ORDER BY
  92. distance
  93. LIMIT 100;
  94. `
  95. fmt.Print(a)
  96. }
  97. func TestLogger(t *testing.T) {
  98. var i = 0
  99. for {
  100. logger.Info("亚洲舞王罗志祥, 多人运动领头羊.")
  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. i++
  125. if i > 10000000000 {
  126. break
  127. }
  128. }
  129. }