- 将OrderSku中没有用的StoreSubName暂时当成VendorActType来使用
- 美团外卖订单使用sku_benefit_detail来更准确的判断单品活动
This commit is contained in:
@@ -126,8 +126,8 @@ func (p *PurchaseHandler) partRefund2OrderDetailSkuList(orderID string, orderDet
|
|||||||
SkuName: skuName,
|
SkuName: skuName,
|
||||||
// Weight: int(utils.Interface2Int64WithDefault(product["total_weight"], 0)) / number, // 退单这里的total_weight有BUG,这里的total_weight还是没有退单时的值
|
// Weight: int(utils.Interface2Int64WithDefault(product["total_weight"], 0)) / number, // 退单这里的total_weight有BUG,这里的total_weight还是没有退单时的值
|
||||||
VendorPrice: utils.MustInterface2Int64(product["product_price"]),
|
VendorPrice: utils.MustInterface2Int64(product["product_price"]),
|
||||||
SalePrice: getSkuSalePrice(product),
|
|
||||||
}
|
}
|
||||||
|
sku.SalePrice, sku.StoreSubName = getSkuSalePrice(product)
|
||||||
if sku.Weight == 0 {
|
if sku.Weight == 0 {
|
||||||
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) // 订单信息里没有重量,只有名字里尝试找
|
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) // 订单信息里没有重量,只有名字里尝试找
|
||||||
}
|
}
|
||||||
@@ -212,9 +212,8 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
SkuName: skuName,
|
SkuName: skuName,
|
||||||
Weight: int(utils.Interface2Int64WithDefault(product["total_weight"], 0)) / productAmount,
|
Weight: int(utils.Interface2Int64WithDefault(product["total_weight"], 0)) / productAmount,
|
||||||
VendorPrice: utils.MustInterface2Int64(product["product_price"]),
|
VendorPrice: utils.MustInterface2Int64(product["product_price"]),
|
||||||
SalePrice: getSkuSalePrice(product),
|
|
||||||
// PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
|
|
||||||
}
|
}
|
||||||
|
sku.SalePrice, sku.StoreSubName = getSkuSalePrice(product)
|
||||||
if sku.Weight == 0 {
|
if sku.Weight == 0 {
|
||||||
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) // 订单信息里没有重量,只有名字里尝试找
|
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) // 订单信息里没有重量,只有名字里尝试找
|
||||||
}
|
}
|
||||||
@@ -227,16 +226,16 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
return order
|
return order
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSkuSalePrice(product map[string]interface{}) (salePrice int64) {
|
func getSkuSalePrice(product map[string]interface{}) (salePrice int64, vendorActType string) {
|
||||||
var product2 *ebaiapi.OrderProductInfo
|
var product2 *ebaiapi.OrderProductInfo
|
||||||
if err := utils.Map2StructByJson(product, &product2, true); err != nil {
|
if err := utils.Map2StructByJson(product, &product2, true); err != nil {
|
||||||
return utils.MustInterface2Int64(product["product_price"])
|
return utils.MustInterface2Int64(product["product_price"]), ""
|
||||||
}
|
}
|
||||||
return int64(getSkuSalePrice2(product2))
|
return getSkuSalePrice2(product2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSkuSalePrice2(product *ebaiapi.OrderProductInfo) (salePrice int) {
|
func getSkuSalePrice2(product *ebaiapi.OrderProductInfo) (salePrice int64, vendorActType string) {
|
||||||
salePrice = product.ProductPrice
|
salePrice = int64(product.ProductPrice)
|
||||||
if product.ProductSubsidy != nil {
|
if product.ProductSubsidy != nil {
|
||||||
for _, v := range product.ProductSubsidy.DiscountDetail {
|
for _, v := range product.ProductSubsidy.DiscountDetail {
|
||||||
if skuActTypeMap[v.Type] == 1 {
|
if skuActTypeMap[v.Type] == 1 {
|
||||||
@@ -244,11 +243,12 @@ func getSkuSalePrice2(product *ebaiapi.OrderProductInfo) (salePrice int) {
|
|||||||
if skuCount == 0 {
|
if skuCount == 0 {
|
||||||
skuCount = product.Number
|
skuCount = product.Number
|
||||||
}
|
}
|
||||||
salePrice -= int(math.Round(float64(v.BaiduRate+v.ShopRate) / float64(skuCount))) // 饿百同一SKU的优惠与非优惠没有拆开,平均摊销处理
|
salePrice -= int64(math.Round(float64(v.BaiduRate+v.ShopRate) / float64(skuCount))) // 饿百同一SKU的优惠与非优惠没有拆开,平均摊销处理
|
||||||
|
vendorActType = v.Type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return salePrice
|
return salePrice, vendorActType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
VendorPrice: utils.MustInterface2Int64(product["skuStorePrice"]),
|
VendorPrice: utils.MustInterface2Int64(product["skuStorePrice"]),
|
||||||
SalePrice: utils.MustInterface2Int64(product["skuJdPrice"]),
|
SalePrice: utils.MustInterface2Int64(product["skuJdPrice"]),
|
||||||
PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
|
PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
|
||||||
|
StoreSubName: utils.Int64ToStr(utils.MustInterface2Int64(product["promotionType"])),
|
||||||
}
|
}
|
||||||
if skuCostumeProperty, ok := product["skuCostumeProperty"]; ok {
|
if skuCostumeProperty, ok := product["skuCostumeProperty"]; ok {
|
||||||
sku.SkuName += skuCostumeProperty.(string)
|
sku.SkuName += skuCostumeProperty.(string)
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加需要赠送的东西
|
// 添加需要赠送的东西
|
||||||
var extraList []*mtwmapi.OrderExtraInfo
|
|
||||||
if result["extras"] != nil {
|
if result["extras"] != nil {
|
||||||
|
var extraList []*mtwmapi.OrderExtraInfo
|
||||||
if err := utils.UnmarshalUseNumber([]byte(result["extras"].(string)), &extraList); err != nil {
|
if err := utils.UnmarshalUseNumber([]byte(result["extras"].(string)), &extraList); err != nil {
|
||||||
panic(fmt.Sprintf("mtwm Map2Order vendorID:%s failed with error:%v", vendorOrderID, err))
|
panic(fmt.Sprintf("mtwm Map2Order vendorID:%s failed with error:%v", vendorOrderID, err))
|
||||||
}
|
}
|
||||||
@@ -157,12 +157,22 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
SkuName: extra.Remark,
|
SkuName: extra.Remark,
|
||||||
Weight: 0,
|
Weight: 0,
|
||||||
SalePrice: 0,
|
SalePrice: 0,
|
||||||
|
StoreSubName: utils.Int2Str(extra.Type),
|
||||||
}
|
}
|
||||||
order.Skus = append(order.Skus, sku)
|
order.Skus = append(order.Skus, sku)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var skuBenefitDetailMap map[string]*mtwmapi.SkuBenefitDetailInfo
|
||||||
|
if skuBenefitDetai := utils.Interface2String(result["sku_benefit_detail"]); skuBenefitDetai != "" {
|
||||||
|
skuBenefitDetailMap = make(map[string]*mtwmapi.SkuBenefitDetailInfo)
|
||||||
|
var skuBenefitDetailList []*mtwmapi.SkuBenefitDetailInfo
|
||||||
|
utils.UnmarshalUseNumber([]byte(skuBenefitDetai), &skuBenefitDetailList)
|
||||||
|
for _, v := range skuBenefitDetailList {
|
||||||
|
skuBenefitDetailMap[v.SkuID] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
ignoreSkuMap := make(map[int]int)
|
ignoreSkuMap := make(map[int]int)
|
||||||
// detail := result["detail"].([]interface{})
|
// detail := result["detail"].([]interface{})
|
||||||
for _, product := range detail {
|
for _, product := range detail {
|
||||||
@@ -179,16 +189,17 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
Weight: getSkuWeight(product),
|
Weight: getSkuWeight(product),
|
||||||
VendorPrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"])),
|
VendorPrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"])),
|
||||||
SalePrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"])),
|
SalePrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"])),
|
||||||
// PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
|
|
||||||
}
|
}
|
||||||
if sku.Weight == 0 {
|
if sku.Weight == 0 {
|
||||||
sku.Weight = 222 // 如果名字里找不到缺省给半斤左右的一个特别值
|
sku.Weight = 222 // 如果名字里找不到缺省给半斤左右的一个特别值
|
||||||
}
|
}
|
||||||
if ignoreSkuMap[sku.SkuID] == 0 && sku.Count == 1 {
|
if skuBenefitDetailMap != nil && skuBenefitDetailMap[sku.VendorSkuID] != nil && ignoreSkuMap[sku.SkuID] == 0 /* && sku.Count == 1 */ {
|
||||||
for _, v := range extraList {
|
for _, v := range skuBenefitDetailMap[sku.VendorSkuID].WmAppOrderActDetails {
|
||||||
if /*skuActTypeMap[v.Type] == 1 && */ strings.Index(v.Remark, skuName) >= 0 {
|
if /*skuActTypeMap[v.Type] == 1 && */ strings.Index(v.Remark, skuName) >= 0 && sku.Count == v.Count {
|
||||||
ignoreSkuMap[sku.SkuID] = 1
|
ignoreSkuMap[sku.SkuID] = 1
|
||||||
sku.SalePrice -= jxutils.StandardPrice2Int(v.ReduceFee)
|
sku.SalePrice -= jxutils.StandardPrice2Int(v.MtCharge + v.PoiCharge)
|
||||||
|
sku.PromotionType = v.Type
|
||||||
|
sku.StoreSubName = utils.Int2Str(v.Type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user