package cn.freemud.service.impl;

import cn.freemud.management.entities.dto.request.order.OrderManagerRequest;
import cn.freemud.management.service.adapter.OrderManagerAdapter;
import cn.freemud.management.thirdparty.MulitiPaymentClient;
import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.ordercenter.request.OrderConditionsReq;
import com.freemud.application.sdk.api.ordercenter.service.OrderDownLoadSdkService;
import com.freemud.sdk.api.assortment.order.request.order.MultiOrderRefundRequest;
import com.freemud.sdk.api.assortment.order.response.order.MultiOrderRefundResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.test.context.junit4.SpringRunner;
import springfox.documentation.spring.web.json.Json;

@RunWith(SpringRunner.class)
@SpringBootTest
@EnableDiscoveryClient
@EnableFeignClients
@EnableAutoConfiguration
public class MallOrderServiceImplTest {

    @Autowired
    private OrderDownLoadSdkService orderDownLoadSdkService;

//    @Autowired
//    private MallOrderServiceImpl mallOrderService;
//
//    @Autowired
//    private MCCafeOrderServiceImpl mcCafeOrderService;
//
//    @Autowired
//    private MulitiPaymentClient mulitiPaymentClient;
//
//    @Autowired
//    private OrderManagerAdapter orderManagerAdapter;

//    @Before
//    public void before() throws Exception {
//    }
//
//    @After
//    public void after() throws Exception {
//    }

//    @Test
//    public void f1() {
//        mcCafeOrderService.createOrder(JSON.parseObject("{\"channelType\":\"saas\",\"couponCode\":\"\",\"menuType\":\"saasdelivery\",\"needInvoice\":0,\"needTableware\":0,\"orderRemark\":\"\",\"orderType\":2,\"partnerId\":\"1206\",\"payChannelType\":1,\"receiveId\":\"3599568180562003060\",\"sessionId\":\"c4377678dbcbd6cdf6e7df86ea112b6f82723023\",\"shopId\":\"1450026\",\"takeMealFlag\":\"0\"}", CreateOrderVo.class),
//                new StoreResponse.BizVO(),
//                JSON.parseObject("{\"activityDiscountsDtos\":[],\"deliveryAmount\":10,\"discountDeliveryAmount\":10,\"isDiscountDelivery\":false,\"originalTotalAmount\":4400,\"packageAmount\":0,\"products\":[{\"activityDiscountsDtos\":[],\"attributeNames\":\"{\\\"attributeNames\\\":\\\"\\\"}\",\"cartGoodsUid\":\"eb8c7260-8ecb-44d1-9234-8d8bed0b0875\",\"classificationId\":\"\",\"classificationName\":\"\",\"comboProducts\":[{\"attributeNames\":\"{\\\"attributeNames\\\":\\\"\\\"}\",\"customerCode\":\"501642\",\"extraList\":[],\"hasProductCoupon\":false,\"isFixedProduct\":false,\"materialList\":[],\"originalPrice\":1700,\"parentProductId\":\"184437853099519288\",\"picture\":\"https://picture.sandload.cn/1598678546485.png\",\"productType\":6,\"qty\":2,\"skuId\":\"184437494035639613\",\"skuName\":\"中杯热美式\",\"spuId\":\"184437494035639613\",\"spuName\":\"中杯热美式\",\"stockLimit\":false,\"tax\":0.01,\"taxId\":\"\",\"totalDiscountAmount\":0,\"unit\":\"\",\"weight\":0.0},{\"attributeNames\":\"{\\\"attributeNames\\\":\\\"\\\"}\",\"customerCode\":\"901290\",\"extraList\":[],\"hasProductCoupon\":false,\"isFixedProduct\":false,\"materialList\":[],\"originalPrice\":500,\"parentProductId\":\"184437853099519288\",\"picture\":\"https://picture.sandload.cn/1598677404074.png\",\"productType\":6,\"qty\":2,\"skuId\":\"184436294373469463\",\"skuName\":\"经典芝士蛋糕\",\"spuId\":\"184436294373469463\",\"spuName\":\"经典芝士蛋糕\",\"stockLimit\":false,\"tax\":0.01,\"taxId\":\"\",\"totalDiscountAmount\":0,\"unit\":\"\",\"weight\":0.0}],\"customerCode\":\"901280\",\"extraList\":[],\"hasProductCoupon\":false,\"materialList\":[],\"originalPrice\":4400,\"picture\":\"https://picture.sandload.cn/1598678861518.png\",\"productCode\":\"901280\",\"productType\":6,\"qty\":2,\"salePrice\":4400,\"skuId\":\"184437853099519288\",\"skuName\":\"早餐啡常搭\",\"spuId\":\"184437853099519288\",\"spuName\":\"早餐啡常搭\",\"stockLimit\":false,\"tax\":0.01,\"taxId\":\"\",\"totalDiscountAmount\":0,\"unit\":\"\",\"weight\":0.0}],\"shareDiscountActivityDtos\":[],\"totalAmount\":4400,\"totalDiscountAmount\":0}", ShoppingCartGoodsDto.class),
//                new OrderExtendedReq(),
//                OrderClientType.SAAS,"www");
//    }
//
//    @Test
//    public void testPaySuccess() {
//        //0元支付
//        String fmId = "SPAY" + ValidationCode.getRandomUuid();
//        PaysuccessNoticeMessage message = new PaysuccessNoticeMessage();
//        message.setResult_code(100);
//        message.setOut_trade_no(fmId);
//        message.setTrans_id("16303606485084241800003");
//        message.setTotal_fee(0);
//        message.setOpenid("oORZK5MHMBm78PO302NdRyzIY5K0");
//        message.setPlatform_coupon(0);
//        message.setMerchant_coupon(0);
//        mallOrderService.paySuccessCallback(message);
//    }

//    @Test
//    public void testAffirm() {
//        OrderAffirmRequestVO requestVO = new OrderAffirmRequestVO();
//        requestVO.setPartnerId("1864");
//        requestVO.setShopId("8899");
//        requestVO.setSessionId("123123");
//        requestVO.setChannelType("saasmall");
//        requestVO.setOid("16303606485084241800003");
//        mallOrderService.orderAffirm(requestVO);
//    }

    @Test
    public void test() {
//        MultiOrderRefundRequest multiOrderRefundRequest = new MultiOrderRefundRequest();
//        multiOrderRefundRequest.setFmId("");
//        multiOrderRefundRequest.setVer3(false);
//        multiOrderRefundRequest.setVer("V1");
//        multiOrderRefundRequest.setNotifyUrl("http://open-store-order-application-service.open-store.svc:9212/order/refundNotifyCallback");
//        multiOrderRefundRequest.setOperatorId("1");
//        multiOrderRefundRequest.setPartnerId("1864");
//        multiOrderRefundRequest.setRefundAmount(1L);
//        multiOrderRefundRequest.setRefundTradeNo("1604886134387{{$timestamp}}");
//        multiOrderRefundRequest.setStationId("1");
//        multiOrderRefundRequest.setStoreId("999999998");
//        multiOrderRefundRequest.setOutOrderNo("3900472893821604933666");
//        MultiOrderRefundResponse<MultiOrderRefundResponse.Data> multiOrderRefundResponseDto = mulitiPaymentClient.paymentApplicationRefund(multiOrderRefundRequest,"1864");
//        System.out.println(2345678);
//        OrderManagerRequest orderManagerRequest = new OrderManagerRequest();
//        orderManagerRequest.setOrderId("19404015572678969200003");
//        orderManagerRequest.setPartnerId("1864");
//        orderManagerAdapter.orderAgreeRefund(orderManagerRequest);
        OrderConditionsReq request ;
        String str = "{\"abnormalStatuses\":[],\"afterSalesStatus\":0,\"appId\":\"\",\"bizType\":0,\"bizTypes\":[1,6,97,98],\"dispenseStatus\":0,\"endTimestamp\":1605542399,\"endUpdateTimestamp\":0,\"expressType\":0,\"externalObjectIds\":[],\"finishStatus\":false,\"isDeleted\":0,\"mobile\":\"\",\"orderClients\":[],\"orderCode\":\"19356550932276285500005\",\"orderCodes\":[],\"orderStatus\":0,\"orderStatuses\":[],\"orderTypes\":[],\"pageNum\":1,\"pageSize\":10,\"partnerId\":\"2655\",\"payStatuses\":[2,3,4],\"payTypes\":[],\"printNum\":0,\"productId\":\"\",\"productName\":\"\",\"settlementTypes\":[],\"startTimestamp\":1604160000,\"startUpdateTimestamp\":0,\"storeIds\":[],\"suspendState\":0,\"thirdOrderCode\":\"\",\"userId\":\"\",\"userName\":\"\"}";
        request = JSON.toJavaObject(JSON.parseObject(str),OrderConditionsReq.class);
        orderDownLoadSdkService.queryOrderByConditions(request,"");
    }


}
