物料订单插入运单finiedtime
This commit is contained in:
@@ -55,8 +55,9 @@ type JxSkuInfo struct {
|
||||
Price int64 `json:"price,omitempty"` // 原价
|
||||
SalePrice int64 `json:"salePrice,omitempty"` // 售卖价
|
||||
|
||||
Name string `json:"name"`
|
||||
Weight int `json:"weight"`
|
||||
Name string `json:"name"`
|
||||
Weight int `json:"weight"`
|
||||
GroupSign bool `json:"groupSign"`
|
||||
}
|
||||
|
||||
type JxSkuInfoList []*JxSkuInfo
|
||||
@@ -644,25 +645,69 @@ func generateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64
|
||||
return outJxOrder, deliveryAddress, err
|
||||
}
|
||||
|
||||
func tryToSplitMatterOrder(jxOrder *JxOrderInfo) (outOrder []*JxOrderInfo, freightPrice int, err error) {
|
||||
func tryToSplitMatterOrder(jxOrder *JxOrderInfo) (outOrders []*JxOrderInfo, freightPrice int, err error) {
|
||||
var (
|
||||
skus = jxOrder.Skus
|
||||
weightList []int
|
||||
weightList []*JxSkuInfo
|
||||
weightMap = make(map[int]*JxSkuInfo)
|
||||
flag = true
|
||||
)
|
||||
for _, v := range skus {
|
||||
for i := 0; i < v.Count; i++ {
|
||||
weightList = append(weightList, v.Weight)
|
||||
weightList = append(weightList, v)
|
||||
}
|
||||
weightMap[v.Weight] = v
|
||||
}
|
||||
sort.Sort(sort.Reverse(sort.IntSlice(weightList)))
|
||||
for _, v := range weightList {
|
||||
if weightMap[v] != nil {
|
||||
for i := 0; i < len(weightList)-1; i++ {
|
||||
for j := 0; j < len(weightList)-i-1; j++ {
|
||||
if weightList[j].Weight < weightList[j+1].Weight {
|
||||
tmp := weightList[j]
|
||||
weightList[j] = weightList[j+1]
|
||||
weightList[j+1] = tmp
|
||||
}
|
||||
}
|
||||
}
|
||||
for k, v := range weightList {
|
||||
weightMap[k+1] = v
|
||||
}
|
||||
outOrders = loop(weightMap, flag, jxOrder)
|
||||
return outOrders, freightPrice, err
|
||||
}
|
||||
|
||||
func loop(weightMap map[int]*JxSkuInfo, flag bool, jxOrder *JxOrderInfo) (outOrders []*JxOrderInfo) {
|
||||
sum5 := 0
|
||||
sum3 := 0
|
||||
for i := 1; i <= len(weightMap); i++ {
|
||||
outOrder := &JxOrderInfo{}
|
||||
outOrder = jxOrder
|
||||
for j := 1; j <= len(weightMap); {
|
||||
if flag {
|
||||
if !weightMap[j].GroupSign {
|
||||
sum5 += weightMap[j].Weight
|
||||
if weightMap[j].Weight+sum5 <= 5 {
|
||||
outOrder.Skus = append(outOrder.Skus, weightMap[j])
|
||||
weightMap[j].GroupSign = true
|
||||
} else {
|
||||
j++
|
||||
continue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if !weightMap[j].GroupSign {
|
||||
sum3 += weightMap[j].Weight
|
||||
if weightMap[j].Weight+sum3 <= 3 {
|
||||
outOrder.Skus = append(outOrder.Skus, weightMap[j])
|
||||
weightMap[j].GroupSign = true
|
||||
} else {
|
||||
j++
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
flag = false
|
||||
outOrders = append(outOrders, outOrder)
|
||||
}
|
||||
return outOrder, freightPrice, err
|
||||
return outOrders
|
||||
}
|
||||
|
||||
func matterSkusLimited(skus []*JxSkuInfo, storeID int) (err error) {
|
||||
@@ -820,13 +865,14 @@ func orderSolutionForWuLiao(order *model.GoodsOrder) (err error) {
|
||||
order.EclpOutID = result
|
||||
dao.UpdateEntity(db, order, "EclpOutID")
|
||||
waybill := &model.Waybill{
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
OrderVendorID: model.VendorIDJX,
|
||||
VendorWaybillID: order.EclpOutID,
|
||||
WaybillVendorID: model.VendorIDJDWL,
|
||||
Status: model.WaybillStatusDelivering,
|
||||
WaybillCreatedAt: time.Now(),
|
||||
StatusTime: time.Now(),
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
OrderVendorID: model.VendorIDJX,
|
||||
VendorWaybillID: order.EclpOutID,
|
||||
WaybillVendorID: model.VendorIDJDWL,
|
||||
Status: model.WaybillStatusDelivering,
|
||||
WaybillCreatedAt: time.Now(),
|
||||
StatusTime: time.Now(),
|
||||
WaybillFinishedAt: utils.DefaultTimeValue,
|
||||
}
|
||||
dao.CreateEntity(db, waybill)
|
||||
// } else { //如果重量超过5kg则需要进行拆单分包,商品分包规则。最后一个包不超过5kg,其他包不超过3kg
|
||||
|
||||
Reference in New Issue
Block a user