Authored by caoyan

订单查询

1 package com.yoho.ufo.dal; 1 package com.yoho.ufo.dal;
2 2
3 -import com.yoho.ufo.dal.model.IdentifyRecords;  
4 -import com.yoho.ufo.model.coupon.UserCoupon;  
5 -import com.yohobuy.ufo.coupon.req.UserCouponQueryReq; 3 +import java.util.List;
  4 +
6 import org.apache.ibatis.annotations.Param; 5 import org.apache.ibatis.annotations.Param;
7 6
8 -import java.util.List; 7 +import com.yoho.ufo.dal.model.IdentifyRecords;
9 8
10 /** 9 /**
11 */ 10 */
12 public interface IdentifyRecordsMapper { 11 public interface IdentifyRecordsMapper {
13 12
14 int insertRecord(IdentifyRecords records); 13 int insertRecord(IdentifyRecords records);
  14 +
  15 + List<IdentifyRecords> selectByBatchOrderCode(@Param("orderCodeList") List<String> orderCode);
15 } 16 }
@@ -24,4 +24,12 @@ @@ -24,4 +24,12 @@
24 (#{tagId,jdbcType=VARCHAR },#{nfcUid,jdbcType=VARCHAR },#{owner,jdbcType=INTEGER },#{allowTransfer,jdbcType=INTEGER },#{orderCode,jdbcType=BIGINT }, 24 (#{tagId,jdbcType=VARCHAR },#{nfcUid,jdbcType=VARCHAR },#{owner,jdbcType=INTEGER },#{allowTransfer,jdbcType=INTEGER },#{orderCode,jdbcType=BIGINT },
25 #{authTime,jdbcType=INTEGER },#{authUid,jdbcType=VARCHAR },#{authName,jdbcType=VARCHAR }) 25 #{authTime,jdbcType=INTEGER },#{authUid,jdbcType=VARCHAR },#{authName,jdbcType=VARCHAR })
26 </insert> 26 </insert>
  27 +
  28 + <select id="selectByBatchOrderCode" resultMap="BaseResultMap">
  29 + select <include refid="Base_Column_List" />
  30 + from identify_records where order_code in
  31 + <foreach item="orderCode" collection="orderCodeList" open="(" separator="," close=")">
  32 + #{orderCode}
  33 + </foreach>
  34 + </select>
27 </mapper> 35 </mapper>
1 package com.yoho.ufo.order.service.impl; 1 package com.yoho.ufo.order.service.impl;
2 2
3 import java.math.BigDecimal; 3 import java.math.BigDecimal;
4 -import java.util.*; 4 +import java.util.ArrayList;
  5 +import java.util.Collections;
  6 +import java.util.HashSet;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +import java.util.Set;
5 import java.util.concurrent.TimeUnit; 10 import java.util.concurrent.TimeUnit;
6 import java.util.stream.Collectors; 11 import java.util.stream.Collectors;
7 12
8 -import com.yoho.order.dal.*;  
9 -import com.yoho.order.model.*;  
10 import org.apache.commons.collections.CollectionUtils; 13 import org.apache.commons.collections.CollectionUtils;
11 import org.apache.commons.lang3.StringUtils; 14 import org.apache.commons.lang3.StringUtils;
12 import org.elasticsearch.common.collect.Lists; 15 import org.elasticsearch.common.collect.Lists;
@@ -22,8 +25,38 @@ import com.alibaba.fastjson.JSONObject; @@ -22,8 +25,38 @@ import com.alibaba.fastjson.JSONObject;
22 import com.yoho.core.common.utils.DateUtil; 25 import com.yoho.core.common.utils.DateUtil;
23 import com.yoho.core.rest.client.ServiceCaller; 26 import com.yoho.core.rest.client.ServiceCaller;
24 import com.yoho.error.exception.ServiceException; 27 import com.yoho.error.exception.ServiceException;
  28 +import com.yoho.order.dal.AppraiseAddressMapper;
  29 +import com.yoho.order.dal.AreaMapper;
  30 +import com.yoho.order.dal.BuyerOrderGoodsMapper;
  31 +import com.yoho.order.dal.BuyerOrderMapper;
  32 +import com.yoho.order.dal.BuyerOrderMetaMapper;
  33 +import com.yoho.order.dal.ExpressCompanyMapper;
  34 +import com.yoho.order.dal.ExpressInfoMapper;
  35 +import com.yoho.order.dal.ExpressRecordMapper;
  36 +import com.yoho.order.dal.OrderOperateRecordMapper;
  37 +import com.yoho.order.dal.OrdersPayMapper;
  38 +import com.yoho.order.dal.QiniuLiveRecordMapper;
  39 +import com.yoho.order.dal.SellerOrderGoodsMapper;
  40 +import com.yoho.order.dal.SellerOrderMapper;
  41 +import com.yoho.order.dal.SellerOrderMetaMapper;
  42 +import com.yoho.order.model.Area;
  43 +import com.yoho.order.model.BuyerOrder;
  44 +import com.yoho.order.model.BuyerOrderGoods;
  45 +import com.yoho.order.model.BuyerOrderMeta;
  46 +import com.yoho.order.model.BuyerOrderReq;
  47 +import com.yoho.order.model.ExpressCompany;
  48 +import com.yoho.order.model.ExpressInfo;
  49 +import com.yoho.order.model.ExpressRecord;
  50 +import com.yoho.order.model.OrderOperateRecord;
  51 +import com.yoho.order.model.OrdersPay;
  52 +import com.yoho.order.model.QiniuLiveRecord;
  53 +import com.yoho.order.model.SellerOrder;
  54 +import com.yoho.order.model.SellerOrderGoods;
  55 +import com.yoho.order.model.SellerOrderMeta;
25 import com.yoho.service.model.order.request.OrderRequest; 56 import com.yoho.service.model.order.request.OrderRequest;
  57 +import com.yoho.ufo.dal.IdentifyRecordsMapper;
26 import com.yoho.ufo.dal.ProductMapper; 58 import com.yoho.ufo.dal.ProductMapper;
  59 +import com.yoho.ufo.dal.model.IdentifyRecords;
27 import com.yoho.ufo.dal.model.Product; 60 import com.yoho.ufo.dal.model.Product;
28 import com.yoho.ufo.order.constant.Constant; 61 import com.yoho.ufo.order.constant.Constant;
29 import com.yoho.ufo.order.service.IBuyerOrderService; 62 import com.yoho.ufo.order.service.IBuyerOrderService;
@@ -95,6 +128,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -95,6 +128,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
95 @Autowired 128 @Autowired
96 private QiniuLiveRecordMapper qiniuLiveRecordMapper; 129 private QiniuLiveRecordMapper qiniuLiveRecordMapper;
97 130
  131 + @Autowired
  132 + private IdentifyRecordsMapper identifyRecordsMapper;
  133 +
98 private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address"; 134 private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address";
99 135
100 private static final String SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS = "back_delivery_address"; 136 private static final String SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS = "back_delivery_address";
@@ -284,8 +320,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -284,8 +320,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
284 List<ExpressRecord> expressRecordList =expressRecordMapper.selectByOrderCodeListAndType(buyerOrderCodeList, Lists.newArrayList(EXPRESS_TYPE_SELLER_TO_JUDGE)); 320 List<ExpressRecord> expressRecordList =expressRecordMapper.selectByOrderCodeListAndType(buyerOrderCodeList, Lists.newArrayList(EXPRESS_TYPE_SELLER_TO_JUDGE));
285 Map<String, ExpressRecord> expressRecordMap = expressRecordList.stream().collect(Collectors.toMap(ExpressRecord::getOrderCode, e->e)); 321 Map<String, ExpressRecord> expressRecordMap = expressRecordList.stream().collect(Collectors.toMap(ExpressRecord::getOrderCode, e->e));
286 322
  323 + //查询identify_records
  324 + List<IdentifyRecords> identifyRecordList = identifyRecordsMapper.selectByBatchOrderCode(buyerOrderCodeList);
  325 + Map<String, List<IdentifyRecords>> identifyMap = identifyRecordList.stream().collect(Collectors.groupingBy(IdentifyRecords::getOrderCode));
287 326
288 - List<BuyerOrderResp> respList = convertToRespForQuery(orderList, buyerGoodsMap, sellerGoodsMap,expressRecordMap, buyerOrderMetaMap); 327 + List<BuyerOrderResp> respList = convertToRespForQuery(orderList, buyerGoodsMap, sellerGoodsMap,expressRecordMap, buyerOrderMetaMap, identifyMap);
289 328
290 PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>(); 329 PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
291 result.setPage(1); 330 result.setPage(1);
@@ -836,7 +875,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -836,7 +875,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
836 875
837 private List<BuyerOrderResp> convertToRespForQuery(List<BuyerOrder> orderList, Map<String, BuyerOrderGoods> buyerGoodsMap, 876 private List<BuyerOrderResp> convertToRespForQuery(List<BuyerOrder> orderList, Map<String, BuyerOrderGoods> buyerGoodsMap,
838 Map<Integer, SellerOrderGoods> sellerGoodsMap, Map<String, ExpressRecord> expressInfoMap, 877 Map<Integer, SellerOrderGoods> sellerGoodsMap, Map<String, ExpressRecord> expressInfoMap,
839 - Map<String, BuyerOrderMeta> buyerOrderMetaMap){ 878 + Map<String, BuyerOrderMeta> buyerOrderMetaMap, Map<String, List<IdentifyRecords>> identifyMap){
840 List<BuyerOrderResp> respList = Lists.newArrayList(); 879 List<BuyerOrderResp> respList = Lists.newArrayList();
841 for(BuyerOrder item : orderList) { 880 for(BuyerOrder item : orderList) {
842 if(null == buyerGoodsMap.get(item.getOrderCode())) { 881 if(null == buyerGoodsMap.get(item.getOrderCode())) {
@@ -857,6 +896,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -857,6 +896,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
857 resp.setReceiveMobile(metaValue.getString("mobile")); 896 resp.setReceiveMobile(metaValue.getString("mobile"));
858 String receiveAddressCode = metaValue.getString("areaCode"); 897 String receiveAddressCode = metaValue.getString("areaCode");
859 resp.setReceiveAddress(getAddressInfo(receiveAddressCode)); 898 resp.setReceiveAddress(getAddressInfo(receiveAddressCode));
  899 + resp.setNfcStatus(CollectionUtils.isEmpty(identifyMap.get(item.getOrderCode())) ? 0 : 1);//0:未写入,1:已写入
860 900
861 respList.add(resp); 901 respList.add(resp);
862 } 902 }