mt sku
This commit is contained in:
@@ -650,7 +650,8 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric
|
||||
t1.jds_stock_switch,
|
||||
t1.preparation_time,
|
||||
t1.best_seller,
|
||||
t1.tiktok_attribute
|
||||
t1.tiktok_attribute,
|
||||
t1.mt_attribute
|
||||
`
|
||||
if isBySku {
|
||||
sqlData += " ,t2.id sku_id"
|
||||
|
||||
@@ -182,6 +182,11 @@ func UpdateSkuNameTiktokBrandName(db *DaoDB, upc, brandName, brandId string) {
|
||||
ExecuteSQL(db, sql, []interface{}{brandName, brandId, upc}...)
|
||||
}
|
||||
|
||||
func UpdateSkuNameMtAttr(db *DaoDB, id int64, attr string) {
|
||||
sql := ` UPDATE sku_name SET mt_attribute = ? WHERE id = ? `
|
||||
ExecuteSQL(db, sql, []interface{}{attr, id}...)
|
||||
}
|
||||
|
||||
func GetSkuNames(db *DaoDB, nameIDs []int, upcs []string, name string, isExd bool) (skuNameList []*model.SkuName, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
|
||||
@@ -3,10 +3,11 @@ package dao
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals/refutil"
|
||||
@@ -108,6 +109,7 @@ type StoreSkuSyncInfo struct {
|
||||
SellCities []string
|
||||
NameCategoryID int `orm:"column(name_category_id)"`
|
||||
TiktokAttribute string `orm:"column(tiktok_attribute)"`
|
||||
MtAttribute string `orm:"column(mt_attribute)"`
|
||||
YbNameSuffix string //银豹的商品条码后缀
|
||||
YbBarCode string //银豹的商品条码
|
||||
JdsStockSwitch int
|
||||
@@ -578,7 +580,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
||||
%s vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time,t1.vendor_son_sku_id,t1.vendor_sku_attr_id,t1.vendor_main_id,
|
||||
t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end, t1.jds_ware_id, t1.stock, t1.mt_ladder_box_price,
|
||||
t2.*,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.category_id name_category_id, t3.yb_name_suffix,t3.tiktok_attribute,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.category_id name_category_id, t3.yb_name_suffix,t3.tiktok_attribute,t3.mt_attribute,
|
||||
t3.jds_stock_switch, t3.preparation_time, t3.img_watermark, t3.ex_vendor_id, t3.img img_origin,t3.upc_brand_name,t3.upc_tiktok_brand_id,
|
||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||
IF(t12.%s <> '', t12.%s, t3.img2) img2,
|
||||
@@ -708,7 +710,7 @@ func GetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSyncInf
|
||||
t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time,
|
||||
t1.store_id, t1.deleted_at bind_deleted_at, t1.stock,
|
||||
t2.*, t2.id sku_id, t2m.vendor_thing_id vendor_sku_id,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.ex_prefix, t3.ex_prefix_begin, t3.ex_prefix_end, t3.category_id name_category_id,t3.tiktok_attribute,t3.upc_brand_name,t3.upc_tiktok_brand_id,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.ex_prefix, t3.ex_prefix_begin, t3.ex_prefix_end, t3.category_id name_category_id,t3.tiktok_attribute,t3.mt_attribute,t3.upc_brand_name,t3.upc_tiktok_brand_id,
|
||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||
IF(t12.%s <> '', t12.%s, t3.img2) img2,
|
||||
IF(t13.%s <> '', t13.%s, t3.desc_img) desc_img,
|
||||
|
||||
@@ -190,6 +190,7 @@ type SkuName struct {
|
||||
Video string `json:"video"` //商品视频地址
|
||||
VideoID string `orm:"column(video_id)" json:"videoID"` //商品视频美团ID
|
||||
TiktokAttribute string `orm:"column(tiktok_attribute);size(1024)" json:"tiktokAttribute"` //抖音分类属性的存储
|
||||
MtAttribute string `orm:"column(mt_attribute);size(1024)" json:"MtAttribute"` //美团分类属性的存储
|
||||
}
|
||||
|
||||
func (*SkuName) TableUnique() [][]string {
|
||||
|
||||
@@ -175,6 +175,7 @@ func SetMessageDetail(req *JXMsg, vendorID int, elmAppID string) error {
|
||||
//生成京西消息ID detail
|
||||
msgID := GenMsgDetailID(req, vendorID, elmAppID)
|
||||
data, _ := json.Marshal(req)
|
||||
globals.SugarLogger.Debugf("SetMessageDetail data=%s", string(data))
|
||||
err := rdb.RPush(msgID, string(data))
|
||||
ok, err := rdb.ExpireResult(msgID, ExpireTimeDay)
|
||||
if err != nil || !ok {
|
||||
@@ -198,6 +199,7 @@ func SetUserList(jxMsg *JXMsg, userList *UserMessageList, vendorID int, elmAppID
|
||||
}
|
||||
//存储当前数据
|
||||
data, _ := json.Marshal(userList)
|
||||
globals.SugarLogger.Debugf("SetUserList data=%s", string(data))
|
||||
err = rdb.RPush(msgID, string(data))
|
||||
ok, err := rdb.ExpireResult(msgID, ExpireTimeDay)
|
||||
if err != nil || !ok {
|
||||
|
||||
@@ -2,6 +2,9 @@ package mtwm
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
@@ -12,8 +15,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -241,6 +242,34 @@ func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
return err
|
||||
}
|
||||
|
||||
// GetCategoryAttrList 根据末级类目id获取类目属性列表
|
||||
func GetCategoryAttrList(appOrgCode string, tagID int) (categoryAttrListResult []*mtwmapi.CategoryAttrListResult, err error) {
|
||||
if resp, err := getAPI(appOrgCode, 0, "").CategoryAttrList(int64(tagID)); err == nil {
|
||||
return resp, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//GetCategoryAttrValueList 查询特殊属性的属性值列表
|
||||
func GetCategoryAttrValueList(appOrgCode, keyword string, attrID int) (categoryAttrValueListResult []*mtwmapi.CategoryAttrValueListResult, err error) {
|
||||
if attrID != utils.Str2Int(mtwmapi.SpecialAttrBrand) && attrID != utils.Str2Int(mtwmapi.SpecialAttrProducer) || len(keyword) == 0 || len(appOrgCode) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
if resp, err := getAPI(appOrgCode, 0, "").CategoryAttrValueList(int64(attrID), keyword); err == nil {
|
||||
return resp, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// GetRetailRecommendTag 根据商品UPC或名称或类目ID查询平台推荐类目及类目属性信息
|
||||
func GetRetailRecommendTag(appOrgCode, appPoiCode, name string, tagID, tagType int) (*mtwmapi.RetailRecommendTagResp, error) {
|
||||
if resp, err := getAPI(appOrgCode, 0, "").RetailRecommendTag(name, appPoiCode, tagID, tagType); err == nil {
|
||||
return resp, nil
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
//批量更新商品进货价
|
||||
func BatchSetRestockingPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, param []*mtwmapi.SpuData) error {
|
||||
if err := getAPI(getStoreVendorOrgCode(storeID), storeID, "").BatchSetRestockingPrice(ctx.GetTrackInfo(), vendorStoreID, param); err != nil {
|
||||
@@ -323,7 +352,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
foodData["min_order_count"] = 1
|
||||
}
|
||||
foodData["unit"] = storeSku.Unit
|
||||
attr := SwitchAttr(storeSku.VendorVendorCatID)
|
||||
//todo 增加商品必填属性
|
||||
attr := SwitchAttr(getAPI(getStoreVendorOrgCode(storeID), storeID, vendorStoreID), vendorStoreID, storeSku.VendorVendorCatID, storeSku.NameID, storeSku.Name, isCreate)
|
||||
if attr != "" {
|
||||
foodData["common_attr_value"] = attr
|
||||
}
|
||||
@@ -452,27 +482,92 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func SwitchAttr(vendorCatID int64) (attrs string) {
|
||||
switch vendorCatID {
|
||||
case 200002727:
|
||||
return mtwmapi.MtwmSkuAttr200002727
|
||||
case 200001555:
|
||||
return mtwmapi.MtwmSkuAttr200001555
|
||||
case 200002728:
|
||||
return mtwmapi.MtwmSkuAttr200002728
|
||||
case 200001519, 200000592:
|
||||
return mtwmapi.MtwmSkuAttr200000592
|
||||
case 200002704, 200002731:
|
||||
return mtwmapi.MtwmSkuAttr200002731
|
||||
case 200002716:
|
||||
return mtwmapi.MtwmSkuAttr200002716
|
||||
case 200002667, 200002713, 200002670:
|
||||
return mtwmapi.MtwmSkuAttr200002670
|
||||
case 200002680:
|
||||
return mtwmapi.MtwmSkuAttr200002680
|
||||
default:
|
||||
return ""
|
||||
// CommonAttrValue 类目对应属性值
|
||||
type CommonAttrValue struct {
|
||||
AttrID int `json:"attr_id"` //普通属性Id
|
||||
AttrName string `json:"attr_name"` //普通属性名称
|
||||
ValueList []ValueList `json:"valueList"`
|
||||
}
|
||||
type ValueList struct {
|
||||
ValueID int `json:"value_id"` //普通属性值Id,当属性值录入方式为文本时,该参数无需上传;若该普通属性可扩展则支持自定义 1.负值 2.同一个商品的同一个普通属性内唯一
|
||||
Value string `json:"value"` //普通属性值名称(与普通属性值Id一一对应),支持自定义。
|
||||
}
|
||||
|
||||
func SwitchAttr(apiObj *mtwmapi.API, vendorStoreID string, vendorCatID int64, nameID int, name string, isNeed bool) (attrs string) {
|
||||
var (
|
||||
db *dao.DaoDB
|
||||
tempCatID int64
|
||||
attrValue CommonAttrValue
|
||||
attrValues []CommonAttrValue
|
||||
)
|
||||
if isNeed == false && nameID != 0 { //是否为纯创建
|
||||
if tData, err := dao.GetSkuNames(db, []int{nameID}, nil, "", false); err == nil && len(tData) > 0 {
|
||||
if tData[0].MtAttribute != "[]" && tData[0].MtAttribute != "{}" && tData[0].MtAttribute != "" {
|
||||
return tData[0].MtAttribute
|
||||
}
|
||||
}
|
||||
}
|
||||
if vendorCatID == 0 { //创建商品时无分类,使用推荐分类
|
||||
if comTag, err := apiObj.RetailRecommendTag(name, vendorStoreID, 0, mtwmapi.TypeCategory); err == nil && comTag.TagID != 0 {
|
||||
tempCatID = int64(comTag.TagID)
|
||||
}
|
||||
} else {
|
||||
tempCatID = vendorCatID
|
||||
}
|
||||
//根据类目id获取类目属性列表
|
||||
if attrList, err := apiObj.CategoryAttrList(tempCatID); err == nil && len(attrList) > 0 {
|
||||
for _, v := range attrList {
|
||||
if v.Need == mtwmapi.NeedYes {
|
||||
attrValue = CommonAttrValue{
|
||||
AttrID: utils.Str2Int(v.AttrID),
|
||||
AttrName: v.AttrName,
|
||||
}
|
||||
if v.AttrID == mtwmapi.SpecialAttrBrand || v.AttrID == mtwmapi.SpecialAttrProducer { //单独获取特殊属性
|
||||
if data, err1 := apiObj.CategoryAttrValueList(utils.Str2Int64(v.AttrID), name); err1 == nil && len(data) > 0 {
|
||||
attrValue.ValueList = []ValueList{{ //默认取推荐第一个
|
||||
ValueID: utils.Str2Int(data[0].ValueID),
|
||||
Value: data[0].Value,
|
||||
}}
|
||||
}
|
||||
} else {
|
||||
if len(v.ValueList) > 0 {
|
||||
attrValue.ValueList = []ValueList{{
|
||||
ValueID: utils.Str2Int(v.ValueList[0].ValueID),
|
||||
Value: v.ValueList[0].Value,
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
attrValues = append(attrValues, attrValue)
|
||||
temp, _ := json.Marshal(attrValues)
|
||||
attrs = string(temp)
|
||||
globals.SugarLogger.Debugf("SwitchAttr attrValues=%s", utils.Format4Output(attrValues, false))
|
||||
} else {
|
||||
switch vendorCatID { //兜底处理
|
||||
case 200002727:
|
||||
attrs = mtwmapi.MtwmSkuAttr200002727
|
||||
case 200001555:
|
||||
attrs = mtwmapi.MtwmSkuAttr200001555
|
||||
case 200002728:
|
||||
attrs = mtwmapi.MtwmSkuAttr200002728
|
||||
case 200001519, 200000592:
|
||||
attrs = mtwmapi.MtwmSkuAttr200000592
|
||||
case 200002704, 200002731:
|
||||
attrs = mtwmapi.MtwmSkuAttr200002731
|
||||
case 200002716:
|
||||
attrs = mtwmapi.MtwmSkuAttr200002716
|
||||
case 200002667, 200002713, 200002670:
|
||||
attrs = mtwmapi.MtwmSkuAttr200002670
|
||||
case 200002680:
|
||||
attrs = mtwmapi.MtwmSkuAttr200002680
|
||||
default:
|
||||
attrs = ""
|
||||
}
|
||||
}
|
||||
//更新进数据库
|
||||
dao.UpdateSkuNameMtAttr(db, int64(nameID), attrs)
|
||||
globals.SugarLogger.Debugf("SwitchAttr attrs=%s", utils.Format4Output(attrs, false))
|
||||
return attrs
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
@@ -11,8 +16,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SkuController struct {
|
||||
@@ -790,6 +793,37 @@ func (c *SkuController) GetTiktokCategoryValue() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 根据美团分类id获取平台属性值
|
||||
// @Description 根据美团分类id获取平台属性值
|
||||
// @Param token header string true "认证token"
|
||||
// @Param appOrgCode query string true "美团app"
|
||||
// @Param categoryId query int64 true "美团类目id"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetMTCategoryAttrList [get]
|
||||
func (c *SkuController) GetMTCategoryAttrList() {
|
||||
c.callGetMTCategoryAttrList(func(params *tSkuGetMTCategoryAttrListParams) (interface{}, string, error) {
|
||||
data, err := mtwm.GetCategoryAttrList(params.AppOrgCode, params.CategoryId)
|
||||
return data, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 根据美团属性id 查询特殊属性(品牌、产地)
|
||||
// @Description 根据美团属性id 查询特殊属性(品牌、产地)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param appOrgCode query string true "美团app"
|
||||
// @Param attrId query int64 true "属性id"
|
||||
// @Param keyword query string true "属性值的关键词"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetMTCategoryAttrValueList [get]
|
||||
func (c *SkuController) GetMTCategoryAttrValueList() {
|
||||
c.callGetMTCategoryAttrValueList(func(params *tSkuGetMTCategoryAttrValueListParams) (interface{}, string, error) {
|
||||
data, err := mtwm.GetCategoryAttrValueList(params.AppOrgCode, params.Keyword, params.AttrId)
|
||||
return data, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 更新美团到京东分类映射
|
||||
// @Description 更新美团到京东分类映射
|
||||
// @Param token header string true "认证token"
|
||||
|
||||
@@ -1953,6 +1953,24 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
web.ControllerComments{
|
||||
Method: "GetMTCategoryAttrList",
|
||||
Router: `/GetMTCategoryAttrList`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
web.ControllerComments{
|
||||
Method: "GetMTCategoryAttrValueList",
|
||||
Router: `/GetMTCategoryAttrValueList`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
web.ControllerComments{
|
||||
Method: "UpdateMtCatToJd",
|
||||
|
||||
Reference in New Issue
Block a user