|
@@ -0,0 +1,128 @@
|
|
|
|
|
+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.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_ProcessRefundRequest 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
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ RetResult<InvokeCallParams> beforeExecute(InvokeCallParams source) {
|
|
|
|
|
+ return super.beforeExecute(source)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ params : {
|
|
|
|
|
+ "idRefundRequest" : 2 , 客户退款申请id
|
|
|
|
|
+ "approve" : 0 , 拒绝0同意1
|
|
|
|
|
+ "rejectReasonCode" : "101,102,103" , 拒绝原因代码
|
|
|
|
|
+ "rejectMemo" : "拒绝原因备注" 拒绝原因备注
|
|
|
|
|
+ }
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ 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("订单来源平台未知!")
|
|
|
|
|
+
|
|
|
|
|
+ //根据订单来源平台,回调平台的接单接口
|
|
|
|
|
+ switch (storePlatform.platformCode) {
|
|
|
|
|
+ case "DYLK": {
|
|
|
|
|
+ //抖音来客
|
|
|
|
|
+ def postBody = [
|
|
|
|
|
+ order_id:
|
|
|
|
|
+ esOrder.incomePlatformOrderCode
|
|
|
|
|
+ ]
|
|
|
|
|
+ String responseStr = douyinService.postInvoker("/goodlife/v1/trade/buy/merchant_confirm_order/", jsonConvert.convertTo(postBody))
|
|
|
|
|
+ def response = jsonSlurper.parseText(responseStr)
|
|
|
|
|
+ if (response["data"]["error_code"] as Integer == 0) {
|
|
|
|
|
+ return RetResult.<InvokeCallResult> successT()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //todo 抖音侧调用失败,怎么处理?
|
|
|
|
|
+ logger.error("[抖音来客]商户接单平台接口调用失败:" + response["data"]["description"] as String)
|
|
|
|
|
+ return RetResult.<InvokeCallResult> errorT().retinfo("[抖音来客]商户接单平台接口调用失败:" + response["data"]["description"] as String)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return RetResult.<InvokeCallResult> errorT().retinfo("订单来源平台未知!")
|
|
|
|
|
+ }
|
|
|
|
|
+}
|