package jlifereptileserver;

import com.reptileclient.jlifeapp.PostorderApplication;
import com.reptileclient.jlifeapp.dao.hm.HmBookOrderMapper;
import com.reptileclient.jlifeapp.dao.jz.OrderGoodsMapper;
import com.reptileclient.jlifeapp.dao.jz.OrderMapper;
import com.reptileclient.jlifeapp.schedule.NoticeTokenTask;
import com.reptileclient.jlifeapp.service.HmBookOrderService;
import com.reptileclient.jlifeapp.service.HmPaymentOrderService;
import com.reptileclient.jlifeapp.service.HmSalesOrderService;
import com.reptileclient.jlifeapp.util.DateUtils;
import com.reptileclient.jlifeapp.util.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = PostorderApplication.class)
public class Test {

    @Autowired
    private HmSalesOrderService hmSalesOrderService;
    @Autowired
    private HmBookOrderMapper hmBookOrderMapper;
    @Autowired
    private OrderGoodsMapper orderGoodsMapper;
    @Autowired
    private HmBookOrderService hmBookOrderService;
    @Autowired
    private HmPaymentOrderService hmPaymentOrderService;

    @Autowired
    private OrderMapper orderMapper;
    
    @Autowired
    NoticeTokenTask noticeTokenTask;

    public static void main(String[] args) {
        String durl = "https://wdk-excel.oss-cn-beijing.aliyuncs.com/export/20201202/2209128993378/20201202_145732.xlsx";

        try {
            HttpUtil.downUrl(durl);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    @org.junit.Test
    public void test() {
//		Order record=new Order();
//		record.setActualPrice(BigDecimal.ZERO);
//		record.setOrderPrice(BigDecimal.ZERO);
//		record.setUserId(1);
//		record.setOrderSn("123456");
//		record.setOrderStatus((short)1);
//		try {
//
//			orderMapper.insertSelective(record);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
////		try {
////			hmSalesOrderService.fetchingData("2020-11-28", "2020-12-01");
////
////		} catch (Exception e) {
////			e.printStackTrace();
////		}
//		List<HmBookOrder> hmBookOrders= Lists.newArrayList();
//		hmBookOrders.add(new HmBookOrder("15294264363"));
//		hmBookOrders.add(new HmBookOrder("18511034283"));
//		hmBookOrderMapper.insertClientByBatch(hmBookOrders);
//
//		OrderGoods orderGoods = orderGoodsMapper.selectByPrimaryKey(35);
//
//		System.out.println(orderGoods.getGoodsName());

//		String str = "新房无家具整体清洁\uD83E\uDDF9";
//		String alias = EmojiParser.parseToAliases(str);
//		System.out.println(str);
//		System.out.println("EmojiConverterTest.testToAlias()=====>");
//		System.out.println(alias);


        //hmBookOrderService.updateByBookOrderNo("4509489","77001");

        //hmPaymentOrderService.updateByPaymentNo("2021011723418501", "44003");
//        List<Map<String, Object>> match = hmBookOrderService.match();
//        match.forEach(item -> {
//            String bookOrderNo = String.valueOf(item.get("book_order_no"));
//            String stationCode = String.valueOf(item.get("station_code"));
//            String paymentNo = String.valueOf(item.get("payment_no"));
//
//            //更新服务单
//            hmBookOrderService.updateByBookOrderNo(bookOrderNo, stationCode);
//            //更新支付单
//            if (StringUtils.isNotBlank(paymentNo)) {
//                hmPaymentOrderService.updateByPaymentNo(paymentNo, stationCode);
//            }
//        });
//    	noticeTokenTask.runTask();
    }


}
