|
@@ -8,8 +8,6 @@ import (
|
|
|
"jyOrderManager/internal/jyutil"
|
|
|
"jyOrderManager/internal/model"
|
|
|
"jyOrderManager/internal/service"
|
|
|
-
|
|
|
- "unicode"
|
|
|
)
|
|
|
|
|
|
var JyProFunc = jyProductFuncMapping{
|
|
@@ -31,30 +29,12 @@ type (
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-// getOnlyProductClassCode 获取
|
|
|
-func getOnlyProductClassCode(code string) string {
|
|
|
- if len(code) == 0 {
|
|
|
- return ""
|
|
|
- }
|
|
|
- // 先检查是否是字母开头
|
|
|
- if !unicode.IsLetter(rune(code[0])) {
|
|
|
- return ""
|
|
|
- }
|
|
|
- i := 0
|
|
|
- for ; i < len(code); i++ {
|
|
|
- if unicode.IsDigit(rune(code[i])) {
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- return code[:i]
|
|
|
-}
|
|
|
-
|
|
|
func (t *jyProductFuncMapping) RegisterJyProductCreateFunc(code string, f ProductInitFunc) {
|
|
|
t.initFuncMapping[code] = f
|
|
|
}
|
|
|
|
|
|
func (t *jyProductFuncMapping) GetProductInitFuncByCode(code interface{}) (ProductInitFunc, error) {
|
|
|
- tCOde := getOnlyProductClassCode(gconv.String(code))
|
|
|
+ tCOde := jyutil.GetOnlyProductClassCode(gconv.String(code))
|
|
|
productObj, ok := t.initFuncMapping[tCOde]
|
|
|
if !ok {
|
|
|
return nil, fmt.Errorf("未知订单类型")
|
|
@@ -63,7 +43,7 @@ func (t *jyProductFuncMapping) GetProductInitFuncByCode(code interface{}) (Produ
|
|
|
}
|
|
|
|
|
|
func (t *jyProductFuncMapping) MustGetProductInitFuncByCode(code interface{}) ProductInitFunc {
|
|
|
- return t.initFuncMapping[getOnlyProductClassCode(gconv.String(code))]
|
|
|
+ return t.initFuncMapping[jyutil.GetOnlyProductClassCode(gconv.String(code))]
|
|
|
}
|
|
|
|
|
|
func GetProductMsgAndCheckPower(ctx context.Context, pCode string, paramCheck ...model.ProductCommonCheck) (*model.Product, *model.ProductClass, error) {
|