! GoodsOrder与OrderSku添加VendorPrice表示平台价,而SalePrice表示单品优惠之后的价格
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
@@ -62,6 +63,12 @@ var (
|
||||
fakeUserUndoApplyCancel: model.OrderStatusUndoApplyCancel,
|
||||
fakeMerchantAgreeApplyCancel: model.OrderStatusCanceled,
|
||||
}
|
||||
|
||||
skuActTypeMap = map[int]int{
|
||||
mtwmapi.ExtrasPromotionTypeTeJiaCai: 1,
|
||||
mtwmapi.ExtrasPromotionTypeZheKouCai: 1,
|
||||
mtwmapi.ExtrasPromotionTypeSecondHalfPrice: 1,
|
||||
}
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) GetStatusFromVendorStatus(vendorStatus string) int {
|
||||
@@ -132,34 +139,10 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
if err := utils.UnmarshalUseNumber([]byte(result["detail"].(string)), &detail); err != nil {
|
||||
panic(fmt.Sprintf("mtwm Map2Order vendorID:%s failed with error:%v", vendorOrderID, err))
|
||||
}
|
||||
// detail := result["detail"].([]interface{})
|
||||
for _, product := range detail {
|
||||
// product := product2.(map[string]interface{})
|
||||
skuName := product["food_name"].(string)
|
||||
skuID := utils.Interface2String(product["sku_id"])
|
||||
sku := &model.OrderSku{
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
VendorID: model.VendorIDMTWM,
|
||||
Count: int(utils.MustInterface2Float64(product["quantity"])),
|
||||
SkuID: int(utils.Str2Int64WithDefault(skuID, 0)),
|
||||
VendorSkuID: skuID,
|
||||
SkuName: skuName,
|
||||
Weight: getSkuWeight(product),
|
||||
SalePrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"])),
|
||||
// PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
|
||||
}
|
||||
if sku.Weight == 0 {
|
||||
sku.Weight = 222 // 如果名字里找不到缺省给半斤左右的一个特别值
|
||||
}
|
||||
// if product["isGift"].(bool) {
|
||||
// sku.SkuType = 1
|
||||
// }
|
||||
order.Skus = append(order.Skus, sku)
|
||||
}
|
||||
|
||||
// 添加需要赠送的东西
|
||||
var extraList []*mtwmapi.OrderExtraInfo
|
||||
if result["extras"] != nil {
|
||||
var extraList []*mtwmapi.OrderExtraInfo
|
||||
if err := utils.UnmarshalUseNumber([]byte(result["extras"].(string)), &extraList); err != nil {
|
||||
panic(fmt.Sprintf("mtwm Map2Order vendorID:%s failed with error:%v", vendorOrderID, err))
|
||||
}
|
||||
@@ -180,6 +163,41 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
}
|
||||
}
|
||||
|
||||
ignoreSkuMap := make(map[int]int)
|
||||
// detail := result["detail"].([]interface{})
|
||||
for _, product := range detail {
|
||||
// product := product2.(map[string]interface{})
|
||||
skuName := product["food_name"].(string)
|
||||
skuID := utils.Interface2String(product["sku_id"])
|
||||
sku := &model.OrderSku{
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
VendorID: model.VendorIDMTWM,
|
||||
Count: int(utils.MustInterface2Float64(product["quantity"])),
|
||||
SkuID: int(utils.Str2Int64WithDefault(skuID, 0)),
|
||||
VendorSkuID: skuID,
|
||||
SkuName: skuName,
|
||||
Weight: getSkuWeight(product),
|
||||
VendorPrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"])),
|
||||
SalePrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"])),
|
||||
// PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
|
||||
}
|
||||
if sku.Weight == 0 {
|
||||
sku.Weight = 222 // 如果名字里找不到缺省给半斤左右的一个特别值
|
||||
}
|
||||
if ignoreSkuMap[sku.SkuID] == 0 && sku.Count == 1 {
|
||||
for _, v := range extraList {
|
||||
if skuActTypeMap[v.Type] == 1 && strings.Index(v.Remark, skuName) >= 0 {
|
||||
ignoreSkuMap[sku.SkuID] = 1
|
||||
sku.SalePrice -= jxutils.StandardPrice2Int(v.ReduceFee)
|
||||
}
|
||||
}
|
||||
}
|
||||
// if product["isGift"].(bool) {
|
||||
// sku.SkuType = 1
|
||||
// }
|
||||
order.Skus = append(order.Skus, sku)
|
||||
}
|
||||
|
||||
jxutils.RefreshOrderSkuRelated(order)
|
||||
return order
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user