|
@@ -67,6 +67,7 @@ import com.yohoufo.product.response.IdentifyShareInfoResp; |
|
@@ -67,6 +67,7 @@ import com.yohoufo.product.response.IdentifyShareInfoResp; |
67
|
import com.yohoufo.product.response.IdentifyTrackResp;
|
67
|
import com.yohoufo.product.response.IdentifyTrackResp;
|
68
|
import com.yohoufo.product.response.ProductIdentifyResp;
|
68
|
import com.yohoufo.product.response.ProductIdentifyResp;
|
69
|
import com.yohoufo.product.service.ProductIdentifyService;
|
69
|
import com.yohoufo.product.service.ProductIdentifyService;
|
|
|
70
|
+import com.yohoufo.product.service.SendMessageService;
|
70
|
|
71
|
|
71
|
|
72
|
|
72
|
@Service
|
73
|
@Service
|
|
@@ -116,6 +117,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -116,6 +117,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
116
|
@Autowired
|
117
|
@Autowired
|
117
|
private TransferRecordsHistoryMapper transferRecordsHistoryMapper;
|
118
|
private TransferRecordsHistoryMapper transferRecordsHistoryMapper;
|
118
|
|
119
|
|
|
|
120
|
+ @Autowired
|
|
|
121
|
+ private SendMessageService sendMessageService;
|
|
|
122
|
+
|
119
|
@Resource(name = "yhProducer")
|
123
|
@Resource(name = "yhProducer")
|
120
|
private YhProducer yhProducer;
|
124
|
private YhProducer yhProducer;
|
121
|
|
125
|
|
|
@@ -134,6 +138,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -134,6 +138,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
134
|
|
138
|
|
135
|
public static final Integer OPERATE_TYPE_NO_APPLY = 4; //未申请
|
139
|
public static final Integer OPERATE_TYPE_NO_APPLY = 4; //未申请
|
136
|
|
140
|
|
|
|
141
|
+ public static final Integer OPERATE_TYPE_CANNOT_APPLY = 5; //不能申请
|
|
|
142
|
+
|
137
|
public static final Integer MESSAGE_TYPE_JUDGE_INFO = 1; //鉴定信息
|
143
|
public static final Integer MESSAGE_TYPE_JUDGE_INFO = 1; //鉴定信息
|
138
|
|
144
|
|
139
|
public static final Integer MESSAGE_TYPE_EX_OWNER = 2; //前主人
|
145
|
public static final Integer MESSAGE_TYPE_EX_OWNER = 2; //前主人
|
|
@@ -339,10 +345,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -339,10 +345,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
339
|
throw new GatewayException(402, "已经是物权所有人");
|
345
|
throw new GatewayException(402, "已经是物权所有人");
|
340
|
}
|
346
|
}
|
341
|
|
347
|
|
342
|
- TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, uid);
|
|
|
343
|
- if(null != history && (history.getStatus().equals(OPERATE_TYPE_APPLYING)
|
|
|
344
|
- || history.getStatus().equals(OPERATE_TYPE_PASS) || history.getStatus().equals(OPERATE_TYPE_REJECT))) {
|
|
|
345
|
- throw new GatewayException(402, "当前不可再申请");
|
348
|
+ TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, null);
|
|
|
349
|
+ if(null != history && (history.getStatus().equals(OPERATE_TYPE_APPLYING))) {
|
|
|
350
|
+ throw new GatewayException(402, "当前不可申请");
|
346
|
}
|
351
|
}
|
347
|
|
352
|
|
348
|
//将申请记录插入数据库
|
353
|
//将申请记录插入数据库
|
|
@@ -355,6 +360,16 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -355,6 +360,16 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
355
|
insertItem.setStatus(OPERATE_TYPE_APPLYING);
|
360
|
insertItem.setStatus(OPERATE_TYPE_APPLYING);
|
356
|
int result = transferRecordsHistoryMapper.insert(insertItem);
|
361
|
int result = transferRecordsHistoryMapper.insert(insertItem);
|
357
|
|
362
|
|
|
|
363
|
+ //根据鉴定记录 获取订单号
|
|
|
364
|
+ Long orderCode = identifyRecord.getOrderCode();
|
|
|
365
|
+ //获取订单详细信息
|
|
|
366
|
+ BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
367
|
+ if(buyerOrder == null){
|
|
|
368
|
+ throw new GatewayException(403, "订单不存在");
|
|
|
369
|
+ }
|
|
|
370
|
+ //向物权所有人发短信“用户189******59向您发起商品xxxxxx的物权转移申请,您可以 打开有货APP站内信查看并确认”
|
|
|
371
|
+ sendSmsToOwner(insertItem.getFromUid(), String.valueOf(uid), orderCode);
|
|
|
372
|
+
|
358
|
//向物权所有人发送站内信
|
373
|
//向物权所有人发送站内信
|
359
|
|
374
|
|
360
|
//发送定时mq
|
375
|
//发送定时mq
|
|
@@ -405,10 +420,30 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -405,10 +420,30 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
405
|
transferRecords.setCreateTime(DateUtil.getCurrentTimeSecond());
|
420
|
transferRecords.setCreateTime(DateUtil.getCurrentTimeSecond());
|
406
|
transferRecordsMapper.insert(transferRecords);
|
421
|
transferRecordsMapper.insert(transferRecords);
|
407
|
|
422
|
|
|
|
423
|
+ //清理缓存
|
|
|
424
|
+ clearIdentifyCache(tagId, nfcUid);
|
|
|
425
|
+
|
408
|
//更新identify_record
|
426
|
//更新identify_record
|
409
|
return identifyRecordsMapper.updateOwner(tagId, nfcUid, toUid);
|
427
|
return identifyRecordsMapper.updateOwner(tagId, nfcUid, toUid);
|
410
|
}
|
428
|
}
|
411
|
|
429
|
|
|
|
430
|
+ private void sendSmsToOwner(String fromUid, String uid, Long orderCode) {
|
|
|
431
|
+ List<String> uidList = Lists.newArrayList(fromUid, uid);
|
|
|
432
|
+ Map<Integer, ProfileInfoRsp> profileMap = queryIcoAndMobile(uidList);
|
|
|
433
|
+ String fromMobile = profileMap.get(Integer.parseInt(fromUid)).getMobile();
|
|
|
434
|
+ String toMobileMask = MobileHelper.coverMobile2(profileMap.get(Integer.parseInt(uid)).getMobile());
|
|
|
435
|
+
|
|
|
436
|
+ //商品信息
|
|
|
437
|
+ BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
|
|
|
438
|
+ Integer skup = buyerOrderGoods.getSkup();
|
|
|
439
|
+ //skup获取 productInfo
|
|
|
440
|
+ SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
441
|
+ StringBuilder content = new StringBuilder();
|
|
|
442
|
+ content.append("用户").append(toMobileMask).append("向您发起商品").append(sellerOrderGoods.getProductName());
|
|
|
443
|
+ content.append("的物权转移申请,您可以打开有货APP站内信查看并确认");
|
|
|
444
|
+ sendMessageService.smsSendByMobile(content.toString(), Lists.newArrayList(fromMobile));
|
|
|
445
|
+ }
|
|
|
446
|
+
|
412
|
private void rebuildResult(ProductIdentifyResp result, String tagId, String nfcUid, Integer uid) {
|
447
|
private void rebuildResult(ProductIdentifyResp result, String tagId, String nfcUid, Integer uid) {
|
413
|
boolean isOwner = queryIsOwner(tagId, nfcUid, uid);
|
448
|
boolean isOwner = queryIsOwner(tagId, nfcUid, uid);
|
414
|
result.setIfOwner(isOwner);
|
449
|
result.setIfOwner(isOwner);
|
|
@@ -421,6 +456,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -421,6 +456,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
421
|
if(null == history || !history.getStatus().equals(OPERATE_TYPE_APPLYING)) {
|
456
|
if(null == history || !history.getStatus().equals(OPERATE_TYPE_APPLYING)) {
|
422
|
result.setApplyStatus(OPERATE_TYPE_NO_APPLY);//未申请
|
457
|
result.setApplyStatus(OPERATE_TYPE_NO_APPLY);//未申请
|
423
|
}else if(!(history.getToUid().equals(String.valueOf(uid)))) {
|
458
|
}else if(!(history.getToUid().equals(String.valueOf(uid)))) {
|
|
|
459
|
+ result.setApplyStatus(OPERATE_TYPE_CANNOT_APPLY);
|
424
|
return;
|
460
|
return;
|
425
|
}else {
|
461
|
}else {
|
426
|
result.setApplyStatus(history.getStatus());
|
462
|
result.setApplyStatus(history.getStatus());
|
|
@@ -434,7 +470,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -434,7 +470,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
434
|
ProfileInfoRsp profileInfo = profileInfoArray[0];
|
470
|
ProfileInfoRsp profileInfo = profileInfoArray[0];
|
435
|
IdentifyTrackResp track = new IdentifyTrackResp();
|
471
|
IdentifyTrackResp track = new IdentifyTrackResp();
|
436
|
track.setUid(uid);
|
472
|
track.setUid(uid);
|
437
|
- track.setType(MESSAGE_TYPE_APPLICANT);;
|
473
|
+ track.setType(MESSAGE_TYPE_APPLICANT);
|
438
|
String mobileMask = MobileHelper.coverMobile2(profileInfo.getMobile());//隐位的手机号码--隐藏中间6位
|
474
|
String mobileMask = MobileHelper.coverMobile2(profileInfo.getMobile());//隐位的手机号码--隐藏中间6位
|
439
|
track.setContent(StringUtils.isEmpty(profileInfo.getNickname()) ? mobileMask : profileInfo.getNickname());
|
475
|
track.setContent(StringUtils.isEmpty(profileInfo.getNickname()) ? mobileMask : profileInfo.getNickname());
|
440
|
String headIcon = profileInfo.getHead_ico();
|
476
|
String headIcon = profileInfo.getHead_ico();
|
|
@@ -443,6 +479,16 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -443,6 +479,16 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
443
|
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}");
|
479
|
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}");
|
444
|
}
|
480
|
}
|
445
|
track.setHeadIcon(headIcon);
|
481
|
track.setHeadIcon(headIcon);
|
|
|
482
|
+
|
|
|
483
|
+ String message = "向" + result.getCurrentOwner() + "申请成为新主人";
|
|
|
484
|
+ String tip = "";
|
|
|
485
|
+ if(result.getApplyStatus().equals(OPERATE_TYPE_REJECT)) {
|
|
|
486
|
+ tip = "当前物权所有⼈人拒绝物权转移";
|
|
|
487
|
+ }else if(result.getApplyStatus().equals(OPERATE_TYPE_TIMEOUT)) {
|
|
|
488
|
+ tip = "当前主人确认申请超时,您可以重新发起申请";
|
|
|
489
|
+ }
|
|
|
490
|
+ track.setMessage(message);
|
|
|
491
|
+ track.setTip(tip);
|
446
|
result.getTrackList().add(track);
|
492
|
result.getTrackList().add(track);
|
447
|
}
|
493
|
}
|
448
|
|
494
|
|
|
@@ -668,6 +714,12 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
@@ -668,6 +714,12 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
668
|
appendVar(tagId).appendVar(":").appendVar(nfcUid);
|
714
|
appendVar(tagId).appendVar(":").appendVar(nfcUid);
|
669
|
clientCache.setEx(kb, result,5 * 60 );
|
715
|
clientCache.setEx(kb, result,5 * 60 );
|
670
|
}
|
716
|
}
|
|
|
717
|
+
|
|
|
718
|
+ private void clearIdentifyCache(String tagId, String nfcUid) {
|
|
|
719
|
+ RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:").
|
|
|
720
|
+ appendVar(tagId).appendVar(":").appendVar(nfcUid);
|
|
|
721
|
+ clientCache.delete(kb.toString());
|
|
|
722
|
+ }
|
671
|
|
723
|
|
672
|
private ProductIdentifyResp getIdentifyFromCache(String tagId, String nfcUid) {
|
724
|
private ProductIdentifyResp getIdentifyFromCache(String tagId, String nfcUid) {
|
673
|
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:").
|
725
|
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:").
|