|  | @@ -13,7 +13,7 @@ package com.yami.shop.api.controller;
 | 
	
		
			
				|  |  |  import cn.hutool.core.collection.CollectionUtil;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  | -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
	
		
			
				|  |  | +import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.app.dto.*;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.enums.OrderStatus;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.enums.RefundStatusEnum;
 | 
	
	
		
			
				|  | @@ -26,9 +26,15 @@ import com.yami.shop.common.util.PageParam;
 | 
	
		
			
				|  |  |  import com.yami.shop.config.ShopConfig;
 | 
	
		
			
				|  |  |  import com.yami.shop.dao.PointsRecordMapper;
 | 
	
		
			
				|  |  |  import com.yami.shop.security.api.util.SecurityUtils;
 | 
	
		
			
				|  |  | +import com.yami.shop.security.comment.dao.AppConnectMapper;
 | 
	
		
			
				|  |  | +import com.yami.shop.security.comment.model.AppConnect;
 | 
	
		
			
				|  |  |  import com.yami.shop.service.*;
 | 
	
		
			
				|  |  |  import com.yami.shop.service.hb.IHBOrderService;
 | 
	
		
			
				|  |  |  import com.yami.shop.utils.CullenUtils;
 | 
	
		
			
				|  |  | +import com.yami.shop.wx.po.TraceWaybill;
 | 
	
		
			
				|  |  | +import com.yami.shop.wx.po.TraceWaybillDetail;
 | 
	
		
			
				|  |  | +import com.yami.shop.wx.po.TraceWaybillGoodsInfo;
 | 
	
		
			
				|  |  | +import com.yami.shop.wx.service.impl.WxProviderServiceImpl;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParam;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParams;
 | 
	
	
		
			
				|  | @@ -53,26 +59,49 @@ import java.util.Objects;
 | 
	
		
			
				|  |  |  public class MyOrderController {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private final OrderService orderService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final MapperFacade mapperFacade;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final UserAddrOrderService userAddrOrderService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final ProductService productService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final SkuService skuService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final ShopConfig shopConfig;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final MyOrderService myOrderService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final ShopDetailService shopDetailService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final OrderItemService orderItemService;
 | 
	
		
			
				|  |  |      private final IHBOrderService ihbOrderService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      private final OrderRefundService orderRefundService;
 | 
	
		
			
				|  |  |      private final PointsRecordMapper pointsRecordMapper;
 | 
	
		
			
				|  |  | +    private final OrderSettlementService orderSettlementService;
 | 
	
		
			
				|  |  | +    private final AppConnectMapper appConnectMapper;
 | 
	
		
			
				|  |  | +    private final DeliveryService deliveryService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @SuppressWarnings("all")
 | 
	
		
			
				|  |  | +    @GetMapping("/getWaybillToken")
 | 
	
		
			
				|  |  | +    @ApiOperation(value = "微信物流-获取waybill_token")
 | 
	
		
			
				|  |  | +    public ResponseEntity<String> getWaybillToken(@RequestParam(value = "orderNumber") String orderNumber) {
 | 
	
		
			
				|  |  | +        CullenUtils.validateDataThrowException(orderNumber==null,"订单号不能为空...");
 | 
	
		
			
				|  |  | +        AppConnect connect = appConnectMapper.getByUserId(SecurityUtils.getUser().getUserId(), 1);
 | 
	
		
			
				|  |  | +        CullenUtils.validateDataThrowException(orderNumber==null,"openid不存在...");
 | 
	
		
			
				|  |  | +        Order order = orderService.getOrderByOrderNumber(orderNumber);
 | 
	
		
			
				|  |  | +        CullenUtils.validateDataThrowException(order==null,"订单不存在...");
 | 
	
		
			
				|  |  | +        UserAddrOrder userAddrOrder = userAddrOrderService.getById(order.getAddrOrderId());
 | 
	
		
			
				|  |  | +        CullenUtils.validateDataThrowException(userAddrOrder==null,"收货地址不存在...");
 | 
	
		
			
				|  |  | +        Delivery delivery = deliveryService.getById(order.getDvyId());
 | 
	
		
			
				|  |  | +        CullenUtils.validateDataThrowException(delivery==null,"订单未发货...");
 | 
	
		
			
				|  |  | +        List<OrderItem> orderItemList = orderItemService.getOrderItemsByOrderNumber(orderNumber);
 | 
	
		
			
				|  |  | +        CullenUtils.validateDataThrowException(orderItemList.isEmpty(),"订单项不存在...");
 | 
	
		
			
				|  |  | +        OrderSettlement settlement = orderSettlementService.getOne(new LambdaQueryWrapper<OrderSettlement>().eq(OrderSettlement::getOrderNumber, orderNumber));
 | 
	
		
			
				|  |  | +        CullenUtils.validateDataThrowException(settlement==null,"订单结算不存在...");
 | 
	
		
			
				|  |  | +        TraceWaybill traceWaybill = new TraceWaybill();
 | 
	
		
			
				|  |  | +        traceWaybill.setOpenid(connect.getBizUserId());
 | 
	
		
			
				|  |  | +        traceWaybill.setReceiverPhone(userAddrOrder.getMobile());
 | 
	
		
			
				|  |  | +        traceWaybill.setDeliveryId(delivery.getDvyNo());
 | 
	
		
			
				|  |  | +        traceWaybill.setWaybillId(order.getDvyFlowId());
 | 
	
		
			
				|  |  | +        List<TraceWaybillGoodsInfo> goodsInfoList = Lists.newArrayList();
 | 
	
		
			
				|  |  | +        orderItemList.forEach(item -> goodsInfoList.add(new TraceWaybillGoodsInfo(item.getProdName(),item.getPic())));
 | 
	
		
			
				|  |  | +        traceWaybill.setGoodsInfo(new TraceWaybillDetail(goodsInfoList));
 | 
	
		
			
				|  |  | +        traceWaybill.setTransId(settlement.getBizPayNo());
 | 
	
		
			
				|  |  | +        return ResponseEntity.ok(WxProviderServiceImpl.traceWaybill(traceWaybill));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 |