! GoodsOrder与OrderSku添加VendorPrice表示平台价,而SalePrice表示单品优惠之后的价格

This commit is contained in:
gazebo
2019-06-11 23:49:21 +08:00
parent 07f8b120f8
commit 7f939333df
6 changed files with 76 additions and 35 deletions

View File

@@ -119,7 +119,8 @@ func (p *PurchaseHandler) partRefund2OrderDetailSkuList(orderID string, orderDet
VendorSkuID: utils.Interface2String(product[ebaiapi.KeySkuID]),
SkuName: skuName,
// Weight: int(utils.Interface2Int64WithDefault(product["total_weight"], 0)) / number, // 退单这里的total_weight有BUG这里的total_weight还是没有退单时的值
SalePrice: utils.MustInterface2Int64(product["product_price"]),
VendorPrice: utils.MustInterface2Int64(product["product_price"]),
SalePrice: getSkuSalePrice(product),
}
if sku.Weight == 0 {
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) // 订单信息里没有重量,只有名字里尝试找
@@ -204,7 +205,8 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
VendorSkuID: utils.Interface2String(product["baidu_product_id"]),
SkuName: skuName,
Weight: int(utils.Interface2Int64WithDefault(product["total_weight"], 0)) / productAmount,
SalePrice: utils.MustInterface2Int64(product["product_price"]),
VendorPrice: utils.MustInterface2Int64(product["product_price"]),
SalePrice: getSkuSalePrice(product),
// PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
}
if sku.Weight == 0 {
@@ -219,6 +221,26 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
return order
}
func getSkuSalePrice(product map[string]interface{}) (salePrice int64) {
var product2 *ebaiapi.OrderProductInfo
if err := utils.Map2StructByJson(product, &product2, true); err != nil {
return utils.MustInterface2Int64(product["product_price"])
}
return int64(getSkuSalePrice2(product2))
}
func getSkuSalePrice2(product *ebaiapi.OrderProductInfo) (salePrice int) {
salePrice = product.ProductPrice
if product.ProductSubsidy != nil {
for _, v := range product.ProductSubsidy.DiscountDetail {
if v.Type == ebaiapi.OrderSkuDiscountTypeZhe {
salePrice -= v.BaiduRate + v.ShopRate
}
}
}
return salePrice
}
func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
globals.SugarLogger.Debugf("ebai AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt)
if isAcceptIt {