Authored by caoyan

物权转移

... ... @@ -86,6 +86,28 @@ public class ProductIdentifyController {
}
}
@ApiOperation(name = "ufo.product.queryIdentifyInfoForPlatform", desc="UFO商品物权转移查询接口")
@ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
@ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
@ApiParam(name="uid",required = true,desc="有货uid",type=Integer.class)
@ApiRespCode(code=200,desc="查询成功")
@ApiRespCode(code=402,desc="查询失败")
@IgnoreSignature
@RequestMapping(params = "method=ufo.product.queryIdentifyInfoForPlatform")
public ApiResponse queryIdentifyInfoForPlatform(@RequestParam(value = "tagId", required = true) String tagId,
@RequestParam(value = "nfcUid",required = false) String nfcUid) throws GatewayException {
try{
ProductIdentifyResp info = identifyService.queryIdentifyInfoForPlatform(tagId, nfcUid);
return new ApiResponse.ApiResponseBuilder().code(200).data(info).build();
}catch (Exception e){
logger.warn("queryIdentifyInfoForPlatform error! tagId={}, nfcUid={}, e is {}", tagId, nfcUid, e);
if( e instanceof GatewayException){
throw e;
}
return new ApiResponse.ApiResponseBuilder().code(402).message("查询失败,请稍后重试").build();
}
}
@ApiOperation(name = "ufo.product.applyToBeOwner", desc="申请成为物权所有人")
@ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
@ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
... ...
... ... @@ -18,4 +18,6 @@ public interface ProductIdentifyService {
int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status) throws GatewayException;
ProductIdentifyResp queryIdentifyInfoForPlatform(String tagId, String nfcUid) throws GatewayException;
}
... ...
... ... @@ -335,6 +335,47 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
}
@Override
public ProductIdentifyResp queryIdentifyInfoForPlatform(String tagId, String nfcUid) throws GatewayException {
logger.info("enter queryNewIdentifyInfo, tagId = {}, nfcUid={}", tagId, nfcUid);
//返回结果可能在缓存中
ProductIdentifyResp result = getNewIdentifyFromCache(tagId, nfcUid);
if(result != null ){
logger.info("queryIdentifyInfoForPlatform get result from cache success! tagId = {}, nfcUid={}, result={} ", tagId, nfcUid, result);
return result;
}
//1)鉴定 记录--先从缓存去取
IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
if(identifyRecord == null){
throw new GatewayException(402, "鉴定信息不存在");
}
//根据鉴定记录 获取订单号
Long orderCode = identifyRecord.getOrderCode();
//2)订单号 获取订单详细信息
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if(buyerOrder == null){
throw new GatewayException(403, "订单不存在");
}
//3)商品详细信息
result = getOrderDetail(buyerOrder, identifyRecord, tagId);
//4)物权转移轨迹
List<IdentifyTrackResp> trackList = getTrackList(identifyRecord, result.getIdentifyPlat());
result.setTrackList(trackList);
//5)设置当前物权所有人
result.setCurrentOwner(trackList.get(trackList.size()-1).getContent());
//设置缓存--可能会有延时,不影响的
setNewIdentifyCache(tagId, nfcUid, result);
logger.info("queryIdentifyInfoForPlatform success!, tagId = {}, nfcUid={}, result ={}", tagId, nfcUid, result );
return result;
}
@Override
public int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException {
IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
if(identifyRecord == null){
... ... @@ -716,7 +757,6 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
}
private void setNewIdentifyCache(String tagId, String nfcUid, ProductIdentifyResp result) {
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:newIdentifyResultInfo:").
appendVar(tagId).appendVar(":").appendVar(nfcUid);
clientCache.setEx(kb, result,5 * 60 );
... ...