|
|
@@ -1,11 +1,15 @@
|
|
|
import com.alibaba.fastjson2.JSON
|
|
|
import com.dderp.common.api.BusinessExecutor
|
|
|
import com.dderp.common.api.ERPLockDataService
|
|
|
+import com.dderp.common.api.StoreService
|
|
|
+import com.dderp.common.api.flycat.OrderSearchService
|
|
|
import com.dderp.common.datas.ERPModule
|
|
|
import com.dderp.common.datas.RedisKeys
|
|
|
import com.dderp.common.entity.base.InvokeCallParams
|
|
|
import com.dderp.common.entity.base.InvokeCallResult
|
|
|
-import com.dderp.common.entity.express.*
|
|
|
+import com.dderp.common.entity.order.BusinessOrder
|
|
|
+import com.dderp.common.entity.store.StorePlatformRequire
|
|
|
+import com.dderp.common.entity.store.ViewStoreInfo
|
|
|
import com.dderp.common.http.HttpTools
|
|
|
import com.dySweetFishPlugin.sql.dao.OperatorWait
|
|
|
import com.sweetfish.convert.json.JsonConvert
|
|
|
@@ -43,6 +47,12 @@ class BE_Express_CreateOrder_SFTC implements BusinessExecutor<InvokeCallParams,
|
|
|
@Resource
|
|
|
ERPLockDataService lockDataService
|
|
|
|
|
|
+ @Resource
|
|
|
+ OrderSearchService orderSearchService
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ StoreService storeService
|
|
|
+
|
|
|
@Override
|
|
|
String scriptName() {
|
|
|
return "顺丰同城创建订单"
|
|
|
@@ -67,6 +77,11 @@ class BE_Express_CreateOrder_SFTC implements BusinessExecutor<InvokeCallParams,
|
|
|
String orderId = invokeOrder["orderId"] as String
|
|
|
//todo 获取订单信息
|
|
|
|
|
|
+ RetResult<BusinessOrder> orderResult = orderSearchService.getBusinessOrder(Long.parseLong(orderId), source.currentUser, source.dataSourceId, source.supplierCode)
|
|
|
+ if (!orderResult.isSuccess()) {
|
|
|
+ return RetResult.<InvokeCallParams> errorT().retinfo("无效的订单信息")
|
|
|
+ }
|
|
|
+
|
|
|
return RetResult.<InvokeCallParams> successT().result(source)
|
|
|
}
|
|
|
|
|
|
@@ -78,7 +93,6 @@ class BE_Express_CreateOrder_SFTC implements BusinessExecutor<InvokeCallParams,
|
|
|
|
|
|
String orderId = invokeOrder["orderId"] as String
|
|
|
|
|
|
- //todo 获取订单信息
|
|
|
if (lockDataService.hLockAdd(orderId, RedisKeys.KEY_ERP_WORKING_ORDER, source.supplierCode) > 1) {
|
|
|
return RetResult.<InvokeCallParams> errorT().retinfo(orderId + "提交工作中,请稍后刷新即可,无需重复操作")
|
|
|
}
|
|
|
@@ -97,51 +111,68 @@ class BE_Express_CreateOrder_SFTC implements BusinessExecutor<InvokeCallParams,
|
|
|
}
|
|
|
|
|
|
RetResult<InvokeCallResult> execute(InvokeCallParams source) {
|
|
|
+ //检查订单信息
|
|
|
+ def jsonSlurper = new JsonSlurper()
|
|
|
+ def invokeOrder = jsonSlurper.parseText(source.params)
|
|
|
+
|
|
|
+ String orderId = invokeOrder["orderId"] as String
|
|
|
+
|
|
|
+ RetResult<BusinessOrder> orderResult = orderSearchService.getBusinessOrder(Long.parseLong(orderId), source.currentUser, source.dataSourceId, source.supplierCode)
|
|
|
+ if (!orderResult.isSuccess()) {
|
|
|
+ return RetResult.<InvokeCallResult> errorT().retinfo("无效的订单信息")
|
|
|
+ }
|
|
|
+
|
|
|
+ BusinessOrder businessOrder = orderResult.result
|
|
|
+
|
|
|
+ ViewStoreInfo viewStoreInfo = storeService.getViewStoreInfo(businessOrder.idStore, source.supplierCode, false, false, true)
|
|
|
+ if (viewStoreInfo == null) {
|
|
|
+ return RetResult.<InvokeCallResult> errorT().retinfo("无效的门店信息")
|
|
|
+ }
|
|
|
+ if (viewStoreInfo.storeInfo == null) {
|
|
|
+ return RetResult.<InvokeCallResult> errorT().retinfo("无效的门店信息")
|
|
|
+ }
|
|
|
+ StorePlatformRequire storePlatformRequire = viewStoreInfo.storeInfo.requireItem("SFTC", "shopId")
|
|
|
+ if (storePlatformRequire == null) {
|
|
|
+ return RetResult.<InvokeCallResult> errorT().retinfo("门店未设置顺丰店铺id")
|
|
|
+ }
|
|
|
+
|
|
|
//秒级时间戳,groovy里面不让用system
|
|
|
long currentTime = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))
|
|
|
long testTime = LocalDateTime.now().toInstant(ZoneOffset.ofHours(8)).toEpochMilli()
|
|
|
- SFOrder sfOrder = new SFOrder(
|
|
|
- dev_id: sfAppId,
|
|
|
- shop_id: "3243279847393",
|
|
|
- shop_type: 1,
|
|
|
- shop_order_id: "JY" + testTime + "L",
|
|
|
- order_sequence: "测试",
|
|
|
- lbs_type: 2,
|
|
|
- order_time: currentTime,
|
|
|
- push_time: currentTime,
|
|
|
- vehicle: 0,
|
|
|
- four_wheeler_type: 10,
|
|
|
- rider_pick_method: 1,
|
|
|
- version: 19,
|
|
|
-
|
|
|
- order_detail: new SFOrderDetail(
|
|
|
- total_price: 30100L,
|
|
|
- product_type: 6,
|
|
|
- weight_gram: 3000L,
|
|
|
- product_num: 15,
|
|
|
- product_type_num: 5,
|
|
|
- product_detail: [
|
|
|
- new SFOrderProductDetail(
|
|
|
- product_name: "测试商品1",
|
|
|
- product_num: 1
|
|
|
- ),
|
|
|
- new SFOrderProductDetail(
|
|
|
- product_name: "测试商品2",
|
|
|
- product_num: 3
|
|
|
- ),
|
|
|
- ]
|
|
|
-
|
|
|
- ),
|
|
|
-
|
|
|
- receive: new SFOrderReceive(
|
|
|
- user_name: "顺丰同城",
|
|
|
- user_phone: "18237171439",
|
|
|
- user_lng: "116.339392",
|
|
|
- user_lat: "40.002349",
|
|
|
- user_address: "北京市海淀区学清嘉创大厦A座15层"
|
|
|
- )
|
|
|
- )
|
|
|
|
|
|
+ def sfOrder = [
|
|
|
+ dev_id : sfAppId,
|
|
|
+ shop_id : storePlatformRequire.itemValue,
|
|
|
+ shop_type : 1,
|
|
|
+ shop_order_id : businessOrder.orderCode,
|
|
|
+ order_source : businessOrder.incomePlatformName,
|
|
|
+ order_sequence: String.valueOf(businessOrder.orderSequence),
|
|
|
+ order_time : currentTime,
|
|
|
+ push_time : currentTime,
|
|
|
+ version : 19,
|
|
|
+
|
|
|
+ order_detail : [
|
|
|
+ total_price : 30100L,
|
|
|
+ product_type : 1,
|
|
|
+ weight_gram : 3000L,
|
|
|
+ product_num : 15,
|
|
|
+ product_type_num: 5,
|
|
|
+ product_detail : businessOrder.detailItemList.collect { detailItem ->
|
|
|
+ def productDetail = [
|
|
|
+ product_name: detailItem.itemName,
|
|
|
+ product_num : detailItem.itemCount
|
|
|
+ ]
|
|
|
+ return productDetail
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ receive : [
|
|
|
+ user_name : businessOrder.orderDeliveryInfo.receiveMan,
|
|
|
+ user_phone : businessOrder.orderDeliveryInfo.contractPhone,
|
|
|
+ user_lng : String.valueOf(businessOrder.orderDeliveryInfo.geoPoiLocation.longitude),
|
|
|
+ user_lat : String.valueOf(businessOrder.orderDeliveryInfo.geoPoiLocation.latitude),
|
|
|
+ user_address: businessOrder.orderDeliveryInfo.deliverAddress
|
|
|
+ ]
|
|
|
+ ]
|
|
|
|
|
|
String postData = JSON.toJSONString(sfOrder)
|
|
|
logger.info("请求数据: " + postData)
|
|
|
@@ -155,16 +186,11 @@ class BE_Express_CreateOrder_SFTC implements BusinessExecutor<InvokeCallParams,
|
|
|
postData,
|
|
|
["Content-Type": "application/json;charset=utf-8"])
|
|
|
try {
|
|
|
- String orderResult = apiResult.get(6000, TimeUnit.SECONDS)
|
|
|
-
|
|
|
- def jsonSlurper = new JsonSlurper()
|
|
|
- def sfOrderJson = jsonSlurper.parseText(orderResult)
|
|
|
+ String sfCreateOrderJson = apiResult.get(6000, TimeUnit.SECONDS)
|
|
|
|
|
|
- logger.info(sfOrderJson)
|
|
|
+ def sfOrderData = jsonSlurper.parseText(sfCreateOrderJson)
|
|
|
|
|
|
- SFCreateOrderResult createOrderResult = jsonConvert.convertFromO(SFCreateOrderResult.class, orderResult)
|
|
|
- logger.info(orderResult)
|
|
|
- logger.info(jsonConvert.convertTo(createOrderResult))
|
|
|
+ logger.info(sfOrderData)
|
|
|
|
|
|
return RetResult.<InvokeCallResult> successT()
|
|
|
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|