- 配置类型增加银行

This commit is contained in:
gazebo
2019-07-25 11:46:32 +08:00
parent a07e84c776
commit 7f6ec1b9de
3 changed files with 41 additions and 18 deletions

View File

@@ -83,6 +83,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
"actStatusName": model.ActStatusName,
"actCreateTypeName": model.ActCreateTypeName,
"storeAuditStatusName": model.StoreAuditStatusName,
"configTypeList": model.ConfigTypeList,
},
}
Init()
@@ -205,10 +206,16 @@ func checkConfig(configType, value string) (err error) {
err = fmt.Errorf("配置:%s不合法", value)
}
}
case model.ConfigTypeBank:
if value != "" {
if model.BankName[value] == "" {
err = fmt.Errorf("些银行代码:%s不支持请联系开发", value)
}
}
default:
err = fmt.Errorf("当前只支持价格包配置:%s", model.ConfigTypePricePack)
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeList, true), configType)
}
return
return err
}
func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error) {
@@ -230,22 +237,25 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
if err = checkConfig(configType, ""); err != nil {
return err
}
db := dao.GetDB()
storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, key)
if err != nil {
return err
}
if len(storeMapList) > 0 {
var storeInfo []string
for _, v := range storeMapList {
storeInfo = append(storeInfo, fmt.Sprintf("门店:%d, 平台:%s", v.StoreID, model.VendorChineseNames[v.VendorID]))
switch configType {
case model.ConfigTypePricePack:
db := dao.GetDB()
storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, key)
if err != nil {
return err
}
return fmt.Errorf("还有门店在使用价格包:%s门店信息:%s", key, strings.Join(storeInfo, ","))
if len(storeMapList) > 0 {
var storeInfo []string
for _, v := range storeMapList {
storeInfo = append(storeInfo, fmt.Sprintf("门店:%d, 平台:%s", v.StoreID, model.VendorChineseNames[v.VendorID]))
}
return fmt.Errorf("还有门店在使用价格包:%s门店信息:%s", key, strings.Join(storeInfo, ","))
}
_, err = dao.DeleteEntityLogically(db, &model.NewConfig{}, nil, ctx.GetUserName(), map[string]interface{}{
"Key": key,
"Type": configType,
})
}
_, err = dao.DeleteEntityLogically(db, &model.NewConfig{}, nil, ctx.GetUserName(), map[string]interface{}{
"Key": key,
"Type": configType,
})
return err
}
@@ -291,3 +301,7 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (err er
dao.Commit(db)
return err
}
func QueryConfigs(key, configType, keyword string) (configList []*model.NewConfig, err error) {
return dao.QueryConfigs(dao.GetDB(), key, configType, keyword)
}

View File

@@ -3,6 +3,15 @@ package model
const (
ConfigTypeSys = "Sys"
ConfigTypePricePack = "PricePack"
ConfigTypeBank = "Bank"
)
var (
ConfigTypeList = []string{
ConfigTypeSys,
ConfigTypePricePack,
ConfigTypeBank,
}
)
type NewConfig struct {
@@ -16,5 +25,6 @@ type NewConfig struct {
func (*NewConfig) TableUnique() [][]string {
return [][]string{
[]string{"Key", "Type", "DeletedAt"},
[]string{"Type", "Key", "DeletedAt"},
}
}

View File

@@ -6,7 +6,6 @@ import (
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/configindb"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/msghub"
"git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego"
@@ -276,7 +275,7 @@ func (c *CmsController) UpdateConfig() {
// @router /QueryConfigs [get]
func (c *CmsController) QueryConfigs() {
c.callQueryConfigs(func(params *tCmsQueryConfigsParams) (retVal interface{}, errCode string, err error) {
retVal, err = dao.QueryConfigs(dao.GetDB(), params.Key, params.Type, params.Keyword)
retVal, err = cms.QueryConfigs(params.Key, params.Type, params.Keyword)
return retVal, "", err
})
}