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

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