From 5c88bf12985bb47794ab3e6334c3a8292a9635f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 18 Jun 2020 09:34:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=BD=AC=E7=A7=BB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 66 +++++++++++++++++++++++++-- business/jxstore/cms/sku.go | 3 +- business/model/api_config.go | 5 +- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 86d3e3e9f..8fb60d9e5 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -7,6 +7,8 @@ import ( "strings" "time" + "git.rosy.net.cn/baseapi/platformapi/jdeclpapi" + "git.rosy.net.cn/jx-callback/business/jxstore/common" "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" @@ -1184,9 +1186,10 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int) } //重新构建order的数据 storeMaps, err := dao.GetStoresMapList(db, []int{order.VendorID}, []int{order.StoreID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "") - if len(storeMaps) > 0 { + stores, err := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "") + if len(storeMaps) > 0 && len(stores) > 0 { order.StoreID = storeID - order.StoreName = storeMaps[0].StoreName + order.StoreName = stores[0].Name order.VendorStoreID = storeMaps[0].VendorStoreID } else { return "", fmt.Errorf("未查询到该门店对应的平台信息!门店:[%v]", order.StoreID) @@ -1233,8 +1236,61 @@ func SendJdwlForJdsOrder(ctx *jxcontext.Context, vendorOrderID string) (err erro return err } } - handler := partner.DeliveryPlatformHandlers[model.VendorIDJDWL] - waybill2, err := handler.Handler.CreateWaybill(order, 0) - jdshop.CurPurchaseHandler.OrderExport(ctx, vendorOrderID, waybill2.VendorWaybillID, false) + var vendorWaybillID string + if order.StoreID == model.JdShopMainStoreID { + var ( + goodsNos []string + prices []string + quantities []string + ) + for _, v := range order.Skus { + skus, err := dao.GetSkus(db, []int{v.SkuID}, nil, nil, nil, nil) + if err != nil || len(skus) == 0 { + continue + } + goodsNos = append(goodsNos, skus[0].EclpID) + prices = append(prices, "0") + quantities = append(quantities, utils.Int2Str(v.Count)) + } + eclpSoNo, err := api.JdEclpAPI.AddOrder(&jdeclpapi.AddOrderParam{ + IsvUUID: order.VendorOrderID, + IsvSource: jdeclpapi.IsvSource, + ShopNo: jdeclpapi.ShopNo, + DepartmentNo: jdeclpapi.DepartmentNo, + WarehouseNo: jdeclpapi.WarehouseNo, + SalesPlatformOrderNo: order.VendorOrderID, + SalePlatformSource: jdeclpapi.SalePlatformSource, + ConsigneeName: order.ConsigneeName, + ConsigneeMobile: order.ConsigneeMobile, + ConsigneeAddress: order.ConsigneeAddress, + OrderMark: jdeclpapi.OrderMark, + GoodsNo: strings.Join(goodsNos, ","), + Price: strings.Join(prices, ","), + Quantity: strings.Join(quantities, ","), + }) + waybill := &model.Waybill{ + VendorOrderID: order.VendorOrderID, + OrderVendorID: model.VendorIDJX, + VendorWaybillID: eclpSoNo, + WaybillVendorID: model.VendorIDJDWL, + Status: model.WaybillStatusDelivering, + WaybillCreatedAt: time.Now(), + StatusTime: time.Now(), + WaybillFinishedAt: utils.DefaultTimeValue, + DeliveryFlag: model.OrderDeliveryFlagMaskScheduleDisabled, + } + dao.CreateEntity(db, waybill) + if err != nil { + return err + } + } else { + handler := partner.DeliveryPlatformHandlers[model.VendorIDJDWL] + waybill2, err := handler.Handler.CreateWaybill(order, 0) + if err != nil { + return err + } + vendorWaybillID = waybill2.VendorWaybillID + } + jdshop.CurPurchaseHandler.OrderExport(ctx, vendorOrderID, vendorWaybillID, false) return err } diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index be91a073a..9d9d6d5f2 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -2587,8 +2587,7 @@ func UpdateSkuExinfoMap(ctx *jxcontext.Context, nameIDs []int, imgWaterMark stri } CurVendorSync.SyncSkus(ctx, db, nil, skuIDs, isAsync, isContinueWhenError, ctx.GetUserName()) } else { - CurVendorSync.SyncStoresSkus2(ctx, nil, 0, db, []int{vendorID}, nil, false, skuIDs, nil, model.SyncFlagModifiedMask, true, true) - + CurVendorSync.SyncStoresSkus2(ctx, nil, 0, db, []int{vendorID}, nil, false, skuIDs, nil, model.SyncFlagModifiedMask, isAsync, isContinueWhenError) } } } diff --git a/business/model/api_config.go b/business/model/api_config.go index fb5b25ad0..ab6d1ffb4 100644 --- a/business/model/api_config.go +++ b/business/model/api_config.go @@ -26,7 +26,8 @@ const ( VendorIDDada = 101 VendorIDMTPS = 102 VendorIDFengNiao = 103 - VendorIDDeliveryEnd = 200 + VendorIDJDWL = 401 //京东物流 + VendorIDDeliveryEnd = 500 VendorIDPrinterBegin = 201 VendorIDFeiE = 201 // 飞鹅打印机 @@ -48,7 +49,6 @@ const ( VendorIDQiNiuCloud = 323 // 七牛云 VendorIDShowAPI = 325 // 万维易源 - VendorIDJDWL = 401 //京东物流 ) type VendorInfo struct { @@ -82,6 +82,7 @@ var ( VendorIDZhongWu: "ZhongWu", VendorIDQiNiuCloud: "Qiniu", + VendorIDJDWL: "Jdwl", } VendorTypeName = map[int]string{