//package cc.mrbird.febs;
|
//
|
//import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
|
//import cc.mrbird.febs.common.enumerates.FlowTypeEnum;
|
//import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
|
//import cc.mrbird.febs.common.exception.FebsException;
|
//import cc.mrbird.febs.common.utils.AppContants;
|
//import cc.mrbird.febs.common.utils.HttpCurlUtil;
|
//import cc.mrbird.febs.common.utils.MallUtils;
|
//import cc.mrbird.febs.common.utils.RedisUtils;
|
//import cc.mrbird.febs.mall.dto.MallMemberCouponDto;
|
//import cc.mrbird.febs.mall.entity.*;
|
//import cc.mrbird.febs.mall.mapper.*;
|
//import cc.mrbird.febs.mall.service.*;
|
//import cc.mrbird.febs.mall.vo.MallGoodsListVo;
|
//import cc.mrbird.febs.mall.vo.MallMemberCouponVo;
|
//import cc.mrbird.febs.pay.model.*;
|
//import cc.mrbird.febs.pay.service.IXcxPayService;
|
//import cc.mrbird.febs.pay.service.WxFaPiaoService;
|
//import cc.mrbird.febs.pay.util.JCEUtil;
|
//import cc.mrbird.febs.pay.util.WechatConfigure;
|
//import cc.mrbird.febs.rabbit.consumer.AgentConsumer;
|
//import cn.hutool.core.collection.CollUtil;
|
//import cn.hutool.core.date.DateTime;
|
//import cn.hutool.core.date.DateUtil;
|
//import cn.hutool.json.JSONArray;
|
//import cn.hutool.json.JSONUtil;
|
//import com.alibaba.fastjson.JSON;
|
//import com.alibaba.fastjson.JSONObject;
|
//import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
|
//import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
|
//import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
|
//import com.wechat.pay.contrib.apache.httpclient.notification.NotificationHandler;
|
//import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
|
//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.HttpPatch;
|
//import org.apache.http.client.methods.HttpPost;
|
//import org.apache.http.entity.StringEntity;
|
//import org.apache.http.impl.client.CloseableHttpClient;
|
//import org.apache.http.impl.client.HttpClients;
|
//import org.apache.http.message.BasicNameValuePair;
|
//import org.apache.http.util.EntityUtils;
|
//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.util.Base64Utils;
|
//import org.springframework.web.client.RestTemplate;
|
//
|
//import javax.annotation.Resource;
|
//import java.io.*;
|
//import java.math.BigDecimal;
|
//import java.net.URLConnection;
|
//import java.nio.charset.Charset;
|
//import java.nio.charset.StandardCharsets;
|
//import java.security.*;
|
//import java.security.cert.CertificateFactory;
|
//import java.security.cert.X509Certificate;
|
//import java.text.ParseException;
|
//import java.text.SimpleDateFormat;
|
//import java.util.*;
|
//import java.io.ByteArrayOutputStream;
|
//import java.io.InputStream;
|
//import java.io.PrintWriter;
|
//import java.net.URL;
|
//import java.util.HashMap;
|
//import java.util.Map;
|
//
|
///**
|
// * @author wzy
|
// * @date 2022-06-02
|
// **/
|
//@SpringBootTest
|
//public class ProfitTest {
|
//
|
// @Autowired
|
// private AgentConsumer agentConsumer;
|
//
|
// @Autowired
|
// private IAgentService agentService;
|
//
|
// @Autowired
|
// private IMemberProfitService memberProfitService;
|
//
|
// @Test
|
// public void dynamicProfit() {
|
// memberProfitService.dynamicProfit(21L);
|
// }
|
// @Test
|
// public void agentProfit() {
|
// memberProfitService.agentProfit(null);
|
// }
|
//
|
//
|
// @Test
|
// public void staticProfit() {
|
// memberProfitService.staticProfit(new Date());
|
// }
|
//
|
// @Test
|
// public void thankfulProfit() {
|
// memberProfitService.thankfulProfit(new Date());
|
// }
|
// @Autowired
|
// private MallMemberCouponMapper mallMemberCouponMapper;
|
// @Autowired
|
// private MallGoodsMapper mallGoodsMapper;
|
// @Autowired
|
// private CouponGoodsMapper couponGoodsMapper;
|
// @Autowired
|
// private WxFaPiaoService wxFaPiaoService;
|
// @Autowired
|
// ResourceLoader resourceLoader;
|
//
|
// @Test
|
// public void redisTest() throws IOException {//配置开发选项
|
// String obj = redisUtils.getString("mall_goods_json");//获取JSONARRAY字符串对象
|
// System.out.println(obj);
|
// JSONArray jsonArray = JSONUtil.parseArray(obj);//转换成JSONARRAY对象
|
// List<MallGoodsListVo> mallGoodsListVos = JSONUtil.toList(jsonArray, MallGoodsListVo.class);//转换成对象集合
|
// System.out.println(mallGoodsListVos.size());
|
//
|
// }
|
// @Test
|
// 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());
|
// PrivateKey privateKey = wxFaPiaoService.getPrivateKeyV3();
|
// HeaderDto headerDto = new HeaderDto();
|
// headerDto.setCallback_url("https://api.blnka.cn/api/xcxPay/fapiaoCallBack");
|
// headerDto.setShow_fapiao_cell(false);
|
// 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 = null;
|
// try {
|
// postStr = wxFaPiaoService.createAuthorization(
|
// "PATCH",
|
// baseUrl+canonicalUrl,
|
// parseObj,
|
// privateKey
|
// );
|
// } catch (NoSuchAlgorithmException e) {
|
// e.printStackTrace();
|
// }
|
//
|
// String token = AppContants.FP_TOKEN_HEADER_TYPE+postStr;
|
// System.out.println("WECHATPAY2-SHA256-RSA2048 "+postStr);
|
// String s = wxFaPiaoService.sendPatch(baseUrl + canonicalUrl, parseObj, token);
|
// System.out.println(s);
|
// }
|
//
|
// @Test
|
// public void rankProfit03() throws IOException {//创建电子发票卡券模板
|
// FPCardTemplateDto fpCardTemplateDto = new FPCardTemplateDto();
|
// fpCardTemplateDto.setCard_appid("wxad2fdb2fcad10fb2");
|
//
|
// FPCardTemplateInformationDto fpCardTemplateInformationDto = new FPCardTemplateInformationDto();
|
// fpCardTemplateInformationDto.setLogo_url("http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7hicFNjakmxibMLGWpXrEXB33367o7zHN0CwngnQY7zb7g/0");
|
// fpCardTemplateInformationDto.setPayee_name("发票测试");
|
//
|
// FPCardTemplateCustomCellDto fpCardTemplateCustomCellDto = new FPCardTemplateCustomCellDto();
|
// fpCardTemplateCustomCellDto.setWords("电子发票");
|
// fpCardTemplateCustomCellDto.setDescription("查看发票");
|
// fpCardTemplateCustomCellDto.setJump_url("http://www.qq.com");
|
// fpCardTemplateCustomCellDto.setMiniprogram_path("gh_86a091e50ad4@app");
|
// fpCardTemplateCustomCellDto.setMiniprogram_user_name("pages/xxxPage");
|
// fpCardTemplateInformationDto.setCustom_cell(fpCardTemplateCustomCellDto);
|
//
|
// fpCardTemplateDto.setCard_template_information(fpCardTemplateInformationDto);
|
//
|
// String parseObj = JSONUtil.parseObj(fpCardTemplateDto).toString();
|
// System.out.println(parseObj);
|
// String baseUrl = "https://api.mch.weixin.qq.com";
|
// String canonicalUrl = "/v3/new-tax-control-fapiao/card-template";
|
// PrivateKey privateKey = wxFaPiaoService.getPrivateKeyV3();
|
// String postStr = null;
|
// try {
|
// postStr = wxFaPiaoService.createAuthorization(
|
// "POST",
|
// baseUrl+canonicalUrl,
|
// parseObj,
|
// privateKey
|
// );
|
// } catch (NoSuchAlgorithmException e) {
|
// e.printStackTrace();
|
// }
|
// String token = AppContants.FP_TOKEN_HEADER_TYPE+postStr;
|
//
|
// System.out.println("WECHATPAY2-SHA256-RSA2048 "+postStr);
|
// String s = wxFaPiaoService.sendPost(baseUrl + canonicalUrl, parseObj, "WECHATPAY2-SHA256-RSA2048 "+postStr);
|
// System.out.println(s);
|
// }
|
//
|
//
|
//
|
// @Test
|
// public void rankProfit04() throws IOException {//获取用户填写的抬头
|
// //初始化请求参数
|
// Map<String, Object> params = new HashMap<>();
|
// params.put("scene","WITH_WECHATPAY");
|
// params.put("fapiao_apply_id","4200002059202401191880748568");
|
//
|
// String baseUrl = "https://api.mch.weixin.qq.com";
|
// String canonicalUrl = "/v3/new-tax-control-fapiao/user-title";
|
//
|
// String urlparm = baseUrl+canonicalUrl;//有参数的get请求,加密是需要把参数加载进去URL
|
// List<BasicNameValuePair> parameters = new ArrayList<>();
|
// for (Map.Entry<String, Object> entry : params.entrySet()) {
|
// parameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
|
// }
|
// StringBuilder dataparm = new StringBuilder();
|
// params.forEach((k, v) -> dataparm.append("&" + k + "=" + v));
|
// String string = dataparm.toString();
|
// if (!"".equals(string)) {
|
// urlparm = baseUrl+canonicalUrl + "?" + dataparm.substring(1);
|
// }
|
// PrivateKey privateKey = wxFaPiaoService.getPrivateKeyV3();
|
// String postStr = null;
|
// try {
|
// postStr = wxFaPiaoService.createAuthorization(
|
// "GET",
|
// urlparm,
|
// "",
|
// privateKey
|
// );
|
// } catch (NoSuchAlgorithmException e) {
|
// e.printStackTrace();
|
// }
|
// String s = wxFaPiaoService.sendGet(baseUrl+canonicalUrl, params, "WECHATPAY2-SHA256-RSA2048 "+postStr);
|
// System.out.println(s);
|
// }
|
//
|
// @Test
|
// public void rankProfit2() throws IOException {//查询配置开发选项
|
// PrivateKey privateKey = wxFaPiaoService.getPrivateKeyV3();
|
// String baseUrl = "https://api.mch.weixin.qq.com";
|
// String canonicalUrl = "/v3/new-tax-control-fapiao/merchant/development-config";
|
// String postStr = null;
|
// try {
|
// postStr = wxFaPiaoService.createAuthorization(
|
// "GET",
|
// baseUrl+canonicalUrl,
|
// "",
|
// privateKey
|
//
|
// );
|
// } catch (NoSuchAlgorithmException e) {
|
// e.printStackTrace();
|
// }
|
// System.out.println("WECHATPAY2-SHA256-RSA2048"+postStr);
|
// String s = wxFaPiaoService.sendGet(baseUrl + canonicalUrl, new HashMap<>(), "WECHATPAY2-SHA256-RSA2048 "+postStr);
|
//
|
// System.out.println(s);
|
//// 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();
|
//// }
|
//
|
// }
|
//
|
// @Test
|
// public void rankProfit2_01() throws IOException, ParseException, GeneralSecurityException {//获取平台证书
|
// JCEUtil.removeCryptographyRestrictions();
|
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
// PrivateKey privateKey = wxFaPiaoService.getPrivateKeyV3();
|
// String baseUrl = "https://api.mch.weixin.qq.com";
|
// String canonicalUrl = "/v3/certificates";
|
// String postStr = null;
|
// try {
|
// postStr = wxFaPiaoService.createAuthorization(
|
// "GET",
|
// baseUrl+canonicalUrl,
|
// "",
|
// privateKey
|
//
|
// );
|
// } catch (NoSuchAlgorithmException e) {
|
// e.printStackTrace();
|
// }
|
// String responseBodyAsString = wxFaPiaoService.sendGet(baseUrl + canonicalUrl, new HashMap<>(), "WECHATPAY2-SHA256-RSA2048 "+postStr);
|
// //完成签名并执行请求
|
// X509Certificate x509Certificate = null;
|
// try {
|
// cn.hutool.json.JSONObject maps = JSONUtil.parseObj(responseBodyAsString);
|
// System.out.println(maps);
|
//
|
// FPCertificateVo certificateVo = com.alibaba.fastjson.JSONObject.parseObject(responseBodyAsString, FPCertificateVo.class);
|
// for (FPCertificates certificates : certificateVo.getData()) {
|
// if (format.parse(certificates.getEffective_time()).before(new Date())
|
// && format.parse(certificates.getExpire_time()).after(new Date())) {
|
// FPEncryptCertificate encrypt_certificate = certificates.getEncrypt_certificate();
|
// //解密
|
// AesUtil aesUtil = new AesUtil("daL341aN5orDt13puXadsAf2rpuX12v3".getBytes("utf-8"));
|
// String pulicKey = aesUtil.decryptToString(
|
// encrypt_certificate.getAssociated_data().getBytes("utf-8"),
|
// encrypt_certificate.getNonce().getBytes("utf-8"),
|
// encrypt_certificate.getCiphertext());
|
// //获取平台证书
|
// final CertificateFactory cf = CertificateFactory.getInstance("X509");
|
//
|
// ByteArrayInputStream inputStream = new ByteArrayInputStream(pulicKey.getBytes(StandardCharsets.UTF_8));
|
//
|
// x509Certificate = (X509Certificate) cf.generateCertificate(inputStream);
|
// System.out.println(x509Certificate);
|
// }
|
// }
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// String timestamp = "1705548628";
|
// String nonce = "sJBCGwYIM8WFJCpTE3gDGifC6VOyrPFY";
|
// String body = "{\"id\":\"f23942b4-b128-56ef-9172-2da8204b5159\",\"create_time\":\"2024-01-18T11:30:28+08:00\",\"resource_type\":\"encrypt-resource\",\"event_type\":\"FAPIAO.USER_APPLIED\",\"summary\":\"用户已申请开票\",\"resource\":{\"original_type\":\"fapiao\",\"algorithm\":\"AEAD_AES_256_GCM\",\"ciphertext\":\"X7XjgHrepsnVpFqNgjl9EfRbJIdMUf15izFrtnvEf7So3SWlg6CFNofcQAJE+iL1XfkFk7DNNW0rILNbY1cGWGlAlKbbPhv5SFEakZVe9GZsSTd4EC5zTk9D6g+FTS6EQNxCkj4ut2WyYaSSqJjHgYaqdKzLNPSTGRVQnynafFE=\",\"associated_data\":\"fapiao\",\"nonce\":\"X7daAHdejNsm\"}}";
|
// Map<String, Object> requestBody = JSONUtil.parseObj(body);
|
// String signature = "WECHATPAY/SIGNTEST/9WwfXW/noMdzDPcOrFD51Bf5YIThXLTtLCl5hoGlSfIBdY2UpE+5eHLs0XyF7y2cQc4OlzTzDDxSMTp/p/8ZenE2hMBaQjxVrdbTtrOLA1h13/WjCNaTr1URTqQ5+IF5bLCxAW8BmZ0jEqpmI/HYR3wdK8/7W91c1zfKODYgkvJzxFzd8OWi2GtELE5tLamkOLyb0GEcsGww2DUOypO5HjNyITgsy9R00w3OH92UInCD8Z6c5BAsQNySqFK8N52y38AlIWTtKROHmJtu+kHbt+nMOU0kbB5bZcPAptsnVYpp9KMmjMrmyjiKtHZb2TGIWiN/L+bgceyN3g==";
|
// //构造验签名串
|
// String signatureStr = timestamp + "\n" + nonce + "\n" + com.alibaba.fastjson.JSONObject.toJSONString(requestBody) + "\n";
|
// System.out.println(signature.length());
|
// System.out.println(signature);
|
// System.out.println(signatureStr.length());
|
// System.out.println(signatureStr);
|
// // 加载SHA256withRSA签名器
|
// Signature signer = Signature.getInstance("SHA256withRSA");
|
// // 用微信平台公钥对签名器进行初始化(调上一节中的获取平台证书方法)
|
// signer.initVerify(x509Certificate);
|
// // 把我们构造的验签名串更新到签名器中
|
// signer.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
// // 把请求头中微信服务器返回的签名用Base64解码 并使用签名器进行验证
|
// boolean result = signer.verify(Base64Utils.decodeFromString(signature));
|
// System.out.println(result);
|
// }
|
//
|
//
|
// @Autowired
|
// private MallOrderInfoMapper mallOrderInfoMapper;
|
//
|
// @Test
|
// public void directorProfitTest() {
|
// memberProfitService.storeAndDirectorProfit(new Date());
|
// }
|
//
|
// @Autowired
|
// private MallOrderItemMapper mallOrderItemMapper;
|
//
|
// @Autowired
|
// private IMallAchieveService mallAchieveService;
|
//
|
// @Test
|
// public void achieveTest() {
|
// List<MallOrderItem> items = mallOrderItemMapper.selectList(null);
|
// for (MallOrderItem item : items) {
|
// mallAchieveService.add(item.getId());
|
// }
|
// }
|
//
|
// @Test
|
// public void paramTest() {
|
// Map<String, Integer> map = new HashMap<>();
|
// BigDecimal amount = new BigDecimal("100");
|
// map.put("amount", 1);
|
// changeAmount(map);
|
// System.out.println(map.get("amount"));
|
// }
|
//
|
// public void changeAmount(Map<String, Integer> amount) {
|
// amount.put("amount", 2);
|
// }
|
//
|
// @Resource
|
// RestTemplate restTemplate;
|
//
|
// @Test
|
// public void getWeChatAccessToken() {
|
//
|
// String appId = "wx5cc58f796224af61";
|
// String appSecret = "71403646f666f9b9dca308d4f357765c";
|
// String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
|
// String jsonStr = restTemplate.getForObject(url, String.class);
|
//
|
// /**
|
// * 返回结果
|
// * {"access_token":"ACCESS_TOKEN","expires_in":7200}
|
// */
|
// if (!jsonStr.contains("access_token")) {
|
// System.out.println("获取微信access_token失败");
|
// }
|
//
|
// JSONObject jsonObject = JSON.parseObject(jsonStr);
|
// System.out.println(jsonObject.get("access_token").toString());
|
// }
|
// @Resource
|
// IApiMallTeamLeaderService iApiMallTeamLeaderService;
|
//
|
// @Test
|
// public void confirm(){
|
//// ApiLeaderOrderConfirmDto apiLeaderOrderConfirmDto = new ApiLeaderOrderConfirmDto();
|
//// apiLeaderOrderConfirmDto.setIds("90");
|
//// iApiMallTeamLeaderService.leaderOrderConfirm(apiLeaderOrderConfirmDto);
|
// String productNames = getProductNames(35L, 106L);
|
// System.out.println(productNames);
|
// }
|
//
|
// /**
|
// * 根据用户ID和订单ID获取所购买商品名称
|
// * @return 所含商品名称(多个以","隔开)
|
// */
|
// public String getProductNames(Long memberId, Long orderId) {
|
// MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectOrderByMemberIdAndId(memberId, orderId);
|
// List<MallOrderItem> details = mallOrderInfo.getItems();
|
// if (CollectionUtils.isEmpty(details)) {
|
// return "";
|
// }
|
// StringBuffer productNameBuffer = new StringBuffer();
|
// Integer maxLength = 30;
|
// for (int i = 0; i< details.size(); i++) {
|
// MallOrderItem mallOrderItem = details.get(i);
|
// String goodsName = mallOrderItem.getGoodsName();
|
// if (goodsName == null) {
|
// continue;
|
// }
|
// if (i == 0 && goodsName.length() > maxLength) {
|
// productNameBuffer.append(goodsName.substring(0, maxLength) + "...");
|
// break;
|
// }
|
// if ((productNameBuffer.length() + goodsName.length()) > maxLength) {
|
// productNameBuffer.append("等");
|
// break;
|
// }
|
// productNameBuffer.append(goodsName + ",");
|
// }
|
// String productNames = productNameBuffer.toString();
|
// if (productNames.endsWith(",")) {
|
// productNames = productNames.substring(0, productNames.length() - 1);
|
// }
|
// if (productNames.endsWith(",等")) {
|
// productNames = productNames.substring(0, productNames.length() - 2) + "等";
|
// }
|
// return productNames;
|
// }
|
// @Autowired
|
// private IXcxPayService iXcxPayService;
|
// @Autowired
|
// private IAdminMallTeamLeaderService iAdminMallTeamLeaderService;
|
//
|
// @Test
|
// public void qrcodeBase64(){
|
//
|
//// Integer integer = mallGoodsMapper.upDateStockAndVolumeByGoodsId(35L, 3);
|
//// System.out.println(integer);
|
//// WxGenerateQrCodeDto wxGenerateQrCodeDto = new WxGenerateQrCodeDto();
|
//// wxGenerateQrCodeDto.setPage("pages/product/details");
|
//// wxGenerateQrCodeDto.setScene("35");
|
//// FebsResponse febsResponse = iXcxPayService.generateQrCode(wxGenerateQrCodeDto);
|
//// String data = febsResponse.get("data").toString();
|
//// System.out.println(data);
|
//// trackServiceInfo("e024c63342930addc57189c8608cdb01",null);
|
//// String e024c63342930addc57189c8608cdb01 = trackServiceDel("e024c63342930addc57189c8608cdb01", "792477");
|
//// System.out.println(e024c63342930addc57189c8608cdb01);
|
// String ss = fenceDel("95ede7157929f5f6b6c758971be924b1", "795278","795554");
|
// System.out.println(ss);
|
// }
|
//
|
// //电子围栏删除
|
// public String fenceDel(String gaodeKey, String sid,String fenceId) {
|
// String url = "https://tsapi.amap.com/v1/track/geofence/delete?key="+gaodeKey+"&sid="+sid+"&gfids="+fenceId;
|
// HttpPost httpPost = new HttpPost(url);
|
// Map<String,String> map = new HashMap<>();
|
// map.put("key",gaodeKey);
|
// map.put("sid",sid);
|
// map.put("gfids",fenceId);
|
// String param= JSON.toJSONString(map);
|
// String result = null;
|
// try {
|
// result = HttpCurlUtil.sendPostHttp(url, param);
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// cn.hutool.json.JSONObject maps = JSONUtil.parseObj(result);
|
// System.out.println(maps);
|
// String errcode = maps.get("errcode").toString();
|
// if(!"10000".equals(errcode)){
|
// return "fail";
|
// }else{
|
// return maps.toString();
|
// }
|
// }
|
// //服务删除
|
// public String trackServiceDel(String gaodeKey, String sid) {
|
// String url = "https://tsapi.amap.com/v1/track/service/delete?key="+gaodeKey+"&sid="+sid;
|
// HttpPost httpPost = new HttpPost(url);
|
// Map<String,String> map = new HashMap<>();
|
// map.put("key",gaodeKey);
|
// map.put("sid",sid);
|
// String param= JSON.toJSONString(map);
|
// String result = null;
|
// try {
|
// result = HttpCurlUtil.sendPostHttp(url, param);
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// cn.hutool.json.JSONObject maps = JSONUtil.parseObj(result);
|
// System.out.println(maps);
|
// String errcode = maps.get("errcode").toString();
|
// if(!"10000".equals(errcode)){
|
// return "fail";
|
// }else{
|
// return maps.toString();
|
// }
|
//// String str2 = maps.get("data").toString();
|
//// cn.hutool.json.JSONObject maps2 = JSONUtil.parseObj(str2);
|
//// String serviceId = maps2.get("sid").toString();
|
//// if(null!=serviceId&&!"".equals(serviceId)){
|
//// return serviceId;
|
//// }else{
|
//// return "fail";
|
//// }
|
// }
|
//
|
//
|
// public String trackServiceInfo(String gaodeKey, String serviceName) {
|
// String url = "https://tsapi.amap.com/v1/track/service/list";
|
// HttpPost httpPost = new HttpPost(url);
|
// Map<String,String> map = new HashMap<>();
|
// //高德Key
|
// //用户在高德地图官网申请Web服务API类型Key
|
// map.put("key",gaodeKey);
|
// System.out.println("==高德返回"+map);
|
// String result = null;
|
// try {
|
// result = HttpCurlUtil.sendGetHttp(url, map);
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// System.out.println("==高德返回"+result);
|
// cn.hutool.json.JSONObject maps = JSONUtil.parseObj(result);
|
// String errCode = maps.get("errcode").toString();
|
// if("10000".equals(errCode)){
|
// String dataStr = maps.get("data").toString();
|
// cn.hutool.json.JSONObject dataResults = JSONUtil.parseObj(dataStr);
|
// String resultsStr = dataResults.get("results").toString();
|
// return resultsStr;
|
// }else{
|
// return "fail";
|
// }
|
// }
|
//
|
//
|
////
|
//// @Autowired
|
//// private MallOrderInfoMapper mallOrderInfoMapper;
|
////
|
//// @Autowired
|
//// private MallGoodsSkuMapper mallGoodsSkuMapper;
|
//
|
// @Autowired
|
// private MallLeaderAchieveMapper mallLeaderAchieveMapper;
|
////
|
//// @Autowired
|
//// private MallTeamLeaderMapper mallTeamLeaderMapper;
|
////
|
//// @Autowired
|
//// private IMemberProfitService memberProfitService;
|
//
|
//// @Autowired
|
//// private IMallAchieveService mallAchieveService;
|
//
|
// @Autowired
|
// private DataDictionaryCustomMapper dataDictionaryCustomMapper;
|
//
|
// @Autowired
|
// private MallMemberMapper mallMemberMapper;
|
//
|
// @Autowired
|
// private IMallMoneyFlowService mallMoneyFlowService;
|
//
|
// @Autowired
|
// private IApiMallMemberWalletService memberWalletService;
|
//
|
// @Test
|
// public void achieve(){
|
// DataDictionaryCustom dicBonusSwitch = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.BONUS_SWITCH.getType(), DataDictionaryEnum.BONUS_SWITCH.getCode());
|
// String bonusSwitch = dicBonusSwitch.getValue();
|
// if("1".equals(bonusSwitch)){
|
// DataDictionaryCustom dicBonusPercent = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.BONUS_PERCENT.getType(), DataDictionaryEnum.BONUS_PERCENT.getCode());
|
// BigDecimal bonusPercent = new BigDecimal(dicBonusPercent.getValue()).setScale(2,BigDecimal.ROUND_DOWN);;
|
// //获取每日提成总数
|
// /**
|
// * a.unique_code uniqueCode 团长特征码
|
// * , IFNULL(sum(a.amount),0) amount 每日提成总金额
|
// */
|
//// DateTime dateTime = DateUtil.offsetDay(new Date(), -1);
|
// DateTime dateTime = DateUtil.offsetDay(new Date(), 0);
|
// List<Map<String, String>> allLeaderAchieve = mallLeaderAchieveMapper.selectListByStateAndCreateTimeAndUniqueCode(MallLeaderAchieve.STATE_ONE,dateTime);
|
// if (CollUtil.isNotEmpty(allLeaderAchieve)) {
|
// for (Map<String, String> map : allLeaderAchieve) {
|
// String uniqueCode = map.get("uniqueCode");
|
// Object amountOrder = map.get("amount");
|
// //直接舍弃小数点的第三位
|
// BigDecimal amount = new BigDecimal(String.valueOf(amountOrder)).setScale(2,BigDecimal.ROUND_DOWN);
|
// BigDecimal achieveMoney = amount.multiply(bonusPercent).setScale(2,BigDecimal.ROUND_DOWN);
|
// MallMember mallMember = mallMemberMapper.selectInfoByInviteId(uniqueCode);
|
// memberWalletService.addBalance(achieveMoney,mallMember.getId());
|
// String achieveNo = "TC."+ MallUtils.getOrderNum();
|
// mallMoneyFlowService.addMoneyFlow(
|
// mallMember.getId(),
|
// achieveMoney,
|
// MoneyFlowTypeEnum.LEADERACHIEVE.getValue(),
|
// achieveNo,
|
// FlowTypeEnum.BALANCE.getValue());
|
//
|
//
|
// //更新到已提成状态
|
// mallLeaderAchieveMapper.updateByUniqueCodeStateAndTime(DateUtil.date(),uniqueCode,MallLeaderAchieve.STATE_ONE,dateTime);
|
// }
|
// }
|
// }
|
//
|
// }
|
// @Autowired
|
// private MallMoneyFlowMapper mallMoneyFlowMapper;
|
//
|
// @Test
|
// public void testAddress(){
|
// MallMember loginUser = mallMemberMapper.selectById(47L);
|
// BigDecimal totalProfit = mallMoneyFlowMapper.selectAmountByFlowtypeAndType(loginUser.getId(),FlowTypeEnum.BALANCE.getValue(),MoneyFlowTypeEnum.LEADERACHIEVE.getValue(),null,null,null);
|
// BigDecimal todayProfit = mallMoneyFlowMapper.selectAmountByFlowtypeAndType(loginUser.getId(),FlowTypeEnum.BALANCE.getValue(),
|
// MoneyFlowTypeEnum.LEADERACHIEVE.getValue(),
|
// null,DateUtil.date(),
|
// null);
|
//
|
// BigDecimal monthProfit = mallMoneyFlowMapper.selectAmountByFlowtypeAndType(loginUser.getId(),FlowTypeEnum.BALANCE.getValue(),
|
// MoneyFlowTypeEnum.LEADERACHIEVE.getValue(),
|
// null,null,
|
// DateUtil.date());
|
// BigDecimal waitProfit = mallLeaderAchieveMapper.selectProfitByStateAndDateTimeAndUniqueCode(1,null,loginUser.getInviteId()).setScale(2,BigDecimal.ROUND_DOWN);
|
// System.out.println(todayProfit +";");
|
// System.out.println(waitProfit +";");
|
// System.out.println(totalProfit +";");
|
// System.out.println(monthProfit +";");
|
// }
|
//
|
// @Autowired
|
// RedisUtils redisUtils;
|
// @Autowired
|
// MallRefundMapper mallRefundMapper;
|
//
|
//
|
//
|
// @Test
|
// public void qrcode(){
|
// MallMember member = mallMemberMapper.selectById(402L);
|
//
|
//// ApiRechargeWalletDto apiRechargeWalletDto = new ApiRechargeWalletDto();
|
//// apiRechargeWalletDto.setAmount(new BigDecimal(1));
|
//// apiRechargeWalletDto.setMemberId(402L);
|
//// BrandWCPayRequestData brandWCPayRequestData = null;
|
//// try {
|
//// brandWCPayRequestData = iXcxPayService.startPayment(mallOrderInfo);
|
//// } catch (Exception e) {
|
//// throw new FebsException("支付失败");
|
//// }
|
//// String s = JSONUtil.toJsonStr(brandWCPayRequestData);
|
//// String prepay_id = brandWCPayRequestData.getPrepay_id();
|
////
|
////
|
////// if(ObjectUtil.isEmpty(mallOrderInfo)){
|
////// }
|
////// Integer status = mallOrderInfo.getStatus();
|
////// if(OrderStatusEnum.WAIT_SHIPPING.getValue() != status){
|
////// }
|
////// Integer deliveryState = mallOrderInfo.getDeliveryState();
|
////// if(1 != deliveryState){
|
////// }
|
////// //根据子订单生成退款记录
|
////// List<MallOrderItem> mallOrderItemList = mallOrderItemMapper.selectListByOrderId(id);
|
////// if(CollUtil.isEmpty(mallOrderItemList)){
|
////// }
|
////// for(MallOrderItem mallOrderItem : mallOrderItemList){
|
////// QueryWrapper<MallRefundEntity> objectQueryWrapper = new QueryWrapper<>();
|
////// objectQueryWrapper.eq("member_id",member.getId());
|
////// objectQueryWrapper.eq("order_id",mallOrderInfo.getId());
|
////// objectQueryWrapper.eq("item_id",mallOrderItem.getId());
|
////// MallRefundEntity mallRefund = mallRefundMapper.selectOne(objectQueryWrapper);
|
////// MallRefundEntity mallRefundEntity = new MallRefundEntity();
|
////// if(ObjectUtil.isEmpty(mallRefund)){
|
////// mallRefundEntity.setRefundNo(mallOrderInfo.getOrderNo()+"_RITEM"+mallOrderItem.getId());
|
////// mallRefundEntity.setMemberId(member.getId());
|
////// mallRefundEntity.setOrderId(mallOrderInfo.getId());
|
////// mallRefundEntity.setItemId(mallOrderItem.getId());
|
////// if("余额支付".equals(mallOrderInfo.getPayMethod())){
|
////// mallRefundEntity.setType(3);
|
////// }else if("微信支付".equals(mallOrderInfo.getPayMethod())){
|
////// mallRefundEntity.setType(1);
|
////// }else{
|
////// mallRefundEntity.setType(3);
|
////// }
|
////// mallRefundEntity.setState(3);
|
////// mallRefundEntity.setAmount(mallOrderItem.getAmount());
|
////// mallRefundMapper.insert(mallRefundEntity);
|
////// }else{
|
////// if(mallRefund.getState() == 2){
|
////// mallRefundEntity.setId(mallRefund.getId());
|
////// mallRefundEntity.setRefundNo(mallRefund.getRefundNo());
|
////// mallRefundEntity.setMemberId(mallRefund.getMemberId());
|
////// mallRefundEntity.setOrderId(mallRefund.getOrderId());
|
////// mallRefundEntity.setItemId(mallRefund.getItemId());
|
////// mallRefundEntity.setType(mallRefund.getType());
|
////// mallRefundEntity.setState(3);
|
////// mallRefundEntity.setAmount(mallRefund.getAmount());
|
////// mallRefundMapper.updateById(mallRefundEntity);
|
////// }
|
////// }
|
////// ApiLeaderRefundOrderDto apiLeaderRefundOrderDto = new ApiLeaderRefundOrderDto();
|
////// apiLeaderRefundOrderDto.setOrderId(mallOrderInfo.getId());
|
////// apiLeaderRefundOrderDto.setItemId(mallOrderItem.getId());
|
////// apiLeaderRefundOrderDto.setAgreeState(1);
|
////// iApiMallTeamLeaderService.leaderRefundOrder(apiLeaderRefundOrderDto);
|
////// }
|
//// }
|
////
|
//// /**
|
//// * 获取小程序菊花码
|
//// * @Description //TODO
|
//// * @Author zhaowx
|
//// * @Date 2020/3/25 15:23
|
//// **/
|
//// @Test
|
//// public void getWXCode() {
|
//// try {
|
//// //这里调用的是上面的获取access_token方法
|
//// String access_token = redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY).toString();
|
//// String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+access_token;
|
//// String scene = "15";
|
//// Map<String, String> param = new HashMap<>();
|
//// param.put("scene",scene);
|
//// //这里的page如果没有的话可以不写,默认是跳主页,如果写了没有的页面的话,会返回错误信息
|
//// param.put("page","pages/product/details");
|
//// String json = JSON.toJSONString(param);
|
//// ByteArrayInputStream inputStream = sendPost(url, json);
|
////
|
//// //这里判断的是返回的图片还是错误信息,一般错误信息不会大于200
|
//// if (inputStream.available() <= 200){
|
//// ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
//// int i;
|
//// byte[] buffer = new byte[200];
|
//// while ((i = inputStream.read(buffer)) != -1){
|
//// byteArrayOutputStream.write(buffer,0,i);
|
//// }
|
//// String str = new String(byteArrayOutputStream.toByteArray());
|
//// //错误信息的格式在官方文档里有
|
//// JSONObject jsonObject = JSONObject.parseObject(str);
|
//// if ("41030".equals(jsonObject.getString("errcode"))){
|
//// System.out.println("所传page页面不存在,或者小程序没有发布");
|
////
|
//// }else if ("45009".equals(jsonObject.getString("errcode"))){
|
//// System.out.println("调用分钟频率受限");
|
//// }
|
//// byteArrayOutputStream.close();
|
//// }
|
//// //输出到本地的代码
|
//// FileOutputStream fileOutputStream = new FileOutputStream("D:/123.png");
|
//// int i;
|
//// byte[] buffer = new byte[10240000];
|
//// while ((i = inputStream.read(buffer)) != -1){
|
//// fileOutputStream.write(buffer,0,i);
|
//// }
|
////
|
//// fileOutputStream.flush();
|
//// fileOutputStream.close();
|
//// inputStream.close();
|
//// }catch (Exception e){
|
//// }
|
//// }
|
////
|
////
|
//// public static ByteArrayInputStream sendPost(String URL, String json) {
|
//// InputStream inputStream = null;
|
//// ByteArrayInputStream byteArrayInputStream = null;
|
//// // 创建默认的httpClient实例.
|
//// CloseableHttpClient httpclient = HttpClients.createDefault();
|
//// // 创建httppost
|
//// HttpPost httppost = new HttpPost(URL);
|
//// httppost.addHeader("Content-type", "application/json; charset=utf-8");
|
//// httppost.setHeader("Accept", "application/json");
|
//// try {
|
//// StringEntity s = new StringEntity(json, Charset.forName("UTF-8"));
|
//// s.setContentEncoding("UTF-8");
|
//// httppost.setEntity(s);
|
//// HttpResponse response = httpclient.execute(httppost);
|
//// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
|
//// // 获取相应实体
|
//// HttpEntity entity = response.getEntity();
|
//// inputStream = entity.getContent();
|
//// ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
//// // 创建一个Buffer字符串
|
//// byte[] buffer = new byte[1024];
|
//// // 每次读取的字符串长度,如果为-1,代表全部读取完毕
|
//// int len = 0;
|
//// // 使用一个输入流从buffer里把数据读取出来
|
//// while ((len = inputStream.read(buffer)) != -1) {
|
//// // 用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
|
//// outStream.write(buffer, 0, len);
|
//// }
|
//// // 关闭输入流
|
//// inputStream.close();
|
//// // 把outStream里的数据写入内存
|
//// byteArrayInputStream = new ByteArrayInputStream(outStream.toByteArray());
|
//// byte[] data = outStream.toByteArray();
|
//// String result = new String(Base64.getEncoder().encode(data));
|
//// result = "data:image/jpeg;base64," + result;
|
//// System.out.println(result);
|
//// }
|
//// } catch (Exception e) {
|
//// e.printStackTrace();
|
//// } finally {
|
//// // 关闭连接,释放资源
|
//// try {
|
//// httpclient.close();
|
//// } catch (IOException e) {
|
//// e.printStackTrace();
|
//// }
|
//// }
|
//// return byteArrayInputStream;
|
//// }
|
////
|
////
|
//// /**
|
//// * 传递自定义参数获取二维码保存后并生成url给前端访问
|
//// * @Author yeafel
|
//// * @param scene
|
//// * @param page
|
//// * @param is_hyaline
|
//// * @param auto_color
|
//// * @return
|
//// */
|
//// @Test
|
//// public void getQrCodeImgUrl() {
|
//// String scene = "pages/product/details";
|
//// String page = "15";
|
//// Boolean is_hyaline = true;
|
//// Boolean auto_color = true;
|
//// RestTemplate restTemplate = new RestTemplate();
|
//// //首先获取ACCESS_TOKEN
|
//// String accessToken = redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY).toString();
|
////
|
//// //然后调用微信官方api生成二维码
|
//// String createQrCodeUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
|
//// //此处我是使用的阿里巴巴的fastJson
|
//// JSONObject createQrParam = new JSONObject();
|
//// createQrParam.put("scene", scene);
|
//// createQrParam.put("page", page);
|
//// createQrParam.put("is_hyaline", is_hyaline);
|
//// createQrParam.put("auto_color", auto_color);
|
////
|
//// PrintWriter out = null;
|
//// InputStream in = null;
|
//// try {
|
//// URL realUrl = new URL(createQrCodeUrl);
|
//// // 打开和URL之间的连接
|
//// URLConnection conn = realUrl.openConnection();
|
//// // 设置通用的请求属性
|
//// conn.setRequestProperty("accept", "*/*");
|
//// conn.setRequestProperty("connection", "Keep-Alive");
|
//// conn.setRequestProperty("user-agent",
|
//// "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
//// // 发送POST请求必须设置如下两行
|
//// conn.setDoOutput(true);
|
//// conn.setDoInput(true);
|
//// // 获取URLConnection对象对应的输出流
|
//// out = new PrintWriter(conn.getOutputStream());
|
//// // 发送请求参数,利用connection的输出流,去写数据到connection中,我的参数数据流出我的电脑内存到connection中,让connection把参数帮我传到URL中去请求。
|
//// out.print(createQrParam);
|
//// // flush输出流的缓冲
|
//// out.flush();
|
//// //获取URL的connection中的输入流,这个输入流就是我请求的url返回的数据,返回的数据在这个输入流中,流入我内存,我将从此流中读取数据。
|
//// in = conn.getInputStream();
|
//// //定义个空字节数组
|
//// byte[] data = null;
|
//// // 读取图片字节数组
|
//// try {
|
//// //创建字节数组输出流作为中转仓库,等待被写入数据
|
//// ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
|
//// byte[] buff = new byte[100];
|
//// int rc = 0;
|
//// while ((rc = in.read(buff, 0, 100)) > 0) {
|
//// //向中转的输出流循环写出输入流中的数据
|
//// swapStream.write(buff, 0, rc);
|
//// }
|
//// //此时connection的输入流返回给我们的请求结果数据已经被完全地写入了我们定义的中转输出流swapStream中
|
//// data = swapStream.toByteArray();
|
//// } catch (IOException e) {
|
//// e.printStackTrace();
|
//// } finally {
|
//// if (in != null) {
|
//// try {
|
//// in.close();
|
//// } catch (IOException e) {
|
//// e.printStackTrace();
|
//// }
|
//// }
|
//// }
|
//// String base64Code = new String(Objects.requireNonNull(Base64.getEncoder().encode(data)));
|
//// //Base64转byte[]数组
|
//// System.out.println(base64Code);
|
//// } catch (Exception e) {
|
//// System.out.println("发送 POST 请求出现异常!" + e);
|
//// e.printStackTrace();
|
//// }
|
////
|
//// // 使用finally块来关闭输出流、输入流
|
//// finally {
|
//// try {
|
//// if (out != null) {
|
//// out.close();
|
//// }
|
//// if (in != null) {
|
//// in.close();
|
//// }
|
//// } catch (IOException ex) {
|
//// ex.printStackTrace();
|
//// }
|
//// }
|
//// }
|
////
|
////
|
//// public static void main(String[] args) {
|
//// BigDecimal amount = new BigDecimal("0.15").setScale(2,BigDecimal.ROUND_DOWN);
|
//// System.out.println(amount);
|
//// }
|
////
|
//// @Test
|
//// public void aaaTest() {
|
////// agentConsumer.vipLevelUp(133L);
|
//// agentConsumer.getScoreMsg(217L);
|
//// }
|
////}
|