|
@@ -10,9 +10,13 @@ import cn.hutool.crypto.symmetric.DES;
|
|
|
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
|
|
|
import cn.hutool.crypto.symmetric.SymmetricCrypto;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.parser.Feature;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.eptok.yspay.opensdkjava.fund.BankAuthorityApi;
|
|
|
import com.eptok.yspay.opensdkjava.fund.MercFundApi;
|
|
|
import com.eptok.yspay.opensdkjava.pojo.vo.OnlineReqDataVo;
|
|
|
import com.eptok.yspay.opensdkjava.util.Base64Utils;
|
|
@@ -28,6 +32,7 @@ import com.qs.mp.admin.service.ICouponChannelService;
|
|
|
import com.qs.mp.admin.service.ICouponService;
|
|
|
import com.qs.mp.admin.service.ICouponTicketService;
|
|
|
import com.qs.mp.admin.service.IGoodsCardService;
|
|
|
+import com.qs.mp.common.constant.YsServerApiConstants;
|
|
|
import com.qs.mp.common.core.redis.DistributedLocker;
|
|
|
import com.qs.mp.common.core.redis.RedisCache;
|
|
|
import com.qs.mp.common.enums.UserTypeEnum;
|
|
@@ -48,6 +53,7 @@ import com.qs.mp.system.service.id.BizIdGenerator;
|
|
|
import com.qs.mp.user.domain.MarketingUserCode;
|
|
|
import com.qs.mp.user.service.IMarketingUserCodeService;
|
|
|
import com.qs.mp.utils.SecurityUtils;
|
|
|
+import com.taobao.api.Constants;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -69,6 +75,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@SpringBootTest
|
|
|
public class MyTest {
|
|
|
+
|
|
|
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
|
|
@@ -126,9 +133,57 @@ public class MyTest {
|
|
|
@Value("${ys-pay.private-key-path}")
|
|
|
private String privateKeyPath;
|
|
|
|
|
|
+ @Value("${ys-pay.public-key-path}")
|
|
|
+ private String publicKeyPath;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提现测试方法
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void test20() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void test19() {
|
|
|
+ // 调用接口校验
|
|
|
+ OnlineReqDataVo req = new OnlineReqDataVo();
|
|
|
+ req.setReqUrl(YsServerApiConstants.OPEN_API);
|
|
|
+ req.setPartnerId(partnerId);
|
|
|
+ req.setPrivateKeyFilePath(privateKeyPath);
|
|
|
+ req.setYsPublicKeyFilePath(publicKeyPath);
|
|
|
+ req.setPrivateKeyPassword(privateKeyPass);
|
|
|
+
|
|
|
+ //银行实名认证三要素下单业务参数
|
|
|
+ Map<String, Object> bizContent = new HashMap<>();
|
|
|
+ String tradeNo = DateUtil.getDateNowYmd() + DateUtil.getRandom(14);
|
|
|
+ //商户生成的订单号,生成规则前8位必须为交易日期,如20180525,范围跨度支持包含当天在内的前后一天
|
|
|
+ bizContent.put("out_trade_no", tradeNo);
|
|
|
+ //商户日期(该参数做交易与查询时需要一致)该日期需在当日的前后一天时间范围之内
|
|
|
+ bizContent.put("shopdate", DateUtil.getDateNowYmd());
|
|
|
+ //实名认证姓名--请填写真实信息
|
|
|
+ bizContent.put("bank_account_name", "张三");
|
|
|
+ //银行帐号,支持对公对私
|
|
|
+ bizContent.put("bank_account_no", "6212260488888888888");
|
|
|
+ //证件号码,目前只支持身份证
|
|
|
+ bizContent.put("id_card", "41022319940916602X");
|
|
|
+ req.setParamData(bizContent);
|
|
|
+
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ logger.info("银行实名认证三要素调用sdk接口addScanMerc请求入参为:" + JSONObject.toJSONString(req));
|
|
|
+ //根据返回结果处理自己的业务逻辑,result内容详见接口文档
|
|
|
+ result = BankAuthorityApi.sendBankAuthThreePrecise(req);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.info("银行实名认证三要素失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ System.out.println("result = " + result);
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void test18() {
|
|
|
- walletService.h5Pay(null,"0239021091223",100,"测试测试测试");
|
|
|
+ walletService.h5Pay(null, "0239021091224323", 100, "测试测试测试");
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -154,47 +209,59 @@ public class MyTest {
|
|
|
bizContent.put("merchant_usercode", partnerId);//商户号
|
|
|
req.setParamData(bizContent);
|
|
|
String result = null;
|
|
|
- try{
|
|
|
- logger.info("账户余额查询调用sdk接口addScanMerc请求入参为:"+ JSONObject.toJSONString(req));
|
|
|
+ try {
|
|
|
+ logger.info("账户余额查询调用sdk接口addScanMerc请求入参为:" + JSONObject.toJSONString(req));
|
|
|
//根据返回结果处理自己的业务逻辑,result内容详见接口文档
|
|
|
result = MercFundApi.getFundAccount(req);
|
|
|
- }catch (Exception e){
|
|
|
- logger.info("账户余额查询失败:"+ e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.info("账户余额查询失败:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 实名认证测试方法
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
@Test
|
|
|
void test16() throws Exception {
|
|
|
|
|
|
- Map<String,String> mapData = new HashMap<>();
|
|
|
+ Map<String, String> mapData = new HashMap<>();
|
|
|
mapData.put("partner_id", partnerId);
|
|
|
- mapData.put("method","ysepay.authenticate.three.key.element.precise");
|
|
|
+ mapData.put("method", "ysepay.authenticate.three.key.element.precise");
|
|
|
mapData.put("timestamp", DateUtil.getDateNow());
|
|
|
mapData.put("sign_type", "RSA");
|
|
|
mapData.put("charset", "utf-8");
|
|
|
mapData.put("version", "3.0");
|
|
|
- mapData.put("notify_url","http://127.0.0.1");
|
|
|
// mapData.put("out_trade_no", "202003276843192280647119");
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("out_trade_no", DateUtil.getDateNowYmd() + DateUtil.getRandom(6));
|
|
|
- json.put("shopdate","20200328");
|
|
|
- json.put("bank_account_name", "张三");
|
|
|
+ json.put("shopdate", DateUtil.getDateNowYmd());
|
|
|
+ json.put("bank_account_name", "蒋浩");
|
|
|
json.put("bank_account_no", "6212260488888888888");
|
|
|
- json.put("id_card", SrcDesUtil.encryptData("ecolosha","41022319940916602X"));
|
|
|
- mapData.put("biz_content",json.toString());
|
|
|
+ json.put("id_card", SrcDesUtil.encryptData(partnerId, "331081199909124619"));
|
|
|
+ mapData.put("biz_content", json.toString());
|
|
|
//参数签名
|
|
|
- try{
|
|
|
- String mp1688 = YsfSignUtil.sign(mapData, "/Users/cup/Downloads/ysPayPre.pfx",privateKeyPass);
|
|
|
- System.out.println("mp1688 = " + mp1688);
|
|
|
- mapData.put("sign", mp1688);
|
|
|
-
|
|
|
- } catch (Exception e){
|
|
|
+ try {
|
|
|
+ String sign = YsOnlineSignUtils.sign(mapData, privateKeyPass, privateKeyPath);
|
|
|
+ mapData.put("sign", sign);
|
|
|
+ System.out.println("sign = " + sign);
|
|
|
+ } catch (Exception e) {
|
|
|
System.err.println("签名异常" + e);
|
|
|
}
|
|
|
|
|
|
- String post = OkHttpUtil.post("https://openapi.ysepay.com/gateway.do", mapData);
|
|
|
- System.out.println("返回" + post);
|
|
|
+ String result = OkHttpUtil.post("https://openapi.ysepay.com/gateway.do", mapData);
|
|
|
+
|
|
|
+ // 结果验签
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result, Feature.OrderedField);
|
|
|
+ // 加签内容
|
|
|
+ String content = JSONObject.toJSONString(
|
|
|
+ jsonObject.get("ysepay_authenticate_three_key_element_precise_response"),
|
|
|
+ SerializerFeature.WriteMapNullValue);
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println("返回" + result);
|
|
|
+ System.out.println("content = " + content);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -206,7 +273,7 @@ public class MyTest {
|
|
|
|
|
|
@Test
|
|
|
void test14() {
|
|
|
- distributedLocker.tryLock("goods_card_lock_key_466",0,-1, TimeUnit.SECONDS);
|
|
|
+ distributedLocker.tryLock("goods_card_lock_key_466", 0, -1, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -233,9 +300,9 @@ public class MyTest {
|
|
|
|
|
|
|
|
|
@Test
|
|
|
- void test10(){
|
|
|
+ void test10() {
|
|
|
for (int i = 0; i < 1; i++) {
|
|
|
- couponService.distributeByMarketing(188L,"56");
|
|
|
+ couponService.distributeByMarketing(188L, "56");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -250,7 +317,7 @@ public class MyTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void test8(){
|
|
|
+ void test8() {
|
|
|
dayStatTask.stat("20220713");
|
|
|
}
|
|
|
|
|
@@ -265,34 +332,34 @@ public class MyTest {
|
|
|
|
|
|
|
|
|
@Test
|
|
|
- void test6(){
|
|
|
+ void test6() {
|
|
|
// List<MarketingUserCode> userCodeList = marketingUserCodeService.list(new LambdaQueryWrapper<MarketingUserCode>()
|
|
|
// .select(MarketingUserCode::getUserId)
|
|
|
// .eq(MarketingUserCode::getMarketingId, 102)
|
|
|
//// .eq(MarketingUserCode::getUserType, UserTypeEnum.ORDINARY.getValue())
|
|
|
// .groupBy(MarketingUserCode::getUserId));
|
|
|
List<MarketingUserCode> userCodeList = marketingUserCodeService.list(new LambdaQueryWrapper<MarketingUserCode>()
|
|
|
- .select(MarketingUserCode::getUserId)
|
|
|
- .eq(MarketingUserCode::getUserType, UserTypeEnum.ORDINARY.getValue())
|
|
|
- .groupBy(MarketingUserCode::getUserId));
|
|
|
+ .select(MarketingUserCode::getUserId)
|
|
|
+ .eq(MarketingUserCode::getUserType, UserTypeEnum.ORDINARY.getValue())
|
|
|
+ .groupBy(MarketingUserCode::getUserId));
|
|
|
userCodeList.forEach(System.out::println);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void test5() {
|
|
|
- Set<String> testSet =new HashSet<>();
|
|
|
+ Set<String> testSet = new HashSet<>();
|
|
|
testSet.add("test1");
|
|
|
testSet.add("test2");
|
|
|
testSet.add("test3");
|
|
|
testSet.add("test4");
|
|
|
- redisCache.setCacheSet("testSet",testSet);
|
|
|
+ redisCache.setCacheSet("testSet", testSet);
|
|
|
List<Object> list = new ArrayList<>();
|
|
|
list.add("test1");
|
|
|
list.add("test3");
|
|
|
list.add("test5");
|
|
|
list.add("test6");
|
|
|
list.add("test7");
|
|
|
- redisCache.removeSetValueByKey("testSet",list);
|
|
|
+ redisCache.removeSetValueByKey("testSet", list);
|
|
|
|
|
|
|
|
|
}
|
|
@@ -311,7 +378,7 @@ public class MyTest {
|
|
|
// wxSubscribeMessage.sendMarketingHelp(188L, marketing);
|
|
|
// wxSubscribeMessage.sendMarketingHelp(79L, marketing);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Test
|
|
|
void test2() throws IOException {
|
|
|
marketingTask.lottery();
|
|
@@ -319,7 +386,7 @@ public class MyTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void test3(){
|
|
|
+ void test3() {
|
|
|
for (int i = 0; i < 20; i++) {
|
|
|
System.out.println("bizIdGenerator = " + bizIdGenerator.newId());
|
|
|
}
|
|
@@ -327,10 +394,9 @@ public class MyTest {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Test
|
|
|
- void test1(){
|
|
|
- walletService.refund("968527112497659906",10,"测试");
|
|
|
+ void test1() {
|
|
|
+ walletService.refund("968527112497659906", 10, "测试");
|
|
|
}
|
|
|
|
|
|
}
|