1
This commit is contained in:
11
platformapi/ebaiapi/elm_im_test.go
Normal file
11
platformapi/ebaiapi/elm_im_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package ebaiapi
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetStoreImStatus(t *testing.T) {
|
||||
data, err := api.GetStoreIMStatus("1139781155")
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
t.Log(data)
|
||||
}
|
||||
@@ -1,6 +1,16 @@
|
||||
package ebaiapi
|
||||
|
||||
// GetStoreIMStatus 获取门店的im状态
|
||||
func (a *API) GetStoreIMStatus(platformShopId string) {
|
||||
import "errors"
|
||||
|
||||
// GetStoreIMStatus 获取门店的im状态
|
||||
func (a *API) GetStoreIMStatus(platformShopId string) (int, error) {
|
||||
result, err := a.AccessAPI("im.getIMStatus", map[string]interface{}{"platformShopId": platformShopId})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if result.ErrNo != 0 {
|
||||
return 0, errors.New(result.Error)
|
||||
}
|
||||
|
||||
return result.Data.(map[string]interface{})["imStatus"].(int), nil
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ type RetailDiscountActData struct {
|
||||
Stock int `json:"stock,omitempty"` // 当日剩余活动商品数量。只有当发起查询时间处于活动生效时段内时(start_time、end_time、period、weeks_time均需满足),该字段才代表实际剩余活动商品数量,否则显示的是创建活动时规定的当日活动库存
|
||||
Status int `json:"status,omitempty"` // 活动状态,0:已过期,1:已生效,2:待生效。
|
||||
Name string `json:"name,omitempty"`
|
||||
SkuId string `json:"sku_id"` // 京西商品id
|
||||
//SkuId string `json:"sku_id"` // 京西商品id
|
||||
}
|
||||
|
||||
type RetailDiscountActResult struct {
|
||||
|
||||
@@ -76,78 +76,6 @@ func TestRetailDiscountBatchSave(t *testing.T) {
|
||||
SettingType: SettingTypeAsDiscount,
|
||||
DiscountCoefficient: 9,
|
||||
},
|
||||
//&RetailDiscountActData{
|
||||
// AppFoodCode: "6043140",
|
||||
// StartTime: time.Now().Unix(),
|
||||
// EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
// OrderLimit: 1,
|
||||
// DayLimit: -1,
|
||||
// SettingType: SettingTypeAsDiscount,
|
||||
// DiscountCoefficient: 9.5,
|
||||
//},
|
||||
//&RetailDiscountActData{
|
||||
// AppFoodCode: "31765",
|
||||
// StartTime: time.Now().Unix(),
|
||||
// EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
// OrderLimit: 1,
|
||||
// DayLimit: -1,
|
||||
// SettingType: SettingTypeAsDiscount,
|
||||
// DiscountCoefficient: 9.5,
|
||||
//},
|
||||
//&RetailDiscountActData{
|
||||
// AppFoodCode: "31239",
|
||||
// StartTime: time.Now().Unix(),
|
||||
// EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
// OrderLimit: 1,
|
||||
// DayLimit: -1,
|
||||
// SettingType: SettingTypeAsDiscount,
|
||||
// DiscountCoefficient: 9.5,
|
||||
//},
|
||||
//&RetailDiscountActData{
|
||||
// AppFoodCode: "6042282",
|
||||
// StartTime: time.Now().Unix(),
|
||||
// EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
// OrderLimit: 1,
|
||||
// DayLimit: -1,
|
||||
// SettingType: SettingTypeAsDiscount,
|
||||
// DiscountCoefficient: 9.5,
|
||||
//},
|
||||
//&RetailDiscountActData{
|
||||
// AppFoodCode: "31901",
|
||||
// StartTime: time.Now().Unix(),
|
||||
// EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
// OrderLimit: 1,
|
||||
// DayLimit: -1,
|
||||
// SettingType: SettingTypeAsDiscount,
|
||||
// DiscountCoefficient: 9.5,
|
||||
//},
|
||||
//&RetailDiscountActData{
|
||||
// AppFoodCode: "6043147",
|
||||
// StartTime: time.Now().Unix(),
|
||||
// EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
// OrderLimit: 1,
|
||||
// DayLimit: -1,
|
||||
// SettingType: SettingTypeAsDiscount,
|
||||
// DiscountCoefficient: 9.5,
|
||||
//},
|
||||
//&RetailDiscountActData{
|
||||
// AppFoodCode: "30645",
|
||||
// StartTime: time.Now().Unix(),
|
||||
// EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
// OrderLimit: 1,
|
||||
// DayLimit: -1,
|
||||
// SettingType: SettingTypeAsDiscount,
|
||||
// DiscountCoefficient: 9.5,
|
||||
//},
|
||||
//&RetailDiscountActData{
|
||||
// AppFoodCode: "30729",
|
||||
// StartTime: time.Now().Unix(),
|
||||
// EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
// OrderLimit: 1,
|
||||
// DayLimit: -1,
|
||||
// SettingType: SettingTypeAsDiscount,
|
||||
// DiscountCoefficient: 9.5,
|
||||
//},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -199,91 +127,92 @@ func TestSgin(t *testing.T) {
|
||||
fmt.Println(timestamp)
|
||||
}
|
||||
|
||||
func TestBaokuanHuodong(t *testing.T) {
|
||||
// 获取门店所有的爆款活动
|
||||
storeId := 668887
|
||||
vendorStoreId := "17056471"
|
||||
|
||||
actList, _ := api.RetailDiscountList(vendorStoreId, 56)
|
||||
if len(actList) > 0 {
|
||||
allActivitySkuIdList := make([]string, 0, 0) // 此门店全部的折扣(爆款)活动商品
|
||||
activationActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店正在进行的折扣(爆款)活动商品
|
||||
loseActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店已经结束的折扣(爆款)活动商品
|
||||
for _, ac := range actList {
|
||||
allActivitySkuIdList = append(allActivitySkuIdList, utils.Int64ToStr(ac.ItemID))
|
||||
// 已经生效的爆款活动
|
||||
if ac.Status == 1 && ac.SkuId != "" {
|
||||
activity := &StoreSkuInfo{
|
||||
SkuID: utils.Str2Int(ac.SkuId),
|
||||
IsSpecialty: 1,
|
||||
}
|
||||
activationActivitySkuIdList = append(activationActivitySkuIdList, activity)
|
||||
}
|
||||
// 已经失效的爆款活动
|
||||
if ac.Status == 0 && ac.SkuId != "" {
|
||||
lose := &StoreSkuInfo{
|
||||
SkuID: utils.Str2Int(ac.SkuId),
|
||||
IsSpecialty: 0,
|
||||
}
|
||||
loseActivitySkuIdList = append(loseActivitySkuIdList, lose)
|
||||
}
|
||||
}
|
||||
|
||||
if err := UpdateStoreSkusSpecTag(nil, "589", storeId, vendorStoreId, loseActivitySkuIdList); err != nil {
|
||||
globals.SugarLogger.Debugf("取消力荐错误:= %v", err)
|
||||
}
|
||||
// 重新推荐力荐商品
|
||||
if err := UpdateStoreSkusSpecTag(nil, "589", storeId, vendorStoreId, activationActivitySkuIdList); err != nil {
|
||||
globals.SugarLogger.Debugf("重推力荐错误:= %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func UpdateStoreSkusSpecTag(aa interface{}, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (err error) {
|
||||
var foodDataList = []map[string]interface{}{}
|
||||
for _, v := range storeSkuList {
|
||||
var foodData = make(map[string]interface{})
|
||||
if v.IsSpecialty == -1 {
|
||||
v.IsSpecialty = 0
|
||||
}
|
||||
foodData["is_specialty"] = v.IsSpecialty
|
||||
foodData["app_food_code"] = v.SkuID
|
||||
foodDataList = append(foodDataList, foodData)
|
||||
}
|
||||
if len(foodDataList) == 1 {
|
||||
err = api.RetailInitData("1111", vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
||||
} else if len(foodDataList) > 0 {
|
||||
_, err = api.RetailBatchInitData("22222", vendorStoreID, foodDataList)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
type StoreSkuInfo struct {
|
||||
SkuID int `json:"skuID,omitempty"`
|
||||
VendorSkuID string `json:"vendorSkuID,omitempty"`
|
||||
NameID int `json:"nameID,omitempty"`
|
||||
VendorNameID string `json:"vendorNameID,omitempty"`
|
||||
|
||||
Stock int `json:"stock,omitempty"`
|
||||
VendorPrice int64 `json:"price,omitempty"`
|
||||
Status int `json:"status,omitempty"`
|
||||
|
||||
Seq int `json:"seq,omitempty"`
|
||||
|
||||
ActPrice int64 `json:"actPrice,omitempty"`
|
||||
VendorActID string `json:"vendorActID,omitempty"`
|
||||
IsSpecialty int `json:"isSpecialty,omitempty"`
|
||||
JxPrice int64 `json:"jxPrice,omitempty"`
|
||||
JxUnitPrice int64 `json:"jxUnitPrice,omitempty"`
|
||||
VendorSkuID2 string `json:"vendorSkuID2,omitempty"`
|
||||
JdsStockSwitch int `json:"jdsStockSwitch"`
|
||||
IsDeletedBySku bool `json:"isDeletedBySku"`
|
||||
VendorOrgCode string `json:"vendorOrgCode"`
|
||||
SpecUnit string `json:"specUnit"`
|
||||
SpecQuality float32 `json:"specQuality"`
|
||||
|
||||
VendorMainId string `json:"vendorMainId"` // 主商品id
|
||||
VendorSkuAttrId string `json:"vendorSkuAttrId"` //主商品sku_id
|
||||
VendorSonSkuID string `json:"vendorSonSkuID"` // 子商品skuid
|
||||
}
|
||||
//
|
||||
//func TestBaokuanHuodong(t *testing.T) {
|
||||
// // 获取门店所有的爆款活动
|
||||
// storeId := 668887
|
||||
// vendorStoreId := "17056471"
|
||||
//
|
||||
// actList, _ := api.RetailDiscountList(vendorStoreId, 56)
|
||||
// if len(actList) > 0 {
|
||||
// allActivitySkuIdList := make([]string, 0, 0) // 此门店全部的折扣(爆款)活动商品
|
||||
// activationActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店正在进行的折扣(爆款)活动商品
|
||||
// loseActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店已经结束的折扣(爆款)活动商品
|
||||
// for _, ac := range actList {
|
||||
// allActivitySkuIdList = append(allActivitySkuIdList, utils.Int64ToStr(ac.ItemID))
|
||||
// // 已经生效的爆款活动
|
||||
// if ac.Status == 1 && ac.SkuId != "" {
|
||||
// activity := &StoreSkuInfo{
|
||||
// SkuID: utils.Str2Int(ac.SkuId),
|
||||
// IsSpecialty: 1,
|
||||
// }
|
||||
// activationActivitySkuIdList = append(activationActivitySkuIdList, activity)
|
||||
// }
|
||||
// // 已经失效的爆款活动
|
||||
// if ac.Status == 0 && ac.SkuId != "" {
|
||||
// lose := &StoreSkuInfo{
|
||||
// SkuID: utils.Str2Int(ac.SkuId),
|
||||
// IsSpecialty: 0,
|
||||
// }
|
||||
// loseActivitySkuIdList = append(loseActivitySkuIdList, lose)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if err := UpdateStoreSkusSpecTag(nil, "589", storeId, vendorStoreId, loseActivitySkuIdList); err != nil {
|
||||
// globals.SugarLogger.Debugf("取消力荐错误:= %v", err)
|
||||
// }
|
||||
// // 重新推荐力荐商品
|
||||
// if err := UpdateStoreSkusSpecTag(nil, "589", storeId, vendorStoreId, activationActivitySkuIdList); err != nil {
|
||||
// globals.SugarLogger.Debugf("重推力荐错误:= %v", err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
||||
//func UpdateStoreSkusSpecTag(aa interface{}, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (err error) {
|
||||
// var foodDataList = []map[string]interface{}{}
|
||||
// for _, v := range storeSkuList {
|
||||
// var foodData = make(map[string]interface{})
|
||||
// if v.IsSpecialty == -1 {
|
||||
// v.IsSpecialty = 0
|
||||
// }
|
||||
// foodData["is_specialty"] = v.IsSpecialty
|
||||
// foodData["app_food_code"] = v.SkuID
|
||||
// foodDataList = append(foodDataList, foodData)
|
||||
// }
|
||||
// if len(foodDataList) == 1 {
|
||||
// err = api.RetailInitData("1111", vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
||||
// } else if len(foodDataList) > 0 {
|
||||
// _, err = api.RetailBatchInitData("22222", vendorStoreID, foodDataList)
|
||||
// }
|
||||
// return err
|
||||
//}
|
||||
//
|
||||
//type StoreSkuInfo struct {
|
||||
// SkuID int `json:"skuID,omitempty"`
|
||||
// VendorSkuID string `json:"vendorSkuID,omitempty"`
|
||||
// NameID int `json:"nameID,omitempty"`
|
||||
// VendorNameID string `json:"vendorNameID,omitempty"`
|
||||
//
|
||||
// Stock int `json:"stock,omitempty"`
|
||||
// VendorPrice int64 `json:"price,omitempty"`
|
||||
// Status int `json:"status,omitempty"`
|
||||
//
|
||||
// Seq int `json:"seq,omitempty"`
|
||||
//
|
||||
// ActPrice int64 `json:"actPrice,omitempty"`
|
||||
// VendorActID string `json:"vendorActID,omitempty"`
|
||||
// IsSpecialty int `json:"isSpecialty,omitempty"`
|
||||
// JxPrice int64 `json:"jxPrice,omitempty"`
|
||||
// JxUnitPrice int64 `json:"jxUnitPrice,omitempty"`
|
||||
// VendorSkuID2 string `json:"vendorSkuID2,omitempty"`
|
||||
// JdsStockSwitch int `json:"jdsStockSwitch"`
|
||||
// IsDeletedBySku bool `json:"isDeletedBySku"`
|
||||
// VendorOrgCode string `json:"vendorOrgCode"`
|
||||
// SpecUnit string `json:"specUnit"`
|
||||
// SpecQuality float32 `json:"specQuality"`
|
||||
//
|
||||
// VendorMainId string `json:"vendorMainId"` // 主商品id
|
||||
// VendorSkuAttrId string `json:"vendorSkuAttrId"` //主商品sku_id
|
||||
// VendorSonSkuID string `json:"vendorSonSkuID"` // 子商品skuid
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user