diff --git a/platformapi/fnpsapi_old/callback.go b/platformapi/fnpsapi_old/callback.go deleted file mode 100644 index 096810d8..00000000 --- a/platformapi/fnpsapi_old/callback.go +++ /dev/null @@ -1,53 +0,0 @@ -package fnpsapi - -import ( - "net/url" - - "git.rosy.net.cn/jx-callback/globals" - - "git.rosy.net.cn/baseapi/utils" -) - -type CallBackInfo struct { - AppID string `json:"app_id"` - Data string `json:"data"` - Salt int `json:"salt"` - Signature string `json:"signature"` -} - -type WayBillInfo struct { - PartnerOrderCode string `json:"partner_order_code"` - OrderStatus int `json:"order_status"` - PushTime int64 `json:"push_time"` - CarrierDriverName string `json:"carrier_driver_name"` - CarrierDriverPhone string `json:"carrier_driver_phone"` - OpenOrderCode int64 `json:"open_order_code"` - PlatformCode string `json:"platform_code"` - ErrorScene string `json:"error_scene"` - Description string `json:"description"` - ErrorCode string `json:"error_code"` - DetailDescription string `json:"detail_description"` -} - -func (a *API) GetOrderCallbackMsg(data []byte) (orderMsg *WayBillInfo) { - callbackInfo := &CallBackInfo{} - err := utils.UnmarshalUseNumber(data, callbackInfo) - if err != nil { - return nil - } - if err == nil { - if str, err := url.QueryUnescape(callbackInfo.Data); err == nil { - orderMsg = &WayBillInfo{} - if err := utils.UnmarshalUseNumber([]byte(str), orderMsg); err == nil { - return orderMsg - } else { - globals.SugarLogger.Debugf("fn msg faild3 %v", err) - return nil - } - } else { - globals.SugarLogger.Debugf("fn msg faild2 %v", err) - return nil - } - } - return orderMsg -} diff --git a/platformapi/fnpsapi_old/fnpsapi.go b/platformapi/fnpsapi_old/fnpsapi.go deleted file mode 100644 index 9fffdb8e..00000000 --- a/platformapi/fnpsapi_old/fnpsapi.go +++ /dev/null @@ -1,148 +0,0 @@ -package fnpsapi - -import ( - "crypto/md5" - "encoding/json" - "fmt" - "math/rand" - "net/http" - "net/url" - "sort" - "strings" - "sync" - "time" - - "git.rosy.net.cn/baseapi/platformapi" - "git.rosy.net.cn/baseapi/utils" -) - -const ( - sigKey = "signature" - - TestURL = "https://exam-anubis.ele.me/anubis-webapi" - URL = "https://open-anubis.ele.me/anubis-webapi" - tokenAction = "get_access_token" -) - -type API struct { - accessToken string - appID string - appSecret string - locker sync.RWMutex - client *http.Client - config *platformapi.APIConfig -} - -func (a *API) SetToken(token string) { - a.locker.Lock() - defer a.locker.Unlock() - a.accessToken = token -} - -func New(appID, appSecret string, config ...*platformapi.APIConfig) *API { - curConfig := platformapi.DefAPIConfig - if len(config) > 0 { - curConfig = *config[0] - } - return &API{ - appID: appID, - appSecret: appSecret, - client: &http.Client{Timeout: curConfig.ClientTimeout}, - config: &curConfig, - } -} - -func (a *API) signParam(params map[string]interface{}) (sig string) { - var valueList []string - for k, v := range params { - if k != sigKey { - if str := fmt.Sprint(v); str != "" { - valueList = append(valueList, fmt.Sprintf("%s=%s", k, str)) - } - } - } - sort.Sort(sort.StringSlice(valueList)) - valueList = append(valueList, fmt.Sprintf("secret_key=%s", a.appSecret)) - sig = strings.Join(valueList, "&") - binSig := md5.Sum([]byte(url.QueryEscape(sig))) - sig = fmt.Sprintf("%x", binSig) - return sig -} - -func (a *API) signParam2(params map[string]interface{}) (sig string) { - sb := new(strings.Builder) - sb.WriteString("app_id=") - sb.WriteString(a.appID) - sb.WriteString("&access_token=") - sb.WriteString(a.accessToken) - sb.WriteString("&data=") - sb.WriteString(params["data"].(string)) - sb.WriteString("&salt=") - sb.WriteString(utils.Int64ToStr(utils.MustInterface2Int64(params["salt"]))) - sig = sb.String() - binSig := md5.Sum([]byte(sig)) - sig = fmt.Sprintf("%x", binSig) - return sig -} - -func (a *API) AccessAPI(action string, url string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) { - params := make(map[string]interface{}) - params["salt"] = GetSalt() - params["app_id"] = a.appID - if action != tokenAction { - data, _ := json.Marshal(bizParams) - params["data"] = string(data) - signStr := a.signParam2(params) - params[sigKey] = signStr - } else { - signStr := a.signParam(params) - params[sigKey] = signStr - } - data, _ := json.Marshal(params) - fullURL := utils.GenerateGetURL(url, action, nil) - err = platformapi.AccessPlatformAPIWithRetry(a.client, - func() *http.Request { - var request *http.Request - if isPost { - request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(data))) - } else { - request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(url, action, params), nil) - } - request.Header.Set("Content-Type", "application/json") - return request - }, - a.config, - func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) { - if jsonResult1 == nil { - return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil") - } - if err == nil { - if utils.MustInterface2Int64(jsonResult1["code"]) != 200 { - errLevel = platformapi.ErrLevelGeneralFail - err = utils.NewErrorCode(jsonResult1["msg"].(string), utils.Int64ToStr(utils.MustInterface2Int64(jsonResult1["code"]))) - } - retVal = jsonResult1 - } - return errLevel, err - }) - return retVal, err -} - -func GetSalt() (salt int) { - rand.Seed(time.Now().UnixNano()) - return rand.Intn(8999) + 1000 -} - -type TokenInfo struct { - AccessToken string `json:"access_token"` - AppID string `json:"app_id"` - ExpireTime int64 `json:"expire_time"` -} - -func (a *API) GetAccessToken() (tokenInfo *TokenInfo, err error) { - result, err := a.AccessAPI(tokenAction, URL, nil, false) - if err == nil { - utils.Map2StructByJson(result["data"], &tokenInfo, false) - } - return tokenInfo, err -} diff --git a/platformapi/fnpsapi_old/fnpsapi_test.go b/platformapi/fnpsapi_old/fnpsapi_test.go deleted file mode 100644 index b4cc7b5d..00000000 --- a/platformapi/fnpsapi_old/fnpsapi_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package fnpsapi - -import ( - "testing" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/utils" - "go.uber.org/zap" -) - -var ( - api *API - apiv3 *APIv3 - sugarLogger *zap.SugaredLogger -) - -func init() { - logger, _ := zap.NewDevelopment() - sugarLogger = logger.Sugar() - baseapi.Init(sugarLogger) - api = New("6a3e2073-1850-413b-9eb7-6c342ec36e1c", "a8248088-a742-4c33-a0db-03aeae00ca7d") - api.SetToken("n-606c907a-5117-4c64-bc32-291c3091cabd-w") - apiv3 = Newv3("6a3e2073-1850-413b-9eb7-6c342ec36e1c", "a8248088-a742-4c33-a0db-03aeae00ca7d") - apiv3.SetTokenv3("n-606c907a-5117-4c64-bc32-291c3091cabd-w") -} - -func TestGetAccessToken(t *testing.T) { - result, err := api.GetAccessToken() - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} diff --git a/platformapi/fnpsapi_old/fnpsapiv3.go b/platformapi/fnpsapi_old/fnpsapiv3.go deleted file mode 100644 index 993e3d1d..00000000 --- a/platformapi/fnpsapi_old/fnpsapiv3.go +++ /dev/null @@ -1,137 +0,0 @@ -package fnpsapi - -import ( - "crypto/sha1" - "encoding/json" - "fmt" - "git.rosy.net.cn/baseapi/platformapi" - "git.rosy.net.cn/baseapi/utils" - "net/http" - "sort" - "strings" - "sync" - "time" -) - -const ( - merchantID = "51658" - - URLv3 = "https://open-anubis.ele.me/anubis-webapi/v3/invoke" -) - -type APIv3 struct { - accessToken string - appID string - appSecret string - - locker sync.RWMutex - client *http.Client - config *platformapi.APIConfig -} - -func Newv3(appID, appSecret string, config ...*platformapi.APIConfig) *APIv3 { - curConfig := platformapi.DefAPIConfig - if len(config) > 0 { - curConfig = *config[0] - } - return &APIv3{ - appID: appID, - appSecret: appSecret, - client: &http.Client{Timeout: curConfig.ClientTimeout}, - config: &curConfig, - } -} - -func (a *APIv3) SetTokenv3(token string) { - a.locker.Lock() - defer a.locker.Unlock() - a.accessToken = token -} - -func (a *APIv3) signParamv3(params map[string]interface{}) (sig string) { - var valueList []string - for k, v := range params { - if k != sigKey { - if str := fmt.Sprint(v); str != "" { - valueList = append(valueList, fmt.Sprintf("%s=%s", k, str)) - } - } - } - sort.Sort(sort.StringSlice(valueList)) - sig = strings.Join(valueList, "&") - sig = a.appSecret + sig - binSig := sha1.Sum([]byte(sig)) - sig = fmt.Sprintf("%x", binSig) - return sig -} - -func (a *APIv3) AccessAPIv3(action string, url string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) { - params := make(map[string]interface{}) - params["timestamp"] = time.Now().UnixNano() - params["app_id"] = a.appID - params["merchant_id"] = merchantID - params["version"] = "1.0" - params["access_token"] = a.accessToken - data, _ := json.Marshal(bizParams) - params["business_data"] = string(data) - signStr := a.signParamv3(params) - params[sigKey] = signStr - datas, _ := json.Marshal(params) - fullURL := utils.GenerateGetURL(url, action, nil) - err = platformapi.AccessPlatformAPIWithRetry(a.client, - func() *http.Request { - var request *http.Request - if isPost { - request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(datas))) - } else { - request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(url, action, params), nil) - } - request.Header.Set("Content-Type", "application/json") - return request - }, - a.config, - func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) { - if jsonResult1 == nil { - return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil") - } - if err == nil { - if utils.MustInterface2Int64(jsonResult1["code"]) != 200 { - errLevel = platformapi.ErrLevelGeneralFail - err = utils.NewErrorCode(jsonResult1["msg"].(string), utils.Int64ToStr(utils.MustInterface2Int64(jsonResult1["code"]))) - } - retVal = jsonResult1 - } - return errLevel, err - }) - return retVal, err -} - -type PreCreateOrderParam struct { - PartnerOrderCode string `json:"partner_order_code"` - OutShopCode string `json:"out_shop_code"` - OrderType int `json:"order_type"` - PositionSource int `json:"position_source"` // 3:高德地图 - ReceiverAddress string `json:"receiver_address"` - ReceiverLongitude float64 `json:"receiver_longitude"` - ReceiverLatitude float64 `json:"receiver_latitude"` - GoodsTotalAmountCent float64 `json:"goods_total_amount_cent"` - GoodsActualAmountCent float64 `json:"goods_actual_amount_cent"` - GoodsWeight float64 `json:"goods_weight"` - GoodsCount float64 `json:"goods_count"` - GoodsItemList []*ItemsJSON2 `json:"goods_item_list"` -} - -type ItemsJSON2 struct { - ItemName string `json:"item_name"` - ItemQuantity int `json:"item_quantity"` - ItemAmountCent float64 `json:"item_amount_cent"` - ItemActualAmountCent float64 `json:"item_actual_amount_cent"` -} - -func (a *APIv3) PreCreateOrder(preCreateOrderParam *PreCreateOrderParam) (queryOrderResult *QueryOrderResult, err error) { - result, err := a.AccessAPIv3("preCreateOrder", URLv3, utils.Struct2FlatMap(preCreateOrderParam), true) - if err == nil { - utils.Map2StructByJson(result["data"], &queryOrderResult, false) - } - return queryOrderResult, err -} diff --git a/platformapi/fnpsapi_old/fnpsapiv3_test.go b/platformapi/fnpsapi_old/fnpsapiv3_test.go deleted file mode 100644 index 14895a64..00000000 --- a/platformapi/fnpsapi_old/fnpsapiv3_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package fnpsapi - -import ( - "git.rosy.net.cn/baseapi/utils" - "testing" -) - -func TestPreCreateOrder(t *testing.T) { - result, err := apiv3.PreCreateOrder(&PreCreateOrderParam{ - PartnerOrderCode: "2118717546000352", - OutShopCode: "667002", - OrderType: 1, - PositionSource: 3, - ReceiverAddress: "徐州市泉山区大润发(欣欣店)一楼咔啦嘟熊童装店", - ReceiverLongitude: 117.195360, - ReceiverLatitude: 34.201010, - GoodsTotalAmountCent: 66.2, - GoodsActualAmountCent: 67.2, - GoodsWeight: 2.3, - GoodsCount: 6, - GoodsItemList: []*ItemsJSON2{ - &ItemsJSON2{ - ItemName: "巨峰葡萄约500g/份", - ItemQuantity: 2, - ItemAmountCent: 15.2, - ItemActualAmountCent: 15.2, - }, - &ItemsJSON2{ - ItemName: "[新鲜]苹果150g/个(约150g-250g)", - ItemQuantity: 2, - ItemAmountCent: 4.3, - ItemActualAmountCent: 4.3, - }, - &ItemsJSON2{ - ItemName: "脆桃 鲜,甜,脆约500g/份", - ItemQuantity: 2, - ItemAmountCent: 14.6, - ItemActualAmountCent: 14.6, - }, - }, - }) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} diff --git a/platformapi/fnpsapi_old/order.go b/platformapi/fnpsapi_old/order.go deleted file mode 100644 index bc01b1b2..00000000 --- a/platformapi/fnpsapi_old/order.go +++ /dev/null @@ -1,175 +0,0 @@ -package fnpsapi - -import ( - "time" - - "git.rosy.net.cn/baseapi/utils" -) - -const ( - OrderCancelReson1 = 1 // 1:物流原因:订单长时间未分配骑手, - OrderCancelReson2 = 2 // 2:物流原因:分配骑手后,骑手长时间未取件 , - OrderCancelReson3 = 3 // 3:物流原因:骑手告知不配送,让取消订单, - OrderCancelReson4 = 4 // 4:商品缺货/无法出货/已售完, - OrderCancelReson5 = 5 // 5:商户联系不上门店/门店关门了, - OrderCancelReson6 = 6 // 6:商户发错单, - OrderCancelReson7 = 7 // 7:商户/顾客自身定位错误, - OrderCancelReson8 = 8 // 8:商户改其他第三方配送, - OrderCancelReson9 = 9 // 9:顾客下错单/临时不想要了, - OrderCancelReson10 = 10 // 10:顾客自取/不在家/要求另改时间配送)(0类型已下线) - - OrderStatusAccept = 1 //系统已接单 - OrderStatusAssigned = 20 //已分配骑手 - OrderStatusArrived = 80 //已到店 - OrderStatusDelivering = 2 //配送中 - OrderStatusDelivered = 3 //已送达 - OrderStatusException = 5 //异常 -) - -type CreateOrderParam struct { - PartnerRemark string `json:"partner_remark,omitempty"` - PartnerOrderCode string `json:"partner_order_code,omitempty"` - NotifyURL string `json:"notify_url,omitempty"` - OrderType int `json:"order_type,omitempty"` - ChainStoreCode string `json:"chain_store_code,omitempty"` - TransportInfo *TransportInfo `json:"transport_info,omitempty"` - OrderAddTime int64 `json:"order_add_time,omitempty"` - OrderTotalAmount float64 `json:"order_total_amount,omitempty"` - OrderActualAmount float64 `json:"order_actual_amount,omitempty"` - OrderWeight float64 `json:"order_weight,omitempty"` - OrderRemark string `json:"order_remark,omitempty"` - IsInvoiced int `json:"is_invoiced"` - Invoice string `json:"invoice,omitempty"` - OrderPaymentStatus int `json:"order_payment_status,omitempty"` - OrderPaymentMethod int `json:"order_payment_method,omitempty"` - IsAgentPayment int `json:"is_agent_payment"` - RequirePaymentPay float64 `json:"require_payment_pay,omitempty"` - GoodsCount int `json:"goods_count,omitempty"` - RequireReceiveTime int64 `json:"require_receive_time,omitempty"` - SerialNumber string `json:"serial_number,omitempty"` - ReceiverInfo *ReceiverInfo `json:"receiver_info,omitempty"` - ItemsJSON []*ItemsJSON `json:"items_json,omitempty"` - OrderSource string `json:"order_source,omitempty"` //饿百订单传109 - ChannelOrderCode string `json:"channel_order_code,omitempty"` - CookingTime int64 `json:"cooking_time,omitempty"` - PlatformPaidTime int64 `json:"platform_paid_time,omitempty"` - PlatformCreatedTime int64 `json:"platform_created_time,omitempty"` - MerchantCode string `json:"merchant_code,omitempty"` -} - -type ReceiverInfo struct { - ReceiverName string `json:"receiver_name,omitempty"` - ReceiverPrimaryPhone string `json:"receiver_primary_phone,omitempty"` - ReceiverSecondPhone string `json:"receiver_second_phone,omitempty"` - ReceiverAddress string `json:"receiver_address,omitempty"` - ReceiverLongitude float64 `json:"receiver_longitude,omitempty"` - ReceiverLatitude float64 `json:"receiver_latitude,omitempty"` - PositionSource int `json:"position_source,omitempty"` -} - -type TransportInfo struct { - TransportName string `json:"transport_name,omitempty"` - TransportAddress string `json:"transport_address,omitempty"` - TransportLongitude float64 `json:"transport_longitude,omitempty"` - TransportLatitude float64 `json:"transport_latitude,omitempty"` - PositionSource int `json:"position_source,omitempty"` - TransportTel string `json:"transport_tel,omitempty"` - TransportRemark string `json:"transport_remark,omitempty"` -} - -type ItemsJSON struct { - ItemID string `json:"item_id,omitempty"` - ItemName string `json:"item_name,omitempty"` - ItemQuantity int `json:"item_quantity,omitempty"` - ItemPrice float64 `json:"item_price"` - ItemActualPrice float64 `json:"item_actual_price"` - ItemSize int `json:"item_size,omitempty"` - ItemRemark string `json:"item_remark,omitempty"` - IsNeedPackage int `json:"is_need_package"` - IsAgentPurchase int `json:"is_agent_purchase"` - AgentPurchasePrice float64 `json:"agent_purchase_price,omitempty"` -} - -//https://open.ele.me/documents/%E5%88%9B%E5%BB%BA%E8%9C%82%E9%B8%9F%E8%AE%A2%E5%8D%95 -func (a *API) CreateOrder(createOrderParam *CreateOrderParam) (err error) { - params := utils.Struct2FlatMap(createOrderParam) - _, err = a.AccessAPI("v2/order", URL, params, true) - return err -} - -//order_cancel_reason_code 订单取消原因代码(1:用户取消,2:商家取消) -// order_cancel_code 订单取消编码( -// 1:物流原因:订单长时间未分配骑手, -// 2:物流原因:分配骑手后,骑手长时间未取件 , -// 3:物流原因:骑手告知不配送,让取消订单, -// 4:商品缺货/无法出货/已售完, 5:商户联系不上门店/门店关门了, 6:商户发错单, -// 7:商户/顾客自身定位错误, 8:商户改其他第三方配送, 9:顾客下错单/临时不想要了, -// 10:顾客自取/不在家/要求另改时间配送)(0类型已下线) - -type CancelOrderParam struct { - PartnerOrderCode string `json:"partner_order_code,omitempty"` - OrderCancelReasonCode int `json:"order_cancel_reason_code,omitempty"` - OrderCancelCode int `json:"order_cancel_code,omitempty"` - OrderCancelDescription string `json:"order_cancel_description,omitempty"` - OrderCancelTime int64 `json:"order_cancel_time,omitempty"` -} - -func (a *API) CancelOrder(cancelOrderParam *CancelOrderParam) (err error) { - params := utils.Struct2FlatMap(cancelOrderParam) - _, err = a.AccessAPI("v2/order/cancel", URL, params, true) - return err -} - -func (a *API) ComplaintOrder(cancelOrderParam *CancelOrderParam) (err error) { - params := utils.Struct2FlatMap(cancelOrderParam) - _, err = a.AccessAPI("v2/order/complaint", URL, params, true) - return err -} - -type QueryOrderResult struct { - AbnormalCode string `json:"abnormal_code"` - AbnormalDesc string `json:"abnormal_desc"` - CarrierDriverID int `json:"carrier_driver_id"` - CarrierDriverName string `json:"carrier_driver_name"` - CarrierDriverPhone string `json:"carrier_driver_phone"` - ComplaintDescription interface{} `json:"complaintDescription"` - ComplaintStatus interface{} `json:"complaintStatus"` - EstimateArriveTime int64 `json:"estimate_arrive_time"` - EventLogDetails []struct { - CarrierDriverName string `json:"carrier_driver_name"` - CarrierDriverPhone string `json:"carrier_driver_phone"` - OccurTime int64 `json:"occur_time"` - OrderStatus int `json:"order_status"` - } `json:"event_log_details"` - HandleID interface{} `json:"handleId"` - OrderID interface{} `json:"orderId"` - OrderStatus int `json:"order_status"` - OrderTotalDeliveryCost float64 `json:"order_total_delivery_cost"` - OrderTotalDeliveryDiscount interface{} `json:"order_total_delivery_discount"` - OvertimeCompensationCost float64 `json:"overtime_compensation_cost"` - Reason string `json:"reason"` - SupportClaims bool `json:"support_claims"` - TrackingID int64 `json:"trackingId"` - TrackingID2 int64 `json:"tracking_id"` - TransportStationID string `json:"transport_station_id"` - TransportStationTel string `json:"transport_station_tel"` -} - -func (a *API) QueryOrder(partnerOrderCode string) (queryOrderResult *QueryOrderResult, err error) { - result, err := a.AccessAPI("v2/order/query", URL, map[string]interface{}{ - "partner_order_code": partnerOrderCode, - }, true) - if err == nil { - utils.Map2StructByJson(result["data"], &queryOrderResult, false) - } - return queryOrderResult, err -} - -func (a *API) ComplaintRider(partnerOrderCode string, orderComplaintCode int) (err error) { - _, err = a.AccessAPI("v2/order/complaint", URL, map[string]interface{}{ - "partner_order_code": partnerOrderCode, - "order_complaint_code": orderComplaintCode, - "order_complaint_time": time.Now().UnixNano() / 1e6, - }, true) - return err -} diff --git a/platformapi/fnpsapi_old/order_test.go b/platformapi/fnpsapi_old/order_test.go deleted file mode 100644 index 0c1f7098..00000000 --- a/platformapi/fnpsapi_old/order_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package fnpsapi - -import ( - "testing" - "time" - - "git.rosy.net.cn/baseapi/utils" -) - -func TestQueryOrder(t *testing.T) { - result, err := api.QueryOrder("134420892247000001") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestCreateOrder(t *testing.T) { - params := &CreateOrderParam{ - PartnerOrderCode: "2140252158517300353", - NotifyURL: "https://callback.test.jxc4.com/fn/msg", - ChainStoreCode: "667281", - OrderType: 1, //即时达 - TransportInfo: &TransportInfo{ - TransportName: "测试西南交大店", - TransportAddress: "成都市金牛区交大路银桂桥二巷60号", - TransportLongitude: 104.047773, - TransportLatitude: 30.695838, - PositionSource: 3, - TransportTel: "18160030913", - }, - OrderAddTime: time.Now().UnixNano() / 1e6, - OrderTotalAmount: 12, - OrderActualAmount: 10, - OrderWeight: 1.2, - OrderRemark: utils.FilterMb4("客户电话:18160030913,测试取货失败或配送遇到问题请联系18048531223,禁止未配送直接完成定单!"), - IsInvoiced: 0, - OrderPaymentStatus: 1, - OrderPaymentMethod: 1, - IsAgentPayment: 0, - GoodsCount: 2, - ReceiverInfo: &ReceiverInfo{ - ReceiverName: "苏尹岚", - ReceiverAddress: "武侯大道金色花园A区", - ReceiverLongitude: 104.01459, - ReceiverLatitude: 30.636258, - ReceiverPrimaryPhone: "18160030913", - ReceiverSecondPhone: "18160030913", - PositionSource: 3, - }, - SerialNumber: "测试1#", - } - var skuInfo []*ItemsJSON - // for _, v := range order.Skus { - skuInfo = append(skuInfo, &ItemsJSON{ - ItemID: "30677", - ItemName: "测试商品", - ItemQuantity: 1, - ItemPrice: 3.6, - ItemActualPrice: 2, - }) - // } - params.ItemsJSON = skuInfo - //要求饿百的订单要传来源 - // if order.VendorID == model.VendorIDEBAI { - // params.OrderSource = "109" - // params.ChannelOrderCode = order.VendorOrderID - // } - err := api.CreateOrder(params) - if err != nil { - t.Fatal(err) - } - // t.Log(utils.Format4Output(result, false)) -} - -func TestComplaintRider(t *testing.T) { - err := api.ComplaintRider("2118635456000161", 130) - if err != nil { - t.Fatal(err) - } - // t.Log(utils.Format4Output(result, false)) -} - -func TestCancelOrder(t *testing.T) { - err := api.CancelOrder(&CancelOrderParam{ - PartnerOrderCode: "89296492736359287", - }) - if err != nil { - t.Fatal(err) - } - // t.Log(utils.Format4Output(result, false)) -} diff --git a/platformapi/fnpsapi_old/store.go b/platformapi/fnpsapi_old/store.go deleted file mode 100644 index d70c6cb7..00000000 --- a/platformapi/fnpsapi_old/store.go +++ /dev/null @@ -1,84 +0,0 @@ -package fnpsapi - -import ( - "fmt" - "strings" - - "git.rosy.net.cn/baseapi/utils" -) - -const ( - StoreNotExist = "门店信息不存在" - StoreExist = "该门店已存在" -) - -type CreateStoreParam struct { - ChainStoreCode string `json:"chain_store_code,omitempty"` - ChainStoreName string `json:"chain_store_name,omitempty"` - ChainStoreType int `json:"chain_store_type,omitempty"` - MerchantCode string `json:"merchant_code,omitempty"` - ContactPhone string `json:"contact_phone,omitempty"` - Address string `json:"address,omitempty"` - PositionSource int `json:"position_source,omitempty"` - Longitude string `json:"longitude,omitempty"` - Latitude string `json:"latitude,omitempty"` - ServiceCode string `json:"service_code,omitempty"` -} - -func (a *API) CreateStore(createStoreParam *CreateStoreParam) (err error) { - createStoreParam.ServiceCode = "1" - params := utils.Struct2FlatMap(createStoreParam) - _, err = a.AccessAPI("v2/chain_store", URL, params, true) - return err -} - -type GetStoreResult struct { - ChainStoreCode string `json:"chain_store_code"` - ChainStoreName string `json:"chain_store_name"` - Address string `json:"address"` - Latitude string `json:"latitude"` - Longitude string `json:"longitude"` - PositionSource int `json:"position_source"` - City string `json:"city"` - ContactPhone string `json:"contact_phone"` - ServiceCode string `json:"service_code"` - Status int `json:"status"` //1关店,2开店 -} - -func (a *API) GetStore(storeID string) (getStoreResult *GetStoreResult, err error) { - result, err := a.AccessAPI("v2/chain_store/query", URL, map[string]interface{}{ - "chain_store_code": []string{storeID}, - }, true) - if err == nil { - if data, ok := result["data"].([]interface{}); ok { - utils.Map2StructByJson(data[0], &getStoreResult, false) - } else { - err = fmt.Errorf(result["msg"].(string)) - } - } - return getStoreResult, err -} - -func IsErrShopNotExist(err error) bool { - if err != nil { - if strings.Contains(err.Error(), StoreNotExist) { - return true - } - } - return false -} - -func IsErrShopExist(err error) bool { - if err != nil { - if strings.Contains(err.Error(), StoreExist) { - return true - } - } - return false -} - -func (a *API) UpdateStore(createStoreParam *CreateStoreParam) (err error) { - params := utils.Struct2FlatMap(createStoreParam) - _, err = a.AccessAPI("v2/chain_store/update", URL, params, true) - return err -} diff --git a/platformapi/fnpsapi_old/store_test.go b/platformapi/fnpsapi_old/store_test.go deleted file mode 100644 index 89dc7c9d..00000000 --- a/platformapi/fnpsapi_old/store_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package fnpsapi - -import ( - "testing" - - "git.rosy.net.cn/baseapi/utils" -) - -func TestCreateStore(t *testing.T) { - err := api.CreateStore(&CreateStoreParam{ - ChainStoreCode: "667281", - ChainStoreName: "测试西南交大店", - ChainStoreType: 2, - ContactPhone: "18160030913", - Address: "成都市金牛区交大路银桂桥二巷60号", - PositionSource: 3, - Longitude: "104.047773", - Latitude: "30.695838", - ServiceCode: "1", - }) - if err != nil { - t.Fatal(err) - } - // t.Log(utils.Format4Output(result, false)) -} - -func TestGetStore(t *testing.T) { - result, err := api.GetStore("667281") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestUpdateStore(t *testing.T) { - err := api.UpdateStore(&CreateStoreParam{ - ChainStoreCode: "667281", - Address: "1111111", - }) - if err != nil { - t.Fatal(err) - } - // t.Log(utils.Format4Output(result, false)) -} diff --git a/platformapi/mtwmapi/poi_test.go b/platformapi/mtwmapi/poi_test.go index 3624aff9..3aa63549 100644 --- a/platformapi/mtwmapi/poi_test.go +++ b/platformapi/mtwmapi/poi_test.go @@ -1,8 +1,8 @@ package mtwmapi import ( + "encoding/json" "fmt" - "strings" "testing" "git.rosy.net.cn/baseapi/utils" @@ -201,18 +201,22 @@ type Name struct { var aa = []map[string]interface{}{{"name": "zhangjianping", "description": "张建平"}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103399}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666990}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667194}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667212}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667385}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100028}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100234}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100236}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100267}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100270}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100273}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100278}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100274}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100279}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100284}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100326}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100329}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100328}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100334}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100335}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100336}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100350}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100351}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100361}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100366}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100369}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100377}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100463}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100477}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100501}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100517}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100515}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100524}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100699}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100754}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100766}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100767}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100883}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100887}, {"name": "StoreBoss", "description": "门店老板", "storeID": 100920}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101000}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101088}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101107}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101111}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101176}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101722}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101755}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101775}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101842}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101997}, {"name": "StoreBoss", "description": "门店老板", "storeID": 101999}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102012}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102014}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102022}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102046}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102047}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102075}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102136}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102134}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102222}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102280}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102300}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102303}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102307}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102373}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102377}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102379}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102405}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102417}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102433}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102444}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102481}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102511}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102519}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102533}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102534}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102562}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102606}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102709}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102752}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102772}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102776}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102778}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102788}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102789}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102790}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102792}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102807}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102824}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102882}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102889}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102890}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102954}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102958}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102962}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102971}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103030}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103041}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103048}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103069}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103082}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103084}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103085}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103089}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103090}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103093}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103116}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103119}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103161}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103178}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103186}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103190}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103200}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103425}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103452}, {"name": "StoreBoss", "description": "门店老板", "storeID": 103454}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666669}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666736}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666742}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666760}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666761}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666852}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666898}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666950}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667050}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667083}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667149}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667227}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667266}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667286}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667291}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667293}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667296}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667510}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667758}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667761}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667762}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667765}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667772}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667777}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667778}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667785}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667790}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667803}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667804}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667805}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667807}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667809}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667810}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667817}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667820}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667823}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667821}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667824}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667825}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667834}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667838}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667839}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667844}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667870}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667871}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667873}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667872}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667874}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667875}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667876}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667877}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667878}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667879}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667880}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667881}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667882}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667883}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667885}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667897}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667905}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667906}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667907}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667915}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667932}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667946}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667948}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667961}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667962}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667965}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667970}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667967}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667971}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667972}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667973}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667981}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667984}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667986}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667987}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667988}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667989}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667990}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667992}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667993}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667994}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667998}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668010}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668011}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668012}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668013}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668014}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668015}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668016}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668017}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668018}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668021}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668023}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668024}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668025}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668026}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668027}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668028}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668029}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668030}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668031}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668032}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668049}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668101}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668104}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668105}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668103}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668102}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102160}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668117}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666711}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668125}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668188}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668199}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668210}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668215}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668214}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668228}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668284}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668396}, {"name": "StoreBoss", "description": "门店老板", "storeID": 666878}, {"name": "StoreBoss", "description": "门店老板", "storeID": 668584}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102057}, {"name": "StoreBoss", "description": "门店老板", "storeID": 102592}, {"name": "StoreBoss", "description": "门店老板", "storeID": 667184}} func TestName2222(t *testing.T) { - storeId := make([]int64, 0, 0) - ddd := make([]string, 0, 0) - for _, v := range aa { - for k2, v2 := range v { - if k2 == "storeID" { - storeId = append(storeId, utils.Interface2Int64WithDefault(v2, 0)) - ddd = append(ddd, utils.Int64ToStr(utils.Interface2Int64WithDefault(v2, 0))) - } + saleStart := utils.Int2Str(int(600)) + saleEnd := utils.Int2Str(int(1900)) + for { + if len(saleStart) != 4 { + saleStart = "0" + saleStart + } + if len(saleEnd) != 4 { + saleEnd += "0" + saleEnd + } + if len(saleEnd) == 4 && len(saleStart) == 4 { + break } } - fmt.Println(len(aa)) - fmt.Println(len(storeId)) - fmt.Println(len(ddd)) - fmt.Println(strings.Join(ddd, ",")) + saleStart = fmt.Sprintf("%s:%s", saleStart[:2], saleStart[2:]) + saleEnd = fmt.Sprintf("%s:%s", saleEnd[:2], saleEnd[2:]) + availableTimes := fmt.Sprintf("%s-%s", saleStart, saleEnd) + available, _ := json.Marshal(map[string]string{"monday": availableTimes, "tuesday": availableTimes, "wednesday": availableTimes, "thursday": availableTimes, "friday": availableTimes, "saturday": availableTimes, "sunday": availableTimes}) + fmt.Println(string(available)) } diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index 916e30e2..fe408c7b 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -297,10 +297,14 @@ func (a *API) RetailInitData(trackInfo, poiCode, foodCode string, params map[str } func (a *API) RetailBatchInitData(trackInfo, poiCode string, foodDataList []map[string]interface{}) (failedFoodList []*AppFoodResult, err error) { + globals.SugarLogger.Debugf("=============result := %d", len(foodDataList)) result, err := a.AccessAPI2("retail/batchinitdata", false, map[string]interface{}{ KeyAppPoiCode: poiCode, "food_data": string(utils.MustMarshal(foodDataList)), }, resultKeyMsg, trackInfo) + globals.SugarLogger.Debugf("=============result := %s", utils.Format4Output(result, false)) + globals.SugarLogger.Debugf("=============err := %v", err) + if err == nil { failedFoodList, err = handleRetailBatchResult(result) } diff --git a/platformapi/tiktok_shop/tiktok_api/store.go b/platformapi/tiktok_shop/tiktok_api/store.go index 69bccf1c..1c8f86b5 100644 --- a/platformapi/tiktok_shop/tiktok_api/store.go +++ b/platformapi/tiktok_shop/tiktok_api/store.go @@ -430,7 +430,6 @@ func (a *API) GetWarehouseByStore(storeID int64) (*warehouse_getWarehouseByStore if err != nil { return nil, err } - globals.SugarLogger.Debugf("GetWarehouseByStore response=%s", utils.Format4Output(response, false)) if response.Code != RequestSuccessCode { globals.SugarLogger.Debugf("GetWarehouseByStore errMsg=%s", response.LogId+","+response.Msg+","+response.SubMsg) return nil, errors.New(response.LogId + response.Msg + "," + response.SubMsg)