| | |
| | | import cc.mrbird.febs.mall.service.*; |
| | | import cc.mrbird.febs.mall.vo.MallMemberCouponVo; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | | import cc.mrbird.febs.pay.model.HeaderDto; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.pay.service.WxFaPiaoService; |
| | | import cc.mrbird.febs.pay.util.WechatConfigure; |
| | | import cc.mrbird.febs.rabbit.consumer.AgentConsumer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import okhttp3.HttpUrl; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.HttpStatus; |
| | | import org.apache.commons.httpclient.methods.GetMethod; |
| | | import org.apache.commons.httpclient.methods.PostMethod; |
| | | import org.apache.commons.httpclient.methods.RequestEntity; |
| | | import org.apache.commons.httpclient.methods.StringRequestEntity; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.core.io.ResourceLoader; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.net.URLConnection; |
| | | import java.nio.charset.Charset; |
| | | import java.security.KeyPair; |
| | | import java.util.*; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | |
| | | private MallGoodsMapper mallGoodsMapper; |
| | | @Autowired |
| | | private CouponGoodsMapper couponGoodsMapper; |
| | | @Autowired |
| | | private WxFaPiaoService wxFaPiaoService; |
| | | @Autowired |
| | | ResourceLoader resourceLoader; |
| | | @Test |
| | | public void rankProfit() { |
| | | // memberProfitService.rankProfit(); |
| | | MallMemberCouponDto mallMemberCouponDto = new MallMemberCouponDto(); |
| | | mallMemberCouponDto.setMemberId(72L); |
| | | mallMemberCouponDto.setExpireTime(DateUtil.date()); |
| | | List<Long> couponIds = couponGoodsMapper.selectByGoodId(10L); |
| | | List<MallMemberCouponVo> mallMemberCouponVos = new ArrayList<>(); |
| | | if(CollUtil.isNotEmpty(couponIds)){ |
| | | mallMemberCouponVos = mallMemberCouponMapper.selectListCreateInPage(mallMemberCouponDto,couponIds); |
| | | System.out.println(mallMemberCouponVos); |
| | | public void rankProfit() throws IOException { |
| | | // System.out.println(new ClassPathResource("wxP12/apiclient_cert.p12").getFile().exists()); |
| | | // System.out.println(new File("src/main/resources/wxP12/apiclient_cert.p12").exists()); |
| | | // |
| | | // InputStream inputStream = new FileInputStream(file); |
| | | // System.out.println(resourceLoader.getResource("classpath:/wxP12/apiclient_cert.p12").exists()); |
| | | KeyPair privateKey = wxFaPiaoService.getPrivateKey(); |
| | | HeaderDto headerDto = new HeaderDto(); |
| | | headerDto.setCallback_url("https://api.blnka.cn/api/xcxPay/fapiaoCallBack"); |
| | | headerDto.setShow_fapiao_cell(true); |
| | | String parseObj = JSONUtil.parseObj(headerDto).toString(); |
| | | String baseUrl = "https://api.mch.weixin.qq.com"; |
| | | String canonicalUrl = "/v3/new-tax-control-fapiao/merchant/development-config"; |
| | | String postStr = wxFaPiaoService.createAuthorization( |
| | | "POST", |
| | | canonicalUrl, |
| | | parseObj, |
| | | privateKey |
| | | |
| | | ); |
| | | // 创建httppost |
| | | try { |
| | | HttpClient httpClient = new HttpClient(); |
| | | PostMethod post = new PostMethod("https://api.mch.weixin.qq.com/v3/new-tax-control-fapiao/merchant/development-config"); |
| | | post.setRequestHeader("Accept", "application/json"); |
| | | post.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"); |
| | | post.setRequestHeader("Content-Type", "application/json; charset=UTF-8"); |
| | | post.setRequestHeader("Connection", "keep-alive"); |
| | | post.setRequestHeader("Authorization", "WECHATPAY2-SHA256-RSA2048 "+postStr); |
| | | RequestEntity entity = new StringRequestEntity(parseObj, "text/html", "utf-8"); |
| | | post.setRequestEntity(entity); |
| | | httpClient.executeMethod(post); |
| | | String responseBodyAsString = post.getResponseBodyAsString(); |
| | | cn.hutool.json.JSONObject maps = JSONUtil.parseObj(responseBodyAsString); |
| | | System.out.println(maps); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Test |
| | | public void rankProfit2() throws IOException { |
| | | KeyPair privateKey = wxFaPiaoService.getPrivateKey(); |
| | | String baseUrl = "https://api.mch.weixin.qq.com"; |
| | | String canonicalUrl = "/v3/new-tax-control-fapiao/merchant/development-config"; |
| | | String postStr = wxFaPiaoService.createAuthorization( |
| | | "GET", |
| | | canonicalUrl, |
| | | "", |
| | | privateKey |
| | | |
| | | ); |
| | | try { |
| | | HttpClient httpClient = new HttpClient(); |
| | | GetMethod method = new GetMethod(baseUrl+canonicalUrl); |
| | | method.setRequestHeader("Accept", "application/json"); |
| | | method.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"); |
| | | method.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); |
| | | method.setRequestHeader("Connection", "keep-alive"); |
| | | method.setRequestHeader("Authorization", "WECHATPAY2-SHA256-RSA2048 "+postStr); |
| | | httpClient.executeMethod(method); |
| | | System.out.println(method); |
| | | String responseBodyAsString = method.getResponseBodyAsString(); |
| | | cn.hutool.json.JSONObject maps = JSONUtil.parseObj(responseBodyAsString); |
| | | System.out.println(maps); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |