Authored by caoyan

物权转移

... ... @@ -110,7 +110,7 @@ public class ProductIdentifyController {
}
}
@ApiOperation(name = "ufo.product.updateOwnerApply", desc="确认物权转移")
@ApiOperation(name = "ufo.product.confirmTransferOwner", desc="确认物权转移")
@ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
@ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
@ApiParam(name="from_uid",required = true,desc="当前物权所有人",type=Integer.class)
... ...
... ... @@ -8,7 +8,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import javax.annotation.Resource;
... ... @@ -366,7 +365,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, null);
if(null != history && (history.getStatus().equals(OPERATE_TYPE_APPLYING))) {
throw new GatewayException(402, "当前不可申请");
throw new GatewayException(402, "已存在物权申请");
}
//将申请记录插入数据库
... ... @@ -390,7 +389,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
messageFacade.applyToBeOwner(insertItem.getFromUid(), String.valueOf(uid), tagId, nfcUid, orderCode);
//发送定时mq
yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 3*24*60);//3天
// yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 3*24*60);//3天
yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 5);
return result;
}
... ... @@ -513,9 +513,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
//申请人申请状态
TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, null);
if(null == history || !history.getStatus().equals(OPERATE_TYPE_APPLYING)) {
if(null == history) {
result.setApplyStatus(OPERATE_TYPE_NO_APPLY);//未申请
}else if(!(history.getToUid().equals(String.valueOf(uid)))) {
}else if(history.getStatus().equals(OPERATE_TYPE_APPLYING) && !(history.getToUid().equals(String.valueOf(uid)))) {
result.setApplyStatus(OPERATE_TYPE_CANNOT_APPLY);
return;
}else {
... ... @@ -570,11 +570,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
//2)第二部分:历史物权所有人,按时间顺序排列
List<TransferRecords> transferList = transferRecordsMapper.selectByTagIdAndNfcUid(identifyRecord.getTagId(), identifyRecord.getNfcUid());
List<String> ownerUidList = transferList.stream().map(TransferRecords::getToUid).collect(Collectors.toList());
List<String> allUidList = Lists.newArrayList();
allUidList.addAll(ownerUidList);
//查询头像和手机号
Map<Integer, ProfileInfoRsp> profileMap = userInfoProxyService.queryIcoAndMobile(allUidList);
Map<Integer, ProfileInfoRsp> profileMap = userInfoProxyService.queryIcoAndMobile(ownerUidList);
List<IdentifyTrackResp> historyTrackList = buildTransferTrackList(profileMap, transferList);
trackRespList.addAll(historyTrackList);
... ... @@ -583,24 +581,21 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
private List<IdentifyTrackResp> buildTransferTrackList(Map<Integer, ProfileInfoRsp> profileMap, List<TransferRecords> transferList) {
List<IdentifyTrackResp> trackList = Lists.newArrayList();
Map<String, TransferRecords> transferMap = transferList.stream().collect(Collectors.toMap(TransferRecords::getToUid, t->t));
for(Entry<Integer, ProfileInfoRsp> entry : profileMap.entrySet()) {
for(TransferRecords record : transferList) {
IdentifyTrackResp item = new IdentifyTrackResp();
item.setUid(entry.getKey());
String mobileMask = MobileHelper.coverMobile2(entry.getValue().getMobile());//隐位的手机号码--隐藏中间6位
item.setContent(StringUtils.isEmpty(entry.getValue().getNickname()) ? mobileMask : entry.getValue().getNickname());
String headIcon = entry.getValue().getHead_ico();
Integer toUid = Integer.parseInt(record.getToUid());
item.setUid(toUid);
String mobileMask = MobileHelper.coverMobile2(profileMap.get(toUid).getMobile());//隐位的手机号码--隐藏中间6位
item.setContent(StringUtils.isEmpty(profileMap.get(toUid).getNickname()) ? mobileMask : profileMap.get(toUid).getNickname());
String headIcon = profileMap.get(toUid).getHead_ico();
if(DEFAULT_HEAD_IMG.equals(headIcon) || StringUtils.isBlank(headIcon)){//有货的默认头像
//ufo 用户的默认头像
headIcon = configReader.getString("ufo.product.defaultUserHeadIcon", "http://head.static.yhbimg.com/yhb-head/2018/12/28/14/0160773bb87685aade796ea4f94e0587cf.png?imageView2/{mode}/w/{width}/h/{height}");
}
item.setHeadIcon(headIcon);
item.setType(MESSAGE_TYPE_EX_OWNER);
if(null != transferMap.get(String.valueOf(entry.getKey()))) {
Integer createTime = transferMap.get(String.valueOf(entry.getKey())).getCreateTime();
item.setTime(createTime);
item.setTimeStr(formatDate(createTime, "yyyy.MM.dd HH:mm:ss"));
}
item.setTime(record.getCreateTime());
item.setTimeStr(formatDate(record.getCreateTime(), "yyyy.MM.dd HH:mm:ss"));
trackList.add(item);
}
... ...