- basic store api added.

This commit is contained in:
gazebo
2018-08-16 16:36:49 +08:00
parent fa6ac348e3
commit 061fe163bd
3 changed files with 193 additions and 1 deletions

View File

@@ -0,0 +1,88 @@
package jdapi
import (
"git.rosy.net.cn/baseapi/utils"
)
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=194&apiid=138426aa19b54c48ae8464af1ca3b681
func (a API) GetStationsByVenderId() ([]string, error) {
result, err := a.AccessAPINoPage("store/getStationsByVenderId", nil, nil, nil)
if err == nil {
result2 := result.([]interface{})
retVal := make([]string, len(result2))
for k, v := range result2 {
retVal[k] = v.(string)
}
return retVal, nil
}
return nil, err
}
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=194&apiid=4c48e347027146d5a103e851055cb1a7
func (a API) GetStoreInfoByStationNo(storeNo string) (map[string]interface{}, error) {
result, err := a.AccessAPINoPage("storeapi/getStoreInfoByStationNo", utils.Params2Map("StoreNo", storeNo), nil, nil)
if err == nil {
return result.(map[string]interface{}), nil
}
return nil, err
}
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=194&apiid=2600369a456446f0921e918f3d15e96a
func (a API) UpdateStoreInfo4Open(storeNo, operator string, addParams map[string]interface{}) (string, error) {
jdParams := map[string]interface{}{
"stationNo": storeNo,
"operator": operator,
}
for k, v := range addParams {
jdParams[k] = v
}
result, err := a.AccessAPINoPage("store/updateStoreInfo4Open", jdParams, nil, nil)
if err == nil {
return result.(string), nil
}
return "", err
}
func (a API) GetCommentByOrderId(orderId int64) (map[string]interface{}, error) {
jdParams := map[string]interface{}{
"orderId": orderId,
}
result, err := a.AccessAPINoPage("commentOutApi/getCommentByOrderId", jdParams, nil, nil)
if err != nil {
return nil, err
}
return result.(map[string]interface{}), nil
}
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=194&apiid=ea0b466a7fa8489b813e8b197efca2d4?
func (a API) OrgReplyComment(orderID int64, storeID, content, replayPin string) (string, error) {
jdParams := map[string]interface{}{
"orderId": orderID,
"storeId": storeID,
"content": content,
"replyPin": replayPin,
}
result, err := a.AccessAPINoPage("commentOutApi/orgReplyComment", jdParams, nil, nil)
if err != nil {
return "", err
}
return result.(string), nil
}
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=194&apiid=5df446bb5ff14413965b8d702718dc48
func (a API) UpdateStoreConfig4Open(stationNo string, isAutoOrder bool) (bool, error) {
jdParams := map[string]interface{}{
"stationNo": stationNo,
}
// 01是反的
if isAutoOrder {
jdParams["isAutoOrder"] = 0
} else {
jdParams["isAutoOrder"] = 1
}
result, err := a.AccessAPINoPage("store/updateStoreConfig4Open", jdParams, nil, nil)
if err != nil {
return false, err
}
return result.(bool), nil
}