- handle special chars in store name.

This commit is contained in:
gazebo
2018-11-07 18:12:32 +08:00
parent e5510db6ea
commit a5d22c3655
4 changed files with 31 additions and 19 deletions

View File

@@ -257,6 +257,10 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
store := &model.Store{}
store.ID = storeID
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 {
valid["lng"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lng"], 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) {
store := &storeExt.Store
existingID := store.ID
storeExt.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
storeExt.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
store.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
store.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
store.Name = jxutils.FormalizeName(store.Name)
dao.WrapAddIDCULDEntity(store, userName)
store.ID = existingID
if err = dao.CreateEntity(nil, store); err == nil {

View File

@@ -487,7 +487,7 @@ func GetJdPromotions(ctx *jxcontext.Context, keyword string, params map[string]i
t1.begin_at,
t1.end_at,
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
FROM promotion t1
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.JdID = msg.SkuId
if err = dao.GetEntity(db, sku, model.FieldJdID); err == nil {
if msg.Vendibility == 1 {
vendibility := &jdapi.StockVendibility{
OutSkuId: utils.Int2Str(sku.ID),
DoSale: true,
go func() {
if msg.Vendibility == 1 {
vendibility := &jdapi.StockVendibility{
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{
vendibility,
}, userName)
}
if !msg.Have {
stock := &jdapi.SkuStock{
OutSkuId: utils.Int2Str(sku.ID),
StockQty: model.MaxStoreSkuStockQty,
if !msg.Have {
stock := &jdapi.SkuStock{
OutSkuId: utils.Int2Str(sku.ID),
StockQty: model.MaxStoreSkuStockQty,
}
_, err = api.JdAPI.BatchUpdateCurrentQtys("", msg.StationNo, []*jdapi.SkuStock{
stock,
}, userName)
}
_, err = api.JdAPI.BatchUpdateCurrentQtys("", msg.StationNo, []*jdapi.SkuStock{
stock,
}, userName)
}
}()
}
}
return jdapi.Err2CallbackResponse(err, "")

View File

@@ -166,3 +166,7 @@ func FormalizePageSize(pageSize int) int {
}
return pageSize
}
func FormalizeName(name string) string {
return utils.TrimBlankChar(strings.Replace(strings.Replace(name, "\t", "", -1), "\"", "", -1))
}

View File

@@ -35,6 +35,7 @@ const (
FieldEnabled = "Enabled"
FieldSpecQuality = "SpecQuality"
FieldSpecUnit = "SpecUnit"
FieldName = "Name"
)
type ModelIDCUL struct {