- dada shop api added.
This commit is contained in:
@@ -93,7 +93,7 @@ func (a *API) signParams(mapData map[string]interface{}) string {
|
|||||||
return fmt.Sprintf("%X", md5.Sum([]byte(finalStr)))
|
return fmt.Sprintf("%X", md5.Sum([]byte(finalStr)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) AccessAPI(action string, params map[string]interface{}) (retVal *ResponseResult, err error) {
|
func (a *API) AccessAPI(action string, params interface{}) (retVal *ResponseResult, err error) {
|
||||||
params2 := make(map[string]interface{})
|
params2 := make(map[string]interface{})
|
||||||
|
|
||||||
params2["app_key"] = a.appKey
|
params2["app_key"] = a.appKey
|
||||||
|
|||||||
78
platformapi/dadaapi/shop.go
Normal file
78
platformapi/dadaapi/shop.go
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package dadaapi
|
||||||
|
|
||||||
|
import "git.rosy.net.cn/baseapi/utils"
|
||||||
|
|
||||||
|
const (
|
||||||
|
BusinessTypeSnack = 1
|
||||||
|
BusinessTypeDrink = 2
|
||||||
|
BusinessTypeFlower = 3
|
||||||
|
BusinessTypePrintTicket = 8
|
||||||
|
BusinessTypeConvStore = 9
|
||||||
|
BusinessTypeFruitVegetable = 13
|
||||||
|
BusinessTypeCityEComm = 19
|
||||||
|
BusinessTypeMedicine = 20
|
||||||
|
BusinessTypeCake = 21
|
||||||
|
BusinessTypeWine = 24
|
||||||
|
BusinessTypeSmallware = 25
|
||||||
|
BusinessTypeClothing = 26
|
||||||
|
BusinessTypeCarPart = 27
|
||||||
|
BusinessTypeDigital = 28
|
||||||
|
BusinessTypeCray = 29
|
||||||
|
BusinessTypeOther = -5
|
||||||
|
)
|
||||||
|
|
||||||
|
func (a *API) ShopDetail(originShopID string) (shopDetail map[string]interface{}, err error) {
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"origin_shop_id": originShopID,
|
||||||
|
}
|
||||||
|
result, err := a.AccessAPI("api/shop/detail", params)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result.Result.(map[string]interface{}), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) ShopAdd(originShopID, stationName string, business int, cityName, areaName, stationAddress string, lng, lat float64, contactName, phone string, addParams map[string]interface{}) (outOriginShopID string, err error) {
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"station_name": stationName,
|
||||||
|
"business": business,
|
||||||
|
"city_name": cityName,
|
||||||
|
"area_name": areaName,
|
||||||
|
"station_address": stationAddress,
|
||||||
|
"lng": lng,
|
||||||
|
"lat": lat,
|
||||||
|
"contact_name": contactName,
|
||||||
|
"phone": phone,
|
||||||
|
}
|
||||||
|
if originShopID != "" {
|
||||||
|
params["origin_shop_id"] = originShopID
|
||||||
|
}
|
||||||
|
if addParams != nil {
|
||||||
|
params = utils.MergeMaps(params, addParams)
|
||||||
|
}
|
||||||
|
successList, _, err := a.BatchShopAdd([]map[string]interface{}{params})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return utils.Interface2String(successList[0]["originShopId"]), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) BatchShopAdd(shopInfoList []map[string]interface{}) (successList, failedList []map[string]interface{}, err error) {
|
||||||
|
result, err := a.AccessAPI("api/shop/add", shopInfoList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
mapResult := result.Result.(map[string]interface{})
|
||||||
|
if successList2 := mapResult["successList"]; successList2 != nil {
|
||||||
|
successList = utils.Slice2MapSlice(successList2.([]interface{}))
|
||||||
|
}
|
||||||
|
if failedList2 := mapResult["failedList"]; failedList2 != nil {
|
||||||
|
failedList = utils.Slice2MapSlice(failedList2.([]interface{}))
|
||||||
|
}
|
||||||
|
return successList, failedList, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) ShopUpdate(originShopID string, shopInfo map[string]interface{}) (err error) {
|
||||||
|
_, err = a.AccessAPI("api/shop/update", utils.MergeMaps(utils.Params2Map("origin_shop_id", originShopID), shopInfo))
|
||||||
|
return err
|
||||||
|
}
|
||||||
24
platformapi/dadaapi/shop_test.go
Normal file
24
platformapi/dadaapi/shop_test.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package dadaapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestShopDetail(t *testing.T) {
|
||||||
|
result, err := dadaapi.ShopDetail("100119")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestShopAddl(t *testing.T) {
|
||||||
|
result, err := dadaapi.ShopAdd("18180948107", "京西大本营", BusinessTypeFruitVegetable, "成都市", "金牛区", "西南交通大学科技大厦二楼", 104.056844, 30.695151, "徐先生", "18180948107", nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
baseapi.SugarLogger.Debug(result)
|
||||||
|
}
|
||||||
@@ -42,8 +42,14 @@ func TestRefreshToken(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMessageTemplateSend(t *testing.T) {
|
func TestMessageTemplateSend(t *testing.T) {
|
||||||
weixinapi.SetToken("14_waQJKNzZi_tNpDRyR0YsnOs-HpHVG3svnktqjlU-NE9aimGo65rpfp0YDyX6AXJ5j3smiFJt0T0JUZQ18wbD8C9limQNbptPtNUfALLf8KheVPevwMldU2UPukcXWLaAAAEDS")
|
// "oYN_usk0AeGc_C6VEZfmFQP5VHMQ": 1, // 周小扬
|
||||||
err := weixinapi.MessageTemplateSend("oYN_ust9hXKEvEv0X6Mq6nlAWs_E", "_DtNGwmOeR6TkkTVUblxLIlkV2MAPOX57TkvfdqG6nY", "http://www.163.com", nil, map[string]interface{}{
|
// "oYN_ust9hXKEvEv0X6Mq6nlAWs_E": 1, // me
|
||||||
|
// "oYN_usvnObzrPweIgHTad9-uMf78": 1, // 老赵
|
||||||
|
weixinapi.SetToken("17_HUkrxPrmSWDb-zuV1g9ioYj_MvHST2aGZZ58iX-g5JFiiV4vFJxQS8SvNlhHNh2HtT7aQGC3Lxozw43l-1lojMVu-6nYqqW-h2SKVxwHUvfYn5BJ6vqzQ9uU-da9u4KIazdq-ImOibw-G6pENNCfAFAIIX")
|
||||||
|
err := weixinapi.MessageTemplateSend("oYN_ust9hXKEvEv0X6Mq6nlAWs_E", "_DtNGwmOeR6TkkTVUblxLIlkV2MAPOX57TkvfdqG6nY", "", map[string]interface{}{
|
||||||
|
"appid": "wx4b5930c13f8b1170",
|
||||||
|
"pagepath": "pages/order-manager/main",
|
||||||
|
}, map[string]interface{}{
|
||||||
"first": "first",
|
"first": "first",
|
||||||
"Day": "Day",
|
"Day": "Day",
|
||||||
"orderId": "orderId",
|
"orderId": "orderId",
|
||||||
|
|||||||
Reference in New Issue
Block a user