|
|
@@ -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()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|