Authored by mlge

鉴定结果查询接口

  1 +package com.yohoufo.common.utils;
  2 +
  3 +import org.apache.commons.lang3.StringUtils;
  4 +
  5 +/**
  6 + * 手机号码公共处理helper类
  7 + *
  8 + * @author yoho
  9 + *
  10 + */
  11 +public class MobileHelper {
  12 +
  13 + /**
  14 + * 覆盖手机号码中4位为*
  15 + *
  16 + * @param mobile
  17 + * @return
  18 + */
  19 + public static String coverMobile(String mobile) {
  20 + if (StringUtils.isEmpty(mobile)) {
  21 + return mobile;
  22 + }
  23 + // 11位国内手机号
  24 + if (mobile.matches("\\d{11}")) {
  25 + StringBuffer sb = new StringBuffer();
  26 + sb.append(mobile.substring(0, 3)).append("****").append(mobile.substring(7));
  27 + return sb.toString();
  28 + }
  29 +
  30 + // 国际号码
  31 + int index = mobile.indexOf("-");
  32 + if (0 < index && mobile.length() > index + 3) {
  33 + StringBuffer sb = new StringBuffer();
  34 + sb.append(mobile.substring(0, index + 4)).append("****");
  35 + if (mobile.length() > index + 7) {
  36 + sb.append(mobile.substring(index + 8));
  37 + }
  38 + return sb.toString();
  39 + }
  40 + return mobile;
  41 + }
  42 +
  43 + public static void main(String[] args) {
  44 + String a = "012-4";
  45 + System.out.println(coverMobile(a));
  46 + }
  47 +
  48 +}
@@ -25,5 +25,7 @@ public interface BuyerOrderGoodsMapper { @@ -25,5 +25,7 @@ public interface BuyerOrderGoodsMapper {
25 25
26 List<BuyerOrderGoods> selectBySkups(@Param("skups") Collection<Integer> skups); 26 List<BuyerOrderGoods> selectBySkups(@Param("skups") Collection<Integer> skups);
27 27
  28 + BuyerOrderGoods selectSkupByOrderCode(@Param("orderCode") long orderCode);
  29 +
28 30
29 } 31 }
  1 +package com.yohoufo.dal.product;
  2 +
  3 +import com.yohoufo.dal.product.model.Brand;
  4 +import com.yohoufo.dal.product.model.IdentifyRecord;
  5 +import org.apache.ibatis.annotations.Param;
  6 +
  7 +import java.util.List;
  8 +
  9 +public interface IdentifyRecordsMapper {
  10 + IdentifyRecord selectByTagAndNfcId(@Param("tagId") String tagId, @Param("nfcUid") String nfcUid);
  11 +
  12 +}
  1 +package com.yohoufo.dal.product.model;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.math.BigDecimal;
  6 +
  7 +@Data
  8 +public class IdentifyRecord {
  9 + private int id;
  10 + private String tagId;
  11 + private String nfcUid;
  12 + private int owner;
  13 + private int allowTransfer;//是否允许转移,0允许,1不允许
  14 + private Long orderCode;
  15 + private int authTime;
  16 + private int authUid;
  17 +}
@@ -138,4 +138,13 @@ @@ -138,4 +138,13 @@
138 goods_amount = #{goodsAmount,jdbcType=DECIMAL} 138 goods_amount = #{goodsAmount,jdbcType=DECIMAL}
139 where id = #{id,jdbcType=INTEGER} 139 where id = #{id,jdbcType=INTEGER}
140 </update> 140 </update>
  141 +
  142 + <select id="selectSkupByOrderCode" resultMap="BaseResultMap">
  143 + select
  144 + <include refid="Base_Column_List" />
  145 + from buyer_order_goods
  146 + where order_code = #{orderCode,jdbcType=BIGINT}
  147 + limit 1
  148 + </select>
  149 +
141 </mapper> 150 </mapper>
@@ -19,10 +19,10 @@ @@ -19,10 +19,10 @@
19 <result column="product_id" property="productId" jdbcType="INTEGER" /> 19 <result column="product_id" property="productId" jdbcType="INTEGER" />
20 </resultMap> 20 </resultMap>
21 <sql id="Base_Column_List" > 21 <sql id="Base_Column_List" >
22 - id, order_code, skup, seller_order_code, depot_no, start_time, end_time, persistId, 22 + id, order_code, skup, seller_order_code, depot_no, start_time, end_time, persist_id,
23 vedio_file_url, create_time, update_time, status, storage_id, goods_id, product_id 23 vedio_file_url, create_time, update_time, status, storage_id, goods_id, product_id
24 </sql> 24 </sql>
25 - <select id="selectByOrderCodes" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 25 + <select id="selectByOrderCodes" resultMap="BaseResultMap" parameterType="java.lang.Long" >
26 select 26 select
27 <include refid="Base_Column_List" /> 27 <include refid="Base_Column_List" />
28 from qiniu_live_record 28 from qiniu_live_record
  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.IdentifyRecordsMapper">
  4 + <resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.IdentifyRecord">
  5 + <id column="id" jdbcType="INTEGER" property="id" />
  6 + <result column="tag_id" jdbcType="VARCHAR" property="tagId" />
  7 + <result column="nfc_uid" jdbcType="VARCHAR" property="nfcUid" />
  8 + <result column="owner" jdbcType="INTEGER" property="owner" />
  9 + <result column="allow_transfer" jdbcType="INTEGER" property="allowTransfer" />
  10 + <result column="order_code" jdbcType="BIGINT" property="orderCode" />
  11 + <result column="auth_time" jdbcType="INTEGER" property="authTime" />
  12 + <result column="auth_uid" jdbcType="INTEGER" property="authUid" />
  13 + </resultMap>
  14 + <sql id="Base_Column_List">
  15 + id, tag_id, nfc_uid, owner,allow_transfer, order_code, auth_time, auth_uid
  16 + </sql>
  17 + <select id="selectByTagAndNfcId" resultMap="BaseResultMap">
  18 + select <include refid="Base_Column_List"/>
  19 + from identify_records
  20 + where tag_id = #{tagId,jdbcType=VARCHAR}
  21 + and nfc_uid = #{nfcUid,jdbcType=VARCHAR}
  22 + </select>
  23 +</mapper>
  1 +package com.yohoufo.product.controller;
  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;
  20 +import org.slf4j.LoggerFactory;
  21 +import org.springframework.beans.factory.annotation.Autowired;
  22 +import org.springframework.web.bind.annotation.RequestMapping;
  23 +import org.springframework.web.bind.annotation.RequestParam;
  24 +import org.springframework.web.bind.annotation.RestController;
  25 +
  26 +import java.util.List;
  27 +import java.util.Map;
  28 +
  29 +@RestController
  30 +public class ProductIdentifyController {
  31 +
  32 + private static final Logger logger = LoggerFactory.getLogger(ProductIdentifyController.class);
  33 +
  34 +
  35 + @Autowired
  36 + private ProductIdentifyService identifyService;
  37 +
  38 +
  39 + @ApiOperation(name = "ufo.product.queryIdentifyInfo", desc="UFO商品鉴定信息查询接口")
  40 + @RequestMapping(params = "method=ufo.product.queryIdentifyInfo")
  41 + public ApiResponse queryIdentifyInfo(@RequestParam(value = "tagId") String tagId,
  42 + @RequestParam(value = "nfcUid") String nfcUid) throws GatewayException {
  43 + try{
  44 + ProductIdentifyResp info = identifyService.queryIdentifyInfo(tagId, nfcUid);
  45 + return new ApiResponse.ApiResponseBuilder().code(200).data(info).build();
  46 + }catch (Exception e){
  47 + logger.warn("queryIdentifyInfo error! tagId={}, nfcUid={}, ", tagId, nfcUid);
  48 + if( e instanceof GatewayException){
  49 + throw e;
  50 + }
  51 + return new ApiResponse.ApiResponseBuilder().code(402).message("查询失败,请稍后再试!").build();
  52 +
  53 + }
  54 +
  55 + }
  56 +
  57 + @ApiOperation(name = "ufo.product.getShareIdentifyInfo", desc="UFO商品鉴定信息查询接口")
  58 + @RequestMapping(params = "method=ufo.product.getShareIdentifyInfo")
  59 + public ApiResponse getShareIdentifyInfo(
  60 + @RequestParam(value = "nfcUid") String nfcUid,
  61 + @RequestParam(value = "tagId") String tagId) {
  62 + try{
  63 + IdentifyShareInfoResp resp = identifyService.getShareIdentifyInfo( tagId, nfcUid);
  64 + return new ApiResponse.ApiResponseBuilder().code(200).data(resp).build();
  65 + }catch (Exception e){
  66 + logger.warn("queryIdentifyInfo error! uid={}, tagId={}, ", tagId);
  67 + if( e instanceof ServiceException){
  68 + throw e;
  69 + }
  70 + return new ApiResponse.ApiResponseBuilder().code(401).message("查询失败!").build();
  71 + }
  72 + }
  73 +}
  1 +package com.yohoufo.product.response;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.util.List;
  6 +
  7 +@Data
  8 +public class IdentifyShareInfoResp {
  9 + private String headIcon;
  10 + private String productImageUrl;
  11 + private Integer productId;
  12 + private String productName;
  13 + private String allowTransfer;
  14 +}
  1 +package com.yohoufo.product.response;
  2 +
  3 +import lombok.Data;
  4 +
  5 +@Data
  6 +public class IdentifyTrackResp {
  7 + private Integer uid;
  8 + private String headIcon;
  9 + private String content;
  10 + private String timeStr;
  11 + private Integer time;
  12 + private String mobile;
  13 +}
  1 +package com.yohoufo.product.response;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.util.List;
  6 +
  7 +@Data
  8 +public class ProductIdentifyResp {
  9 + private String productImageUrl;
  10 + private String vedioFileUrl;
  11 + private String nfcUid;
  12 + private Integer productId;
  13 + private String productName;
  14 + private String productSize;
  15 + private String identifyTime;
  16 + private String identifyPlat;
  17 + private List<IdentifyTrackResp> trackList;
  18 +
  19 +}
  1 +package com.yohoufo.product.service;
  2 +
  3 +
  4 +
  5 +import com.yohoufo.common.exception.GatewayException;
  6 +import com.yohoufo.product.response.IdentifyShareInfoResp;
  7 +import com.yohoufo.product.response.ProductIdentifyResp;
  8 +
  9 +import java.util.List;
  10 +
  11 +public interface ProductIdentifyService {
  12 +
  13 +
  14 + ProductIdentifyResp queryIdentifyInfo(String tagId, String nfcUid) throws GatewayException;
  15 +
  16 + IdentifyShareInfoResp getShareIdentifyInfo( String tagId, String nfcUid);
  17 +}
  1 +package com.yohoufo.product.service.impl;
  2 +
  3 +
  4 +import com.alibaba.fastjson.JSON;
  5 +import com.alibaba.fastjson.JSONObject;
  6 +import com.yoho.core.config.ConfigReader;
  7 +import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
  8 +import com.yoho.core.rest.client.ServiceCaller;
  9 +import com.yoho.error.ServiceError;
  10 +import com.yoho.error.exception.ServiceException;
  11 +import com.yoho.service.model.response.ProfileInfoRsp;
  12 +import com.yohoufo.common.cache.CacheClient;
  13 +import com.yohoufo.common.exception.GatewayException;
  14 +import com.yohoufo.common.utils.DateUtil;
  15 +import com.yohoufo.common.utils.MobileHelper;
  16 +import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
  17 +import com.yohoufo.dal.order.BuyerOrderMapper;
  18 +import com.yohoufo.dal.order.QiniuLiveRecordMapper;
  19 +import com.yohoufo.dal.order.SellerOrderGoodsMapper;
  20 +import com.yohoufo.dal.order.model.BuyerOrder;
  21 +import com.yohoufo.dal.order.model.BuyerOrderGoods;
  22 +import com.yohoufo.dal.order.model.QiniuLiveRecord;
  23 +import com.yohoufo.dal.order.model.SellerOrderGoods;
  24 +import com.yohoufo.dal.product.IdentifyRecordsMapper;
  25 +import com.yohoufo.dal.product.model.IdentifyRecord;
  26 +import com.yohoufo.product.response.IdentifyShareInfoResp;
  27 +import com.yohoufo.product.response.IdentifyTrackResp;
  28 +import com.yohoufo.product.response.ProductIdentifyResp;
  29 +import com.yohoufo.product.service.ProductIdentifyService;
  30 +import org.apache.commons.lang3.StringUtils;
  31 +import org.slf4j.Logger;
  32 +import org.slf4j.LoggerFactory;
  33 +import org.springframework.beans.factory.annotation.Autowired;
  34 +import org.springframework.stereotype.Service;
  35 +
  36 +import java.text.SimpleDateFormat;
  37 +import java.util.*;
  38 +import java.util.stream.Collectors;
  39 +
  40 +@Service
  41 +public class ProductIdentifyServiceImpl implements ProductIdentifyService{
  42 +
  43 + private final Logger logger = LoggerFactory.getLogger(ProductIdentifyServiceImpl.class);
  44 +
  45 + public static final String LIVE_VEDIO_DOMAIN = "http://yhb-img01.qiniudn.com/";
  46 +
  47 + @Autowired
  48 + private IdentifyRecordsMapper identifyRecordsMapper;
  49 +
  50 + @Autowired
  51 + private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
  52 +
  53 + @Autowired
  54 + private SellerOrderGoodsMapper sellerOrderGoodsMapper;
  55 +
  56 + @Autowired
  57 + private QiniuLiveRecordMapper qiniuLiveRecordMapper;
  58 +
  59 + @Autowired
  60 + private BuyerOrderMapper buyerOrderMapper;
  61 +
  62 + @Autowired
  63 + private ServiceCaller serviceCaller;
  64 +
  65 + @Autowired
  66 + private CacheClient clientCache;
  67 +
  68 + @Autowired
  69 + private ConfigReader configReader;
  70 +
  71 + /**
  72 + * 鉴定结果查询接口
  73 + * @param tagId
  74 + * @param nfcUid
  75 + * @return
  76 + */
  77 + @Override
  78 + public ProductIdentifyResp queryIdentifyInfo(String tagId, String nfcUid) throws GatewayException {
  79 + logger.info("enter queryIdentifyInfo, tagId = {}, nfcUid={}", tagId, nfcUid);
  80 + //返回结果可能在缓存中
  81 + ProductIdentifyResp result = getIdentifyFromCache(tagId, nfcUid);
  82 + if(result != null ){
  83 + logger.info("queryIdentifyInfo get result from cache success! tagId = {}, nfcUid={},result={} ", tagId, nfcUid, result );
  84 + return result;
  85 + }
  86 +
  87 + result = new ProductIdentifyResp();
  88 + //鉴定 记录--先从缓存去取
  89 + IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
  90 + if(identifyRecord == null || identifyRecord.getOrderCode() == null){
  91 + throw new GatewayException(402, "鉴定信息不存在");
  92 + }
  93 + //根据鉴定记录 获取订单号
  94 + Long orderCode = identifyRecord.getOrderCode();
  95 + //订单号 获取订单详细信息
  96 + BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
  97 + if(buyerOrder == null){
  98 + throw new GatewayException(403, "订单不存在");
  99 + }
  100 + Integer buyerUid = buyerOrder.getUid();//买家
  101 + Integer sellerUid = buyerOrder.getSellerUid();//卖家
  102 + Integer orderStatus = buyerOrder.getStatus();//5--订单已经完成
  103 +
  104 + //订单号获取 skup
  105 + BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectSkupByOrderCode(orderCode);
  106 + Integer skup = buyerOrderGoods.getSkup();
  107 + //skup获取 productInfo
  108 + SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
  109 + result.setProductImageUrl(sellerOrderGoods.getImageUrl());
  110 + result.setNfcUid(identifyRecord.getNfcUid());
  111 + result.setProductId(sellerOrderGoods.getProductId());
  112 + result.setProductName(sellerOrderGoods.getProductName());
  113 + result.setProductSize(sellerOrderGoods.getSizeName());
  114 +
  115 + //vedioFileUrl视频链接
  116 + QiniuLiveRecord qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(orderCode);
  117 + if (qiniuLiveRecords != null && StringUtils.isNotBlank(qiniuLiveRecords.getVedioFileUrl())) {
  118 + result.setVedioFileUrl(LIVE_VEDIO_DOMAIN + qiniuLiveRecords.getVedioFileUrl());
  119 + }
  120 +
  121 + //鉴定时间
  122 + int authTime = identifyRecord.getAuthTime();
  123 + String timeStr = formatDate(authTime, "yyyy.MM.dd HH:mm:ss");
  124 + result.setIdentifyTime(timeStr);
  125 + String authName = "UFO鉴定中心";
  126 + result.setIdentifyPlat(authName);
  127 +
  128 + //交易轨迹---最多三条
  129 + List<IdentifyTrackResp> trackRespList = new ArrayList<>();
  130 + result.setTrackList(trackRespList);
  131 + //1)鉴定结果
  132 + IdentifyTrackResp identifyTrack = new IdentifyTrackResp();
  133 + identifyTrack.setTime(authTime);
  134 + identifyTrack.setTimeStr(timeStr);
  135 + identifyTrack.setContent( authName + "鉴定结果为\"真\"");
  136 + String auth_inco = configReader.getString("ufo.product.authIcon", "XXXXXX");
  137 + identifyTrack.setHeadIcon(auth_inco);
  138 + trackRespList.add(identifyTrack);
  139 +
  140 +
  141 + List<Integer> uidsList = Arrays.asList(buyerUid, sellerUid);
  142 + Map<Integer, ProfileInfoRsp> profileMap = getUserProfileInfo(uidsList);
  143 + ProfileInfoRsp buyerInfo = profileMap.get(buyerUid);
  144 +
  145 + //订单轨迹
  146 + String mobile = MobileHelper.coverMobile(buyerInfo.getMobile());//隐位的手机号码
  147 + String headIcon = buyerInfo.getHead_ico();//头像
  148 + //订单更新时间
  149 + if(orderStatus != null && orderStatus.intValue() == 5){//订单已完成
  150 + IdentifyTrackResp updateOrderTrack = new IdentifyTrackResp();
  151 + timeStr = formatDate(buyerOrder.getUpdateTime(), "yyyy.MM.dd HH:mm:ss");
  152 + updateOrderTrack.setTime(buyerOrder.getUpdateTime());
  153 + updateOrderTrack.setTimeStr(timeStr);
  154 + updateOrderTrack.setContent("用户" + mobile + "成为商品新主人");
  155 + updateOrderTrack.setHeadIcon(headIcon);
  156 + updateOrderTrack.setMobile(mobile);
  157 +
  158 + trackRespList.add(updateOrderTrack);
  159 + }
  160 + //创建订单的时间
  161 + IdentifyTrackResp createOrderTrack = new IdentifyTrackResp();
  162 + createOrderTrack.setUid(buyerUid);
  163 + createOrderTrack.setHeadIcon(headIcon);
  164 + createOrderTrack.setContent("用户"+ mobile + "在UFO平台下单购买");
  165 + createOrderTrack.setTime(buyerOrder.getCreateTime());
  166 + timeStr = formatDate(buyerOrder.getCreateTime(),"yyyy.MM.dd HH:mm:ss");
  167 + createOrderTrack.setTimeStr(timeStr);
  168 + createOrderTrack.setMobile(mobile);
  169 + trackRespList.add(createOrderTrack);
  170 +
  171 + Collections.sort(trackRespList, new Comparator<IdentifyTrackResp>(){//时间倒序排列
  172 + @Override
  173 + public int compare(IdentifyTrackResp o1, IdentifyTrackResp o2) {
  174 + Integer time1 = o1.getTime();
  175 + Integer time2 = o2.getTime();
  176 + return time2 -time1;
  177 + }
  178 + });
  179 +
  180 + //设置缓存--可能会有延时,不影响的
  181 + setIdentifyCache(tagId, nfcUid, result);
  182 + logger.info("queryIdentifyInfo success!, tagId = {}, nfcUid={}, result ={}", tagId, nfcUid, result );
  183 + return result;
  184 + }
  185 +
  186 +
  187 + private IdentifyRecord queryIdentifyRecord(String tagId, String nfcUid) {
  188 +
  189 + RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyRecord:").
  190 + appendVar(tagId).appendVar(":").appendVar(nfcUid);
  191 + IdentifyRecord result = clientCache.get(kb, IdentifyRecord.class);
  192 + if( result != null){
  193 + logger.info("queryIdentifyRecord from cache success!");
  194 + return result;
  195 + }
  196 +
  197 + result = identifyRecordsMapper.selectByTagAndNfcId(tagId, nfcUid);
  198 +
  199 + if(result != null){
  200 + clientCache.set(kb.getKey(), 5 * 60, result );
  201 + }
  202 + return result;
  203 + }
  204 +
  205 + /**
  206 + *
  207 + * @param tagId
  208 + * @param nfcUid
  209 + * @param result
  210 + */
  211 + private void setIdentifyCache(String tagId, String nfcUid, ProductIdentifyResp result) {
  212 +
  213 + RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyInfo:").
  214 + appendVar(tagId).appendVar(":").appendVar(nfcUid);
  215 + clientCache.set(kb.getKey(), 5 * 60, result );
  216 + }
  217 +
  218 + private ProductIdentifyResp getIdentifyFromCache(String tagId, String nfcUid) {
  219 + RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyInfo:").
  220 + appendVar(tagId).appendVar(":").appendVar(nfcUid);
  221 + ProductIdentifyResp identifyResp = clientCache.get(kb.getKey(), ProductIdentifyResp.class);
  222 + return identifyResp;
  223 + }
  224 +
  225 + /**
  226 + * 鉴定结果分享
  227 + * @param uid
  228 + * @param tagId
  229 + * @return
  230 + */
  231 + @Override
  232 + public IdentifyShareInfoResp getShareIdentifyInfo( String tagId, String nfcUid) {
  233 + logger.info("enter getShareIdentifyInfo , tagId={}, nfcUid={}", tagId, nfcUid);
  234 + IdentifyShareInfoResp result = new IdentifyShareInfoResp();
  235 +
  236 + IdentifyRecord identifyRecord = identifyRecordsMapper.selectByTagAndNfcId(tagId, nfcUid);
  237 + if(identifyRecord == null){
  238 + throw new ServiceException(ServiceError.ORDER_NULL);
  239 + }
  240 +
  241 + Long orderCode = identifyRecord.getOrderCode();//订单号
  242 +
  243 + //订单号获取 skup
  244 + BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectSkupByOrderCode(orderCode);
  245 + Integer skup = buyerOrderGoods.getSkup();
  246 + //skup获取 productInfo
  247 + SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
  248 + result.setProductImageUrl(sellerOrderGoods.getImageUrl());
  249 + result.setProductId(sellerOrderGoods.getProductId());
  250 + result.setProductName(sellerOrderGoods.getProductName());
  251 + result.setAllowTransfer(identifyRecord.getAllowTransfer() == 0 ? "Y" : "N");
  252 +
  253 + //买家的头像
  254 + Integer buyerUid = buyerOrderGoods.getUid();
  255 + List<Integer> uidsList = Arrays.asList(buyerUid);
  256 + Map<Integer, ProfileInfoRsp> profileMap = getUserProfileInfo(uidsList);
  257 + ProfileInfoRsp profile = profileMap.get(buyerUid);
  258 + result.setHeadIcon(profile.getHead_ico());
  259 + return result;
  260 + }
  261 +
  262 + private Map<Integer,ProfileInfoRsp> getUserProfileInfo(List<Integer> uidsList) {
  263 + Map<Integer,ProfileInfoRsp > result = new HashMap<>();
  264 + if(uidsList == null || uidsList.size() == 0){
  265 + return result;
  266 + }
  267 + StringBuilder sb = new StringBuilder();
  268 + for(Integer uid : uidsList ){
  269 + if(uid != null && uid > 0){
  270 + sb.append(uid).append(",");
  271 + }
  272 + }
  273 + String s = sb.toString();
  274 + if(s.length() == 0){
  275 + return result;
  276 + }
  277 +
  278 + String uids = s.substring(0, s.length() - 1);
  279 + List<JSONObject> rsp = serviceCaller.call("uic.getUserProfilesByUids", uids, List.class);
  280 + //必须要强转下
  281 + List<ProfileInfoRsp> resultList = rsp.stream().map(profileInfoRsp -> JSONObject.parseObject(JSONObject.toJSONString(profileInfoRsp),ProfileInfoRsp.class))
  282 + .collect(Collectors.toList());
  283 +
  284 + result = resultList.stream().collect(Collectors.toMap(ProfileInfoRsp :: getUid, (ProfileInfoRsp obj) -> obj));
  285 + return result;
  286 +
  287 + }
  288 +
  289 + private String formatDate(Integer time, String pattern) {
  290 +
  291 + SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
  292 + return dateFormat.format(new Date((long) time * 1000));
  293 + }
  294 +
  295 +
  296 +}
@@ -28,6 +28,7 @@ datasources: @@ -28,6 +28,7 @@ datasources:
28 - com.yohoufo.dal.product.ProductSortMapper 28 - com.yohoufo.dal.product.ProductSortMapper
29 - com.yohoufo.dal.product.SearchWordMapper 29 - com.yohoufo.dal.product.SearchWordMapper
30 - com.yohoufo.dal.product.SaleCategoryMapper 30 - com.yohoufo.dal.product.SaleCategoryMapper
  31 + - com.yohoufo.dal.product.IdentifyRecordsMapper
31 32
32 ufo_order: 33 ufo_order:
33 servers: 34 servers:
@@ -28,6 +28,7 @@ datasources: @@ -28,6 +28,7 @@ datasources:
28 - com.yohoufo.dal.product.ProductSortMapper 28 - com.yohoufo.dal.product.ProductSortMapper
29 - com.yohoufo.dal.product.SearchWordMapper 29 - com.yohoufo.dal.product.SearchWordMapper
30 - com.yohoufo.dal.product.SaleCategoryMapper 30 - com.yohoufo.dal.product.SaleCategoryMapper
  31 + - com.yohoufo.dal.product.IdentifyRecordsMapper
31 32
32 ufo_order: 33 ufo_order:
33 servers: 34 servers: