解决冲突,合并提交

This commit is contained in:
Rosy-zhudan
2019-08-07 15:24:35 +08:00
17 changed files with 112 additions and 75 deletions

View File

@@ -9,7 +9,6 @@ import (
"regexp"
"sort"
"strings"
"sync"
"time"
"io/ioutil"
@@ -28,11 +27,6 @@ var (
skuNamePat *regexp.Regexp
)
type SyncMapWithTimeout struct {
sync.Map
timers sync.Map
}
type OrderSkuList []*model.OrderSku
func (l OrderSkuList) Len() int {
@@ -61,22 +55,6 @@ func init() {
skuNamePat = regexp.MustCompile(`([\(\[【][^\(\[【\)\]】]*[\)\]】])?(.*?)([(].*[)])?\s*约?([1-9][\d\.]*)(g|G|kg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([(].*[)])?\s*(?:\/||)\s*([^\s()]{0,2})\s*([(].*[)])?$`)
}
func (m *SyncMapWithTimeout) StoreWithTimeout(key, value interface{}, timeout time.Duration) {
m.Map.Store(key, value)
m.timers.Store(key, utils.AfterFuncWithRecover(timeout, func() {
m.Delete(key)
}))
}
func (m *SyncMapWithTimeout) Delete(key interface{}) {
m.Map.Delete(key)
if value, ok := m.timers.Load(key); ok {
timer := value.(*time.Timer)
timer.Stop()
}
m.timers.Delete(key)
}
func getJxStoreIDFromOrder(order *model.GoodsOrder) (retVal int) {
if order.JxStoreID != 0 {
return order.JxStoreID