package otosaas import ( "git.oa00.com/go/otosaas/config" "log" "testing" "time" ) func init() { if err := config.InitOtoSaas(config.Config{ Url: "https://dev-api.otosaas.com/open_api", AppKey: "shama", AppSecret: "7b6cff19a8de4b4dad6480698b4d87b6", HexPrivateKey: "22cc7a92d82f4ade30f63be1a800e700aa9386d422a19ab6e8b43af15a6c8a91", OtoSaasPublicKey: "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE5QoFDXf57f1tn0UwuTFnnL070fhAE+A9omI9f1LGt5ZQmZUEtEfVSvY2IDhcSo2/JCMysQHyAqwmh5X9Ha4l+Q==", OtoSaasSm4Secret: "8E0BEC651A7D97D0A8B370C074E4E65E", }); err != nil { log.Println(err) return } } func TestSkuPool(t *testing.T) { result, err := Api.Sku.Pool(0, 100) if err != nil { return } for _, skuCode := range result.SkuCodes { Api.Sku.Detail(skuCode) } } func TestSkuDetail(t *testing.T) { log.Println(Api.Sku.Detail("YD1002902")) } func TestSkuImage(t *testing.T) { log.Println(Api.Sku.Image("YD1002902")) } func TestSkuStatus(t *testing.T) { log.Println(Api.Sku.Status("YD1002902")) } func TestSkuStock(t *testing.T) { log.Println(Api.Sku.Stock("YD1002902")) } func TestOrderFreight(t *testing.T) { log.Println(Api.Order.Freight([]SkuFreightItem{ { CommodityCode: "YD1002902", CommoditySpecCode: "HL69110000464848", CommodityNum: 1, }, })) } func TestOrderSubmit(t *testing.T) { log.Println(Api.Order.Submit(OrderSubmit{ UserId: "1", UserPhone: "18906611076", TotalPrice: 789, ReceiverName: "杨赟", ReceiverPhone: "15394315510", ReceiverProvince: "浙江省", ReceiverCity: "宁波市", ReceiverRegion: "鄞州区", ReceiverStreetName: "", ReceiverDetailAddress: "浙江省宁波市鄞州区深蓝大厦19楼", CommodityList: []OrderSkuItem{ { CommodityCode: "YD1002902", CommoditySpecCode: "HL69110000464848", CommodityNum: 1, CommoditySpecPrice: 789, ShopCode: "hailv", }, }, Remark: "无", FreightAmount: 0, CustomerOrderId: "shama" + time.Now().Format("20060102150405"), CreateTime: time.Now().UnixMilli(), })) } func TestOrderConfirm(t *testing.T) { log.Println(Api.Order.Confirm("20221213115326352640", "1")) } func TestOrderDetail(t *testing.T) { log.Println(Api.Order.Detail("20221213115326352640", "1")) } func TestOrderLogistics(t *testing.T) { log.Println(Api.Order.Logistics("20221213115326352640", "1")) } func TestOrderReceipt(t *testing.T) { log.Println(Api.Order.Receipt("20221213115326352640", "1", "202212131153263526400101")) } func TestAfsApply(t *testing.T) { log.Println(Api.Afs.Apply(AfsApply{ UserId: "1", CommodityStatus: 2, OrderId: "20221213115326352640", ItemOrderIds: []string{"202212131153263526400101"}, Pics: []string{}, ReturnReasonValue: "不想要了", ReturnRemark: "不想要了", Type: 2, ReturnType: 0, })) } func TestAfsDetail(t *testing.T) { log.Println(Api.Afs.Detail("20221213132903665728", "1")) } func TestAfsRefund(t *testing.T) { log.Println(Api.Afs.Refund("20221213132903665728", "1")) } func TestAfsLogisticsAddress(t *testing.T) { log.Println(Api.Afs.LogisticsAddress("20221213132903665728", "1")) } func TestAfsBackLogisticsBill(t *testing.T) { log.Println(Api.Afs.BackLogisticsBill(BackLogisticsBill{ UserId: "1", ReturnOrderId: "20221213132903665728", LogisticsNum: "JDVC16678045614", LogisticsCode: "", LogisticsName: "京东快递", ReturnAddress: "浙江省宁波市深蓝大厦19楼", })) }