- 饿百订单添加赠品sku
This commit is contained in:
@@ -99,6 +99,7 @@ func (p *PurchaseHandler) GetOrder4PartRefund(vendorOrderID string) (order *mode
|
|||||||
order = p.Map2Order(result1)
|
order = p.Map2Order(result1)
|
||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
order.Skus = p.partRefund2OrderDetailSkuList(utils.Interface2String(result2["order_id"]), result2["order_detail"])
|
order.Skus = p.partRefund2OrderDetailSkuList(utils.Interface2String(result2["order_id"]), result2["order_detail"])
|
||||||
|
order.Skus = append(order.Skus, getZengSkus(vendorOrderID, result1)...)
|
||||||
order.ActualPayPrice = utils.MustInterface2Int64(result2["user_fee"])
|
order.ActualPayPrice = utils.MustInterface2Int64(result2["user_fee"])
|
||||||
jxutils.RefreshOrderSkuRelated(order)
|
jxutils.RefreshOrderSkuRelated(order)
|
||||||
} else if err2Ext, ok := err2.(*utils.ErrorWithCode); !ok || err2Ext.IntCode() != ebaiapi.ErrOrderIsNotPartRefund {
|
} else if err2Ext, ok := err2.(*utils.ErrorWithCode); !ok || err2Ext.IntCode() != ebaiapi.ErrOrderIsNotPartRefund {
|
||||||
@@ -110,6 +111,26 @@ func (p *PurchaseHandler) GetOrder4PartRefund(vendorOrderID string) (order *mode
|
|||||||
return order, err
|
return order, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getZengSkus(orderID string, orderMan map[string]interface{}) (skus []*model.OrderSku) {
|
||||||
|
discounts, _ := orderMan["discount"].([]interface{})
|
||||||
|
for _, v := range discounts {
|
||||||
|
discount := v.(map[string]interface{})
|
||||||
|
if utils.Interface2String(discount["type"]) == ebaiapi.OrderSkuDiscountTypeZeng {
|
||||||
|
sku := &model.OrderSku{
|
||||||
|
VendorOrderID: orderID,
|
||||||
|
VendorID: model.VendorIDEBAI,
|
||||||
|
Count: 1,
|
||||||
|
SkuID: 0,
|
||||||
|
VendorSkuID: "",
|
||||||
|
SkuName: utils.Interface2String(discount["desc"]),
|
||||||
|
VendorPrice: 0,
|
||||||
|
}
|
||||||
|
skus = append(skus, sku)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return skus
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) partRefund2OrderDetailSkuList(orderID string, orderDetail2 interface{}) (skuList []*model.OrderSku) {
|
func (p *PurchaseHandler) partRefund2OrderDetailSkuList(orderID string, orderDetail2 interface{}) (skuList []*model.OrderSku) {
|
||||||
orderDetail := orderDetail2.([]interface{})
|
orderDetail := orderDetail2.([]interface{})
|
||||||
for _, product2 := range orderDetail {
|
for _, product2 := range orderDetail {
|
||||||
@@ -197,7 +218,6 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(originalLat)
|
order.ConsigneeLat = jxutils.StandardCoordinate2Int(originalLat)
|
||||||
|
|
||||||
products := result["products"].([]interface{})[0].([]interface{})
|
products := result["products"].([]interface{})[0].([]interface{})
|
||||||
// discounts := result["discount"].(map[string]interface{})
|
|
||||||
for _, product2 := range products {
|
for _, product2 := range products {
|
||||||
product := product2.(map[string]interface{})
|
product := product2.(map[string]interface{})
|
||||||
skuName := product["product_name"].(string)
|
skuName := product["product_name"].(string)
|
||||||
@@ -224,6 +244,7 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
// }
|
// }
|
||||||
order.Skus = append(order.Skus, sku)
|
order.Skus = append(order.Skus, sku)
|
||||||
}
|
}
|
||||||
|
order.Skus = append(order.Skus, getZengSkus(vendorOrderID, orderData)...)
|
||||||
jxutils.RefreshOrderSkuRelated(order)
|
jxutils.RefreshOrderSkuRelated(order)
|
||||||
return order
|
return order
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user