mtwm.getStoreIDFromList
This commit is contained in:
@@ -2,7 +2,6 @@ package mtwm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -185,20 +184,27 @@ func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgDa
|
||||
return imgHint, err
|
||||
}
|
||||
|
||||
func getStoreIDFromList(storeIDs []string) (poiCode string) {
|
||||
if len(storeIDs) > 0 {
|
||||
poiCode = storeIDs[0]
|
||||
}
|
||||
return poiCode
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) getUploadImgPoiCode() (poiCode string) {
|
||||
var storeIDs []string
|
||||
p.locker.RLock()
|
||||
storeIDs = p.storeIDs
|
||||
p.locker.RUnlock()
|
||||
if len(storeIDs) > 0 {
|
||||
return storeIDs[rand.Intn(len(storeIDs))]
|
||||
return getStoreIDFromList(storeIDs)
|
||||
}
|
||||
|
||||
p.locker.Lock()
|
||||
storeIDs = p.storeIDs
|
||||
if len(storeIDs) > 0 {
|
||||
p.locker.Unlock()
|
||||
return storeIDs[rand.Intn(len(storeIDs))]
|
||||
return getStoreIDFromList(storeIDs)
|
||||
}
|
||||
|
||||
defer p.locker.Unlock()
|
||||
@@ -206,7 +212,7 @@ func (p *PurchaseHandler) getUploadImgPoiCode() (poiCode string) {
|
||||
if err == nil {
|
||||
if len(storeIDs) > 0 {
|
||||
p.storeIDs = storeIDs
|
||||
poiCode = storeIDs[rand.Intn(len(storeIDs))]
|
||||
poiCode = getStoreIDFromList(storeIDs)
|
||||
} else {
|
||||
// p.storeIDs = []string{""}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user