package com.clx.performance;

import com.clx.order.feign.OrderFeign;
import com.clx.performance.component.GoodsOrderTruckRecordComponent;
import com.clx.performance.component.OrderGoodsStatusLazyComponent;
import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.feign.TransportFeignService;
import com.clx.performance.model.OrderChild;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.param.feign.transport.ThirdOrderChildBrokerParam;
import com.clx.performance.service.OrderCancelService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@SpringBootTest
@ExtendWith(SpringExtension.class)
public class JobTest {

    @Autowired
    private OrderFeign orderFeign;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private OrderGoodsStatusLazyComponent orderGoodsStatusLazyComponent;

    @Autowired
    private OrderGoodsDao orderGoodsDao;

    @Autowired
    private GoodsOrderTruckRecordComponent recordComponent;

    @Autowired
    private OrderCancelService orderCancelService;

    @Autowired
    private TransportFeignService transportFeignService;

    @Test
    public void test1() {

//        OrderCancelMqParam mqParam = new OrderCancelMqParam();
//        mqParam.setType("2");
//        mqParam.setOrderNo("123");
//        Message message = MessageBuilder.withBody(JSONUtil.parse(mqParam).toString().getBytes()).build();
//        rabbitTemplate.send(
//                RabbitKeyConstants.ORDER_CANCEL_EXCHANGE, RabbitKeyConstants.ORDER_CANCEL_ROUTE_KEY, message
//        );

        //orderCancelService.ownerCancelOrderPre("PT2023102700473");
        //orderCancelService.ownerCancelOrder("PT2023102600466");
        OrderChild orderChild = new OrderChild();
        OrderGoods orderGoods = new OrderGoods();
        ThirdOrderChildBrokerParam param = new ThirdOrderChildBrokerParam();
        param.setOrderNo(orderChild.getOrderNo());
        param.setChildNo(orderChild.getChildNo());
        param.setTruckNo(orderChild.getTruckNo());
        param.setFreightPrice(Integer.valueOf(orderChild.getFreightPrice().toString()));
        param.setFreight(Integer.valueOf(orderChild.getFreight().toString()));
        param.setSendAddress(orderGoods.getSendAddressShorter());
        //缺省市区
        param.setSendName(orderGoods.getUserName());


//        Result<ThirdOrderChildBrokerResultVO> thirdOrderChildBrokerResultVOResult = transportFeignService.orderChildSync(param);
//        System.out.println(thirdOrderChildBrokerResultVOResult);
    }
}
