1
This commit is contained in:
70
business/enterprise/ebai_test.go
Normal file
70
business/enterprise/ebai_test.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
package enterprise
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOOO(t *testing.T) {
|
||||||
|
product := map[string]interface{}{
|
||||||
|
"apply_quantity": 1,
|
||||||
|
"apply_refund_time": 1711447475000,
|
||||||
|
"apply_refund_user_amount": 143,
|
||||||
|
"commodity_type": 2,
|
||||||
|
"custom_sku_id": "25381",
|
||||||
|
"custom_sku_spec_id": "",
|
||||||
|
"discount_detail": map[string]interface{}{
|
||||||
|
"agent_discount_amount": 0,
|
||||||
|
"discount_total_amount": 577,
|
||||||
|
"merchant_discount_amount": 563,
|
||||||
|
"platform_discount_amount": 14,
|
||||||
|
"total_price": 720,
|
||||||
|
"user_discount_amount": 0,
|
||||||
|
},
|
||||||
|
"free_gift": false,
|
||||||
|
"fund_calculate_type": 0,
|
||||||
|
"gift_related_sub_biz_order_id_list": nil,
|
||||||
|
"is_combine": false,
|
||||||
|
"last_refund_status": 0,
|
||||||
|
"platform_sku_id": 16319366072214214,
|
||||||
|
"refund_order_id": 2403269635888396215,
|
||||||
|
"refund_quantity": 1,
|
||||||
|
"refund_status": 50,
|
||||||
|
"refund_user_amount": 143,
|
||||||
|
"refund_weight": 350,
|
||||||
|
"sku_name": "【尽享好价】西红柿 番茄约300~350g/组",
|
||||||
|
"sku_spec_id": "null",
|
||||||
|
"sub_biz_order_id": "4006435770425226215",
|
||||||
|
"upc": "upc-25381",
|
||||||
|
"virtual_type": "0",
|
||||||
|
}
|
||||||
|
skuList := make([]*model.OrderSku, 0, 0)
|
||||||
|
if product["virtual_type"] == ebaiapi.OrderVirtualType {
|
||||||
|
skuName := product["sku_name"].(string)
|
||||||
|
_, _, _, specUnit, _, specQuality := jxutils.SplitSkuName(skuName)
|
||||||
|
number := int(utils.MustInterface2Int64(product["apply_quantity"]))
|
||||||
|
sku := &model.OrderSku{
|
||||||
|
VendorOrderID: "1",
|
||||||
|
VendorID: model.VendorIDEBAI,
|
||||||
|
Count: number,
|
||||||
|
SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(product[ebaiapi.KeyCustomSkuID]), 0)),
|
||||||
|
VendorSkuID: utils.Int2Str(product["platform_sku_id"].(int)),
|
||||||
|
SkuName: skuName,
|
||||||
|
Weight: int(utils.Interface2Int64WithDefault(product["refund_weight"], 0)) / number, // 退单这里的total_weight有BUG,这里的total_weight还是没有退单时的值
|
||||||
|
VendorPrice: utils.MustInterface2Int64(product["refund_user_amount"]),
|
||||||
|
}
|
||||||
|
//sku.SalePrice, _, sku.StoreSubName = getSkuSalePrice(product)
|
||||||
|
sku.SalePrice = utils.Interface2Int64WithDefault(product["discount_detail"].(map[string]interface{})["total_price"], 0)
|
||||||
|
if sku.Weight == 0 {
|
||||||
|
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) // 订单信息里没有重量,只有名字里尝试找
|
||||||
|
}
|
||||||
|
skuList = append(skuList, sku)
|
||||||
|
}
|
||||||
|
|
||||||
|
globals.SugarLogger.Debugf("=====skulist := %s", utils.Format4Output(skuList, false))
|
||||||
|
|
||||||
|
}
|
||||||
@@ -423,6 +423,9 @@ func (c *OrderManager) SaveOrder(order *model.GoodsOrder, isAdjust bool, db *dao
|
|||||||
}
|
}
|
||||||
_, _, err = db.Db.ReadOrCreate(originalOrder, "VendorOrderID", "VendorID")
|
_, _, err = db.Db.ReadOrCreate(originalOrder, "VendorOrderID", "VendorID")
|
||||||
if created {
|
if created {
|
||||||
|
if order.VendorOrderID == "4062150144186637882" {
|
||||||
|
globals.SugarLogger.Debugf("=====err----- %s", utils.Format4Output(order.Skus, false))
|
||||||
|
}
|
||||||
if err = dao.CreateMultiEntities(db, order.Skus); err != nil {
|
if err = dao.CreateMultiEntities(db, order.Skus); err != nil {
|
||||||
baseapi.SugarLogger.Warnf("saveOrder orderID:%s, save order_sku failed with error:%v", order.VendorOrderID, err)
|
baseapi.SugarLogger.Warnf("saveOrder orderID:%s, save order_sku failed with error:%v", order.VendorOrderID, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ func (p *PurchaseHandler) partRefund2OrderDetailSkuList(orderID string, orderDet
|
|||||||
skuList = append(skuList, sku)
|
skuList = append(skuList, sku)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if orderID == "4062150144186637882" {
|
||||||
|
globals.SugarLogger.Debugf("=====order----- %s", utils.Format4Output(skuList, false))
|
||||||
|
}
|
||||||
return skuList
|
return skuList
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,6 +547,7 @@ func (c *PurchaseHandler) onOrderMsg(msg *ebaiapi.CallbackMsg) (retVal *ebaiapi.
|
|||||||
order, err = c.GetOrder4PartRefund(GetOrderIDFromMsg(msg))
|
order, err = c.GetOrder4PartRefund(GetOrderIDFromMsg(msg))
|
||||||
if status.RefVendorOrderID == "4062150144186637882" {
|
if status.RefVendorOrderID == "4062150144186637882" {
|
||||||
globals.SugarLogger.Debugf("=====order----- %s", utils.Format4Output(order, false))
|
globals.SugarLogger.Debugf("=====order----- %s", utils.Format4Output(order, false))
|
||||||
|
globals.SugarLogger.Debugf("=====order-skus---- %s", utils.Format4Output(order.Skus, false))
|
||||||
globals.SugarLogger.Debugf("=====order----- %v", err)
|
globals.SugarLogger.Debugf("=====order----- %v", err)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user