|
@@ -0,0 +1,138 @@
|
|
|
|
|
+import com.dderp.business.dao.OrderDao
|
|
|
|
|
+import com.dderp.common.api.BusinessExecutor
|
|
|
|
|
+import com.dderp.common.api.StoreService
|
|
|
|
|
+import com.dderp.common.api.SupplierInitService
|
|
|
|
|
+import com.dderp.common.api.flycat.DouyinService
|
|
|
|
|
+import com.dderp.common.api.flycat.OrderSearchService
|
|
|
|
|
+import com.dderp.common.api.flycat.OrderService
|
|
|
|
|
+import com.dderp.common.api.flycat.OrderStepService
|
|
|
|
|
+import com.dderp.common.datas.ERPModule
|
|
|
|
|
+import com.dderp.common.datas.flycat.BusinessOrderStatus
|
|
|
|
|
+import com.dderp.common.entity.base.InvokeCallParams
|
|
|
|
|
+import com.dderp.common.entity.base.InvokeCallResult
|
|
|
|
|
+import com.dderp.common.entity.order.BusinessOrder
|
|
|
|
|
+import com.dderp.common.entity.site.ERPTokenUser
|
|
|
|
|
+import com.dderp.common.entity.store.StorePlatform
|
|
|
|
|
+import com.dySweetFishPlugin.elasticsearch.ESClient
|
|
|
|
|
+import com.dySweetFishPlugin.sql.TableIdService
|
|
|
|
|
+import com.dySweetFishPlugin.sql.dao.TunaService
|
|
|
|
|
+import com.sweetfish.convert.json.JsonConvert
|
|
|
|
|
+import com.sweetfish.service.RetResult
|
|
|
|
|
+import groovy.json.JsonSlurper
|
|
|
|
|
+import org.apache.logging.log4j.LogManager
|
|
|
|
|
+import org.apache.logging.log4j.Logger
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource
|
|
|
|
|
+import java.time.LocalDateTime
|
|
|
|
|
+import java.time.ZoneOffset
|
|
|
|
|
+
|
|
|
|
|
+@SuppressWarnings("unused")
|
|
|
|
|
+class BE_Order_SubmitDeliveryInfo_DYLK implements BusinessExecutor<InvokeCallParams, InvokeCallResult> {
|
|
|
|
|
+
|
|
|
|
|
+ private final Logger logger = LogManager.getLogger(this.getClass().getSimpleName())
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private JsonConvert jsonConvert
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private TableIdService tableIdService
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private StoreService storeService
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private ESClient esClient
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private SupplierInitService supplierInitService
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private OrderStepService orderStepService
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private OrderService orderService
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private OrderSearchService orderSearchService
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private DouyinService douyinService
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private TunaService tunaService
|
|
|
|
|
+
|
|
|
|
|
+ private OrderDao orderDao
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ String scriptName() {
|
|
|
|
|
+ return "[抖音来客]回传配送信息"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ ERPModule module() {
|
|
|
|
|
+ return ERPModule.ORDER_API
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ params : {
|
|
|
|
|
+ "idOrder" : 2, 系统订单id
|
|
|
|
|
+ //"order_id" : "8000007372302629122" , 抖音的订单id,不要了,传入系统内订单id就行了
|
|
|
|
|
+ "rider_phone" : "123241289303" , 骑手电话
|
|
|
|
|
+ "three_source" : 7 , 三方配送商,注1
|
|
|
|
|
+ "behavior" : 2 , 回传状态,注2
|
|
|
|
|
+ "accept_time" : 1669344364 , 骑手接单时间戳,秒
|
|
|
|
|
+ "rider_flow_time" : 1669344364 , 骑手信息采集时间戳,秒
|
|
|
|
|
+ "rider_lat" : 43.26 , 骑手坐标,GCJ02坐标
|
|
|
|
|
+ "rider_lng" : 26.36 , 骑手坐标,GCJ02坐标
|
|
|
|
|
+ "rider_name" : "配送员姓名" , 骑手姓名
|
|
|
|
|
+ "rider_phone_type" : 0 , 骑手电话类型0真实号1隐私号
|
|
|
|
|
+ "three_delivery_id" : "SF263579679634687" 三方物流单号
|
|
|
|
|
+ }
|
|
|
|
|
+ 注1: 三方配送商标示 0=顺丰同城;1=新达达;2=蜂鸟配送;3=美团配送;4=闪送;5=点我达;6=UU跑腿;8=信天翁;10=365跑腿;11=曹操跑腿;12=爱跑腿;13=快跑者;14=极客快送;15=同达;16=生活半径;17=临趣;18=趣送;19=快服务;20=菜鸟新联盟;21=风先生;22=来答配送;23=好急跑腿;24=送个东西跑题;25=靠谱送;26=快男跑腿;27=裹小递 7=其他;1000=商家自配送
|
|
|
|
|
+ 注2: 1=骑手已接单; 2=骑手已到店; 3=骑手已取货(配送中); 4=骑手已送达; 5=运单取消 (允许跨状态回传,例如1->3,跳过2)
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ RetResult<InvokeCallResult> execute(InvokeCallParams source) {
|
|
|
|
|
+ //秒级时间戳,groovy里面不让用system
|
|
|
|
|
+ long currentTime = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))
|
|
|
|
|
+ String dataSourceId = source.dataSourceId
|
|
|
|
|
+ long supplierCode = source.supplierCode
|
|
|
|
|
+ ERPTokenUser currentUser = source.currentUser
|
|
|
|
|
+
|
|
|
|
|
+ def jsonSlurper = new JsonSlurper()
|
|
|
|
|
+ def invokeOrder = jsonSlurper.parseText(source.params)
|
|
|
|
|
+ long idOrder = invokeOrder["idOrder"] as Long
|
|
|
|
|
+ RetResult<BusinessOrder> orderResult = orderSearchService.getBusinessOrder(idOrder, currentUser, dataSourceId, supplierCode, null)
|
|
|
|
|
+ if (!orderResult.isSuccess()) return RetResult.<InvokeCallResult> errorT().retinfo(orderResult.retinfo)
|
|
|
|
|
+
|
|
|
|
|
+ BusinessOrder esOrder = orderResult.result
|
|
|
|
|
+
|
|
|
|
|
+ StorePlatform storePlatform = storeService.getStorePlatformInfo(esOrder.incomePlatformId, supplierCode)
|
|
|
|
|
+ if (storePlatform == null) return RetResult.<InvokeCallResult> errorT().retinfo("订单来源平台未知!")
|
|
|
|
|
+ if (storePlatform.platformCode != "DYLK") return RetResult.<InvokeCallResult> errorT().retinfo("同步配送信息失败:订单来源平台有误")
|
|
|
|
|
+
|
|
|
|
|
+ //抖音来客
|
|
|
|
|
+ def postBody = [
|
|
|
|
|
+ order_id : esOrder.incomePlatformOrderCode,
|
|
|
|
|
+ behavior : invokeOrder["behavior"] as int,
|
|
|
|
|
+ three_source : invokeOrder["three_source"] as int,
|
|
|
|
|
+ accept_time : invokeOrder["accept_time"] as int,
|
|
|
|
|
+ rider_flow_time : invokeOrder["rider_flow_time"] as int,
|
|
|
|
|
+ rider_lat : invokeOrder["rider_lat"] as double,
|
|
|
|
|
+ rider_lng : invokeOrder["rider_lng"] as double,
|
|
|
|
|
+ rider_name : invokeOrder["rider_name"] as String,
|
|
|
|
|
+ rider_phone : invokeOrder["rider_phone"] as String,
|
|
|
|
|
+ rider_phone_type : invokeOrder["rider_phone_type"] as int,
|
|
|
|
|
+ three_delivery_id: invokeOrder["three_delivery_id"] as String
|
|
|
|
|
+ ]
|
|
|
|
|
+ String responseStr = douyinService.postInvoker("/goodlife/v1/fulfilment/distribution/order/sync_status/", jsonConvert.convertTo(postBody))
|
|
|
|
|
+ def response = jsonSlurper.parseText(responseStr)
|
|
|
|
|
+ if (response["extra"]["error_code"] as Integer == 0) {
|
|
|
|
|
+ return RetResult.<InvokeCallResult> successT()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //todo 抖音侧调用失败,怎么处理?
|
|
|
|
|
+ logger.error("[抖音来客]回传配送信息接口调用失败:" + response["extra"]["description"] as String)
|
|
|
|
|
+ return RetResult.<InvokeCallResult> errorT().retinfo("[抖音来客]回传配送信息接口调用失败:" + response["extra"]["description"] as String)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|