Authored by TANLING

增加物流信息

... ... @@ -26,6 +26,9 @@ public interface ExpressRecordMapper {
*/
ExpressRecord selectByOrderCodeAndExpressType( @Param("orderCode") Long orderCode, @Param("expressType") Integer expressType);
List<ExpressRecord> selectByOrderCodesAndExpressType( @Param("orderCodeList") List<Long> orderCodeList, @Param("expressType") Integer expressType);
/**
* 根据物流单号和物流类型查询快递信息
* @param wayBillCode
... ...
... ... @@ -41,6 +41,17 @@
limit 1
</select>
<select id="selectByOrderCodesAndExpressType" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM express_record
where order_code in
<foreach collection="orderCodeList" item="orderCode" open="(" close=")" separator=",">
#{orderCode, jdbcType=BIGINT}
</foreach>
and express_type = #{expressType}
</select>
<select id="selectByWayBillCodeAndExpressType" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM express_record
... ...
... ... @@ -6,10 +6,7 @@ import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.ProductInfo;
import com.yohobuy.ufo.model.enums.StorageCheckEnum;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.*;
... ... @@ -109,6 +106,9 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
ExpressRecordMapper expressRecordMapper;
@Autowired
private TradeBillsMapper tradeBillsMapper;
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 {
List<BuyerOrderGoods> buyerOrderGoodList = buyerOrderGoodsMapper.selectOrderBySkups(req.getSkup());
Map<Long, BuyerOrder> orderCodeToBuyer = null;
Map<Long, List<TradeBills>> buyerOrderToTradeBills = null;
Map<Long, ExpressRecord> expressRecordMap = null;
if (CollectionUtils.isNotEmpty(buyerOrderGoodList)){
List<Long> buyerOrderCodeList = buyerOrderGoodList.stream().map(BuyerOrderGoods::getOrderCode).collect(Collectors.toList());
... ... @@ -222,6 +225,10 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
// 买家订单信息
orderCodeToBuyer = buyerOrderList.stream().collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity(), (key1, key2) -> key2));
// 查询是否存在寄回信息
List<ExpressRecord> expressRecords = expressRecordMapper.selectByOrderCodesAndExpressType(buyerOrderCodeList, EnumExpressType.EXPRESS_TYPE_3.getCode());
expressRecordMap = expressRecords.stream().collect(Collectors.toMap(ExpressRecord::getOrderCode, Function.identity(), (key1, key2) -> key2));
List<TradeBills> tradeBillsList = tradeBillsMapper.selectByOrderCodeList(buyerOrderCodeList);
// 根据买家订单号查对账信息
buyerOrderToTradeBills = tradeBillsList.stream().collect(Collectors.groupingBy(TradeBills::getOrderCode));
... ... @@ -231,12 +238,13 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
// 鉴定通过 -- 货款收入
// 鉴定不通过 -- 保证金扣款
// 买家取消时 -- 扣款
return covertToFastDeliveryShelfResp(productInfo, orderCodeToBuyer, buyerOrderToTradeBills, sellerOrder);
return covertToFastDeliveryShelfResp(productInfo, orderCodeToBuyer, buyerOrderToTradeBills,expressRecordMap, sellerOrder);
}
private FastDeliveryGetShelfDetailResp covertToFastDeliveryShelfResp(ProductInfo productInfo,
Map<Long, BuyerOrder> orderCodeToBuyer,
Map<Long, List<TradeBills>> buyerOrderToTradeBills,
Map<Long, ExpressRecord> expressRecordMap,
FastDeliveryGetShelfDetailResp sellerOrder) {
if (productInfo != null){
... ... @@ -269,6 +277,10 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
tradeBillResp.setBuyerOrderStatus(buyerOrder.getStatus());
tradeBillResp.setBuyerOrderStatusDesc(OrderStatus.getOrderStatus(buyerOrder.getStatus()).getDesc());
if (expressRecordMap!=null && expressRecordMap.get(buyerOrderCode)!=null){
sellerOrder.setWaybillCode(expressRecordMap.get(buyerOrderCode).getWaybillCode());
}
if (buyerOrderToTradeBills.get(buyerOrderCode) == null || CollectionUtils.isEmpty(buyerOrderToTradeBills.get(buyerOrderCode))){
continue;
}
... ...
... ... @@ -49,6 +49,18 @@ public class BaseServiceCaller {
}
public ApiResponse doPost(String serviceName, String url, Object object, int defaultTime) {
try {
return serviceCaller.post(serviceName, url, object, ApiResponse.class, null).get(defaultTime, TimeUnit.MILLISECONDS);
} catch (ServiceException e) {
throw e;
} catch (Exception e) {
logger.warn("doPost fail, url is {} object is {}", url, object, e);
throw e;
}
}
public <T> T getResultFromApiResponse(ApiResponse resp, Class<T> clazz) {
if (resp == null) {
throw new UfoServiceException(500, "服务器访问异常");
... ...
... ... @@ -23,6 +23,8 @@ public class FastDeliveryProxyService {
public static final String YH_SECRET = "yh_2019oEngMex8";
int Default_Time = 1000;
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
... ... @@ -73,7 +75,7 @@ public class FastDeliveryProxyService {
fastDeliveryReq.getSkup(), sellerAccessInfo.getLockSkupUrl(), fastDeliveryReq);
ApiResponse result = null;
try{
result = baseServiceCaller.doPost("fast.delivery.lockSkup", sellerAccessInfo.getLockSkupUrl(), fastDeliveryReq);
result = baseServiceCaller.doPost("fast.delivery.lockSkup", sellerAccessInfo.getLockSkupUrl(), fastDeliveryReq, Default_Time);
}catch (Exception e){
logger.info("[{}],[{}] error fast delivery lockSkup, {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), e);
throw new ServiceException(403, "扣减库存失败");
... ... @@ -103,7 +105,7 @@ public class FastDeliveryProxyService {
logger.info("[{}],[{}] start fast delivery delivery {}, body {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(),
sellerAccessInfo.getDeliveryUrl(), fastDeliveryReq);
ApiResponse result = baseServiceCaller.doPost("fast.delivery.delivery", sellerAccessInfo.getDeliveryUrl(), fastDeliveryReq);
ApiResponse result = baseServiceCaller.doPost("fast.delivery.delivery", sellerAccessInfo.getDeliveryUrl(), fastDeliveryReq, Default_Time);
logger.info("[{}],[{}] end fast delivery delivery, result {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), result);
return result;
... ... @@ -133,7 +135,7 @@ public class FastDeliveryProxyService {
sellerAccessInfo.getUnlockSkupUrl(),sellerAccessInfo);
ApiResponse result = baseServiceCaller.doPost("fast.delivery.cancel", sellerAccessInfo.getUnlockSkupUrl(),
fastDeliveryReq);
fastDeliveryReq, Default_Time);
logger.info("[{}],[{}] end fast delivery cancel, result {}", fastDeliveryReq.getSellerUid(), fastDeliveryReq.getSkup(), result);
return result;
... ...