- improve jxutils.SplitStoreName
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -11,6 +12,10 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
var (
|
||||
storeNamePat = regexp.MustCompile(`([^(\[(【)\])】\-\s]*)[(\[(【\-\s]+([^(\[(【)\])】\-]*)[)\])】]*`)
|
||||
)
|
||||
|
||||
// 合并得到最终的门店状态
|
||||
func MergeStoreStatus(status int, vendorStatus int) int {
|
||||
if status < vendorStatus {
|
||||
@@ -58,15 +63,26 @@ func SplitStoreName(fullName, separator, defaultPrefix string) (prefix, bareName
|
||||
prefix = names[0]
|
||||
bareName = names[1]
|
||||
} else {
|
||||
prefix = defaultPrefix
|
||||
bareName = strings.Trim(strings.Trim(fullName, defaultPrefix), separator)
|
||||
|
||||
searchResult := storeNamePat.FindStringSubmatch(fullName)
|
||||
if searchResult != nil {
|
||||
prefix = searchResult[1]
|
||||
bareName = strings.Trim(strings.Trim(searchResult[2], defaultPrefix), separator)
|
||||
} else {
|
||||
prefix = defaultPrefix
|
||||
bareName = strings.Trim(strings.Trim(fullName, defaultPrefix), separator)
|
||||
}
|
||||
}
|
||||
return TrimDecorationChar(defaultPrefix), TrimDecorationChar(bareName)
|
||||
return TrimDecorationChar(prefix), TrimDecorationChar(bareName)
|
||||
}
|
||||
|
||||
func ComposeStoreName(bareName, separator, prefix string) (fullName string) {
|
||||
return prefix + separator + TrimDecorationChar(strings.Trim(bareName, separator))
|
||||
func ComposeStoreName(bareName string, vendorID int) (fullName string) {
|
||||
bareName = TrimDecorationChar(strings.Trim(bareName, "-"))
|
||||
if vendorID == model.VendorIDJD {
|
||||
fullName = "京西菜市-" + bareName
|
||||
} else {
|
||||
fullName = "京西菜市(" + bareName + ")"
|
||||
}
|
||||
return fullName
|
||||
}
|
||||
|
||||
func StrTime2JxOperationTime(strTime string, defValue int16) int16 {
|
||||
|
||||
Reference in New Issue
Block a user