+onSysConfigChanged
This commit is contained in:
@@ -32,6 +32,13 @@ const (
|
|||||||
SendMsgTypeSuggestRequest = "suggestRequest"
|
SendMsgTypeSuggestRequest = "suggestRequest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type SysConfigLimit struct {
|
||||||
|
ValueType reflect.Kind
|
||||||
|
MinValue int64
|
||||||
|
MaxValue int64
|
||||||
|
AfterChanged func() error
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
serviceInfo map[string]interface{}
|
serviceInfo map[string]interface{}
|
||||||
allowUpdatePlaceFieldsMap = map[string]bool{
|
allowUpdatePlaceFieldsMap = map[string]bool{
|
||||||
@@ -55,6 +62,36 @@ var (
|
|||||||
needConfirmRequestMap = map[string]int{
|
needConfirmRequestMap = map[string]int{
|
||||||
SendMsgTypeOpenStoreRequest: 1,
|
SendMsgTypeOpenStoreRequest: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SysConfigLimitMap = map[string]*SysConfigLimit{
|
||||||
|
model.ConfigSysEbaiBoxFee: &SysConfigLimit{
|
||||||
|
ValueType: reflect.Int,
|
||||||
|
MinValue: 0,
|
||||||
|
MaxValue: 500,
|
||||||
|
AfterChanged: func() (err error) {
|
||||||
|
_, err = dao.SetStoreMapSyncStatus(dao.GetDB(), model.VendorIDEBAI, nil, model.SyncFlagModifiedMask)
|
||||||
|
return err
|
||||||
|
},
|
||||||
|
},
|
||||||
|
model.ConfigSysMtwmBoxFee: &SysConfigLimit{
|
||||||
|
ValueType: reflect.Int,
|
||||||
|
MinValue: 0,
|
||||||
|
MaxValue: 500,
|
||||||
|
AfterChanged: func() (err error) {
|
||||||
|
_, err = dao.SetStoreMapSyncStatus(dao.GetDB(), model.VendorIDMTWM, nil, model.SyncFlagModifiedMask)
|
||||||
|
return err
|
||||||
|
},
|
||||||
|
},
|
||||||
|
model.ConfigSysMtwmSkuBoxFee: &SysConfigLimit{
|
||||||
|
ValueType: reflect.Int,
|
||||||
|
MinValue: 0,
|
||||||
|
MaxValue: 50,
|
||||||
|
AfterChanged: func() (err error) {
|
||||||
|
_, err = dao.SetStoreSkuSyncStatus(dao.GetDB(), model.VendorIDMTWM, nil, nil, model.SyncFlagModifiedMask)
|
||||||
|
return err
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
|
func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
|
||||||
@@ -195,7 +232,7 @@ func SendMsg2Somebody(ctx *jxcontext.Context, mobileNum, verifyCode, msgType, ms
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkSysConfig(key, value string) (err error) {
|
func checkSysConfig(key, value string) (err error) {
|
||||||
if limit := model.SysConfigLimitMap[key]; limit != nil {
|
if limit := SysConfigLimitMap[key]; limit != nil {
|
||||||
if limit.ValueType == reflect.Int {
|
if limit.ValueType == reflect.Int {
|
||||||
int64Value, err2 := strconv.ParseInt(value, 10, 64)
|
int64Value, err2 := strconv.ParseInt(value, 10, 64)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
@@ -208,6 +245,13 @@ func checkSysConfig(key, value string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func onSysConfigChanged(key, value string) (err error) {
|
||||||
|
if limit := SysConfigLimitMap[key]; limit != nil && limit.AfterChanged != nil {
|
||||||
|
err = limit.AfterChanged()
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func checkConfig(opFlag int, configType, key, value string) (err error) {
|
func checkConfig(opFlag int, configType, key, value string) (err error) {
|
||||||
switch configType {
|
switch configType {
|
||||||
case model.ConfigTypePricePack:
|
case model.ConfigTypePricePack:
|
||||||
@@ -266,7 +310,11 @@ func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error
|
|||||||
Value: value,
|
Value: value,
|
||||||
}
|
}
|
||||||
dao.WrapAddIDCULDEntity(conf, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(conf, ctx.GetUserName())
|
||||||
return dao.CreateEntity(db, conf)
|
err = dao.CreateEntity(db, conf)
|
||||||
|
if configType == model.ConfigTypeSys && err == nil {
|
||||||
|
err = onSysConfigChanged(key, value)
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
|
func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
|
||||||
@@ -331,6 +379,9 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
|
|||||||
"Type": configType,
|
"Type": configType,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if configType == model.ConfigTypeSys && err == nil {
|
||||||
|
err = onSysConfigChanged(key, "")
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,6 +461,9 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (hint s
|
|||||||
default:
|
default:
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
}
|
}
|
||||||
|
if configType == model.ConfigTypeSys && err == nil {
|
||||||
|
err = onSysConfigChanged(key, value)
|
||||||
|
}
|
||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"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"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 带购物平台信息的
|
// 带购物平台信息的
|
||||||
@@ -579,3 +580,22 @@ func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreS
|
|||||||
err = GetRows(db, &storePriceScoreSnapshot, sql, sqlParams...)
|
err = GetRows(db, &storePriceScoreSnapshot, sql, sqlParams...)
|
||||||
return storePriceScoreSnapshot, err
|
return storePriceScoreSnapshot, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetStoreMapSyncStatus(db *DaoDB, vendorID int, storeIDs []int, syncStatus int) (num int64, err error) {
|
||||||
|
globals.SugarLogger.Debugf("SetStoreMapSyncStatus, storeIDs:%v, vendorID:%d", storeIDs, vendorID)
|
||||||
|
|
||||||
|
sql := `
|
||||||
|
UPDATE store_map t1
|
||||||
|
SET t1.sync_status = t1.sync_status | ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
syncStatus,
|
||||||
|
}
|
||||||
|
sql += " WHERE t1.deleted_at = ? AND t1.sync_status & ? = 0 AND t1.vendor_id = ?"
|
||||||
|
sqlParams = append(sqlParams, utils.DefaultTimeValue, model.SyncFlagDeletedMask, vendorID)
|
||||||
|
if len(storeIDs) > 0 {
|
||||||
|
sql += " AND t1.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
|
}
|
||||||
|
return ExecuteSQL(db, sql, sqlParams...)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "reflect"
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ConfigTypeSys = "Sys"
|
ConfigTypeSys = "Sys"
|
||||||
ConfigTypePricePack = "PricePack"
|
ConfigTypePricePack = "PricePack"
|
||||||
@@ -17,12 +15,6 @@ const (
|
|||||||
ConfigSysMtwmSkuBoxFee = "MtwmSkuBoxFee" // 美团外卖单商品打包费
|
ConfigSysMtwmSkuBoxFee = "MtwmSkuBoxFee" // 美团外卖单商品打包费
|
||||||
)
|
)
|
||||||
|
|
||||||
type SysConfigLimit struct {
|
|
||||||
ValueType reflect.Kind
|
|
||||||
MinValue int64
|
|
||||||
MaxValue int64
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ConfigTypeName = map[string]string{
|
ConfigTypeName = map[string]string{
|
||||||
ConfigTypeSys: "系统",
|
ConfigTypeSys: "系统",
|
||||||
@@ -31,24 +23,6 @@ var (
|
|||||||
ConfigTypeBank: "银行",
|
ConfigTypeBank: "银行",
|
||||||
ConfigTypeRole: "角色",
|
ConfigTypeRole: "角色",
|
||||||
}
|
}
|
||||||
|
|
||||||
SysConfigLimitMap = map[string]*SysConfigLimit{
|
|
||||||
ConfigSysEbaiBoxFee: &SysConfigLimit{
|
|
||||||
ValueType: reflect.Int,
|
|
||||||
MinValue: 0,
|
|
||||||
MaxValue: 500,
|
|
||||||
},
|
|
||||||
ConfigSysMtwmBoxFee: &SysConfigLimit{
|
|
||||||
ValueType: reflect.Int,
|
|
||||||
MinValue: 0,
|
|
||||||
MaxValue: 500,
|
|
||||||
},
|
|
||||||
ConfigSysMtwmSkuBoxFee: &SysConfigLimit{
|
|
||||||
ValueType: reflect.Int,
|
|
||||||
MinValue: 0,
|
|
||||||
MaxValue: 50,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type NewConfig struct {
|
type NewConfig struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user