package com.nuvole.util.pay.allinPay.yunst;
|
|
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.json.JSONUtil;
|
import com.allinpay.yunst.sdk.YunClient;
|
import com.allinpay.yunst.sdk.bean.YunConfig;
|
import com.allinpay.yunst.sdk.bean.YunRequest;
|
import com.allinpay.yunst.sdk.util.RSAUtil;
|
import com.nuvole.common.domain.dto.AppDTO;
|
import com.nuvole.util.IPUtil;
|
import lombok.extern.slf4j.Slf4j;
|
import org.junit.Before;
|
import org.junit.Test;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
import java.util.Date;
|
import java.util.HashMap;
|
|
/**
|
* 支付工具类(通联云商通)
|
*
|
* @Author: lc
|
* @Date: 2019/10/12 11:49
|
*/
|
@Slf4j
|
public class YunStUtil {
|
|
private Logger logger = LoggerFactory.getLogger(YunStUtil.class);
|
|
//测试
|
/*@Before
|
public void initConfig() {
|
final String serverUrl = "http://116.228.64.55:6900/service/soa";
|
final String sysId = "1906061744156467038";
|
final String pwd = "123456";
|
final String alias = "1906061744156467038";
|
final String path = "C:/Users/Administrator/Desktop/yunst/1906061744156467038/1906061744156467038.pfx";
|
final String tlCertPath = "C:/Users/Administrator/Desktop/yunst/1906061744156467038/TLCert-test.cer";
|
final String version = "2.0";
|
final YunConfig config = new YunConfig(serverUrl, sysId, pwd, alias, version, path, tlCertPath);
|
YunClient.configure(config);
|
}
|
|
@Test
|
public void test() {
|
|
String bizUserId = "lc201910171030"; //用户唯一标识 4806722d-3c3a-4137-bc6f-5982e2759dd5
|
String acct = "oZN135B20y8KIUFMl4GaeRyuFyQ3"; //微信小程序openid
|
String bizOrderNo = "123456789987654322"; //订单编号
|
|
YunStResult yunStResult = new YunStResult();
|
|
System.out.println("is Enter the test.............................创建会员");
|
Long memberType = 3L;
|
Long source = 2L;
|
//创建会员
|
yunStResult = createMember(bizUserId, memberType, source);
|
if ("OK".equals(yunStResult.getStatus())) {
|
log.info("is ok:-------------->");
|
log.info(yunStResult.getSignedValue());
|
} else {
|
log.info("is error:-------------->");
|
log.info(yunStResult.getErrorCode());
|
log.info(yunStResult.getMessage());
|
}
|
|
System.out.println("is The end of the test.......................创建会员");
|
|
|
System.out.println("is Enter the test.............................发送验证码");
|
String phone = "17803846500";
|
Long verificationCodeType = 9L;
|
//创建会员
|
yunStResult = sendVerificationCode(bizUserId, phone, verificationCodeType);
|
if ("OK".equals(yunStResult.getStatus())) {
|
log.info("is ok:-------------->");
|
log.info(yunStResult.getSignedValue());
|
} else {
|
log.info("is error:-------------->");
|
log.info(yunStResult.getErrorCode());
|
log.info(yunStResult.getMessage());
|
}
|
|
System.out.println("is The end of the test.......................发送验证码");
|
|
|
System.out.println("is Enter the test.............................绑定手机");
|
String verificationCode = "544343";
|
//创建会员
|
yunStResult = bindPhone(bizUserId, phone, verificationCode);
|
if ("OK".equals(yunStResult.getStatus())) {
|
log.info("is ok:-------------->");
|
log.info(yunStResult.getSignedValue());
|
} else {
|
log.info("is error:-------------->");
|
log.info(yunStResult.getErrorCode());
|
log.info(yunStResult.getMessage());
|
}
|
|
System.out.println("is The end of the test.......................绑定手机");
|
|
System.out.println("is Enter the test.............................个人实名认证");
|
//创建会员
|
yunStResult = setRealName(bizUserId, "王莉", 1L, "410521199209010565");
|
if ("OK".equals(yunStResult.getStatus())) {
|
log.info("is ok:-------------->");
|
log.info(yunStResult.getSignedValue());
|
} else {
|
log.info("is error:-------------->");
|
log.info(yunStResult.getErrorCode());
|
log.info(yunStResult.getMessage());
|
}
|
|
System.out.println("is The end of the test.......................个人实名认证");
|
|
System.out.println("is Enter the test.............................绑定会员支付账户");
|
|
//绑定会员支付账户
|
String acctType = "weChatMiniProgram";
|
YunStResult yunStResult1 = applyBindAcct(bizUserId, acctType, acct);
|
if ("OK".equals(yunStResult1.getStatus())) {
|
log.info("is ok:-------------->");
|
log.info(yunStResult1.getSignedValue());
|
} else {
|
log.info("is error:-------------->");
|
log.info(yunStResult1.getErrorCode());
|
log.info(yunStResult1.getMessage());
|
}
|
System.out.println("is The end of the test.......................绑定会员支付账户");
|
|
|
System.out.println("is Enter the test.............................个人实名认证");
|
|
//绑定会员支付账户
|
String name = "张三";
|
Long identityType = 1L;
|
String identityNo = "41000000000000000000";
|
|
yunStResult = setRealName(bizUserId, name, identityType, identityNo);
|
if ("OK".equals(yunStResult.getStatus())) {
|
log.info("is ok:-------------->");
|
log.info(yunStResult.getSignedValue());
|
} else {
|
log.info("is error:-------------->");
|
log.info(yunStResult.getErrorCode());
|
log.info(yunStResult.getMessage());
|
}
|
System.out.println("is The end of the test.......................个人实名认证");
|
|
|
System.out.println("is Enter the test.............................请求绑定银行卡");
|
|
//绑定会员支付账户
|
String cardNo = "6228481111111111111";
|
String phone = "17803846500";
|
|
yunStResult = applyBindBankCard(bizUserId, cardNo, phone, name, identityType, identityNo);
|
if ("OK".equals(yunStResult.getStatus())) {
|
log.info("is ok:-------------->");
|
log.info(yunStResult.getSignedValue());
|
} else {
|
log.info("is error:-------------->");
|
log.info(yunStResult.getErrorCode());
|
log.info(yunStResult.getMessage());
|
}
|
System.out.println("is The end of the test.......................请求绑定银行卡");
|
|
|
System.out.println("is Enter the test.............................消费申请");
|
|
|
//绑定会员支付账户
|
String recieverId = "123456";
|
Long validateType = 0L; //交易验签方式【0.无验证 1.短信验证码 2.支付密码】
|
String backUrl = "https://www.baudi.com"; //后台回调地址
|
ConsumeApply consumeApply = new ConsumeApply() {{
|
setPayerId(bizUserId);
|
setRecieverId(recieverId);
|
setBizOrderNo(bizOrderNo);
|
setAmount(1L);
|
setFee(0L);
|
setValidateType(validateType);
|
setBackUrl(backUrl);
|
setSummary("商品交易");
|
}};
|
String vspCusid = "552651058145DRF";
|
String subAppid = "00143623";
|
Long amount = 1L;
|
yunStResult = wechatMiniprogramPay(consumeApply, vspCusid, subAppid, amount, acct);
|
if ("OK".equals(yunStResult.getStatus())) {
|
log.info("is ok:-------------->");
|
log.info(yunStResult.getSignedValue());
|
} else {
|
log.info("is error:-------------->");
|
log.info(yunStResult.getErrorCode());
|
log.info(yunStResult.getMessage());
|
}
|
|
System.out.println("is The end of the test.......................消费申请");
|
|
}*/
|
|
/**
|
* 小程序支付
|
*/
|
/* @Test
|
public void wechatPay() {
|
log.info("<-------------------------this is createMember operation 创建会员 ------------------------->");
|
//创建会员
|
String bizUserId = "tz20200401111"; //普通会员
|
//String shBizUserId = "shanghu001"; //普通会员会员(收款方,已实名)
|
Long memberType = 3L;
|
Long source = 1L;
|
YunStResult result;
|
result = createMember(bizUserId, memberType, source);
|
logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()});
|
|
log.info("<-------------------------this is applyBindAcct operation 会员绑定支付账户用户标识------------------------->");
|
//会员绑定支付账户用户标识(支付账户绑定小程序openId)
|
String bizUserId = "tz20200401111"; //普通会员
|
String acctType = "weChatMiniProgram";
|
String acct = "tm001001";
|
result = applyBindAcct(bizUserId, acctType, acct);
|
logger.info("applyBindAcct result: status={}", new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is wechatMiniprogramPay operation 消费申请------------------------->");
|
//消费申请
|
String bizUserId = "tz20200401111"; //普通会员
|
String recieverId = "shanghu001";
|
Long validateType = 0L; //交易验签方式【0.无验证 1.短信验证码 2.支付密
|
String bizOrderNo = "201200401111212";
|
String backUrl = "https:localhost:8080"; //后台回调地址
|
String acct = "tm001001";
|
ConsumeApply consumeApply = ConsumeApply.builder()
|
.payerId(bizUserId)
|
.recieverId(recieverId)
|
.bizOrderNo(bizOrderNo)
|
.amount(1L)
|
.fee(0L)
|
.validateType(validateType)
|
.backUrl(backUrl)
|
.summary("商品交易").build();
|
String vspCusid = "552651058145DRF";
|
String subAppid = "00143623";
|
Long amount = 1L;
|
result = wechatMiniprogramPay(consumeApply, vspCusid, subAppid, amount, acct);
|
//todo 测试子商户号未提供 通联未反馈
|
logger.info("consumeApply result: status={}, signedValue={}", new Object[]{result.getStatus(), result.getSignedValue()});
|
|
log.info("<-------------------------this is callBack operation 订单结果通知------------------------->");
|
//订单结果通知
|
}*/
|
|
|
/**
|
* 收银宝快捷支付
|
*
|
*/
|
/*@Test
|
public void quickPay() throws Exception {
|
log.info("<-------------------------this is createMember operation 创建会员------------------------->");
|
//创建会员
|
String bizUserId = "tz20200401113"; //普通会员
|
String shBizUserId = "shanghu001"; //普通会员会员(收款方,已实名)
|
Long memberType = 3L;
|
Long source = 1L;
|
YunStResult result;
|
result = createMember(bizUserId, memberType, source);
|
logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()});
|
|
log.info("<-------------------------this is sendVerificationCode operation 发送验证码------------------------->");
|
//发送验证码
|
String bizUserId = "tz20200401111"; //普通会员
|
String phone = "17803846500";
|
Long verificationCodeType = 9L;
|
result = sendVerificationCode(bizUserId, phone, verificationCodeType);
|
logger.info("sendVerificationCode result: status={},message={},signedValue={}",new Object[]{result.getStatus(),result.getMessage(),result.getSignedValue()});
|
|
log.info("<-------------------------this is bindPhone operation 绑定手机------------------------->");
|
//绑定手机
|
String bizUserId = "tz20200401111"; //普通会员
|
String verificationCode = "544343";
|
result = bindPhone(bizUserId, phone, verificationCode);
|
logger.info("bindPhone result: status={}",new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is certification operation 实名认证------------------------->");
|
//实名认证
|
String bizUserId = "tz20200401113"; //普通会员
|
String name = "唐宗旭";
|
Long identityType = 1L;
|
String identityNo = "511521199408143656";
|
result = setRealName(bizUserId, name, identityType, identityNo);
|
logger.info("certification result: status={}",new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is applyBindBankCard operation 申请绑定的银行卡------------------------->");
|
//申请绑定的银行卡(需用真实姓名,手机,身份证,银行卡)
|
String bizUserId = "tz20200401111"; //普通会员
|
String cardNo = "6217853100025227554"; //4结尾卡号返回姓名不匹配
|
String phone = "17723341354";
|
String name = "唐宗旭";
|
Long identityType = 1L;
|
String identityNo = "511521199408143656";
|
result = applyBindBankCard(bizUserId, cardNo, phone, name, identityType, identityNo);
|
logger.info("applyBindBankCard result: status={} , signedValue= {}", new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is bindBankCard operation 确认绑定银行卡------------------------->");
|
//确认绑定银行卡
|
String bizUserId = "tz20200401111"; //普通会员
|
String phone = "17803846500";
|
String tranceNum = "123"; //流水号(请求绑定银行卡接口返回)
|
String transDate = "2019-10-12"; //申请时间(请求绑定银行卡接口返回)
|
String verificationCode = "123";
|
//todo "errorCode":"9000","message":"确认超时或请求号错误,请重新调用绑卡申请接口" 通联未反馈
|
result = bindBankCard(bizUserId,tranceNum,transDate,phone,verificationCode);
|
logger.info("bindBankCard result: status={}", new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is unbindBankCard operation 解除银行卡绑定------------------------->");
|
//解除银行卡绑定(需要时调用)
|
String bizUserId = "tz20200401111"; //普通会员
|
String cardNo = "6230943800000203604";
|
result = unbindBankCard(bizUserId,cardNo);
|
logger.info("unbindBankCard result: status={},message={}",new Object[]{result.getStatus(),result.getMessage()});
|
|
log.info("<-------------------------this is quickPayVsp operation 消费申请(短信验证)------------------------->");
|
String recieverId = "shanghu001";
|
Long validateType = 1L; //交易验签方式【0.无验证 1.短信验证码 2.支付密
|
String bizOrderNo = "201200401111212";
|
Long amount = 1L;
|
Long fee = 1L;
|
String backUrl = "http://localhost:8080";
|
ConsumeApply consumeApply = ConsumeApply.builder()
|
.payerId("tz20200401111")
|
.recieverId("shanghu001")
|
.validateType(1L)
|
.bizOrderNo("201200401111212")
|
.amount(1L)
|
.fee(1L)
|
.backUrl("http://localhost:8080").build();
|
result = quickPayVsp(consumeApply,cardNo);
|
log.info("consumeApply result: status = {},message = {}",new Object[]{result.getStatus(),result.getMessage()});
|
|
log.info("<-------------------------this is pay operation 确认支付(短信+后台验证)------------------------->");
|
|
String bizUserId = "tz20200401111"; //普通会员
|
String bizOrderNo = "201200401111212";
|
String tradeNo = "123";
|
String verificationCode = "123";
|
result = pay(bizUserId,bizOrderNo,tradeNo,verificationCode);
|
log.info("pay result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()});
|
|
log.info("<-------------------------this is getOrderDetail 查询订单状态(确认支付返回处理中时调用)------------------------->");
|
String bizOrderNo = "201200401111212";
|
result = getOrderDetail(bizOrderNo);
|
log.info("getOrderDetail result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()});
|
|
}*/
|
|
/**
|
* 面扫面支付(B扫c)
|
*
|
*/
|
/*@Test
|
public void bussToCustPay(){
|
log.info("<-------------------------this is createMember operation 创建会员------------------------->");
|
//创建会员
|
String bizUserId = "tz20200401111"; //普通会员
|
String shBizUserId = "shanghu001"; //普通会员会员(收款方,已实名)
|
Long memberType = 3L;
|
Long source = 1L;
|
YunStResult result;
|
result = createMember(bizUserId, memberType, source);
|
logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()});
|
|
log.info("<-------------------------this is applyBindAcct operation 会员绑定支付账户用户标识(微信/支付宝/云闪付openId)------------------------->");
|
//会员绑定支付账户用户标识(微信/支付宝/云闪付openId)
|
String bizUserId = "tz20200401111"; //普通会员
|
String acctType = "weChatMiniProgram";
|
String acct = "tm001001";
|
result = applyBindAcct(bizUserId, acctType, acct);
|
logger.info("applyBindAcct result: status={}", new Object[]{result.getStatus(),result.getSignedValue()});
|
|
log.info("<-------------------------this is quickPayVsp operation 消费申请(支付方式:收银宝刷卡支付(被扫)_集团——支持微信、支付宝、银联、手机QQ)------------------------->");
|
String bizUserId = "tz20200401111"; //普通会员
|
String shBizUserId = "shanghu001"; //普通会员会员(收款方,已实名)
|
ConsumeApply consumeApply = ConsumeApply.builder()
|
.payerId(bizUserId)
|
.recieverId(shBizUserId)
|
.bizOrderNo("123231231")
|
.amount(1L)
|
.fee(1L)
|
.validateType(0L)
|
.backUrl("localhost")
|
.build();
|
Long amount = 1L;
|
String authcode = "124316162322111111"; //此处需用真实付款码
|
String vspCusid = "zsh111111";
|
result = doCodePay(consumeApply,vspCusid,amount,authcode);
|
|
log.info("<-------------------------this is getOrderDetail 查询订单状态(确认支付返回处理中时调用)------------------------->");
|
result = getOrderDetail("12312323");
|
log.info("getOrderDetail result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()});
|
|
}*/
|
|
/**
|
* 面对面付款c扫b
|
*/
|
/* @Test
|
public void custToBussPay(){
|
log.info("<-------------------------this is createMember operation 创建会员------------------------->");
|
//创建会员
|
String bizUserId = "tz20200401111"; //普通会员
|
String shBizUserId = "shanghu001"; //普通会员会员(收款方,已实名)
|
Long memberType = 3L;
|
Long source = 1L;
|
YunStResult result;
|
result = createMember(bizUserId, memberType, source);
|
logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()});
|
|
log.info("<-------------------------this is applyBindAcct operation 会员绑定支付账户用户标识(微信/支付宝/云闪付openId)------------------------->");
|
//会员绑定支付账户用户标识(微信/支付宝/云闪付openId)
|
String bizUserId = "tz20200401111"; //普通会员
|
String acctType = "weChatMiniProgram";
|
String acct = "tm001001";
|
result = applyBindAcct(bizUserId, acctType, acct);
|
logger.info("applyBindAcct result: status={}", new Object[]{result.getStatus(),result.getSignedValue()});
|
|
log.info("<-------------------------this is quickPayVsp operation 消费申请(支付方式:收银宝刷卡支付(正扫)_)------------------------->");
|
String bizUserId = "tz20200401111"; //普通会员
|
ConsumeApply consumeApply = ConsumeApply.builder()
|
.payerId(bizUserId)
|
.recieverId(shBizUserId)
|
.bizOrderNo("1232312311")
|
.amount(1L)
|
.fee(1L)
|
.validateType(0L)
|
.backUrl("localhost")
|
.build();
|
Long amount = 1L;
|
String vspCusid = "zsh111111";
|
result = doScanPay(consumeApply,vspCusid,amount,"SCAN_WEIXIN"); //正式环后加_ORG
|
log.info("quickPayVsp result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()});
|
|
log.info("<-------------------------this is getOrderDetail 查询订单状态(入金类交易(使用银行账户资金进行支付),只有订单支付成功情况下才会通知)------------------------->");
|
result = getOrderDetail("12312323");
|
log.info("getOrderDetail result: status={},signedValue={}",new Object[]{result.getStatus(),result.getSignedValue()});
|
}*/
|
|
/**
|
* 企业卖家会员
|
*/
|
/*@Test
|
public void createOrgMember(){
|
log.info("<-------------------------this is createOrgMember operation 创建企业会员------------------------->");
|
String bizUserId = "sh20200401111"; //企业会员
|
Long memberType = 2L;
|
Long source = 2L; //pc端
|
YunStResult result;
|
result = createMember(bizUserId, memberType, source);
|
logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()});
|
|
log.info("<-------------------------this is createOrgMember operation 创建企业会员------------------------->");
|
String bizUserId = "sh20200401111"; //企业会员
|
String backUrl = "localhost"; //通知地址
|
Boolean isAuth = true;
|
MerchantApply merchantApply = MerchantApply.builder()
|
.companyName("company")
|
.authType(2L)
|
.uniCredit("112")
|
.legalName("张三")
|
.identityType(1L)
|
.legalIds("122212121") //RSA加密
|
.legalPhone("13360881231")
|
.accountNo("13360881231") //RSA加密
|
.parentBankName("工商银行")
|
.bankName("中国工商银行股份有限公司北京樱桃园支行") //需是父级直连银行
|
.unionBank("111111111111")//12位数字
|
.build();
|
result = setCompanyInfo(bizUserId,backUrl,isAuth,merchantApply);
|
|
log.info("<-------------------------this is sendVerificationCode operation 发送验证码------------------------->");
|
//发送验证码
|
String bizUserId = "tz20200401111"; //企业会员
|
String phone = "17803846500";
|
Long verificationCodeType = 9L;
|
result = sendVerificationCode(bizUserId, phone, verificationCodeType);
|
logger.info("sendVerificationCode result: status={},message={},signedValue={}",new Object[]{result.getStatus(),result.getMessage(),result.getSignedValue()});
|
|
log.info("<-------------------------this is bindPhone operation 绑定手机------------------------->");
|
//绑定手机
|
String bizUserId = "tz20200401111"; //企业通会员
|
String verificationCode = "544343";
|
result = bindPhone(bizUserId, phone, verificationCode);
|
logger.info("bindPhone result: status={}",new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is signContract operation 会员电子签约------------------------->");
|
|
SignContractApply signContractApply = SignContractApply.builder()
|
.bizUserId("tz20200401113")
|
.jumpUrl("http://www.baidu.com")
|
.backUrl("localhost")
|
.source(2L)
|
.build();
|
String webParamUrl = "http://116.228.64.55:6900/yungateway/member/signContract.html?";
|
String signUrl = signContract(signContractApply,webParamUrl); //以前台 H5 页面形式进行请求
|
System.out.println("signUrl is " + signUrl);
|
}*/
|
|
/**
|
* 个人卖家会员
|
*
|
*/
|
/*@Test
|
public void createSellerMember(){
|
log.info("<-------------------------this is createOrgMember operation 创建个人会员------------------------->");
|
String bizUserId = "sh20200401111"; //企业会员
|
Long memberType = 3L;
|
Long source = 2L; //pc端
|
YunStResult result;
|
result = createMember(bizUserId, memberType, source);
|
logger.info("createMember result: status={},message={},signedValue={}", new Object[]{result.getStatus(), result.getMessage(), result.getSignedValue()});
|
|
log.info("<-------------------------this is sendVerificationCode operation 发送验证码------------------------->");
|
//发送验证码
|
String bizUserId = "tz20200401111"; //普通会员
|
String phone = "17803846500";
|
Long verificationCodeType = 9L;
|
result = sendVerificationCode(bizUserId, phone, verificationCodeType);
|
logger.info("sendVerificationCode result: status={},message={},signedValue={}",new Object[]{result.getStatus(),result.getMessage(),result.getSignedValue()});
|
|
log.info("<-------------------------this is bindPhone operation 绑定手机------------------------->");
|
//绑定手机
|
String bizUserId = "tz20200401111"; //普通会员
|
String verificationCode = "544343";
|
result = bindPhone(bizUserId, phone, verificationCode);
|
logger.info("bindPhone result: status={}",new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is certification operation 实名认证------------------------->");
|
//实名认证
|
String bizUserId = "tz20200401113"; //普通会员
|
String name = "唐宗旭";
|
Long identityType = 1L;
|
String identityNo = "511521199408143656";
|
result = setRealName(bizUserId, name, identityType, identityNo);
|
logger.info("certification result: status={}",new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is applyBindBankCard operation 申请绑定的银行卡------------------------->");
|
//申请绑定的银行卡(需用真实姓名,手机,身份证,银行卡)
|
String bizUserId = "tz20200401111"; //普通会员
|
String cardNo = "6217853100025227554"; //4结尾卡号返回姓名不匹配
|
String phone = "17723341354";
|
String name = "唐宗旭";
|
Long identityType = 1L;
|
String identityNo = "511521199408143656";
|
result = applyBindBankCard(bizUserId, cardNo, phone, name, identityType, identityNo);
|
logger.info("applyBindBankCard result: status={} , signedValue= {}", new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is bindBankCard operation 确认绑定银行卡------------------------->");
|
//确认绑定银行卡
|
String bizUserId = "tz20200401111"; //普通会员
|
String phone = "17803846500";
|
String tranceNum = "123"; //流水号(请求绑定银行卡接口返回)
|
String transDate = "2019-10-12"; //申请时间(请求绑定银行卡接口返回)
|
String verificationCode = "123";
|
//todo "errorCode":"9000","message":"确认超时或请求号错误,请重新调用绑卡申请接口" 通联未反馈
|
result = bindBankCard(bizUserId,tranceNum,transDate,phone,verificationCode);
|
logger.info("bindBankCard result: status={}", new Object[]{result.getStatus()});
|
|
log.info("<-------------------------this is queryBankCard operation 查询绑定银行卡------------------------->");
|
String bizUserId = "tz20200401111";
|
String cardNo = null; //为空则查询所有银行卡
|
result = queryBankCard(bizUserId,cardNo);
|
|
|
log.info("<-------------------------this is unbindBankCard operation 解除银行卡绑定------------------------->");
|
//解除银行卡绑定(需要时调用)
|
String bizUserId = "tz20200401111"; //普通会员
|
String cardNo = "6230943800000203604";
|
result = unbindBankCard(bizUserId,cardNo);
|
logger.info("unbindBankCard result: status={},message={}",new Object[]{result.getStatus(),result.getMessage()});
|
|
log.info("<-------------------------this is signContract operation 会员电子签约------------------------->");
|
|
SignContractApply signContractApply = SignContractApply.builder()
|
.bizUserId("tz20200401113")
|
.jumpUrl("http://www.baidu.com")
|
.backUrl("localhost")
|
.source(2L)
|
.build();
|
String webParamUrl = "http://116.228.64.55:6900/yungateway/member/signContract.html?";
|
String signUrl = signContract(signContractApply,webParamUrl); //以前台 H5 页面形式进行请求
|
System.out.println("signUrl is " + signUrl);
|
}*/
|
|
|
/**
|
* 会员电子签约
|
*
|
* @param signContractApply
|
* @return
|
*
|
*/
|
public static String signContract(SignContractApply signContractApply, String webParamUrl) {
|
final YunRequest request = new YunRequest("MemberService", "signContract");
|
request.put("bizUserId", signContractApply.getBizUserId());
|
request.put("jumpUrl", signContractApply.getJumpUrl());
|
request.put("backUrl", signContractApply.getBackUrl());
|
request.put("source", signContractApply.getSource());
|
try {
|
webParamUrl += YunClient.encodeOnce(request);
|
return webParamUrl;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 创建会员
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param memberType 会员类型 [2.企业会员 3.个人会员]
|
* @param source 访问终端类型[1.mobile 2.pc]
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult createMember(String bizUserId, Long memberType, Long source) {
|
final YunRequest request = new YunRequest("MemberService", "createMember");
|
request.put("bizUserId", bizUserId);
|
request.put("memberType", memberType);
|
request.put("source", source);
|
try {
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 会员绑定支付账户用户标识
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param acctType 支付账户类型【weChatPublic:微信公众号 weChatMiniProgram:微信小程序 aliPayService:支付宝生活号】
|
* @param acct 支付账户用户标识【微信公众号openid/微信小程序openid/支付宝生活号user_id 】
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult applyBindAcct(String bizUserId, String acctType, String acct) {
|
final YunRequest request = new YunRequest("MemberService", "applyBindAcct");
|
request.put("bizUserId", bizUserId);
|
request.put("operationType", "set");
|
request.put("acctType", acctType);
|
request.put("acct", acct);
|
try {
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 发送短信验证码
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param phone 手机号码
|
* @param verificationCodeType 验证码类型[9-绑定手机 6-解绑手机]
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult sendVerificationCode(String bizUserId, String phone, Long verificationCodeType) {
|
final YunRequest request = new YunRequest("MemberService", "sendVerificationCode");
|
request.put("bizUserId", bizUserId);
|
request.put("phone", phone);
|
request.put("verificationCodeType", verificationCodeType);
|
try {
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 绑定手机
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param phone 手机号码
|
* @param verificationCode 验证码
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult bindPhone(String bizUserId, String phone, String verificationCode) {
|
final YunRequest request = new YunRequest("MemberService", "bindPhone");
|
request.put("bizUserId", bizUserId);
|
request.put("phone", phone);
|
request.put("verificationCode", verificationCode);
|
try {
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 个人实名认证
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param name 姓名
|
* @param identityType 证件类型【1.身份证 2.护照 3.军官证 4.回乡证 5.台胞证 6.警官证 7.士兵证 99.其他证件】
|
* @param identityNo 证件号码
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult setRealName(String bizUserId, String name, Long identityType, String identityNo) {
|
final YunRequest request = new YunRequest("MemberService", "setRealName");
|
try {
|
request.put("bizUserId", bizUserId);
|
request.put("name", name);
|
request.put("identityType", identityType);
|
request.put("identityNo", RSAUtil.encrypt(identityNo));
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 请求绑定银行卡
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param cardNo 银行卡号
|
* @param phone 银行预留手机
|
* @param name 姓名
|
* @param identityType 证件类型【1.身份证 2.护照 3.军官证 4.回乡证 5.台胞证 6.警官证 7.士兵证 99.其他证件】
|
* @param identityNo 证件号码
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult applyBindBankCard(String bizUserId, String cardNo, String phone, String name, Long identityType, String identityNo) {
|
final YunRequest request = new YunRequest("MemberService", "applyBindBankCard");
|
try {
|
request.put("bizUserId", bizUserId);
|
request.put("cardNo", RSAUtil.encrypt(cardNo));
|
request.put("cardNo", YunClient.encrypt(cardNo));
|
request.put("phone", phone);
|
request.put("name", name);
|
request.put("cardCheck", 7L); //默认7L快捷支付
|
request.put("identityType", identityType);
|
request.put("identityNo", RSAUtil.encrypt(identityNo));
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 确认绑定银行卡
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param tranceNum 流水号
|
* @param transDate 申请时间
|
* @param phone 银行预留手机
|
* @param verificationCode 手机验证码
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult bindBankCard(String bizUserId, String tranceNum, String transDate, String phone, String verificationCode) {
|
final YunRequest request = new YunRequest("MemberService", "bindBankCard");
|
try {
|
request.put("bizUserId", bizUserId);
|
request.put("tranceNum", tranceNum);
|
request.put("transDate", transDate);
|
request.put("phone", phone);
|
request.put("verificationCode", verificationCode);
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
public static YunStResult queryBankCard(String bizUserId, String cardNo){
|
final YunRequest request = new YunRequest("MemberService","queryBankCard");
|
try {
|
if (StrUtil.isNotEmpty(cardNo)){
|
RSAUtil.encrypt(cardNo);
|
};
|
request.put("bizUserId",bizUserId);
|
request.put("cardNo",cardNo);
|
return JSONUtil.toBean(YunClient.request(request),YunStResult.class);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 解除绑定银行卡
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param cardNo 银行卡号
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult unbindBankCard(String bizUserId, String cardNo) {
|
final YunRequest request = new YunRequest("MemberService", "unbindBankCard");
|
try {
|
request.put("bizUserId", bizUserId);
|
request.put("cardNo", RSAUtil.encrypt(cardNo));
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 设置企业会员信息(暂时不用)
|
*
|
* @param bizUserId:用户标识(用户主键id)
|
* @param backUrl:企业会员审核结果通知url
|
* @param isAuth:是否进行线上认证
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult setCompanyInfo(String bizUserId, String backUrl, Boolean isAuth, MerchantApply merchantApply) {
|
final YunRequest request = new YunRequest("MemberService", "setCompanyInfo");
|
try {
|
merchantApply.setLegalIds(RSAUtil.encrypt(merchantApply.getLegalIds()));
|
merchantApply.setAccountNo(RSAUtil.encrypt(merchantApply.getAccountNo()));
|
request.put("companyBasicInfo", merchantApply);
|
request.put("bizUserId", bizUserId);
|
request.put("backUrl", backUrl);
|
request.put("isAuth", isAuth);
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 消费申请(收银宝快捷支付)
|
*
|
* @param consumeApply:消费公共实体
|
* @param bankCardNo:银行卡号
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult quickPayVsp(ConsumeApply consumeApply, String bankCardNo) throws Exception {
|
final YunRequest request = new YunRequest("OrderService", "consumeApply");
|
|
HashMap<String, Object> params = new HashMap<>();
|
params.put("limitPay", "no_credit");
|
params.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
|
|
// 组装支付方式
|
HashMap<String, Object> payMethod = new HashMap<>();
|
payMethod.put("QUICKPAY_VSP", params);
|
|
request.put("payerId", consumeApply.getPayerId());
|
request.put("recieverId", consumeApply.getRecieverId());
|
request.put("bizOrderNo", consumeApply.getBizOrderNo());
|
request.put("amount", consumeApply.getAmount());
|
request.put("fee", consumeApply.getFee());
|
request.put("validateType", consumeApply.getValidateType());
|
request.put("backUrl", consumeApply.getBackUrl());
|
request.put("orderExpireDatetime", consumeApply.getOrderExpireDatetime());
|
request.put("payMethod", payMethod);
|
request.put("industryCode", YunStParam.industryCode);
|
request.put("industryName", YunStParam.industryName);
|
request.put("source", YunStParam.source);
|
request.put("summary", consumeApply.getSummary());
|
request.put("extendInfo", consumeApply.getExtendInfo());
|
request.put("splitRule", consumeApply.getSplitRule());
|
try {
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 确认支付(后台+短信验证码确认)
|
*
|
* @param bizUserId 用户标识(用户主键id)
|
* @param bizOrderNo 订单编号(支付订单)
|
* @param tradeNo 交易编号
|
* @param verificationCode 短信验证码
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult pay(String bizUserId, String bizOrderNo, String tradeNo, String verificationCode) {
|
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
// HttpServletRequest req = requestAttributes.getRequest();
|
// String ipAddress = IPUtil.getIpAddr(req); //正式环境传用户ip
|
final YunRequest request = new YunRequest("OrderService", "pay");
|
try {
|
request.put("bizUserId", bizUserId);
|
request.put("bizOrderNo", bizOrderNo);
|
request.put("tradeNo", tradeNo);
|
request.put("verificationCode", verificationCode);
|
request.put("bizOrderNo", bizOrderNo);
|
request.put("consumerIp", IPUtil.getLocalHostIp()); //ip地址
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 查询订单状态
|
*
|
* @param bizOrderNo 订单编号(支付订单)
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult getOrderDetail(String bizOrderNo) {
|
final YunRequest request = new YunRequest("OrderService", "getOrderDetail");
|
try {
|
request.put("bizOrderNo", bizOrderNo);
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 消费申请(微信小程序)
|
*
|
* @param consumeApply:消费公共实体
|
* @param vspCusid:收银宝子商户号
|
* @param subAppid:微信小程序支付appid参数
|
* @param amount:支付金额,单位:分
|
* @param acct:微信JS支付openid——微信分配
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult wechatMiniprogramPay(ConsumeApply consumeApply, String vspCusid, String subAppid, Long amount, String acct) {
|
final YunRequest request = new YunRequest("OrderService", "consumeApply");
|
|
HashMap<String, Object> params = new HashMap<>();
|
params.put("vspCusid", vspCusid);
|
params.put("subAppid", subAppid); //正式环境请必传
|
params.put("limitPay", "no_credit");
|
params.put("amount", amount);
|
params.put("acct", acct);
|
|
// 组装支付方式
|
HashMap<String, Object> payMethod = new HashMap<>();
|
//payMethod.put("WECHATPAY_MINIPROGRAM", params); //测试
|
payMethod.put("WECHATPAY_MINIPROGRAM_ORG", params); //正式集团版
|
|
request.put("payerId", consumeApply.getPayerId());
|
request.put("recieverId", consumeApply.getRecieverId());
|
request.put("bizOrderNo", consumeApply.getBizOrderNo());
|
request.put("amount", consumeApply.getAmount());
|
request.put("fee", consumeApply.getFee());
|
request.put("validateType", consumeApply.getValidateType());
|
request.put("backUrl", consumeApply.getBackUrl());
|
request.put("orderExpireDatetime", consumeApply.getOrderExpireDatetime());
|
request.put("payMethod", payMethod);
|
request.put("industryCode", YunStParam.industryCode);
|
request.put("industryName", YunStParam.industryName);
|
request.put("source", YunStParam.source);
|
request.put("summary", consumeApply.getSummary());
|
request.put("extendInfo", consumeApply.getExtendInfo());
|
request.put("splitRule", consumeApply.getSplitRule());
|
try {
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 消费申请(B扫C 用户被扫)
|
*
|
* @param consumeApply:消费公共实体
|
* @param vspCusid:收银宝子商户号
|
* @param amount:支付金额,单位:分
|
* @param authcode:支付授权码(用户出示的二维码)
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult doCodePay(ConsumeApply consumeApply, String vspCusid, Long amount, String authcode) {
|
final YunRequest request = new YunRequest("OrderService", "consumeApply");
|
|
HashMap<String, Object> params = new HashMap<>();
|
params.put("amount", amount);
|
params.put("vspCusid", vspCusid);
|
params.put("authcode", authcode);
|
params.put("limitPay", "no_credit");
|
|
// 组装支付方式
|
HashMap<String, Object> payMethod = new HashMap<>();
|
payMethod.put("CODEPAY_VSP", params);
|
//payMethod.put("CODEPAY_VSP_ORG", params); //正式集团版
|
|
request.put("payerId", consumeApply.getPayerId());
|
request.put("recieverId", consumeApply.getRecieverId());
|
request.put("bizOrderNo", consumeApply.getBizOrderNo());
|
request.put("amount", consumeApply.getAmount());
|
request.put("fee", consumeApply.getFee());
|
request.put("validateType", consumeApply.getValidateType());
|
request.put("backUrl", consumeApply.getBackUrl());
|
request.put("orderExpireDatetime", consumeApply.getOrderExpireDatetime());
|
request.put("payMethod", payMethod);
|
request.put("industryCode", YunStParam.industryCode);
|
request.put("industryName", YunStParam.industryName);
|
request.put("source", YunStParam.source);
|
request.put("summary", consumeApply.getSummary());
|
request.put("extendInfo", consumeApply.getExtendInfo());
|
request.put("splitRule", consumeApply.getSplitRule());
|
try {
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 消费申请(C扫B 用户主扫)
|
*
|
* @param consumeApply:消费公共实体
|
* @param vspCusid:收银宝子商户号
|
* @param amount:支付金额,单位:分
|
* @param acctType:支付账户类型【SCAN_WEIXIN_ORG:微信 SCAN_ALIPAY_ORG:支付宝 SCAN_UNIONPAY_ORG:银联云闪付】 测试环境不带_ORG
|
* @Author: lc
|
* @Date: 2019/10/14 16:12
|
*/
|
public static YunStResult doScanPay(ConsumeApply consumeApply, String vspCusid, Long amount, String acctType) {
|
final YunRequest request = new YunRequest("OrderService", "consumeApply");
|
|
HashMap<String, Object> params = new HashMap<>();
|
params.put("vspCusid", vspCusid);
|
params.put("amount", amount);
|
params.put("limitPay", "no_credit");
|
|
// 组装支付方式
|
HashMap<String, Object> payMethod = new HashMap<>();
|
payMethod.put(acctType, params);
|
|
request.put("payerId", consumeApply.getPayerId());
|
request.put("recieverId", consumeApply.getRecieverId());
|
request.put("bizOrderNo", consumeApply.getBizOrderNo());
|
request.put("amount", consumeApply.getAmount());
|
request.put("fee", consumeApply.getFee());
|
request.put("validateType", consumeApply.getValidateType());
|
request.put("backUrl", consumeApply.getBackUrl());
|
request.put("orderExpireDatetime", consumeApply.getOrderExpireDatetime());
|
request.put("payMethod", payMethod);
|
request.put("industryCode", YunStParam.industryCode);
|
request.put("industryName", YunStParam.industryName);
|
request.put("source", YunStParam.source);
|
request.put("summary", consumeApply.getSummary());
|
request.put("extendInfo", consumeApply.getExtendInfo());
|
request.put("splitRule", consumeApply.getSplitRule());
|
try {
|
return JSONUtil.toBean(YunClient.request(request), YunStResult.class);
|
} catch (final Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
}
|