Commit f8f68720 by 陶光胜

门店变更

parent ff678a35
......@@ -38,6 +38,8 @@ public class StoreMessageHandler implements MessageHandler {
public static final String NEW_STATUS = "new_status";
public static final String NEW_OWN_TYPE = "new_own_type";
public static final Integer NEW_STATUS_VALUE = 2;
private static final String OLD_DELETE_FLAG = "old_delete_flag";
private static final String NEW_DELETE_FALG = "new_delete_flag";
@Autowired
private StoreApiService storeApiService;
......@@ -69,16 +71,13 @@ public class StoreMessageHandler implements MessageHandler {
enterpriseId = Integer.valueOf(fieldMap.get("new_enterprise_id").getValue());
storeId = Integer.valueOf(fieldMap.get("new_store_id").getValue());
storeInfoId = Integer.valueOf(fieldMap.get("new_store_info_id").getValue());
if (Integer.valueOf(fieldMap.get(OLD_STATUS).getValue()) == 1 && Integer.valueOf(fieldMap.get(NEW_STATUS).getValue()) == 0) { //删除
if (Integer.valueOf(fieldMap.get(OLD_DELETE_FLAG).getValue()) == 0 && Integer.valueOf(fieldMap.get(NEW_DELETE_FALG).getValue()) == 1) { //删除
this.storeApiService.deleteStoreFromEs(enterpriseId, storeId);
} else if (Integer.valueOf(fieldMap.get(OLD_STATUS).getValue()) == 1 && Integer.valueOf(fieldMap.get(NEW_STATUS).getValue()).equals(NEW_STATUS_VALUE)){ //下线
//todo 通知会员组(积分成本转移)
}else {
//todo 刷新es改为同步
this.storeIndexRefreshHandler.refreshStoreIndex(enterpriseId, storeId);
}
if (StoreOwnTypeEnum.OWNER.getCode() == Integer.valueOf(fieldMap.get(NEW_OWN_TYPE).getValue())) {
this.dealStoreChange(enterpriseId, storeId, storeInfoId, GicRecordType.UPDATE.value());
}
this.dealStoreChange(enterpriseId, storeId, storeInfoId, GicRecordType.UPDATE.value());
}
if(GicRecordType.DELETE.value() == value.getRecordType().value()){
enterpriseId = Integer.valueOf(fieldMap.get("enterprise_id").getValue());
......@@ -93,6 +92,11 @@ public class StoreMessageHandler implements MessageHandler {
}
private void dealStoreChange(Integer enterpriseId, Integer storeId, Integer storeInfoId, int recordType){
/****
* 1 判断当前门店是否在联合商户资源组中 存在 判断联合商户中是否存在 不存在需要进行同步
* 2 判断当前门店是否在联合商户资源组中 不存在 判断联合商户中是否存在 存在需要进行取消同步
* ****/
ServiceResponse<List<UnionEnterpriseResourceDTO>> resourceResponse = this.unionEnterpriseApiService.listStoreResourceByEnterpriseId(enterpriseId);
if(CollectionUtils.isNotEmpty(resourceResponse.getResult())){
for(UnionEnterpriseResourceDTO dto : resourceResponse.getResult()){
......@@ -107,11 +111,19 @@ public class StoreMessageHandler implements MessageHandler {
storeSearchDTO.setStoreIds(String.valueOf(storeId));
storeSearchDTO.setSearchJson(storeWidgetDTO.getSearchParam());
storeSearchDTO.setEnterpriseId(enterpriseId);
ServiceResponse<Page<StoreDTO>> response = this.storeApiService.listStore(storeSearchDTO, 1, 1);
if(!response.isSuccess()){
continue;
Long count = this.storeApiService.queryStoreCountFromEs(storeSearchDTO).getResult();
boolean ownExist = count > 0 ? true : false;
Integer unionEnterpriseId = 1;
storeSearchDTO.setEnterpriseId(unionEnterpriseId);
count = this.storeApiService.queryStoreCountFromEs(storeSearchDTO).getResult();
boolean unionExist = count > 0 ? true : false;
if(ownExist && !unionExist){
//todo 进行联合同步 记录表更日志
}
if(CollectionUtils.isNotEmpty(response.getResult().getResult())){
if(!ownExist && unionExist){
//// TODO: 2021/2/9 取消授权 记录表更日志
}
if(count > 0){
if(GicRecordType.DELETE.value() == recordType){
this.storeAuthorizationApiService.cancelStore(storeInfoId, dto.getUnionEnterpriseId());
}else {
......@@ -124,6 +136,7 @@ public class StoreMessageHandler implements MessageHandler {
}else {
this.storeAuthorizationApiService.cancelStore(storeInfoId, dto.getUnionEnterpriseId());
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment