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

139 lines
4.0 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
  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(114, im.NoticeShakeRedPackStart, map[string]interface{}{
  49. "customer_id": 1,
  50. "shake_red_envelope_rule_id": 2,
  51. "timestamp": time.Now().Unix(),
  52. })
  53. fmt.Print(err)
  54. }
  55. }
  56. // 地球半径,单位米
  57. const R = 6367000
  58. //const R = 6378.137
  59. func rad(d float64) float64 {
  60. return d * math.Pi / 180.0
  61. }
  62. // lonA, latA分别为A点的纬度和经度
  63. // lonB, latB分别为B点的纬度和经度
  64. // 返回的距离单位为米
  65. func Sphere(lonA, latA, lonB, latB float64) float64 {
  66. c := math.Sin(latA)*math.Sin(latB)*math.Cos(lonA-lonB) + math.Cos(latA)*math.Cos(latB)
  67. return R * math.Acos(c) * math.Pi / 180
  68. }
  69. func TestSphere(t *testing.T) {
  70. lonA, latA := 43.653887, 108.197424
  71. lonB, latB := 42.901128, 107.562718
  72. a := Sphere(lonA, latA, lonB, latB)
  73. fmt.Print(a / 1000.0)
  74. }
  75. func TestMy(t *testing.T) {
  76. a := `SELECT
  77. shop_id ,
  78. shop_name ,
  79. lng ,
  80. lat ,
  81. POWER(lat - 40.05748 , 2) + POWER(lng - 116.30759 , 2) * POWER(COS((lat + 40.05748) / 2) , 2) AS distance
  82. FROM
  83. shop_list
  84. HAVING
  85. distance < 1000
  86. ORDER BY
  87. distance
  88. LIMIT 100;
  89. `
  90. fmt.Print(a)
  91. }
  92. func TestLogger(t *testing.T) {
  93. var i = 0
  94. for {
  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. 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. i++
  120. if i > 10000000000 {
  121. break
  122. }
  123. }
  124. }