package cn.freemud.client;

import cn.freemud.base.util.DateUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

/**
 * All rights Reserved, Designed By www.freemud.cn
 *
 * @version V1.0
 * @Title: PaymentClientTest
 * @Package cn.freemud.client
 * @Description: 简单描述下这个类是做什么用的
 * @author: zhenghuan.yang
 * @date: 2018/6/25 14:12
 * @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
 * 注意：本内容仅限于上海非码科技内部传阅，禁止外泄以及用于其他的商业目
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@EnableDiscoveryClient
@EnableFeignClients
@EnableAutoConfiguration
public class PaymentClientTest {

//    @Autowired
//    private PaymentClient paymentClient;

    /**
     * 统一下单
     */
//    @Test
//    public void payOrder() {
//        OrderPayDto orderPayDto = new OrderPayDto();
//        orderPayDto.setVer(2);
//        orderPayDto.setReqtype(73);
//        orderPayDto.setUnifyid("66077052-0288-4113-b520-7aeee3ab86cb");
//        orderPayDto.setPartnerId("360bb48b-5316-458a-903e-9a44c7f339b1");
//        orderPayDto.setStore_id("fm99999");
//        orderPayDto.setStation_id("1");
//        orderPayDto.setOperator_id("1");
//        orderPayDto.setTrans_id("112089974163116583");
//        orderPayDto.setOpenid("ob0iP4ohZECkc4aDV7q0n0FtThHw");
//        orderPayDto.setBusiness_date("20180622");
//        OrderPayDto.TransactionBean transactionBean = new OrderPayDto.TransactionBean();
//        transactionBean.setAmount(1l);
//        transactionBean.setPay_ebcode("10007");
//        transactionBean.setUndis_amount(1l);
//        transactionBean.setInvoice_flag(null);
//        OrderPayDto.TransactionBean.ProductBean productBean = new OrderPayDto.TransactionBean.ProductBean();
//        productBean.setConsume_num(1);
//        productBean.setPid("107901193270854179");
//        productBean.setSeq(0);
//        productBean.setSales_type("NORMAL");
//        productBean.setPrice(1l);
//        productBean.setName("蜜汁鸡腿满碗饭大套餐");
//        List<OrderPayDto.TransactionBean.ProductBean> productBeanlist = new ArrayList<OrderPayDto.TransactionBean.ProductBean>();
//        transactionBean.setProducts(productBeanlist);
//        List<OrderPayDto.TransactionBean> transactionBeanList = new ArrayList<OrderPayDto.TransactionBean>();
//        transactionBeanList.add(transactionBean);
//        orderPayDto.setTransactions(transactionBeanList);
//        OrderPayResponseDto orderPayResponseDto = paymentClient.orderPay(orderPayDto);
//    }

    /**
     * 支付退款
     */
//    @Test
//    public void orderRefund() {
//        OrderRefundDto orderRefundDto = new OrderRefundDto();
//        orderRefundDto.setVer(2);
//        orderRefundDto.setReqtype(62);
//        orderRefundDto.setUnifyid("1760");
//        orderRefundDto.setRefund_id(1531387597878L);
//        orderRefundDto.setStore_id("FM00001");
//        orderRefundDto.setStation_id("1");
//        orderRefundDto.setOperator_id("1");
//        orderRefundDto.setTrans_id("1167546566670410331");
//        orderRefundDto.setOpenid("oqRsc5D_AKQUGe8D_r4BHiYGHscI");
//        List<OrderRefundDto.TransactionBean> transactionBeans = Lists.newArrayList();
//        OrderRefundDto.TransactionBean transactionBean = new OrderRefundDto.TransactionBean();
//        transactionBean.setFmid("ZHL1760O1555887003");
//        transactionBean.setRefund_count(10L);
//        transactionBeans.add(transactionBean);
//        orderRefundDto.setTransactions(transactionBeans);
//        String json = paymentClient.orderRefund(orderRefundDto);
//        System.out.println("json===" + json);
//    }

    /**
     *
     */
//    @Test
//    public void getOrderPayInfo() {
//        QueryOrderPayInfoDto queryOrderPayInfoDto = new QueryOrderPayInfoDto("66077052-0288-4113-b520-7aeee3ab86cb", "fm99999"
//                , "116198662578682369", "ZHL1407O1555795703");
//        QueryOrderPayInfoResponseDto responseDto = paymentClient.queryOrderPayInfo(queryOrderPayInfoDto);
//        System.out.println("responseDto=="+new Gson().toJson(responseDto));
//    }

    @Test
    public void test1() {
        String str = "2018-07-06 14:08:16.960";
        System.out.println("dateStr==" + DateUtil.convert2String(DateUtil.convert2Date(str, "yyyy-MM-dd HH:mm:ss"),
                "yyyy-MM-dd HH:mm:ss"));
    }
}
