1
This commit is contained in:
@@ -1,8 +1,19 @@
|
|||||||
package ebaiapi
|
package ebaiapi
|
||||||
|
|
||||||
import "errors"
|
import (
|
||||||
|
"errors"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
// GetStoreIMStatus 获取门店的im状态
|
const (
|
||||||
|
IMStoreStatusOnLine = "ONLINE" // 门店im在线状态
|
||||||
|
IMStoreStatusBusy = "BUSY" // 忙碌状态
|
||||||
|
IMType = "IM" // 业务类型,消息默认IM
|
||||||
|
SubIMType = "SEND_MESSAGE" // 子业务类型,发送消息。默认值:SEND_MESSAGE
|
||||||
|
ReadIMType = "READ_MESSAGE"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetStoreIMStatus 获取门店的im状态(这个应该不怎么用)
|
||||||
func (a *API) GetStoreIMStatus(platformShopId string) (int, error) {
|
func (a *API) GetStoreIMStatus(platformShopId string) (int, error) {
|
||||||
result, err := a.AccessAPI("im.getIMStatus", map[string]interface{}{"platformShopId": platformShopId})
|
result, err := a.AccessAPI("im.getIMStatus", map[string]interface{}{"platformShopId": platformShopId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -14,3 +25,76 @@ func (a *API) GetStoreIMStatus(platformShopId string) (int, error) {
|
|||||||
|
|
||||||
return result.Data.(map[string]interface{})["imStatus"].(int), nil
|
return result.Data.(map[string]interface{})["imStatus"].(int), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetImOnlineStatus 获取门店IM线上状态
|
||||||
|
func (a *API) GetImOnlineStatus(platformShopId string) (int, error) {
|
||||||
|
result, err := a.AccessAPI("im.getIMOnlineStatus", 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{})["status"].(int), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetImOnlineStatus 设置im线上状态 ONLINE - 在线 BUSY - 忙碌
|
||||||
|
func (a *API) SetImOnlineStatus(platformShopId string, status string) error {
|
||||||
|
result, err := a.AccessAPI("im.updateIMOnlineStatus", map[string]interface{}{"platformShopId": platformShopId, "status": status})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if result.ErrNo != 0 {
|
||||||
|
return errors.New(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BusinessSendMsg 门店老板发送消息
|
||||||
|
func (a *API) BusinessSendMsg(param *BusinessSendMsgReq) error {
|
||||||
|
result, err := a.AccessAPI("im.message", utils.Struct2MapByJson(param))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if result.ErrNo != 0 {
|
||||||
|
return errors.New(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BusinessSendMsgReq im发送消息
|
||||||
|
type BusinessSendMsgReq struct {
|
||||||
|
PlatformShopId string `json:"platformShopId"` // 平台门店id
|
||||||
|
BizType string `json:"bizType"` // 业务类型,IM消息。默认值:IM
|
||||||
|
SubBizType string `json:"subBizType"` // 子业务类型,发送消息。默认值:SEND_MESSAGE
|
||||||
|
Payload BusinessMsgPayload `json:"payload"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BusinessMsgPayload struct {
|
||||||
|
GroupId string `json:"groupId"` // 会话ID
|
||||||
|
MsgId string `json:"msgId"` // 消息ID
|
||||||
|
ReceiverIds []string `json:"receiverIds"` // 接收人列表
|
||||||
|
Content string `json:"content"` // 发送内容,格式:JSON {"text":"msg"}
|
||||||
|
ContentType string `json:"contentType"` // 内容类型,目前只支持文本消息。枚举值: 1-普通文本
|
||||||
|
}
|
||||||
|
|
||||||
|
// SettingStoreMsgRead 设置消息已读
|
||||||
|
func (a *API) SettingStoreMsgRead(platformShopId string, msgId string) error {
|
||||||
|
result, err := a.AccessAPI("im.message.read", map[string]interface{}{
|
||||||
|
"platformShopId": platformShopId,
|
||||||
|
"bizType": IMType,
|
||||||
|
"subBizType": ReadIMType,
|
||||||
|
"payload": map[string]string{"msgId": msgId},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if result.ErrNo != 0 {
|
||||||
|
return errors.New(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -134,6 +134,29 @@ type RetailDiscountActData struct {
|
|||||||
//SkuId string `json:"sku_id"` // 京西商品id
|
//SkuId string `json:"sku_id"` // 京西商品id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetStoreRetailDiscountActData struct {
|
||||||
|
AppFoodCode string `json:"app_food_code"`
|
||||||
|
UserType int `json:"user_type"`
|
||||||
|
StartTime int64 `json:"start_time"` // 活动开始时间,单位秒
|
||||||
|
EndTime int64 `json:"end_time"` // 活动结束时间,单位秒
|
||||||
|
OrderLimit int `json:"order_limit"` // 每单限购:1)只能是正整数或-1。2)最大为10。
|
||||||
|
DayLimit int `json:"day_limit"` // 当日活动库存:只能是正整数或-1。
|
||||||
|
Period string `json:"period,omitempty"`
|
||||||
|
WeeksTime string `json:"weeks_time,omitempty"`
|
||||||
|
SettingType int `json:"setting_type"`
|
||||||
|
ActPrice float64 `json:"act_price,omitempty"` // 折扣价格(单位元):必须为大于0的数字,且不能超过2位小数。
|
||||||
|
DiscountCoefficient float64 `json:"discount_coefficient,omitempty"` // 折扣系数:必须大于0小于9.8,最多支持两位小数。如输入3,即为3折
|
||||||
|
Sequence int `json:"sequence,omitempty"`
|
||||||
|
ItemID int64 `json:"item_id,omitempty"` // 活动ID,为什么这里又是int64
|
||||||
|
|
||||||
|
// list时用
|
||||||
|
OriginalPrice float64 `json:"origin_price,omitempty"` // 商品原价,单位元
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
type RetailDiscountActResult struct {
|
type RetailDiscountActResult struct {
|
||||||
AppFoodCode string `json:"app_food_code"`
|
AppFoodCode string `json:"app_food_code"`
|
||||||
StartTime int64 `json:"start_time"` // 活动开始时间,单位秒
|
StartTime int64 `json:"start_time"` // 活动开始时间,单位秒
|
||||||
@@ -391,7 +414,7 @@ func parseErr4ErrList(msg string) (failedList []*AppFoodResult) {
|
|||||||
|
|
||||||
// 查询门店零售折扣商品
|
// 查询门店零售折扣商品
|
||||||
// http://developer.waimai.meituan.com/home/docDetail/288
|
// http://developer.waimai.meituan.com/home/docDetail/288
|
||||||
func (a *API) RetailDiscountList(poiCode string, actType int) (actList []*RetailDiscountActData, err error) {
|
func (a *API) RetailDiscountList(poiCode string, actType int) (actList []*GetStoreRetailDiscountActData, err error) {
|
||||||
limit := 200
|
limit := 200
|
||||||
offset := 0
|
offset := 0
|
||||||
if actType == 0 {
|
if actType == 0 {
|
||||||
@@ -406,7 +429,7 @@ func (a *API) RetailDiscountList(poiCode string, actType int) (actList []*Retail
|
|||||||
"offset": offset,
|
"offset": offset,
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
var tmpActList []*RetailDiscountActData
|
var tmpActList []*GetStoreRetailDiscountActData
|
||||||
if err = utils.Map2StructByJson(result, &tmpActList, false); err != nil {
|
if err = utils.Map2StructByJson(result, &tmpActList, false); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,92 +127,91 @@ func TestSgin(t *testing.T) {
|
|||||||
fmt.Println(timestamp)
|
fmt.Println(timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
func TestBaokuanHuodong(t *testing.T) {
|
||||||
//func TestBaokuanHuodong(t *testing.T) {
|
// 获取门店所有的爆款活动
|
||||||
// // 获取门店所有的爆款活动
|
storeId := 668887
|
||||||
// storeId := 668887
|
vendorStoreId := "17056471"
|
||||||
// vendorStoreId := "17056471"
|
|
||||||
//
|
actList, _ := api.RetailDiscountList(vendorStoreId, 56)
|
||||||
// actList, _ := api.RetailDiscountList(vendorStoreId, 56)
|
if len(actList) > 0 {
|
||||||
// if len(actList) > 0 {
|
allActivitySkuIdList := make([]string, 0, 0) // 此门店全部的折扣(爆款)活动商品
|
||||||
// allActivitySkuIdList := make([]string, 0, 0) // 此门店全部的折扣(爆款)活动商品
|
activationActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店正在进行的折扣(爆款)活动商品
|
||||||
// activationActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店正在进行的折扣(爆款)活动商品
|
loseActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店已经结束的折扣(爆款)活动商品
|
||||||
// loseActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店已经结束的折扣(爆款)活动商品
|
for _, ac := range actList {
|
||||||
// for _, ac := range actList {
|
allActivitySkuIdList = append(allActivitySkuIdList, utils.Int64ToStr(ac.ItemID))
|
||||||
// allActivitySkuIdList = append(allActivitySkuIdList, utils.Int64ToStr(ac.ItemID))
|
// 已经生效的爆款活动
|
||||||
// // 已经生效的爆款活动
|
if ac.Status == 1 && ac.SkuId != "" {
|
||||||
// if ac.Status == 1 && ac.SkuId != "" {
|
activity := &StoreSkuInfo{
|
||||||
// activity := &StoreSkuInfo{
|
SkuID: utils.Str2Int(ac.SkuId),
|
||||||
// SkuID: utils.Str2Int(ac.SkuId),
|
IsSpecialty: 1,
|
||||||
// IsSpecialty: 1,
|
}
|
||||||
// }
|
activationActivitySkuIdList = append(activationActivitySkuIdList, activity)
|
||||||
// activationActivitySkuIdList = append(activationActivitySkuIdList, activity)
|
}
|
||||||
// }
|
// 已经失效的爆款活动
|
||||||
// // 已经失效的爆款活动
|
if ac.Status == 0 && ac.SkuId != "" {
|
||||||
// if ac.Status == 0 && ac.SkuId != "" {
|
lose := &StoreSkuInfo{
|
||||||
// lose := &StoreSkuInfo{
|
SkuID: utils.Str2Int(ac.SkuId),
|
||||||
// SkuID: utils.Str2Int(ac.SkuId),
|
IsSpecialty: 0,
|
||||||
// IsSpecialty: 0,
|
}
|
||||||
// }
|
loseActivitySkuIdList = append(loseActivitySkuIdList, lose)
|
||||||
// loseActivitySkuIdList = append(loseActivitySkuIdList, lose)
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//
|
if err := UpdateStoreSkusSpecTag(nil, "589", storeId, vendorStoreId, loseActivitySkuIdList); err != nil {
|
||||||
// if err := UpdateStoreSkusSpecTag(nil, "589", storeId, vendorStoreId, loseActivitySkuIdList); err != nil {
|
globals.SugarLogger.Debugf("取消力荐错误:= %v", err)
|
||||||
// globals.SugarLogger.Debugf("取消力荐错误:= %v", err)
|
}
|
||||||
// }
|
// 重新推荐力荐商品
|
||||||
// // 重新推荐力荐商品
|
if err := UpdateStoreSkusSpecTag(nil, "589", storeId, vendorStoreId, activationActivitySkuIdList); err != nil {
|
||||||
// if err := UpdateStoreSkusSpecTag(nil, "589", storeId, vendorStoreId, activationActivitySkuIdList); err != nil {
|
globals.SugarLogger.Debugf("重推力荐错误:= %v", err)
|
||||||
// globals.SugarLogger.Debugf("重推力荐错误:= %v", err)
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//
|
}
|
||||||
//}
|
|
||||||
//
|
func UpdateStoreSkusSpecTag(aa interface{}, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (err error) {
|
||||||
//func UpdateStoreSkusSpecTag(aa interface{}, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (err error) {
|
var foodDataList = []map[string]interface{}{}
|
||||||
// var foodDataList = []map[string]interface{}{}
|
for _, v := range storeSkuList {
|
||||||
// for _, v := range storeSkuList {
|
var foodData = make(map[string]interface{})
|
||||||
// var foodData = make(map[string]interface{})
|
if v.IsSpecialty == -1 {
|
||||||
// if v.IsSpecialty == -1 {
|
v.IsSpecialty = 0
|
||||||
// v.IsSpecialty = 0
|
}
|
||||||
// }
|
foodData["is_specialty"] = v.IsSpecialty
|
||||||
// foodData["is_specialty"] = v.IsSpecialty
|
foodData["app_food_code"] = v.SkuID
|
||||||
// foodData["app_food_code"] = v.SkuID
|
foodDataList = append(foodDataList, foodData)
|
||||||
// foodDataList = append(foodDataList, foodData)
|
}
|
||||||
// }
|
if len(foodDataList) == 1 {
|
||||||
// if len(foodDataList) == 1 {
|
err = api.RetailInitData("1111", vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
||||||
// err = api.RetailInitData("1111", vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
} else if len(foodDataList) > 0 {
|
||||||
// } else if len(foodDataList) > 0 {
|
_, err = api.RetailBatchInitData("22222", vendorStoreID, foodDataList)
|
||||||
// _, err = api.RetailBatchInitData("22222", vendorStoreID, foodDataList)
|
}
|
||||||
// }
|
return err
|
||||||
// return err
|
}
|
||||||
//}
|
|
||||||
//
|
type StoreSkuInfo struct {
|
||||||
//type StoreSkuInfo struct {
|
SkuID int `json:"skuID,omitempty"`
|
||||||
// SkuID int `json:"skuID,omitempty"`
|
VendorSkuID string `json:"vendorSkuID,omitempty"`
|
||||||
// VendorSkuID string `json:"vendorSkuID,omitempty"`
|
NameID int `json:"nameID,omitempty"`
|
||||||
// NameID int `json:"nameID,omitempty"`
|
VendorNameID string `json:"vendorNameID,omitempty"`
|
||||||
// VendorNameID string `json:"vendorNameID,omitempty"`
|
|
||||||
//
|
Stock int `json:"stock,omitempty"`
|
||||||
// Stock int `json:"stock,omitempty"`
|
VendorPrice int64 `json:"price,omitempty"`
|
||||||
// VendorPrice int64 `json:"price,omitempty"`
|
Status int `json:"status,omitempty"`
|
||||||
// Status int `json:"status,omitempty"`
|
|
||||||
//
|
Seq int `json:"seq,omitempty"`
|
||||||
// Seq int `json:"seq,omitempty"`
|
|
||||||
//
|
ActPrice int64 `json:"actPrice,omitempty"`
|
||||||
// ActPrice int64 `json:"actPrice,omitempty"`
|
VendorActID string `json:"vendorActID,omitempty"`
|
||||||
// VendorActID string `json:"vendorActID,omitempty"`
|
IsSpecialty int `json:"isSpecialty,omitempty"`
|
||||||
// IsSpecialty int `json:"isSpecialty,omitempty"`
|
JxPrice int64 `json:"jxPrice,omitempty"`
|
||||||
// JxPrice int64 `json:"jxPrice,omitempty"`
|
JxUnitPrice int64 `json:"jxUnitPrice,omitempty"`
|
||||||
// JxUnitPrice int64 `json:"jxUnitPrice,omitempty"`
|
VendorSkuID2 string `json:"vendorSkuID2,omitempty"`
|
||||||
// VendorSkuID2 string `json:"vendorSkuID2,omitempty"`
|
JdsStockSwitch int `json:"jdsStockSwitch"`
|
||||||
// JdsStockSwitch int `json:"jdsStockSwitch"`
|
IsDeletedBySku bool `json:"isDeletedBySku"`
|
||||||
// IsDeletedBySku bool `json:"isDeletedBySku"`
|
VendorOrgCode string `json:"vendorOrgCode"`
|
||||||
// VendorOrgCode string `json:"vendorOrgCode"`
|
SpecUnit string `json:"specUnit"`
|
||||||
// SpecUnit string `json:"specUnit"`
|
SpecQuality float32 `json:"specQuality"`
|
||||||
// SpecQuality float32 `json:"specQuality"`
|
|
||||||
//
|
VendorMainId string `json:"vendorMainId"` // 主商品id
|
||||||
// VendorMainId string `json:"vendorMainId"` // 主商品id
|
VendorSkuAttrId string `json:"vendorSkuAttrId"` //主商品sku_id
|
||||||
// VendorSkuAttrId string `json:"vendorSkuAttrId"` //主商品sku_id
|
VendorSonSkuID string `json:"vendorSonSkuID"` // 子商品skuid
|
||||||
// VendorSonSkuID string `json:"vendorSonSkuID"` // 子商品skuid
|
}
|
||||||
//}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user