package sfps2 import ( "fmt" "git.rosy.net.cn/baseapi/utils" "strings" "testing" ) var api = New(AppID, AppKey) //测试 //var api = New(AppID2, AppKey2) //正式 const ( //正式环境 AppID2 = 1663705444 AppKey2 = "600e22db5deb6402e527e58f0d6636a0" AppID = 1663705378 //测试开发者ID AppKey = "0838426b310fd2530c57dd6e770ddff1" //测试开发者密钥 TestSFStoreID = "3243279847393" //open测试平台型店铺 ) //预下单 func TestPreCreateOrder(t *testing.T) { param := &PreCreateOrderReq{ DevId: 1663705444, ShopId: "3270426476337", UserLng: "104.052898", UserLat: "30.685366", UserAddress: "四川省成都市金牛区抚琴街道洛克中心写字楼", Weight: 1, ProductType: 6, PushTime: 1691550274, ShopType: 1, CityName: "", TotalPrice: 0, IsAppoint: 0, AppointType: 0, ExpectTime: 0, LbsType: 2, IsInsured: 0, IsPersonDirect: 0, Vehicle: 0, DeclaredValue: 0, GratuityFee: 0, RiderPickMethod: 1, ReturnFlag: 1, //Shop: { // "shop_name": "印象汇果园测试店", // "shop_phone": "18981810340", // "shop_address": "成都市金牛区沙湾路1号汇龙湾生活广场", // "shop_lng": "104.052898", // "shop_lat": "30.685366" //}, //"multi_pickup_info": null } resp, err := api.PreCreateOrder(param) fmt.Println(resp) fmt.Println(err) } //正式下单 func TestCreateOrder(t *testing.T) { param := &CreateOrderReq{ DevId: AppID, ShopId: TestSFStoreID, ShopType: 1, ShopOrderId: "20240110", OrderSequence: "测试", OrderSource: OrderSourceELM, OrderTime: 1694168441, LbsType: LbsTypeGD, PushTime: 1694168441, Version: 19, ReturnFlag: 511, Receive: &ReceiveAddress{ UserLng: "116.339392", UserLat: "40.002349", UserAddress: "北京市海淀区学清嘉创大厦A座15层", UserName: "杨玺", UserPhone: "17236456352", }, OrderDetail: &OrderDetail{ TotalPrice: 890, ProductType: 4, WeightGram: 390, ProductNum: 1, ProductTypeNum: 1, ProductDetail: []*ProductDetail{{ ProductName: "新鲜水果拼盘", ProductNum: 1, }}, }, RiderPickMethod: 1, } sfOrderID, sfBillID, totalPrice, err, _ := api.CreateOrder(param) fmt.Println(sfOrderID, sfBillID) fmt.Println(totalPrice) fmt.Println(err) } //预取消订单 func TestPreCancelOrder(t *testing.T) { resp, err := api.PreCancelOrder("JS8556325634982") fmt.Println(resp) fmt.Println(err) } //取消订单 func TestCancelOrder(t *testing.T) { err := api.CancelOrder("JS4157196256886") fmt.Println(err) } //订单实时信息查询 func TestGetOrderStatus(t *testing.T) { resp, err := api.GetOrderStatus("JS4157016257273") fmt.Println(utils.Format4Output(resp, false)) fmt.Println(err) } // func TestGetRiderLatestPosition(t *testing.T) { resp, err := api.GetRiderLatestPosition("JS4157016257273") fmt.Println(utils.Format4Output(resp, false)) fmt.Println(err) } func TestNew(t *testing.T) { te := strings.Split("113.71776,34.767501", ",") if len(te) > 0 { fmt.Println(te[0], te[1]) lng := utils.Str2Float64(te[0]) lat := utils.Str2Float64(te[1]) fmt.Println(lng, lat) } } func Test2(t *testing.T) { //n, _ := rand.Int(rand.Reader, big.NewInt(10000000000)) //println(n.Int64()) //var }