- cms store management.
This commit is contained in:
@@ -2,14 +2,26 @@ package cms
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/basesch"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals/gormdb"
|
||||
)
|
||||
|
||||
type StoreExt struct {
|
||||
*model.Store
|
||||
CityName string `json:"cityName"`
|
||||
DistrictName string `json:"districtName"`
|
||||
}
|
||||
|
||||
var (
|
||||
ErrMissingInput = errors.New("没有有效的输入参数")
|
||||
ErrCanNotVendor = errors.New("vendorID参数不合法")
|
||||
)
|
||||
|
||||
func GetPlaces(parentCode int, vendorID int, includeDisabled bool) ([]*model.Place, error) {
|
||||
@@ -47,3 +59,145 @@ func UpdatePlaces(places []*model.Place, userName string) (err error) {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetStores(params map[string]interface{}, offset, pageSize int) (retVal []*StoreExt, err error) {
|
||||
sql := `
|
||||
SELECT t1.*, city.name city_name, district.name district_name
|
||||
FROM store t1
|
||||
LEFT JOIN place city ON t1.city_code = city.code AND city.level = 2
|
||||
LEFT JOIN place district ON t1.district_code = district.code AND district.level = 3
|
||||
WHERE 1 = 1`
|
||||
|
||||
params2 := make([]interface{}, 0)
|
||||
if params["id"] != nil {
|
||||
sql += " AND t1.id = ?"
|
||||
params2 = append(params2, params["id"].(int))
|
||||
}
|
||||
if params["name"] != nil {
|
||||
sql += " AND t1.name LIKE ?"
|
||||
params2 = append(params2, "%"+params["name"].(string)+"%")
|
||||
}
|
||||
if params["placeID"] != nil {
|
||||
level := 2
|
||||
if params["placeLevel"] != nil {
|
||||
level = params["placeLevel"].(int)
|
||||
}
|
||||
if level == 2 {
|
||||
sql += " AND t1.city_code = ?"
|
||||
} else {
|
||||
sql += " AND t1.district_code = ?"
|
||||
}
|
||||
params2 = append(params2, params["placeID"].(int))
|
||||
}
|
||||
if params["address"] != nil {
|
||||
sql += " AND t1.address LIKE ?"
|
||||
params2 = append(params2, "%"+params["address"].(string)+"%")
|
||||
}
|
||||
if params["tel"] != nil {
|
||||
sql += " AND (t1.tel1 LIKE ? OR t1.tel2 LIKE ?)"
|
||||
params2 = append(params2, "%"+params["tel"].(string)+"%")
|
||||
params2 = append(params2, "%"+params["tel"].(string)+"%")
|
||||
}
|
||||
if params["fromStatus"] != nil {
|
||||
fromStatus := params["fromStatus"].(int)
|
||||
toStatus := fromStatus
|
||||
if params["toStatus"] != nil {
|
||||
toStatus = params["toStatus"].(int)
|
||||
}
|
||||
sql += " AND t1.status >= ? AND t1.status <= ?"
|
||||
params2 = append(params2, fromStatus, toStatus)
|
||||
}
|
||||
sql += `
|
||||
ORDER BY id
|
||||
LIMIT ? OFFSET ?`
|
||||
if pageSize == 0 {
|
||||
pageSize = model.DefPageSize
|
||||
}
|
||||
if offset < 0 {
|
||||
offset = 0
|
||||
}
|
||||
params2 = append(params2, pageSize, offset)
|
||||
|
||||
err = dao.GetRows(nil, &retVal, sql, params2...)
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func SearchStores(keyword string, fromStatus, toStatus int, offset, pageSize int) (retVal []*StoreExt, err error) {
|
||||
sql := `
|
||||
SELECT t1.*, city.name city_name, district.name district_name
|
||||
FROM store t1
|
||||
LEFT JOIN place city ON t1.city_code = city.code AND city.level = 2
|
||||
LEFT JOIN place district ON t1.district_code = district.code AND district.level = 3
|
||||
WHERE t1.name LIKE ? OR t1.address LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.last_operator LIKE ?`
|
||||
keywordLike := "%" + keyword + "%"
|
||||
params := []interface{}{keywordLike, keywordLike, keywordLike, keywordLike, keywordLike}
|
||||
|
||||
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
|
||||
sql += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ? OR t1.lng = ? OR t1.lat = ?"
|
||||
params = append(params, keywordInt64, keywordInt64, keywordInt64, keywordInt64, keywordInt64)
|
||||
}
|
||||
|
||||
sql += " AND t1.status >= ? AND t1.status <= ?"
|
||||
params = append(params, fromStatus, toStatus)
|
||||
|
||||
sql += `
|
||||
ORDER BY id
|
||||
LIMIT ? OFFSET ?`
|
||||
if pageSize == 0 {
|
||||
pageSize = model.DefPageSize
|
||||
}
|
||||
if offset < 0 {
|
||||
offset = 0
|
||||
}
|
||||
params = append(params, pageSize, offset)
|
||||
|
||||
err = dao.GetRows(nil, &retVal, sql, params...)
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func GetVendorStore(vendorStoreID string, vendorID int) (retVal *StoreExt, err error) {
|
||||
handler := basesch.FixedBaseScheduler.GetPurchasePlatformFromVendorID(vendorID)
|
||||
if handler != nil {
|
||||
result, err2 := handler.ReadStore(vendorStoreID)
|
||||
if err = err2; err == nil {
|
||||
retVal = &StoreExt{
|
||||
Store: result,
|
||||
}
|
||||
db := gormdb.GetDB()
|
||||
if city, err2 := dao.GetPlaceByCode(db, result.CityCode); err2 == nil {
|
||||
retVal.CityName = city.Name
|
||||
}
|
||||
if district, err2 := dao.GetPlaceByCode(db, result.DistrictCode); err2 == nil {
|
||||
retVal.DistrictName = district.Name
|
||||
}
|
||||
return retVal, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return nil, ErrCanNotVendor
|
||||
}
|
||||
|
||||
func UpdateStore(params map[string]interface{}, userName string) (err error) {
|
||||
store := &model.Store{}
|
||||
if params["id"] == nil {
|
||||
return ErrMissingInput
|
||||
}
|
||||
params["lastOperator"] = userName
|
||||
params["updatedAt"] = time.Now()
|
||||
|
||||
store.ID = int(utils.MustInterface2Int64(params["id"]))
|
||||
valid, _ := jxutils.FilterMapByStructObject(params, &model.Store{})
|
||||
err = dao.UpdateEntity(nil, store, valid)
|
||||
return err
|
||||
}
|
||||
|
||||
func CreateStore(store *model.Store, userName string) (id int, err error) {
|
||||
store.ID = 0
|
||||
store.LastOperator = userName
|
||||
store.CreatedAt = time.Now()
|
||||
store.UpdatedAt = store.CreatedAt
|
||||
if err = dao.CreateEntity(nil, store); err == nil {
|
||||
return store.ID, nil
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/baseapi/utils/routinepool"
|
||||
@@ -268,3 +270,17 @@ func SplitSkuName(skuName string) (prefix, name, comment, specUnit, unit string,
|
||||
}
|
||||
return prefix, name, comment, specUnit, unit, specQuality
|
||||
}
|
||||
|
||||
func FilterMapByStructObject(mapData map[string]interface{}, obj interface{}) (valid map[string]interface{}, invalid map[string]interface{}) {
|
||||
m := structs.Map(obj)
|
||||
valid = make(map[string]interface{})
|
||||
invalid = make(map[string]interface{})
|
||||
for k, v := range mapData {
|
||||
if m[k] != nil {
|
||||
valid[k] = v
|
||||
} else {
|
||||
invalid[k] = v
|
||||
}
|
||||
}
|
||||
return valid, invalid
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
DefPageSize = 50
|
||||
)
|
||||
|
||||
type GoodsOrderExt struct {
|
||||
GoodsOrder
|
||||
WaybillStatus int `json:"waybillStatus"`
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -20,7 +19,6 @@ func GetRows(db *gorm.DB, inPtr interface{}, sql string, values ...interface{})
|
||||
}
|
||||
typeInfo := topTypeInfo.Elem()
|
||||
if typeInfo.Kind() != reflect.Slice {
|
||||
fmt.Printf("type:%s", typeInfo.String())
|
||||
panic("SelectEntities inPtr should be slice ptr (*[]Type)")
|
||||
}
|
||||
elmType := typeInfo.Elem()
|
||||
@@ -47,7 +45,7 @@ func GetRows(db *gorm.DB, inPtr interface{}, sql string, values ...interface{})
|
||||
return err
|
||||
}
|
||||
|
||||
func GetEntity(item interface{}, db *gorm.DB) error {
|
||||
func GetEntity(db *gorm.DB, item interface{}) error {
|
||||
if db == nil {
|
||||
db = gormdb.GetDB()
|
||||
}
|
||||
@@ -57,6 +55,26 @@ func GetEntity(item interface{}, db *gorm.DB) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateEntity(db *gorm.DB, item interface{}, values map[string]interface{}) error {
|
||||
if db == nil {
|
||||
db = gormdb.GetDB()
|
||||
}
|
||||
err := utils.CallFuncLogError(func() error {
|
||||
return db.Model(item).Updates(values).Error
|
||||
}, reflect.TypeOf(item).Name())
|
||||
return err
|
||||
}
|
||||
|
||||
func CreateEntity(db *gorm.DB, item interface{}) error {
|
||||
if db == nil {
|
||||
db = gormdb.GetDB()
|
||||
}
|
||||
err := utils.CallFuncLogError(func() error {
|
||||
return db.Create(item).Error
|
||||
}, reflect.TypeOf(item).Name())
|
||||
return err
|
||||
}
|
||||
|
||||
func GetSellCities(skuNameID int, vendorID int, db *gorm.DB) (cities []*model.Place, err error) {
|
||||
cities = []*model.Place{}
|
||||
sql := `
|
||||
@@ -71,3 +89,32 @@ func GetSellCities(skuNameID int, vendorID int, db *gorm.DB) (cities []*model.Pl
|
||||
}
|
||||
return cities, GetRows(nil, &cities, sql, skuNameID)
|
||||
}
|
||||
|
||||
func GetPlaceByCode(db *gorm.DB, code int) (place *model.Place, err error) {
|
||||
if db == nil {
|
||||
db = gormdb.GetDB()
|
||||
}
|
||||
place = new(model.Place)
|
||||
err = db.Where("code = ?", code).First(place).Error
|
||||
return place, err
|
||||
}
|
||||
|
||||
func GetPlaceByName(db *gorm.DB, name string, level int, parentCode int) (place *model.Place, err error) {
|
||||
if db == nil {
|
||||
db = gormdb.GetDB()
|
||||
}
|
||||
place = new(model.Place)
|
||||
if err = db.Where("parent_code = ? AND level = ? AND name = ?", parentCode, level, name).First(place).Error; err == gorm.ErrRecordNotFound {
|
||||
err = db.Where("parent_code = ? AND level = ? AND name LIKE ?", parentCode, level, "%"+name+"%").First(place).Error
|
||||
}
|
||||
return place, err
|
||||
}
|
||||
|
||||
func GetPlaceByJdCode(db *gorm.DB, jdCode int) (place *model.Place, err error) {
|
||||
if db == nil {
|
||||
db = gormdb.GetDB()
|
||||
}
|
||||
place = new(model.Place)
|
||||
err = db.Where("jd_code = ?", jdCode).First(place).Error
|
||||
return place, err
|
||||
}
|
||||
|
||||
@@ -34,3 +34,11 @@ func TestSelectEntities(t *testing.T) {
|
||||
|
||||
globals.SugarLogger.Debug(utils.Format4Output(places, false))
|
||||
}
|
||||
|
||||
func TestGetPlaceByName(t *testing.T) {
|
||||
result, err := GetPlaceByName(nil, "青羊", 3, 510100)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(result)
|
||||
}
|
||||
|
||||
@@ -19,21 +19,21 @@ const (
|
||||
|
||||
type Store struct {
|
||||
ModelIDCUO
|
||||
Name string `gorm:"type:varchar(255);unique_index"`
|
||||
CityCode int // todo ?
|
||||
DistrictCode int // todo ?
|
||||
Address string `gorm:"type:varchar(255)"`
|
||||
Tel1 string `gorm:"type:varchar(32)"`
|
||||
Tel2 string `gorm:"type:varchar(32)"`
|
||||
OpenTime1 int16 // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有
|
||||
CloseTime1 int16 // 格式同上
|
||||
OpenTime2 int16 // 格式同上
|
||||
CloseTime2 int16 // 格式同上
|
||||
Lng int // 乘了10的6次方
|
||||
Lat int // 乘了10的6次方
|
||||
DeliveryRangeType int8 // 参见相关常量定义
|
||||
DeliveryRange string `gorm:"type:varchar(2048)"` // 如果DeliveryRangeType为DeliveryRangeTypePolygon,则为逗号分隔坐标,分号分隔的坐标点(坐标与Lng和Lat一样,都是整数),比如 121361504,31189308;121420555,31150238。否则为半径,单位为米
|
||||
Status int
|
||||
Name string `gorm:"type:varchar(255);unique_index" json:"name"`
|
||||
CityCode int `json:"cityCode"` // todo ?
|
||||
DistrictCode int `json:"districtCode"` // todo ?
|
||||
Address string `gorm:"type:varchar(255)" json:"address"`
|
||||
Tel1 string `gorm:"type:varchar(32)" json:"tel1"`
|
||||
Tel2 string `gorm:"type:varchar(32)" json:"tel2"`
|
||||
OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有
|
||||
CloseTime1 int16 `json:"closeTime1"` // 格式同上
|
||||
OpenTime2 int16 `json:"openTime2"` // 格式同上
|
||||
CloseTime2 int16 `json:"closeTime2"` // 格式同上
|
||||
Lng int `json:"lng"` // 乘了10的6次方
|
||||
Lat int `json:"lat"` // 乘了10的6次方
|
||||
DeliveryRangeType int8 `json:"deliveryRangeType"` // 参见相关常量定义
|
||||
DeliveryRange string `gorm:"type:varchar(2048)" json:"deliveryRange"` // 如果DeliveryRangeType为DeliveryRangeTypePolygon,则为逗号分隔坐标,分号分隔的坐标点(坐标与Lng和Lat一样,都是整数),比如 121361504,31189308;121420555,31150238。否则为半径,单位为米
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
type StoreSub struct {
|
||||
|
||||
@@ -54,6 +54,9 @@ type IPurchasePlatformHandler interface {
|
||||
|
||||
// 完全自送的门店表示配送完成
|
||||
SelfDeliverDelievered(order *model.GoodsOrder, userName string) (err error)
|
||||
|
||||
////////
|
||||
ReadStore(vendorStoreID string) (store *model.Store, err error)
|
||||
}
|
||||
|
||||
type IDeliveryPlatformHandler interface {
|
||||
|
||||
7
business/partner/purchase/elm/store.go
Normal file
7
business/partner/purchase/elm/store.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package elm
|
||||
|
||||
import "git.rosy.net.cn/jx-callback/business/model"
|
||||
|
||||
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
package jd
|
||||
|
||||
// 这里函数取得的信息,除了与自身实体相关的ID(比如PARENT ID),都已经转换成了本地ID了
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/gormdb"
|
||||
)
|
||||
|
||||
const (
|
||||
DefBrandID = 35247
|
||||
DefJdCategoryID = 20362
|
||||
)
|
||||
|
||||
type skuInfoExt struct {
|
||||
model.SkuName
|
||||
Img string
|
||||
JdID int64 // 商家类别
|
||||
JdCategoryID int // 到家类别
|
||||
SkuCatID int64 // 商家特殊类别
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateCategory(cat *model.SkuCategory, userName string) (err error) {
|
||||
var jdPid int64
|
||||
if cat.ParentID != 0 {
|
||||
pCat := &model.SkuCategory{}
|
||||
pCat.ID = cat.ParentID
|
||||
if err = dao.GetEntity(pCat, nil); err == nil {
|
||||
jdPid = pCat.JdID
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
result, err := api.JdAPI.AddShopCategory(jdPid, cat.Name, int(cat.Level), cat.Seq, userName)
|
||||
if err == nil {
|
||||
cat.JdID = utils.Str2Int64(result)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadCategory(vendorCatID string) (cat *model.SkuCategory, err error) {
|
||||
result, err := p.ReadCategories()
|
||||
if err == nil {
|
||||
jdID := utils.Str2Int64(vendorCatID)
|
||||
for _, v := range result {
|
||||
if v.JdID == jdID {
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadCategories() (cats []*model.SkuCategory, err error) {
|
||||
result, err := api.JdAPI.QueryCategoriesByOrgCode()
|
||||
if err == nil {
|
||||
cats = make([]*model.SkuCategory, len(result))
|
||||
for k, v := range result {
|
||||
cats[k] = &model.SkuCategory{
|
||||
ParentID: int(v.ParentId), // 这里是暂存,传递数据用,正确的值应该是本地的ID
|
||||
Name: v.Name,
|
||||
Level: int8(v.Level),
|
||||
Seq: v.Sort,
|
||||
JdID: v.Id,
|
||||
}
|
||||
}
|
||||
return cats, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateCategory(cat *model.SkuCategory) error {
|
||||
return api.JdAPI.UpdateShopCategory(cat.JdID, cat.Name)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteCategory(cat *model.SkuCategory) error {
|
||||
return api.JdAPI.DelShopCategory(cat.JdID)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) cuSku(sku *model.Sku, handler func(skuExt *skuInfoExt, skuName string, shopCategories []int64, addParams map[string]interface{}) (string, error)) (err error) {
|
||||
var otherInfo skuInfoExt
|
||||
db := gormdb.GetDB()
|
||||
err = db.Raw(`
|
||||
SELECT t2.*, t3.jd_id, t3.jd_category_id, t4.jd_id sku_cat_id
|
||||
FROM sku t1
|
||||
JOIN sku_name t2 ON t1.name_id = t2.id
|
||||
JOIN sku_category t3 ON t2.category_id = t3.id
|
||||
LEFT JOIN sku_category t4 ON t1.category_id = t4.id
|
||||
WHERE t1.id = ?
|
||||
`, sku.ID).Scan(&otherInfo).Error
|
||||
if err == nil {
|
||||
shopCategories := []int64{otherInfo.JdID}
|
||||
if otherInfo.SkuCatID != 0 {
|
||||
shopCategories = append(shopCategories, otherInfo.SkuCatID)
|
||||
}
|
||||
if otherInfo.JdCategoryID == 0 {
|
||||
otherInfo.JdCategoryID = DefJdCategoryID
|
||||
}
|
||||
if otherInfo.BrandID == 0 {
|
||||
otherInfo.BrandID = DefBrandID
|
||||
}
|
||||
addParams := map[string]interface{}{}
|
||||
|
||||
if otherInfo.IsGlobal == 0 { //如果不是全国可售,要查可售区域
|
||||
sellPlaces, err2 := dao.GetSellCities(otherInfo.ID, model.VendorIDJD, db)
|
||||
if err = err2; err == nil && len(sellPlaces) > 0 {
|
||||
sellCites := make([]int, len(sellPlaces))
|
||||
for k, v := range sellPlaces {
|
||||
sellCites[k] = v.JdCode
|
||||
}
|
||||
addParams["sellCities"] = sellCites
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
skuName := jxutils.ComposeSkuName(otherInfo.Prefix, otherInfo.Name, otherInfo.Comment, otherInfo.Unit, sku.SpecQuality, sku.SpecUnit, 0)
|
||||
globals.SugarLogger.Debug(skuName)
|
||||
result, err2 := handler(&otherInfo, skuName, shopCategories, addParams)
|
||||
if err = err2; err == nil {
|
||||
sku.JdID = utils.Str2Int64(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateSku(sku *model.Sku) (err error) {
|
||||
return p.cuSku(sku, func(skuExt *skuInfoExt, skuName string, shopCategories []int64, addParams map[string]interface{}) (string, error) {
|
||||
return api.JdAPI.AddSku(utils.Int2Str(sku.ID), skuExt.JdCategoryID, shopCategories, skuExt.BrandID, skuName, skuExt.Price, jxutils.IntWeight2Float(sku.Weight), []string{skuExt.Img}, 1, true, addParams)
|
||||
})
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadSku(vendorSkuID string) (skuName *model.SkuName, sellPlaces []*model.Place, sku *model.Sku, err error) {
|
||||
result, _, err := api.JdAPI.QuerySkuInfos("", int(utils.Str2Int64(vendorSkuID)), 0, 0, false)
|
||||
if err == nil {
|
||||
if len(result) == 1 {
|
||||
mapData := result[0]
|
||||
skuNameStr := utils.Interface2String(mapData["skuName"])
|
||||
prefix, name, comment, specUnit, unit, specQuality := jxutils.SplitSkuName(skuNameStr)
|
||||
if name == "" {
|
||||
name = skuNameStr
|
||||
unit = "份"
|
||||
specUnit = "g"
|
||||
}
|
||||
skuName = &model.SkuName{
|
||||
Prefix: prefix,
|
||||
Name: name,
|
||||
Comment: comment,
|
||||
Unit: unit,
|
||||
Price: int(utils.MustInterface2Int64(mapData["skuPrice"])),
|
||||
}
|
||||
sku = &model.Sku{
|
||||
SpecQuality: specQuality,
|
||||
SpecUnit: specUnit,
|
||||
Weight: jxutils.FloatWeight2Int(float32(utils.MustInterface2Float64(mapData["weight"]))),
|
||||
JdID: utils.MustInterface2Int64(mapData["skuId"]),
|
||||
}
|
||||
sku.ID = int(utils.Str2Int64(utils.Interface2String(mapData["outSkuId"])))
|
||||
|
||||
db := gormdb.GetDB()
|
||||
shopCategories := utils.Interface2Int64List(mapData["shopCategories"])
|
||||
if len(shopCategories) > 0 {
|
||||
skuCat := &model.SkuCategory{}
|
||||
if db.Where("jd_id = ?", shopCategories[0]).Find(skuCat).Error == nil {
|
||||
skuName.CategoryID = skuCat.ID
|
||||
}
|
||||
}
|
||||
sellCities := utils.Interface2Int64List(mapData["sellCities"])
|
||||
if len(sellCities) == 0 {
|
||||
skuName.IsGlobal = 1
|
||||
} else {
|
||||
sellPlaces = make([]*model.Place, 0)
|
||||
err2 := db.Where("jd_code IN (?) AND level = 2", sellCities).Find(&sellPlaces).Error
|
||||
globals.SugarLogger.Debug("err2:%v", err2)
|
||||
}
|
||||
return skuName, sellPlaces, sku, nil
|
||||
}
|
||||
}
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateSku(sku *model.Sku) (err error) {
|
||||
return p.cuSku(sku, func(skuExt *skuInfoExt, skuName string, shopCategories []int64, addParams map[string]interface{}) (string, error) {
|
||||
params := utils.MergeMaps(addParams)
|
||||
params["categoryId"] = skuExt.JdCategoryID
|
||||
params["shopCategories"] = shopCategories
|
||||
params["brandId"] = skuExt.BrandID
|
||||
params["skuName"] = skuName
|
||||
params["weight"] = jxutils.IntWeight2Float(sku.Weight)
|
||||
params["images"] = []string{skuExt.Img}
|
||||
|
||||
return api.JdAPI.UpdateSku(utils.Int2Str(sku.ID), params)
|
||||
})
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteSku(sku *model.Sku) (err error) {
|
||||
params := map[string]interface{}{
|
||||
"fixedStatus": 4,
|
||||
}
|
||||
_, err = api.JdAPI.UpdateSku(utils.Int2Str(sku.ID), params)
|
||||
return err
|
||||
}
|
||||
@@ -1,13 +1,206 @@
|
||||
package jd
|
||||
|
||||
// 这里函数取得的信息,除了与自身实体相关的ID(比如PARENT ID),都已经转换成了本地ID了
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/gormdb"
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) AddSku(sku *model.Sku) error {
|
||||
// params := map[string]interface{}{
|
||||
// "outSkuId": utils.Int2Str(int(sku.ID)),
|
||||
// "categoryId": skuman.GetJdCategoryID(sku),
|
||||
// }
|
||||
return nil
|
||||
const (
|
||||
DefBrandID = 35247
|
||||
DefJdCategoryID = 20362
|
||||
)
|
||||
|
||||
type skuInfoExt struct {
|
||||
model.SkuName
|
||||
Img string
|
||||
JdID int64 // 商家类别
|
||||
JdCategoryID int // 到家类别
|
||||
SkuCatID int64 // 商家特殊类别
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateCategory(cat *model.SkuCategory, userName string) (err error) {
|
||||
var jdPid int64
|
||||
if cat.ParentID != 0 {
|
||||
pCat := &model.SkuCategory{}
|
||||
pCat.ID = cat.ParentID
|
||||
if err = dao.GetEntity(nil, pCat); err == nil {
|
||||
jdPid = pCat.JdID
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
result, err := api.JdAPI.AddShopCategory(jdPid, cat.Name, int(cat.Level), cat.Seq, userName)
|
||||
if err == nil {
|
||||
cat.JdID = utils.Str2Int64(result)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadCategory(vendorCatID string) (cat *model.SkuCategory, err error) {
|
||||
result, err := p.ReadCategories()
|
||||
if err == nil {
|
||||
jdID := utils.Str2Int64(vendorCatID)
|
||||
for _, v := range result {
|
||||
if v.JdID == jdID {
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadCategories() (cats []*model.SkuCategory, err error) {
|
||||
result, err := api.JdAPI.QueryCategoriesByOrgCode()
|
||||
if err == nil {
|
||||
cats = make([]*model.SkuCategory, len(result))
|
||||
for k, v := range result {
|
||||
cats[k] = &model.SkuCategory{
|
||||
ParentID: int(v.ParentId), // 这里是暂存,传递数据用,正确的值应该是本地的ID
|
||||
Name: v.Name,
|
||||
Level: int8(v.Level),
|
||||
Seq: v.Sort,
|
||||
JdID: v.Id,
|
||||
}
|
||||
}
|
||||
return cats, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateCategory(cat *model.SkuCategory) error {
|
||||
return api.JdAPI.UpdateShopCategory(cat.JdID, cat.Name)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteCategory(cat *model.SkuCategory) error {
|
||||
return api.JdAPI.DelShopCategory(cat.JdID)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) cuSku(sku *model.Sku, handler func(skuExt *skuInfoExt, skuName string, shopCategories []int64, addParams map[string]interface{}) (string, error)) (err error) {
|
||||
var otherInfo skuInfoExt
|
||||
db := gormdb.GetDB()
|
||||
err = db.Raw(`
|
||||
SELECT t2.*, t3.jd_id, t3.jd_category_id, t4.jd_id sku_cat_id
|
||||
FROM sku t1
|
||||
JOIN sku_name t2 ON t1.name_id = t2.id
|
||||
JOIN sku_category t3 ON t2.category_id = t3.id
|
||||
LEFT JOIN sku_category t4 ON t1.category_id = t4.id
|
||||
WHERE t1.id = ?
|
||||
`, sku.ID).Scan(&otherInfo).Error
|
||||
if err == nil {
|
||||
shopCategories := []int64{otherInfo.JdID}
|
||||
if otherInfo.SkuCatID != 0 {
|
||||
shopCategories = append(shopCategories, otherInfo.SkuCatID)
|
||||
}
|
||||
if otherInfo.JdCategoryID == 0 {
|
||||
otherInfo.JdCategoryID = DefJdCategoryID
|
||||
}
|
||||
if otherInfo.BrandID == 0 {
|
||||
otherInfo.BrandID = DefBrandID
|
||||
}
|
||||
addParams := map[string]interface{}{}
|
||||
|
||||
if otherInfo.IsGlobal == 0 { //如果不是全国可售,要查可售区域
|
||||
sellPlaces, err2 := dao.GetSellCities(otherInfo.ID, model.VendorIDJD, db)
|
||||
if err = err2; err == nil && len(sellPlaces) > 0 {
|
||||
sellCites := make([]int, len(sellPlaces))
|
||||
for k, v := range sellPlaces {
|
||||
sellCites[k] = v.JdCode
|
||||
}
|
||||
addParams["sellCities"] = sellCites
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
skuName := jxutils.ComposeSkuName(otherInfo.Prefix, otherInfo.Name, otherInfo.Comment, otherInfo.Unit, sku.SpecQuality, sku.SpecUnit, 0)
|
||||
globals.SugarLogger.Debug(skuName)
|
||||
result, err2 := handler(&otherInfo, skuName, shopCategories, addParams)
|
||||
if err = err2; err == nil {
|
||||
sku.JdID = utils.Str2Int64(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateSku(sku *model.Sku) (err error) {
|
||||
return p.cuSku(sku, func(skuExt *skuInfoExt, skuName string, shopCategories []int64, addParams map[string]interface{}) (string, error) {
|
||||
return api.JdAPI.AddSku(utils.Int2Str(sku.ID), skuExt.JdCategoryID, shopCategories, skuExt.BrandID, skuName, skuExt.Price, jxutils.IntWeight2Float(sku.Weight), []string{skuExt.Img}, 1, true, addParams)
|
||||
})
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadSku(vendorSkuID string) (skuName *model.SkuName, sellPlaces []*model.Place, sku *model.Sku, err error) {
|
||||
result, _, err := api.JdAPI.QuerySkuInfos("", int(utils.Str2Int64(vendorSkuID)), 0, 0, false)
|
||||
if err == nil {
|
||||
if len(result) == 1 {
|
||||
mapData := result[0]
|
||||
skuNameStr := utils.Interface2String(mapData["skuName"])
|
||||
prefix, name, comment, specUnit, unit, specQuality := jxutils.SplitSkuName(skuNameStr)
|
||||
if name == "" {
|
||||
name = skuNameStr
|
||||
unit = "份"
|
||||
specUnit = "g"
|
||||
}
|
||||
skuName = &model.SkuName{
|
||||
Prefix: prefix,
|
||||
Name: name,
|
||||
Comment: comment,
|
||||
Unit: unit,
|
||||
Price: int(utils.MustInterface2Int64(mapData["skuPrice"])),
|
||||
}
|
||||
sku = &model.Sku{
|
||||
SpecQuality: specQuality,
|
||||
SpecUnit: specUnit,
|
||||
Weight: jxutils.FloatWeight2Int(float32(utils.MustInterface2Float64(mapData["weight"]))),
|
||||
JdID: utils.MustInterface2Int64(mapData["skuId"]),
|
||||
}
|
||||
sku.ID = int(utils.Str2Int64(utils.Interface2String(mapData["outSkuId"])))
|
||||
|
||||
db := gormdb.GetDB()
|
||||
shopCategories := utils.Interface2Int64List(mapData["shopCategories"])
|
||||
if len(shopCategories) > 0 {
|
||||
skuCat := &model.SkuCategory{}
|
||||
if db.Where("jd_id = ?", shopCategories[0]).Find(skuCat).Error == nil {
|
||||
skuName.CategoryID = skuCat.ID
|
||||
}
|
||||
}
|
||||
sellCities := utils.Interface2Int64List(mapData["sellCities"])
|
||||
if len(sellCities) == 0 {
|
||||
skuName.IsGlobal = 1
|
||||
} else {
|
||||
sellPlaces = make([]*model.Place, 0)
|
||||
err2 := db.Where("jd_code IN (?) AND level = 2", sellCities).Find(&sellPlaces).Error
|
||||
globals.SugarLogger.Debug("err2:%v", err2)
|
||||
}
|
||||
return skuName, sellPlaces, sku, nil
|
||||
}
|
||||
}
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateSku(sku *model.Sku) (err error) {
|
||||
return p.cuSku(sku, func(skuExt *skuInfoExt, skuName string, shopCategories []int64, addParams map[string]interface{}) (string, error) {
|
||||
params := utils.MergeMaps(addParams)
|
||||
params["categoryId"] = skuExt.JdCategoryID
|
||||
params["shopCategories"] = shopCategories
|
||||
params["brandId"] = skuExt.BrandID
|
||||
params["skuName"] = skuName
|
||||
params["weight"] = jxutils.IntWeight2Float(sku.Weight)
|
||||
params["images"] = []string{skuExt.Img}
|
||||
|
||||
return api.JdAPI.UpdateSku(utils.Int2Str(sku.ID), params)
|
||||
})
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteSku(sku *model.Sku) (err error) {
|
||||
params := map[string]interface{}{
|
||||
"fixedStatus": 4,
|
||||
}
|
||||
_, err = api.JdAPI.UpdateSku(utils.Int2Str(sku.ID), params)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ func TestCreateSku(t *testing.T) {
|
||||
skuID := 21741
|
||||
sku := &model.Sku{}
|
||||
sku.ID = skuID
|
||||
dao.GetEntity(sku, nil)
|
||||
dao.GetEntity(nil, sku)
|
||||
t.Log(sku)
|
||||
// err := new(PurchaseHandler).CreateSku(sku)
|
||||
// if err != nil {
|
||||
@@ -26,7 +26,7 @@ func TestUpdateSku(t *testing.T) {
|
||||
skuID := 21741
|
||||
sku := &model.Sku{}
|
||||
sku.ID = skuID
|
||||
dao.GetEntity(sku, nil)
|
||||
dao.GetEntity(nil, sku)
|
||||
|
||||
err := new(PurchaseHandler).UpdateSku(sku)
|
||||
if err != nil {
|
||||
@@ -5,10 +5,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/gormdb"
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error) {
|
||||
@@ -22,7 +24,25 @@ func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error)
|
||||
OpenTime2: JdOperationTime2JxOperationTime(result["serviceTimeStart2"]),
|
||||
CloseTime2: JdOperationTime2JxOperationTime(result["serviceTimeEnd2"]),
|
||||
Status: JdStoreStatus2JxStatus(result["yn"], result["closeStatus"]),
|
||||
Tel1: utils.Interface2String(result["phone"]),
|
||||
}
|
||||
tel2 := utils.Interface2String(result["mobile"])
|
||||
if tel2 != "" && tel2 != retVal.Tel1 {
|
||||
retVal.Tel2 = tel2
|
||||
}
|
||||
cityCode := int(utils.MustInterface2Int64(result["city"]))
|
||||
if cityCode != 0 {
|
||||
db := gormdb.GetDB()
|
||||
if city, err2 := dao.GetPlaceByJdCode(db, cityCode); err2 == nil {
|
||||
retVal.CityCode = city.Code
|
||||
districtName := utils.Interface2String(result["countyName"]) // 京东的市区号码与通用数据完全无法关联,只有通过名字来关联
|
||||
if district, err2 := dao.GetPlaceByName(db, districtName, 3, city.Code); err2 == nil {
|
||||
retVal.DistrictCode = district.Code
|
||||
}
|
||||
}
|
||||
}
|
||||
retVal.Lng = jxutils.StandardCoordinate2Int(utils.MustInterface2Float64(result["lng"]))
|
||||
retVal.Lat = jxutils.StandardCoordinate2Int(utils.MustInterface2Float64(result["lat"]))
|
||||
|
||||
retVal.ID = int(utils.Str2Int64WithDefault(utils.Interface2String(result["outSystemId"]), 0))
|
||||
result, err2 := api.JdAPI.GetDeliveryRangeByStationNo(vendorStoreID)
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestUpdateStore(t *testing.T) {
|
||||
|
||||
// result := &model.Store{}
|
||||
// result.ID = 100164
|
||||
// err := dao.GetEntity(result, nil)
|
||||
// err := dao.GetEntity(nil, result)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
|
||||
@@ -11,7 +11,7 @@ type SkuController struct {
|
||||
|
||||
// @Title 得到厂商商品类别
|
||||
// @Description 得到厂商商品类别(区别于商家SKU类别)
|
||||
// @Param token header string true "认证toke"
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorID query int true "厂商ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
@@ -25,7 +25,7 @@ func (c *SkuController) GetVendorCategories() {
|
||||
|
||||
// @Title 得到商品相关的一些基础信息
|
||||
// @Description 得到商品相关的一些基础信息,包括unit列表,specUnit列表
|
||||
// @Param token header string true "认证toke"
|
||||
// @Param token header string true "认证token"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetSkuMetaInfo [get]
|
||||
|
||||
@@ -15,7 +15,7 @@ type StoreController struct {
|
||||
|
||||
// @Title 得到地点(省,城市,区)信息
|
||||
// @Description parentCode与vendorID必传入一个,vendorID的意思是得到所有与这个厂商相关的城市列表
|
||||
// @Param token header string true "认证toke"
|
||||
// @Param token header string true "认证token"
|
||||
// @Param parentCode query int false "上级地点code。地点级别:省为1,市为2,区为3,缺省为市"
|
||||
// @Param vendorID query int false "得到所有与这个厂商相关的省与城市列表"
|
||||
// @Param includeDisabled query bool false "是否包括禁用的城市"
|
||||
@@ -37,7 +37,7 @@ func (c *StoreController) GetPlaces() {
|
||||
|
||||
// @Title 修改地点信息
|
||||
// @Description 只支持修改enabled, jd_code和mtps_price这三个属性
|
||||
// @Param token header string true "认证toke"
|
||||
// @Param token header string true "认证token"
|
||||
// @Param payload formData string true "json数据,place对象数组"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
@@ -50,3 +50,97 @@ func (c *StoreController) UpdatePlaces() {
|
||||
return nil, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到京西门店信息
|
||||
// @Description 得到京西门店信息,如下条件之间是与的关系
|
||||
// @Param token header string true "认证token"
|
||||
// @Param id query int false "门店ID"
|
||||
// @Param name query string false "门店名称(不要求完全一致)"
|
||||
// @Param placeID query int false "所属地点ID"
|
||||
// @Param placeLevel query int false "所属地点级别"
|
||||
// @Param address query string false "门店地址"
|
||||
// @Param tel query string false "电话"
|
||||
// @Param fromStatus query int false "起始状态"
|
||||
// @Param toStatus query int false "结束状态"
|
||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "门店列表页大小(缺省为50)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetStores [get]
|
||||
func (c *StoreController) GetStores() {
|
||||
c.callGetStores(func(params *tStoreGetStoresParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetStores(params.MapData, params.Offset, params.PageSize)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 查询京西门店信息
|
||||
// @Description 查询京西门店信息,根据关键字查询门店,如果关键字可以转换成数字,还会尝试数值相关的信息
|
||||
// @Param token header string true "认证token"
|
||||
// @Param keyword query string true "查询关键字"
|
||||
// @Param fromStatus query int false "起始状态(缺省为营业中状态)"
|
||||
// @Param toStatus query int false "结束状态"
|
||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "门店列表页大小(缺省为50)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /SearchStores [get]
|
||||
func (c *StoreController) SearchStores() {
|
||||
c.callSearchStores(func(params *tStoreSearchStoresParams) (retVal interface{}, errCode string, err error) {
|
||||
if params.MapData["fromStatus"] == nil {
|
||||
params.FromStatus = 1
|
||||
}
|
||||
if params.MapData["toStatus"] == nil {
|
||||
params.ToStatus = params.FromStatus
|
||||
}
|
||||
retVal, err = cms.SearchStores(params.Keyword, params.FromStatus, params.ToStatus, params.Offset, params.PageSize)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 远程查询厂商门店信息
|
||||
// @Description 远程查询厂商门店信息,这个是实时调用API远程查询
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorStoreID query string true "门店ID"
|
||||
// @Param vendorID query int true "门店所属的厂商ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetVendorStore [get]
|
||||
func (c *StoreController) GetVendorStore() {
|
||||
c.callGetVendorStore(func(params *tStoreGetVendorStoreParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetVendorStore(params.VendorStoreID, params.VendorID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 修改门店信息
|
||||
// @Description 修改门店信息
|
||||
// @Param token header string true "认证token"
|
||||
// @Param payload formData string true "json数据,store对象"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateStore [put]
|
||||
func (c *StoreController) UpdateStore() {
|
||||
c.callUpdateStore(func(params *tStoreUpdateStoreParams) (retVal interface{}, errCode string, err error) {
|
||||
store := make(map[string]interface{})
|
||||
utils.UnmarshalUseNumber([]byte(params.Payload), &store)
|
||||
err = cms.UpdateStore(store, GetUserNameFromToken(params.Token))
|
||||
return nil, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 创建京西门店
|
||||
// @Description 创建京西门店
|
||||
// @Param token header string true "认证token"
|
||||
// @Param payload formData string true "json数据,store对象"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /CreateStore [post]
|
||||
func (c *StoreController) CreateStore() {
|
||||
c.callCreateStore(func(params *tStoreCreateStoreParams) (retVal interface{}, errCode string, err error) {
|
||||
store := &model.Store{}
|
||||
utils.UnmarshalUseNumber([]byte(params.Payload), store)
|
||||
retVal, err = cms.CreateStore(store, GetUserNameFromToken(params.Token))
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -95,6 +95,14 @@ func init() {
|
||||
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.ControllerComments{
|
||||
Method: "CreateStore",
|
||||
Router: `/CreateStore`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
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.ControllerComments{
|
||||
Method: "GetPlaces",
|
||||
@@ -103,6 +111,30 @@ func init() {
|
||||
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.ControllerComments{
|
||||
Method: "GetStores",
|
||||
Router: `/GetStores`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
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.ControllerComments{
|
||||
Method: "GetVendorStore",
|
||||
Router: `/GetVendorStore`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
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.ControllerComments{
|
||||
Method: "SearchStores",
|
||||
Router: `/SearchStores`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
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.ControllerComments{
|
||||
Method: "UpdatePlaces",
|
||||
@@ -111,4 +143,12 @@ func init() {
|
||||
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.ControllerComments{
|
||||
Method: "UpdateStore",
|
||||
Router: `/UpdateStore`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Params: nil})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user