package com.tax.file.test;

import com.yxcheng.token.utils.DateUtils;
import com.yxcheng.token.utils.ZoneUtil;
import org.junit.Test;

import java.util.Date;

public class TestTaxNoDB {



    @Test
    public void genRegisterSQL(){
        String taxNo = "91310114798932009N," +
                "91320581MA1NM9YG1P";
       // String zoneCode = "3100";
       // String username = "bwgf-limit";
        String username = "daxiang";
        String serverNo = "T00002";
        String invSpec = "0";
        String taxNoSql= "INSERT INTO tk_tax_user (`taxno`, `zone_code`, `user_name`, `del_flag`, `server_no`, `inv_spec`) VALUES ('%s',  '%s', '%s', '0','%s', '%s');";
        String tokenSql = "INSERT INTO `tk_token` ( `taxno`,`zone_code`, `user_code`, `server_no`,  `is_valid`) VALUES ('%s', '%s', '"+username+"', 'B00001',  '1');";


        for(String taxno : taxNo.split(",")){
            System.out.println(String.format(taxNoSql,taxno,ZoneUtil.getDqByTaxno(taxno),username,serverNo,invSpec));
        }


        for(String taxno : taxNo.split(",")){
            System.out.println(String.format(tokenSql,taxno,ZoneUtil.getDqByTaxno(taxno)));
        }
    }



    @Test
    public void genTkFileSQL(){
        String taxNo = "91310113342290888U";
        String invType = "01";
        String invSpec = "2";
        String username = "xforce";
        String url = "http://file.taxservices.cn/invoice/91310113342290888U-20200330-201509-%E9%94%80%E9%A1%B9%E7%A5%A8-%E5%A2%9E%E5%80%BC%E7%A8%8E%E4%B8%93%E7%94%A8%E5%8F%91%E7%A5%A8-1.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=JHJG2Y3HVTM48YUU2ZYW%2F20200403%2F%2Fs3%2Faws4_request&X-Amz-Date=20200403T023530Z&X-Amz-Expires=432000&X-Amz-SignedHeaders=host&X-Amz-Signature=49571cf3c19f1087e8995852248c5577101281a22c7590e57a13a25e7d54cbc0";
        String invDateStart = "2015-09-01";
        String invDateEnd = "2015-09-30";
        String fileName = "91310113342290888U-20200330-201509-销项票-增值税专用发票-1.zip";
        String fileKey = "91310113342290888U-20200330-201509-销项票-增值税专用发票-1.zip";
        String applyDate = DateUtils.formatDate(new Date(),"yyyy-MM-dd hh:mm:ss");
        String tkFileSql= "INSERT INTO `tk_file` (`taxno`, `inv_spec`, `inv_type`, `dec_pwd`, `url`, `apply_status`, `down_status`, `inv_date_start`, `inv_date_end`, `user_name`, `file_name`, `file_key`,`apply_date`) VALUES ('%s', '%s', '%s', '123456', '%s', '1', '1', '%s', '%s', '%s', '%s', '%s', '%s');";


        for(String taxno : taxNo.split(",")){
            System.out.println(String.format(tkFileSql,taxno,invSpec,invType,url,invDateStart,invDateEnd,username,fileName,fileKey,applyDate));
        }


    }
}
