Commit 04e1c964 by 陶光胜

Merge branch 'developer' into 'master'

Developer

See merge request !3
parents 5c21fe8b 5e1339ac
package com.gic.message.constant;
/**
*
* @ClassName: Constants
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public class Constants {
public static final String INSERT = "INSERT";
public static final String UPDATE = "UPDATE";
......
package com.gic.message.dao.mapper;
/**
*
* @ClassName: TestMapper
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public class TestMapper {
}
......@@ -5,6 +5,13 @@ import java.util.Date;
/**
* tab_city
*/
/**
*
* @ClassName: TabCity
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public class TabCity {
/**
* 城市id
......
......@@ -2,7 +2,22 @@ package com.gic.message.service;
import com.gic.binlog.base.entity.GicRecord;
import org.apache.kafka.clients.consumer.ConsumerRecord;
/**
*
* @ClassName: MessageHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public interface MessageHandler {
/**
* handler
* @Title: handler
* @Description:
* @author zhiwj
* @param consumerRecord
* @return void
* @throws
*/
void handler(ConsumerRecord<String, GicRecord> consumerRecord);
}
package com.gic.message.service.impl;
import com.alibaba.fastjson.JSON;
import com.gic.binlog.base.entity.GicRecord;
import com.gic.message.service.MessageHandler;
import org.apache.kafka.clients.consumer.ConsumerRecord;
......@@ -8,7 +7,13 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.listener.MessageListener;
/**
*
* @ClassName: KafkaMessageServiceImpl
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public class KafkaMessageServiceImpl implements MessageListener<String, GicRecord> {
private static final Logger log = LogManager.getLogger(KafkaMessageServiceImpl.class);
@Autowired
......
......@@ -8,6 +8,13 @@ import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
/**
*
* @ClassName: MessageHandlerInit
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
@Component
public class MessageHandlerInit {
@Autowired
......
......@@ -25,9 +25,19 @@ import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
*
* @ClassName: StoreCustomMessageHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
@Component
public class StoreCustomMessageHandler implements MessageHandler {
private static final String OLD_VALUE = "old_value";
private static final String NEW_VALUE = "new_value";
@Autowired
private StoreApiService storeApiService;
@Autowired
......@@ -55,7 +65,7 @@ public class StoreCustomMessageHandler implements MessageHandler {
enterpriseId = Integer.valueOf(fieldMap.get("new_enterprise_id").getValue());
storeFieldId = Integer.valueOf(fieldMap.get("new_store_field_id").getValue());
storeInfoId = Integer.valueOf(fieldMap.get("new_store_info_id").getValue());
if(!fieldMap.get("old_value").getValue().equals(fieldMap.get("new_value").getValue())){
if(!fieldMap.get(OLD_VALUE).getValue().equals(fieldMap.get(NEW_VALUE).getValue())){
this.dealCustomChange(enterpriseId, storeFieldId, storeInfoId, fieldMap);
}
}
......@@ -91,7 +101,7 @@ public class StoreCustomMessageHandler implements MessageHandler {
}
StoreWidgetDTO storeWidgetDTO = storeWidget.getResult();
if(storeWidgetDTO != null){
if(AuthModeEnum.YES.getCode() == storeWidgetDTO.getAuthMode()){
if(AuthModeEnum.YES.getCode().equals(storeWidgetDTO.getAuthMode())){
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setStoreInfoIds(String.valueOf(storeInfoId));
storeSearchDTO.setSearchJson(storeWidgetDTO.getSearchParam());
......
......@@ -6,7 +6,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
*
* @ClassName: StoreIndexRefreshHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
@Component
public class StoreIndexRefreshHandler {
@Autowired
......@@ -17,7 +23,7 @@ public class StoreIndexRefreshHandler {
Object cache = RedisUtil.getCache(key);
if(cache == null){
this.storeApiService.addStoreToIndex(enterpriseId, storeId);
RedisUtil.setCache(key, storeId, 1l, TimeUnit.SECONDS);
RedisUtil.setCache(key, storeId, 1L, TimeUnit.SECONDS);
}
}
}
......@@ -25,7 +25,13 @@ import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
*
* @ClassName: StoreInfoMessageHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
@Component
public class StoreInfoMessageHandler implements MessageHandler {
@Autowired
......@@ -57,7 +63,7 @@ public class StoreInfoMessageHandler implements MessageHandler {
for(StoreDTO storeDTO : listStore){
if(storeDTO.getOwnType() == StoreOwnTypeEnum.OWNER.getCode()){
if(Integer.valueOf(fieldMap.get("old_status").getValue()) == 1 && Integer.valueOf(fieldMap.get("new_status").getValue()) == 0){
this.storeApiService.deleteStoreFromES(storeDTO.getEnterpriseId(), storeDTO.getStoreId());
this.storeApiService.deleteStoreFromEs(storeDTO.getEnterpriseId(), storeDTO.getStoreId());
}else {
this.storeIndexRefreshHandler.refreshStoreIndex(storeDTO.getEnterpriseId(), storeDTO.getStoreId());
}
......@@ -76,7 +82,7 @@ public class StoreInfoMessageHandler implements MessageHandler {
ServiceResponse<List<StoreDTO>> listStoreResponse = this.storeApiService.listStoreByStoreInfoId(storeInfoId);
List<StoreDTO> listStore = listStoreResponse.getResult();
for(StoreDTO storeDTO : listStore){
this.storeApiService.deleteStoreFromES(storeDTO.getEnterpriseId(), storeDTO.getStoreId());
this.storeApiService.deleteStoreFromEs(storeDTO.getEnterpriseId(), storeDTO.getStoreId());
}
}
}
......@@ -91,7 +97,7 @@ public class StoreInfoMessageHandler implements MessageHandler {
}
StoreWidgetDTO storeWidgetDTO = storeWidget.getResult();
if(storeWidgetDTO != null){
if(AuthModeEnum.YES.getCode() == storeWidgetDTO.getAuthMode()){
if(AuthModeEnum.YES.getCode().equals(storeWidgetDTO.getAuthMode())){
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setStoreInfoIds(String.valueOf(storeInfoId));
storeSearchDTO.setSearchJson(storeWidgetDTO.getSearchParam());
......@@ -109,11 +115,11 @@ public class StoreInfoMessageHandler implements MessageHandler {
}else {
this.storeAuthorizationApiService.cancelStore(storeInfoId, dto.getUnionEnterpriseId());
}
if(Integer.valueOf(fieldMap.get("old_region_id").getValue()) != Integer.valueOf(fieldMap.get("new_region_id").getValue())){
StoreSearchDTO storeSearchDTO1 = new StoreSearchDTO();
storeSearchDTO1.setRegionId(Integer.valueOf(fieldMap.get("old_region_id").getValue()));
storeSearchDTO1.setSearchJson(storeWidgetDTO.getSearchParam());
storeSearchDTO1.setEnterpriseId(enterpriseId);
if(!Integer.valueOf(fieldMap.get("old_region_id").getValue()).equals(Integer.valueOf(fieldMap.get("new_region_id").getValue()))){
StoreSearchDTO storeSearchDto1 = new StoreSearchDTO();
storeSearchDto1.setRegionId(Integer.valueOf(fieldMap.get("old_region_id").getValue()));
storeSearchDto1.setSearchJson(storeWidgetDTO.getSearchParam());
storeSearchDto1.setEnterpriseId(enterpriseId);
ServiceResponse<Page<StoreDTO>> response1 = this.storeApiService.listStore(storeSearchDTO, 1, 1);
if(CollectionUtils.isEmpty(response1.getResult().getResult())){
this.storeRegionApiService.unAuthorizeRegion(dto.getUnionEnterpriseId(), Integer.valueOf(fieldMap.get("old_region_id").getValue()));
......
......@@ -3,7 +3,6 @@ package com.gic.message.service.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.constant.AuthModeEnum;
import com.gic.auth.dto.UnionEnterpriseDTO;
import com.gic.auth.dto.UnionEnterpriseResourceDTO;
import com.gic.auth.service.UnionEnterpriseApiService;
import com.gic.binlog.base.entity.GicField;
......@@ -25,9 +24,21 @@ import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
*
* @ClassName: StoreMessageHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:12
*/
@Component
public class StoreMessageHandler implements MessageHandler {
public static final String OLD_STATUS = "old_status";
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;
@Autowired
private StoreApiService storeApiService;
@Autowired
......@@ -58,14 +69,14 @@ 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) { //删除
this.storeApiService.deleteStoreFromES(enterpriseId, storeId);
} else if (Integer.valueOf(fieldMap.get("old_status").getValue()) == 1 && Integer.valueOf(fieldMap.get("new_status").getValue()) == 2){ //下线
if (Integer.valueOf(fieldMap.get(OLD_STATUS).getValue()) == 1 && Integer.valueOf(fieldMap.get(NEW_STATUS).getValue()) == 0) { //删除
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 {
this.storeIndexRefreshHandler.refreshStoreIndex(enterpriseId, storeId);
}
if (StoreOwnTypeEnum.OWNER.getCode() == Integer.valueOf(fieldMap.get("new_own_type").getValue())) {
if (StoreOwnTypeEnum.OWNER.getCode() == Integer.valueOf(fieldMap.get(NEW_OWN_TYPE).getValue())) {
this.dealStoreChange(enterpriseId, storeId, storeInfoId, GicRecordType.UPDATE.value());
}
}
......@@ -73,7 +84,7 @@ public class StoreMessageHandler implements MessageHandler {
enterpriseId = Integer.valueOf(fieldMap.get("enterprise_id").getValue());
storeId = Integer.valueOf(fieldMap.get("store_id").getValue());
storeInfoId = Integer.valueOf(fieldMap.get("store_info_id").getValue());
this.storeApiService.deleteStoreFromES(enterpriseId, storeId);
this.storeApiService.deleteStoreFromEs(enterpriseId, storeId);
Integer ownType = Integer.valueOf(fieldMap.get("own_type").getValue());
if(ownType == StoreOwnTypeEnum.OWNER.getCode()){
this.dealStoreChange(enterpriseId, storeId, storeInfoId, GicRecordType.DELETE.value());
......@@ -91,7 +102,7 @@ public class StoreMessageHandler implements MessageHandler {
}
StoreWidgetDTO storeWidgetDTO = storeWidget.getResult();
if(storeWidgetDTO != null){
if(AuthModeEnum.YES.getCode() == storeWidgetDTO.getAuthMode()){
if(AuthModeEnum.YES.getCode().equals(storeWidgetDTO.getAuthMode())){
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setStoreIds(String.valueOf(storeId));
storeSearchDTO.setSearchJson(storeWidgetDTO.getSearchParam());
......
......@@ -8,7 +8,13 @@ import org.apache.kafka.clients.consumer.ConsumerRecord;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @ClassName: ListToMapUtil
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public class ListToMapUtil {
public static Map<String, GicField> listToMap(ConsumerRecord<String, GicRecord> consumerRecord){
GicRecord value = consumerRecord.value();
......
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