- add operator for some jd api.
This commit is contained in:
@@ -232,7 +232,7 @@ func TestCallbackMsgPlayback(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestOrderAcceptOperate(t *testing.T) {
|
func TestOrderAcceptOperate(t *testing.T) {
|
||||||
result, err := jdapi.OrderAcceptOperate("813344594000041", true)
|
result, err := jdapi.OrderAcceptOperate("813344594000041", true, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ func TestOrderAcceptOperate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderJDZBDelivery(t *testing.T) {
|
func TestOrderJDZBDelivery(t *testing.T) {
|
||||||
result, err := jdapi.OrderJDZBDelivery("813344594000041")
|
result, err := jdapi.OrderJDZBDelivery("813344594000041", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ func TestOrderJDZBDelivery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestModifySellerDelivery(t *testing.T) {
|
func TestModifySellerDelivery(t *testing.T) {
|
||||||
result, err := jdapi.ModifySellerDelivery("813344594000041")
|
result, err := jdapi.ModifySellerDelivery("813344594000041", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ func TestModifySellerDelivery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderSerllerDelivery(t *testing.T) {
|
func TestOrderSerllerDelivery(t *testing.T) {
|
||||||
result, err := jdapi.OrderSerllerDelivery("813344594000041")
|
result, err := jdapi.OrderSerllerDelivery("813344594000041", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ func TestOrderSerllerDelivery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeliveryEndOrder(t *testing.T) {
|
func TestDeliveryEndOrder(t *testing.T) {
|
||||||
result, err := jdapi.DeliveryEndOrder("813344594000041")
|
result, err := jdapi.DeliveryEndOrder("813344594000041", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package jdapi
|
package jdapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,6 +51,10 @@ const (
|
|||||||
PromotionTypeBuyGiveGift = 6
|
PromotionTypeBuyGiveGift = 6
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrCanNotFindOrder = errors.New("can not find order")
|
||||||
|
)
|
||||||
|
|
||||||
func (a API) OrderQuery(jdParams map[string]interface{}) (retVal []interface{}, err error) {
|
func (a API) OrderQuery(jdParams map[string]interface{}) (retVal []interface{}, err error) {
|
||||||
retVal, err = a.AccessAPIHavePage("order/es/query", jdParams, nil, nil, nil)
|
retVal, err = a.AccessAPIHavePage("order/es/query", jdParams, nil, nil, nil)
|
||||||
return
|
return
|
||||||
@@ -65,6 +71,9 @@ func (a API) QuerySingleOrder(orderId string) (map[string]interface{}, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if len(result) == 0 {
|
||||||
|
return nil, ErrCanNotFindOrder
|
||||||
|
}
|
||||||
return result[0].(map[string]interface{}), nil
|
return result[0].(map[string]interface{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,51 +98,51 @@ func (a API) LegacyQuerySingleOrder(orderId string) (map[string]interface{}, err
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a API) OrderAcceptOperate(orderId string, isAgreed bool) (interface{}, error) {
|
func (a API) OrderAcceptOperate(orderId string, isAgreed bool, userName string) (interface{}, error) {
|
||||||
jdParams := map[string]interface{}{
|
jdParams := map[string]interface{}{
|
||||||
"orderId": orderId,
|
"orderId": orderId,
|
||||||
"isAgreed": utils.Bool2String(isAgreed),
|
"isAgreed": utils.Bool2String(isAgreed),
|
||||||
"operator": utils.GetAPIOperator(),
|
"operator": utils.GetAPIOperator(userName),
|
||||||
}
|
}
|
||||||
return a.AccessAPINoPage("ocs/orderAcceptOperate", jdParams, nil, nil)
|
return a.AccessAPINoPage("ocs/orderAcceptOperate", jdParams, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拣货完成且众包配送接口
|
// 拣货完成且众包配送接口
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=ed93745b86c6487eaaea5f55a84785ac
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=ed93745b86c6487eaaea5f55a84785ac
|
||||||
func (a API) OrderJDZBDelivery(orderId string) (interface{}, error) {
|
func (a API) OrderJDZBDelivery(orderId string, userName string) (interface{}, error) {
|
||||||
jdParams := map[string]interface{}{
|
jdParams := map[string]interface{}{
|
||||||
"orderId": orderId,
|
"orderId": orderId,
|
||||||
"operator": utils.GetAPIOperator(),
|
"operator": utils.GetAPIOperator(userName),
|
||||||
}
|
}
|
||||||
return a.AccessAPINoPage("bm/open/api/order/OrderJDZBDelivery", jdParams, nil, nil)
|
return a.AccessAPINoPage("bm/open/api/order/OrderJDZBDelivery", jdParams, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订单达达配送转商家自送接口
|
// 订单达达配送转商家自送接口
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=e7b4950164754eecac7ea87278c2b071
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=e7b4950164754eecac7ea87278c2b071
|
||||||
func (a API) ModifySellerDelivery(orderId string) (interface{}, error) {
|
func (a API) ModifySellerDelivery(orderId string, userName string) (interface{}, error) {
|
||||||
jdParams := map[string]interface{}{
|
jdParams := map[string]interface{}{
|
||||||
"orderId": orderId,
|
"orderId": orderId,
|
||||||
"updatePin": utils.GetAPIOperator(),
|
"updatePin": utils.GetAPIOperator(userName),
|
||||||
}
|
}
|
||||||
return a.AccessAPINoPage("order/modifySellerDelivery", jdParams, nil, nil)
|
return a.AccessAPINoPage("order/modifySellerDelivery", jdParams, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拣货完成且商家自送接口(这个接口是商家本身配置为自送模式下才能调用的接口,如果启用了达达配送,是不能调用的)
|
// 拣货完成且商家自送接口(这个接口是商家本身配置为自送模式下才能调用的接口,如果启用了达达配送,是不能调用的)
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=0e08e71a45dc48b6a337e06a852ac33a
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=0e08e71a45dc48b6a337e06a852ac33a
|
||||||
func (a API) OrderSerllerDelivery(orderId string) (interface{}, error) {
|
func (a API) OrderSerllerDelivery(orderId string, userName string) (interface{}, error) {
|
||||||
jdParams := map[string]interface{}{
|
jdParams := map[string]interface{}{
|
||||||
"orderId": orderId,
|
"orderId": orderId,
|
||||||
"operator": utils.GetAPIOperator(),
|
"operator": utils.GetAPIOperator(userName),
|
||||||
}
|
}
|
||||||
return a.AccessAPINoPage("bm/open/api/order/OrderSerllerDelivery", jdParams, nil, nil)
|
return a.AccessAPINoPage("bm/open/api/order/OrderSerllerDelivery", jdParams, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商家自送,订单妥投接口
|
// 商家自送,订单妥投接口
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=ecc80f06d35141979f4841f345001f74
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=ecc80f06d35141979f4841f345001f74
|
||||||
func (a API) DeliveryEndOrder(orderId string) (interface{}, error) {
|
func (a API) DeliveryEndOrder(orderId string, userName string) (interface{}, error) {
|
||||||
jdParams := map[string]interface{}{
|
jdParams := map[string]interface{}{
|
||||||
"orderId": orderId,
|
"orderId": orderId,
|
||||||
"operPin": utils.GetAPIOperator(),
|
"operPin": utils.GetAPIOperator(userName),
|
||||||
"operTime": utils.GetCurTimeStr(),
|
"operTime": utils.GetCurTimeStr(),
|
||||||
}
|
}
|
||||||
return a.AccessAPINoPage("ocs/deliveryEndOrder", jdParams, nil, nil)
|
return a.AccessAPINoPage("ocs/deliveryEndOrder", jdParams, nil, nil)
|
||||||
|
|||||||
@@ -89,8 +89,12 @@ func GetCurTimestamp() int64 {
|
|||||||
return time.Now().Unix()
|
return time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAPIOperator() string {
|
func GetAPIOperator(userName string) string {
|
||||||
return "jxc4-admin"
|
retVal := "jxc4-admin"
|
||||||
|
if userName != "" {
|
||||||
|
retVal += "-" + userName
|
||||||
|
}
|
||||||
|
return retVal
|
||||||
}
|
}
|
||||||
|
|
||||||
func MergeMaps(firstMap map[string]interface{}, otherMaps ...map[string]interface{}) (retVal map[string]interface{}) {
|
func MergeMaps(firstMap map[string]interface{}, otherMaps ...map[string]interface{}) (retVal map[string]interface{}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user