添加自动创建分类
This commit is contained in:
@@ -1175,6 +1175,13 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
|
||||
if skuNameExt.JdCategoryID != "" {
|
||||
updateOrCreate(model.VendorIDJD, nameID, skuNameExt.JdCategoryID)
|
||||
flag = true
|
||||
} else {
|
||||
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDJD).(partner.IPurchasePlatformStoreSkuHandler)
|
||||
vendorCategoryId, _ := handler.GetSkuCategoryIdByName(beego.AppConfig.DefaultString("jdOrgCode", "320406"), skuNameExt.Name)
|
||||
if vendorCategoryId != "" {
|
||||
updateOrCreate(model.VendorIDJD, nameID, skuNameExt.JdCategoryID)
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
if skuNameExt.JdsCategoryID != "" {
|
||||
updateOrCreate(model.VendorIDJDShop, nameID, skuNameExt.JdsCategoryID)
|
||||
@@ -1187,15 +1194,32 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
|
||||
if skuNameExt.MtwmCategoryID != "" {
|
||||
updateOrCreate(model.VendorIDMTWM, nameID, skuNameExt.MtwmCategoryID)
|
||||
flag = true
|
||||
} else {
|
||||
|
||||
}
|
||||
if skuNameExt.DdCategoryID != "" {
|
||||
updateOrCreate(model.VendorIDDD, nameID, skuNameExt.DdCategoryID)
|
||||
flag = true
|
||||
} else {
|
||||
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDDD).(partner.IPurchasePlatformStoreSkuHandler)
|
||||
imgs := fmt.Sprintf("%s,%s,%s,%s,%s,%s", skuNameExt.DescImg, skuNameExt.Img, skuNameExt.Img2, skuNameExt.Img3, skuNameExt.Img4, skuNameExt.Img5)
|
||||
vendorCategoryId, _ := handler.GetSkuCategoryIdByName("57939570", imgs)
|
||||
if vendorCategoryId != "" {
|
||||
updateOrCreate(model.VendorIDDD, nameID, skuNameExt.JdCategoryID)
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if payload["jdCategoryID"] != nil {
|
||||
updateOrCreate(model.VendorIDJD, nameID, payload["jdCategoryID"].(string))
|
||||
flag = true
|
||||
} else {
|
||||
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDJD).(partner.IPurchasePlatformStoreSkuHandler)
|
||||
vendorCategoryId, _ := handler.GetSkuCategoryIdByName(beego.AppConfig.DefaultString("jdOrgCode", "320406"), skuNameExt.Name)
|
||||
if vendorCategoryId != "" {
|
||||
updateOrCreate(model.VendorIDJD, nameID, skuNameExt.JdCategoryID)
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
if payload["jdsCategoryID"] != nil {
|
||||
updateOrCreate(model.VendorIDJDShop, nameID, payload["jdsCategoryID"].(string))
|
||||
@@ -1212,6 +1236,14 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
|
||||
if payload["ddCategoryID"] != nil {
|
||||
updateOrCreate(model.VendorIDDD, nameID, payload["ddCategoryID"].(string))
|
||||
flag = true
|
||||
} else {
|
||||
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDDD).(partner.IPurchasePlatformStoreSkuHandler)
|
||||
imgs := fmt.Sprintf("%s,%s,%s,%s,%s,%s", skuNameExt.DescImg, skuNameExt.Img, skuNameExt.Img2, skuNameExt.Img3, skuNameExt.Img4, skuNameExt.Img5)
|
||||
vendorCategoryId, _ := handler.GetSkuCategoryIdByName("57939570", imgs)
|
||||
if vendorCategoryId != "" {
|
||||
updateOrCreate(model.VendorIDDD, nameID, skuNameExt.JdCategoryID)
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,12 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
const (
|
||||
SoundsFileNewOrder = "newOrder.mp4"
|
||||
SoundsFileNewAfsOrder = "newAfsOrder.mp4"
|
||||
SoundsFileNewCancelOrder = "newCancelOrder.mp4"
|
||||
)
|
||||
|
||||
// NotifyNewOrder 推送新订单
|
||||
func NotifyNewOrder(order *model.GoodsOrder) {
|
||||
storeId := order.StoreID
|
||||
@@ -38,9 +44,10 @@ func NotifyNewOrder(order *model.GoodsOrder) {
|
||||
msg.VendorName = model.VendorChineseNames[order.VendorID]
|
||||
msg.OrderSqs = utils.Int2Str(order.OrderSeq)
|
||||
msg.StoreTitle = storeDetail.Name
|
||||
msg.Context = "老板,你有新的订单了"
|
||||
msg.Context = "老板,你有新的订单了!"
|
||||
context, _ := json.Marshal(msg)
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
|
||||
body := msg.Context + model.VendorChineseNames[order.VendorID] + "#" + msg.OrderSqs
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewOrder)
|
||||
}
|
||||
|
||||
func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
|
||||
@@ -63,11 +70,12 @@ func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
|
||||
|
||||
msg.MsgType = "newAfsOrder"
|
||||
msg.VendorName = model.VendorChineseNames[afsOrder.VendorID]
|
||||
msg.OrderSqs = "0"
|
||||
msg.OrderSqs = afsOrder.VendorOrderID
|
||||
msg.StoreTitle = storeDetail.Name
|
||||
msg.Context = "老板订单申请退款了"
|
||||
msg.Context = "老板订单申请退款了!"
|
||||
context, _ := json.Marshal(msg)
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
|
||||
body := msg.Context + model.VendorChineseNames[afsOrder.VendorID] + "#" + msg.OrderSqs
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewAfsOrder)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -91,11 +99,12 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
|
||||
|
||||
msg.MsgType = "newCancelOrder"
|
||||
msg.VendorName = model.VendorChineseNames[order.VendorID]
|
||||
msg.OrderSqs = "0"
|
||||
msg.OrderSqs = utils.Int2Str(order.OrderSeq)
|
||||
msg.StoreTitle = storeDetail.Name
|
||||
msg.Context = "老板订单被取消了"
|
||||
msg.Context = "老板订单被取消了!"
|
||||
context, _ := json.Marshal(msg)
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
|
||||
body := msg.Context + model.VendorChineseNames[order.VendorID] + "#" + msg.OrderSqs
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewCancelOrder)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -134,7 +143,7 @@ type MsgContext struct {
|
||||
OrderSqs string `json:"order_sqs"` // 订单流水号
|
||||
}
|
||||
|
||||
func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string) {
|
||||
func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, body string, soundsFileName string) {
|
||||
var errs []error
|
||||
for _, v := range cID {
|
||||
param := map[string]interface{}{
|
||||
@@ -160,10 +169,10 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string) {
|
||||
"aps": map[string]interface{}{
|
||||
"alert": map[string]interface{}{
|
||||
"title": storeName,
|
||||
"body": msg,
|
||||
"body": body,
|
||||
},
|
||||
"content-available": 0,
|
||||
"sound": "ring.mp3",
|
||||
"sound": soundsFileName,
|
||||
},
|
||||
"auto_badge": "+1",
|
||||
},
|
||||
|
||||
@@ -166,6 +166,8 @@ type IPurchasePlatformStoreSkuHandler interface {
|
||||
CreateStoreSkusAct(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (failedList []*StoreSkuInfoWithErr, err error)
|
||||
CancelActs(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (failedList []*StoreSkuInfoWithErr, err error)
|
||||
UpdateStoreSkusSpecTag(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (err error)
|
||||
// GetSkuCategoryIdByName 获取各个平台推荐分类
|
||||
GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error)
|
||||
}
|
||||
|
||||
type ISingleStoreStoreSkuHandler interface {
|
||||
|
||||
@@ -714,3 +714,7 @@ func (p *PurchaseHandler) CancelActs(ctx *jxcontext.Context, vendorOrgCode strin
|
||||
func (p *PurchaseHandler) UpdateStoreSkusSpecTag(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -23,3 +23,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
||||
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) {
|
||||
return storeStatus, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -285,6 +285,19 @@ func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, vendorOrgCode string,
|
||||
return skuNameList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
|
||||
vendorCategory, err := getAPI(vendorOrgCode).GetSkuCategoryBySkuName(skuName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if vendorCategory == nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
return utils.Int2Str(vendorCategory.CategoryId), nil
|
||||
}
|
||||
|
||||
func setSkuNameListPic(vendorOrgCode string, skuNameList []*partner.SkuNameInfo) []*partner.SkuNameInfo {
|
||||
jdSkuIDs := make([]int64, len(skuNameList))
|
||||
for k, v := range skuNameList {
|
||||
|
||||
@@ -1299,3 +1299,7 @@ func buildUpdateSkusParam(storeSku *dao.StoreSkuSyncInfo, v *dao.StoreSkuSyncInf
|
||||
updateSkusParam.Skus = skus
|
||||
return updateSkusParam, wareSku, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -80,3 +80,7 @@ func (p *PurchaseHandler) GetVendorCategories(ctx *jxcontext.Context) (vendorCat
|
||||
func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, vendorOrgCode string, skuID int, vendorSkuID string) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||
return skuNameList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -764,3 +764,7 @@ func (p *PurchaseHandler) UpdateStoreSkusSpecTag(ctx *jxcontext.Context, vendorO
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -3,12 +3,9 @@ package tiktok_store
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
@@ -84,61 +81,6 @@ func skuCategory(param1 []*tiktok_api.RetailCategoryInfo) (vendorCats []*model.S
|
||||
return
|
||||
}
|
||||
|
||||
func rangeMtwm2JX(areaStr string) string {
|
||||
var area []interface{}
|
||||
if err := utils.UnmarshalUseNumber([]byte(areaStr), &area); err == nil {
|
||||
if len(area) > 0 {
|
||||
coordList := make([]string, len(area))
|
||||
for k, v := range area {
|
||||
vv := v.(map[string]interface{})
|
||||
coordList[k] = fmt.Sprintf("%.6f,%.6f", jxutils.IntCoordinate2Standard(int(utils.ForceInterface2Int64(vv["x"]))), jxutils.IntCoordinate2Standard(int(utils.ForceInterface2Int64(vv["y"]))))
|
||||
}
|
||||
return strings.Join(coordList, ";")
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func rangeJX2Mtwm(coords string) string {
|
||||
pairs := strings.Split(strings.Trim(coords, ";"), ";")
|
||||
if len(pairs) > 0 {
|
||||
coordList := make([]map[string]interface{}, len(pairs))
|
||||
for k, v := range pairs {
|
||||
pair := strings.Split(v, ",")
|
||||
coordList[k] = map[string]interface{}{
|
||||
"x": jxutils.StandardCoordinate2Int(utils.Str2Float64(pair[0])),
|
||||
"y": jxutils.StandardCoordinate2Int(utils.Str2Float64(pair[1])),
|
||||
}
|
||||
}
|
||||
return string(utils.MustMarshal(coordList))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func openTimeMtwm2JX(vendorOpenTime string) (opTimeList []int16) {
|
||||
timePairs := strings.Split(vendorOpenTime, ",")
|
||||
for _, v := range timePairs {
|
||||
times := strings.Split(v, "-")
|
||||
if len(times) >= 2 {
|
||||
opTimeList = append(opTimeList, jxutils.StrTime2JxOperationTime(times[0]+":00", 700), jxutils.StrTime2JxOperationTime(times[1]+":00", 2000))
|
||||
}
|
||||
}
|
||||
return opTimeList
|
||||
}
|
||||
|
||||
func openTimeJX2Mtwm(opTimeList []int16) string {
|
||||
timesLen := len(opTimeList) / 2 * 2
|
||||
var strPairs []string
|
||||
for i := 0; i < timesLen; i += 2 {
|
||||
if opTimeList[i] != 0 {
|
||||
strPairs = append(strPairs, jxutils.JxOperationTime2StrTime(opTimeList[i])+"-"+jxutils.JxOperationTime2StrTime(opTimeList[i+1]))
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return strings.Join(strPairs, ",")
|
||||
}
|
||||
|
||||
func bizStatusTiktok2JX(status int64) int {
|
||||
switch status {
|
||||
case tiktok_api.StoreStateNormalBusiness:
|
||||
@@ -149,22 +91,6 @@ func bizStatusTiktok2JX(status int64) int {
|
||||
return model.StoreStatusDisabled
|
||||
}
|
||||
|
||||
func bizStatusJX2Mtwm(status int) (openLevel, online int) {
|
||||
if status == model.StoreStatusDisabled {
|
||||
return mtwmapi.PoiOpenLevelHaveRest, mtwmapi.PoiStatusOnline //mtwmapi.PoiStatusOffline
|
||||
} else if status == model.StoreStatusHaveRest || status == model.StoreStatusClosed {
|
||||
return mtwmapi.PoiOpenLevelHaveRest, mtwmapi.PoiStatusOnline
|
||||
}
|
||||
return mtwmapi.PoiOpenLevelNormal, mtwmapi.PoiStatusOnline
|
||||
}
|
||||
|
||||
func skuStatusJX2Tiktok(status int) int {
|
||||
if status == model.SkuStatusNormal {
|
||||
return mtwmapi.SellStatusOnline
|
||||
}
|
||||
return mtwmapi.SellStatusOffline
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, vendorOrgCode, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
|
||||
poiCode4UploadImg := p.getUploadImgPoiCode()
|
||||
if poiCode4UploadImg == "" {
|
||||
@@ -227,7 +153,3 @@ func getAPI(appOrgCode string, storeID int, vendorStoreID string) (apiObj *tikto
|
||||
func GetTiktokApi(appOrgCode string, storeID int, vendorStoreID string) *tiktok_api.API {
|
||||
return getAPI(appOrgCode, storeID, vendorStoreID)
|
||||
}
|
||||
|
||||
func getAPIWithoutToken(appOrgCode string) (apiObj *tiktok_api.API) {
|
||||
return partner.CurAPIManager.GetAPI(model.VendorIDDD, appOrgCode).(*tiktok_api.API)
|
||||
}
|
||||
|
||||
@@ -336,3 +336,8 @@ func GetProductAuditList(vendorOrgCode string, page, pageSize int64) (map[string
|
||||
}
|
||||
return updateCategory, total
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (string, error) {
|
||||
vendorCategoryId, err := getAPI(vendorOrgCode, 0, "").GetRecommendCategory(strings.Split(skuName, "|"))
|
||||
return utils.Int64ToStr(vendorCategoryId), err
|
||||
}
|
||||
|
||||
@@ -201,3 +201,6 @@ func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask ta
|
||||
func composeFakeDelName(name string) string {
|
||||
return "del_" + name
|
||||
}
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -398,6 +398,9 @@ func (p *PurchaseHandler) IsErrSkuNotExist(err error) (isNotExist bool) {
|
||||
return yinbaoapi.IsErrSkuNotExist(err)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
|
||||
return "", err
|
||||
}
|
||||
func ybSkuStatus2Jx(ybStatus int) (jxSkuStatus int) {
|
||||
if ybStatus == yinbaoapi.SkuStatusEnable {
|
||||
jxSkuStatus = model.SkuStatusNormal
|
||||
|
||||
Reference in New Issue
Block a user