- 调整单修正实际支付价

This commit is contained in:
gazebo
2019-06-12 11:24:34 +08:00
parent 13a384248b
commit c71a9bf40d
3 changed files with 24 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import (
"math"
"math/rand"
"regexp"
"sort"
"strings"
"sync"
"time"
@@ -31,6 +32,25 @@ type SyncMapWithTimeout struct {
timers sync.Map
}
type OrderSkuList []*model.OrderSku
func (l OrderSkuList) Len() int {
return len(l)
}
// Less reports whether the element with
// index i should sort before the element with index j.
func (l OrderSkuList) Less(i, j int) bool {
return l[i].SalePrice < l[j].SalePrice
}
// Swap swaps the elements with indexes i and j.
func (l OrderSkuList) Swap(i, j int) {
tmp := l[i]
l[i] = l[j]
l[j] = tmp
}
func init() {
rand.Seed(time.Now().Unix())
routinePool = routinepool.New(1000, 1000)
@@ -489,6 +509,7 @@ func RemoveSkuFromOrder(order *model.GoodsOrder, removedSkuList []*model.OrderSk
}
}
var skuList []*model.OrderSku
sort.Sort(sort.Reverse(OrderSkuList(order.Skus)))
for _, sku := range order.Skus {
var removedSku *model.OrderSku
if skuID := GetSkuIDFromOrderSku(sku); skuID > 0 {