Authored by caoyan

Merge branch 'dev_物权转移' into test6.8.6

# Conflicts:
#	web/src/main/resources/databases.yml
#	web/src/main/webapp/META-INF/autoconf/databases.yml
1 package com.yohoufo.dal.order; 1 package com.yohoufo.dal.order;
2 2
  3 +import org.apache.ibatis.annotations.Param;
  4 +
3 import com.yohoufo.dal.order.model.OrderOperateRecord; 5 import com.yohoufo.dal.order.model.OrderOperateRecord;
4 6
5 /** 7 /**
@@ -8,4 +10,6 @@ import com.yohoufo.dal.order.model.OrderOperateRecord; @@ -8,4 +10,6 @@ import com.yohoufo.dal.order.model.OrderOperateRecord;
8 public interface OrderOperateRecordMapper { 10 public interface OrderOperateRecordMapper {
9 11
10 int insert(OrderOperateRecord orderOperateRecord); 12 int insert(OrderOperateRecord orderOperateRecord);
  13 +
  14 + OrderOperateRecord selectByTypeAndOrderCode(@Param("type") Integer type, @Param("orderCode") Long orderCode);
11 } 15 }
1 package com.yohoufo.dal.product; 1 package com.yohoufo.dal.product;
2 2
3 -import com.yohoufo.dal.product.model.Brand;  
4 -import com.yohoufo.dal.product.model.IdentifyRecord;  
5 import org.apache.ibatis.annotations.Param; 3 import org.apache.ibatis.annotations.Param;
6 4
7 -import java.util.List; 5 +import com.yohoufo.dal.product.model.IdentifyRecord;
8 6
9 public interface IdentifyRecordsMapper { 7 public interface IdentifyRecordsMapper {
10 IdentifyRecord selectByTagAndNfcId(@Param("tagId") String tagId, @Param("nfcUid") String nfcUid); 8 IdentifyRecord selectByTagAndNfcId(@Param("tagId") String tagId, @Param("nfcUid") String nfcUid);
  9 +
  10 + int updateOwner(@Param("tagId") String tagId, @Param("nfcUid") String nfcUid, @Param("owner") Integer owner);
11 11
12 } 12 }
  1 +package com.yohoufo.dal.product;
  2 +
  3 +import org.apache.ibatis.annotations.Param;
  4 +
  5 +import com.yohoufo.dal.product.model.TransferRecordsHistory;
  6 +
  7 +/**
  8 + */
  9 +public interface TransferRecordsHistoryMapper {
  10 + int insert(TransferRecordsHistory transferRecordsHistory);
  11 +
  12 + TransferRecordsHistory selectByToUid(@Param("tagId") String tagId, @Param("nfcUid") String nfcUid, @Param("toUid") Integer toUid);
  13 +
  14 + int updateStatus(@Param("tagId") String tagId, @Param("nfcUid") String nfcUid, @Param("status") Integer status);
  15 +}
  1 +package com.yohoufo.dal.product;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.apache.ibatis.annotations.Param;
  6 +
  7 +import com.yohoufo.dal.product.model.TransferRecords;
  8 +
  9 +/**
  10 + */
  11 +public interface TransferRecordsMapper {
  12 + List<TransferRecords> selectByTagIdAndNfcUid(@Param("tagId") String tagId, @Param("nfcUid") String nfcUid);
  13 +
  14 + int insert(TransferRecords transferRecords);
  15 +}
  1 +package com.yohoufo.dal.product.model;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +
  5 +public class TransferRecords {
  6 +
  7 + private Integer id;
  8 +
  9 + private String tagId;
  10 +
  11 + private String nfcUid;
  12 +
  13 + private Integer createTime;
  14 +
  15 + private String fromUid;
  16 +
  17 + private String toUid;
  18 +
  19 + public Integer getId() {
  20 + return id;
  21 + }
  22 +
  23 + public void setId(Integer id) {
  24 + this.id = id;
  25 + }
  26 +
  27 + public String getTagId() {
  28 + return tagId;
  29 + }
  30 +
  31 + public void setTagId(String tagId) {
  32 + this.tagId = tagId;
  33 + }
  34 +
  35 + public String getNfcUid() {
  36 + return nfcUid;
  37 + }
  38 +
  39 + public void setNfcUid(String nfcUid) {
  40 + this.nfcUid = nfcUid;
  41 + }
  42 +
  43 + public Integer getCreateTime() {
  44 + return createTime;
  45 + }
  46 +
  47 + public void setCreateTime(Integer createTime) {
  48 + this.createTime = createTime;
  49 + }
  50 +
  51 + public String getFromUid() {
  52 + return fromUid;
  53 + }
  54 +
  55 + public void setFromUid(String fromUid) {
  56 + this.fromUid = fromUid;
  57 + }
  58 +
  59 + public String getToUid() {
  60 + return toUid;
  61 + }
  62 +
  63 + public void setToUid(String toUid) {
  64 + this.toUid = toUid;
  65 + }
  66 +
  67 + @Override
  68 + public String toString() {
  69 + return JSONObject.toJSONString(this);
  70 + }
  71 +}
  1 +package com.yohoufo.dal.product.model;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +
  5 +public class TransferRecordsHistory {
  6 +
  7 + private Integer id;
  8 +
  9 + private String tagId;
  10 +
  11 + private String nfcUid;
  12 +
  13 + private Integer operateTime;
  14 +
  15 + private String fromUid;
  16 +
  17 + private String toUid;
  18 +
  19 + private Integer status;
  20 +
  21 + public Integer getId() {
  22 + return id;
  23 + }
  24 +
  25 + public void setId(Integer id) {
  26 + this.id = id;
  27 + }
  28 +
  29 + public String getTagId() {
  30 + return tagId;
  31 + }
  32 +
  33 + public void setTagId(String tagId) {
  34 + this.tagId = tagId;
  35 + }
  36 +
  37 + public String getNfcUid() {
  38 + return nfcUid;
  39 + }
  40 +
  41 + public void setNfcUid(String nfcUid) {
  42 + this.nfcUid = nfcUid;
  43 + }
  44 +
  45 + public String getFromUid() {
  46 + return fromUid;
  47 + }
  48 +
  49 + public void setFromUid(String fromUid) {
  50 + this.fromUid = fromUid;
  51 + }
  52 +
  53 + public String getToUid() {
  54 + return toUid;
  55 + }
  56 +
  57 + public void setToUid(String toUid) {
  58 + this.toUid = toUid;
  59 + }
  60 +
  61 + public Integer getOperateTime() {
  62 + return operateTime;
  63 + }
  64 +
  65 + public void setOperateTime(Integer operateTime) {
  66 + this.operateTime = operateTime;
  67 + }
  68 +
  69 + public Integer getStatus() {
  70 + return status;
  71 + }
  72 +
  73 + public void setStatus(Integer status) {
  74 + this.status = status;
  75 + }
  76 +
  77 + @Override
  78 + public String toString() {
  79 + return JSONObject.toJSONString(this);
  80 + }
  81 +}
@@ -20,4 +20,11 @@ @@ -20,4 +20,11 @@
20 values (#{orderCode}, #{uid}, #{type}, #{userName}, #{oldInfo}, #{updateTime}) 20 values (#{orderCode}, #{uid}, #{type}, #{userName}, #{oldInfo}, #{updateTime})
21 </insert> 21 </insert>
22 22
  23 + <select id="selectByTypeAndOrderCode" resultMap="BaseResultMap">
  24 + select <include refid="Base_Column_List"></include>
  25 + from order_operate_record
  26 + where type=#{type} and order_code=#{orderCode}
  27 + limit 1
  28 + </select>
  29 +
23 </mapper> 30 </mapper>
@@ -23,4 +23,12 @@ @@ -23,4 +23,12 @@
23 </if> 23 </if>
24 limit 1 24 limit 1
25 </select> 25 </select>
  26 +
  27 + <update id="updateOwner">
  28 + update identify_records set owner=#{owner}
  29 + where tag_id = #{tagId,jdbcType=VARCHAR}
  30 + <if test="nfcUid != null" >
  31 + and nfc_uid = #{nfcUid,jdbcType=VARCHAR}
  32 + </if>
  33 + </update>
26 </mapper> 34 </mapper>
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.yohoufo.dal.product.TransferRecordsHistoryMapper">
  4 + <resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.TransferRecordsHistory">
  5 + <result column="id" property="id" jdbcType="INTEGER" />
  6 + <result column="tag_id" property="tagId" jdbcType="VARCHAR" />
  7 + <result column="nfc_uid" property="nfcUid" jdbcType="VARCHAR" />
  8 + <result column="from_uid" property="fromUid" jdbcType="VARCHAR" />
  9 + <result column="to_uid" property="toUid" jdbcType="VARCHAR" />
  10 + <result column="operate_time" property="operateTime" jdbcType="INTEGER" />
  11 + <result column="status" property="status" jdbcType="INTEGER" />
  12 + </resultMap>
  13 +
  14 + <sql id="Base_Column_List">
  15 + id,tag_id,nfc_uid,from_uid,to_uid,operate_time, status
  16 + </sql>
  17 +
  18 + <insert id="insert" parameterType="com.yohoufo.dal.product.model.TransferRecordsHistory">
  19 + insert into transfer_records_history (tag_id, nfc_uid, from_uid, to_uid, operate_time, status)
  20 + values (#{tagId}, #{nfcUid}, #{fromUid}, #{toUid}, #{operateTime}, #{status})
  21 + </insert>
  22 +
  23 + <select id="selectByToUid" resultMap="BaseResultMap">
  24 + select <include refid="Base_Column_List"></include>
  25 + from transfer_records_history
  26 + where tag_id=#{tagId}
  27 + <if test="nfcUid != null and nfcUid != '' ">
  28 + and nfc_uid=#{nfcUid}
  29 + </if>
  30 + <if test="toUid != null and toUid != 0">
  31 + and to_uid=#{toUid}
  32 + </if>
  33 + order by operate_time desc
  34 + limit 1
  35 + </select>
  36 +
  37 + <update id="updateStatus">
  38 + update transfer_records_history set status=#{status}
  39 + where tag_id=#{tagId}
  40 + <if test="nfcUid != null and nfcUid != '' ">
  41 + and nfc_uid=#{nfcUid}
  42 + </if>
  43 + </update>
  44 +</mapper>
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.yohoufo.dal.product.TransferRecordsMapper">
  4 + <resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.TransferRecords">
  5 + <result column="id" property="id" jdbcType="INTEGER" />
  6 + <result column="tag_id" property="tagId" jdbcType="VARCHAR" />
  7 + <result column="nfc_uid" property="nfcUid" jdbcType="VARCHAR" />
  8 + <result column="from_uid" property="fromUid" jdbcType="VARCHAR" />
  9 + <result column="to_uid" property="toUid" jdbcType="VARCHAR" />
  10 + <result column="create_time" property="createTime" jdbcType="INTEGER" />
  11 + </resultMap>
  12 +
  13 + <sql id="Base_Column_List">
  14 + id,tag_id,nfc_uid,from_uid,to_uid,create_time
  15 + </sql>
  16 +
  17 + <select id="selectByTagIdAndNfcUid" resultMap="BaseResultMap">
  18 + select <include refid="Base_Column_List"></include>
  19 + from transfer_records
  20 + where tag_id=#{tagId}
  21 + <if test="nfcUid != null" >
  22 + and nfc_uid = #{nfcUid,jdbcType=VARCHAR}
  23 + </if>
  24 + order by create_time asc
  25 + </select>
  26 +
  27 + <update id="updateOwner">
  28 + update transfer_records set from_uid=#{fromUid}, to_uid=#{toUid}
  29 + </update>
  30 +
  31 + <insert id="insert" parameterType="com.yohoufo.dal.product.model.TransferRecords">
  32 + insert into
  33 + transfer_records(tag_id,nfc_uid,from_uid,to_uid,create_time)
  34 + values
  35 + (#{tagId,jdbcType=VARCHAR },#{nfcUid,jdbcType=VARCHAR },#{fromUid,jdbcType=VARCHAR},#{toUid,jdbcType=VARCHAR },#{createTime,jdbcType=INTEGER })
  36 + </insert>
  37 +
  38 +</mapper>
@@ -38,5 +38,9 @@ @@ -38,5 +38,9 @@
38 <groupId>com.yoho.ufo.model</groupId> 38 <groupId>com.yoho.ufo.model</groupId>
39 <artifactId>product-ufo-model</artifactId> 39 <artifactId>product-ufo-model</artifactId>
40 </dependency> 40 </dependency>
  41 + <dependency>
  42 + <groupId>com.yoho.core</groupId>
  43 + <artifactId>yoho-core-rabbitmq</artifactId>
  44 + </dependency>
41 </dependencies> 45 </dependencies>
42 </project> 46 </project>
1 package com.yohoufo.product.controller; 1 package com.yohoufo.product.controller;
2 2
3 -import com.alibaba.fastjson.JSONObject;  
4 -import com.yoho.error.GatewayError;  
5 -import com.yoho.error.exception.ServiceException;  
6 -import com.yoho.tools.docs.ApiOperation;  
7 -import com.yohoufo.common.ApiResponse;  
8 -import com.yohoufo.common.annotation.IgnoreSession;  
9 -import com.yohoufo.common.annotation.IgnoreSignature;  
10 -import com.yohoufo.common.cache.Cachable;  
11 -import com.yohoufo.common.caller.UfoServiceCaller;  
12 -import com.yohoufo.common.exception.GatewayException;  
13 -import com.yohoufo.product.helper.SearchHelpService;  
14 -import com.yohoufo.product.request.ProductSearchReq;  
15 -import com.yohoufo.product.request.SortIdLevel;  
16 -import com.yohoufo.product.response.*;  
17 -import com.yohoufo.product.service.ProductIdentifyService;  
18 -import com.yohoufo.product.service.ProductSearchService;  
19 import org.slf4j.Logger; 3 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory; 4 import org.slf4j.LoggerFactory;
21 import org.springframework.beans.factory.annotation.Autowired; 5 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,8 +7,15 @@ import org.springframework.web.bind.annotation.RequestMapping; @@ -23,8 +7,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
23 import org.springframework.web.bind.annotation.RequestParam; 7 import org.springframework.web.bind.annotation.RequestParam;
24 import org.springframework.web.bind.annotation.RestController; 8 import org.springframework.web.bind.annotation.RestController;
25 9
26 -import java.util.List;  
27 -import java.util.Map; 10 +import com.yoho.tools.docs.ApiOperation;
  11 +import com.yoho.tools.docs.ApiParam;
  12 +import com.yoho.tools.docs.ApiResp;
  13 +import com.yoho.tools.docs.ApiRespCode;
  14 +import com.yohoufo.common.ApiResponse;
  15 +import com.yohoufo.common.annotation.IgnoreSignature;
  16 +import com.yohoufo.common.exception.GatewayException;
  17 +import com.yohoufo.product.response.ProductIdentifyResp;
  18 +import com.yohoufo.product.service.ProductIdentifyService;
28 19
29 @RestController 20 @RestController
30 public class ProductIdentifyController { 21 public class ProductIdentifyController {
@@ -70,4 +61,80 @@ public class ProductIdentifyController { @@ -70,4 +61,80 @@ public class ProductIdentifyController {
70 // return new ApiResponse.ApiResponseBuilder().code(401).message("操作失败,请稍后重试").build(); 61 // return new ApiResponse.ApiResponseBuilder().code(401).message("操作失败,请稍后重试").build();
71 // } 62 // }
72 // } 63 // }
  64 +
  65 + @ApiOperation(name = "ufo.product.queryNewIdentifyInfo", desc="UFO商品物权转移查询接口")
  66 + @ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
  67 + @ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
  68 + @ApiParam(name="uid",required = true,desc="有货uid",type=Integer.class)
  69 + @ApiResp(dataClazz=ProductIdentifyResp.class, desc="UFO商品物权转移信息")
  70 + @ApiRespCode(code=200,desc="查询成功")
  71 + @ApiRespCode(code=402,desc="查询失败")
  72 + @IgnoreSignature
  73 + @RequestMapping(params = "method=ufo.product.queryNewIdentifyInfo")
  74 + public ApiResponse queryNewIdentifyInfo(@RequestParam(value = "tagId", required = true) String tagId,
  75 + @RequestParam(value = "nfcUid",required = false) String nfcUid,
  76 + @RequestParam(value = "uid", required = true) Integer uid) throws GatewayException {
  77 + try{
  78 + ProductIdentifyResp info = identifyService.queryNewIdentifyInfo(tagId, nfcUid, uid);
  79 + return new ApiResponse.ApiResponseBuilder().code(200).data(info).build();
  80 + }catch (Exception e){
  81 + logger.warn("queryNewIdentifyInfo error! tagId={}, nfcUid={}, uid={}, e is {}", tagId, nfcUid, uid, e);
  82 + if( e instanceof GatewayException){
  83 + throw e;
  84 + }
  85 + return new ApiResponse.ApiResponseBuilder().code(402).message("查询失败,请稍后重试").build();
  86 + }
  87 + }
  88 +
  89 + @ApiOperation(name = "ufo.product.applyToBeOwner", desc="申请成为物权所有人")
  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 + @ApiResp(dataClazz=ProductIdentifyResp.class, desc="申请成为物权所有人")
  94 + @ApiRespCode(code=200,desc="操作成功")
  95 + @ApiRespCode(code=402,desc="操作失败")
  96 + @IgnoreSignature
  97 + @RequestMapping(params = "method=ufo.product.applyToBeOwner")
  98 + public ApiResponse applyToBeOwner(@RequestParam(value = "tagId", required = true) String tagId,
  99 + @RequestParam(value = "nfcUid",required = false) String nfcUid,
  100 + @RequestParam(value = "uid", required = true) Integer uid) throws GatewayException {
  101 + try{
  102 + int result = identifyService.applyToBeOwner(tagId, nfcUid, uid);
  103 + return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
  104 + }catch (Exception e){
  105 + logger.warn("applyToBeOwner error! tagId={}, nfcUid={}, uid={}, e is {}", tagId, nfcUid, uid, e);
  106 + if( e instanceof GatewayException){
  107 + throw e;
  108 + }
  109 + return new ApiResponse.ApiResponseBuilder().code(402).message("申请失败,请稍后重试").build();
  110 + }
  111 + }
  112 +
  113 + @ApiOperation(name = "ufo.product.updateOwnerApply", desc="确认物权转移")
  114 + @ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
  115 + @ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
  116 + @ApiParam(name="from_uid",required = true,desc="当前物权所有人",type=Integer.class)
  117 + @ApiParam(name="to_uid",required = true,desc="物权申请人",type=Integer.class)
  118 + @ApiParam(name="status",required = true,desc="确认结果1:同意,2:拒绝",type=Integer.class)
  119 + @ApiResp(dataClazz=ProductIdentifyResp.class, desc="申请成为物权所有人")
  120 + @ApiRespCode(code=200,desc="操作成功")
  121 + @ApiRespCode(code=402,desc="操作失败")
  122 + @IgnoreSignature
  123 + @RequestMapping(params = "method=ufo.product.confirmTransferOwner")
  124 + public ApiResponse confirmTransferOwner(@RequestParam(value = "tagId", required = true) String tagId,
  125 + @RequestParam(value = "nfcUid",required = false) String nfcUid,
  126 + @RequestParam(value = "from_uid", required = true) Integer fromUid,
  127 + @RequestParam(value = "to_uid", required = true) Integer toUid,
  128 + @RequestParam(value = "status", required = true) Integer status) throws GatewayException {
  129 + try{
  130 + int result = identifyService.confirmOwner(tagId, nfcUid, fromUid, toUid, status);
  131 + return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
  132 + }catch (Exception e){
  133 + logger.warn("confirmTransferOwner error! tagId={}, nfcUid={}, fromUid={}, toUid is{}, e is {}", tagId, nfcUid, fromUid, toUid, e);
  134 + if(e instanceof GatewayException){
  135 + throw e;
  136 + }
  137 + return new ApiResponse.ApiResponseBuilder().code(402).message("操作失败,请稍后重试").build();
  138 + }
  139 + }
73 } 140 }
  1 +package com.yohoufo.product.mq;
  2 +
  3 +public interface TopicConstants {
  4 + /**
  5 + * 物权转移确认超时
  6 + */
  7 + String MQ_TOPIC_CONFIRM_OWNER_DELAY = "productOwner.updateTimeOut";
  8 +}
  1 +package com.yohoufo.product.mq.consumer;
  2 +
  3 +import org.slf4j.Logger;
  4 +import org.slf4j.LoggerFactory;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.stereotype.Component;
  7 +
  8 +import com.alibaba.fastjson.JSON;
  9 +import com.yoho.core.rabbitmq.YhConsumer;
  10 +import com.yohoufo.common.utils.DateUtil;
  11 +import com.yohoufo.dal.product.TransferRecordsHistoryMapper;
  12 +import com.yohoufo.dal.product.model.TransferRecordsHistory;
  13 +import com.yohoufo.product.mq.TopicConstants;
  14 +
  15 +/**
  16 + * 物权确认超时
  17 + * Created by caoyan.
  18 + */
  19 +@Component
  20 +public class ProductOwnerConfirmDelayMsgConsumer implements YhConsumer {
  21 + private static final Logger LOGGER = LoggerFactory.getLogger("mqConsumerLog");
  22 +
  23 + @Autowired
  24 + private TransferRecordsHistoryMapper transferRecordsHistoryMapper;
  25 +
  26 + public static final Integer OPERATE_TYPE_APPLYING = 0;//申请中
  27 +
  28 + public static final Integer OPERATE_TYPE_TIMEOUT = 3;//确认超时
  29 +
  30 + public String getMessageTopic() {
  31 + return TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY;
  32 + }
  33 +
  34 + @Override
  35 + public void handleMessage(Object message) {
  36 + LOGGER.info("begin handle productOwnerConfirmTimeout update message, message is {}.", message);
  37 + TransferRecordsHistory obj = JSON.parseObject(String.valueOf(message),TransferRecordsHistory.class);
  38 + TransferRecordsHistory dbItem = transferRecordsHistoryMapper.selectByToUid(obj.getTagId(), obj.getNfcUid(), Integer.valueOf(obj.getToUid()));
  39 + if(null != dbItem && dbItem.getStatus().equals(OPERATE_TYPE_APPLYING)) {
  40 + //将记录插入历史表transfer_recors_history
  41 + TransferRecordsHistory insertItem = new TransferRecordsHistory();
  42 + insertItem.setTagId(obj.getTagId());
  43 + insertItem.setNfcUid(obj.getNfcUid());
  44 + insertItem.setFromUid(obj.getFromUid());
  45 + insertItem.setToUid(obj.getToUid());
  46 + insertItem.setOperateTime(DateUtil.getCurrentTimeSecond());
  47 + insertItem.setStatus(OPERATE_TYPE_TIMEOUT);
  48 + transferRecordsHistoryMapper.insert(insertItem);
  49 + LOGGER.info("handle productOwnerConfirmTimeout update message success, message is {}.", message);
  50 + return;
  51 + }
  52 +
  53 + LOGGER.info("not need to handle productOwnerConfirmTimeout update message, message is {}.", message);
  54 +
  55 + }
  56 +}
@@ -16,5 +16,8 @@ public class ProductIdentifyResp { @@ -16,5 +16,8 @@ public class ProductIdentifyResp {
16 private String identifyPlat; 16 private String identifyPlat;
17 private List<IdentifyTrackResp> trackList; 17 private List<IdentifyTrackResp> trackList;
18 private String transactionId;//区块链Id 18 private String transactionId;//区块链Id
19 - 19 + private boolean ifOwner;//当前登录的是否是物权所有人
  20 + private String identifyUserName;//鉴定师名字
  21 + private Integer applyStatus;//申请物权转移状态
  22 + private String currentOwner;//当前物权所有人
20 } 23 }
@@ -6,12 +6,16 @@ import com.yohoufo.common.exception.GatewayException; @@ -6,12 +6,16 @@ import com.yohoufo.common.exception.GatewayException;
6 import com.yohoufo.product.response.IdentifyShareInfoResp; 6 import com.yohoufo.product.response.IdentifyShareInfoResp;
7 import com.yohoufo.product.response.ProductIdentifyResp; 7 import com.yohoufo.product.response.ProductIdentifyResp;
8 8
9 -import java.util.List;  
10 -  
11 public interface ProductIdentifyService { 9 public interface ProductIdentifyService {
12 10
13 -  
14 ProductIdentifyResp queryIdentifyInfo(String tagId, String nfcUid) throws GatewayException; 11 ProductIdentifyResp queryIdentifyInfo(String tagId, String nfcUid) throws GatewayException;
15 12
16 IdentifyShareInfoResp getShareIdentifyInfo( String tagId, String nfcUid) throws GatewayException; 13 IdentifyShareInfoResp getShareIdentifyInfo( String tagId, String nfcUid) throws GatewayException;
  14 +
  15 + ProductIdentifyResp queryNewIdentifyInfo(String tagId, String nfcUid, Integer uid) throws GatewayException;
  16 +
  17 + int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException;
  18 +
  19 + int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status) throws GatewayException;
  20 +
17 } 21 }
1 package com.yohoufo.product.service.impl; 1 package com.yohoufo.product.service.impl;
2 2
  3 +import java.text.SimpleDateFormat;
  4 +import java.util.ArrayList;
  5 +import java.util.Collections;
  6 +import java.util.Comparator;
  7 +import java.util.Date;
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +import java.util.Map.Entry;
  11 +import java.util.stream.Collectors;
  12 +
  13 +import javax.annotation.Resource;
  14 +
  15 +import org.apache.commons.lang.ArrayUtils;
  16 +import org.apache.commons.lang3.StringUtils;
  17 +import org.elasticsearch.common.collect.Lists;
  18 +import org.slf4j.Logger;
  19 +import org.slf4j.LoggerFactory;
  20 +import org.springframework.beans.factory.annotation.Autowired;
  21 +import org.springframework.beans.factory.annotation.Value;
  22 +import org.springframework.stereotype.Service;
  23 +
3 import com.alibaba.fastjson.JSONObject; 24 import com.alibaba.fastjson.JSONObject;
4 -import com.qiniu.util.Json; 25 +import com.google.common.collect.Maps;
5 import com.yoho.core.config.ConfigReader; 26 import com.yoho.core.config.ConfigReader;
  27 +import com.yoho.core.rabbitmq.YhProducer;
6 import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder; 28 import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
7 import com.yoho.core.rest.client.ServiceCaller; 29 import com.yoho.core.rest.client.ServiceCaller;
8 import com.yoho.core.rest.client.hystrix.AsyncFuture; 30 import com.yoho.core.rest.client.hystrix.AsyncFuture;
@@ -11,37 +33,40 @@ import com.yoho.service.model.social.request.UicUserReqBO; @@ -11,37 +33,40 @@ import com.yoho.service.model.social.request.UicUserReqBO;
11 import com.yoho.service.model.social.response.UserInfoRspBO; 33 import com.yoho.service.model.social.response.UserInfoRspBO;
12 import com.yoho.service.model.uic.UicResponse; 34 import com.yoho.service.model.uic.UicResponse;
13 import com.yoho.service.model.uic.request.UserInfoBO; 35 import com.yoho.service.model.uic.request.UserInfoBO;
  36 +import com.yohobuy.ufo.model.order.common.OperateTypeEnum;
14 import com.yohobuy.ufo.model.order.constants.QNliveConstants; 37 import com.yohobuy.ufo.model.order.constants.QNliveConstants;
15 import com.yohoufo.common.cache.CacheClient; 38 import com.yohoufo.common.cache.CacheClient;
16 import com.yohoufo.common.exception.GatewayException; 39 import com.yohoufo.common.exception.GatewayException;
17 import com.yohoufo.common.helper.ImageUrlAssist; 40 import com.yohoufo.common.helper.ImageUrlAssist;
  41 +import com.yohoufo.common.utils.DateUtil;
18 import com.yohoufo.common.utils.MobileHelper; 42 import com.yohoufo.common.utils.MobileHelper;
19 -  
20 -import com.yohoufo.dal.order.*; 43 +import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
  44 +import com.yohoufo.dal.order.BuyerOrderMapper;
  45 +import com.yohoufo.dal.order.OrderOperateRecordMapper;
  46 +import com.yohoufo.dal.order.OrdersPayMapper;
  47 +import com.yohoufo.dal.order.QiniuLiveRecordMapper;
  48 +import com.yohoufo.dal.order.SellerOrderGoodsMapper;
21 import com.yohoufo.dal.order.model.BuyerOrder; 49 import com.yohoufo.dal.order.model.BuyerOrder;
22 import com.yohoufo.dal.order.model.BuyerOrderGoods; 50 import com.yohoufo.dal.order.model.BuyerOrderGoods;
  51 +import com.yohoufo.dal.order.model.OrderOperateRecord;
  52 +import com.yohoufo.dal.order.model.OrdersPay;
23 import com.yohoufo.dal.order.model.QiniuLiveRecord; 53 import com.yohoufo.dal.order.model.QiniuLiveRecord;
24 import com.yohoufo.dal.order.model.SellerOrderGoods; 54 import com.yohoufo.dal.order.model.SellerOrderGoods;
25 -import com.yohoufo.dal.order.model.OrdersPay;  
26 import com.yohoufo.dal.product.IdentifyRecordsMapper; 55 import com.yohoufo.dal.product.IdentifyRecordsMapper;
27 import com.yohoufo.dal.product.IdentifyRelationMapper; 56 import com.yohoufo.dal.product.IdentifyRelationMapper;
28 import com.yohoufo.dal.product.ProductChainMapper; 57 import com.yohoufo.dal.product.ProductChainMapper;
  58 +import com.yohoufo.dal.product.TransferRecordsHistoryMapper;
  59 +import com.yohoufo.dal.product.TransferRecordsMapper;
29 import com.yohoufo.dal.product.model.IdentifyRecord; 60 import com.yohoufo.dal.product.model.IdentifyRecord;
30 import com.yohoufo.dal.product.model.IdentifyRelation; 61 import com.yohoufo.dal.product.model.IdentifyRelation;
31 import com.yohoufo.dal.product.model.ProductChain; 62 import com.yohoufo.dal.product.model.ProductChain;
  63 +import com.yohoufo.dal.product.model.TransferRecords;
  64 +import com.yohoufo.dal.product.model.TransferRecordsHistory;
  65 +import com.yohoufo.product.mq.TopicConstants;
32 import com.yohoufo.product.response.IdentifyShareInfoResp; 66 import com.yohoufo.product.response.IdentifyShareInfoResp;
33 import com.yohoufo.product.response.IdentifyTrackResp; 67 import com.yohoufo.product.response.IdentifyTrackResp;
34 import com.yohoufo.product.response.ProductIdentifyResp; 68 import com.yohoufo.product.response.ProductIdentifyResp;
35 import com.yohoufo.product.service.ProductIdentifyService; 69 import com.yohoufo.product.service.ProductIdentifyService;
36 -import org.apache.commons.lang3.StringUtils;  
37 -import org.slf4j.Logger;  
38 -import org.slf4j.LoggerFactory;  
39 -import org.springframework.beans.factory.annotation.Autowired;  
40 -import org.springframework.beans.factory.annotation.Value;  
41 -import org.springframework.stereotype.Service;  
42 -  
43 -import java.text.SimpleDateFormat;  
44 -import java.util.*;  
45 70
46 71
47 @Service 72 @Service
@@ -81,12 +106,34 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -81,12 +106,34 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
81 106
82 @Autowired 107 @Autowired
83 private ConfigReader configReader; 108 private ConfigReader configReader;
  109 +
  110 + @Autowired
  111 + private TransferRecordsMapper transferRecordsMapper;
  112 +
  113 + @Autowired
  114 + private OrderOperateRecordMapper orderOperateRecordMapper;
  115 +
  116 + @Autowired
  117 + private TransferRecordsHistoryMapper transferRecordsHistoryMapper;
  118 +
  119 + @Resource(name = "yhProducer")
  120 + private YhProducer yhProducer;
84 121
85 @Value("${uic.url:http://uic.yohoops.org/uic}") 122 @Value("${uic.url:http://uic.yohoops.org/uic}")
86 private String uicUrl; 123 private String uicUrl;
87 124
88 public static final String DEFAULT_HEAD_IMG = "http://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png?imageView/{mode}/w/{width}/h/{height}"; 125 public static final String DEFAULT_HEAD_IMG = "http://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png?imageView/{mode}/w/{width}/h/{height}";
89 126
  127 + public static final Integer OPERATE_TYPE_APPLYING = 0;//申请中
  128 +
  129 + public static final Integer OPERATE_TYPE_PASS = 1;//同意
  130 +
  131 + public static final Integer OPERATE_TYPE_REJECT = 2;//拒绝
  132 +
  133 + public static final Integer OPERATE_TYPE_TIMEOUT = 3;//确认超时
  134 +
  135 + public static final Integer OPERATE_TYPE_NO_APPLY = 4; //未申请
  136 +
90 /** 137 /**
91 * 鉴定结果查询接口 138 * 鉴定结果查询接口
92 * @param tagId 139 * @param tagId
@@ -219,6 +266,288 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -219,6 +266,288 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
219 logger.info("queryIdentifyInfo success!, tagId = {}, nfcUid={}, result ={}", tagId, nfcUid, result ); 266 logger.info("queryIdentifyInfo success!, tagId = {}, nfcUid={}, result ={}", tagId, nfcUid, result );
220 return result; 267 return result;
221 } 268 }
  269 +
  270 + private boolean queryIsOwner(String tagId, String nfcUid, Integer uid) {
  271 + IdentifyRecord record = identifyRecordsMapper.selectByTagAndNfcId(tagId, nfcUid);
  272 + if(null != record && record.getOwner() == uid.intValue()) {
  273 + return true;
  274 + }
  275 +
  276 + return false;
  277 + }
  278 +
  279 + @Override
  280 + public ProductIdentifyResp queryNewIdentifyInfo(String tagId, String nfcUid, Integer uid) throws GatewayException {
  281 + logger.info("enter queryNewIdentifyInfo, tagId = {}, nfcUid={}, uid={}", tagId, nfcUid, uid);
  282 + //返回结果可能在缓存中
  283 + ProductIdentifyResp result = getIdentifyFromCache(tagId, nfcUid);
  284 + if(result != null ){
  285 + rebuildResult(result, tagId, nfcUid, uid);
  286 + logger.info("queryNewIdentifyInfo get result from cache success! tagId = {}, nfcUid={},uid={}, result={} ", tagId, nfcUid, uid, result );
  287 + return result;
  288 + }
  289 +
  290 + //1)鉴定 记录--先从缓存去取
  291 + IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
  292 + if(identifyRecord == null){
  293 + throw new GatewayException(402, "鉴定信息不存在");
  294 + }
  295 +
  296 + //根据鉴定记录 获取订单号
  297 + Long orderCode = identifyRecord.getOrderCode();
  298 + //2)订单号 获取订单详细信息
  299 + BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
  300 + if(buyerOrder == null){
  301 + throw new GatewayException(403, "订单不存在");
  302 + }
  303 +
  304 + //3)商品详细信息
  305 + result = getOrderDetail(buyerOrder, identifyRecord, tagId);
  306 +
  307 + //4)物权转移轨迹
  308 + List<IdentifyTrackResp> trackList = getTrackList(identifyRecord, result.getIdentifyPlat());
  309 + result.setTrackList(trackList);
  310 +
  311 + //5)设置当前物权所有人
  312 + result.setCurrentOwner(trackList.get(trackList.size()-1).getContent());
  313 +
  314 + //设置缓存--可能会有延时,不影响的
  315 + setIdentifyCache(tagId, nfcUid, result);
  316 +
  317 + //添加申请物权转移人信息
  318 + rebuildResult(result, tagId, nfcUid, uid);
  319 + logger.info("queryIdentifyInfo success!, tagId = {}, nfcUid={}, result ={}", tagId, nfcUid, result );
  320 + return result;
  321 + }
  322 +
  323 + @Override
  324 + public int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException {
  325 + IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
  326 + if(identifyRecord == null){
  327 + throw new GatewayException(402, "鉴定信息不存在");
  328 + }
  329 +
  330 + if(identifyRecord.getOwner() == uid.intValue()) {
  331 + throw new GatewayException(402, "已经是物权所有人");
  332 + }
  333 +
  334 + TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, uid);
  335 + if(null != history && (history.getStatus().equals(OPERATE_TYPE_APPLYING)
  336 + || history.getStatus().equals(OPERATE_TYPE_PASS) || history.getStatus().equals(OPERATE_TYPE_REJECT))) {
  337 + throw new GatewayException(402, "当前不可再申请");
  338 + }
  339 +
  340 + //将申请记录插入数据库
  341 + TransferRecordsHistory insertItem = new TransferRecordsHistory();
  342 + insertItem.setTagId(tagId);
  343 + insertItem.setNfcUid(nfcUid);
  344 + insertItem.setFromUid(String.valueOf(identifyRecord.getOwner()));
  345 + insertItem.setToUid(String.valueOf(uid));
  346 + insertItem.setOperateTime(DateUtil.getCurrentTimeSecond());
  347 + insertItem.setStatus(OPERATE_TYPE_APPLYING);
  348 + int result = transferRecordsHistoryMapper.insert(insertItem);
  349 +
  350 + //向物权所有人发送站内信
  351 +
  352 + //发送定时mq
  353 + yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 3*24*60);//3天
  354 +
  355 + return result;
  356 + }
  357 +
  358 + @Override
  359 + public int confirmOwner(String tagId, String nfcUid, Integer fromUid, Integer toUid, Integer status) throws GatewayException {
  360 + if(null == status || !(status.equals(OPERATE_TYPE_PASS) || status.equals(OPERATE_TYPE_REJECT))){
  361 + throw new GatewayException(402, "参数status错误");
  362 + }
  363 + IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
  364 + if(identifyRecord == null){
  365 + throw new GatewayException(402, "鉴定信息不存在");
  366 + }
  367 +
  368 + if(identifyRecord.getOwner() != fromUid.intValue()) {
  369 + throw new GatewayException(402, "不是当前物权所有人,无法操作");
  370 + }
  371 +
  372 + TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, toUid);
  373 + if(null == history || !history.getStatus().equals(OPERATE_TYPE_APPLYING)) {
  374 + throw new GatewayException(402, "不是申请中状态");
  375 + }
  376 +
  377 + //将记录插入历史表transfer_recors_history
  378 + TransferRecordsHistory histroy = new TransferRecordsHistory();
  379 + histroy.setTagId(tagId);
  380 + histroy.setNfcUid(nfcUid);
  381 + histroy.setFromUid(String.valueOf(identifyRecord.getOwner()));
  382 + histroy.setToUid(String.valueOf(toUid));
  383 + histroy.setOperateTime(DateUtil.getCurrentTimeSecond());
  384 + histroy.setStatus(status);
  385 + int result = transferRecordsHistoryMapper.insert(histroy);
  386 +
  387 + if(status.equals(OPERATE_TYPE_REJECT)) {
  388 + return result;
  389 + }
  390 +
  391 + //增加记录到transfer_records
  392 + TransferRecords transferRecords = new TransferRecords();
  393 + transferRecords.setTagId(tagId);
  394 + transferRecords.setNfcUid(nfcUid);
  395 + transferRecords.setFromUid(histroy.getFromUid());
  396 + transferRecords.setToUid(history.getToUid());
  397 + transferRecords.setCreateTime(DateUtil.getCurrentTimeSecond());
  398 + transferRecordsMapper.insert(transferRecords);
  399 +
  400 + //更新identify_record
  401 + return identifyRecordsMapper.updateOwner(tagId, nfcUid, toUid);
  402 + }
  403 +
  404 + private void rebuildResult(ProductIdentifyResp result, String tagId, String nfcUid, Integer uid) {
  405 + boolean isOwner = queryIsOwner(tagId, nfcUid, uid);
  406 + result.setIfOwner(isOwner);
  407 + if(isOwner) {
  408 + return;
  409 + }
  410 +
  411 + //申请人申请状态
  412 + TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, uid);
  413 + if(null == history) {
  414 + result.setApplyStatus(OPERATE_TYPE_NO_APPLY);//未申请
  415 + }else {
  416 + result.setApplyStatus(history.getStatus());
  417 + }
  418 +
  419 + ProfileInfoRsp[] profileInfoArray = getUserProfilesByUids(Lists.newArrayList(String.valueOf(uid)));
  420 + if(ArrayUtils.isEmpty(profileInfoArray)) {
  421 + return;
  422 + }
  423 +
  424 + ProfileInfoRsp profileInfo = profileInfoArray[0];
  425 + IdentifyTrackResp track = new IdentifyTrackResp();
  426 + track.setUid(uid);
  427 + String mobileMask = MobileHelper.coverMobile2(profileInfo.getMobile());//隐位的手机号码--隐藏中间6位
  428 + track.setContent(StringUtils.isEmpty(profileInfo.getNickname()) ? mobileMask : profileInfo.getNickname());
  429 + String headIcon = profileInfo.getHead_ico();
  430 + if(DEFAULT_HEAD_IMG.equals(headIcon) || StringUtils.isBlank(headIcon)){//有货的默认头像
  431 + //ufo 用户的默认头像
  432 + 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}");
  433 + }
  434 + track.setHeadIcon(headIcon);
  435 + result.getTrackList().add(track);
  436 + }
  437 +
  438 + //交易轨迹
  439 + private List<IdentifyTrackResp> getTrackList(IdentifyRecord identifyRecord, String authGroup) {
  440 + List<IdentifyTrackResp> trackRespList = new ArrayList<>();
  441 + //1)第一部分:一条记录,商品鉴定结果
  442 + IdentifyTrackResp identifyTrack = new IdentifyTrackResp();
  443 + int authTime = identifyRecord.getAuthTime();
  444 + identifyTrack.setTime(authTime);
  445 + identifyTrack.setTimeStr(formatDate(authTime, "yyyy.MM.dd HH:mm:ss"));
  446 + identifyTrack.setContent(authGroup + "鉴定结果为\"真\"");
  447 + //鉴定中心,默认的展示头像
  448 + String authIco = configReader.getString("ufo.product.defaultAuthHeadIcon", "http://head.static.yhbimg.com/yhb-head/2018/12/28/14/01384244a3ca86fa5345df87c59317b81f.png?imageView2/{mode}/w/{width}/h/{height}");
  449 + identifyTrack.setHeadIcon(authIco);
  450 + trackRespList.add(identifyTrack);
  451 +
  452 + //2)第二部分:历史物权所有人,按时间顺序排列
  453 + List<TransferRecords> transferList = transferRecordsMapper.selectByTagIdAndNfcUid(identifyRecord.getTagId(), identifyRecord.getNfcUid());
  454 + List<String> ownerUidList = transferList.stream().map(TransferRecords::getToUid).collect(Collectors.toList());
  455 + List<String> allUidList = Lists.newArrayList();
  456 + allUidList.addAll(ownerUidList);
  457 +
  458 + //查询头像和手机号
  459 + Map<Integer, ProfileInfoRsp> profileMap = queryIcoAndMobile(allUidList);
  460 + List<IdentifyTrackResp> historyTrackList = buildTransferTrackList(profileMap, transferList);
  461 + trackRespList.addAll(historyTrackList);
  462 +
  463 + return trackRespList;
  464 + }
  465 +
  466 + private List<IdentifyTrackResp> buildTransferTrackList(Map<Integer, ProfileInfoRsp> profileMap, List<TransferRecords> transferList) {
  467 + List<IdentifyTrackResp> trackList = Lists.newArrayList();
  468 + Map<String, TransferRecords> transferMap = transferList.stream().collect(Collectors.toMap(TransferRecords::getToUid, t->t));
  469 + for(Entry<Integer, ProfileInfoRsp> entry : profileMap.entrySet()) {
  470 + IdentifyTrackResp item = new IdentifyTrackResp();
  471 + item.setUid(entry.getKey());
  472 + String mobileMask = MobileHelper.coverMobile2(entry.getValue().getMobile());//隐位的手机号码--隐藏中间6位
  473 + item.setContent(StringUtils.isEmpty(entry.getValue().getNickname()) ? mobileMask : entry.getValue().getNickname());
  474 + String headIcon = entry.getValue().getHead_ico();
  475 + if(DEFAULT_HEAD_IMG.equals(headIcon) || StringUtils.isBlank(headIcon)){//有货的默认头像
  476 + //ufo 用户的默认头像
  477 + 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}");
  478 + }
  479 + item.setHeadIcon(headIcon);
  480 + if(null != transferMap.get(String.valueOf(entry.getKey()))) {
  481 + Integer createTime = transferMap.get(String.valueOf(entry.getKey())).getCreateTime();
  482 + item.setTime(createTime);
  483 + item.setTimeStr(formatDate(createTime, "yyyy.MM.dd HH:mm:ss"));
  484 + }
  485 + trackList.add(item);
  486 + }
  487 +
  488 + Collections.sort(trackList, new Comparator<IdentifyTrackResp>(){//时间顺序排列
  489 + @Override
  490 + public int compare(IdentifyTrackResp o1, IdentifyTrackResp o2) {
  491 + Integer time1 = o1.getTime();
  492 + Integer time2 = o2.getTime();
  493 + return time1 -time2;
  494 + }
  495 + });
  496 +
  497 + return trackList;
  498 + }
  499 +
  500 + private Map<Integer,ProfileInfoRsp> queryIcoAndMobile(List<String> uidList) {
  501 + Map<Integer,ProfileInfoRsp> profileMap = Maps.newHashMap();
  502 + ProfileInfoRsp[] profileInfoArray = getUserProfilesByUids(uidList);
  503 + if(ArrayUtils.isEmpty(profileInfoArray)) {
  504 + return profileMap;
  505 + }
  506 +
  507 + for(int i=0; i< profileInfoArray.length; i++) {
  508 + ProfileInfoRsp item = profileInfoArray[i];
  509 + profileMap.put(item.getUid(), item);
  510 + }
  511 +
  512 + return profileMap;
  513 + }
  514 +
  515 + //获取订单详情
  516 + private ProductIdentifyResp getOrderDetail(BuyerOrder buyerOrder, IdentifyRecord identifyRecord, String tagId) {
  517 + ProductIdentifyResp result = new ProductIdentifyResp();
  518 +
  519 + //3)订单号获取 skup
  520 + BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(buyerOrder.getOrderCode());
  521 + Integer skup = buyerOrderGoods.getSkup();
  522 + //3)skup获取 productInfo
  523 + SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
  524 + result.setProductImageUrl(ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
  525 + result.setNfcUid(identifyRecord.getNfcUid());
  526 + result.setProductId(sellerOrderGoods.getProductId());
  527 + result.setProductName(sellerOrderGoods.getProductName());
  528 + result.setProductSize(sellerOrderGoods.getSizeName());
  529 +
  530 + //4)vedioFileUrl视频链接
  531 + String vedioFileUrl = getLiveVideoUrlByOrderCode(buyerOrder.getOrderCode());
  532 + result.setVedioFileUrl(vedioFileUrl);
  533 +
  534 + //查询区块链id
  535 + ProductChain productChain = queryTransactionIdByTagId(tagId);
  536 + result.setTransactionId(productChain == null ? null : productChain.getTransactionId());
  537 +
  538 + //组装查询结果
  539 + //鉴定者的信息、鉴定中心等
  540 + IdentifyRelation authGroupInfo = queryAuthGroupInfo(identifyRecord.getAuthUid());
  541 + String authGroup = authGroupInfo == null ? "UFO鉴定中心" : authGroupInfo.getGroupName();
  542 + result.setIdentifyPlat(authGroup);
  543 +// result.setIdentifyTime(timeStr);
  544 +
  545 + //查询鉴定师名字
  546 + OrderOperateRecord orderOperateRecord = orderOperateRecordMapper.selectByTypeAndOrderCode(OperateTypeEnum.OPERATE_TYPE_JUDGE_PASS.getCode(), buyerOrder.getOrderCode());
  547 + result.setIdentifyUserName(null == orderOperateRecord ? "" : orderOperateRecord.getUserName());
  548 +
  549 + return result;
  550 + }
222 551
223 /** 552 /**
224 * 查询区块链Id 553 * 查询区块链Id
@@ -332,6 +661,22 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -332,6 +661,22 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
332 ProductIdentifyResp identifyResp = clientCache.get(kb, ProductIdentifyResp.class); 661 ProductIdentifyResp identifyResp = clientCache.get(kb, ProductIdentifyResp.class);
333 return identifyResp; 662 return identifyResp;
334 } 663 }
  664 +
  665 + /**
  666 + * 批量查询用户基本信息--头像信息+手机号
  667 + * @return
  668 + */
  669 + private ProfileInfoRsp[] getUserProfilesByUids(List<String> uidList) {
  670 + try{
  671 + String uids = String.join(",", uidList);
  672 + String url = uicUrl + "/profile/getUserProfilesByUids";
  673 + logger.info("getUserProfilesByUids start call uic.getUserProfilesByUids uidList={}, url={} ", uidList, url);
  674 + return serviceCaller.post("uic.getUserProfilesByUids", url, uids, ProfileInfoRsp[].class,null).get();
  675 + }catch(Exception e){
  676 + logger.warn("getUserProfilesByUids call uic.getUserProfilesByUids error! uidList={}, e {}", uidList, e);
  677 + return null;
  678 + }
  679 + }
335 680
336 /** 681 /**
337 * 查询用户基本信息--头像信息(不要取此接口的手机号) 682 * 查询用户基本信息--头像信息(不要取此接口的手机号)
@@ -348,7 +693,6 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -348,7 +693,6 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
348 logger.warn("getUserBaseInfo call uic.getUserInfoByYohoUid error! uid={}, e {}", uid, e); 693 logger.warn("getUserBaseInfo call uic.getUserInfoByYohoUid error! uid={}, e {}", uid, e);
349 return null; 694 return null;
350 } 695 }
351 -  
352 } 696 }
353 697
354 /** 698 /**
@@ -367,7 +711,6 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -367,7 +711,6 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
367 logger.warn("getUserProfileInfo call uic.getProfileActionPost error! uid={}, e {}", uid, e); 711 logger.warn("getUserProfileInfo call uic.getProfileActionPost error! uid={}, e {}", uid, e);
368 return null; 712 return null;
369 } 713 }
370 -  
371 } 714 }
372 715
373 private String formatDate(Integer time, String pattern) { 716 private String formatDate(Integer time, String pattern) {
@@ -36,6 +36,9 @@ datasources: @@ -36,6 +36,9 @@ datasources:
36 - com.yohoufo.dal.product.PriceTrendHalfYearMapper 36 - com.yohoufo.dal.product.PriceTrendHalfYearMapper
37 - com.yohoufo.dal.product.PriceTrendDayMapper 37 - com.yohoufo.dal.product.PriceTrendDayMapper
38 - com.yohoufo.dal.product.ProductImportTranItemMapper 38 - com.yohoufo.dal.product.ProductImportTranItemMapper
  39 + - com.yohoufo.dal.product.TransferRecordsMapper
  40 + - com.yohoufo.dal.product.TransferRecordsHistoryMapper
  41 +
39 42
40 ufo_order: 43 ufo_order:
41 servers: 44 servers:
@@ -63,6 +63,16 @@ consumer: @@ -63,6 +63,16 @@ consumer:
63 - class: com.yohoufo.order.mq.consumer.ExpressInfoUpdateConsumer 63 - class: com.yohoufo.order.mq.consumer.ExpressInfoUpdateConsumer
64 topic: ufo.order.updateExpressInfo 64 topic: ufo.order.updateExpressInfo
65 65
  66 + - address: 192.168.102.45:5672
  67 + username: yoho
  68 + password: yoho
  69 + consumers:
  70 + #物权转移确认超时
  71 + - class: com.yohoufo.product.mq.consumer.ProductOwnerConfirmDelayMsgConsumer
  72 + topic: productOwner.updateTimeOut
  73 + delay:
  74 + interval: 4320
  75 +
66 # crm 76 # crm
67 - address: 192.168.102.211:5672 77 - address: 192.168.102.211:5672
68 consumers: 78 consumers:
@@ -36,6 +36,8 @@ datasources: @@ -36,6 +36,8 @@ datasources:
36 - com.yohoufo.dal.product.PriceTrendHalfYearMapper 36 - com.yohoufo.dal.product.PriceTrendHalfYearMapper
37 - com.yohoufo.dal.product.PriceTrendDayMapper 37 - com.yohoufo.dal.product.PriceTrendDayMapper
38 - com.yohoufo.dal.product.ProductImportTranItemMapper 38 - com.yohoufo.dal.product.ProductImportTranItemMapper
  39 + - com.yohoufo.dal.product.TransferRecordsMapper
  40 + - com.yohoufo.dal.product.TransferRecordsHistoryMapper
39 41
40 ufo_order: 42 ufo_order:
41 servers: 43 servers:
@@ -79,6 +79,16 @@ consumer: @@ -79,6 +79,16 @@ consumer:
79 #更新物流调拨信息 79 #更新物流调拨信息
80 - class: com.yohoufo.order.mq.consumer.ExpressInfoUpdateConsumer 80 - class: com.yohoufo.order.mq.consumer.ExpressInfoUpdateConsumer
81 topic: ufo.order.updateExpressInfo 81 topic: ufo.order.updateExpressInfo
  82 +
  83 + - address: ${rabbit_ufo}
  84 + username: ${rabbit_ufo_user}
  85 + password: ${rabbit_ufo_password}
  86 + consumers:
  87 + #物权转移确认超时
  88 + - class: com.yohoufo.product.mq.consumer.ProductOwnerConfirmDelayMsgConsumer
  89 + topic: productOwner.updateTimeOut
  90 + delay:
  91 + interval: 4320
82 92
83 93
84 # crm 94 # crm