- 添加了部分到家订单级促销
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
func TestQueryOassBussMoney(t *testing.T) {
|
||||
bussResult, bussErr := jdapi.QueryOassBussMoney("815536199000222")
|
||||
bussResult, bussErr := api.QueryOassBussMoney("815536199000222")
|
||||
if bussErr != nil {
|
||||
t.Error(bussErr.Error())
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
jdapi *API
|
||||
api *API
|
||||
sugarLogger *zap.SugaredLogger
|
||||
)
|
||||
|
||||
@@ -21,14 +21,14 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// sandbox
|
||||
jdapi = New("df97f334-f7d8-4b36-9664-5784d8ae0baf", "06692746f7224695ad4788ce340bc854", "d6b42a35a7414a5490d811654d745c84")
|
||||
api = New("df97f334-f7d8-4b36-9664-5784d8ae0baf", "06692746f7224695ad4788ce340bc854", "d6b42a35a7414a5490d811654d745c84")
|
||||
// prod
|
||||
// jdapi = New("ccb10daf-e6f5-4a58-ada5-b97f9073a137", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4")
|
||||
|
||||
// 天天果园
|
||||
// jdapi = New("b9f98667-9856-45e9-a31c-9a8862b1bfde", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26")
|
||||
|
||||
jdapi.SetStoreCookie("YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHBUOPCIUXDX4MQEAYEPUFFOAD4WJECT4R3K22T24MKC7OMIRDLX7S55243TDVXLO25PP4UYSPTTPMNRUFXDNP4WPE566Q6V4AH32F7HT")
|
||||
api.SetStoreCookie("YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHBUOPCIUXDX4MQEAYEPUFFOAD4WJECT4R3K22T24MKC7OMIRDLX7S55243TDVXLO25PP4UYSPTTPMNRUFXDNP4WPE566Q6V4AH32F7HT")
|
||||
}
|
||||
|
||||
func TestTest(t *testing.T) {
|
||||
@@ -36,7 +36,7 @@ func TestTest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccessAPI(t *testing.T) {
|
||||
result, err := jdapi.AccessAPI("address/allcities", nil)
|
||||
result, err := api.AccessAPI("address/allcities", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Error when accessing AccessAPI: %v", err)
|
||||
} else {
|
||||
@@ -48,7 +48,7 @@ func TestAccessAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccessAPINoPage(t *testing.T) {
|
||||
result, err := jdapi.AccessAPINoPage("address/allcities", nil, []string{"yn"}, nil, nil)
|
||||
result, err := api.AccessAPINoPage("address/allcities", nil, []string{"yn"}, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("TestAccessAPINoPage return error:%v", err)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func TestAccessAPIHavePage(t *testing.T) {
|
||||
"pageNo": 1,
|
||||
"pageSize": 20,
|
||||
}
|
||||
skuInfo, totalCount, err := jdapi.AccessAPIHavePage("pms/querySkuInfos", jdParams, nil, []string{"skuName", "skuId"}, nil)
|
||||
skuInfo, totalCount, err := api.AccessAPIHavePage("pms/querySkuInfos", jdParams, nil, []string{"skuName", "skuId"}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("AccessAPIHavePage return error:%v", err)
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ import (
|
||||
)
|
||||
|
||||
func TestQuerySingleOrder(t *testing.T) {
|
||||
retVal, err := jdapi.QuerySingleOrder("815536199000222")
|
||||
retVal, err := api.QuerySingleOrder("815536199000222")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if false {
|
||||
t.Log(utils.Format4Output(retVal, false))
|
||||
}
|
||||
retVal, err = jdapi.QuerySingleOrder("999999")
|
||||
retVal, err = api.QuerySingleOrder("999999")
|
||||
if err == nil {
|
||||
t.Error("应该找不到这个订单!")
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func TestOrderQuery(t *testing.T) {
|
||||
jdParams := map[string]interface{}{
|
||||
"orderId": "813344594000041",
|
||||
}
|
||||
result, totalCount, err := jdapi.OrderQuery(jdParams)
|
||||
result, totalCount, err := api.OrderQuery(jdParams)
|
||||
if err != nil {
|
||||
t.Fatalf("OrderQuery return error:%v", err)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func TestOrderQuery(t *testing.T) {
|
||||
|
||||
func TestGetOrderCallbackMsg(t *testing.T) {
|
||||
callbackStr := "timestamp=2018-06-27+12%3A43%3A51&sign=84096ADFAB81E224D6231269AD1F6AAB&v=1.0&jd_param_json=%7B%22billId%22%3A%22815338526000221%22%2C%22statusId%22%3A%2232000%22%2C%22timestamp%22%3A%222018-06-27+12%3A42%3A34%22%7D&token=91633f2a-c5f5-4982-a925-a220d19095c3&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json"
|
||||
result, resp := jdapi.GetOrderCallbackMsg([]byte(callbackStr))
|
||||
result, resp := api.GetOrderCallbackMsg([]byte(callbackStr))
|
||||
|
||||
if resp != nil {
|
||||
t.Fatal(resp)
|
||||
@@ -60,7 +60,7 @@ func TestGetOrderCallbackMsg(t *testing.T) {
|
||||
|
||||
func TestGetOrderDeliveryCallbackMsg(t *testing.T) {
|
||||
callbackStr := "timestamp=2018-06-27%2B09%253A08%253A41&sign=54D9A8515BB5650DC3B81366E3286570&v=1.0&jd_param_json=%257B%2522createPin%2522%253A%2522JD_21134dac1c251d2%2522%252C%2522deliveryCarrierName%2522%253A%2522%25E8%25BE%25BE%25E8%25BE%25BE%25E4%25B8%2593%25E9%2580%2581%2522%252C%2522deliveryCarrierNo%2522%253A%25229966%2522%252C%2522deliveryStatus%2522%253A%252210%2522%252C%2522deliveryStatusTime%2522%253A%25222018-06-27%2B09%253A08%253A41%2522%252C%2522inputTime%2522%253A%25222018-06-27%2B09%253A08%253A41%2522%252C%2522orderId%2522%253A%2522815324888000121%2522%257D&token=91633f2a-c5f5-4982-a925-a220d19095c3&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json"
|
||||
result, resp := jdapi.GetOrderDeliveryCallbackMsg([]byte(callbackStr))
|
||||
result, resp := api.GetOrderDeliveryCallbackMsg([]byte(callbackStr))
|
||||
|
||||
if resp != nil {
|
||||
t.Fatal(resp)
|
||||
@@ -70,7 +70,7 @@ func TestGetOrderDeliveryCallbackMsg(t *testing.T) {
|
||||
|
||||
func TestGetOrderApplyCancelCallbackMsg(t *testing.T) {
|
||||
callbackStr := "timestamp=2018-06-27%2B13%253A35%253A29&sign=F1398D658514D8864FFB56F5EF2C4792&v=1.0&jd_param_json=%257B%2522billId%2522%253A%2522815339944000322%2522%252C%2522remark%2522%253A%2522%25E5%2595%2586%25E5%25AE%25B6%25E7%25BC%25BA%25E8%25B4%25A7%2522%252C%2522statusId%2522%253A%252220030%2522%252C%2522timestamp%2522%253A%25222018-06-27%2B13%253A35%253A24%2522%257D&token=91633f2a-c5f5-4982-a925-a220d19095c3&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json"
|
||||
result, resp := jdapi.GetOrderApplyCancelCallbackMsg([]byte(callbackStr))
|
||||
result, resp := api.GetOrderApplyCancelCallbackMsg([]byte(callbackStr))
|
||||
|
||||
if resp != nil {
|
||||
t.Fatal(resp)
|
||||
@@ -85,15 +85,15 @@ func TestSimulateSendNewOrderMsg(t *testing.T) {
|
||||
Timestamp: utils.GetCurTimeStr(),
|
||||
}
|
||||
params := make(url.Values)
|
||||
params.Set("token", jdapi.token)
|
||||
params.Set("app_key", jdapi.appKey)
|
||||
params.Set("token", api.token)
|
||||
params.Set("app_key", api.appKey)
|
||||
params.Set("timestamp", utils.GetCurTimeStr())
|
||||
params.Set("v", "1.0")
|
||||
params.Set("format", "json")
|
||||
params.Set(paramJson, string(utils.MustMarshal(orderInfo)))
|
||||
|
||||
mapData := utils.URLValues2Map(params)
|
||||
params.Set(signKey, jdapi.signParams(mapData))
|
||||
params.Set(signKey, api.signParams(mapData))
|
||||
|
||||
response, err := http.PostForm("http://callback.test.jxc4.com/djsw/newOrder", params)
|
||||
if err != nil {
|
||||
@@ -156,14 +156,14 @@ func TestCallbackMsgPlayback(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestOrderAcceptOperate(t *testing.T) {
|
||||
err := jdapi.OrderAcceptOperate("813344594000041", true, "")
|
||||
err := api.OrderAcceptOperate("813344594000041", true, "")
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrderJDZBDelivery(t *testing.T) {
|
||||
result, err := jdapi.OrderJDZBDelivery("813344594000041", "")
|
||||
result, err := api.OrderJDZBDelivery("813344594000041", "")
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
@@ -171,7 +171,7 @@ func TestOrderJDZBDelivery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestModifySellerDelivery(t *testing.T) {
|
||||
result, err := jdapi.ModifySellerDelivery("813344594000041", "")
|
||||
result, err := api.ModifySellerDelivery("813344594000041", "")
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func TestModifySellerDelivery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderSerllerDelivery(t *testing.T) {
|
||||
result, err := jdapi.OrderSerllerDelivery("813344594000041", "")
|
||||
result, err := api.OrderSerllerDelivery("813344594000041", "")
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
@@ -187,7 +187,7 @@ func TestOrderSerllerDelivery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeliveryEndOrder(t *testing.T) {
|
||||
result, err := jdapi.DeliveryEndOrder("813344594000041", "")
|
||||
result, err := api.DeliveryEndOrder("813344594000041", "")
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
|
||||
163
platformapi/jdapi/promotion_order.go
Normal file
163
platformapi/jdapi/promotion_order.go
Normal file
@@ -0,0 +1,163 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
OrderDiscountActivityTypeManJian = 1 // 满减
|
||||
OrderDiscountActivityTypeHuanGou = 1202 // 换购
|
||||
OrderDiscountActivityTypeManZeng = 1203 // 满赠
|
||||
OrderDiscountActivityTypeManJianJian = 1206 // 满件减
|
||||
OrderDiscountActivityTypeManJianZhe = 1207 // 满件折
|
||||
OrderDiscountActivityTypeKunBang = 1208 // 捆绑
|
||||
OrderDiscountActivityTypeMeiManJian = 2210 // 每满减
|
||||
|
||||
ParticipationModeAllSku = 1 // 全部商品维度
|
||||
ParticipationModePartSku = 2 // 部分商品维度
|
||||
)
|
||||
|
||||
type OrderDiscountGift struct {
|
||||
SkuID string `json:"skuId"`
|
||||
StockCount int `json:"stockCount"`
|
||||
}
|
||||
|
||||
type OrderDiscountRuleRequest struct {
|
||||
LowerLimitAmount int `json:"lowerLimitAmount"`
|
||||
DiscountAmount int `json:"discountAmount"`
|
||||
UpperLimitCount int `json:"upperLimitCount"`
|
||||
LowerLimitCount int `json:"lowerLimitCount"`
|
||||
DiscountRate int `json:"discountRate"`
|
||||
AddPrice int `json:"addPrice"` // 分
|
||||
GiftList []*OrderDiscountGift `json:"giftList"`
|
||||
LadderLimit int `json:"ladderLimit"`
|
||||
}
|
||||
|
||||
type OrderDiscountActivity struct {
|
||||
OutActivityID string `json:"outActivityId"` // 必须
|
||||
PromName string `json:"promName"` // 必须
|
||||
PromType int `json:"promType"` // 必须
|
||||
BeginTime string `json:"beginTime"` // 必须
|
||||
EndTime string `json:"endTime"` // 必须
|
||||
ParticipationMode int `json:"participationMode"` // 必须
|
||||
OutStationNos []string `json:"outStationNos"`
|
||||
StationNos []string `json:"stationNos"`
|
||||
OutSkuIds []string `json:"outSkuIds"`
|
||||
SkuIds []string `json:"skuIds"`
|
||||
LimitOrderTotalNumber int `json:"limitOrderTotalNumber"` // 必须
|
||||
LimitUserTotalNumber int `json:"limitUserTotalNumber"`
|
||||
Display string `json:"display"` // 必须
|
||||
RuleRequestList []*OrderDiscountRuleRequest `json:"ruleRequestList"`
|
||||
}
|
||||
|
||||
type ActivityOpResultInfo struct {
|
||||
ActivityID int64 `json:"activityID"`
|
||||
PromName string `json:"promName"`
|
||||
StationNo int64 `json:"stationNo"`
|
||||
SkuID int64 `json:"skuID"`
|
||||
OutActivityID string `json:"outActivityId"`
|
||||
OutSkuID string `json:"outSkuId"`
|
||||
OutStationNo string `json:"outStationNo"`
|
||||
}
|
||||
|
||||
type ActivityOpQueryResultResponse struct {
|
||||
SubCode string `json:"subCode"`
|
||||
SubMsg string `json:"subMsg"`
|
||||
ResultList []*ActivityOpResultInfo `json:"resultList"`
|
||||
}
|
||||
|
||||
type ActivityOpQueryInfoResponse struct {
|
||||
ActivityID int64 `json:"activityID"`
|
||||
OutActivityID string `json:"outActivityId"`
|
||||
PromotionName string `json:"promotionName"`
|
||||
BeginDate time.Time `json:"beginDate"`
|
||||
EndDate time.Time `json:"endDate"`
|
||||
Awords string `json:"awords"`
|
||||
State int `json:"state"`
|
||||
OrderLadder string `json:"orderLadder"`
|
||||
StationList []int `json:"stationList"`
|
||||
SkuList []int `json:"skuList"`
|
||||
LadderList []int `json:"ladderList"`
|
||||
}
|
||||
|
||||
var (
|
||||
ignoreOrderDiscountActivity = OrderDiscountActivity{}
|
||||
ignoreOrderDiscountRuleRequest = OrderDiscountRuleRequest{}
|
||||
)
|
||||
|
||||
func (a *API) OrderDiscountSubmitActivity(actInfo *OrderDiscountActivity) (activityID int64, err error) {
|
||||
result, err := a.AccessAPINoPage("orderdiscount/submitActivity", utils.Struct2MapWithIgnore(actInfo, map[string]interface{}{
|
||||
"outStationNos": ignoreOrderDiscountActivity.OutStationNos,
|
||||
"stationNos": ignoreOrderDiscountActivity.StationNos,
|
||||
"outSkuIds": ignoreOrderDiscountActivity.OutSkuIds,
|
||||
"skuIds": ignoreOrderDiscountActivity.SkuIds,
|
||||
"limitUserTotalNumber": ignoreOrderDiscountActivity.LimitUserTotalNumber,
|
||||
"ruleRequestList": ignoreOrderDiscountActivity.RuleRequestList,
|
||||
}), nil, nil, nil)
|
||||
if err == nil {
|
||||
return utils.MustInterface2Int64((result.(map[string]interface{}))["activityId"]), nil
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func (a *API) OrderDiscountQuerySubmitActivityResult(activityID int64) (response *ActivityOpQueryResultResponse, err error) {
|
||||
result, err := a.AccessAPINoPage("orderdiscount/querySubmitActivityResult", map[string]interface{}{
|
||||
"activityId": activityID,
|
||||
"sourceFrom": 3,
|
||||
"operator": "",
|
||||
"traceId": "",
|
||||
"version": "",
|
||||
}, nil, nil, nil)
|
||||
if err == nil {
|
||||
resultMap := result.(map[string]interface{})
|
||||
response = &ActivityOpQueryResultResponse{
|
||||
SubCode: utils.Interface2String(resultMap["subCode"]),
|
||||
SubMsg: utils.Interface2String(resultMap["subMsg"]),
|
||||
}
|
||||
for _, v := range resultMap["resultList"].([]interface{}) {
|
||||
vMap := v.(map[string]interface{})
|
||||
response.ResultList = append(response.ResultList, &ActivityOpResultInfo{
|
||||
ActivityID: utils.MustInterface2Int64(vMap["activityId"]),
|
||||
PromName: utils.Interface2String(vMap["promName"]),
|
||||
StationNo: utils.MustInterface2Int64(vMap["stationNo"]),
|
||||
SkuID: utils.MustInterface2Int64(vMap["skuId"]),
|
||||
OutActivityID: utils.Interface2String(vMap["outActivityId"]),
|
||||
OutSkuID: utils.Interface2String(vMap["outSkuId"]),
|
||||
OutStationNo: utils.Interface2String(vMap["outStationNo"]),
|
||||
})
|
||||
}
|
||||
}
|
||||
return response, err
|
||||
}
|
||||
|
||||
// func (a *API) OrderDiscountQueryActivityInfo(activityID int64) (response *OrderDiscountResultResponse, err error) {
|
||||
// result, err := a.AccessAPINoPage("orderdiscount/queryActivityInfo", map[string]interface{}{
|
||||
// "activityId": activityID,
|
||||
// "sourceFrom": 3,
|
||||
// "operator": "",
|
||||
// "traceId": "",
|
||||
// "version": "",
|
||||
// }, nil, nil, nil)
|
||||
// if err == nil {
|
||||
// resultMap := result.(map[string]interface{})
|
||||
// response = &OrderDiscountResultResponse{
|
||||
// SubCode: utils.Interface2String(resultMap["subCode"]),
|
||||
// SubMsg: utils.Interface2String(resultMap["subMsg"]),
|
||||
// }
|
||||
// for _, v := range resultMap["resultList"].([]interface{}) {
|
||||
// vMap := v.(map[string]interface{})
|
||||
// response.ResultList = append(response.ResultList, &OrderDiscountResultInfo{
|
||||
// ActivityID: utils.MustInterface2Int64(vMap["activityId"]),
|
||||
// PromName: utils.Interface2String(vMap["promName"]),
|
||||
// StationNo: utils.MustInterface2Int64(vMap["stationNo"]),
|
||||
// SkuID: utils.MustInterface2Int64(vMap["skuId"]),
|
||||
// OutActivityId: utils.Interface2String(vMap["outActivityId"]),
|
||||
// OutSkuId: utils.Interface2String(vMap["outSkuId"]),
|
||||
// OutStationNo: utils.Interface2String(vMap["outStationNo"]),
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// return response, err
|
||||
// }
|
||||
21
platformapi/jdapi/promotion_order_test.go
Normal file
21
platformapi/jdapi/promotion_order_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestOrderDiscountSubmitActivity(t *testing.T) {
|
||||
actID, err := api.OrderDiscountSubmitActivity(&OrderDiscountActivity{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(actID)
|
||||
}
|
||||
|
||||
func TestOrderDiscountQuerySubmitActivityResult(t *testing.T) {
|
||||
result, err := api.OrderDiscountQuerySubmitActivityResult(3)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(result)
|
||||
}
|
||||
@@ -50,6 +50,17 @@ type PromotionInfo struct {
|
||||
SkuResultList []*PromotionSkuResult
|
||||
}
|
||||
|
||||
func getPromotionCmd(inCmd string, promotionType int) (outCmd string) {
|
||||
if promotionType == PromotionTypeDirectDown {
|
||||
outCmd = "singlePromote/" + inCmd
|
||||
} else if promotionType == PromotionTypeLimitedTime {
|
||||
outCmd = "limitTime/" + inCmd
|
||||
} else {
|
||||
panic("unknow promotionType!")
|
||||
}
|
||||
return outCmd
|
||||
}
|
||||
|
||||
// 单品直降添加主活动信息接口
|
||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=178&apiid=ee8685c9be9b4aa5bdc41468c5ebc33b
|
||||
func (a *API) CreatePromotionInfosSingle(name string, beginDate, endDate time.Time, outInfoId, advertising string) (infoId int64, err error) {
|
||||
@@ -132,15 +143,7 @@ func (a *API) createPromotionInfos(promotionType int, name string, beginDate, en
|
||||
"timeStamp": utils.GetCurTimeStr(),
|
||||
KeyOutInfoId: outInfoId,
|
||||
}
|
||||
cmd := ""
|
||||
if promotionType == PromotionTypeDirectDown {
|
||||
cmd = "singlePromote/createPromotionInfos"
|
||||
} else if promotionType == PromotionTypeLimitedTime {
|
||||
cmd = "limitTime/createPromotionInfos"
|
||||
} else {
|
||||
panic("unknow promotionType!")
|
||||
}
|
||||
result, err := a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0"))
|
||||
result, err := a.AccessAPINoPage(getPromotionCmd("createPromotionInfos", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0"))
|
||||
if err == nil {
|
||||
return utils.MustInterface2Int64(result), nil
|
||||
}
|
||||
@@ -158,15 +161,7 @@ func (a *API) createPromotionSku(promotionType int, infoId int64, outInfoId stri
|
||||
} else {
|
||||
jdParams[KeyOutInfoId] = outInfoId
|
||||
}
|
||||
cmd := ""
|
||||
if promotionType == PromotionTypeDirectDown {
|
||||
cmd = "singlePromote/createPromotionSku"
|
||||
} else if promotionType == PromotionTypeLimitedTime {
|
||||
cmd = "limitTime/createPromotionSku"
|
||||
} else {
|
||||
panic("unknow promotionType!")
|
||||
}
|
||||
_, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "data", "", "0"))
|
||||
_, err = a.AccessAPINoPage(getPromotionCmd("createPromotionSku", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "data", "", "0"))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -179,15 +174,7 @@ func (a *API) confirmPromotion(promotionType int, infoId int64, outInfoId string
|
||||
} else {
|
||||
jdParams[KeyOutInfoId] = outInfoId
|
||||
}
|
||||
cmd := ""
|
||||
if promotionType == PromotionTypeDirectDown {
|
||||
cmd = "singlePromote/confirmPromotion"
|
||||
} else if promotionType == PromotionTypeLimitedTime {
|
||||
cmd = "limitTime/confirmPromotion"
|
||||
} else {
|
||||
panic("unknow promotionType!")
|
||||
}
|
||||
_, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0"))
|
||||
_, err = a.AccessAPINoPage(getPromotionCmd("confirmPromotion", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0"))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -200,15 +187,7 @@ func (a *API) cancelPromotion(promotionType int, infoId int64, outInfoId string)
|
||||
} else {
|
||||
jdParams[KeyOutInfoId] = outInfoId
|
||||
}
|
||||
cmd := ""
|
||||
if promotionType == PromotionTypeDirectDown {
|
||||
cmd = "singlePromote/cancelPromotion"
|
||||
} else if promotionType == PromotionTypeLimitedTime {
|
||||
cmd = "limitTime/cancelPromotion"
|
||||
} else {
|
||||
panic("unknow promotionType!")
|
||||
}
|
||||
_, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0"))
|
||||
_, err = a.AccessAPINoPage(getPromotionCmd("cancelPromotion", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0"))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import (
|
||||
)
|
||||
|
||||
func TestCreatePromotionSingle(t *testing.T) {
|
||||
infoId, err := jdapi.CreatePromotionInfosSingle("测试1", time.Now(), time.Now().Add(24*time.Hour), "", "")
|
||||
infoId, err := api.CreatePromotionInfosSingle("测试1", time.Now(), time.Now().Add(24*time.Hour), "", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(infoId)
|
||||
err = jdapi.CreatePromotionRules(infoId, "", 1, 1, 1, 1)
|
||||
err = api.CreatePromotionRules(infoId, "", 1, 1, 1, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
skuInfos, err := jdapi.CreatePromotionSkuSingle(infoId, "", []map[string]interface{}{
|
||||
skuInfos, err := api.CreatePromotionSkuSingle(infoId, "", []map[string]interface{}{
|
||||
{
|
||||
KeyOutSkuId: "2216",
|
||||
KeyStationNo: 11682042,
|
||||
@@ -27,23 +27,23 @@ func TestCreatePromotionSingle(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(skuInfos)
|
||||
err = jdapi.ConfirmPromotionSingle(infoId, "")
|
||||
err = api.ConfirmPromotionSingle(infoId, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePromotionLimitTime(t *testing.T) {
|
||||
infoId, err := jdapi.CreatePromotionInfosLimitTime("测试1", time.Now(), time.Now().Add(24*time.Hour), "", "")
|
||||
infoId, err := api.CreatePromotionInfosLimitTime("测试1", time.Now(), time.Now().Add(24*time.Hour), "", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(infoId)
|
||||
err = jdapi.CreatePromotionRules(infoId, "", 1, 1, 5, 1)
|
||||
err = api.CreatePromotionRules(infoId, "", 1, 1, 5, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
skuInfos, err := jdapi.CreatePromotionSkuLimitTime(infoId, "", []map[string]interface{}{
|
||||
skuInfos, err := api.CreatePromotionSkuLimitTime(infoId, "", []map[string]interface{}{
|
||||
{
|
||||
KeyOutSkuId: "2216",
|
||||
KeyStationNo: 11682042,
|
||||
@@ -55,14 +55,14 @@ func TestCreatePromotionLimitTime(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(skuInfos)
|
||||
err = jdapi.ConfirmPromotionLimitTime(infoId, "")
|
||||
err = api.ConfirmPromotionLimitTime(infoId, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueryPromotionInfo(t *testing.T) {
|
||||
result, err := jdapi.QueryPromotionInfo(14885272)
|
||||
result, err := api.QueryPromotionInfo(14885272)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestQueryPageBrandInfo(t *testing.T) {
|
||||
result, _, err := jdapi.QueryPageBrandInfo(0, 0, 0, "")
|
||||
result, _, err := api.QueryPageBrandInfo(0, 0, 0, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -19,7 +19,7 @@ func TestQueryPageBrandInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryCategoriesByOrgCode(t *testing.T) {
|
||||
result, err := jdapi.QueryCategoriesByOrgCode()
|
||||
result, err := api.QueryCategoriesByOrgCode()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -29,7 +29,7 @@ func TestQueryCategoriesByOrgCode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryChildCategoriesForOP(t *testing.T) {
|
||||
result, err := jdapi.QueryChildCategoriesForOP(0)
|
||||
result, err := api.QueryChildCategoriesForOP(0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func TestBatchUpdateOutSkuId(t *testing.T) {
|
||||
|
||||
func TestQuerySkuInfos(t *testing.T) {
|
||||
pageSize := 20
|
||||
result, totalCount, err := jdapi.QuerySkuInfos("", 0, 0, pageSize, true)
|
||||
result, totalCount, err := api.QuerySkuInfos("", 0, 0, pageSize, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func TestQueryListBySkuIds(t *testing.T) {
|
||||
2018806493,
|
||||
2018805873,
|
||||
}
|
||||
result, err := jdapi.QueryListBySkuIds(ids, nil)
|
||||
result, err := api.QueryListBySkuIds(ids, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func TestQueryListBySkuIds(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryKeyWordDicInfo(t *testing.T) {
|
||||
result, totalCount, err := jdapi.QueryKeyWordDicInfo(0, 0, "")
|
||||
result, totalCount, err := api.QueryKeyWordDicInfo(0, 0, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -95,46 +95,46 @@ func TestQueryKeyWordDicInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSyncProduct(t *testing.T) {
|
||||
result, err := jdapi.SyncProduct("11732425", "2015717812")
|
||||
result, err := api.SyncProduct("11732425", "2015717812")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(result)
|
||||
result, err = jdapi.SyncProduct("wrongstoreid", "2015717812")
|
||||
result, err = api.SyncProduct("wrongstoreid", "2015717812")
|
||||
if err == nil {
|
||||
t.Fatal("SyncProduct should return error")
|
||||
}
|
||||
result, err = jdapi.SyncProduct("11732425", "wrongskuid")
|
||||
result, err = api.SyncProduct("11732425", "wrongskuid")
|
||||
if err == nil {
|
||||
t.Fatal("SyncProduct should return error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetProductStatust(t *testing.T) {
|
||||
result, err := jdapi.GetProductStatus("11732425", "2015717812")
|
||||
result, err := api.GetProductStatus("11732425", "2015717812")
|
||||
if err != nil || result == nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// baseapi.SugarLogger.Debug(result)
|
||||
result, err = jdapi.GetProductStatus("wrongstoreid", "2015717812")
|
||||
result, err = api.GetProductStatus("wrongstoreid", "2015717812")
|
||||
if err == nil {
|
||||
t.Fatal("GetProductStatus should return error")
|
||||
}
|
||||
result, err = jdapi.GetProductStatus("11732425", "wrongskuid")
|
||||
result, err = api.GetProductStatus("11732425", "wrongskuid")
|
||||
if err == nil {
|
||||
t.Fatal("GetProductStatus should return error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDelShopCategory(t *testing.T) {
|
||||
err := jdapi.DelShopCategory(4784689)
|
||||
err := api.DelShopCategory(4784689)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSkuSaleAttrName(t *testing.T) {
|
||||
result, err := jdapi.GetSkuSaleAttrName()
|
||||
result, err := api.GetSkuSaleAttrName()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func TestGetSkuSaleAttrName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSpuSaleAttr(t *testing.T) {
|
||||
result, err := jdapi.GetSpuSaleAttr("3628")
|
||||
result, err := api.GetSpuSaleAttr("3628")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func TestBatchAddSku(t *testing.T) {
|
||||
IsSale: true,
|
||||
},
|
||||
}
|
||||
result, err := jdapi.BatchAddSku(paramList)
|
||||
result, err := api.BatchAddSku(paramList)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func TestBatchAddSku(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSpuStatus(t *testing.T) {
|
||||
result, err := jdapi.GetSpuStatus("8515")
|
||||
result, err := api.GetSpuStatus("8515")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func TestGetSpuStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateSpuSaleAttr(t *testing.T) {
|
||||
err := jdapi.UpdateSpuSaleAttr("3628", "1001", "", "10", "hello")
|
||||
err := api.UpdateSpuSaleAttr("3628", "1001", "", "10", "hello")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func TestGetRealMobileNumber4Order(t *testing.T) {
|
||||
orderId := "900658736000042"
|
||||
desiredMobile := "18569035610"
|
||||
mobile, err := jdapi.GetRealMobile4Order(orderId, "11738115")
|
||||
mobile, err := api.GetRealMobile4Order(orderId, "11738115")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func TestGetRealMobileNumber4Order(t *testing.T) {
|
||||
func TestGetStoreOrderInfo(t *testing.T) {
|
||||
orderId := "826309564000021"
|
||||
// desiredMobile := "18569035610"
|
||||
orderInfo, err := jdapi.GetStoreOrderInfo(orderId, "11738115")
|
||||
orderInfo, err := api.GetStoreOrderInfo(orderId, "11738115")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func TestGetStoreOrderInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetStoreOrderInfoList(t *testing.T) {
|
||||
orderInfoList, err := jdapi.GetStoreOrderInfoList("2018-05-01 12:00:00", "2018-05-01 12:59:59")
|
||||
orderInfoList, err := api.GetStoreOrderInfoList("2018-05-01 12:00:00", "2018-05-01 12:59:59")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ const (
|
||||
)
|
||||
|
||||
func TestGetStationInfoList(t *testing.T) {
|
||||
result, err := jdapi.GetStationInfoList(mustExistStoreID, []int64{mustExistSkuID})
|
||||
result, err := api.GetStationInfoList(mustExistStoreID, []int64{mustExistSkuID})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func TestGetStationInfoList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryOpenUseable(t *testing.T) {
|
||||
result, err := jdapi.QueryOpenUseable([]*BaseStockCenterRequest{
|
||||
result, err := api.QueryOpenUseable([]*BaseStockCenterRequest{
|
||||
&BaseStockCenterRequest{
|
||||
StationNo: mustExistStoreID,
|
||||
SkuId: mustExistSkuID,
|
||||
@@ -38,7 +38,7 @@ func TestQueryOpenUseable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryStockCenter(t *testing.T) {
|
||||
result, err := jdapi.QueryStockCenter(mustExistStoreJXID, []*SkuIdEntity{
|
||||
result, err := api.QueryStockCenter(mustExistStoreJXID, []*SkuIdEntity{
|
||||
&SkuIdEntity{
|
||||
OutSkuId: mustExistSkuJXID,
|
||||
},
|
||||
@@ -52,7 +52,7 @@ func TestQueryStockCenter(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBatchUpdateVendibility(t *testing.T) {
|
||||
result, err := jdapi.BatchUpdateVendibility("100130", "", []*StockVendibility{
|
||||
result, err := api.BatchUpdateVendibility("100130", "", []*StockVendibility{
|
||||
&StockVendibility{
|
||||
OutSkuId: "26919",
|
||||
DoSale: true,
|
||||
|
||||
@@ -14,7 +14,7 @@ const (
|
||||
)
|
||||
|
||||
func TestGetStationsByVenderId(t *testing.T) {
|
||||
result, err := jdapi.GetStationsByVenderId()
|
||||
result, err := api.GetStationsByVenderId()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func TestGetStationsByVenderId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetStoreInfoByStationNo(t *testing.T) {
|
||||
result, err := jdapi.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
result, err := api.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func TestGetStoreInfoByStationNo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
result, err := jdapi.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
result, err := api.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -51,12 +51,12 @@ func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
addParams := map[string]interface{}{
|
||||
"stationAddress": testAddress,
|
||||
}
|
||||
err = jdapi.UpdateStoreInfo4Open(mustExistStoreID, "test", addParams)
|
||||
err = api.UpdateStoreInfo4Open(mustExistStoreID, "test", addParams)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
result, err = jdapi.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
result, err = api.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
newAddress := result["stationAddress"].(string)
|
||||
if newAddress != testAddress {
|
||||
t.Fatalf("address not match, newAddress:%s, oldAddress:%s", newAddress, oldAddress)
|
||||
@@ -65,7 +65,7 @@ func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
addParams = map[string]interface{}{
|
||||
"stationAddress": oldAddress,
|
||||
}
|
||||
jdapi.UpdateStoreInfo4Open(mustExistStoreID, "test", addParams)
|
||||
api.UpdateStoreInfo4Open(mustExistStoreID, "test", addParams)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
}
|
||||
func TestGetCommentByOrderId(t *testing.T) {
|
||||
testOrderID := int64(822347450000922)
|
||||
result, err := jdapi.GetCommentByOrderId(testOrderID)
|
||||
result, err := api.GetCommentByOrderId(testOrderID)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
testStationNo := "11785740"
|
||||
desiredValue := true
|
||||
// 马上修改了后,通过GetStoreInfoByStationNo得到的数据不及时,测试不能过的。。。
|
||||
result, err := jdapi.UpdateStoreConfig4Open(testStationNo, desiredValue)
|
||||
result, err := api.UpdateStoreConfig4Open(testStationNo, desiredValue)
|
||||
if err != nil || !result {
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
@@ -96,7 +96,7 @@ func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
t.Fatal(result)
|
||||
}
|
||||
time.Sleep(2 * time.Second)
|
||||
result2, err := jdapi.GetStoreInfoByStationNo(testStationNo)
|
||||
result2, err := api.GetStoreInfoByStationNo(testStationNo)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
@@ -108,11 +108,11 @@ func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
|
||||
func TestGetDeliveryRangeByStationNo(t *testing.T) {
|
||||
const testStoreID = "11738152"
|
||||
result, err := jdapi.GetDeliveryRangeByStationNo(testStoreID)
|
||||
result, err := api.GetDeliveryRangeByStationNo(testStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result2, err := jdapi.GetStoreInfoByStationNo(testStoreID)
|
||||
result2, err := api.GetStoreInfoByStationNo(testStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func TestGetDeliveryRangeByStationNo(t *testing.T) {
|
||||
"deliveryRangeType": 2,
|
||||
"coordinatePoints": deliveryRange,
|
||||
}
|
||||
err = jdapi.UpdateStoreInfo4Open(testStoreID, "test", params)
|
||||
err = api.UpdateStoreInfo4Open(testStoreID, "test", params)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -168,9 +168,15 @@ func (a *API) FullDiscountList(poiCode string, actType int) (actInfoList []*Full
|
||||
})
|
||||
}
|
||||
}
|
||||
return actInfoList, nil
|
||||
// decoder, _ := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
||||
// TagName: "json",
|
||||
// Result: &actInfoList,
|
||||
// })
|
||||
// if err = decoder.Decode(result); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
}
|
||||
return nil, err
|
||||
return actInfoList, err
|
||||
}
|
||||
|
||||
func interface2ActInfo(actInfo interface{}) *FullDiscountActInfo {
|
||||
|
||||
@@ -454,6 +454,8 @@ func FlatMap(in map[string]interface{}) map[string]interface{} {
|
||||
vMap = FlatMap(vMap)
|
||||
maps = append(maps, vMap)
|
||||
keys = append(keys, k)
|
||||
} else {
|
||||
fmt.Printf("%s is %s\n", k, reflect.TypeOf(v).String())
|
||||
}
|
||||
}
|
||||
if len(maps) > 0 {
|
||||
@@ -473,8 +475,9 @@ func Struct2FlatMap(obj interface{}) map[string]interface{} {
|
||||
|
||||
func Struct2MapWithIgnore(obj interface{}, ignoreValues map[string]interface{}) map[string]interface{} {
|
||||
mapData := Struct2FlatMap(obj)
|
||||
for k, v := range mapData {
|
||||
if ignoreValues[k] == v {
|
||||
for k, v := range ignoreValues {
|
||||
// todo 性能考虑?
|
||||
if fmt.Sprint(mapData[k]) == fmt.Sprint(v) {
|
||||
delete(mapData, k)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package utils
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestConv(t *testing.T) {
|
||||
@@ -69,3 +70,17 @@ func TestMarshal(t *testing.T) {
|
||||
t.Log(Format4Output(obj2, false))
|
||||
t.Log(Format4Output(Struct2FlatMap(obj2), false))
|
||||
}
|
||||
|
||||
func TestTime(t *testing.T) {
|
||||
for _, v := range [][]interface{}{
|
||||
[]interface{}{
|
||||
"2019-04-01",
|
||||
Str2Time("2019-04-01 00:00:00"),
|
||||
},
|
||||
} {
|
||||
data := Str2Time(v[0].(string))
|
||||
if data != v[1].(time.Time) {
|
||||
t.Fatal("Interface2Int64WithDefault failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user