...
|
...
|
@@ -67,6 +67,7 @@ import com.yohoufo.product.response.IdentifyShareInfoResp; |
|
|
import com.yohoufo.product.response.IdentifyTrackResp;
|
|
|
import com.yohoufo.product.response.ProductIdentifyResp;
|
|
|
import com.yohoufo.product.service.ProductIdentifyService;
|
|
|
import com.yohoufo.product.service.SendMessageService;
|
|
|
|
|
|
|
|
|
@Service
|
...
|
...
|
@@ -116,6 +117,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
@Autowired
|
|
|
private TransferRecordsHistoryMapper transferRecordsHistoryMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private SendMessageService sendMessageService;
|
|
|
|
|
|
@Resource(name = "yhProducer")
|
|
|
private YhProducer yhProducer;
|
|
|
|
...
|
...
|
@@ -134,6 +138,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
|
|
|
public static final Integer OPERATE_TYPE_NO_APPLY = 4; //未申请
|
|
|
|
|
|
public static final Integer OPERATE_TYPE_CANNOT_APPLY = 5; //不能申请
|
|
|
|
|
|
public static final Integer MESSAGE_TYPE_JUDGE_INFO = 1; //鉴定信息
|
|
|
|
|
|
public static final Integer MESSAGE_TYPE_EX_OWNER = 2; //前主人
|
...
|
...
|
@@ -339,10 +345,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
throw new GatewayException(402, "已经是物权所有人");
|
|
|
}
|
|
|
|
|
|
TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, uid);
|
|
|
if(null != history && (history.getStatus().equals(OPERATE_TYPE_APPLYING)
|
|
|
|| history.getStatus().equals(OPERATE_TYPE_PASS) || history.getStatus().equals(OPERATE_TYPE_REJECT))) {
|
|
|
throw new GatewayException(402, "当前不可再申请");
|
|
|
TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, null);
|
|
|
if(null != history && (history.getStatus().equals(OPERATE_TYPE_APPLYING))) {
|
|
|
throw new GatewayException(402, "当前不可申请");
|
|
|
}
|
|
|
|
|
|
//将申请记录插入数据库
|
...
|
...
|
@@ -355,6 +360,16 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
insertItem.setStatus(OPERATE_TYPE_APPLYING);
|
|
|
int result = transferRecordsHistoryMapper.insert(insertItem);
|
|
|
|
|
|
//根据鉴定记录 获取订单号
|
|
|
Long orderCode = identifyRecord.getOrderCode();
|
|
|
//获取订单详细信息
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
if(buyerOrder == null){
|
|
|
throw new GatewayException(403, "订单不存在");
|
|
|
}
|
|
|
//向物权所有人发短信“用户189******59向您发起商品xxxxxx的物权转移申请,您可以 打开有货APP站内信查看并确认”
|
|
|
sendSmsToOwner(insertItem.getFromUid(), String.valueOf(uid), orderCode);
|
|
|
|
|
|
//向物权所有人发送站内信
|
|
|
|
|
|
//发送定时mq
|
...
|
...
|
@@ -405,10 +420,30 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
transferRecords.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
transferRecordsMapper.insert(transferRecords);
|
|
|
|
|
|
//清理缓存
|
|
|
clearIdentifyCache(tagId, nfcUid);
|
|
|
|
|
|
//更新identify_record
|
|
|
return identifyRecordsMapper.updateOwner(tagId, nfcUid, toUid);
|
|
|
}
|
|
|
|
|
|
private void sendSmsToOwner(String fromUid, String uid, Long orderCode) {
|
|
|
List<String> uidList = Lists.newArrayList(fromUid, uid);
|
|
|
Map<Integer, ProfileInfoRsp> profileMap = queryIcoAndMobile(uidList);
|
|
|
String fromMobile = profileMap.get(Integer.parseInt(fromUid)).getMobile();
|
|
|
String toMobileMask = MobileHelper.coverMobile2(profileMap.get(Integer.parseInt(uid)).getMobile());
|
|
|
|
|
|
//商品信息
|
|
|
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
|
|
|
Integer skup = buyerOrderGoods.getSkup();
|
|
|
//skup获取 productInfo
|
|
|
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
StringBuilder content = new StringBuilder();
|
|
|
content.append("用户").append(toMobileMask).append("向您发起商品").append(sellerOrderGoods.getProductName());
|
|
|
content.append("的物权转移申请,您可以打开有货APP站内信查看并确认");
|
|
|
sendMessageService.smsSendByMobile(content.toString(), Lists.newArrayList(fromMobile));
|
|
|
}
|
|
|
|
|
|
private void rebuildResult(ProductIdentifyResp result, String tagId, String nfcUid, Integer uid) {
|
|
|
boolean isOwner = queryIsOwner(tagId, nfcUid, uid);
|
|
|
result.setIfOwner(isOwner);
|
...
|
...
|
@@ -421,6 +456,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
if(null == history || !history.getStatus().equals(OPERATE_TYPE_APPLYING)) {
|
|
|
result.setApplyStatus(OPERATE_TYPE_NO_APPLY);//未申请
|
|
|
}else if(!(history.getToUid().equals(String.valueOf(uid)))) {
|
|
|
result.setApplyStatus(OPERATE_TYPE_CANNOT_APPLY);
|
|
|
return;
|
|
|
}else {
|
|
|
result.setApplyStatus(history.getStatus());
|
...
|
...
|
@@ -434,7 +470,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
ProfileInfoRsp profileInfo = profileInfoArray[0];
|
|
|
IdentifyTrackResp track = new IdentifyTrackResp();
|
|
|
track.setUid(uid);
|
|
|
track.setType(MESSAGE_TYPE_APPLICANT);;
|
|
|
track.setType(MESSAGE_TYPE_APPLICANT);
|
|
|
String mobileMask = MobileHelper.coverMobile2(profileInfo.getMobile());//隐位的手机号码--隐藏中间6位
|
|
|
track.setContent(StringUtils.isEmpty(profileInfo.getNickname()) ? mobileMask : profileInfo.getNickname());
|
|
|
String headIcon = profileInfo.getHead_ico();
|
...
|
...
|
@@ -443,6 +479,16 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
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}");
|
|
|
}
|
|
|
track.setHeadIcon(headIcon);
|
|
|
|
|
|
String message = "向" + result.getCurrentOwner() + "申请成为新主人";
|
|
|
String tip = "";
|
|
|
if(result.getApplyStatus().equals(OPERATE_TYPE_REJECT)) {
|
|
|
tip = "当前物权所有⼈人拒绝物权转移";
|
|
|
}else if(result.getApplyStatus().equals(OPERATE_TYPE_TIMEOUT)) {
|
|
|
tip = "当前主人确认申请超时,您可以重新发起申请";
|
|
|
}
|
|
|
track.setMessage(message);
|
|
|
track.setTip(tip);
|
|
|
result.getTrackList().add(track);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -668,6 +714,12 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ |
|
|
appendVar(tagId).appendVar(":").appendVar(nfcUid);
|
|
|
clientCache.setEx(kb, result,5 * 60 );
|
|
|
}
|
|
|
|
|
|
private void clearIdentifyCache(String tagId, String nfcUid) {
|
|
|
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:").
|
|
|
appendVar(tagId).appendVar(":").appendVar(nfcUid);
|
|
|
clientCache.delete(kb.toString());
|
|
|
}
|
|
|
|
|
|
private ProductIdentifyResp getIdentifyFromCache(String tagId, String nfcUid) {
|
|
|
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:").
|
...
|
...
|
|