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

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