Files
baseapi/platformapi/jdshopapi/store_page_test.go
苏尹岚 68f2de0bf4 aa
2020-11-26 08:59:56 +08:00

308 lines
7.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package jdshopapi
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"fmt"
"testing"
"git.rosy.net.cn/baseapi/utils"
)
func TestCreateShopCategory(t *testing.T) {
var CreateShopCategoryParams = []*CreateShopCategoryParam{
&CreateShopCategoryParam{
HomeShow: "0",
ID: "1",
Open: "",
OrderNo: "0",
ParentID: "",
Title: "测试1",
Type: "3",
},
}
result, _ := api.CreateShopCategory(CreateShopCategoryParams)
fmt.Println(result)
}
func TestUpdateStoreStatus(t *testing.T) {
err := api.UpdateStoreStatus(24332466, 1)
if err != nil {
t.Fatal(err)
}
}
func TestNewInfoList(t *testing.T) {
result, err := api.NewInfoList(1)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func Test11(t *testing.T) {
change := func(s ...string) {
s[0] = "Go"
s = append(s, "playground")
fmt.Println(s)
}
welcome := []string{"hello", "world"}
change(welcome...)
fmt.Println(welcome)
}
func TestAllOrders(t *testing.T) {
result, err := api.AllOrders(&AllOrdersParam{
Current: 1,
PageSize: 1,
OrderID: "118793082128",
})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestOrderDetail(t *testing.T) {
result, err := api.OrderDetail("125138699851")
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestPhoneSensltiveInfo(t *testing.T) {
result, err := api.PhoneSensltiveInfo("124396047880", "10b1707dc87755373d488a7a4f422f7d")
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestUpdateWaybill(t *testing.T) {
err := api.UpdateWaybill("123076499052", "1274", "88328977356545 ")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestTryGetCookie(t *testing.T) {
result, err := api.TryGetCookie()
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestAAADS(t *testing.T) {
str := "AASWvkdk5a60bjm3lFqaoCyzBFIjrHQjoKSY+LN5VcswOzDkqjbjxVyK1Psdqcj3ci0+4I9v3evrtrJHLuUSo3eEfT3+psX6DF45CILeq0VbKxwxkE+AS1WTxr9RTHqaM3g="
data, _ := base64.StdEncoding.DecodeString(str)
data2, _ := base64.StdEncoding.DecodeString("XsGNdyDyDHnR79iKU6d5LTSJYaQyWAEssDoD7VM5Kks=")
b := bytes.NewBuffer(data)
b.Next(18)
iv := make([]byte, 16)
b.Read(iv)
main := make([]byte, len(data)-18-16)
b.Read(main)
decryptedData, err := utils.AESCBCDecpryt(main, data2[:16], iv)
// decryptedData, err := Decrypt(main, data2[:16], iv)
if err != nil {
t.Fatal(err)
}
fmt.Println("data", string(decryptedData))
}
func Decrypt(decryptBytes, key, iv []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
blockMode := cipher.NewCBCDecrypter(block, iv)
blockMode.CryptBlocks(decryptBytes, decryptBytes)
return PKCS5UnPadding(decryptBytes), nil
}
func PKCS5UnPadding(decrypted []byte) []byte {
length := len(decrypted)
unPadding := int(decrypted[length-1])
return decrypted[:(length - unPadding)]
}
func TestShopDetail(t *testing.T) {
result, err := api.ShopDetail(24562992)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestUpdateBasic(t *testing.T) {
err := api.UpdateBasic(&UpdateBasicParam{
StoreID: 24562992,
StoreName: "京西菜市温江旗舰生鲜店",
CategoryID2: 62,
Coordinate: "30.692941,103.858781",
BussinessBeginTime: "08:30",
BussinessEndTime: "20:00",
ImgURL: "jfs/t1/141918/10/14803/148865/5fb4e8cbE95a606cb/08a8dc277eb97a16.png",
StorePhone: "13706546496",
AddName: "四川成都市温江区@!温江区锦泉街116号优取舍",
AddCode1: 22,
AddCode2: 1930,
AddCode3: 49315,
CategoryID1: 34,
QualificationRequests: []*QualificationRequests{
&QualificationRequests{
QualificationID: 41,
QualificationName: "营业执照",
QualificationNo: "11111",
QualificationURL: "jfs/t1/148622/37/14846/10266/5fb4e3e2Ef2f61870/a7cfba9c1513d95e.png",
StartTime: "2020-11-04 00:00:00",
EndingTime: "2020-11-06 23:59:59",
Time: []string{"2020-11-04 00:00:00", "2020-11-06 23:59:59"},
},
},
})
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestUpdateExpand(t *testing.T) {
err := api.UpdateExpand(24563694)
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestUploadImageNew(t *testing.T) {
// data, _, err := DownloadFileByURL("http://image.jxc4.com/image/b90ae8585e8cf2f3871f6e8318bde1dc.tem.png")
// result, err := api.UploadImageNew(data, "b90ae8585e8cf2f3871f6e8318bde1dc.tem.png")
// if err != nil {
// t.Fatal(err)
// }
// t.Log(utils.Format4Output(result, false))
// str := "京西菜市松林农贸市场.生鲜店"
// str2 := str[0:strings.Index(str, ".")] + str[strings.Index(str, ".")+1:len(str)]
fmt.Println(2 % 4)
}
func TestShopList(t *testing.T) {
result, err := api.ShopList(1)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestWareSave(t *testing.T) {
// desc := `<p>因生鲜比较脆弱,发货途中如果有磕碰损坏,请收到联系客服,闪电赔付。请核对好地址,发货后不可修改地址,因改地址导致损坏不能赔付,谢谢理解</p><p><img style="width:auto;height:auto;max-width:100%;" src="//img10.360buyimg.com/imgzone/jfs/t1/126814/22/1326/472568/5ebb888dEa2cfb5f6/c0c81db660994246.jpg"><br></p><p><br></p>`
params := &WareSaveParam{
WareID: 10020528071531,
Height: 120,
CategoryID: 12247,
VenderID: 10569615,
BrandID: 44259,
Length: 200,
Wide: 100,
// WareStatus: 2,
Title: "三线肉",
Weight: "3",
ShopCategorys: []int{15602360},
// Notes: desc,
Skus: []*WareSaveSkus{
&WareSaveSkus{
SkuID: 10024685331653,
JdPrice: "15",
StockNum: 5,
Props: []*WareSaveSkusProp{
&WareSaveSkusProp{
AttrID: 1000022043,
AttrValues: 2515313135,
AttrValueAlias: "250g",
},
},
},
&WareSaveSkus{
JdPrice: "31",
StockNum: 5,
Props: []*WareSaveSkusProp{
&WareSaveSkusProp{
AttrID: 1000022043,
AttrValues: 2515430634,
AttrValueAlias: "500g",
},
},
},
},
PromiseID: -1,
MultiCateProps: []interface{}{},
PropsSet: []interface{}{},
SaleAttrs: []interface{}{},
}
// params.ImageMap.Num0000000000 = append(params.ImageMap.Num0000000000, &CreateSkuParamImages{
// ColorID: "0000000000",
// ImgIndex: 1,
// ImgURL: "jfs/t1/142006/30/15024/504060/5fb636d4Ef12079f7/2adad323cbcf7c52.jpg",
// // ImgZoneID: "0000000000",
// }, &CreateSkuParamImages{
// ColorID: "0000000000",
// ImgIndex: 2,
// ImgURL: "jfs/t1/142006/30/15024/504060/5fb636d4Ef12079f7/2adad323cbcf7c52.jpg",
// // ImgZoneID: "0000000000",
// })
result, err := api.WareSave(params)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestWareDoUpdate(t *testing.T) {
err := api.WareDoUpdate("up", "10020528071531")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreWareDoUpdate(t *testing.T) {
err := api.StoreWareDoUpdate(1, 10024685331653, "1000063128")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreUpdatePrice(t *testing.T) {
err := api.StoreUpdatePrice(80, 10024685331653, "1000063128")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreUpdateStock(t *testing.T) {
err := api.StoreUpdateStock(80, 10024685331653, "1000063128")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreSkuBindStore(t *testing.T) {
err := api.StoreSkuBindStore(false, 10024685331653, "1000063128")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}