门店商品分类
This commit is contained in:
@@ -1407,9 +1407,18 @@ func AdjustJdsOrderSimple(ctx *jxcontext.Context, vendorOrderID string, skuID in
|
||||
db = dao.GetDB()
|
||||
)
|
||||
orderSkus, err := dao.GetSimpleOrderSkus(db, vendorOrderID, []int{skuID})
|
||||
order, err := dao.GetSimpleOrder(db, vendorOrderID)
|
||||
|
||||
orderSkus2, err := dao.GetSimpleOrderSkus(db, vendorOrderID, nil)
|
||||
if len(orderSkus2) == 1 {
|
||||
return fmt.Errorf("这一单只剩这最后一个商品了,不允许删除!")
|
||||
}
|
||||
if len(orderSkus) == 0 {
|
||||
return fmt.Errorf("未查询到该订单商品!")
|
||||
}
|
||||
if order.Status > model.OrderStatusAccepted {
|
||||
return fmt.Errorf("目前只支持待拣货状态前的订单售前调整!")
|
||||
}
|
||||
orderSku := orderSkus[0]
|
||||
if orderSku.Count > 1 {
|
||||
orderSku.Count--
|
||||
|
||||
@@ -1278,6 +1278,10 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
if valid["status"] != nil {
|
||||
syncStatus |= model.SyncFlagStoreStatus
|
||||
}
|
||||
//修改分类开关需要打同步标志
|
||||
if valid["isSysCat"] != nil {
|
||||
SetStoreCategorySyncStatus2(db, []int{storeID}, nil, model.SyncFlagModifiedMask)
|
||||
}
|
||||
if vendorStoreName, ok := valid["vendorStoreName"].(string); ok {
|
||||
if utf8.RuneCountInString(vendorStoreName) > jdapi.MaxStoreNameLen && vendorID == model.VendorIDJD {
|
||||
return 0, fmt.Errorf("门店名称不允许超过13位!")
|
||||
@@ -3016,6 +3020,282 @@ func ChangeYbCookie() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func GetStoreCategoryMap(ctx *jxcontext.Context, parentID, level int, storeID int) (storeCatMaps []*model.StoreCategoryMap, err error) {
|
||||
db := dao.GetDB()
|
||||
storeCatMaps, err = dao.GetStoreCategoryMap(db, parentID, level, storeID, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return storeCatMaps, err
|
||||
}
|
||||
|
||||
func AddStoreCategoryMap(ctx *jxcontext.Context, storeCategoryMap *model.StoreCategoryMap) (result *model.StoreCategoryMap, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if storeCategoryMap.Level != 1 {
|
||||
storeCatMaps, _ := dao.GetStoreCategoryMap(db, -1, 0, storeCategoryMap.StoreID, storeCategoryMap.CategoryID)
|
||||
if len(storeCatMaps) > 0 {
|
||||
return nil, fmt.Errorf("已存在绑定的京西分类,分类名:[%v]", storeCatMaps[0].StoreCategoryName)
|
||||
}
|
||||
}
|
||||
storeCategoryMap.StoreCategoryName = strings.Trim(storeCategoryMap.StoreCategoryName, " ")
|
||||
dao.WrapAddIDCULDEntity(storeCategoryMap, ctx.GetUserName())
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if err = dao.CreateEntity(db, storeCategoryMap); err != nil {
|
||||
dao.Rollback(db)
|
||||
return nil, err
|
||||
}
|
||||
dao.Commit(db)
|
||||
result = storeCategoryMap
|
||||
if storeCategoryMap.CategoryID != 0 {
|
||||
SetStoreCategorySyncStatus2(db, []int{storeCategoryMap.StoreID}, []int{storeCategoryMap.CategoryID}, model.SyncFlagModifiedMask)
|
||||
}
|
||||
// _, err = CurVendorSync.SyncCategory(ctx, nil, cat.ID, false, userName)
|
||||
return result, err
|
||||
}
|
||||
|
||||
func UpdateStoreCategoryMap(ctx *jxcontext.Context, ID int, storeCategoryMap *model.StoreCategoryMap, isDelete bool) (num int64, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
valid = make(map[string]interface{})
|
||||
storeCategoryMap2 = &model.StoreCategoryMap{}
|
||||
)
|
||||
storeCategoryMap2.ID = ID
|
||||
if err = dao.GetEntity(db, storeCategoryMap2); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if storeCategoryMap.StoreCategoryName != "" {
|
||||
valid["storeCategoryName"] = storeCategoryMap.StoreCategoryName
|
||||
}
|
||||
if storeCategoryMap.CategoryID != 0 {
|
||||
valid["categoryID"] = storeCategoryMap.CategoryID
|
||||
if !isDelete {
|
||||
storeCatMaps, _ := dao.GetStoreCategoryMap(db, -1, 0, storeCategoryMap2.StoreID, storeCategoryMap.CategoryID)
|
||||
if len(storeCatMaps) > 0 {
|
||||
for _, v := range storeCatMaps {
|
||||
if v.ID != ID {
|
||||
return 0, fmt.Errorf("已存在绑定的京西分类,分类名:[%v]", storeCatMaps[0].StoreCategoryName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if storeCategoryMap.Level != 0 {
|
||||
valid["level"] = storeCategoryMap.Level
|
||||
if storeCategoryMap.Level == 2 {
|
||||
cat2, _ := dao.GetCategories(db, -1, 0, []int{storeCategoryMap.CategoryID}, false)
|
||||
if len(cat2) > 0 {
|
||||
if cat2[0].ParentID != storeCategoryMap.ParentID {
|
||||
return 0, fmt.Errorf("此二级分类只能绑定到对应一级分类下!")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if isDelete {
|
||||
valid["deletedAt"] = time.Now()
|
||||
valid["updatedAt"] = time.Now()
|
||||
valid["lastOperator"] = ctx.GetUserName()
|
||||
//如果是1级分类则删除下面的子分类
|
||||
var catIDs []int
|
||||
if storeCategoryMap2.Level == 1 {
|
||||
storeCatMaps, _ := dao.GetStoreCategoryMap(db, storeCategoryMap2.CategoryID, 2, storeCategoryMap2.StoreID, 0)
|
||||
if len(storeCatMaps) > 0 {
|
||||
for _, v := range storeCatMaps {
|
||||
catIDs = append(catIDs, v.CategoryID)
|
||||
v.DeletedAt = time.Now()
|
||||
v.LastOperator = ctx.GetUserName()
|
||||
dao.UpdateEntity(db, v, "DeletedAt", "LastOperator")
|
||||
}
|
||||
}
|
||||
}
|
||||
// var storeSkus []*model.StoreSkuBind
|
||||
// sql := `
|
||||
// SELECT a.*
|
||||
// FROM store_sku_bind a
|
||||
// JOIN sku b ON a.sku_id = b.id
|
||||
// JOIN sku_name c ON c.id = b.name_id
|
||||
// WHERE a.deleted_at = ? AND b.deleted_at = ? AND c.deleted_at = ?
|
||||
// AND c.category_id = ? AND a.store_id = ?
|
||||
// UNION ALL
|
||||
// SELECT a.*
|
||||
// FROM store_sku_bind a
|
||||
// JOIN sku b ON a.sku_id = b.id
|
||||
// JOIN sku_name c ON c.id = b.name_id
|
||||
// JOIN sku_category d ON d.id = c.category_id
|
||||
// JOIN sku_category e ON e.id = d.parent_id
|
||||
// WHERE a.deleted_at = ? AND b.deleted_at = ? AND c.deleted_at = ?
|
||||
// AND e.id = ? AND a.store_id = ?
|
||||
// `
|
||||
// sqlParams := []interface{}{
|
||||
// utils.DefaultTimeValue, utils.DefaultTimeValue, utils.DefaultTimeValue,
|
||||
// storeCategoryMap2.CategoryID, storeCategoryMap2.StoreID,
|
||||
// utils.DefaultTimeValue, utils.DefaultTimeValue, utils.DefaultTimeValue,
|
||||
// storeCategoryMap2.CategoryID, storeCategoryMap2.StoreID,
|
||||
// }
|
||||
// if err = dao.GetRows(db, &storeSkus, sql, sqlParams); err != nil {
|
||||
// return 0, err
|
||||
// }
|
||||
// if len(storeSkus) > 0 {
|
||||
// return 0, fmt.Errorf("该分类下或该分类的子分类下有关注的商品,不可删除!分类名:[%v]", storeCategoryMap2.StoreCategoryName)
|
||||
// }
|
||||
catIDs = append(catIDs, storeCategoryMap.CategoryID)
|
||||
SetStoreCategorySyncStatus2(db, []int{storeCategoryMap2.StoreID}, catIDs, model.SyncFlagModifiedMask)
|
||||
} else {
|
||||
SetStoreCategorySyncStatus2(db, []int{storeCategoryMap2.StoreID}, []int{storeCategoryMap.CategoryID, storeCategoryMap2.CategoryID}, model.SyncFlagModifiedMask)
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if num, err = dao.UpdateEntityLogically(db, storeCategoryMap2, valid, ctx.GetUserName(), nil); err != nil {
|
||||
dao.Rollback(db)
|
||||
return 0, err
|
||||
}
|
||||
dao.Commit(db)
|
||||
return num, err
|
||||
}
|
||||
|
||||
func ReorderStoreCategories(ctx *jxcontext.Context, parentID, storeID int, categoryIDs []int) (err error) {
|
||||
var (
|
||||
storeCatsMap []*model.StoreCategoryMap
|
||||
)
|
||||
db := dao.GetDB()
|
||||
storeCatsMap, err = dao.GetStoreCategoryMap(db, parentID, 0, storeID, 0)
|
||||
catsLen := len(storeCatsMap)
|
||||
if catsLen != len(categoryIDs) {
|
||||
return ErrInputCatsDoesntMatch
|
||||
}
|
||||
catsMap := make(map[int]*model.StoreCategoryMap, catsLen)
|
||||
for _, cat := range storeCatsMap {
|
||||
catsMap[cat.CategoryID] = cat
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
for k, v := range categoryIDs {
|
||||
if catsMap[v] == nil {
|
||||
dao.Rollback(db)
|
||||
return fmt.Errorf("分类:%d不在%d分类下", v, parentID)
|
||||
}
|
||||
catsMap[v].StoreCategorySeq = k
|
||||
catsMap[v].LastOperator = ctx.GetUserName()
|
||||
if _, err = dao.UpdateEntity(db, catsMap[v]); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
}
|
||||
dao.Commit(db)
|
||||
SetStoreCategorySyncStatus2(db, nil, categoryIDs, model.SyncFlagModifiedMask)
|
||||
if err == nil {
|
||||
CurVendorSync.SyncStoresCategory(ctx, db, nil, nil, false, true, true)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func CopyStoreCategories(ctx *jxcontext.Context, fromStoreID int, toStoreIDs, categoryIDs []int, isContinueWhenError, isAsync bool) (hint string, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
storeCatList, err := dao.GetStoreCategoryMap(db, -1, 0, fromStoreID, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(storeCatList) == 0 {
|
||||
return "", fmt.Errorf("原门店无分类信息!storeID: %v", fromStoreID)
|
||||
}
|
||||
task := tasksch.NewParallelTask("CopyStoreCategories", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeID := batchItemList[0].(int)
|
||||
//证明是要全复制
|
||||
if len(categoryIDs) == 0 {
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
sql := `
|
||||
DELETE FROM store_category_map WHERE store_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{storeID}
|
||||
if _, err = dao.ExecuteSQL(db, sql, sqlParams); err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
sql2 := `
|
||||
INSERT INTO store_category_map(created_at,updated_at,last_operator,deleted_at,store_id,category_id,store_category_name,store_category_seq,level,parent_id)
|
||||
SELECT ?, ?, ?, ?, ?, category_id, store_category_name, store_category_seq, level, parent_id
|
||||
FROM store_category_map
|
||||
WHERE store_id = ? AND deleted_at = ?
|
||||
`
|
||||
sqlParams2 := []interface{}{
|
||||
time.Now(), time.Now(), ctx.GetUserName(), utils.DefaultTimeValue, storeID,
|
||||
fromStoreID, utils.DefaultTimeValue,
|
||||
}
|
||||
if _, err = dao.ExecuteSQL(db, sql2, sqlParams2); err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
dao.Commit(db)
|
||||
} else {
|
||||
for _, v := range categoryIDs {
|
||||
list, err := dao.GetStoreCategoryMap(db, -1, 0, storeID, v)
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
if len(list) > 0 {
|
||||
return retVal, fmt.Errorf("该门店已有重复绑定的京西分类!storeID: %v,categroyID: %v", storeID, v)
|
||||
} else {
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
sql2 := `
|
||||
INSERT INTO store_category_map(created_at,updated_at,last_operator,deleted_at,store_id,category_id,store_category_name,store_category_seq,level,parent_id)
|
||||
SELECT ?, ?, ?, ?, ?, category_id, store_category_name, store_category_seq, level, parent_id
|
||||
FROM store_category_map
|
||||
WHERE store_id = ? AND deleted_at = ? AND category_id = ?
|
||||
`
|
||||
sqlParams2 := []interface{}{
|
||||
time.Now(), time.Now(), ctx.GetUserName(), utils.DefaultTimeValue, storeID,
|
||||
fromStoreID, utils.DefaultTimeValue, v,
|
||||
}
|
||||
if _, err = dao.ExecuteSQL(db, sql2, sqlParams2); err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
dao.Commit(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, toStoreIDs)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if isAsync {
|
||||
hint = task.GetID()
|
||||
} else {
|
||||
_, err = task.GetResult(0)
|
||||
hint = "1"
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func DisabledStoreWithoutVendor(ctx *jxcontext.Context, isContinueWhenError, isAsync bool) (hint string, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
|
||||
@@ -78,7 +78,7 @@ func SyncStoreCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo
|
||||
if len(catList) > 0 {
|
||||
num += len(catList)
|
||||
task := tasksch.NewParallelTask(fmt.Sprintf("%s SyncStoreCategory step2, level=%d", model.VendorChineseNames[vendorID], level),
|
||||
tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
updateFields := []string{dao.GetSyncStatusStructField(model.VendorNames[vendorID])}
|
||||
idFieldName := dao.GetVendorThingIDStructField(model.VendorNames[vendorID])
|
||||
@@ -91,6 +91,13 @@ func SyncStoreCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if vendorID != model.VendorIDJD && vendorID != model.VendorIDJDShop {
|
||||
if catInfo.IsSysCat == model.YES && catInfo.StoreCatID != 0 {
|
||||
catInfo.Name = catInfo.StoreCatName
|
||||
catInfo.Seq = catInfo.StoreCatSeq
|
||||
}
|
||||
|
||||
}
|
||||
if model.IsSyncStatusDelete(catInfo.CatSyncStatus) { // 删除
|
||||
if model.IsSyncStatusDelete(catInfo.CatSyncStatus) && !dao.IsVendorThingIDEmpty(catInfo.VendorCatID) {
|
||||
err = handler.DeleteStoreCategory(ctx, storeID, vendorStoreID, catInfo.VendorCatID, level)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/aliupcapi"
|
||||
@@ -230,6 +231,8 @@ func GetSkuCategoryWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string,
|
||||
sqlParams = append(sqlParams, parentCatID)
|
||||
}
|
||||
sql += " ORDER BY t1.seq"
|
||||
fmt.Println(sql)
|
||||
fmt.Println(sqlParams)
|
||||
err = GetRows(db, &catList, sql, sqlParams...)
|
||||
return catList, err
|
||||
}
|
||||
|
||||
@@ -744,36 +744,37 @@ func GetRealLinkStoreID(db *DaoDB, linkStoreID int) (realLinkStoreID int, err er
|
||||
return realLinkStoreID, err
|
||||
}
|
||||
|
||||
// func GetStoreCategoryMap(db *DaoDB, parentID, storeID, categoryID int) (storeCatMaps []*StoreCatMap, err error) {
|
||||
// sql := `
|
||||
// SELECT a.*, b.level, b.parent_id, b.seq, b.name
|
||||
// FROM store_category_map a
|
||||
// JOIN sku_category b ON b.id = a.category_id
|
||||
// AND a.deleted_at = ?
|
||||
// AND b.deleted_at = ?
|
||||
// `
|
||||
// sqlParams := []interface{}{
|
||||
// utils.DefaultTimeValue,
|
||||
// utils.DefaultTimeValue,
|
||||
// }
|
||||
// if parentID != -1 {
|
||||
// sql += " AND b.parent_id = ?"
|
||||
// sqlParams = append(sqlParams, parentID)
|
||||
// }
|
||||
// if storeID > 0 {
|
||||
// sql += " AND a.store_id = ?"
|
||||
// sqlParams = append(sqlParams, storeID)
|
||||
// }
|
||||
// if categoryID > 0 {
|
||||
// sql += " AND a.category_id = ?"
|
||||
// sqlParams = append(sqlParams, categoryID)
|
||||
// }
|
||||
// err = GetRows(db, &storeCatMaps, sql, sqlParams)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return storeCatMaps, err
|
||||
// }
|
||||
func GetStoreCategoryMap(db *DaoDB, parentID, level, storeID, categoryID int) (storeCatMaps []*model.StoreCategoryMap, err error) {
|
||||
sql := `
|
||||
SELECT a.*
|
||||
FROM store_category_map a
|
||||
WHERE a.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if parentID >= 0 {
|
||||
sql += " AND a.parent_id = ?"
|
||||
sqlParams = append(sqlParams, parentID)
|
||||
}
|
||||
if level > 0 {
|
||||
sql += " AND a.level = ?"
|
||||
sqlParams = append(sqlParams, level)
|
||||
}
|
||||
if storeID > 0 {
|
||||
sql += " AND a.store_id = ?"
|
||||
sqlParams = append(sqlParams, storeID)
|
||||
}
|
||||
if categoryID > 0 {
|
||||
sql += " AND a.category_id = ?"
|
||||
sqlParams = append(sqlParams, categoryID)
|
||||
}
|
||||
err = GetRows(db, &storeCatMaps, sql, sqlParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return storeCatMaps, err
|
||||
}
|
||||
|
||||
func InsertStoreCategories(db *DaoDB, userName string, storeID int) (err error) {
|
||||
sql := `
|
||||
|
||||
@@ -41,6 +41,11 @@ type SkuStoreCatInfo struct {
|
||||
ParentCatName string
|
||||
ParentVendorCatID string `orm:"column(parent_vendor_cat_id)"`
|
||||
ParentCatSyncStatus int8
|
||||
|
||||
StoreCatID int `orm:"column(store_category_id)"`
|
||||
StoreCatName string
|
||||
StoreCatSeq int
|
||||
IsSysCat int
|
||||
}
|
||||
|
||||
type StoreSkuSyncInfo struct {
|
||||
@@ -347,15 +352,18 @@ func GetSkusCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level int
|
||||
func GetStoreCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level int, mustDirty bool) (cats []*SkuStoreCatInfo, err error) {
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql := `
|
||||
SELECT t4.*,
|
||||
SELECT t4.*, ts.store_category_name store_cat_name, ts.store_category_seq store_cat_seq, ts.id store_category_id,
|
||||
t5.id map_id, t5.%s_id vendor_cat_id, t5.%s_sync_status cat_sync_status,
|
||||
t4p.name parent_cat_name,
|
||||
t5p.id parent_map_id, t5p.%s_id parent_vendor_cat_id, t5p.%s_sync_status parent_cat_sync_status
|
||||
tsp.store_category_name parent_cat_name,
|
||||
t5p.id parent_map_id, t5p.%s_id parent_vendor_cat_id, t5p.%s_sync_status parent_cat_sync_status,
|
||||
t1.is_sys_cat
|
||||
FROM store_sku_category_map t5
|
||||
JOIN sku_category t4 ON t5.category_id = t4.id AND t4.deleted_at = ?
|
||||
LEFT JOIN store_category_map ts ON ts.store_id = t5.store_id AND ts.category_id = t4.id AND ts.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
fieldPrefixParams := []interface{}{fieldPrefix, fieldPrefix, fieldPrefix, fieldPrefix}
|
||||
if len(skuIDs) > 0 {
|
||||
@@ -372,9 +380,11 @@ func GetStoreCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level in
|
||||
}
|
||||
sql += `
|
||||
LEFT JOIN sku_category t4p ON t4.parent_id = t4p.id
|
||||
LEFT JOIN store_category_map tsp ON tsp.store_id = t5.store_id AND tsp.category_id = t4p.id AND tsp.deleted_at = ?
|
||||
LEFT JOIN store_sku_category_map t5p ON t4p.id = t5p.category_id AND t5.store_id = t5p.store_id AND t5p.deleted_at = ?
|
||||
LEFT JOIN store_map t1 ON t1.store_id = t5.store_id AND t1.vendor_id = ?
|
||||
WHERE t5.store_id = ? AND t5.deleted_at = ? AND t4.is_sync <> ?`
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, storeID, utils.DefaultTimeValue, model.YES)
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, utils.DefaultTimeValue, vendorID, storeID, utils.DefaultTimeValue, model.YES)
|
||||
if mustDirty {
|
||||
sql += " AND t5.%s_sync_status <> 0"
|
||||
fieldPrefixParams = append(fieldPrefixParams, fieldPrefix)
|
||||
|
||||
@@ -442,6 +442,8 @@ type StoreMap struct {
|
||||
YbAppID string `orm:"column(yb_app_id);size(255)" json:"ybAppID"`
|
||||
YbAppKey string `orm:"size(255)" json:"ybAppKey"`
|
||||
YbStorePrefix string `orm:"size(255)" json:"ybStorePrefix"`
|
||||
|
||||
IsSysCat int `orm:"default(0)" json:"isSysCat"` //是否使用京西分类
|
||||
}
|
||||
|
||||
func (*StoreMap) TableUnique() [][]string {
|
||||
@@ -666,3 +668,19 @@ func (l *FreightDeductionPack) Swap(i, j int) {
|
||||
l2[i] = l2[j]
|
||||
l2[j] = tmp
|
||||
}
|
||||
|
||||
type StoreCategoryMap struct {
|
||||
ModelIDCULD
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
CategoryID int `orm:"column(category_id)" json:"categoryID"` // 这个是指对应的sku_category
|
||||
StoreCategoryName string `orm:"size(255)" json:"storeCategoryName"` // 门店类别单独的名字
|
||||
StoreCategorySeq int `orm:"default(0)" json:"storeCategorySeq"` // 门店类别单独的序号
|
||||
Level int `json:"level"` // 门店类别单独的等级
|
||||
ParentID int `orm:"column(parent_id)" json:"parentID"` //门店类别父ID,和sku_category一致
|
||||
}
|
||||
|
||||
func (*StoreCategoryMap) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"StoreID", "CategoryID", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,8 +355,8 @@ jdAppKey = "06692746f7224695ad4788ce340bc854"
|
||||
jdSecret = "d6b42a35a7414a5490d811654d745c84"
|
||||
jdStorePageCookie = "5EOCZRXVCRXBTYD5EPV6FOXRCQWFFQO75FRMJ3BAKZ5JXY6XTJECMWXK5OZIPLZTUWZKZKXHXA6I7G3WMIKSWOHZIHRLNE5FZY3NBD6G5IMBOYHMJSJR3RF4TMZB2JEW2DF755YPFUSA6BMWI3KNLT3I4EAP2Z4JA6ZWAA34MNQX5P6LOI4EGG76QJU3G3VW7QFE6BAVAONMKBEHKNXNZGX3RQF7PHXDXSPJSY5XQEGM7IV2L7LKIG3M2D6QVSPEGQW4NV7SZ4TX32D2XQA7PIX46M"
|
||||
|
||||
ebaiSource = "62289"
|
||||
ebaiSecret = "d3ec2358d6a819ea"
|
||||
ebaiSource = "61219"
|
||||
ebaiSecret = "9ef8be6a53fb33e7"
|
||||
ebaiStorePageCookieWMUSS = "AHYHAAApIX5oBXUFKFsXKEdObiclRUhTFRZ1MUh7KEMiClB7MnB5G3VvIB5KN0USAABjQ4KngBfQ4Wcj9ebWYiEHBxCyNiBT1Yc111PhQ7UBluCENnCUB0HjIzfCAaHjAKEDoscT8sDL8JDDuQD81NaQ1dW3kN1MS9DeFMPgwC2YYROVy7AV3cKhMPkQrBwA"
|
||||
ebaiStorePageCookieWMSTOKEN = "UAABRL3ZhLykdGFQBBDxXVDBuYisaB3tQHjUmHlQ5cEAs5dxMdG0R-EwVILAy_CV1Vlw_nbQAA0ijuEe-F2xUzAQAAAdujHKzhohkrxY0c5LsAAH0CeSGnywAHBQAAMA"
|
||||
|
||||
|
||||
@@ -667,3 +667,111 @@ func (c *StoreController) DeletePrinterSeq() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到门店类别
|
||||
// @Description 得到门店类别
|
||||
// @Param token header string true "认证token"
|
||||
// @Param parentID query int false "父ID"
|
||||
// @Param level query int false "分类等级"
|
||||
// @Param storeID query int true "门店ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetStoreCategoryMap [get]
|
||||
func (c *StoreController) GetStoreCategoryMap() {
|
||||
c.callGetStoreCategoryMap(func(params *tStoreGetStoreCategoryMapParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetStoreCategoryMap(params.Ctx, params.ParentID, params.Level, params.StoreID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 新增门店类别
|
||||
// @Description 新增门店类别
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeID formData int true "门店ID"
|
||||
// @Param categroyID formData int false "京西分类id"
|
||||
// @Param level formData int true "分类级别"
|
||||
// @Param parentID formData int true "分类父ID"
|
||||
// @Param storeCategroyName formData string true "类别name"
|
||||
// @Param storeCategroySeq formData int true "类别序号"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /AddStoreCategoryMap [post]
|
||||
func (c *StoreController) AddStoreCategoryMap() {
|
||||
c.callAddStoreCategoryMap(func(params *tStoreAddStoreCategoryMapParams) (retVal interface{}, errCode string, err error) {
|
||||
storeCategoryMap := &model.StoreCategoryMap{
|
||||
StoreID: params.StoreID,
|
||||
CategoryID: params.CategroyID,
|
||||
StoreCategoryName: params.StoreCategroyName,
|
||||
StoreCategorySeq: params.StoreCategroySeq,
|
||||
Level: params.Level,
|
||||
ParentID: params.ParentID,
|
||||
}
|
||||
retVal, err = cms.AddStoreCategoryMap(params.Ctx, storeCategoryMap)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 修改门店类别
|
||||
// @Description 修改门店类别
|
||||
// @Param token header string true "认证token"
|
||||
// @Param ID formData int true "记录ID"
|
||||
// @Param categoryID formData int false "京西分类id"
|
||||
// @Param storeCategroyName formData string false "类别name"
|
||||
// @Param level formData int true "分类级别"
|
||||
// @Param parentID formData int true "分类父ID"
|
||||
// @Param isDelete formData bool false "是否是删除操作,默认false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateStoreCategoryMap [put]
|
||||
func (c *StoreController) UpdateStoreCategoryMap() {
|
||||
c.callUpdateStoreCategoryMap(func(params *tStoreUpdateStoreCategoryMapParams) (retVal interface{}, errCode string, err error) {
|
||||
storeCategoryMap := &model.StoreCategoryMap{
|
||||
CategoryID: params.CategoryID,
|
||||
StoreCategoryName: params.StoreCategroyName,
|
||||
Level: params.Level,
|
||||
ParentID: params.ParentID,
|
||||
}
|
||||
retVal, err = cms.UpdateStoreCategoryMap(params.Ctx, params.ID, storeCategoryMap, params.IsDelete)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 门店类别重排序
|
||||
// @Description 门店类别重排序
|
||||
// @Param token header string true "认证token"
|
||||
// @Param categoryID formData int true "父ID"
|
||||
// @Param storeID formData int true "门店ID"
|
||||
// @Param categoryIDs formData string true "同一父类别下的所有子类别ID列表([1,2,3,4])"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /ReorderStoreCategories [put]
|
||||
func (c *SkuController) ReorderStoreCategories() {
|
||||
c.callReorderStoreCategories(func(params *tSkuReorderStoreCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||||
var idList []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.CategoryIDs), &idList); err == nil {
|
||||
err = cms.ReorderStoreCategories(params.Ctx, params.CategoryID, params.StoreID, idList)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 复制门店类别
|
||||
// @Description 复制门店类别
|
||||
// @Param token header string true "认证token"
|
||||
// @Param fromStoreID formData int true "源门店ID"
|
||||
// @Param toStoreIDs formData string true "目标门店的IDs"
|
||||
// @Param categoryIDs formData string false "原门店的分类IDs,不传代表整个复制"
|
||||
// @Param isAsync formData bool false "是否异步操作"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /CopyStoreCategories [put]
|
||||
func (c *SkuController) CopyStoreCategories() {
|
||||
var toStoreIDs, categoryIDs []int
|
||||
c.callCopyStoreCategories(func(params *tSkuCopyStoreCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||||
if jxutils.Strings2Objs(params.ToStoreIDs, &toStoreIDs, params.CategoryIDs, &categoryIDs); err == nil {
|
||||
retVal, err = cms.CopyStoreCategories(params.Ctx, params.FromStoreID, toStoreIDs, categoryIDs, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1112,7 +1112,7 @@ func (c *OrderController) SaveJdsOrders() {
|
||||
// @Param skuID formData int true "商品ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /AdjustJdsOrderSimple [delete]
|
||||
// @router /AdjustJdsOrderSimple [post]
|
||||
func (c *OrderController) AdjustJdsOrderSimple() {
|
||||
c.callAdjustJdsOrderSimple(func(params *tOrderAdjustJdsOrderSimpleParams) (retVal interface{}, errCode string, err error) {
|
||||
err = orderman.AdjustJdsOrderSimple(params.Ctx, params.VendorOrderID, params.SkuID)
|
||||
|
||||
@@ -29,7 +29,7 @@ func Init() {
|
||||
orm.RegisterModel(new(model.MessageStatus))
|
||||
|
||||
orm.RegisterModel(&model.Place{})
|
||||
orm.RegisterModel(&model.Store{}, &model.StoreSub{}, &model.StoreMap{}, &model.StoreCourierMap{})
|
||||
orm.RegisterModel(&model.Store{}, &model.StoreSub{}, &model.StoreMap{}, &model.StoreCourierMap{}, &model.StoreCategoryMap{})
|
||||
orm.RegisterModel(&model.SkuVendorCategory{}, &model.StoreSkuCategoryMap{}, &model.SkuName{}, &model.Sku{}, &model.SkuNamePlaceBind{}, &model.StoreSkuBind{})
|
||||
orm.RegisterModel(&model.StoreSkuBindHistory{})
|
||||
orm.RegisterModel(&model.StoreSkuAudit{})
|
||||
|
||||
@@ -841,7 +841,7 @@ func init() {
|
||||
beego.ControllerComments{
|
||||
Method: "AdjustJdsOrderSimple",
|
||||
Router: `/AdjustJdsOrderSimple`,
|
||||
AllowHTTPMethods: []string{"delete"},
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
@@ -1386,6 +1386,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "CopyStoreCategories",
|
||||
Router: `/CopyStoreCategories`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "CreateUpcSkuByExcel",
|
||||
@@ -1512,6 +1521,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "ReorderStoreCategories",
|
||||
Router: `/ReorderStoreCategories`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "SortCategorySkus",
|
||||
@@ -1611,6 +1629,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "AddStoreCategoryMap",
|
||||
Router: `/AddStoreCategoryMap`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "AddStoreCourierMap",
|
||||
@@ -1728,6 +1755,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetStoreCategoryMap",
|
||||
Router: `/GetStoreCategoryMap`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetStoreCourierMaps",
|
||||
@@ -1908,6 +1944,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "UpdateStoreCategoryMap",
|
||||
Router: `/UpdateStoreCategoryMap`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "UpdateStoreCourierMap",
|
||||
|
||||
Reference in New Issue
Block a user