Merge branch 'master' of https://e.coding.net/rosydev/baseapi
This commit is contained in:
@@ -51,7 +51,7 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
MaxStoreNameLen = 13 // 门店名称最大长度(2个英文或数字算一位)
|
||||
MaxStoreNameLen = 100 // 门店名称最大长度(2个英文或数字算一位)
|
||||
)
|
||||
|
||||
type CreateShopResult struct {
|
||||
@@ -343,6 +343,7 @@ func (a *API) UpdateStoreInfo4Open2(updateParams *OpStoreParams, modifyCloseStat
|
||||
if !modifyCloseStatus {
|
||||
delete(mapData, "closeStatus")
|
||||
}
|
||||
delete(mapData, "storeNotice") // 这个限制长度100个汉字老是超长!直接不修改了!
|
||||
// else {
|
||||
// jdStoreID, err := a.GetJdStoreID(int(utils.Str2Int64(updateParams.OutSystemID)))
|
||||
// if err != nil {
|
||||
|
||||
@@ -40,7 +40,7 @@ const (
|
||||
resultKeySuccessMsg = "success_msg"
|
||||
)
|
||||
const (
|
||||
GeneralMaxLimit = 200 // 大多数的API的批处理最大条数
|
||||
GeneralMaxLimit = 100 // 大多数的API的批处理最大条数
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -26,7 +26,7 @@ func init() {
|
||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_izAHEkoEl4lV-w4JdJFNww") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_nngsVP37s-HXY86xe85H7Q") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_r36FEse6_ywebQI65FNNWA") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
cookieStr := `
|
||||
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||
|
||||
@@ -17,9 +17,20 @@ func TestOrderViewStatus(t *testing.T) {
|
||||
}
|
||||
t.Log(result)
|
||||
}
|
||||
func TestTimne(t *testing.T) {
|
||||
|
||||
fmt.Println(utils.Interface2Int64WithDefault(1695292241, 0))
|
||||
fmt.Println(getTimeFromTimestamp(utils.Interface2Int64WithDefault(1695292241, 0)))
|
||||
}
|
||||
func getTimeFromTimestamp(timeStamp int64) time.Time {
|
||||
if timeStamp < 1538103149 { // 立即达订单给的是1(而不是空,0),1538103149不是特殊值,只是一个任意之前的时间,这样写可以处理
|
||||
return utils.DefaultTimeValue
|
||||
}
|
||||
return utils.Timestamp2Time(timeStamp)
|
||||
}
|
||||
|
||||
func TestOrderGetOrderDetail(t *testing.T) {
|
||||
result, err := api.OrderGetOrderDetail(1100692033635137950, false)
|
||||
result, err := api.OrderGetOrderDetail(1000732590328335860, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestPoiGetIDs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPoiMGet(t *testing.T) {
|
||||
result, err := api.PoiMGet([]string{"18822904"})
|
||||
result, err := api.PoiMGet([]string{"18172253"})
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -125,6 +123,7 @@ type AppFood struct {
|
||||
Unit string `json:"unit"`
|
||||
Utime int `json:"utime"`
|
||||
ZhName string `json:"zh_name"`
|
||||
CommonAttrValue string `json:"common_attr_value"`
|
||||
}
|
||||
|
||||
type AppFoodResult struct {
|
||||
@@ -187,9 +186,8 @@ func (a *API) RetailCatUpdate(poiCode, catName string, updateParams *Param4Updat
|
||||
params := utils.Struct2MapByJson(updateParams)
|
||||
params[KeyAppPoiCode] = poiCode
|
||||
params["category_name"] = catName
|
||||
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
_, err = a.AccessAPI("retailCat/update", false, params)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -242,19 +240,16 @@ func (a *API) RetailList(poiCode string, offset, limit int) (foodList []*AppFood
|
||||
return foodList, err
|
||||
}
|
||||
|
||||
func (a *API) RetailListAll(poiCode string) (foodList []*AppFood, err error) {
|
||||
offset := 0
|
||||
for {
|
||||
batchList, err2 := a.RetailList(poiCode, offset, GeneralMaxLimit)
|
||||
if err = err2; err == nil {
|
||||
foodList = append(foodList, batchList...)
|
||||
}
|
||||
if len(batchList) < GeneralMaxLimit {
|
||||
break
|
||||
}
|
||||
offset += GeneralMaxLimit
|
||||
func (a *API) RetailListAll(poiCode string, offset int) (foodList []*AppFood, err error) {
|
||||
data := make([]*AppFood, 0, 0)
|
||||
offset = offset * GeneralMaxLimit
|
||||
batchList, err2 := a.RetailList(poiCode, offset, GeneralMaxLimit) // GeneralMaxLimit
|
||||
globals.SugarLogger.Debugf("==========batchList %d", len(batchList))
|
||||
globals.SugarLogger.Debugf("==========batchList %s", utils.Format4Output(err2, false))
|
||||
if err = err2; err == nil {
|
||||
data = append(data, batchList...)
|
||||
}
|
||||
return foodList, err
|
||||
return data, err
|
||||
}
|
||||
|
||||
func handleRetailBatchResult(result interface{}) (failedFoodList []*AppFoodResult, err error) {
|
||||
@@ -296,6 +291,7 @@ 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("foodDataList :%s", utils.Format4Output(foodDataList, false))
|
||||
result, err := a.AccessAPI2("retail/batchinitdata", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"food_data": string(utils.MustMarshal(foodDataList)),
|
||||
@@ -303,6 +299,9 @@ func (a *API) RetailBatchInitData(trackInfo, poiCode string, foodDataList []map[
|
||||
if err == nil {
|
||||
failedFoodList, err = handleRetailBatchResult(result)
|
||||
}
|
||||
globals.SugarLogger.Debugf("result :%s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("err :%s", utils.Format4Output(err, false))
|
||||
|
||||
return failedFoodList, err
|
||||
}
|
||||
|
||||
|
||||
@@ -3,21 +3,20 @@ package mtwmapi
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
// 测试添加分类
|
||||
func TestRetailCatUpdate(t *testing.T) {
|
||||
err := api.RetailCatUpdate("17250949", "火腿罐头", &Param4UpdateCat{
|
||||
CategoryNameOrigin: "",
|
||||
CategoryCodeOrigin: "",
|
||||
CategoryCode: "",
|
||||
Sequence: 0,
|
||||
err := api.RetailCatUpdate("19120530", "海鲜火锅丸", &Param4UpdateCat{
|
||||
CategoryNameOrigin: "海鲜火锅丸",
|
||||
CategoryCodeOrigin: "",
|
||||
CategoryCode: "",
|
||||
SecondaryCategoryName: "火锅丸",
|
||||
Sequence: 1,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -26,7 +25,7 @@ func TestRetailCatUpdate(t *testing.T) {
|
||||
|
||||
// 测试获取门店分类列表
|
||||
func TestRetailCatList(t *testing.T) {
|
||||
result, err := api.RetailCatList("12663480")
|
||||
result, err := api.RetailCatList("18900165")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -94,8 +93,7 @@ func TestRetailCatDelete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailList(t *testing.T) {
|
||||
result, err := api.RetailList("8967897"+
|
||||
"", 0, 20)
|
||||
result, err := api.RetailList("18900165", 2100, 100)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -106,31 +104,6 @@ func TestRetailList(t *testing.T) {
|
||||
t.Log(len(result))
|
||||
}
|
||||
|
||||
func TestRetailListAll(t *testing.T) {
|
||||
result, err := api.RetailListAll("8967897")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(result) == 0 {
|
||||
t.Fatal("should have items")
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
t.Log(len(result))
|
||||
}
|
||||
|
||||
// 删除所有门店商品
|
||||
func TestReloadStoreSku(t *testing.T) {
|
||||
result, err := api.RetailListAll("17924337")
|
||||
if err == nil {
|
||||
for i := 0; i < len(result); i++ {
|
||||
err := api.RetailDelete(utils.Int64ToStr(time.Now().Unix()), "17924337", result[i].AppFoodCode)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetailGet(t *testing.T) {
|
||||
result, err := api.RetailGet("18048546", "305011012")
|
||||
if err != nil {
|
||||
@@ -202,52 +175,33 @@ func TestErrList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailBatchInitData(t *testing.T) {
|
||||
failedFoods, err := api.RetailBatchInitData(utils.GetUUID(), testPoiCode, []map[string]interface{}{
|
||||
failedFoods, err := api.RetailBatchInitData(utils.GetUUID(), "19120530", []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"app_food_code": "23841",
|
||||
"box_num": 0,
|
||||
"box_price": 0,
|
||||
"category_name": "南北干货",
|
||||
"description": "",
|
||||
"is_sold_out": 0,
|
||||
"min_order_count": 1,
|
||||
"name": "干腐竹约150g/份",
|
||||
"picture": "http://image.jxc4.com/5f7fba025fc9348796039423c48ac3f5.jpg",
|
||||
"price": 1000,
|
||||
"skus": []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"price": 1000,
|
||||
"sku_id": "23841",
|
||||
"spec": "150g",
|
||||
"stock": "*",
|
||||
"upc": "",
|
||||
},
|
||||
},
|
||||
// "tag_id": "200000380",
|
||||
"unit": "份",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"app_food_code": "23840",
|
||||
"box_num": 0,
|
||||
"box_price": 0,
|
||||
"category_name": "南北干货",
|
||||
"description": "",
|
||||
"is_sold_out": 0,
|
||||
"min_order_count": 1,
|
||||
"name": "干腐竹约150g/份",
|
||||
"picture": "http://image.jxc4.com/5f7fba025fc9348796039423c48ac3f5.jpg",
|
||||
"price": 1000,
|
||||
"skus": []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"price": 1000,
|
||||
"sku_id": "23840",
|
||||
"spec": "150g",
|
||||
"stock": "*",
|
||||
"upc": "",
|
||||
},
|
||||
},
|
||||
"tag_id": "200000380",
|
||||
"unit": "份",
|
||||
"app_food_code": 1692848899,
|
||||
"category_name": "调味用品",
|
||||
"common_attr_value": "[{\"attrId\":1200000094,\"attrName\":\"产地\",\"setAttrId\":true,\"setAttrName\":true,\"setValueList\":true,\"valueList\":[{\"setValue\":true,\"setValueId\":true,\"value\":\"中国\",\"valueId\":100000050}],\"valueListIterator\":[{\"$ref\":\"$[0].valueList[0]\"}],\"valueListSize\":1},{\"attrId\":1200000135,\"attrName\":\"包装方式\",\"setAttrId\":true,\"setAttrName\":true,\"setValueList\":true,\"valueList\":[{\"setValue\":true,\"setValueId\":true,\"value\":\"袋\",\"valueId\":1300004918}],\"valueListIterator\":[{\"$ref\":\"$[1].valueList[0]\"}],\"valueListSize\":1},{\"attrId\":1200000088,\"attrName\":\"品牌\",\"setAttrId\":true,\"setAttrName\":true,\"setValueList\":true,\"valueList\":[{\"setValue\":true,\"setValueId\":true,\"value\":\"吉香居\",\"valueId\":1008695}],\"valueListIterator\":[{\"$ref\":\"$[2].valueList[0]\"}],\"valueListSize\":1}]",
|
||||
"description": "",
|
||||
"is_sold_out": 0,
|
||||
"min_order_count": 1,
|
||||
"name": "吉香居 麻辣萝卜干泡菜 52g/袋",
|
||||
"picture": "http://p0.meituan.net/retailsp/f2aec3c090c7ee952f61301848f27c09917081.jpg,http://p0.meituan.net/retailsp/c93074d623f04272b28d7b03fd2b8699852829.jpg,http://p0.meituan.net/retailsp/8d2ef2c6f92b7c48f3673a67fe420fbe111196.jpg",
|
||||
"picture_contents": "",
|
||||
"price": 4.5,
|
||||
"sequence": -117,
|
||||
"skus": ` [
|
||||
{
|
||||
"ladder_box_num": "",
|
||||
"ladder_box_price": "0.0",
|
||||
"price": "4.5",
|
||||
"sku_id": 1692848899,
|
||||
"spec": "52g*1袋",
|
||||
"stock": "9999",
|
||||
"upc": "6926896703303",
|
||||
"weight": "52"
|
||||
}
|
||||
]`,
|
||||
"tag_id": 200005035,
|
||||
"unit": "",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tao_vegetable
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
domain2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/domain"
|
||||
request2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/request"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -34,3 +35,7 @@ func TestDiseAgreeCancel(t *testing.T) {
|
||||
err := apiTao.DisAgreeUserCancel(param)
|
||||
globals.SugarLogger.Debugf("err := %v", err)
|
||||
}
|
||||
|
||||
func TestLen(t *testing.T) {
|
||||
fmt.Println(len("【平台推荐】\\u0026【官方认证】\\u0026【品质联盟】——请各位顾客放心下单!!!本店线下实体经营十余年,在此承诺,坏菜包赔,绝不出售隔夜菜,若出现错送或者质量问题,请相信我们不是故意的,您可第一时间与我们联系,我们一定竭诚为您服务,感谢您的信任!谢谢!"))
|
||||
}
|
||||
|
||||
@@ -241,8 +241,11 @@ func (a *API) QueryBillList(req *request591.AlibabaWdkBillListRequest) (*domain5
|
||||
globals.SugarLogger.Debugf("进入 QueryBillList : %s", utils.Format4Output(req, false))
|
||||
client := ability591.NewAbility591(&a.client)
|
||||
|
||||
data, _ := client.AlibabaWdkBillList(req, a.token)
|
||||
|
||||
data, err := client.AlibabaWdkBillList(req, a.token)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(err, false))
|
||||
return nil, err
|
||||
}
|
||||
if !*data.ApiResult.Success {
|
||||
globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(data, false))
|
||||
return nil, fmt.Errorf(*data.ApiResult.ErrMsg)
|
||||
|
||||
@@ -2,6 +2,7 @@ package tao_vegetable
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
domain3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/domain"
|
||||
request3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/request"
|
||||
@@ -9,9 +10,9 @@ import (
|
||||
request591 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability591/request"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/util"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -227,34 +228,63 @@ func TestDeliveryTrajectory(t *testing.T) {
|
||||
|
||||
func TestQueryBillList(t *testing.T) {
|
||||
queryData := time.Now()
|
||||
create := time.Date(queryData.Year(), queryData.Month(), queryData.Day()-7, 0, 0, 0, 0, queryData.Location())
|
||||
create := time.Date(queryData.Year(), queryData.Month(), queryData.Day()-90, 0, 0, 0, 0, queryData.Location())
|
||||
end := time.Date(queryData.Year(), queryData.Month(), queryData.Day(), 23, 59, 59, 59, queryData.Location())
|
||||
createTime := util.LocalTime(create)
|
||||
endTime := util.LocalTime(end)
|
||||
|
||||
data, err := GetOrderTotalShopMoney("", "JX100002", create, end)
|
||||
|
||||
globals.SugarLogger.Debugf("data:= %s", utils.Format4Output(data, false))
|
||||
globals.SugarLogger.Debugf("data:= %s", utils.Format4Output(err, false))
|
||||
}
|
||||
|
||||
// GetOrderTotalShopMoney 获取门店结算信息
|
||||
func GetOrderTotalShopMoney(appOrgCode string, vendorStoreID string, start, end time.Time) (map[string]string, error) {
|
||||
if start.IsZero() || end.IsZero() {
|
||||
return nil, errors.New("开始时间和结束时间不能为空")
|
||||
}
|
||||
|
||||
settlement := make(map[string]string, 0)
|
||||
|
||||
api := apiTao
|
||||
startBillDate := util.LocalTime(start)
|
||||
endBillDate := util.LocalTime(end)
|
||||
pageSize := 200
|
||||
pageIndex := 1
|
||||
|
||||
param := &request591.AlibabaWdkBillListRequest{
|
||||
TxdBillListGetRequest: &domain591.AlibabaWdkBillListTxdBillListGetRequest{
|
||||
EndBillDate: &endTime,
|
||||
StartBillDate: &createTime,
|
||||
ShopCode: utils.String2Pointer("JX667321"),
|
||||
PageSize: utils.Int64ToPointer(200),
|
||||
PageIndex: utils.Int64ToPointer(1),
|
||||
EndBillDate: &endBillDate,
|
||||
StartBillDate: &startBillDate,
|
||||
ShopCode: utils.String2Pointer(vendorStoreID),
|
||||
PageSize: utils.Int64ToPointer(int64(pageSize)),
|
||||
PageIndex: utils.Int64ToPointer(int64(pageIndex)),
|
||||
},
|
||||
}
|
||||
|
||||
data, err := apiTao.QueryBillList(param)
|
||||
if err != nil {
|
||||
fmt.Println("err === ", err)
|
||||
return
|
||||
var totalIndex int64 = 0
|
||||
result, _ := api.QueryBillList(param)
|
||||
for _, v := range *result.TxdBillDetailBOS {
|
||||
if *v.OrderType == "positive" {
|
||||
settlement[*v.BizOrderId] = *v.ReceivableAmount
|
||||
}
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("data:= %s", utils.Format4Output(data, false))
|
||||
}
|
||||
if *result.Total > int64(pageSize) {
|
||||
totalIndex = *result.Total / int64(pageSize)
|
||||
if *result.Total%int64(pageSize) != model.NO {
|
||||
totalIndex += 1
|
||||
}
|
||||
|
||||
func TestName2(t *testing.T) {
|
||||
emoji := `【右上角关注点亮⭐️】`
|
||||
a := replaceContentOther(emoji)
|
||||
fmt.Println(a)
|
||||
}
|
||||
func replaceContentOther(content string) string {
|
||||
return strings.ReplaceAll(strings.ReplaceAll(content, "⃣️", " "), "•", "-")
|
||||
for i := 2; i <= int(totalIndex); i++ {
|
||||
param.TxdBillListGetRequest.PageIndex = utils.Int64ToPointer(int64(i))
|
||||
result2, _ := api.QueryBillList(param)
|
||||
for _, v := range *result2.TxdBillDetailBOS {
|
||||
if *v.OrderType == "positive" {
|
||||
settlement[*v.BizOrderId] = *v.ReceivableAmount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return settlement, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user