打包费参数有效性检查
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -193,6 +194,20 @@ func SendMsg2Somebody(ctx *jxcontext.Context, mobileNum, verifyCode, msgType, ms
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkSysConfig(key, value string) (err error) {
|
||||||
|
if limit := model.SysConfigLimitMap[key]; limit != nil {
|
||||||
|
if limit.ValueType == reflect.Int {
|
||||||
|
int64Value, err2 := strconv.ParseInt(value, 10, 64)
|
||||||
|
if err = err2; err == nil {
|
||||||
|
if int64Value < limit.MinValue || int64Value > limit.MaxValue {
|
||||||
|
err = fmt.Errorf("配置%s,值%s超范围[%d,%d]", key, value, limit.MinValue, limit.MaxValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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:
|
||||||
@@ -228,8 +243,10 @@ func checkConfig(opFlag int, configType, key, value string) (err error) {
|
|||||||
}
|
}
|
||||||
case model.ConfigTypeRole:
|
case model.ConfigTypeRole:
|
||||||
case model.ConfigTypeSys:
|
case model.ConfigTypeSys:
|
||||||
if opFlag&(model.SyncFlagNewMask|model.SyncFlagDeletedMask) != 0 {
|
if opFlag&( /*model.SyncFlagNewMask|*/ model.SyncFlagDeletedMask) != 0 {
|
||||||
err = fmt.Errorf("系统参数只支持修改,不支持自由添加")
|
err = fmt.Errorf("系统参数只支持修改或添加,不支持删除")
|
||||||
|
} else {
|
||||||
|
err = checkSysConfig(key, value)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeName, true), configType)
|
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeName, true), configType)
|
||||||
|
|||||||
@@ -236,7 +236,9 @@ func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyn
|
|||||||
if len(inSkuList) > 0 {
|
if len(inSkuList) > 0 {
|
||||||
boxFee := getSkuBoxFee(inSkuList[0].VendorID)
|
boxFee := getSkuBoxFee(inSkuList[0].VendorID)
|
||||||
for _, skuItem := range inSkuList {
|
for _, skuItem := range inSkuList {
|
||||||
|
if skuItem.VendorPrice > skuItem.BoxFee {
|
||||||
skuItem.BoxFee = boxFee
|
skuItem.BoxFee = boxFee
|
||||||
|
}
|
||||||
skuItem.MergedStatus = jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus)
|
skuItem.MergedStatus = jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus)
|
||||||
skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd)
|
skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
import "reflect"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ConfigTypeSys = "Sys"
|
ConfigTypeSys = "Sys"
|
||||||
ConfigTypePricePack = "PricePack"
|
ConfigTypePricePack = "PricePack"
|
||||||
@@ -15,6 +17,12 @@ 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: "系统",
|
||||||
@@ -23,6 +31,24 @@ 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