Authored by caoyan

物权转移

@@ -86,6 +86,28 @@ public class ProductIdentifyController { @@ -86,6 +86,28 @@ public class ProductIdentifyController {
86 } 86 }
87 } 87 }
88 88
  89 + @ApiOperation(name = "ufo.product.queryIdentifyInfoForPlatform", desc="UFO商品物权转移查询接口")
  90 + @ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
  91 + @ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
  92 + @ApiParam(name="uid",required = true,desc="有货uid",type=Integer.class)
  93 + @ApiRespCode(code=200,desc="查询成功")
  94 + @ApiRespCode(code=402,desc="查询失败")
  95 + @IgnoreSignature
  96 + @RequestMapping(params = "method=ufo.product.queryIdentifyInfoForPlatform")
  97 + public ApiResponse queryIdentifyInfoForPlatform(@RequestParam(value = "tagId", required = true) String tagId,
  98 + @RequestParam(value = "nfcUid",required = false) String nfcUid) throws GatewayException {
  99 + try{
  100 + ProductIdentifyResp info = identifyService.queryIdentifyInfoForPlatform(tagId, nfcUid);
  101 + return new ApiResponse.ApiResponseBuilder().code(200).data(info).build();
  102 + }catch (Exception e){
  103 + logger.warn("queryIdentifyInfoForPlatform error! tagId={}, nfcUid={}, e is {}", tagId, nfcUid, e);
  104 + if( e instanceof GatewayException){
  105 + throw e;
  106 + }
  107 + return new ApiResponse.ApiResponseBuilder().code(402).message("查询失败,请稍后重试").build();
  108 + }
  109 + }
  110 +
89 @ApiOperation(name = "ufo.product.applyToBeOwner", desc="申请成为物权所有人") 111 @ApiOperation(name = "ufo.product.applyToBeOwner", desc="申请成为物权所有人")
90 @ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class) 112 @ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
91 @ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class) 113 @ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
@@ -18,4 +18,6 @@ public interface ProductIdentifyService { @@ -18,4 +18,6 @@ public interface ProductIdentifyService {
18 18
19 int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status) throws GatewayException; 19 int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status) throws GatewayException;
20 20
  21 + ProductIdentifyResp queryIdentifyInfoForPlatform(String tagId, String nfcUid) throws GatewayException;
  22 +
21 } 23 }
@@ -335,6 +335,47 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -335,6 +335,47 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
335 } 335 }
336 336
337 @Override 337 @Override
  338 + public ProductIdentifyResp queryIdentifyInfoForPlatform(String tagId, String nfcUid) throws GatewayException {
  339 + logger.info("enter queryNewIdentifyInfo, tagId = {}, nfcUid={}", tagId, nfcUid);
  340 + //返回结果可能在缓存中
  341 + ProductIdentifyResp result = getNewIdentifyFromCache(tagId, nfcUid);
  342 + if(result != null ){
  343 + logger.info("queryIdentifyInfoForPlatform get result from cache success! tagId = {}, nfcUid={}, result={} ", tagId, nfcUid, result);
  344 + return result;
  345 + }
  346 +
  347 + //1)鉴定 记录--先从缓存去取
  348 + IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
  349 + if(identifyRecord == null){
  350 + throw new GatewayException(402, "鉴定信息不存在");
  351 + }
  352 +
  353 + //根据鉴定记录 获取订单号
  354 + Long orderCode = identifyRecord.getOrderCode();
  355 + //2)订单号 获取订单详细信息
  356 + BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
  357 + if(buyerOrder == null){
  358 + throw new GatewayException(403, "订单不存在");
  359 + }
  360 +
  361 + //3)商品详细信息
  362 + result = getOrderDetail(buyerOrder, identifyRecord, tagId);
  363 +
  364 + //4)物权转移轨迹
  365 + List<IdentifyTrackResp> trackList = getTrackList(identifyRecord, result.getIdentifyPlat());
  366 + result.setTrackList(trackList);
  367 +
  368 + //5)设置当前物权所有人
  369 + result.setCurrentOwner(trackList.get(trackList.size()-1).getContent());
  370 +
  371 + //设置缓存--可能会有延时,不影响的
  372 + setNewIdentifyCache(tagId, nfcUid, result);
  373 +
  374 + logger.info("queryIdentifyInfoForPlatform success!, tagId = {}, nfcUid={}, result ={}", tagId, nfcUid, result );
  375 + return result;
  376 + }
  377 +
  378 + @Override
338 public int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException { 379 public int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException {
339 IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid); 380 IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
340 if(identifyRecord == null){ 381 if(identifyRecord == null){
@@ -716,7 +757,6 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -716,7 +757,6 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
716 } 757 }
717 758
718 private void setNewIdentifyCache(String tagId, String nfcUid, ProductIdentifyResp result) { 759 private void setNewIdentifyCache(String tagId, String nfcUid, ProductIdentifyResp result) {
719 -  
720 RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:newIdentifyResultInfo:"). 760 RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:newIdentifyResultInfo:").
721 appendVar(tagId).appendVar(":").appendVar(nfcUid); 761 appendVar(tagId).appendVar(":").appendVar(nfcUid);
722 clientCache.setEx(kb, result,5 * 60 ); 762 clientCache.setEx(kb, result,5 * 60 );