package com.izouma.nineth;

import com.alibaba.fastjson.JSONObject;
import com.izouma.nineth.domain.UserFundAccount;
import com.izouma.nineth.dto.PageQuery;
import com.izouma.nineth.service.*;
import com.izouma.nineth.service.pay.UniformPayUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

public class PayTest extends  ApplicationTests{

    @Autowired
    private UniformPayUtil uniformPayUtil;


    @Test
    public void testRefund(){
        String orderNo = "969314774821109760";
        Map<String,Object> result = null;
        try {
            result = uniformPayUtil.refund(orderNo, "测试退款");
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println("result:" + result);
    }


    @Autowired
    private SumpayMerchantService sumpayMerchantService;

    @Autowired
    private UserFundAccountService userFundAccountService;

    @Test
    public void testRegister(){
        Long userId = 9398L;
//        UserFundAccount result = userFundAccountService.addSumpayAccount(userId);
        //100198515732
//        PageQuery pageQuery = new PageQuery();
//        pageQuery.getQuery().put("user_id", 100198515732L);
        Map<String,String> result = sumpayMerchantService.balanceQuery(userId);
//        UserFundAccount result = userFundAccountService.checkSumpayAccount(userId);
        System.out.println("result:" + result);

    }


    @Autowired
    private SandpayService sandpayService;

    @Test
    public void validSign(){
        //String reqStr = "extend=&charset=UTF-8&data=%7B%22head%22%3A%7B%22version%22%3A%221.0%22%2C%22respTime%22%3A%2220220509113020%22%2C%22respCode%22%3A%22000000%22%2C%22respMsg%22%3A%22%E6%88%90%E5%8A%9F%22%7D%2C%22body%22%3A%7B%22mid%22%3A%226888803043805%22%2C%22orderCode%22%3A%22973185092866277376%22%2C%22tradeNo%22%3A%22973185092866277376%22%2C%22clearDate%22%3A%2220220509%22%2C%22totalAmount%22%3A%22000000000010%22%2C%22orderStatus%22%3A%221%22%2C%22payTime%22%3A%2220220509113020%22%2C%22settleAmount%22%3A%22000000000010%22%2C%22buyerPayAmount%22%3A%22000000000010%22%2C%22discAmount%22%3A%22000000000000%22%2C%22txnCompleteTime%22%3A%2220220509113019%22%2C%22payOrderCode%22%3A%2220220509001336200000000000090543%22%2C%22accLogonNo%22%3A%22189****0062%22%2C%22accNo%22%3A%22208870******9685%22%2C%22midFee%22%3A%22000000000001%22%2C%22extraFee%22%3A%22000000000000%22%2C%22specialFee%22%3A%22000000000000%22%2C%22plMidFee%22%3A%22000000000000%22%2C%22bankserial%22%3A%22742022050922001439681437916809%22%2C%22externalProductCode%22%3A%2200000006%22%2C%22cardNo%22%3A%22208870******9685%22%2C%22creditFlag%22%3A%22%22%2C%22bid%22%3A%22%22%2C%22benefitAmount%22%3A%22000000000000%22%2C%22remittanceCode%22%3A%22%22%2C%22extend%22%3A%22%22%7D%7D&sign=SEXEhts7gCw6EL0UejyK0u2O9WJ9XVm7gn3iTLaFX9wwJ2Y4eiGaoaA2Y5Ja8n9hse4wWvbButYTaqChZM5taWyGrOKmz5k2ddiytR4cTX%2BYBEmPtaWY4CkS0y4H4Qe0o6I%2BrovTZ%2FPVipI%2BizaZ6CgNT1hT0JBIHORiC6xghf05edaVUMGfqLIxD7mb0jYmEujwCK1IjM223ggRkDFpdtw9c1mpNPufaO%2FwpaYJ4fpuKqa24admfQXYDlAWn0DqVAb%2FWKzQ6eD4maH91UqKkmb%2BB6%2F%2Bg8Cjl1BAY8dKfx%2FITECQ1SPX%2BZQHBVW8S6EXwbtFlbNSaQFaaViCAzmyjg%3D%3D&signType=01";
        String reqStr = "transCode=RTPM&accessPlatform=&merId=6888803043805&accessType=0&plId=&encryptKey=LUwNF814ETDr2KWdQN09tXkUnAHInWwrdwUU3PtAfgD88nz%2FQ94bGLPW1uMLrvsFrmCaVR1qwn%2BdURhrYec5%2FkzAn8SFSzxllipRlkMNrwyR1zWEPtx%2FZAJX4dDK0Rs9l898UmpMIvSFv7CVAXFyNIm7ePR2J0Yqh%2FeDYpuug2FE4YIQPaC%2B0t4Kx47Q0U4OqdcwdPYxoWJAwU9V%2Frk4%2F5I3vPmSn7oo7Pf8jH6SC6D%2FMHhYMzx4kMJAYF%2B7U9GCcpYslz0RUlFSrjjWiHXN5cf8RhLcP0xsOf%2B%2BacwaqSBvlsR5xNdWHhuma8y%2BSwCU5W9U6jnHLC3Pm8P8CNYRKQ%3D%3D&encryptData=l7306dJVIQeyzvBEG%2BSNUsScK1GJg1lkOZg0TXrCmyvwc8RLy55vAqmjffsigplXy3F%2BFTokWuDk0DBL96SfdIkCKakv%2BqiyKalHx2e%2B2TM%3D&sign=OQr%2FbHf5C2%2BexP0qvWajfVZYXHBjBViiCvhHYf4xCGJHLPNvYP7QHnP1EQI0LXEW3dCJgDqJjJZaRQLfJV9Dkkre14sODQ4HvKtkWNbPtBL7yaEAIuBu5fql7xFVESCJUykdRjXGLHBeYN2YYJWXkDcBZnJKxEhwKNt5gnwA4lOMKxRdFeCB2wmaKRmM6mKw1Jp1Ig4UaCeeBrrI%2BiCLTiD%2BhXAGSmCQKg3nPYzoXZIO45BXGi36BXOyZOOOTj35joKlPTjo2M4yDfEWPXGcm%2FmQsdvIfFB3Xx0I6bbJ7UI3YdUjN40MLBv%2F4sAuuELyDdcoDZNeloRb6PvPE2P8Wg%3D%3D";
        JSONObject res = null;
        try {
            //res = sandpayService.checkSuccessBody(reqStr);
            res = sandpayService.checkFundSuccessBody(reqStr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(res);

    }


    @Autowired
    private SandAccountService sandAccountService;

    @Test
    public void accountQuery(){
        try {
            JSONObject res = sandAccountService.memberInfoQuery(19L);
            System.out.println("res:" + res);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @Autowired
    private LianlianPayService lianlianPayService;

    @Test
    public void cardQuery(){
        try {
            JSONObject res = lianlianPayService.bindCardQuery(19L);
            System.out.println("res:" + res);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
