Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -85,7 +85,7 @@ func TestGetDistricts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCoordinateFromAddress(t *testing.T) {
|
||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("江西赣州市章贡区赣州经济技术开发区国际企业中心赣州国际企业中心13栋A502(华坚路大门右拐)", "")
|
||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("北京昌平区城区军民路1号院", "")
|
||||
t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// sandbox
|
||||
dadaapi = New("dada9623324449cd250", "30c2abbfe8a8780ad5aace46300c64b9", "73753", "http://callback.jxc4.com/dada/order", false)
|
||||
// dadaapi = New("dada9623324449cd250", "30c2abbfe8a8780ad5aace46300c64b9", "73753", "http://callback.jxc4.com/dada/order", false)
|
||||
|
||||
// prod
|
||||
// dadaapi = New("dada147f7a190ce7b3c", "2c717ad914767d6e2beb3f743db9e477", "6660", "http://callback.jxc4.com/dada/order", true)
|
||||
dadaapi = New("dada154e2a41fd6cef3", "7f97d8f258b70b450f04e7ab274ed8f8", "6660", "http://callback.jxc4.com/dadadelivery/msg", true)
|
||||
|
||||
// prod
|
||||
testOrder = &OperateOrderParams{
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestAddOrderAfterQuery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancel(t *testing.T) {
|
||||
cancelResponse, err := dadaapi.CancelOrder("91BBFE1626E011EAA059186590E02977", ReasonIDOther, "test")
|
||||
cancelResponse, err := dadaapi.CancelOrder("88330338129212", ReasonIDOther, "接单时间过长")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// sandbox
|
||||
api = New("594ab45a-9a73-4a43-82b0-a64cbd55d883", "06692746f7224695ad4788ce340bc854", "d6b42a35a7414a5490d811654d745c84")
|
||||
// api = New("594ab45a-9a73-4a43-82b0-a64cbd55d883", "06692746f7224695ad4788ce340bc854", "d6b42a35a7414a5490d811654d745c84")
|
||||
// prod
|
||||
// api = New("77e703b7-7997-441b-a12a-2e522efb117a", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4")
|
||||
api = New("77e703b7-7997-441b-a12a-2e522efb117a", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4")
|
||||
// 天天果园
|
||||
// api = New("84541069-fbe2-424b-b625-9b2ba1d4c9e6", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26")
|
||||
|
||||
|
||||
@@ -35,6 +35,13 @@ func TestCreatePromotionSingle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfirmPromotionSingle(t *testing.T) {
|
||||
err := api.ConfirmPromotionSingle(326890763, "", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePromotionLimitTime(t *testing.T) {
|
||||
infoId, err := api.CreatePromotionInfosLimitTime("测试1", time.Now(), time.Now().Add(24*time.Hour), "", "", "")
|
||||
if err != nil {
|
||||
@@ -78,7 +85,7 @@ func TestCreatePromotionSkuLimitTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelPromotion(t *testing.T) {
|
||||
err := api.CancelPromotionSingle(334831149, "", utils.GetUUID())
|
||||
err := api.CancelPromotionSingle(334829148, "", utils.GetUUID())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -400,6 +400,7 @@ func (a *API) QueryStock(goodsNo string) (queryStockResult []*QueryStockResult,
|
||||
"warehouseNo": WarehouseNo,
|
||||
"returnZeroStock": 2, //表示返回库存为0的数据
|
||||
"stockType": 1,
|
||||
"stockStatus": 1, //良品
|
||||
}
|
||||
if goodsNo != "" {
|
||||
params["goodsNo"] = goodsNo
|
||||
|
||||
@@ -86,7 +86,7 @@ func TestSearchShopStock(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryStock(t *testing.T) {
|
||||
result, err := api.QueryStock("EMG4418113943423")
|
||||
result, err := api.QueryStock("")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func TestQueryStock(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWaybillReceive(t *testing.T) {
|
||||
err := api.WaybillReceive(&WaybillReceiveParam{
|
||||
_, err := api.WaybillReceive(&WaybillReceiveParam{
|
||||
SalePlat: SalePlatSourceDelivery,
|
||||
CustomerCode: CustomerCode,
|
||||
OrderID: "883289609977992",
|
||||
|
||||
@@ -16,6 +16,6 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
||||
api.SetCookieWithStr(`
|
||||
thor=80FAF09E9A09B6E618A68057BDFCFCB82CCFD5645F40A144C6CA92A0B84FE8EFE9869C996F2E8961897A27841241639DB35880508820C0CA9E10513471C69F54E4AB811C98D045B848501CAE165D62FEC731B43499E9A86C821179ED3A0B2D683E5472D06BF5D30DC8D029682A30858FC22FC228246002C368B0A689F25113A240E0B8EDB9D8C99915526D3E34C84A82;
|
||||
thor=00513FC363111586B2C0E065A90E33C1284E5BA68461D5ACC9B4830A54FE27F559AB1D4D2F6FBCD3F6FC99402F2C7C6CC65751CB0BB5AB39CBC12EFE762024EAFEC90B6F414373DDD6B07D72367A45E79C72A12A2B87F158020FA41387E6D34FF3BA71F33342994A47217C3D1C753CC79B6A98E8F78935F09D50A2AFDF34F666FAB9C0D159B6FCE72CAA929B8420F419;
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -36,3 +36,13 @@ func (a *API) GetDeliveryCompany() (result interface{}, err error) {
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
//查询单个订单
|
||||
//https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=4247&apiName=jingdong.pop.order.get
|
||||
func (a *API) GetOrder(orderID int64) (err error) {
|
||||
_, err = a.AccessAPI("jingdong.pop.order.get", prodURL, map[string]interface{}{
|
||||
"order_id": orderID,
|
||||
"optional_fields": "orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice",
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -21,3 +21,11 @@ func TestGetDeliveryCompany(t *testing.T) {
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetOrder(t *testing.T) {
|
||||
err := api.GetOrder(120146365818)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ func (a *API) UpdateSkus(updateSkusParam *UpdateSkusParam) (vendorSkuID string,
|
||||
//删除sku
|
||||
//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1323&apiName=jingdong.sku.write.deleteSku
|
||||
func (a *API) DeleteSku(skuId int64) (err error) {
|
||||
_, err = a.AccessAPI2("jingdong.sku.write.deleteSku", prodURL, map[string]interface{}{
|
||||
_, err = a.AccessAPI("jingdong.sku.write.deleteSku", prodURL, map[string]interface{}{
|
||||
"skuId": skuId,
|
||||
})
|
||||
return err
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
@@ -421,7 +422,8 @@ func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult,
|
||||
}
|
||||
}
|
||||
if len(expectedDeliveredTime) > 0 {
|
||||
orderDetailResult.ExpectedDeliveredTime = expectedDeliveredTime[1][:strings.LastIndex(expectedDeliveredTime[1], "-")] + ":00"
|
||||
expectedDeliveredTime := expectedDeliveredTime[1][:strings.LastIndex(expectedDeliveredTime[1], "-")] + ":00"
|
||||
orderDetailResult.ExpectedDeliveredTime = utils.Time2Str(utils.Str2Time(expectedDeliveredTime).Add(50 * time.Minute))
|
||||
} else {
|
||||
expectedDeliveredTime2 := regexpOrderDetailDay2.FindStringSubmatch(body)
|
||||
if len(expectedDeliveredTime2) > 0 {
|
||||
|
||||
@@ -2,11 +2,14 @@ package jdshopapi
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
@@ -59,9 +62,9 @@ func Test11(t *testing.T) {
|
||||
|
||||
func TestAllOrders(t *testing.T) {
|
||||
result, err := api.AllOrders(&AllOrdersParam{
|
||||
Current: 1,
|
||||
PageSize: 999,
|
||||
OrderCreateDateRange: []string{"2020-06-17 00:00:00", "2020-06-17 23:59:59"},
|
||||
Current: 1,
|
||||
PageSize: 1,
|
||||
OrderID: "118793082128",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -70,7 +73,7 @@ func TestAllOrders(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderDetail(t *testing.T) {
|
||||
result, err := api.OrderDetail("124350112427")
|
||||
result, err := api.OrderDetail("125138699851")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -102,8 +105,19 @@ func TestTryGetCookie(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAAADS(t *testing.T) {
|
||||
//c5MSDWxbgDc698slnUlR1w==
|
||||
fmt.Println(DecryptDESECB([]byte("Av3VLNsKfmmGw70Wiw7Qdw=="), []byte(JdsMobileKey)))
|
||||
const prefix = 80
|
||||
const randPartNum = 100
|
||||
orderNoBeginTimestamp := utils.Str2Time("2010-01-01 00:00:00").Unix()
|
||||
orderNo := time.Now().Unix() - orderNoBeginTimestamp
|
||||
orderNo = orderNo * randPartNum
|
||||
md5Bytes := md5.Sum([]byte(utils.GetUUID()))
|
||||
randPart := 0
|
||||
for k, v := range md5Bytes {
|
||||
randPart += int(v) << ((k % 3) * 8)
|
||||
}
|
||||
orderNo += int64(randPart % randPartNum)
|
||||
orderNo += int64(math.Pow10(int(math.Log10(float64(orderNo)))+1)) * prefix
|
||||
fmt.Println(orderNo)
|
||||
}
|
||||
|
||||
func DecryptDESECB(d, key []byte) string {
|
||||
|
||||
@@ -3,6 +3,7 @@ package jdshopapi
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -48,7 +49,7 @@ func TestGetProvince(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCity(t *testing.T) {
|
||||
result, err := api.GetCity(12)
|
||||
result, err := api.GetCity(2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -56,7 +57,7 @@ func TestGetCity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCounty(t *testing.T) {
|
||||
result, err := api.GetCounty(988)
|
||||
result, err := api.GetCounty(2822)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -96,7 +97,5 @@ func TestFindStoreInfoByExtStoreId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWIREHL(t *testing.T) {
|
||||
data := "http://image.jxc4.com/image/f8578c9ee724408d514bbbfac3461142.tem.png"
|
||||
res := base64.URLEncoding.EncodeToString([]byte(data))
|
||||
fmt.Println(res)
|
||||
fmt.Println(strings.Contains("上海市", "上海"))
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const (
|
||||
MtwmSkuAttr200002716 = `[{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300003951,"value":"非特产品种"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000275,"attrName":"是否有机","valueList":[{"valueId":1300003874,"value":"无机"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300003944,"value":"其他品牌"}]}]`
|
||||
//200002667,200002713
|
||||
MtwmSkuAttr200002670 = `[{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300003946,"value":"其他品种"}]},{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300003951,"value":"非特产品种"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000275,"attrName":"是否有机","valueList":[{"valueId":1300003874,"value":"无机"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300003944,"value":"其他品牌"}]}]`
|
||||
MtwmSkuAttr200002680 = `[{"attrId":25381,"attrName":"品种","valueList":[{"valueId":100004872,"value":"其他品种"}]},{"attrId":100002270,"attrName":"品规","valueList":[{"valueId":100006799,"value":"未区分品规"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000275,"attrName":"是否有机","valueList":[{"valueId":1300003874,"value":"无机"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300003944,"value":"其他品牌"}]}]`
|
||||
MtwmSkuAttr200002680 = `[{"attrId":25381,"attrName":"品种","valueList":[{"valueId":100004872,"value":"其他品种"}]},{"attrId":100002270,"attrName":"品规","valueList":[{"valueId":100006799,"value":"未区分品规"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000275,"attrName":"是否有机","valueList":[{"valueId":1300003874,"value":"无机"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":100006421,"value":"其他品牌"}]}]`
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -56,7 +56,7 @@ func TestRetailList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailListAll(t *testing.T) {
|
||||
result, err := api.RetailListAll(testPoiCode)
|
||||
result, err := api.RetailListAll("9325917")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -286,7 +286,7 @@ func TestRetailSellStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCategoryAttrList(t *testing.T) {
|
||||
result, err := api.CategoryAttrList(200002713)
|
||||
result, err := api.CategoryAttrList(200002680)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -458,10 +458,12 @@ func (a *API) ResetCoverImage(userId, keyword string) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = a.AccessStorePage("Product/ResetCoverImage", map[string]interface{}{
|
||||
"productImageId": findProductResult.Productimages[len(findProductResult.Productimages)-1].ID,
|
||||
"forMulColorSize": false,
|
||||
})
|
||||
if len(findProductResult.Productimages) > 0 {
|
||||
_, err = a.AccessStorePage("Product/ResetCoverImage", map[string]interface{}{
|
||||
"productImageId": findProductResult.Productimages[len(findProductResult.Productimages)-1].ID,
|
||||
"forMulColorSize": false,
|
||||
})
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -307,6 +307,9 @@ func Time2DateStr(t time.Time) string {
|
||||
}
|
||||
|
||||
func Str2Time(timeStr string) time.Time {
|
||||
if timeStr == "" {
|
||||
return ZeroTimeValue
|
||||
}
|
||||
retVal, err := TryStr2Time(timeStr)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("time.ParseInLocation failed, timeStr:%v, error:%v", timeStr, err)
|
||||
|
||||
Reference in New Issue
Block a user