...
|
...
|
@@ -2,6 +2,7 @@ package com.yohoufo.user.service.impl; |
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.annotation.Resource;
|
...
|
...
|
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Service; |
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.yoho.core.common.utils.DateUtil;
|
|
|
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
|
|
|
import com.yoho.error.ServiceError;
|
...
|
...
|
@@ -287,6 +289,55 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
deleteIboxsByRedis(uid,type);
|
|
|
return inBox.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void addBatchInboxByUids(String uids, Integer type, Integer businessType, String params) {
|
|
|
log.info("entre addBatchInboxByUids with param .uids is {},type is {},businessType is {},params is {}", uids,type,businessType,params);
|
|
|
InboxBusinessTypeEnum businessTypeEnum = InboxBusinessTypeEnum.getByTypeAndBusinessType(type,businessType);
|
|
|
if(businessTypeEnum == null){
|
|
|
log.warn("addInbox businessTypeEnum is null.type is {},businessType is {}",type,businessType);
|
|
|
throw new ServiceException(ServiceError.SMS_TEMPLATE_NOT_EXIST);
|
|
|
}
|
|
|
|
|
|
String[] uidArr = uids.split(",");
|
|
|
Map<String, List<InBox>> tableNameInboxMap = Maps.newHashMap();
|
|
|
for(int i=0; i<uidArr.length; i++) {
|
|
|
Integer uid = Integer.parseInt(uidArr[i]);
|
|
|
InBox inBox = createInBox(type, businessType, params, businessTypeEnum);
|
|
|
String tableName = getTableName(uid);
|
|
|
if(CollectionUtils.isEmpty(tableNameInboxMap.get(tableName))) {
|
|
|
List<InBox> inBoxList = Lists.newArrayList(inBox);
|
|
|
tableNameInboxMap.put(tableName, inBoxList);
|
|
|
}else {
|
|
|
tableNameInboxMap.get(tableName).add(inBox);
|
|
|
}
|
|
|
|
|
|
//清空redis缓存
|
|
|
deleteIboxsByRedis(uid,type);
|
|
|
}
|
|
|
|
|
|
//分表批量插入
|
|
|
for(Entry<String, List<InBox>> entry : tableNameInboxMap.entrySet()) {
|
|
|
List<InBox> inBoxList = entry.getValue();
|
|
|
inBoxDao.insertBatch(entry.getKey(), inBoxList);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private InBox createInBox(Integer type, Integer businessType, String params, InboxBusinessTypeEnum businessTypeEnum) {
|
|
|
InBox inBox = new InBox();
|
|
|
inBox.setType(type);
|
|
|
inBox.setIsRead(InBox.N);
|
|
|
inBox.setIsDel(InBox.N);
|
|
|
inBox.setTitle(businessTypeEnum.getTitle());
|
|
|
inBox.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
inBox.setContent(createContent(businessTypeEnum.getContent(),params));
|
|
|
inBox.setBusinessType(businessType);
|
|
|
//处理附加业务
|
|
|
dealAddition(inBox,params);
|
|
|
|
|
|
return inBox;
|
|
|
}
|
|
|
|
|
|
private void dealAddition(InBox inBox,String params) {
|
|
|
if(InboxBusinessTypeEnum.NOTICE_PROBLEM_ORDER.getBusinessType().equals(inBox.getBusinessType())){
|
...
|
...
|
|