diff --git a/business/partner/purchase/mtwm/mtwm.go b/business/partner/purchase/mtwm/mtwm.go index 1f6c280ff..4a82b7d0b 100644 --- a/business/partner/purchase/mtwm/mtwm.go +++ b/business/partner/purchase/mtwm/mtwm.go @@ -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{""} }