|
@@ -12,6 +12,7 @@ import java.util.stream.Collectors; |
|
@@ -12,6 +12,7 @@ import java.util.stream.Collectors; |
12
|
|
12
|
|
13
|
import javax.annotation.Resource;
|
13
|
import javax.annotation.Resource;
|
14
|
|
14
|
|
|
|
15
|
+import org.apache.commons.collections.CollectionUtils;
|
15
|
import org.apache.commons.collections.MapUtils;
|
16
|
import org.apache.commons.collections.MapUtils;
|
16
|
import org.apache.commons.lang3.StringUtils;
|
17
|
import org.apache.commons.lang3.StringUtils;
|
17
|
import org.elasticsearch.common.collect.Lists;
|
18
|
import org.elasticsearch.common.collect.Lists;
|
|
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
21
|
import org.springframework.beans.factory.annotation.Value;
|
22
|
import org.springframework.beans.factory.annotation.Value;
|
22
|
import org.springframework.stereotype.Service;
|
23
|
import org.springframework.stereotype.Service;
|
23
|
|
24
|
|
|
|
25
|
+import com.alibaba.fastjson.JSON;
|
24
|
import com.alibaba.fastjson.JSONObject;
|
26
|
import com.alibaba.fastjson.JSONObject;
|
25
|
import com.yoho.core.config.ConfigReader;
|
27
|
import com.yoho.core.config.ConfigReader;
|
26
|
import com.yoho.core.rabbitmq.YhProducer;
|
28
|
import com.yoho.core.rabbitmq.YhProducer;
|
|
@@ -35,8 +37,10 @@ import com.yoho.service.model.uic.request.UserInfoBO; |
|
@@ -35,8 +37,10 @@ import com.yoho.service.model.uic.request.UserInfoBO; |
35
|
import com.yohobuy.ufo.model.order.common.OperateTypeEnum;
|
37
|
import com.yohobuy.ufo.model.order.common.OperateTypeEnum;
|
36
|
import com.yohobuy.ufo.model.order.constants.QNliveConstants;
|
38
|
import com.yohobuy.ufo.model.order.constants.QNliveConstants;
|
37
|
import com.yohoufo.common.cache.CacheClient;
|
39
|
import com.yohoufo.common.cache.CacheClient;
|
|
|
40
|
+import com.yohoufo.common.cache.CacheEnum;
|
38
|
import com.yohoufo.common.exception.GatewayException;
|
41
|
import com.yohoufo.common.exception.GatewayException;
|
39
|
import com.yohoufo.common.helper.ImageUrlAssist;
|
42
|
import com.yohoufo.common.helper.ImageUrlAssist;
|
|
|
43
|
+import com.yohoufo.common.redis.NoSyncGracefulRedisTemplate;
|
40
|
import com.yohoufo.common.utils.DateUtil;
|
44
|
import com.yohoufo.common.utils.DateUtil;
|
41
|
import com.yohoufo.common.utils.MobileHelper;
|
45
|
import com.yohoufo.common.utils.MobileHelper;
|
42
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
46
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
|
@@ -63,6 +67,8 @@ import com.yohoufo.dal.product.model.Product; |
|
@@ -63,6 +67,8 @@ import com.yohoufo.dal.product.model.Product; |
63
|
import com.yohoufo.dal.product.model.ProductChain;
|
67
|
import com.yohoufo.dal.product.model.ProductChain;
|
64
|
import com.yohoufo.dal.product.model.TransferRecords;
|
68
|
import com.yohoufo.dal.product.model.TransferRecords;
|
65
|
import com.yohoufo.dal.product.model.TransferRecordsHistory;
|
69
|
import com.yohoufo.dal.product.model.TransferRecordsHistory;
|
|
|
70
|
+import com.yohoufo.dal.user.IInBoxAttrDao;
|
|
|
71
|
+import com.yohoufo.dal.user.model.InBoxAttr;
|
66
|
import com.yohoufo.product.mq.TopicConstants;
|
72
|
import com.yohoufo.product.mq.TopicConstants;
|
67
|
import com.yohoufo.product.response.IdentifyShareInfoResp;
|
73
|
import com.yohoufo.product.response.IdentifyShareInfoResp;
|
68
|
import com.yohoufo.product.response.IdentifyTrackResp;
|
74
|
import com.yohoufo.product.response.IdentifyTrackResp;
|
|
@@ -127,6 +133,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -127,6 +133,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
127
|
|
133
|
|
128
|
@Autowired
|
134
|
@Autowired
|
129
|
private ProductMapper productMapper;
|
135
|
private ProductMapper productMapper;
|
|
|
136
|
+
|
|
|
137
|
+ @Autowired
|
|
|
138
|
+ private IInBoxAttrDao inBoxAttrDao;
|
130
|
|
139
|
|
131
|
@Resource(name = "yhProducer")
|
140
|
@Resource(name = "yhProducer")
|
132
|
private YhProducer yhProducer;
|
141
|
private YhProducer yhProducer;
|
|
@@ -136,6 +145,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -136,6 +145,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
136
|
|
145
|
|
137
|
@Value("${uic.url}")
|
146
|
@Value("${uic.url}")
|
138
|
private String uicServerIpAndPort;
|
147
|
private String uicServerIpAndPort;
|
|
|
148
|
+
|
|
|
149
|
+ @Resource(name="NoSyncGracefulRedisTemplate")
|
|
|
150
|
+ private NoSyncGracefulRedisTemplate redisTemplate;
|
139
|
|
151
|
|
140
|
@Value("${ufo.nfc.syncBlockChain.url}")
|
152
|
@Value("${ufo.nfc.syncBlockChain.url}")
|
141
|
private String syncBlockChain_url;
|
153
|
private String syncBlockChain_url;
|
|
@@ -389,14 +401,13 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -389,14 +401,13 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
389
|
messageFacade.applyToBeOwner(insertItem.getFromUid(), String.valueOf(uid), tagId, nfcUid, orderCode);
|
401
|
messageFacade.applyToBeOwner(insertItem.getFromUid(), String.valueOf(uid), tagId, nfcUid, orderCode);
|
390
|
|
402
|
|
391
|
//发送定时mq
|
403
|
//发送定时mq
|
392
|
-// yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 3*24*60);//3天
|
|
|
393
|
- yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 5);
|
404
|
+ yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 3*24*60);//3天
|
394
|
|
405
|
|
395
|
return result;
|
406
|
return result;
|
396
|
}
|
407
|
}
|
397
|
|
408
|
|
398
|
@Override
|
409
|
@Override
|
399
|
- public int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status) throws GatewayException {
|
410
|
+ public int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status, Integer inboxId) throws GatewayException {
|
400
|
if(null == status || !(status.equals(OPERATE_TYPE_PASS) || status.equals(OPERATE_TYPE_REJECT))){
|
411
|
if(null == status || !(status.equals(OPERATE_TYPE_PASS) || status.equals(OPERATE_TYPE_REJECT))){
|
401
|
throw new GatewayException(402, "参数status错误");
|
412
|
throw new GatewayException(402, "参数status错误");
|
402
|
}
|
413
|
}
|
|
@@ -425,6 +436,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -425,6 +436,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
425
|
int result = transferRecordsHistoryMapper.insert(histroy);
|
436
|
int result = transferRecordsHistoryMapper.insert(histroy);
|
426
|
|
437
|
|
427
|
if(status.equals(OPERATE_TYPE_REJECT)) {
|
438
|
if(status.equals(OPERATE_TYPE_REJECT)) {
|
|
|
439
|
+ setFinalTimeToEnd(inboxId, fromUid);
|
428
|
//“不同意”则拒绝物权占有,短信通知申请⼈人“您发起商品xxxxxx的物权转 移申请,当前物权所有⼈人拒绝转移申请,您可以重新发起物权申请”
|
440
|
//“不同意”则拒绝物权占有,短信通知申请⼈人“您发起商品xxxxxx的物权转 移申请,当前物权所有⼈人拒绝转移申请,您可以重新发起物权申请”
|
429
|
messageFacade.ownerReject(String.valueOf(toUid), queryIdentifyRecord(tagId, nfcUid).getOrderCode());
|
441
|
messageFacade.ownerReject(String.valueOf(toUid), queryIdentifyRecord(tagId, nfcUid).getOrderCode());
|
430
|
return result;
|
442
|
return result;
|
|
@@ -441,6 +453,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -441,6 +453,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
441
|
|
453
|
|
442
|
//更新identify_record
|
454
|
//更新identify_record
|
443
|
result = identifyRecordsMapper.updateOwner(tagId, nfcUid, toUid);
|
455
|
result = identifyRecordsMapper.updateOwner(tagId, nfcUid, toUid);
|
|
|
456
|
+ setFinalTimeToEnd(inboxId, fromUid);
|
|
|
457
|
+
|
444
|
//区块链
|
458
|
//区块链
|
445
|
syncBlockChain(tagId, nfcUid, toUid);
|
459
|
syncBlockChain(tagId, nfcUid, toUid);
|
446
|
|
460
|
|
|
@@ -450,6 +464,36 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -450,6 +464,36 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
450
|
return result;
|
464
|
return result;
|
451
|
}
|
465
|
}
|
452
|
|
466
|
|
|
|
467
|
+ private void setFinalTimeToEnd(Integer inboxId, Integer uid) {
|
|
|
468
|
+ if(null == inboxId) {
|
|
|
469
|
+ return;
|
|
|
470
|
+ }
|
|
|
471
|
+ List<InBoxAttr> attrList = inBoxAttrDao.selectInboxAttrList(uid, Lists.newArrayList(inboxId));
|
|
|
472
|
+ if(CollectionUtils.isEmpty(attrList)) {
|
|
|
473
|
+ return;
|
|
|
474
|
+ }
|
|
|
475
|
+
|
|
|
476
|
+ InBoxAttr attr = attrList.get(0);
|
|
|
477
|
+ String jsonContent = attr.getJsonContent();
|
|
|
478
|
+ JSONObject jo = JSON.parseObject(jsonContent);
|
|
|
479
|
+ jo.replace("finalTime", 0);
|
|
|
480
|
+ inBoxAttrDao.updateJsonContent(uid, inboxId, jo.toJSONString());
|
|
|
481
|
+ //清缓存
|
|
|
482
|
+ deleteIboxsByRedis(uid, 2);
|
|
|
483
|
+ }
|
|
|
484
|
+
|
|
|
485
|
+ private void deleteIboxsByRedis(int uid, int type){
|
|
|
486
|
+ logger.info("deleteIboxsByRedis params uid is {} type is {}",uid,type);
|
|
|
487
|
+ RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(uid);
|
|
|
488
|
+ redisTemplate.delete(inboxKey);
|
|
|
489
|
+ RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(uid,type);
|
|
|
490
|
+ redisTemplate.delete(key);
|
|
|
491
|
+ RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,"N");
|
|
|
492
|
+ redisTemplate.delete(inboxTotalKey);
|
|
|
493
|
+ RedisKeyBuilder inboxTypeTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,type);
|
|
|
494
|
+ redisTemplate.delete(inboxTypeTotalKey);
|
|
|
495
|
+ }
|
|
|
496
|
+
|
453
|
private void syncBlockChain(String tagId, String nfcUid, Integer toUid){
|
497
|
private void syncBlockChain(String tagId, String nfcUid, Integer toUid){
|
454
|
IdentifyRecord record = queryIdentifyRecord(tagId, nfcUid);
|
498
|
IdentifyRecord record = queryIdentifyRecord(tagId, nfcUid);
|
455
|
//商品信息
|
499
|
//商品信息
|
|
@@ -475,7 +519,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -475,7 +519,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
475
|
//根据uid去uic获取用户手机号,并进行模糊处理。吃掉异常,防止超时影响正常逻辑
|
519
|
//根据uid去uic获取用户手机号,并进行模糊处理。吃掉异常,防止超时影响正常逻辑
|
476
|
try{
|
520
|
try{
|
477
|
Map<String,Integer> request = Collections.singletonMap("uid", toUid);
|
521
|
Map<String,Integer> request = Collections.singletonMap("uid", toUid);
|
478
|
- JSONObject jsonObject = serviceCaller.get("uic.getProfileAction", "http://" + uicServerIpAndPort + UIC_PROFILE_URL, request, JSONObject.class, null).get(1);
|
522
|
+ JSONObject jsonObject = serviceCaller.get("uic.getProfileAction", uicServerIpAndPort + UIC_PROFILE_URL, request, JSONObject.class, null).get(1);
|
479
|
|
523
|
|
480
|
if(null != jsonObject.getJSONObject("data") && null != jsonObject.getJSONObject("data").getString("mobile_phone")) {
|
524
|
if(null != jsonObject.getJSONObject("data") && null != jsonObject.getJSONObject("data").getString("mobile_phone")) {
|
481
|
String mobile = jsonObject.getJSONObject("data").getString("mobile_phone");;
|
525
|
String mobile = jsonObject.getJSONObject("data").getString("mobile_phone");;
|