- sku category man almost ok.
- mysql connect str add utf8mb4.
This commit is contained in:
@@ -4,9 +4,18 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/basesch"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/basesch"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type VendorSync struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
CurVendorSync VendorSync
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrHaveNotImplementedYet = errors.New("还没有实现")
|
ErrHaveNotImplementedYet = errors.New("还没有实现")
|
||||||
)
|
)
|
||||||
@@ -14,3 +23,28 @@ var (
|
|||||||
func GetPurchaseHandler(vendorID int) partner.IPurchasePlatformHandler {
|
func GetPurchaseHandler(vendorID int) partner.IPurchasePlatformHandler {
|
||||||
return basesch.FixedBaseScheduler.GetPurchasePlatformFromVendorID(vendorID)
|
return basesch.FixedBaseScheduler.GetPurchasePlatformFromVendorID(vendorID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *VendorSync) SyncCategory(categoryID int, isForce bool, userName string) (err error) {
|
||||||
|
db := dao.GetDB()
|
||||||
|
cats := []*model.SkuCategory{}
|
||||||
|
if categoryID != 0 {
|
||||||
|
err = dao.GetRows(db, &cats, "SELECT * FROM sku_category WHERE id = ?", categoryID)
|
||||||
|
} else {
|
||||||
|
err = dao.GetRows(db, &cats, "SELECT * FROM sku_category")
|
||||||
|
}
|
||||||
|
for _, cat := range cats {
|
||||||
|
if (cat.JdSyncStatus & model.SyncFlagNewMask) != 0 { // 新增
|
||||||
|
err = GetPurchaseHandler(model.VendorIDJD).CreateCategory(cat, userName)
|
||||||
|
} else if (cat.JdSyncStatus&model.SyncFlagModifiedMask) != 0 || isForce { // 修改
|
||||||
|
err = GetPurchaseHandler(model.VendorIDJD).UpdateCategory(cat, userName)
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
cat.JdSyncStatus = 0
|
||||||
|
_, err = dao.UpdateEntity(db, cat, "JdSyncStatus")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,23 @@
|
|||||||
package cms
|
package cms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetVendorCategories(vendorID int) ([]*model.SkuVendorCategory, error) {
|
var (
|
||||||
cats := []*model.SkuVendorCategory{}
|
ErrInputCatsDoesntMatch = errors.New("输入的类别列表不合法,需要输入一个父ID下的所有子类别")
|
||||||
|
)
|
||||||
|
|
||||||
|
// parentID 为-1表示所有
|
||||||
|
func GetVendorCategories(vendorID int, parentID int) (cats []*model.SkuVendorCategory, err error) {
|
||||||
|
if parentID == -1 {
|
||||||
return cats, dao.GetRows(nil, &cats, "SELECT * FROM sku_vendor_category WHERE vendor_id = ?", vendorID)
|
return cats, dao.GetRows(nil, &cats, "SELECT * FROM sku_vendor_category WHERE vendor_id = ?", vendorID)
|
||||||
|
}
|
||||||
|
return cats, dao.GetRows(nil, &cats, "SELECT * FROM sku_vendor_category WHERE vendor_id = ? AND parent_id = ?", vendorID, parentID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSkuMetaInfo() (*model.SkuMetaInfo, error) {
|
func GetSkuMetaInfo() (*model.SkuMetaInfo, error) {
|
||||||
@@ -16,3 +26,63 @@ func GetSkuMetaInfo() (*model.SkuMetaInfo, error) {
|
|||||||
SpecUnits: model.SpecUnitNames,
|
SpecUnits: model.SpecUnitNames,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parentID 为-1表示所有
|
||||||
|
func GetCategories(parentID int) (cats []*model.SkuCategory, err error) {
|
||||||
|
if parentID == -1 {
|
||||||
|
return cats, dao.GetRows(nil, &cats, "SELECT * FROM sku_category")
|
||||||
|
}
|
||||||
|
return cats, dao.GetRows(nil, &cats, "SELECT * FROM sku_category WHERE parent_id = ?", parentID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddCategory(cat *model.SkuCategory, userName string) (outCat *model.SkuCategory, err error) {
|
||||||
|
cat.ID = 0
|
||||||
|
cat.JdSyncStatus = model.SyncFlagNewMask
|
||||||
|
if err = dao.CreateEntity(nil, cat); err == nil {
|
||||||
|
outCat = cat
|
||||||
|
err = CurVendorSync.SyncCategory(cat.ID, false, userName)
|
||||||
|
}
|
||||||
|
return outCat, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateCategory(categoryID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||||
|
cat := &model.SkuCategory{}
|
||||||
|
cat.ID = categoryID
|
||||||
|
valid := jxutils.NormalMakeMapByStructObject(payload, cat, userName)
|
||||||
|
valid["JdSyncStatus"] = model.SyncFlagModifiedMask
|
||||||
|
db := dao.GetDB()
|
||||||
|
if num, err = dao.UpdateEntityByKV(db, cat, valid, nil); err == nil {
|
||||||
|
err = CurVendorSync.SyncCategory(categoryID, false, userName)
|
||||||
|
}
|
||||||
|
return num, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReorderCategories(parentID int, categoryIDs []int, userName string) (err error) {
|
||||||
|
var cats []*model.SkuCategory
|
||||||
|
parentCat := &model.SkuCategory{}
|
||||||
|
parentCat.ID = parentID
|
||||||
|
db := dao.GetDB()
|
||||||
|
if err = dao.GetEntity(db, parentCat); err == nil {
|
||||||
|
if err = dao.GetRows(db, &cats, "SELECT * FROM sku_category WHERE parent_id = ?", parentID); err == nil {
|
||||||
|
catsLen := len(cats)
|
||||||
|
if catsLen != len(categoryIDs) {
|
||||||
|
return ErrInputCatsDoesntMatch
|
||||||
|
}
|
||||||
|
catsMap := make(map[int]*model.SkuCategory, catsLen)
|
||||||
|
for _, cat := range cats {
|
||||||
|
catsMap[cat.ID] = cat
|
||||||
|
}
|
||||||
|
for k, v := range categoryIDs {
|
||||||
|
catsMap[v].Seq = k * 5
|
||||||
|
// catsMap[v].JdSyncStatus = model.SyncFlagModifiedMask
|
||||||
|
if _, err = dao.UpdateEntity(db, catsMap[v], "Seq"); err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
err = GetPurchaseHandler(model.VendorIDJD).ReorderCategories(parentCat, userName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -211,11 +211,9 @@ func GetVendorStore(vendorStoreID string, vendorID int) (retVal *StoreExt, err e
|
|||||||
func UpdateStore(storeID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
func UpdateStore(storeID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||||
store := &model.Store{}
|
store := &model.Store{}
|
||||||
store.ID = storeID
|
store.ID = storeID
|
||||||
valid := jxutils.NormalMakeMapByStructObject(payload, &model.Store{}, userName)
|
valid := jxutils.NormalMakeMapByStructObject(payload, store, userName)
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
globals.SugarLogger.Debug("1")
|
|
||||||
if num, err = dao.UpdateEntityByKV(db, store, valid, nil); err == nil {
|
if num, err = dao.UpdateEntityByKV(db, store, valid, nil); err == nil {
|
||||||
globals.SugarLogger.Debug("2")
|
|
||||||
dummy := &model.StoreMap{}
|
dummy := &model.StoreMap{}
|
||||||
_, err2 := dao.UpdateEntityByKV(db, dummy, utils.Params2Map("SyncStatus", model.SyncFlagModifiedMask), utils.Params2Map("StoreID", store.ID))
|
_, err2 := dao.UpdateEntityByKV(db, dummy, utils.Params2Map("SyncStatus", model.SyncFlagModifiedMask), utils.Params2Map("StoreID", store.ID))
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ func GetRows(db *DaoDB, inPtr interface{}, sql string, values ...interface{}) (e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEntity(db *DaoDB, item interface{}, cols ...string) error {
|
func GetEntity(db *DaoDB, item interface{}, cols ...string) (err error) {
|
||||||
if db == nil {
|
if db == nil {
|
||||||
db = GetDB()
|
db = GetDB()
|
||||||
}
|
}
|
||||||
err := utils.CallFuncLogError(func() error {
|
err = utils.CallFuncLogError(func() error {
|
||||||
return db.db.Read(item, cols...)
|
return db.db.Read(item, cols...)
|
||||||
}, reflect.TypeOf(item).Name())
|
}, reflect.TypeOf(item).Name())
|
||||||
return err
|
return err
|
||||||
@@ -109,13 +109,13 @@ func UpdateEntityByKV(db *DaoDB, item interface{}, kvs map[string]interface{}, c
|
|||||||
return num, err
|
return num, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateEntity(db *DaoDB, item interface{}) error {
|
func CreateEntity(db *DaoDB, item interface{}) (err error) {
|
||||||
if db == nil {
|
if db == nil {
|
||||||
db = GetDB()
|
db = GetDB()
|
||||||
}
|
}
|
||||||
err := utils.CallFuncLogError(func() error {
|
err = utils.CallFuncLogError(func() error {
|
||||||
_, err2 := db.db.Insert(item) // todo 这里需要将ID赋值么?
|
_, err = db.db.Insert(item) // todo 这里需要将ID赋值么?
|
||||||
return err2
|
return err
|
||||||
}, reflect.TypeOf(item).Name())
|
}, reflect.TypeOf(item).Name())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,20 +69,19 @@ func (*SkuVendorCategory) TableUnique() [][]string {
|
|||||||
type SkuCategory struct {
|
type SkuCategory struct {
|
||||||
ModelIDCUL
|
ModelIDCUL
|
||||||
|
|
||||||
Name string `orm:"size(255);unique"`
|
Name string `orm:"size(255);unique" json:"name"`
|
||||||
ParentID int `orm:"column(parent_id)"`
|
ParentID int `orm:"column(parent_id)" json:"parentID"`
|
||||||
Level int8
|
Level int8 `json:"level"`
|
||||||
Type int8 // 类别类型
|
Type int8 `json:"type"` // 类别类型,即是普通类别还是特殊用于做活动的类别
|
||||||
Seq int
|
Seq int `json:"seq"`
|
||||||
|
|
||||||
JdID int64 `orm:"column(jd_id);index"` // 这个是指商家自己的商品类别在京东平台上的ID
|
JdID int64 `orm:"column(jd_id);index" json:"jdID"` // 这个是指商家自己的商品类别在京东平台上的ID
|
||||||
JdCategoryID int `orm:"column(jd_category_id)"` // 这个是指对应的京东商品类别
|
JdCategoryID int `orm:"column(jd_category_id)" json:"jdCategoryID"` // 这个是指对应的京东商品类别
|
||||||
|
|
||||||
ElmCategoryID int64 `orm:"column(elm_category_id)"` // 这个是指对应的饿了么商品类别
|
ElmCategoryID int64 `orm:"column(elm_category_id)" json:"elmCategoryID"` // 这个是指对应的饿了么商品类别
|
||||||
EbaiCategoryID int64 `orm:"column(ebai_category_id)"` // 这个是指对应的饿百商品类别
|
EbaiCategoryID int64 `orm:"column(ebai_category_id)" json:"ebaiCategoryID"` // 这个是指对应的饿百商品类别
|
||||||
|
|
||||||
// MtID string `orm:"size(48);index"`
|
JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
||||||
// DidiID string `orm:"size(48);index"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SkuName struct {
|
type SkuName struct {
|
||||||
|
|||||||
@@ -67,8 +67,9 @@ type IPurchasePlatformHandler interface {
|
|||||||
CreateCategory(cat *model.SkuCategory, userName string) (err error)
|
CreateCategory(cat *model.SkuCategory, userName string) (err error)
|
||||||
ReadCategory(vendorCatID string) (cat *model.SkuCategory, err error)
|
ReadCategory(vendorCatID string) (cat *model.SkuCategory, err error)
|
||||||
ReadCategories() (cats []*model.SkuCategory, err error)
|
ReadCategories() (cats []*model.SkuCategory, err error)
|
||||||
UpdateCategory(cat *model.SkuCategory) error
|
UpdateCategory(cat *model.SkuCategory, userName string) error
|
||||||
DeleteCategory(cat *model.SkuCategory) error
|
DeleteCategory(cat *model.SkuCategory, userName string) error
|
||||||
|
ReorderCategories(parentCat *model.SkuCategory, userName string) (err error)
|
||||||
|
|
||||||
CreateSku(sku *model.Sku) (err error)
|
CreateSku(sku *model.Sku) (err error)
|
||||||
ReadSku(vendorSkuID string) (skuName *model.SkuName, sellPlaces []*model.Place, sku *model.Sku, err error)
|
ReadSku(vendorSkuID string) (skuName *model.SkuName, sellPlaces []*model.Place, sku *model.Sku, err error)
|
||||||
|
|||||||
@@ -14,11 +14,15 @@ func (p *PurchaseHandler) ReadCategories() (cats []*model.SkuCategory, err error
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) UpdateCategory(cat *model.SkuCategory) error {
|
func (p *PurchaseHandler) UpdateCategory(cat *model.SkuCategory, userName string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteCategory(cat *model.SkuCategory) error {
|
func (p *PurchaseHandler) DeleteCategory(cat *model.SkuCategory, userName string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) ReorderCategories(parentCat *model.SkuCategory, userName string) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ type skuInfoExt struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateCategory(cat *model.SkuCategory, userName string) (err error) {
|
func (p *PurchaseHandler) CreateCategory(cat *model.SkuCategory, userName string) (err error) {
|
||||||
|
if !globals.EnableStoreWrite {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var jdPid int64
|
var jdPid int64
|
||||||
if cat.ParentID != 0 {
|
if cat.ParentID != 0 {
|
||||||
pCat := &model.SkuCategory{}
|
pCat := &model.SkuCategory{}
|
||||||
@@ -73,15 +77,43 @@ func (p *PurchaseHandler) ReadCategories() (cats []*model.SkuCategory, err error
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) UpdateCategory(cat *model.SkuCategory) error {
|
func (p *PurchaseHandler) UpdateCategory(cat *model.SkuCategory, userName string) error {
|
||||||
|
if !globals.EnableStoreWrite {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return api.JdAPI.UpdateShopCategory(cat.JdID, cat.Name)
|
return api.JdAPI.UpdateShopCategory(cat.JdID, cat.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteCategory(cat *model.SkuCategory) error {
|
func (p *PurchaseHandler) DeleteCategory(cat *model.SkuCategory, userName string) error {
|
||||||
|
if !globals.EnableStoreWrite {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return api.JdAPI.DelShopCategory(cat.JdID)
|
return api.JdAPI.DelShopCategory(cat.JdID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) ReorderCategories(parentCat *model.SkuCategory, userName string) (err error) {
|
||||||
|
if !globals.EnableStoreWrite {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var cats []*model.SkuCategory
|
||||||
|
if err = dao.GetRows(nil, &cats, "SELECT * FROM sku_category WHERE parent_id = ? ORDER BY seq", parentCat.ID); err == nil {
|
||||||
|
jdCatIDs := make([]int64, len(cats))
|
||||||
|
for k, v := range cats {
|
||||||
|
jdCatIDs[k] = v.JdID
|
||||||
|
}
|
||||||
|
err = api.JdAPI.ChangeShopCategoryOrder(parentCat.JdID, jdCatIDs)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) cuSku(sku *model.Sku, handler func(skuExt *skuInfoExt, skuName string, shopCategories []int64, addParams map[string]interface{}) (string, error)) (err error) {
|
func (p *PurchaseHandler) cuSku(sku *model.Sku, handler func(skuExt *skuInfoExt, skuName string, shopCategories []int64, addParams map[string]interface{}) (string, error)) (err error) {
|
||||||
|
if !globals.EnableStoreWrite {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var otherInfo skuInfoExt
|
var otherInfo skuInfoExt
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
err = dao.GetRow(nil, &otherInfo, `
|
err = dao.GetRow(nil, &otherInfo, `
|
||||||
@@ -197,6 +229,10 @@ func (p *PurchaseHandler) UpdateSku(sku *model.Sku) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteSku(sku *model.Sku) (err error) {
|
func (p *PurchaseHandler) DeleteSku(sku *model.Sku) (err error) {
|
||||||
|
if !globals.EnableStoreWrite {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
"fixedStatus": 4,
|
"fixedStatus": 4,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -62,7 +63,9 @@ func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) UpdateStore(vendorStoreID string, store *model.Store, userName string) error {
|
func (p *PurchaseHandler) UpdateStore(vendorStoreID string, store *model.Store, userName string) error {
|
||||||
|
if !globals.EnableStoreWrite {
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
"outSystemId": utils.Int2Str(int(store.ID)),
|
"outSystemId": utils.Int2Str(int(store.ID)),
|
||||||
"stationName": store.Name,
|
"stationName": store.Name,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ autonaviKey = "4427170f870af2110becb8852d36ab08"
|
|||||||
|
|
||||||
generateLegacyJxOrder = false
|
generateLegacyJxOrder = false
|
||||||
enableStore = true
|
enableStore = true
|
||||||
|
enableStoreWrite = false
|
||||||
|
|
||||||
aliKey = "LTAI6xJUGaP6WdMQ"
|
aliKey = "LTAI6xJUGaP6WdMQ"
|
||||||
aliSecret = "CLmx5T93Bgi89EGAxWM4RTAXUsiHbM"
|
aliSecret = "CLmx5T93Bgi89EGAxWM4RTAXUsiHbM"
|
||||||
@@ -42,7 +43,7 @@ dadaSourceID = "73753"
|
|||||||
weixinAppID = "wxbf235770edaabc5c"
|
weixinAppID = "wxbf235770edaabc5c"
|
||||||
weixinSecret = "ba32b269a068a5b72486a0beafd171e8"
|
weixinSecret = "ba32b269a068a5b72486a0beafd171e8"
|
||||||
|
|
||||||
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8&loc=Local&parseTime=true"
|
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
|
|
||||||
[prod]
|
[prod]
|
||||||
freshFoodServerURL = "http://portal.int.jxc4.com"
|
freshFoodServerURL = "http://portal.int.jxc4.com"
|
||||||
@@ -66,7 +67,7 @@ dadaSourceID = "6660"
|
|||||||
weixinAppID = "wx2bb99eb5d2c9b82c"
|
weixinAppID = "wx2bb99eb5d2c9b82c"
|
||||||
weixinSecret = "6bbbed1443cc062c20a015a64c07a531"
|
weixinSecret = "6bbbed1443cc062c20a015a64c07a531"
|
||||||
|
|
||||||
dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxd_dev_0?charset=utf8&loc=Local&parseTime=true"
|
dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
|
|
||||||
enableStore = false
|
enableStore = false
|
||||||
|
|
||||||
@@ -92,4 +93,4 @@ dadaSourceID = "6660"
|
|||||||
weixinAppID = "wx2bb99eb5d2c9b82c"
|
weixinAppID = "wx2bb99eb5d2c9b82c"
|
||||||
weixinSecret = "6bbbed1443cc062c20a015a64c07a531"
|
weixinSecret = "6bbbed1443cc062c20a015a64c07a531"
|
||||||
|
|
||||||
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8&loc=Local&parseTime=true"
|
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,12 +15,16 @@ type SkuController struct {
|
|||||||
// @Description 得到厂商商品类别(区别于商家SKU类别)
|
// @Description 得到厂商商品类别(区别于商家SKU类别)
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param vendorID query int true "厂商ID"
|
// @Param vendorID query int true "厂商ID"
|
||||||
|
// @Param parentID query int false "父ID,-1表示所有,缺省为-1"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /GetVendorCategories [get]
|
// @router /GetVendorCategories [get]
|
||||||
func (c *SkuController) GetVendorCategories() {
|
func (c *SkuController) GetVendorCategories() {
|
||||||
c.callGetVendorCategories(func(params *tSkuGetVendorCategoriesParams) (retVal interface{}, errCode string, err error) {
|
c.callGetVendorCategories(func(params *tSkuGetVendorCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = cms.GetVendorCategories(params.VendorID)
|
if c.GetString("parentID") == "" {
|
||||||
|
params.ParentID = -1
|
||||||
|
}
|
||||||
|
retVal, err = cms.GetVendorCategories(params.VendorID, params.ParentID)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -35,3 +41,73 @@ func (c *SkuController) GetSkuMetaInfo() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 得到商品类别
|
||||||
|
// @Description 得到商品类别(区别于厂商家SKU类别)
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param parentID query int false "父ID,-1表示所有,缺省为-1"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetCategories [get]
|
||||||
|
func (c *SkuController) GetCategories() {
|
||||||
|
c.callGetCategories(func(params *tSkuGetCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
if c.GetString("parentID") == "" {
|
||||||
|
params.ParentID = -1
|
||||||
|
}
|
||||||
|
retVal, err = cms.GetCategories(params.ParentID)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 新增商品类别
|
||||||
|
// @Description 新增商品类别(区别于厂商家SKU类别)
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param payload formData string true "json数据,skuCategory对象()"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /AddCategory [post]
|
||||||
|
func (c *SkuController) AddCategory() {
|
||||||
|
c.callAddCategory(func(params *tSkuAddCategoryParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
cat := &model.SkuCategory{}
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), cat); err == nil {
|
||||||
|
retVal, err = cms.AddCategory(cat, GetUserNameFromToken(params.Token))
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 修改商品类别
|
||||||
|
// @Description 修改商品类别(区别于厂商家SKU类别)
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param categoryID formData int true "类别ID,payload中的相应字段会被忽略"
|
||||||
|
// @Param payload formData string true "json数据,skuCategory对象()"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /UpdateCategory [put]
|
||||||
|
func (c *SkuController) UpdateCategory() {
|
||||||
|
c.callUpdateCategory(func(params *tSkuUpdateCategoryParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
payload := make(map[string]interface{})
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
||||||
|
retVal, err = cms.UpdateCategory(params.CategoryID, payload, GetUserNameFromToken(params.Token))
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 商品类别重排序
|
||||||
|
// @Description 商品类别重排序(区别于厂商家SKU类别)
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param categoryID formData int true "父ID"
|
||||||
|
// @Param ids formData string true "同一父类别下的所有子类别ID列表([1,2,3,4])"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /ReorderCategories [put]
|
||||||
|
func (c *SkuController) ReorderCategories() {
|
||||||
|
c.callReorderCategories(func(params *tSkuReorderCategoriesParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
var idList []int
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params.Ids), &idList); err == nil {
|
||||||
|
err = cms.ReorderCategories(params.CategoryID, idList, GetUserNameFromToken(params.Token))
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package beegodb
|
|||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/jx-callback/business/legacymodel"
|
"git.rosy.net.cn/jx-callback/business/legacymodel"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
)
|
)
|
||||||
@@ -24,6 +25,7 @@ func Init() {
|
|||||||
orm.RegisterModel(new(legacymodel.Jxorder2))
|
orm.RegisterModel(new(legacymodel.Jxorder2))
|
||||||
orm.RegisterModel(new(legacymodel.Jxordersku2))
|
orm.RegisterModel(new(legacymodel.Jxordersku2))
|
||||||
|
|
||||||
|
if globals.EnableStore {
|
||||||
orm.RegisterModel(&model.Place{})
|
orm.RegisterModel(&model.Place{})
|
||||||
orm.RegisterModel(&model.Store{}, &model.StoreSub{}, &model.StoreMap{})
|
orm.RegisterModel(&model.Store{}, &model.StoreSub{}, &model.StoreMap{})
|
||||||
orm.RegisterModel(&model.SkuVendorCategory{}, &model.StoreSkuCategoryMap{}, &model.SkuName{}, &model.Sku{}, &model.SkuNamePlaceBind{}, &model.StoreSkuBind{})
|
orm.RegisterModel(&model.SkuVendorCategory{}, &model.StoreSkuCategoryMap{}, &model.SkuName{}, &model.Sku{}, &model.SkuNamePlaceBind{}, &model.StoreSkuBind{})
|
||||||
@@ -31,6 +33,7 @@ func Init() {
|
|||||||
orm.RegisterModel(&model.SkuCategory{})
|
orm.RegisterModel(&model.SkuCategory{})
|
||||||
orm.RegisterModel(&model.WeiXins{}, &model.JxBackendUser{})
|
orm.RegisterModel(&model.WeiXins{}, &model.JxBackendUser{})
|
||||||
orm.RegisterModel(&model.DurableTask{}, &model.DurableTaskItem{})
|
orm.RegisterModel(&model.DurableTask{}, &model.DurableTaskItem{})
|
||||||
|
}
|
||||||
// create table
|
// create table
|
||||||
orm.RunSyncdb("default", false, true)
|
orm.RunSyncdb("default", false, true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ var (
|
|||||||
|
|
||||||
AliKey string
|
AliKey string
|
||||||
AliSecret string
|
AliSecret string
|
||||||
|
|
||||||
|
EnableStore bool
|
||||||
|
EnableStoreWrite bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -59,4 +62,7 @@ func Init() {
|
|||||||
|
|
||||||
AliKey = beego.AppConfig.DefaultString("aliKey", "")
|
AliKey = beego.AppConfig.DefaultString("aliKey", "")
|
||||||
AliSecret = beego.AppConfig.DefaultString("aliSecret", "")
|
AliSecret = beego.AppConfig.DefaultString("aliSecret", "")
|
||||||
|
|
||||||
|
EnableStore = beego.AppConfig.DefaultBool("enableStore", false)
|
||||||
|
EnableStoreWrite = beego.AppConfig.DefaultBool("enableStoreWrite", false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,22 @@ func init() {
|
|||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Params: 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: "AddCategory",
|
||||||
|
Router: `/AddCategory`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
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: "GetCategories",
|
||||||
|
Router: `/GetCategories`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetSkuMetaInfo",
|
Method: "GetSkuMetaInfo",
|
||||||
@@ -143,6 +159,22 @@ func init() {
|
|||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Params: 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: "ReorderCategories",
|
||||||
|
Router: `/ReorderCategories`,
|
||||||
|
AllowHTTPMethods: []string{"put"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
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: "UpdateCategory",
|
||||||
|
Router: `/UpdateCategory`,
|
||||||
|
AllowHTTPMethods: []string{"put"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "AddStoreVendorMap",
|
Method: "AddStoreVendorMap",
|
||||||
|
|||||||
Reference in New Issue
Block a user