فهرست منبع

顺丰同城门店取消授权回调

jlutt@163.com 2 سال پیش
والد
کامیت
e20893c321

+ 1 - 1
conf/script/1000/business/BE_DocClearScriptCache.groovy

@@ -101,7 +101,7 @@ class BE_DocClearScriptCache implements BusinessExecutor<ProcessEntityItem<ERPMo
                         expressOutService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
                     }
                     break
-                case ERPModule.ERP_ORDER:
+                case [ERPModule.ERP_ORDER, ERPModule.ORDER_API]:
                     if (source.getOperation() == BusinessOperation.SAVE) {
                         orderService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
                     } else {

+ 13 - 5
conf/script/1000/expressApi/BE_Express_CallBack_Invoke_SFTC.groovy

@@ -1,5 +1,8 @@
 import com.dderp.business.dao.OrderDao
-import com.dderp.common.api.*
+import com.dderp.common.api.BusinessExecutor
+import com.dderp.common.api.ERPLockDataService
+import com.dderp.common.api.StoreService
+import com.dderp.common.api.SupplierInitService
 import com.dderp.common.api.flycat.OrderSearchService
 import com.dderp.common.api.flycat.OrderStepService
 import com.dderp.common.datas.ERPModule
@@ -44,9 +47,6 @@ class BE_Express_CallBack_Invoke_SFTC implements BusinessExecutor<InvokeCallPara
     ERPLockDataService lockDataService
 
     @Resource
-    NoSqlKeysService keysService
-
-    @Resource
     StoreService storeService
 
     @Resource
@@ -718,7 +718,15 @@ class BE_Express_CallBack_Invoke_SFTC implements BusinessExecutor<InvokeCallPara
                 return RetResult.<InvokeCallResult> successT().result(
                         InvokeCallResult.success()
                 )
+            },
+
+            "cancelbindnotify@0"      : { invokeOrder, InvokeCallParams source ->
+                storeService.unBindStorePlatform(source.params, "SFTC", source.dataSourceId, source.supplierCode, source.currentUser)
+                return RetResult.<InvokeCallResult> successT().result(
+                        InvokeCallResult.success()
+                )
             }
+
     ]
 
     @Override
@@ -805,7 +813,7 @@ class BE_Express_CallBack_Invoke_SFTC implements BusinessExecutor<InvokeCallPara
 
         String urlIndex = invokeOrder["url_index"]
         int orderStatus = 0
-        if (!StringUtils.equalsIgnoreCase("bindnotify", urlIndex)) {
+        if ((!StringUtils.equalsIgnoreCase("bindnotify", urlIndex)) && (!StringUtils.equalsIgnoreCase("cancelbindnotify", urlIndex))) {
             orderStatus = invokeOrder["order_status"] as int
         }
 

+ 0 - 1
conf/script/1000/storeApi/BE_Store_BindStorePlatform_SFTC.groovy

@@ -116,7 +116,6 @@ class BE_Store_BindStorePlatform_SFTC implements BusinessExecutor<ProcessStringI
                 dev_id           : sfAppId,
                 shop_id          : invokeContent["shop_id"] as String,
                 push_time        : currentTime,
-
         ]
         String postData = JSON.toJSONString(sfStoreRequest)
         String sign = ExpressApiSign.sfGenerateOpenSign(postData, sfAppId, sfAppKey)

+ 99 - 0
conf/script/1000/storeApi/BE_Store_UnBindStorePlatform_SFTC.groovy

@@ -0,0 +1,99 @@
+import com.dderp.business.dao.StoreDao
+import com.dderp.common.api.BusinessExecutor
+import com.dderp.common.api.NoSqlKeysService
+import com.dderp.common.api.StoreService
+import com.dderp.common.datas.ERPModule
+import com.dderp.common.datas.ESKeys
+import com.dderp.common.datas.flycat.PlatformType
+import com.dderp.common.entity.base.ProcessStringItem
+import com.dderp.common.entity.site.ERPTokenUser
+import com.dderp.common.entity.store.StoreInfo
+import com.dderp.common.entity.store.StorePlatform
+import com.dySweetFishPlugin.elasticsearch.ESClient
+import com.dySweetFishPlugin.sql.dao.TunaService
+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 static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder
+
+@SuppressWarnings("unused")
+class BE_Store_UnBindStorePlatform_SFTC implements BusinessExecutor<ProcessStringItem, StorePlatform> {
+
+    private final Logger logger = LogManager.getLogger(this.getClass().getSimpleName())
+
+    @Resource
+    private StoreService storeService
+
+    @Resource
+    private ESClient esClient
+
+    @Resource
+    private NoSqlKeysService keysService
+
+    @Resource
+    private TunaService tunaService
+
+    private StoreDao storeDao
+
+    @Override
+    String scriptName() {
+        return "顺丰同城门店取消授权回调"
+    }
+
+    @Override
+    ERPModule module() {
+        return ERPModule.STORE_API
+    }
+
+    @Override
+    void start(long supplierCode) {
+        storeDao = tunaService.generate(StoreDao.class)
+    }
+
+    RetResult<StorePlatform> execute(ProcessStringItem source) {
+
+        String dataSourceId = source.dataSourceId
+        long supplierCode = source.supplierCode
+        ERPTokenUser currentUser = source.currentUser
+
+        def jsonSlurper = new JsonSlurper()
+        def invokeContent = jsonSlurper.parseText(source.itemValue)
+
+        long idStore = invokeContent["out_shop_id"] as Long
+        StoreInfo storeInfo = storeService.getStoreInfo(idStore, supplierCode, false, false, false)
+        if (storeInfo == null) return RetResult.<StorePlatform> errorT().retinfo("门店信息不存在")
+
+        //查询之前绑定过这个门店没有
+        StorePlatform esStorePlatform = storeService.getStorePlatformByInvokeInfo(invokeContent["shop_id"] as String,
+                "SFTC", PlatformType.delivery.value, supplierCode)
+
+        if (esStorePlatform != null) {
+            esStorePlatform.enableStatue = 0
+            StorePlatform.update(esStorePlatform, currentUser.id)
+            try {
+                esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE,
+                        String.valueOf(esStorePlatform.getId()))
+                        .setDoc(jsonBuilder()
+                                .startObject()
+                                .field("enableStatue", esStorePlatform.enableStatue)
+                                .field("updateBy", esStorePlatform.getUpdateBy())
+                                .field("updateTimeLong", esStorePlatform.getUpdateTimeLong())
+                                .endObject())
+                        .get()
+
+
+                storeDao.enableStorePlatform(esStorePlatform, dataSourceId, supplierCode)
+                return RetResult.<StorePlatform> successT().result(esStorePlatform)
+            } catch (IOException e) {
+                logger.error("取消绑定门店出错:" + e.getMessage(), e)
+                return RetResult.<StorePlatform> errorT().retinfo("取消绑定门店出错:" + e.getMessage())
+            }
+        } else {
+            return RetResult.<StorePlatform> successT()
+        }
+    }
+}

+ 13 - 0
ddBusiness/src/main/java/com/dderp/business/service/StoreServiceImpl.java

@@ -754,6 +754,19 @@ public class StoreServiceImpl extends BaseService implements StoreService {
         );
     }
 
+    public RetResult<StorePlatform> unBindStorePlatform(String requestContent, String platformCode, String dataSourceId, long supplierCode, ERPTokenUser currentUser) {
+        return handleScript("Store_UnBindStorePlatform_" + platformCode.toUpperCase(), ERPModule.STORE_API,
+                dataSourceId, supplierCode,
+                () -> ProcessStringItem.newBuilder()
+                        .itemValue(requestContent)
+                        .dataSourceId(dataSourceId)
+                        .supplierCode(supplierCode)
+                        .currentUser(currentUser)
+                        .build()
+                        .addConvert("storePlatformWriteConvert", storePlatformWriteConvert)
+        );
+    }
+
     public RetResult<List<StorePlatform>> getStorePlatformList(long idStore, String platformCode, long supplierCode) {
         PlatformInfo platformInfo = platformService.getPlatformInfoByCode(platformCode, false, supplierCode);
         if (platformInfo == null) {

+ 2 - 0
ddCommon/src/main/java/com/dderp/common/api/StoreService.java

@@ -56,6 +56,8 @@ public interface StoreService extends ScriptService {
 
     RetResult<StorePlatform> bindStorePlatform(String requestContent, String platformCode, String dataSourceId, long supplierCode, ERPTokenUser currentUser);
 
+    RetResult<StorePlatform> unBindStorePlatform(String requestContent, String platformCode, String dataSourceId, long supplierCode, ERPTokenUser currentUser);
+
     RetResult<List<StorePlatform>> getStorePlatformList(long idStore, String platformCode, long supplierCode);
 
     /**