...
|
...
|
@@ -12,6 +12,7 @@ import java.util.stream.Collectors; |
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.elasticsearch.common.collect.Lists;
|
...
|
...
|
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.core.config.ConfigReader;
|
|
|
import com.yoho.core.rabbitmq.YhProducer;
|
...
|
...
|
@@ -35,8 +37,10 @@ import com.yoho.service.model.uic.request.UserInfoBO; |
|
|
import com.yohobuy.ufo.model.order.common.OperateTypeEnum;
|
|
|
import com.yohobuy.ufo.model.order.constants.QNliveConstants;
|
|
|
import com.yohoufo.common.cache.CacheClient;
|
|
|
import com.yohoufo.common.cache.CacheEnum;
|
|
|
import com.yohoufo.common.exception.GatewayException;
|
|
|
import com.yohoufo.common.helper.ImageUrlAssist;
|
|
|
import com.yohoufo.common.redis.NoSyncGracefulRedisTemplate;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.common.utils.MobileHelper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
...
|
...
|
@@ -63,6 +67,8 @@ import com.yohoufo.dal.product.model.Product; |
|
|
import com.yohoufo.dal.product.model.ProductChain;
|
|
|
import com.yohoufo.dal.product.model.TransferRecords;
|
|
|
import com.yohoufo.dal.product.model.TransferRecordsHistory;
|
|
|
import com.yohoufo.dal.user.IInBoxAttrDao;
|
|
|
import com.yohoufo.dal.user.model.InBoxAttr;
|
|
|
import com.yohoufo.product.mq.TopicConstants;
|
|
|
import com.yohoufo.product.response.IdentifyShareInfoResp;
|
|
|
import com.yohoufo.product.response.IdentifyTrackResp;
|
...
|
...
|
@@ -127,6 +133,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private IInBoxAttrDao inBoxAttrDao;
|
|
|
|
|
|
@Resource(name = "yhProducer")
|
|
|
private YhProducer yhProducer;
|
...
|
...
|
@@ -136,6 +145,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
|
|
|
@Value("${uic.url}")
|
|
|
private String uicServerIpAndPort;
|
|
|
|
|
|
@Resource(name="NoSyncGracefulRedisTemplate")
|
|
|
private NoSyncGracefulRedisTemplate redisTemplate;
|
|
|
|
|
|
@Value("${ufo.nfc.syncBlockChain.url}")
|
|
|
private String syncBlockChain_url;
|
...
|
...
|
@@ -389,14 +401,13 @@ 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, 5);
|
|
|
yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 3*24*60);//3天
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status) throws GatewayException {
|
|
|
public int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status, Integer inboxId) throws GatewayException {
|
|
|
if(null == status || !(status.equals(OPERATE_TYPE_PASS) || status.equals(OPERATE_TYPE_REJECT))){
|
|
|
throw new GatewayException(402, "参数status错误");
|
|
|
}
|
...
|
...
|
@@ -425,6 +436,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
int result = transferRecordsHistoryMapper.insert(histroy);
|
|
|
|
|
|
if(status.equals(OPERATE_TYPE_REJECT)) {
|
|
|
setFinalTimeToEnd(inboxId, fromUid);
|
|
|
//“不同意”则拒绝物权占有,短信通知申请⼈人“您发起商品xxxxxx的物权转 移申请,当前物权所有⼈人拒绝转移申请,您可以重新发起物权申请”
|
|
|
messageFacade.ownerReject(String.valueOf(toUid), queryIdentifyRecord(tagId, nfcUid).getOrderCode());
|
|
|
return result;
|
...
|
...
|
@@ -441,6 +453,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
|
|
|
//更新identify_record
|
|
|
result = identifyRecordsMapper.updateOwner(tagId, nfcUid, toUid);
|
|
|
setFinalTimeToEnd(inboxId, fromUid);
|
|
|
|
|
|
//区块链
|
|
|
syncBlockChain(tagId, nfcUid, toUid);
|
|
|
|
...
|
...
|
@@ -450,6 +464,36 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private void setFinalTimeToEnd(Integer inboxId, Integer uid) {
|
|
|
if(null == inboxId) {
|
|
|
return;
|
|
|
}
|
|
|
List<InBoxAttr> attrList = inBoxAttrDao.selectInboxAttrList(uid, Lists.newArrayList(inboxId));
|
|
|
if(CollectionUtils.isEmpty(attrList)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
InBoxAttr attr = attrList.get(0);
|
|
|
String jsonContent = attr.getJsonContent();
|
|
|
JSONObject jo = JSON.parseObject(jsonContent);
|
|
|
jo.replace("finalTime", 0);
|
|
|
inBoxAttrDao.updateJsonContent(uid, inboxId, jo.toJSONString());
|
|
|
//清缓存
|
|
|
deleteIboxsByRedis(uid, 2);
|
|
|
}
|
|
|
|
|
|
private void deleteIboxsByRedis(int uid, int type){
|
|
|
logger.info("deleteIboxsByRedis params uid is {} type is {}",uid,type);
|
|
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(uid);
|
|
|
redisTemplate.delete(inboxKey);
|
|
|
RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(uid,type);
|
|
|
redisTemplate.delete(key);
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,"N");
|
|
|
redisTemplate.delete(inboxTotalKey);
|
|
|
RedisKeyBuilder inboxTypeTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,type);
|
|
|
redisTemplate.delete(inboxTypeTotalKey);
|
|
|
}
|
|
|
|
|
|
private void syncBlockChain(String tagId, String nfcUid, Integer toUid){
|
|
|
IdentifyRecord record = queryIdentifyRecord(tagId, nfcUid);
|
|
|
//商品信息
|
...
|
...
|
@@ -475,7 +519,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
//根据uid去uic获取用户手机号,并进行模糊处理。吃掉异常,防止超时影响正常逻辑
|
|
|
try{
|
|
|
Map<String,Integer> request = Collections.singletonMap("uid", toUid);
|
|
|
JSONObject jsonObject = serviceCaller.get("uic.getProfileAction", "http://" + uicServerIpAndPort + UIC_PROFILE_URL, request, JSONObject.class, null).get(1);
|
|
|
JSONObject jsonObject = serviceCaller.get("uic.getProfileAction", uicServerIpAndPort + UIC_PROFILE_URL, request, JSONObject.class, null).get(1);
|
|
|
|
|
|
if(null != jsonObject.getJSONObject("data") && null != jsonObject.getJSONObject("data").getString("mobile_phone")) {
|
|
|
String mobile = jsonObject.getJSONObject("data").getString("mobile_phone");;
|
...
|
...
|
|