Merge branch 'master' of e.coding.net:rosydev/baseapi

This commit is contained in:
suyl
2020-08-17 21:27:43 +08:00
15 changed files with 122 additions and 42 deletions

View File

@@ -37,9 +37,8 @@ func TestShopAdd(t *testing.T) {
func TestShopUpdate(t *testing.T) {
shopInfo := &ShopInfo{
OriginShopID: "18180948107",
StationName: "京西大本营234",
CityName: "包头市",
OriginShopID: "666872",
Status: 1,
}
err := dadaapi.ShopUpdate(shopInfo)
if err != nil {

View File

@@ -760,7 +760,7 @@ func (a *API) getCommentList(isElm bool, fromTime, toTime time.Time, shopID, sup
for {
params["page_num"] = pageNo
retVal, err2 := a.AccessStorePage(fixedURL, "", params, false)
if err = err2; err == nil {
if err = err2; err == nil && retVal != nil {
for _, comment := range retVal["comment_list"].([]interface{}) {
commentMap := comment.(map[string]interface{})
for _, orderComment := range commentMap["order_commentList"].([]interface{}) {
@@ -782,7 +782,7 @@ func (a *API) getCommentList(isElm bool, fromTime, toTime time.Time, shopID, sup
}
func (a *API) GetEleCommentList(fromTime, toTime time.Time, shopID, supplierID string, replyStatus, level, nonEmpty int) (commentList []map[string]interface{}, err error) {
return a.getCommentList(true, fromTime, toTime, shopID, supplierID, replyStatus, level, nonEmpty)
return a.getCommentList(false, fromTime, toTime, shopID, supplierID, replyStatus, level, nonEmpty)
}
func (a *API) GetCommentList(fromTime, toTime time.Time, shopID, supplierID string, replyStatus, level, nonEmpty int) (commentList []map[string]interface{}, err error) {

View File

@@ -36,12 +36,12 @@ const (
var (
TopicList = []string{
"open_message_order_order_pay", //订单付款
// "open_message_pop_order_remk_chg", //POP订单备注变更
// "open_message_pop_order_out", //POP订单出库
// "open_message_pop_order_create", //POP订单创建
// "open_message_pop_order_change", //POP订单变更消息
// "open_message_order_order_finish", //订单完成
"open_message_order_order_cancel", //订单取消
// "open_message_pop_order_remk_chg", //POP订单备注变更
}
)

View File

@@ -28,7 +28,7 @@ func init() {
// api = New("c45e6510-00ba-4be2-977e-bcb9c9792cc7", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26")
// const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHCT3RM3CQG7IJIPUQ3THS5UIUYWMKINM7ETUOQB7OBPOPZVCT3ZJY55243TDVXLO25PP4UYSPTTPMNQ7HPMWOJKJ3BJWGVHD243MXH7NZWW264TKN5UOCJBSSSOKD2QQII"
const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHD6O37OTAHUCKU6ALXATYTGMHNFLM4XRLVSFUQAJR77M4URSZRKVO55243TDVXLO25PP4UYSPTTPMNRUFXDNP4WPE566Q6V4AH32F7HT"
const cookieValue = "OPJQMA7B3FTKCAUGO7FHCH5NMBGAWGGXYRNLEHYYZNGNPNIBCAM4IOEPG3NT3RIA44G5C3535Q5LGG4F4SR4AZVLGYKYTKFJJKEAOXENVBL5VXNILRP3GLNVVWA26XZ3VGSYOHA72RICMVZS3G53DTEH3J7VMEGG2RGQEK6VMGIWEIL3X66ZYUZZOKKUUBKAWCWZPLF745R6MSYFJJ6EXUPLU4UGKXFQWEBUCQAMIOV7EVR4JGDPUMIPCVZVKBP5XQU32N7XTB6LGOP5RZQCH7DRHM"
api.SetJdCookie(cookieValue)
api.SetCookie("user", "VCQUVHVJI4ELNGFZOYMCDYDUSHEJMPXZRZXSNBRB4MVBNENP72REAAZR3R4SGDJ5ZI4FLYLLN5EGBBMTFCWHZVESIWBNLKZPLHWD6UIBTPXOF5IXM6AVA3V6TUNZD5UJS43AROJ2IRPZWEN5AGZYBUEGD3MSKKBKBSRP3DSEQXLITYNBLFZCHXCA7L4KGOSJRMM7R5IQP7QGLGRQB27AOE4YMLRJ3UPTZADPWJOYB3UZ7UZHLBVZRREEX647O3WQUU4BYXUOFZPIPRR77W3PQV543E")
}

View File

@@ -298,10 +298,12 @@ var (
regexpTable = regexp.MustCompile(`<table class="check-container" data-container="list1">([\s\S]*?)</table>`)
regexpTd = regexp.MustCompile(`<td>([0-9].*)</td>`)
regexpJDUserPage = regexp.MustCompile(`共([\s\S].*)页/([\s\S].*)条记录`)
regexpJDStoreSkuPage = regexp.MustCompile(`共1/(.*)页`)
regexpJDTbody = regexp.MustCompile(`<tbody>([\s\S]*?)</tbody>`)
regexpJDTr = regexp.MustCompile(`<tr>([\s\S]*?)</tr>`)
regexpJDTdInfo = regexp.MustCompile(`<td>([\s\S]*?)</td>`)
regexpJDSkuID = regexp.MustCompile(`sku编码:(.*)`)
regexpJDSkuID2 = regexp.MustCompile(`<p>SKU编码:(.*)</p>`)
regexpJDUserID = regexp.MustCompile(`value="(.*)"`)
regexpJDUserIsManager = regexp.MustCompile(`<div class="list-mask">`)
regexpJDStoreLevel = regexp.MustCompile(`门店分级 (.*)`)
@@ -1074,3 +1076,29 @@ func (a *API) GetJdShopOrders(orderStartTime, orderEndTime, orgCode, loginName s
}
return getJdShopOrdersResult, err
}
//获取京东的置顶门店商品
//https://stock-store.jddj.com/storeproduct/query
func (a *API) GetJdTopSkus(vendorStoreID string, currentPage int) (vendorSkuIDs []string, totalCount int, err error) {
jdParams := map[string]interface{}{
"fixedStatus": 1,
"stationNo": vendorStoreID,
"numStatus": 0,
"currentPage": currentPage,
"pageSize": 10,
}
body, err := a.AccessStorePage2("https://stock-store.jddj.com/storeproduct/query", jdParams, true, "")
if body != nil {
bodyStr := body.(map[string]interface{})["fakeData"].(string)
result := regexpJDStoreSkuPage.FindStringSubmatch(bodyStr)
totalCount = utils.Str2Int(result[1])
resultTr := regexpJDTr.FindAllStringSubmatch(bodyStr, -1)
for _, v := range resultTr {
resultSkuID := regexpJDSkuID2.FindStringSubmatch(v[1])
if strings.Contains(v[1], "取消置顶") {
vendorSkuIDs = append(vendorSkuIDs, resultSkuID[1])
}
}
}
return vendorSkuIDs, totalCount, err
}

View File

@@ -272,3 +272,12 @@ func TestGetJdShopOrders(t *testing.T) {
}
t.Log(utils.Format4Output(result, false))
}
func TestGetJdTopSkus(t *testing.T) {
result1, result2, err := api.GetJdTopSkus("11732425")
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result1, false))
t.Log(utils.Format4Output(result2, false))
}

View File

@@ -9,25 +9,26 @@ import (
)
type CallBackResult struct {
OrderStateRemark string `json:"orderStateRemark"`
OrderRemark string `json:"orderRemark"`
OrderSellerPrice string `json:"orderSellerPrice"`
OrderState string `json:"orderState"`
OrderType string `json:"orderType"`
OrderPayment string `json:"orderPayment"`
PayType string `json:"payType"`
StoreID string `json:"storeId"`
OrderTotalPrice string `json:"orderTotalPrice"`
OrderExt string `json:"orderExt"`
StoreOrder string `json:"storeOrder"`
OrderStartTime string `json:"orderStartTime"`
OrderID string `json:"orderId"`
OrderSource string `json:"orderSource"`
FreightPrice string `json:"freightPrice"`
MsgType string `json:"msgType"`
Pin string `json:"pin"`
ConsigneeInfo *CallBackConsigneeInfo `json:"consigneeInfo"`
ItemInfoList []*CallBackItemInfoList `json:"itemInfoList"`
OrderStateRemark string `json:"orderStateRemark"`
OrderRemark string `json:"orderRemark"`
OrderSellerPrice string `json:"orderSellerPrice"`
OrderState string `json:"orderState"`
OrderType string `json:"orderType"`
OrderPayment string `json:"orderPayment"`
PayType string `json:"payType"`
StoreID string `json:"storeId"`
OrderTotalPrice string `json:"orderTotalPrice"`
OrderExt string `json:"orderExt"`
StoreOrder string `json:"storeOrder"`
OrderStartTime string `json:"orderStartTime"`
OrderID string `json:"orderId"`
OrderSource string `json:"orderSource"`
FreightPrice string `json:"freightPrice"`
MsgType string `json:"msgType"`
Pin string `json:"pin"`
IDSopShipmenttype string `json:"idSopShipmenttype"`
ConsigneeInfo *CallBackConsigneeInfo `json:"consigneeInfo"`
ItemInfoList []*CallBackItemInfoList `json:"itemInfoList"`
}
type CallBackConsigneeInfo struct {

View File

@@ -62,7 +62,7 @@ const (
JdsBeefCatID = 13582
JdsBeefLastCatID = 17902
JdsPayPercentage float64 = 0.97
JdsPayPercentage float64 = 0.94
)
var (

View File

@@ -6,6 +6,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"strings"
"time"
"git.rosy.net.cn/baseapi/utils"
@@ -16,6 +17,8 @@ const (
OrderStatusPause = "PAUSE"
OrderStatusWait = "WAIT_SELLER_STOCK_OUT"
OrderStatusCancel = "TRADE_CANCELED"
IdSopShipmenttypeTC = "71" //同城配送,需要调其他接口获取期望送货时间
)
//订单出库
@@ -107,7 +110,7 @@ func (a *API) GetOrder(orderID int64, isStatus bool) (getOrderResult *GetOrderRe
orderStartTime,orderEndTime,orderRemark,consigneeInfo,
itemInfoList,pauseBizInfo,pin,idSopShipmenttype`
if isStatus {
params["order_state"] = "WAIT_SELLER_STOCK_OUT,PAUSE,TRADE_CANCELED"
params["order_state"] = "WAIT_SELLER_STOCK_OUT,TRADE_CANCELED"
}
result, err := a.AccessAPI("jingdong.pop.order.get", prodURL, params)
if err == nil {
@@ -218,3 +221,35 @@ func (a *API) KeyGet() (keyGetResult *KeyGetResult, err error) {
}
return keyGetResult, err
}
type GetOrderExtInfoByOrderIdResult struct {
IDSopShipmentType string `json:"idSopShipmentType"`
OrderCreateDate string `json:"orderCreateDate"`
CodDate string `json:"codDate"`
SelectedItem string `json:"selectedItem"`
Batch string `json:"batch"`
DeliveryCodTime string `json:"deliveryCodTime"`
Speedhour string `json:"Speedhour"`
FinalDelieveredTime string `json:"finalDelieveredTime"`
}
//获取期望送货时间
func (a *API) GetOrderExtInfoByOrderId(orderId string) (time string, err error) {
getOrderExtInfoByOrderIdResult := &GetOrderExtInfoByOrderIdResult{}
result, err := a.AccessAPI("jingdong.pop.order.getOrderExtInfoByOrderId", prodURL, map[string]interface{}{
"orderId": orderId,
"searchFileds": "deliveryInfo",
})
if err == nil {
str := strings.ReplaceAll(result["jingdong_pop_order_getOrderExtInfoByOrderId_responce"].(map[string]interface{})["orderExtraInfoResultModel"].(map[string]interface{})["resultMap"].(map[string]interface{})["deliveryInfo"].(string), "\\", "")
err = json.Unmarshal([]byte(str), &getOrderExtInfoByOrderIdResult)
exTime := strings.Split(getOrderExtInfoByOrderIdResult.DeliveryCodTime, ",")
if len(exTime) < 2 {
time = getOrderExtInfoByOrderIdResult.FinalDelieveredTime
} else {
exTime2 := strings.Split(exTime[1], "-")
time = exTime[0] + " " + exTime2[1] + ":00"
}
}
return time, err
}

View File

@@ -45,3 +45,11 @@ func TestKeyGet(t *testing.T) {
}
t.Log(utils.Format4Output(result, false))
}
func TestGetOrderExtInfoByOrderId(t *testing.T) {
result, err := api.GetOrderExtInfoByOrderId("130427633633")
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}

View File

@@ -43,16 +43,16 @@ func TestNewInfoList(t *testing.T) {
}
func Test11(t *testing.T) {
type StrA struct {
Cat string `json:"cat"`
Dog int `json:"dog,omitempty"`
Mouse int `json:"mouse"`
change := func(s ...string) {
s[0] = "Go"
s = append(s, "playground")
fmt.Println(s)
}
a := &StrA{
Cat: "加菲",
}
fmt.Println(utils.Format4Output(a, false))
fmt.Println(a.Dog == 0, a.Mouse)
welcome := []string{"hello", "world"}
change(welcome...)
fmt.Println(welcome)
}
func TestAllOrders(t *testing.T) {

View File

@@ -18,7 +18,7 @@ func TestShopQuery(t *testing.T) {
// if err == nil {
// t.Fatal("应该报错找不到门店")
// }
shopInfo, err := api.ShopQuery("11732425")
shopInfo, err := api.ShopQuery("667446")
if err != nil {
t.Fatal(err)
}

View File

@@ -16,7 +16,7 @@ func TestOrderViewStatus(t *testing.T) {
}
func TestOrderGetOrderDetail(t *testing.T) {
result, err := api.OrderGetOrderDetail(69760842061320598, false)
result, err := api.OrderGetOrderDetail(73322892924405911, false)
if err != nil {
t.Fatal(err)
}
@@ -27,7 +27,7 @@ func TestOrderGetOrderDetail(t *testing.T) {
}
func TestOrderGetOrderDetail2(t *testing.T) {
result, err := api.OrderGetOrderDetail2(69760842061320598, false)
result, err := api.OrderGetOrderDetail2(73322892924405911, false)
if err != nil {
t.Fatal(err)
}

View File

@@ -286,7 +286,7 @@ func TestRetailSellStatus(t *testing.T) {
}
func TestCategoryAttrList(t *testing.T) {
result, err := api.CategoryAttrList(200002728)
result, err := api.CategoryAttrList(200002727)
if err != nil {
t.Fatal(err)
}

View File

@@ -26,7 +26,7 @@ func init() {
// prod
api = New("wx2bb99eb5d2c9b82c", "6bbbed1443cc062c20a015a64c07a531")
api.CBSetToken("35_1ilNtBtqXwojmsYWgzpjn8Nn-1DuOfy0rTcsIuRz5RqXAcJRYCmcFP0oBQR6N6dBm6lOvg7j7O-YMKh_--zfbJ_4hBCfBbvI7svoeIc3l4W_UHA41LyT_asp731YpNKA9oRWkg0ftTJj0rHwLEDhAHAUNM")
api.CBSetToken("36_un9YOYENTdiNi4TVoDfrb2oiiU9XSugSgbm0B-uJ4TbhVk543aOi5UcBgYcujsCZ1gyCIMDbaKCON7oWMHtHRLCg1P2KzjRhxU3KoVbNZ04PPzdDOXStnigkoSLTxv-y9pbenFP0kHYHUeRHQEUeAHAJXN")
}
func handleError(t *testing.T, err error) {