Authored by TANLING

增加物流信息

@@ -26,6 +26,9 @@ public interface ExpressRecordMapper { @@ -26,6 +26,9 @@ public interface ExpressRecordMapper {
26 */ 26 */
27 ExpressRecord selectByOrderCodeAndExpressType( @Param("orderCode") Long orderCode, @Param("expressType") Integer expressType); 27 ExpressRecord selectByOrderCodeAndExpressType( @Param("orderCode") Long orderCode, @Param("expressType") Integer expressType);
28 28
  29 +
  30 + List<ExpressRecord> selectByOrderCodesAndExpressType( @Param("orderCodeList") List<Long> orderCodeList, @Param("expressType") Integer expressType);
  31 +
29 /** 32 /**
30 * 根据物流单号和物流类型查询快递信息 33 * 根据物流单号和物流类型查询快递信息
31 * @param wayBillCode 34 * @param wayBillCode
@@ -40,6 +40,17 @@ @@ -40,6 +40,17 @@
40 where order_code = #{orderCode} and express_type = #{expressType} 40 where order_code = #{orderCode} and express_type = #{expressType}
41 limit 1 41 limit 1
42 </select> 42 </select>
  43 +
  44 +
  45 + <select id="selectByOrderCodesAndExpressType" resultMap="BaseResultMap">
  46 + SELECT <include refid="Base_Column_List" />
  47 + FROM express_record
  48 + where order_code in
  49 + <foreach collection="orderCodeList" item="orderCode" open="(" close=")" separator=",">
  50 + #{orderCode, jdbcType=BIGINT}
  51 + </foreach>
  52 + and express_type = #{expressType}
  53 + </select>
43 54
44 <select id="selectByWayBillCodeAndExpressType" resultMap="BaseResultMap"> 55 <select id="selectByWayBillCodeAndExpressType" resultMap="BaseResultMap">
45 SELECT <include refid="Base_Column_List" /> 56 SELECT <include refid="Base_Column_List" />
@@ -6,10 +6,7 @@ import com.google.common.collect.Lists; @@ -6,10 +6,7 @@ import com.google.common.collect.Lists;
6 import com.yohobuy.ufo.model.ProductInfo; 6 import com.yohobuy.ufo.model.ProductInfo;
7 import com.yohobuy.ufo.model.enums.StorageCheckEnum; 7 import com.yohobuy.ufo.model.enums.StorageCheckEnum;
8 import com.yohobuy.ufo.model.order.bo.SellerBo; 8 import com.yohobuy.ufo.model.order.bo.SellerBo;
9 -import com.yohobuy.ufo.model.order.common.OrderAttributes;  
10 -import com.yohobuy.ufo.model.order.common.OrderStatus;  
11 -import com.yohobuy.ufo.model.order.common.SellerFuncEnum;  
12 -import com.yohobuy.ufo.model.order.common.SkupStatus; 9 +import com.yohobuy.ufo.model.order.common.*;
13 import com.yohobuy.ufo.model.order.constants.SkupType; 10 import com.yohobuy.ufo.model.order.constants.SkupType;
14 import com.yohobuy.ufo.model.order.req.*; 11 import com.yohobuy.ufo.model.order.req.*;
15 import com.yohobuy.ufo.model.order.resp.*; 12 import com.yohobuy.ufo.model.order.resp.*;
@@ -109,6 +106,9 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { @@ -109,6 +106,9 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
109 SellerOrderGoodsMapper sellerOrderGoodsMapper; 106 SellerOrderGoodsMapper sellerOrderGoodsMapper;
110 107
111 @Autowired 108 @Autowired
  109 + ExpressRecordMapper expressRecordMapper;
  110 +
  111 + @Autowired
112 private TradeBillsMapper tradeBillsMapper; 112 private TradeBillsMapper tradeBillsMapper;
113 113
114 private static final String ADDRESS_STR = "{\"address\":\"松金公路2758号sneakerburger仓储中心\",\"address_id\":17560803,\"area\":\"上海 金山区 张堰镇\",\"areaCode\":\"310116103\",\"consignee\":\"阿津\",\"isUpdate\":\"N\",\"mobile\":\"18121153590\",\"phone\":\"\",\"zipCode\":\"\"}"; 114 private static final String ADDRESS_STR = "{\"address\":\"松金公路2758号sneakerburger仓储中心\",\"address_id\":17560803,\"area\":\"上海 金山区 张堰镇\",\"areaCode\":\"310116103\",\"consignee\":\"阿津\",\"isUpdate\":\"N\",\"mobile\":\"18121153590\",\"phone\":\"\",\"zipCode\":\"\"}";
@@ -213,8 +213,11 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { @@ -213,8 +213,11 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
213 213
214 List<BuyerOrderGoods> buyerOrderGoodList = buyerOrderGoodsMapper.selectOrderBySkups(req.getSkup()); 214 List<BuyerOrderGoods> buyerOrderGoodList = buyerOrderGoodsMapper.selectOrderBySkups(req.getSkup());
215 215
  216 +
  217 +
216 Map<Long, BuyerOrder> orderCodeToBuyer = null; 218 Map<Long, BuyerOrder> orderCodeToBuyer = null;
217 Map<Long, List<TradeBills>> buyerOrderToTradeBills = null; 219 Map<Long, List<TradeBills>> buyerOrderToTradeBills = null;
  220 + Map<Long, ExpressRecord> expressRecordMap = null;
218 if (CollectionUtils.isNotEmpty(buyerOrderGoodList)){ 221 if (CollectionUtils.isNotEmpty(buyerOrderGoodList)){
219 List<Long> buyerOrderCodeList = buyerOrderGoodList.stream().map(BuyerOrderGoods::getOrderCode).collect(Collectors.toList()); 222 List<Long> buyerOrderCodeList = buyerOrderGoodList.stream().map(BuyerOrderGoods::getOrderCode).collect(Collectors.toList());
220 223
@@ -222,6 +225,10 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { @@ -222,6 +225,10 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
222 // 买家订单信息 225 // 买家订单信息
223 orderCodeToBuyer = buyerOrderList.stream().collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity(), (key1, key2) -> key2)); 226 orderCodeToBuyer = buyerOrderList.stream().collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity(), (key1, key2) -> key2));
224 227
  228 + // 查询是否存在寄回信息
  229 + List<ExpressRecord> expressRecords = expressRecordMapper.selectByOrderCodesAndExpressType(buyerOrderCodeList, EnumExpressType.EXPRESS_TYPE_3.getCode());
  230 + expressRecordMap = expressRecords.stream().collect(Collectors.toMap(ExpressRecord::getOrderCode, Function.identity(), (key1, key2) -> key2));
  231 +
225 List<TradeBills> tradeBillsList = tradeBillsMapper.selectByOrderCodeList(buyerOrderCodeList); 232 List<TradeBills> tradeBillsList = tradeBillsMapper.selectByOrderCodeList(buyerOrderCodeList);
226 // 根据买家订单号查对账信息 233 // 根据买家订单号查对账信息
227 buyerOrderToTradeBills = tradeBillsList.stream().collect(Collectors.groupingBy(TradeBills::getOrderCode)); 234 buyerOrderToTradeBills = tradeBillsList.stream().collect(Collectors.groupingBy(TradeBills::getOrderCode));
@@ -231,12 +238,13 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { @@ -231,12 +238,13 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
231 // 鉴定通过 -- 货款收入 238 // 鉴定通过 -- 货款收入
232 // 鉴定不通过 -- 保证金扣款 239 // 鉴定不通过 -- 保证金扣款
233 // 买家取消时 -- 扣款 240 // 买家取消时 -- 扣款
234 - return covertToFastDeliveryShelfResp(productInfo, orderCodeToBuyer, buyerOrderToTradeBills, sellerOrder); 241 + return covertToFastDeliveryShelfResp(productInfo, orderCodeToBuyer, buyerOrderToTradeBills,expressRecordMap, sellerOrder);
235 } 242 }
236 243
237 private FastDeliveryGetShelfDetailResp covertToFastDeliveryShelfResp(ProductInfo productInfo, 244 private FastDeliveryGetShelfDetailResp covertToFastDeliveryShelfResp(ProductInfo productInfo,
238 Map<Long, BuyerOrder> orderCodeToBuyer, 245 Map<Long, BuyerOrder> orderCodeToBuyer,
239 Map<Long, List<TradeBills>> buyerOrderToTradeBills, 246 Map<Long, List<TradeBills>> buyerOrderToTradeBills,
  247 + Map<Long, ExpressRecord> expressRecordMap,
240 FastDeliveryGetShelfDetailResp sellerOrder) { 248 FastDeliveryGetShelfDetailResp sellerOrder) {
241 249
242 if (productInfo != null){ 250 if (productInfo != null){
@@ -269,6 +277,10 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { @@ -269,6 +277,10 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
269 tradeBillResp.setBuyerOrderStatus(buyerOrder.getStatus()); 277 tradeBillResp.setBuyerOrderStatus(buyerOrder.getStatus());
270 tradeBillResp.setBuyerOrderStatusDesc(OrderStatus.getOrderStatus(buyerOrder.getStatus()).getDesc()); 278 tradeBillResp.setBuyerOrderStatusDesc(OrderStatus.getOrderStatus(buyerOrder.getStatus()).getDesc());
271 279
  280 + if (expressRecordMap!=null && expressRecordMap.get(buyerOrderCode)!=null){
  281 + sellerOrder.setWaybillCode(expressRecordMap.get(buyerOrderCode).getWaybillCode());
  282 + }
  283 +
272 if (buyerOrderToTradeBills.get(buyerOrderCode) == null || CollectionUtils.isEmpty(buyerOrderToTradeBills.get(buyerOrderCode))){ 284 if (buyerOrderToTradeBills.get(buyerOrderCode) == null || CollectionUtils.isEmpty(buyerOrderToTradeBills.get(buyerOrderCode))){
273 continue; 285 continue;
274 } 286 }
@@ -49,6 +49,18 @@ public class BaseServiceCaller { @@ -49,6 +49,18 @@ public class BaseServiceCaller {
49 } 49 }
50 50
51 51
  52 + public ApiResponse doPost(String serviceName, String url, Object object, int defaultTime) {
  53 + try {
  54 + return serviceCaller.post(serviceName, url, object, ApiResponse.class, null).get(defaultTime, TimeUnit.MILLISECONDS);
  55 + } catch (ServiceException e) {
  56 + throw e;
  57 + } catch (Exception e) {
  58 + logger.warn("doPost fail, url is {} object is {}", url, object, e);
  59 + throw e;
  60 + }
  61 + }
  62 +
  63 +
52 public <T> T getResultFromApiResponse(ApiResponse resp, Class<T> clazz) { 64 public <T> T getResultFromApiResponse(ApiResponse resp, Class<T> clazz) {
53 if (resp == null) { 65 if (resp == null) {
54 throw new UfoServiceException(500, "服务器访问异常"); 66 throw new UfoServiceException(500, "服务器访问异常");
@@ -23,6 +23,8 @@ public class FastDeliveryProxyService { @@ -23,6 +23,8 @@ public class FastDeliveryProxyService {
23 23
24 public static final String YH_SECRET = "yh_2019oEngMex8"; 24 public static final String YH_SECRET = "yh_2019oEngMex8";
25 25
  26 + int Default_Time = 1000;
  27 +
26 @Autowired 28 @Autowired
27 private SellerOrderGoodsMapper sellerOrderGoodsMapper; 29 private SellerOrderGoodsMapper sellerOrderGoodsMapper;
28 30
@@ -73,7 +75,7 @@ public class FastDeliveryProxyService { @@ -73,7 +75,7 @@ public class FastDeliveryProxyService {
73 fastDeliveryReq.getSkup(), sellerAccessInfo.getLockSkupUrl(), fastDeliveryReq); 75 fastDeliveryReq.getSkup(), sellerAccessInfo.getLockSkupUrl(), fastDeliveryReq);
74 ApiResponse result = null; 76 ApiResponse result = null;
75 try{ 77 try{
76 - result = baseServiceCaller.doPost("fast.delivery.lockSkup", sellerAccessInfo.getLockSkupUrl(), fastDeliveryReq); 78 + result = baseServiceCaller.doPost("fast.delivery.lockSkup", sellerAccessInfo.getLockSkupUrl(), fastDeliveryReq, Default_Time);
77 }catch (Exception e){ 79 }catch (Exception e){
78 logger.info("[{}],[{}] error fast delivery lockSkup, {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), e); 80 logger.info("[{}],[{}] error fast delivery lockSkup, {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), e);
79 throw new ServiceException(403, "扣减库存失败"); 81 throw new ServiceException(403, "扣减库存失败");
@@ -103,7 +105,7 @@ public class FastDeliveryProxyService { @@ -103,7 +105,7 @@ public class FastDeliveryProxyService {
103 105
104 logger.info("[{}],[{}] start fast delivery delivery {}, body {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), 106 logger.info("[{}],[{}] start fast delivery delivery {}, body {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(),
105 sellerAccessInfo.getDeliveryUrl(), fastDeliveryReq); 107 sellerAccessInfo.getDeliveryUrl(), fastDeliveryReq);
106 - ApiResponse result = baseServiceCaller.doPost("fast.delivery.delivery", sellerAccessInfo.getDeliveryUrl(), fastDeliveryReq); 108 + ApiResponse result = baseServiceCaller.doPost("fast.delivery.delivery", sellerAccessInfo.getDeliveryUrl(), fastDeliveryReq, Default_Time);
107 logger.info("[{}],[{}] end fast delivery delivery, result {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), result); 109 logger.info("[{}],[{}] end fast delivery delivery, result {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), result);
108 return result; 110 return result;
109 111
@@ -133,7 +135,7 @@ public class FastDeliveryProxyService { @@ -133,7 +135,7 @@ public class FastDeliveryProxyService {
133 sellerAccessInfo.getUnlockSkupUrl(),sellerAccessInfo); 135 sellerAccessInfo.getUnlockSkupUrl(),sellerAccessInfo);
134 136
135 ApiResponse result = baseServiceCaller.doPost("fast.delivery.cancel", sellerAccessInfo.getUnlockSkupUrl(), 137 ApiResponse result = baseServiceCaller.doPost("fast.delivery.cancel", sellerAccessInfo.getUnlockSkupUrl(),
136 - fastDeliveryReq); 138 + fastDeliveryReq, Default_Time);
137 logger.info("[{}],[{}] end fast delivery cancel, result {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), result); 139 logger.info("[{}],[{}] end fast delivery cancel, result {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), result);
138 return result; 140 return result;
139 141