- handle special chars in store name.
This commit is contained in:
@@ -257,6 +257,10 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
|||||||
store := &model.Store{}
|
store := &model.Store{}
|
||||||
store.ID = storeID
|
store.ID = storeID
|
||||||
valid := dao.NormalMakeMapByStructObject(payload, store, userName)
|
valid := dao.NormalMakeMapByStructObject(payload, store, userName)
|
||||||
|
globals.SugarLogger.Debug(utils.Format4Output(valid, false))
|
||||||
|
if valid["name"] != nil {
|
||||||
|
valid["name"] = jxutils.FormalizeName(valid["name"].(string))
|
||||||
|
}
|
||||||
if payload["lng"] != nil {
|
if payload["lng"] != nil {
|
||||||
valid["lng"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lng"], 0.0))
|
valid["lng"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lng"], 0.0))
|
||||||
valid["lat"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lat"], 0.0))
|
valid["lat"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lat"], 0.0))
|
||||||
@@ -284,8 +288,9 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
|||||||
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
||||||
store := &storeExt.Store
|
store := &storeExt.Store
|
||||||
existingID := store.ID
|
existingID := store.ID
|
||||||
storeExt.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
|
store.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
|
||||||
storeExt.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
|
store.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
|
||||||
|
store.Name = jxutils.FormalizeName(store.Name)
|
||||||
dao.WrapAddIDCULDEntity(store, userName)
|
dao.WrapAddIDCULDEntity(store, userName)
|
||||||
store.ID = existingID
|
store.ID = existingID
|
||||||
if err = dao.CreateEntity(nil, store); err == nil {
|
if err = dao.CreateEntity(nil, store); err == nil {
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ func GetJdPromotions(ctx *jxcontext.Context, keyword string, params map[string]i
|
|||||||
t1.begin_at,
|
t1.begin_at,
|
||||||
t1.end_at,
|
t1.end_at,
|
||||||
t1.advertising,
|
t1.advertising,
|
||||||
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"storeID":', t2.store_id, ', "name":"', t22.name, '"}')), "]") store_str,
|
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"storeID":', t2.store_id, ', "name":"', REPLACE(REPLACE(t22.name, '\t', ''), '"', ''), '"}')), "]") store_str,
|
||||||
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"skuID":', t3.sku_id, ', "priceType":', t3.price_type, ', "price":', t3.price, ', "limitSkuCount":', t3.limit_sku_count, ', "isLock":', t3.is_lock, '}')), "]") sku_price_str
|
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"skuID":', t3.sku_id, ', "priceType":', t3.price_type, ', "price":', t3.price, ', "limitSkuCount":', t3.limit_sku_count, ', "isLock":', t3.is_lock, '}')), "]") sku_price_str
|
||||||
FROM promotion t1
|
FROM promotion t1
|
||||||
JOIN promotion_store t2 ON t1.id = t2.promotion_id
|
JOIN promotion_store t2 ON t1.id = t2.promotion_id
|
||||||
@@ -843,24 +843,26 @@ func OnStoreStockMsg(msg *jdapi.CallbackStoreStockMsg) (retVal *jdapi.CallbackRe
|
|||||||
sku := &model.Sku{}
|
sku := &model.Sku{}
|
||||||
sku.JdID = msg.SkuId
|
sku.JdID = msg.SkuId
|
||||||
if err = dao.GetEntity(db, sku, model.FieldJdID); err == nil {
|
if err = dao.GetEntity(db, sku, model.FieldJdID); err == nil {
|
||||||
if msg.Vendibility == 1 {
|
go func() {
|
||||||
vendibility := &jdapi.StockVendibility{
|
if msg.Vendibility == 1 {
|
||||||
OutSkuId: utils.Int2Str(sku.ID),
|
vendibility := &jdapi.StockVendibility{
|
||||||
DoSale: true,
|
OutSkuId: utils.Int2Str(sku.ID),
|
||||||
|
DoSale: true,
|
||||||
|
}
|
||||||
|
_, err = api.JdAPI.BatchUpdateVendibility("", msg.StationNo, []*jdapi.StockVendibility{
|
||||||
|
vendibility,
|
||||||
|
}, userName)
|
||||||
}
|
}
|
||||||
_, err = api.JdAPI.BatchUpdateVendibility("", msg.StationNo, []*jdapi.StockVendibility{
|
if !msg.Have {
|
||||||
vendibility,
|
stock := &jdapi.SkuStock{
|
||||||
}, userName)
|
OutSkuId: utils.Int2Str(sku.ID),
|
||||||
}
|
StockQty: model.MaxStoreSkuStockQty,
|
||||||
if !msg.Have {
|
}
|
||||||
stock := &jdapi.SkuStock{
|
_, err = api.JdAPI.BatchUpdateCurrentQtys("", msg.StationNo, []*jdapi.SkuStock{
|
||||||
OutSkuId: utils.Int2Str(sku.ID),
|
stock,
|
||||||
StockQty: model.MaxStoreSkuStockQty,
|
}, userName)
|
||||||
}
|
}
|
||||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", msg.StationNo, []*jdapi.SkuStock{
|
}()
|
||||||
stock,
|
|
||||||
}, userName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return jdapi.Err2CallbackResponse(err, "")
|
return jdapi.Err2CallbackResponse(err, "")
|
||||||
|
|||||||
@@ -166,3 +166,7 @@ func FormalizePageSize(pageSize int) int {
|
|||||||
}
|
}
|
||||||
return pageSize
|
return pageSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FormalizeName(name string) string {
|
||||||
|
return utils.TrimBlankChar(strings.Replace(strings.Replace(name, "\t", "", -1), "\"", "", -1))
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const (
|
|||||||
FieldEnabled = "Enabled"
|
FieldEnabled = "Enabled"
|
||||||
FieldSpecQuality = "SpecQuality"
|
FieldSpecQuality = "SpecQuality"
|
||||||
FieldSpecUnit = "SpecUnit"
|
FieldSpecUnit = "SpecUnit"
|
||||||
|
FieldName = "Name"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModelIDCUL struct {
|
type ModelIDCUL struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user