This commit is contained in:
richboo111
2023-09-25 15:09:58 +08:00
10 changed files with 130 additions and 127 deletions

View File

@@ -51,7 +51,7 @@ const (
) )
const ( const (
MaxStoreNameLen = 13 // 门店名称最大长度2个英文或数字算一位 MaxStoreNameLen = 100 // 门店名称最大长度2个英文或数字算一位
) )
type CreateShopResult struct { type CreateShopResult struct {
@@ -343,6 +343,7 @@ func (a *API) UpdateStoreInfo4Open2(updateParams *OpStoreParams, modifyCloseStat
if !modifyCloseStatus { if !modifyCloseStatus {
delete(mapData, "closeStatus") delete(mapData, "closeStatus")
} }
delete(mapData, "storeNotice") // 这个限制长度100个汉字老是超长!直接不修改了!
// else { // else {
// jdStoreID, err := a.GetJdStoreID(int(utils.Str2Int64(updateParams.OutSystemID))) // jdStoreID, err := a.GetJdStoreID(int(utils.Str2Int64(updateParams.OutSystemID)))
// if err != nil { // if err != nil {

View File

@@ -40,7 +40,7 @@ const (
resultKeySuccessMsg = "success_msg" resultKeySuccessMsg = "success_msg"
) )
const ( const (
GeneralMaxLimit = 200 // 大多数的API的批处理最大条数 GeneralMaxLimit = 100 // 大多数的API的批处理最大条数
) )
const ( const (

View File

@@ -26,7 +26,7 @@ func init() {
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //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 //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_r36FEse6_ywebQI65FNNWA") //token_n4TwqCntWWuvQwAawzxC0w
cookieStr := ` cookieStr := `
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;

View File

@@ -17,9 +17,20 @@ func TestOrderViewStatus(t *testing.T) {
} }
t.Log(result) 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而不是空01538103149不是特殊值只是一个任意之前的时间这样写可以处理
return utils.DefaultTimeValue
}
return utils.Timestamp2Time(timeStamp)
}
func TestOrderGetOrderDetail(t *testing.T) { func TestOrderGetOrderDetail(t *testing.T) {
result, err := api.OrderGetOrderDetail(1100692033635137950, false) result, err := api.OrderGetOrderDetail(1000732590328335860, false)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -24,7 +24,7 @@ func TestPoiGetIDs(t *testing.T) {
} }
func TestPoiMGet(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)) t.Log(utils.Format4Output(result, false))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View File

@@ -1,12 +1,10 @@
package mtwmapi package mtwmapi
import ( import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"regexp" "regexp"
"strings" "strings"
"time"
"git.rosy.net.cn/baseapi/utils"
) )
const ( const (
@@ -125,6 +123,7 @@ type AppFood struct {
Unit string `json:"unit"` Unit string `json:"unit"`
Utime int `json:"utime"` Utime int `json:"utime"`
ZhName string `json:"zh_name"` ZhName string `json:"zh_name"`
CommonAttrValue string `json:"common_attr_value"`
} }
type AppFoodResult struct { type AppFoodResult struct {
@@ -187,9 +186,8 @@ func (a *API) RetailCatUpdate(poiCode, catName string, updateParams *Param4Updat
params := utils.Struct2MapByJson(updateParams) params := utils.Struct2MapByJson(updateParams)
params[KeyAppPoiCode] = poiCode params[KeyAppPoiCode] = poiCode
params["category_name"] = catName params["category_name"] = catName
time.Sleep(200 * time.Millisecond)
_, err = a.AccessAPI("retailCat/update", false, params) _, err = a.AccessAPI("retailCat/update", false, params)
return err return err
} }
@@ -242,19 +240,16 @@ func (a *API) RetailList(poiCode string, offset, limit int) (foodList []*AppFood
return foodList, err return foodList, err
} }
func (a *API) RetailListAll(poiCode string) (foodList []*AppFood, err error) { func (a *API) RetailListAll(poiCode string, offset int) (foodList []*AppFood, err error) {
offset := 0 data := make([]*AppFood, 0, 0)
for { offset = offset * GeneralMaxLimit
batchList, err2 := a.RetailList(poiCode, 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 { if err = err2; err == nil {
foodList = append(foodList, batchList...) data = append(data, batchList...)
} }
if len(batchList) < GeneralMaxLimit { return data, err
break
}
offset += GeneralMaxLimit
}
return foodList, err
} }
func handleRetailBatchResult(result interface{}) (failedFoodList []*AppFoodResult, err error) { 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) { 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{}{ result, err := a.AccessAPI2("retail/batchinitdata", false, map[string]interface{}{
KeyAppPoiCode: poiCode, KeyAppPoiCode: poiCode,
"food_data": string(utils.MustMarshal(foodDataList)), "food_data": string(utils.MustMarshal(foodDataList)),
@@ -303,6 +299,9 @@ func (a *API) RetailBatchInitData(trackInfo, poiCode string, foodDataList []map[
if err == nil { if err == nil {
failedFoodList, err = handleRetailBatchResult(result) 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 return failedFoodList, err
} }

View File

@@ -3,21 +3,20 @@ package mtwmapi
import ( import (
"errors" "errors"
"fmt" "fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"strings" "strings"
"testing" "testing"
"time"
"git.rosy.net.cn/baseapi/utils"
) )
// 测试添加分类 // 测试添加分类
func TestRetailCatUpdate(t *testing.T) { func TestRetailCatUpdate(t *testing.T) {
err := api.RetailCatUpdate("17250949", "火腿罐头", &Param4UpdateCat{ err := api.RetailCatUpdate("19120530", "海鲜火锅丸", &Param4UpdateCat{
CategoryNameOrigin: "", CategoryNameOrigin: "海鲜火锅丸",
CategoryCodeOrigin: "", CategoryCodeOrigin: "",
CategoryCode: "", CategoryCode: "",
Sequence: 0, SecondaryCategoryName: "火锅丸",
Sequence: 1,
}) })
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@@ -26,7 +25,7 @@ func TestRetailCatUpdate(t *testing.T) {
// 测试获取门店分类列表 // 测试获取门店分类列表
func TestRetailCatList(t *testing.T) { func TestRetailCatList(t *testing.T) {
result, err := api.RetailCatList("12663480") result, err := api.RetailCatList("18900165")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -94,8 +93,7 @@ func TestRetailCatDelete(t *testing.T) {
} }
func TestRetailList(t *testing.T) { func TestRetailList(t *testing.T) {
result, err := api.RetailList("8967897"+ result, err := api.RetailList("18900165", 2100, 100)
"", 0, 20)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -106,31 +104,6 @@ func TestRetailList(t *testing.T) {
t.Log(len(result)) 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) { func TestRetailGet(t *testing.T) {
result, err := api.RetailGet("18048546", "305011012") result, err := api.RetailGet("18048546", "305011012")
if err != nil { if err != nil {
@@ -202,52 +175,33 @@ func TestErrList(t *testing.T) {
} }
func TestRetailBatchInitData(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{}{ map[string]interface{}{
"app_food_code": "23841", "app_food_code": 1692848899,
"box_num": 0, "category_name": "调味用品",
"box_price": 0, "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}]",
"category_name": "南北干货",
"description": "", "description": "",
"is_sold_out": 0, "is_sold_out": 0,
"min_order_count": 1, "min_order_count": 1,
"name": "干腐竹约150g/", "name": "吉香居 麻辣萝卜干泡菜 52g/",
"picture": "http://image.jxc4.com/5f7fba025fc9348796039423c48ac3f5.jpg", "picture": "http://p0.meituan.net/retailsp/f2aec3c090c7ee952f61301848f27c09917081.jpg,http://p0.meituan.net/retailsp/c93074d623f04272b28d7b03fd2b8699852829.jpg,http://p0.meituan.net/retailsp/8d2ef2c6f92b7c48f3673a67fe420fbe111196.jpg",
"price": 1000, "picture_contents": "",
"skus": []map[string]interface{}{ "price": 4.5,
map[string]interface{}{ "sequence": -117,
"price": 1000, "skus": ` [
"sku_id": "23841", {
"spec": "150g", "ladder_box_num": "",
"stock": "*", "ladder_box_price": "0.0",
"upc": "", "price": "4.5",
}, "sku_id": 1692848899,
}, "spec": "52g*1袋",
// "tag_id": "200000380", "stock": "9999",
"unit": "份", "upc": "6926896703303",
}, "weight": "52"
map[string]interface{}{ }
"app_food_code": "23840", ]`,
"box_num": 0, "tag_id": 200005035,
"box_price": 0, "unit": "",
"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": "份",
}, },
}) })
if err != nil { if err != nil {

View File

@@ -1,6 +1,7 @@
package tao_vegetable package tao_vegetable
import ( import (
"fmt"
domain2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/domain" domain2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/domain"
request2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/request" request2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/request"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
@@ -34,3 +35,7 @@ func TestDiseAgreeCancel(t *testing.T) {
err := apiTao.DisAgreeUserCancel(param) err := apiTao.DisAgreeUserCancel(param)
globals.SugarLogger.Debugf("err := %v", err) globals.SugarLogger.Debugf("err := %v", err)
} }
func TestLen(t *testing.T) {
fmt.Println(len("【平台推荐】\\u0026【官方认证】\\u0026【品质联盟】——请各位顾客放心下单本店线下实体经营十余年在此承诺坏菜包赔绝不出售隔夜菜若出现错送或者质量问题请相信我们不是故意的您可第一时间与我们联系我们一定竭诚为您服务感谢您的信任谢谢"))
}

View File

@@ -241,8 +241,11 @@ func (a *API) QueryBillList(req *request591.AlibabaWdkBillListRequest) (*domain5
globals.SugarLogger.Debugf("进入 QueryBillList : %s", utils.Format4Output(req, false)) globals.SugarLogger.Debugf("进入 QueryBillList : %s", utils.Format4Output(req, false))
client := ability591.NewAbility591(&a.client) 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 { if !*data.ApiResult.Success {
globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(data, false)) globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(data, false))
return nil, fmt.Errorf(*data.ApiResult.ErrMsg) return nil, fmt.Errorf(*data.ApiResult.ErrMsg)

View File

@@ -2,6 +2,7 @@ package tao_vegetable
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
domain3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/domain" domain3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/domain"
request3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/request" 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" 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/platformapi/tao_vegetable/sdk/util"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"strconv" "strconv"
"strings"
"testing" "testing"
"time" "time"
) )
@@ -227,34 +228,63 @@ func TestDeliveryTrajectory(t *testing.T) {
func TestQueryBillList(t *testing.T) { func TestQueryBillList(t *testing.T) {
queryData := time.Now() 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()) 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{ param := &request591.AlibabaWdkBillListRequest{
TxdBillListGetRequest: &domain591.AlibabaWdkBillListTxdBillListGetRequest{ TxdBillListGetRequest: &domain591.AlibabaWdkBillListTxdBillListGetRequest{
EndBillDate: &endTime, EndBillDate: &endBillDate,
StartBillDate: &createTime, StartBillDate: &startBillDate,
ShopCode: utils.String2Pointer("JX667321"), ShopCode: utils.String2Pointer(vendorStoreID),
PageSize: utils.Int64ToPointer(200), PageSize: utils.Int64ToPointer(int64(pageSize)),
PageIndex: utils.Int64ToPointer(1), PageIndex: utils.Int64ToPointer(int64(pageIndex)),
}, },
} }
data, err := apiTao.QueryBillList(param) var totalIndex int64 = 0
if err != nil { result, _ := api.QueryBillList(param)
fmt.Println("err === ", err) for _, v := range *result.TxdBillDetailBOS {
return 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) { for i := 2; i <= int(totalIndex); i++ {
emoji := `【右上角关注点亮⭐️】` param.TxdBillListGetRequest.PageIndex = utils.Int64ToPointer(int64(i))
a := replaceContentOther(emoji) result2, _ := api.QueryBillList(param)
fmt.Println(a) for _, v := range *result2.TxdBillDetailBOS {
} if *v.OrderType == "positive" {
func replaceContentOther(content string) string { settlement[*v.BizOrderId] = *v.ReceivableAmount
return strings.ReplaceAll(strings.ReplaceAll(content, "⃣️", " "), "•", "-") }
}
}
}
return settlement, nil
} }