- add SaveOrder to IOrderManager
- add Map2Order to IPurchasePlatformHandler
This commit is contained in:
@@ -79,83 +79,90 @@ func (c *PurchaseHandler) GetOrder(orderID string) (order *model.GoodsOrder, err
|
||||
task.Run()
|
||||
task.GetResult(0)
|
||||
if err == nil {
|
||||
order = &model.GoodsOrder{
|
||||
VendorOrderID: orderID,
|
||||
VendorID: model.VendorIDJD,
|
||||
VendorStoreID: result["produceStationNo"].(string),
|
||||
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["produceStationNoIsv"]), 0)),
|
||||
StoreName: utils.Interface2String(result["produceStationName"]),
|
||||
ConsigneeName: result["buyerFullName"].(string),
|
||||
ConsigneeMobile: result["buyerMobile"].(string),
|
||||
ConsigneeAddress: result["buyerFullAddress"].(string),
|
||||
CoordinateType: model.CoordinateTypeMars,
|
||||
BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["orderBuyerRemark"])),
|
||||
ExpectedDeliveredTime: utils.Str2TimeWithDefault(utils.Interface2String(result["orderPreEndDeliveryTime"]), utils.DefaultTimeValue),
|
||||
VendorStatus: utils.Int64ToStr(utils.MustInterface2Int64(result["orderStatus"])),
|
||||
OrderSeq: int(utils.MustInterface2Int64(result["orderNum"])),
|
||||
StatusTime: utils.Str2Time(result["orderPurchaseTime"].(string)),
|
||||
OriginalData: string(utils.MustMarshal(result)),
|
||||
ActualPayPrice: utils.MustInterface2Int64(result["orderBuyerPayableMoney"]),
|
||||
Skus: []*model.OrderSku{},
|
||||
}
|
||||
order = c.Map2Order(result)
|
||||
if err2 == nil {
|
||||
order.ConsigneeMobile2 = result2
|
||||
} else {
|
||||
// globals.SugarLogger.Warnf("jd GetOrder orderID:%s, GetRealMobile4Order failed with error:%v", orderID, err2)
|
||||
}
|
||||
order.Status = c.GetStatusFromVendorStatus(order.VendorStatus)
|
||||
businessTage := utils.Interface2String(result["businessTag"])
|
||||
if strings.Index(businessTage, "dj_aging_immediately") >= 0 {
|
||||
order.BusinessType = model.BusinessTypeImmediate
|
||||
} else {
|
||||
order.BusinessType = model.BusinessTypeDingshida
|
||||
}
|
||||
coordinateType := utils.Interface2Int64WithDefault(result["buyerCoordType"], 1)
|
||||
originalLng := utils.MustInterface2Float64(result["buyerLng"])
|
||||
originalLat := utils.MustInterface2Float64(result["buyerLat"])
|
||||
if coordinateType == 1 {
|
||||
lng, lat, err2 := api.AutonaviAPI.CoordinateConvert(originalLng, originalLat, autonavi.CoordSysGPS)
|
||||
if err2 == nil {
|
||||
originalLng = lng
|
||||
originalLat = lat
|
||||
} else {
|
||||
// 如果没有转成功,保留原始数据
|
||||
order.CoordinateType = model.CoordinateTypeGPS
|
||||
}
|
||||
}
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(originalLng)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(originalLat)
|
||||
// discounts := result["discount"].(map[string]interface{})
|
||||
for _, product2 := range result["product"].([]interface{}) {
|
||||
product := product2.(map[string]interface{})
|
||||
sku := &model.OrderSku{
|
||||
VendorOrderID: orderID,
|
||||
VendorID: model.VendorIDJD,
|
||||
Count: int(utils.MustInterface2Int64(product["skuCount"])),
|
||||
SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(product["skuIdIsv"]), 0)),
|
||||
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(product["skuId"])),
|
||||
SkuName: product["skuName"].(string),
|
||||
Weight: jxutils.FloatWeight2Int(float32(utils.MustInterface2Float64(product["skuWeight"]))),
|
||||
SalePrice: utils.MustInterface2Int64(product["skuJdPrice"]),
|
||||
PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
|
||||
}
|
||||
if skuCostumeProperty, ok := product["skuCostumeProperty"]; ok {
|
||||
sku.SkuName += skuCostumeProperty.(string)
|
||||
}
|
||||
if product["isGift"].(bool) {
|
||||
sku.SkuType = 1
|
||||
}
|
||||
order.Skus = append(order.Skus, sku)
|
||||
order.SkuCount++
|
||||
order.GoodsCount += sku.Count
|
||||
order.SalePrice += sku.SalePrice * int64(sku.Count)
|
||||
order.Weight += sku.Weight * sku.Count
|
||||
}
|
||||
setOrederDetailFee(result, order)
|
||||
}
|
||||
return order, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder) {
|
||||
result := orderData
|
||||
orderID := utils.Int64ToStr(utils.MustInterface2Int64(result["orderId"]))
|
||||
order = &model.GoodsOrder{
|
||||
VendorOrderID: orderID,
|
||||
VendorID: model.VendorIDJD,
|
||||
VendorStoreID: result["produceStationNo"].(string),
|
||||
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["produceStationNoIsv"]), 0)),
|
||||
StoreName: utils.Interface2String(result["produceStationName"]),
|
||||
ConsigneeName: result["buyerFullName"].(string),
|
||||
ConsigneeMobile: result["buyerMobile"].(string),
|
||||
ConsigneeAddress: result["buyerFullAddress"].(string),
|
||||
CoordinateType: model.CoordinateTypeMars,
|
||||
BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["orderBuyerRemark"])),
|
||||
ExpectedDeliveredTime: utils.Str2TimeWithDefault(utils.Interface2String(result["orderPreEndDeliveryTime"]), utils.DefaultTimeValue),
|
||||
VendorStatus: utils.Int64ToStr(utils.MustInterface2Int64(result["orderStatus"])),
|
||||
OrderSeq: int(utils.MustInterface2Int64(result["orderNum"])),
|
||||
StatusTime: utils.Str2Time(result["orderPurchaseTime"].(string)),
|
||||
OriginalData: string(utils.MustMarshal(result)),
|
||||
ActualPayPrice: utils.MustInterface2Int64(result["orderBuyerPayableMoney"]),
|
||||
Skus: []*model.OrderSku{},
|
||||
}
|
||||
order.Status = c.GetStatusFromVendorStatus(order.VendorStatus)
|
||||
businessTage := utils.Interface2String(result["businessTag"])
|
||||
if strings.Index(businessTage, "dj_aging_immediately") >= 0 {
|
||||
order.BusinessType = model.BusinessTypeImmediate
|
||||
} else {
|
||||
order.BusinessType = model.BusinessTypeDingshida
|
||||
}
|
||||
coordinateType := utils.Interface2Int64WithDefault(result["buyerCoordType"], 1)
|
||||
originalLng := utils.MustInterface2Float64(result["buyerLng"])
|
||||
originalLat := utils.MustInterface2Float64(result["buyerLat"])
|
||||
if coordinateType == 1 {
|
||||
lng, lat, err2 := api.AutonaviAPI.CoordinateConvert(originalLng, originalLat, autonavi.CoordSysGPS)
|
||||
if err2 == nil {
|
||||
originalLng = lng
|
||||
originalLat = lat
|
||||
} else {
|
||||
// 如果没有转成功,保留原始数据
|
||||
order.CoordinateType = model.CoordinateTypeGPS
|
||||
}
|
||||
}
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(originalLng)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(originalLat)
|
||||
// discounts := result["discount"].(map[string]interface{})
|
||||
for _, product2 := range result["product"].([]interface{}) {
|
||||
product := product2.(map[string]interface{})
|
||||
sku := &model.OrderSku{
|
||||
VendorOrderID: orderID,
|
||||
VendorID: model.VendorIDJD,
|
||||
Count: int(utils.MustInterface2Int64(product["skuCount"])),
|
||||
SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(product["skuIdIsv"]), 0)),
|
||||
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(product["skuId"])),
|
||||
SkuName: product["skuName"].(string),
|
||||
Weight: jxutils.FloatWeight2Int(float32(utils.MustInterface2Float64(product["skuWeight"]))),
|
||||
SalePrice: utils.MustInterface2Int64(product["skuJdPrice"]),
|
||||
PromotionType: int(utils.MustInterface2Int64(product["promotionType"])),
|
||||
}
|
||||
if skuCostumeProperty, ok := product["skuCostumeProperty"]; ok {
|
||||
sku.SkuName += skuCostumeProperty.(string)
|
||||
}
|
||||
if product["isGift"].(bool) {
|
||||
sku.SkuType = 1
|
||||
}
|
||||
order.Skus = append(order.Skus, sku)
|
||||
order.SkuCount++
|
||||
order.GoodsCount += sku.Count
|
||||
order.SalePrice += sku.SalePrice * int64(sku.Count)
|
||||
order.Weight += sku.Weight * sku.Count
|
||||
}
|
||||
setOrederDetailFee(result, order)
|
||||
return order
|
||||
}
|
||||
|
||||
func setOrederDetailFee(result map[string]interface{}, order *model.GoodsOrder) {
|
||||
order.BoxFee = utils.MustInterface2Int64(result["packagingMoney"])
|
||||
order.PlatformFeeRate = model.JdPlatformFeeRate
|
||||
|
||||
Reference in New Issue
Block a user