package camel_oil_api

import (
	_ "github.com/gogf/gf/contrib/nosql/redis/v2"
	"github.com/gogf/gf/v2/net/gclient"
	"github.com/gogf/gf/v2/os/gctx"
	"github.com/gogf/gf/v2/os/glog"
	"github.com/gogf/gf/v2/os/gtime"
	"kami/internal/logic/proxy_pool"
	"kami/internal/service"
	"testing"
)

func TestClient_SendCaptcha(t *testing.T) {
	client := NewClient(t.Context())
	isOk, err := client.SendCaptcha(t.Context(), "17862666120")
	glog.Info(t.Context(), isOk, err)
}

func TestClient_SendCard(t *testing.T) {
	for i := 0; i < 10000; i++ {
		client := gclient.New()

		req := struct {
			BodyStr string `json:"bodyStr"`
			Channel string `json:"channel"`
			Yanqian bool   `json:"yanqian"`
		}{
			BodyStr: "RSCkYgmxmejXt3Tn7b4+E2qV7bkhYXRTWeYwH8uHeupFo6cdxxv8GeyKAX2K0xWzE5lhlVJY+wPHswlO5nly46yaFBRKQ1ATo+J9uMezP8bvw0Ue483T8yYJy/gdqGQtv3+nBRqCD4Zb9QG75VIgrZhcGGN3XLKd3qd+lvrAOnCA5yhyGi7NnCNGFG7amgpEJL8DhUiy3vum+oe+4m8D0Qp9SrMhluDql5GrO0Kb6U3X0+ecD1sfSPOIGPQ82vIZsHRTnmKJNb/OUtJR5uKNURsZyBNlNprScv7WDsFy8jiKMBGgD59okxWpanxX/c2T0ijEyfcz8kJb06MzWrPubBFA+Ut7XNebiTMhFszDy5Y4DUFepby6ta+F5AOf62Ashuvu6MMoFP2woryfaYrovDgEAtttmj9iXoZUJCPG7NY6XaXFkmIlRTY7WtFy807v/vo4rppTYw+a3yfcMPya8wP0lKSIn7x4ubUUdiF3Gi8ro8YMJmYoMyYgQ3g27ZJpK99KcwhwkwhoP0mS7tf25pd3IrScds2o2jtuSxHHDFkH1muRnsNG/qgdG3W7gUdyap53i92dqWPGZHdhRPTl23Xw9PwVPf1t1NJ3nYluBq+awye0ZUK1BjGebKEoBbVN7Mg6pkNN5OjwFDz6jCvdTNpIrKTcIt8+yAt6h0BST6Q=",
			Channel: "app",
			Yanqian: true,
		}
		client.SetHeader("authorization", "Bearer NOsm3aE1symoxiqciCUG6FkzpqT3ebhGbWlAxTZa+ipzSXBhToyHaVrtYlKEtIjHqKwael5dsdUQuNA0bvqe3lYwx8a2w4RoJS8AFT690Yzuef0ASNU0YGP5OujpPrAkyBxMwl7tvQntVd2nj2kLecF14pjNeE5YsjgZ5G6mEYg=")
		result, err := client.ContentJson().Post(t.Context(), "https://recharge3.bac365.com/camel_wechat_mini_oil_server/eCardMall/wechatCardOrder", req)
		glog.Info(t.Context(), result.ReadAllString(), err)
	}
}

func TestClient_LoginWithCaptcha(t *testing.T) {
	client := NewClient(t.Context())
	isOk, err := client.LoginWithCaptcha(t.Context(), "19224625031", "063713")
	glog.Info(t.Context(), isOk, err)
	//	2025-11-27T17:14:24.131+08:00 [INFO]
}

func TestClient_CreateOrder(t *testing.T) {
	service.RegisterProxyPool(proxy_pool.New())
	_ = service.ProxyPool().InitStrategy(gctx.GetInitCtx(), "http://api.dmdaili.com/dmgetip.asp?apikey=42bab0ac&pwd=1b567c2f286a08e391b5805565fa0882&getnum=1&httptype=1&geshi=1&fenge=3&fengefu=&operate=all", gtime.M)
	client := NewClient(t.Context())
	resp, err := client.Client.Get(t.Context(), "https://www.baidu.com")
	t.Log(resp.ReadAllString(), err, resp.StatusCode, resp.ReadAllString())
	//ticker := time.NewTicker(time.Second * 1)
	//for range ticker.C {
	//	orderId, payUrl, err := client.CreateCamelOilOrder(t.Context(), "19247252286", "D/k6sTlhbNrGk798lDhAP88qlJKYqMyiz9ESzmKW6uiuvj1ZWSPOlCgv3L0pEEr871Vuxr9tBAA4BiH2RTuSaYugq458wOjsJedfyGGHRyZZyMzZ/Tl6Km2vKT2Dph2/n9FaqNwErxNeq0+11x9q7VnBhhJTjxVIYN/fe3TB/m4=", 100)
	//	if err == nil {
	//		glog.Info(t.Context(), orderId, payUrl, err)
	//		return
	//	}
	//	glog.Info(t.Context(), orderId, payUrl, err)
	//}
}
