Browse Source

接入新账通支付

multiwx
dy-hu 2 months ago
parent
commit
c9086999b6
  1. 6
      cereshop-app/pom.xml
  2. 80
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/extend/HnaPayController.java
  3. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/business/CerePlatformBusinessDAO.java
  4. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/param/order/OrderParam.java
  5. 22
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/domain/DivideAcctDtlVo.java
  6. 205
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/BaseTransForm.java
  7. 38
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/F001TransForm.java
  8. 36
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q001TransForm.java
  9. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q002TransForm.java
  10. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q003TransForm.java
  11. 40
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q004TransForm.java
  12. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q006TransForm.java
  13. 41
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q007TransForm.java
  14. 36
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q008TransForm.java
  15. 38
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q009TransForm.java
  16. 47
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R001TransForm.java
  17. 43
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R002TransForm.java
  18. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R003TransForm.java
  19. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R004TransForm.java
  20. 44
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R007TransForm.java
  21. 38
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R008TransForm.java
  22. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R009TransForm.java
  23. 39
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R010TransForm.java
  24. 40
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R011TransForm.java
  25. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R012TransForm.java
  26. 39
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R013TransForm.java
  27. 36
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R014TransForm.java
  28. 43
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R015TransForm.java
  29. 41
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T002TransForm.java
  30. 39
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T003TransForm.java
  31. 43
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T004TransForm.java
  32. 45
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T005TransForm.java
  33. 58
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T006TransForm.java
  34. 55
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T007TransForm.java
  35. 45
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T008TransForm.java
  36. 53
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T009TransForm.java
  37. 52
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T010TransForm.java
  38. 38
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T011TransForm.java
  39. 36
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T012TransForm.java
  40. 48
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T013TransForm.java
  41. 41
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T019TransForm.java
  42. 54
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T020TransForm.java
  43. 40
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T021TransForm.java
  44. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T022TransForm.java
  45. 815
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/init/InitForm.java
  46. 23
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/service/HnaPayService.java
  47. 378
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/service/impl/HnaPayServiceImpl.java
  48. 61
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/Base64Util.java
  49. 102
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HexStringByte.java
  50. 195
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HnaPayDateUtils.java
  51. 167
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HnapaySign.java
  52. 148
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HttpClientUtils.java
  53. 114
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HttpUtils.java
  54. 211
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HttpsTransport.java
  55. 82
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/JsonUtils.java
  56. 32
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/KeyUtils.java
  57. 105
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/RSAAlgorithms.java
  58. 4
      cereshop-app/src/main/resources/mybatis/mapper/business/CerePlatformBusinessDAO.xml
  59. 62
      cereshop-commons/src/main/java/com/shop/cereshop/commons/config/HnaPayConfig.java
  60. 2
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/business/CerePlatformBusiness.java

6
cereshop-app/pom.xml

@ -80,6 +80,12 @@
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
<profiles>

80
cereshop-app/src/main/java/com/shop/cereshop/app/controller/extend/HnaPayController.java

@ -0,0 +1,80 @@
package com.shop.cereshop.app.controller.extend;
import com.alibaba.fastjson.JSONObject;
import com.shop.cereshop.app.pay.hnapay.service.HnaPayService;
import com.shop.cereshop.app.pay.xs.domain.XsCallBackRequestVo;
import com.shop.cereshop.app.pay.xs.service.XsPayService;
import com.shop.cereshop.app.service.order.CereShopOrderService;
import com.shop.cereshop.commons.utils.EmptyUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 描述新生支付新账通回调处理
*
* @author stevenhu
* @version 2025/02/14 9:24
*/
@RestController
@RequestMapping("extend/hnaPay")
@Slf4j(topic = "hnaPayController")
@Api(value = "新账通模块", tags = "新账通模块")
public class HnaPayController {
@Autowired
private HnaPayService hnaPayService;
@Autowired
private CereShopOrderService cereShopOrderService;
/**
* 支付通知回调
* @param msg
* @return
* @throws Exception
*/
@PostMapping("pay/notify")
public String payNotify(@RequestParam(name = "msg") String msg) throws Exception {
try {
XsCallBackRequestVo xsCallBackRequestVo = hnaPayService.parseCallBackRequestVo(msg);
String status = xsCallBackRequestVo.getContent().getString("status");
//0进行中 1成功 2失败
if (status.equals("1")){
//截取订单编号
JSONObject content = xsCallBackRequestVo.getContent();
String merOrderId = content.getString("merOrderId");
String[] split = merOrderId.split("-");
String dealId = "";
if(!EmptyUtils.isEmpty(split)){
String orderFormId=split[0];
if(!EmptyUtils.isEmpty(orderFormId)){
//支付有礼
cereShopOrderService.payGift(orderFormId);
dealId = content.getString("dealId");
//处理支付成功后的其他逻辑
cereShopOrderService.handleWxLog(orderFormId, dealId, merOrderId);
}
}
}
}catch (Exception e) {
e.printStackTrace();
}
return "200";
}
/**
* 退款通知回调
* @throws Exception
*/
@PostMapping("refund/notify")
public String refundNotify(@RequestParam(name = "msg") String msg) throws Exception {
log.info("----refundNotify:" + msg);
return "success";
}
}

2
cereshop-app/src/main/java/com/shop/cereshop/app/dao/business/CerePlatformBusinessDAO.java

@ -37,4 +37,6 @@ public interface CerePlatformBusinessDAO extends BaseMapper<CerePlatformBusiness
CerePlatformBusiness findByDomain(@Param("domain") String domain);
String findXsPayIdByProject(@Param("project") String project);
}

2
cereshop-app/src/main/java/com/shop/cereshop/app/param/order/OrderParam.java

@ -99,7 +99,7 @@ public class OrderParam implements Serializable {
private String remark;
/**
* 订单支付方式 1-微信 2-支付宝
* 订单支付方式 1-微信 2-支付宝 3-花呗分期 4-新生支付
*/
@ApiModelProperty(value = "订单支付方式")
private Integer paymentMode;

22
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/domain/DivideAcctDtlVo.java

@ -0,0 +1,22 @@
package com.shop.cereshop.app.pay.hnapay.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 描述
*
* @author stevenhu
* @version 2025/02/14 10:44
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class DivideAcctDtlVo {
private String ledgerUserId;
private String amount;
}

205
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/BaseTransForm.java

@ -0,0 +1,205 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import com.alibaba.fastjson.JSONObject;
import com.shop.cereshop.app.pay.hnapay.utils.HnaPayDateUtils;
import com.shop.cereshop.commons.config.HnaPayConfig;
import lombok.Data;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 交易报文
* 交易报文是面向商户的各交易报文中的字段必须与商户提交请求中的参数key一致
* <p>Title: BaseTransForm</p>
* <p>Description: </p>
* <p>Company: </p>
*/
@Data
public abstract class BaseTransForm implements Serializable{
private static final long serialVersionUID = 1L;
public static final String VERSION = "version";
public static final String TRAN_CODE = "tranCode";
public static final String MER_ID = "merId";
public static final String MER_ORDER_ID = "merOrderId";
public static final String CHARSET = "charset";
public static final String SIGN_TYPE = "signType";
public static final String SIGN_VALUE = "signValue";
public static final String MER_ATTACH = "merAttach";
public static final String SUBMIT_TIME = "submitTime";
public static final String MSG_CIPHER_TEXT = "msgCiphertext";
public static final String RESULT_CODE = "resultCode";
public static final String ERROR_CODE = "errorCode";
public static final String ERROR_MSG = "errorMsg";
public static final String CERT_INFO = "certInfo";
// 暂定公共的报文字段
protected String tranCode;
protected String version;
protected String merId;
protected String merOrderId;
protected String signType;
protected String signValue;
protected String msgCiphertext;
protected String charset;
protected String merAttach;
protected String submitTime;
protected String certInfo;
//提交地址
protected String submitUrl;
/**
* 获取公共返回参数<br>
* Map中的key必须与返回XML文件中的field的name值一致<br>
* 子类可选择性重写
* @return
*/
@SuppressWarnings("static-access")
public Map<String, Object> getCommonRespParams() {
Map<String, Object> commonParams = new HashMap<String, Object>();
commonParams.put(this.VERSION, this.version);
commonParams.put(this.TRAN_CODE, this.tranCode);
commonParams.put(this.MER_ORDER_ID, this.merOrderId);
commonParams.put(this.MER_ID, this.merId);
commonParams.put(this.MER_ATTACH, this.merAttach);
commonParams.put(this.CHARSET, this.charset);
commonParams.put(this.SIGN_TYPE, this.signType);
return commonParams;
}
/**
* 获取共用请求的签名字段
* @author wgy
* @date 2018年8月10日 上午10:26:54
* @description 一句话描述功能
* @return Map<String,Object>
*/
@SuppressWarnings("static-access")
public Map<String,Object> getCommonReqSignParams(boolean isUpload){
Map<String, Object> commonParams = new HashMap<String, Object>();
commonParams.put(this.TRAN_CODE, this.tranCode);
commonParams.put(this.VERSION, this.version);
commonParams.put(this.MER_ID, this.merId);
commonParams.put(this.MER_ORDER_ID, this.merOrderId);
commonParams.put(this.SUBMIT_TIME, this.submitTime);
commonParams.put(this.MSG_CIPHER_TEXT, this.msgCiphertext);
commonParams.put(this.SIGN_TYPE, this.signType);
if (isUpload) {
commonParams.put(this.CERT_INFO, this.certInfo);
}
return commonParams;
}
/**
* 获取加密json串明文
* @author wgy
* @date 2018年8月27日 下午6:08:46
* @description 一句话描述功能
* @return String
*/
public abstract String getEncryptJsonStr();
/**
* 获取验签字段
* @return
*/
public abstract String getVerifyJsonStr();
/**
* 获取提交字段
* @return
*/
public abstract String getSubmitJsonStr();
public void initCommonParams(String tranCode) {
this.version="1.0";
this.tranCode=tranCode;
this.merId= HnaPayConfig.MER_ID;
this.merOrderId=tranCode+"_"+ HnaPayDateUtils.format(new Date());
this.submitTime= HnaPayDateUtils.format(new Date());
this.signType="1";
this.merAttach="";
this.charset="UTF-8";
}
public String getCommonSignStr() {
StringBuffer sb = new StringBuffer();
sb.append(this.VERSION);
sb.append("=[");
sb.append(getVersion());
sb.append("]");
sb.append(this.TRAN_CODE);
sb.append("=[");
sb.append(getTranCode());
sb.append("]");
sb.append(this.MER_ID);
sb.append("=[");
sb.append(getMerId());
sb.append("]");
sb.append(this.MER_ORDER_ID);
sb.append("=[");
sb.append(getMerOrderId());
sb.append("]");
sb.append(this.SUBMIT_TIME);
sb.append("=[");
sb.append(getSubmitTime());
sb.append("]");
sb.append(this.MSG_CIPHER_TEXT);
sb.append("=[");
sb.append(getMsgCiphertext());
sb.append("]");
sb.append(this.SIGN_TYPE);
sb.append("=[");
sb.append(getSignType());
sb.append("]");
return sb.toString();
}
public String getValueByReflet(Object model, String paraName){
// 返回值
String value = "";
try {
// 获取属性值
Field[] fields = model.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
if (field.getName().equals(paraName)) {
value = (String) field.get(model);
break;
}
}
}catch (Exception e){
}
return value;
}
public String getJsonStr(Object model,String[] strArr) {
JSONObject json = new JSONObject(true);
for(String file:strArr){
json.put(file, getValueByReflet(model,file));
}
return json.toJSONString();
}
}

38
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/F001TransForm.java

@ -0,0 +1,38 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class F001TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"orgMerOrderId","divideId","divideDtlId"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode", "ncountOrderId"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "charset"};
private String orgMerOrderId;//原商户订单号
private String divideId;//分账主订单号
private String divideDtlId;//分账明细订单号
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

36
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q001TransForm.java

@ -0,0 +1,36 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class Q001TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","userId", "outUserId","userStat","auditStat","balAmount","bindCardAgrNoList"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String userId;//用户编号
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q002TransForm.java

@ -0,0 +1,37 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class Q002TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"tranMerOrderId","queryType"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode", "tranMerOrderId", "ncountOrderId","orderStatus","tranAmount"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String tranMerOrderId;//商户订单号
private String queryType;//交易大类
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q003TransForm.java

@ -0,0 +1,37 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* Created by gaoyantao on 16/4/10.
* Q003 - 开户结果查询
*/
@Data
public class Q003TransForm extends BaseTransForm {
/**
*
*/
private static final long serialVersionUID = 1L;
private String origMerOrderId;
public static final String[] encryptArr = new String[]{"origMerOrderId"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode", "userId","bindCardAgrNoList"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

40
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q004TransForm.java

@ -0,0 +1,40 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class Q004TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId","acctType","startDate","endDate","pageNum"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","userId","acctType","count"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String userId;//用户编号
private String acctType;//账户类型
private String startDate;//开始时间
private String endDate;//结束时间
private String pageNum;//请求页数
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q006TransForm.java

@ -0,0 +1,37 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class Q006TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId","enpAcct"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","userId","enpAcctNo"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String userId;//用户编号
private String enpAcct;//银行企业号
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

41
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q007TransForm.java

@ -0,0 +1,41 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class Q007TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId","enpAcct","startDate","endDate","pageSize","pageNum"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","enpAcctNo","count"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String userId;//用户编号
private String enpAcct;//银行企业号
private String startDate;//交易开始日期
private String endDate;//交易结束日期
private String pageSize;//查询笔数
private String pageNum;//请求页数
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

36
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q008TransForm.java

@ -0,0 +1,36 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class Q008TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"oriChannelSerialNo"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","transStatus","oriRespCode","oriRespMsg"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String oriChannelSerialNo;//原交易流水号
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

38
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/Q009TransForm.java

@ -0,0 +1,38 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class Q009TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"enpAcct","identityType","identityCode"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","enpAcct","enpAcctStatus","totalAmt"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String enpAcct;//企业号
private String identityType;//企业证件类型
private String identityCode;//企业证件号
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

47
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R001TransForm.java

@ -0,0 +1,47 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R001TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"merUserId","userName","mobile","certType","certNo","certValidate","cardNo","bankCode","province","city","branch"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode", "userId","bindCardAgrNo"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String merUserId;//商户用户唯一标识
private String userName;//用户名称
private String mobile;//手机号
private String certType;//证件类型
private String certNo;//证件号
private String certValidate;//证件有效期
private String cardNo;//银行卡号
private String bankCode;//银行简码
private String province;//开户行所属省份
private String city;//开户行所属城市
private String branch;//开户支行
private String notifyServerUrl;//审核异步通知地址
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

43
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R002TransForm.java

@ -0,0 +1,43 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R002TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId","bindCardAgrNo","mobile","cardNo","bankCode","province","city","branch"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode", "userId","bindCardAgrNo"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String userId;//用户编号
private String bindCardAgrNo;//原绑卡协议号
private String mobile;//手机号
private String cardNo;//银行卡号
private String bankCode;//银行简码
private String province;//开户行所属省份
private String city;//开户行所属城市
private String branch;//开户支行
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R003TransForm.java

@ -0,0 +1,37 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R003TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId","certFileType"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode", "userId","certFileType"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset","certInfo"};
private String userId;//用户编号
private String certFileType;//证件资料类型
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R004TransForm.java

@ -0,0 +1,37 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R004TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId","certFileType"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode", "userId","certFileType"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String userId;//用户编号
private String certFileType;//证件资料类型
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

44
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R007TransForm.java

@ -0,0 +1,44 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R007TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"cardNo","holderName","cardAvailableDate","cvv2","mobileNo","identityType","identityCode","userId","merUserIp"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","ncountOrderId"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String cardNo;//支付银行卡卡号
private String holderName;//持卡人姓名
private String cardAvailableDate;//信用卡有效期
private String cvv2;//信用卡CVV2
private String mobileNo;//银行签约手机号
private String identityType;//证件类型
private String identityCode;//证件号码
private String userId;//用户ID
private String merUserIp;//商户用户IP
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

38
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R008TransForm.java

@ -0,0 +1,38 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R008TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"ncountOrderId","smsCode","merUserIp"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","bindCardAgrNo", "bankCode", "cardType", "shortCardNo"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String ncountOrderId;//签约订单号
private String smsCode;//签约短信验证码
private String merUserIp;//商户用户IP
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R009TransForm.java

@ -0,0 +1,37 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R009TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"oriBindCardAgrNo","userId"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String oriBindCardAgrNo;//原绑卡协议号
private String userId;//用户ID
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

39
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R010TransForm.java

@ -0,0 +1,39 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R010TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"merUserId","mobile","userName","certNo"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","userId"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String merUserId;//商户用户唯一标识
private String mobile;//用户手机号
private String userName;//真实姓名
private String certNo;//身份证号
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

40
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R011TransForm.java

@ -0,0 +1,40 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R011TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId","certNo","userName","mobile","certValidate"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String userId;//企业用户Id
private String certNo;//营业执照号
private String userName;//用户名称
private String mobile;//手机号
private String certValidate;//证件有效期
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R012TransForm.java

@ -0,0 +1,37 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R012TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"userId","choiceAgreement"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","userId","identityType","identityCode","enpAcct","openBankNo","openId"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String userId;//商户用户唯一标识
private String choiceAgreement;//勾选线上协议01勾选00未勾选
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

39
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R013TransForm.java

@ -0,0 +1,39 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R013TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"bizType","userId","enpAcct","transAmt"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","channelSerialNo","userId","enpAcct"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String bizType;//业务类型 00 小额打款鉴权,01 小额验证
private String userId;//新账通用户号
private String enpAcct;//银行企业号
private String transAmt;//交易金额,业务类型是01时必填
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

36
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R014TransForm.java

@ -0,0 +1,36 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R014TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"enpAcct"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","enpAcct","signResult"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String enpAcct;//银行企业号
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

43
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/R015TransForm.java

@ -0,0 +1,43 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class R015TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"cardNo","userId","mobileNo","frontUrl","notifyUrl","merUserIp","pageStyle"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "merAttach", "charset", "signType", "resultCode" ,"errorCode", "errorMsg", "bindCardAgrNo", "bankCode",
"cardType", "shortCardNo"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String cardNo;//支付银行卡卡号
private String userId;//用户编号
private String mobileNo;//银行签约手机号
private String frontUrl;//商户回调地址
private String notifyUrl;//异步通知地址
private String merUserIp;//商户用户IP
private String pageStyle;//页面样式
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

41
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T002TransForm.java

@ -0,0 +1,41 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T002TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"tranAmount","userId","bindCardAgrNo","notifyUrl","paymentTerminalInfo","deviceInfo"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode","ncountOrderId"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String tranAmount;//支付金额
private String userId;//提现用户编号
private String bindCardAgrNo;//绑卡协议号
private String notifyUrl;//异步通知地址
private String paymentTerminalInfo;//付款方终端信息
private String deviceInfo;//设备信息
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

39
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T003TransForm.java

@ -0,0 +1,39 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T003TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"payUserId","receiveUserId","tranAmount","businessType"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String payUserId;//付款方用户编号
private String receiveUserId;//收款方ID
private String tranAmount;//转账金额
private String businessType;//业务类型
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

43
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T004TransForm.java

@ -0,0 +1,43 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T004TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"tranAmount","bankCode","currencyType","remark","receiveUserId","merUserIp","notifyUrl","businessType"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode","tranAmount","hnapayOrderId","bankAcct"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String tranAmount;//充值金额
private String bankCode;//银行编码
private String currencyType;//币种
private String remark;//备注
private String receiveUserId;//充值商户新账通商户ID
private String merUserIp;//用户浏览器IP
private String notifyUrl;//异步通知地址
private String businessType;//业务类型
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

45
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T005TransForm.java

@ -0,0 +1,45 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T005TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"serialId","orgMerOrderId","orgSubmitTime","orderAmount","refundSource","destType","refundType","refundAmount","notifyUrl","remark"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode","orgMerOrderId","orderAmount","refundAmount"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String serialId;//请求序列号
private String orgMerOrderId;//商户原始订单号
private String orgSubmitTime;//原订单支付下单请求时间
private String orderAmount;//原订单金额
private String refundSource;//退款资金来源
private String destType;//退款目的地类型
private String refundType;//退款类型
private String refundAmount;//商户退款金额
private String notifyUrl;//异步通知地址
private String remark;//备注
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

58
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T006TransForm.java

@ -0,0 +1,58 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T006TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"tranAmount","orgCode","currencyType","remark","notifyServerUrl","merUserIp","expireTime","riskExpand","goodsInfo","orderSubject","orderDesc","payLimit","appId","openId","aliAppId","buyerLogonId","buyerId","merchantId","receiveUserId","businessType","feeType","divideAcctDtl","feeAmountUser"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode", "ncountOrderId","payInfo"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String tranAmount;//交易金额
private String orgCode;//目标资金机构代码
private String currencyType;//币种
private String remark;//备注
private String notifyServerUrl;//异步通知地址
private String merUserIp;//用户浏览器IP
private String expireTime;//订单过期时间
private String riskExpand;//分控扩展信息
private String goodsInfo;//商品信息
private String orderSubject;//订单标题
private String orderDesc;//订单描述
private String payLimit;//限制信用卡支付
private String appId;//商家微信公众号ID
private String openId;//微信用户关注商家公众号的openid
private String aliAppId;//商家支付宝生活号ID
private String buyerLogonId;//买家支付宝账号
private String buyerId;//买家支付宝用户ID
private String merchantId;//客户机构号
private String receiveUserId;//收款方 ID
private String businessType;//业务类型
private String feeType;//手续费内扣外扣
private String divideAcctDtl;//分账明细
private String feeAmountUser;//手续费承担方id
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

55
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T007TransForm.java

@ -0,0 +1,55 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T007TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"tranAmount","payType","cardNo","holderName","cardAvailableDate","cvv2","mobileNo","identityType","identityCode","bindCardAgrNo","notifyUrl","orderExpireTime","userId","receiveUserId","merUserIp","riskExpand","goodsInfo","subMerchantId","divideFlag","divideDetail"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode", "ncountOrderId","submitTime"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String tranAmount;//支付金额
private String payType;//支付方式
private String cardNo;//支付银行卡卡号
private String holderName;//持卡人姓名
private String cardAvailableDate;//信用卡有效期
private String cvv2;//信用卡CVV2
private String mobileNo;//银行签约手机号
private String identityType;//证件类型
private String identityCode;//证件号码
private String bindCardAgrNo;//商户异步通知地址
private String notifyUrl;//备注
private String orderExpireTime;//订单过期时长
private String userId;//用户编号
private String receiveUserId;//收款方ID
private String merUserIp;//商户用户IP
private String riskExpand;//风控扩展信息
private String goodsInfo;//商品信息
private String subMerchantId;//商户渠道进件ID
private String divideFlag;//是否分账
private String divideDetail;//分账明细信息
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

45
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T008TransForm.java

@ -0,0 +1,45 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T008TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"ncountOrderId","smsCode","merUserIp","paymentTerminalInfo","receiverTerminalInfo","deviceInfo","businessType","feeType","divideAcctDtl","feeAmountUser"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode", "ncountOrderId","tranAmount","checkDate","submitTime","tranFinishTime","bankCode","cardType","shortCardNo","bindCardAgrNo"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String ncountOrderId;//新账通订单号
private String smsCode;//短信验证码
private String merUserIp;//商户用户IP
private String paymentTerminalInfo;//付款方终端信息
private String receiverTerminalInfo;//收款方终端信息
private String deviceInfo;//设备信息
private String businessType;//业务类型
private String feeType;//手续费内扣外扣
private String divideAcctDtl;//分账明细
private String feeAmountUser;//手续费承担方id
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

53
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T009TransForm.java

@ -0,0 +1,53 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T009TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"tranAmount","orgCode","currencyType","remark","notifyServerUrl","merUserIp","expireTime","riskExpand","goodsInfo","orderSubject","orderDesc","payLimit","merchantId","receiveUserId","businessType","feeType","divideAcctDtl","feeAmountUser"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode", "ncountOrderId","qrCodeUrl"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset","tranAmount","orgCode","currencyType","remark","notifyServerUrl","merUserIp","expireTime","riskExpand","goodsInfo","orderSubject","orderDesc","payLimit","merchantId","receiveUserId"};
private String tranAmount;//交易金额
private String orgCode;//目标资金机构代码
private String currencyType;//币种
private String remark;//备注
private String notifyServerUrl;//异步通知地址
private String merUserIp;//用户浏览器IP
private String expireTime;//订单过期时间
private String riskExpand;//分控扩展信息
private String goodsInfo;//商品信息
private String orderSubject;//订单标题
private String orderDesc;//订单描述
private String payLimit;//限制信用卡支付
private String merchantId;//客户机构号
private String receiveUserId;//收款方 ID
private String businessType;//业务类型
private String feeType;//手续费内扣外扣
private String divideAcctDtl;//分账明细
private String feeAmountUser;//手续费承担方id
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

52
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T010TransForm.java

@ -0,0 +1,52 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T010TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"merUserIp","goodsInfo","tranAmount","payType","bankCode","currencyType","directFlag","notifyFrontUrl","notifyServerUrl","receiveUserId","paymentTerminalInfo","receiverTerminalInfo","deviceInfo","businessType","feeType","divideAcctDtl","feeAmountUser"};
public static final String[] verifyArr = new String[]{};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String merUserIp;//用户浏览器IP
private String goodsInfo;//商品信息
private String tranAmount;//交易金额
private String payType;//付款方支付方式
private String bankCode;//网银机构代码
private String currencyType;//币种
private String directFlag;//是否直连
private String notifyFrontUrl;//商户回调地址
private String notifyServerUrl;//商户通知地址
private String receiveUserId;//收款方 ID
private String paymentTerminalInfo;//付款方终端信息
private String receiverTerminalInfo;//收款方终端信息
private String deviceInfo;//设备信息
private String businessType;//业务类型
private String feeType;//手续费内扣外扣
private String divideAcctDtl;//分账明细
private String feeAmountUser;//手续费承担方id
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

38
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T011TransForm.java

@ -0,0 +1,38 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T011TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"ncountOrderId","businessType","orgTranCode"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode","reciptBase64Pdf"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset","ncountOrderId","businessType","orgTranCode"};
private String ncountOrderId;//原交易订单号
private String businessType;//业务类型
private String orgTranCode;//原交易代码
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

36
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T012TransForm.java

@ -0,0 +1,36 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T012TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"colDate"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode" ,"errorCode","collateFileBase64"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset","colDate"};
private String colDate;//交易日期
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

48
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T013TransForm.java

@ -0,0 +1,48 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2020-10-19
**/
@Data
public class T013TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"tranAmount","currencyType","payType","receiveUserId","notifyFrontUrl","notifyServerUrl","riskExpand","goodsInfo","orderSubject","orderDesc","merchantId","merUserIp","payLimit"};
public static final String[] verifyArr = new String[]{};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String tranAmount;//交易金额
private String currencyType;//币种
private String payType;//付款方支付方式
private String receiveUserId;//收款方 ID
private String notifyFrontUrl;//商户回调地址
private String notifyServerUrl;//商户通知地址
private String riskExpand;//分控扩展信息
private String goodsInfo;//商品信息
private String orderSubject;//订单标题
private String orderDesc;//订单描述
private String merchantId;//客户机构号
private String merUserIp;//商户用户IP
private String payLimit;//限制信用卡支付
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

41
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T019TransForm.java

@ -0,0 +1,41 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2023-06-05
**/
@Data
public class T019TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"tranAmount","receiveUserId","merUserIp","notifyUrl","businessType","feeType"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "charset", "signType", "resultCode", "errorCode", "tranAmount", "ncountOrderId", "hnapayBankAcctNo", "inChargeCode"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String tranAmount;//交易金额
private String receiveUserId;//收款方ID
private String merUserIp;//用户浏览器IP
private String notifyUrl;//异步通知地址
private String businessType;//业务类型
private String feeType;//手续费内扣外扣
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

54
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T020TransForm.java

@ -0,0 +1,54 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2023-07-12
**/
@Data
public class T020TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"merchantId","tranAmount","scanCodeId","businessType","feeType","currencyType","orderSubject","holderName","identityType","identityCode","minAge","riskExpand","terminalId","terminalIp","location","receiveUserId","merUserIp","notifyServerUrl","remark"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "merAttach", "charset", "signType", "resultCode", "errorCode", "errorMsg", "signValue", "ncountOrderId", "businessType"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String merchantId;//客户机构号
private String tranAmount;//支付金额
private String scanCodeId;//条形码
private String businessType;//业务类型
private String feeType;//手续费内扣外扣
private String currencyType;//币种
private String orderSubject;//订单标题
private String holderName;//姓名
private String identityType;//证件类型
private String identityCode;//证件号
private String minAge;//最小买家年龄
private String riskExpand;//风控扩展信息
private String terminalId;//设备编号
private String terminalIp;//设备终端IP
private String location;//实时经纬度
private String receiveUserId;//收款方用户ID
private String merUserIp;//交易IP
private String notifyServerUrl;//商户后台通知地址
private String remark;//备注
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

40
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T021TransForm.java

@ -0,0 +1,40 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2023-07-12
**/
@Data
public class T021TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"merchantId","terminalId","terminalType","serialNum","terminalAddress"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "merAttach", "charset", "signType", "resultCode", "errorCode", "errorMsg", "signValue", "businessType"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String merchantId;//客户机构号
private String terminalId;//设备编号
private String terminalType;//设备类型
private String serialNum;//终端序列号
private String terminalAddress;//终端布放地址
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/form/T022TransForm.java

@ -0,0 +1,37 @@
package com.shop.cereshop.app.pay.hnapay.request.form;
import lombok.Data;
/**
* @Author
* @Version V1.0
* @Description
* @Date 2023-07-12
**/
@Data
public class T022TransForm extends BaseTransForm {
private static final long serialVersionUID = 1L;
public static final String[] encryptArr = new String[]{"merchantId","terminalId"};
public static final String[] verifyArr = new String[]{"version", "tranCode", "merOrderId", "merId", "merAttach", "charset", "signType", "resultCode", "errorCode", "errorMsg", "signValue"};
public static final String[] submitArr = new String[]{"version", "tranCode", "merId", "merOrderId", "submitTime", "msgCiphertext", "signType", "signValue", "merAttach", "charset"};
private String merchantId;//客户机构号
private String terminalId;//设备编号
@Override
public String getEncryptJsonStr() {
return getJsonStr(this,encryptArr);
}
@Override
public String getVerifyJsonStr() {
return getJsonStr(this,verifyArr);
}
@Override
public String getSubmitJsonStr() {
return getJsonStr(this,submitArr);
}
}

815
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/request/init/InitForm.java

@ -0,0 +1,815 @@
package com.shop.cereshop.app.pay.hnapay.request.init;
import com.shop.cereshop.app.pay.hnapay.request.form.*;
import java.util.Map;
public class InitForm {
// 接口请求提交地址
public static final String R012_SUBMIT_URL = "https://ncount.hnapay.com/api/r012.htm";
public static final String R013_SUBMIT_URL = "https://ncount.hnapay.com/api/r013.htm";
public static final String R014_SUBMIT_URL = "https://ncount.hnapay.com/api/r014.htm";
public static final String Q006_SUBMIT_URL = "https://ncount.hnapay.com/api/q006.htm";
public static final String Q007_SUBMIT_URL = "https://ncount.hnapay.com/api/q007.htm";
public static final String Q008_SUBMIT_URL = "https://ncount.hnapay.com/api/q008.htm";
public static final String Q009_SUBMIT_URL = "https://ncount.hnapay.com/api/q009.htm";
public static final String Q001_SUBMIT_URL = "https://ncount.hnapay.com/api/q001.htm";
public static final String Q002_SUBMIT_URL = "https://ncount.hnapay.com/api/q002.htm";
public static final String Q004_SUBMIT_URL = "https://ncount.hnapay.com/api/q004.htm";
public static final String R001_SUBMIT_URL = "https://ncount.hnapay.com/api/r001.htm";
public static final String R002_SUBMIT_URL = "https://ncount.hnapay.com/api/r002.htm";
public static final String R003_SUBMIT_URL = "https://ncount.hnapay.com/api/r003.htm";
public static final String R004_SUBMIT_URL = "https://ncount.hnapay.com/api/r004.htm";
public static final String R007_SUBMIT_URL = "https://ncount.hnapay.com/api/r007.htm";
public static final String R008_SUBMIT_URL = "https://ncount.hnapay.com/api/r008.htm";
public static final String R009_SUBMIT_URL = "https://ncount.hnapay.com/api/r009.htm";
public static final String R010_SUBMIT_URL = "https://ncount.hnapay.com/api/r010.htm";
public static final String R011_SUBMIT_URL = "https://ncount.hnapay.com/api/r011.htm";
public static final String T002_SUBMIT_URL = "https://ncount.hnapay.com/api/t002.htm";
public static final String T003_SUBMIT_URL = "https://ncount.hnapay.com/api/t003.htm";
public static final String T004_SUBMIT_URL = "https://ncount.hnapay.com/api/t004.htm";
public static final String T005_SUBMIT_URL = "https://ncount.hnapay.com/api/t005.htm";
public static final String T006_SUBMIT_URL = "https://ncount.hnapay.com/api/t006.htm";
public static final String T007_SUBMIT_URL = "https://ncount.hnapay.com/api/t007.htm";
public static final String T008_SUBMIT_URL = "https://ncount.hnapay.com/api/t008.htm";
public static final String R015_SUBMIT_URL = "https://ncount.hnapay.com/api/r015.htm";
public static final String T009_SUBMIT_URL = "https://ncount.hnapay.com/api/t009.htm";
public static final String T010_SUBMIT_URL = "https://ncount.hnapay.com/api/t010.htm";
public static final String T011_SUBMIT_URL = "https://ncount.hnapay.com/api/t011.htm";
public static final String T012_SUBMIT_URL = "https://ncount.hnapay.com/api/t012.htm";
public static final String T013_SUBMIT_URL = "https://ncount.hnapay.com/api/t013.htm";
public static final String F001_SUBMIT_URL = "https://ncount.hnapay.com/api/f001.htm";
public static final String T019_SUBMIT_URL = "https://ncount.hnapay.com/api/t019.htm";
public static final String T020_SUBMIT_URL = "https://ncount.hnapay.com/api/t020.htm";
public static final String T021_SUBMIT_URL = "https://ncount.hnapay.com/api/t021.htm";
public static final String T022_SUBMIT_URL = "https://ncount.hnapay.com/api/t022.htm";
public static BaseTransForm getFormByTranCode(String tranCode) {
BaseTransForm baseTransForm = null;
switch (tranCode) {
case "R012":
baseTransForm = getR012TransForm();
break;
case "R013":
baseTransForm = getR013TransForm();
break;
case "R014":
baseTransForm = getR014TransForm();
break;
case "Q006":
baseTransForm = getQ006TransForm();
break;
case "Q007":
baseTransForm = getQ007TransForm();
break;
case "Q008":
baseTransForm = getQ008TransForm();
break;
case "Q009":
baseTransForm = getQ009TransForm();
break;
case "Q001":
baseTransForm = getQ001TransForm();
break;
case "Q002":
baseTransForm = getQ002TransForm();
break;
case "Q004":
baseTransForm = getQ004TransForm();
break;
case "R001":
baseTransForm = getR001TransForm();
break;
case "R002":
baseTransForm = getR002TransForm();
break;
case "R003":
baseTransForm = getR003TransForm();
break;
case "R004":
baseTransForm = getR004TransForm();
break;
case "R007":
baseTransForm = getR007TransForm();
break;
case "R008":
baseTransForm = getR008TransForm();
break;
case "R009":
baseTransForm = getR009TransForm();
break;
case "R010":
baseTransForm = getR010TransForm();
break;
case "R011":
baseTransForm = getR011TransForm();
break;
case "T002":
baseTransForm = getT002TransForm();
break;
case "T003":
baseTransForm = getT003TransForm();
break;
case "T004":
baseTransForm = getT004TransForm();
break;
case "T005":
baseTransForm = getT005TransForm();
break;
case "T006":
baseTransForm = getT006TransForm();
break;
case "T007":
baseTransForm = getT007TransForm();
break;
case "T008":
baseTransForm = getT008TransForm();
break;
case "R015":
baseTransForm = getR015TransForm();
break;
case "T009":
baseTransForm = getT009TransForm();
break;
case "T010":
baseTransForm = getT010TransForm();
break;
case "T011":
baseTransForm = getT011TransForm();
break;
case "T012":
baseTransForm = getT012TransForm();
break;
case "T013":
baseTransForm = getT013TransForm();
break;
case "F001":
baseTransForm = getF001TransForm();
break;
case "T019":
baseTransForm = getT019TransForm();
break;
case "T020":
baseTransForm = getT020TransForm();
break;
case "T021":
baseTransForm = getT021TransForm();
break;
case "T022":
baseTransForm = getT022TransForm();
break;
default:
break;
}
return baseTransForm;
}
private static R012TransForm getR012TransForm() {
R012TransForm transForm = new R012TransForm();
transForm.setTranCode("R012");
transForm.initCommonParams("R012");
transForm.setSubmitUrl(R012_SUBMIT_URL);
transForm.setUserId("102302320");
transForm.setChoiceAgreement("01");
return transForm;
}
private static R013TransForm getR013TransForm() {
R013TransForm transForm = new R013TransForm();
transForm.setTranCode("R013");
transForm.initCommonParams("R013");
transForm.setSubmitUrl(R013_SUBMIT_URL);
transForm.setBizType("00");
transForm.setUserId("102302320");
transForm.setEnpAcct("21341242423423423");
transForm.setTransAmt("");
return transForm;
}
private static R014TransForm getR014TransForm() {
R014TransForm transForm = new R014TransForm();
transForm.setTranCode("R014");
transForm.initCommonParams("R014");
transForm.setSubmitUrl(R014_SUBMIT_URL);
transForm.setEnpAcct("21341242423423423");
return transForm;
}
private static Q006TransForm getQ006TransForm() {
Q006TransForm transForm = new Q006TransForm();
transForm.setTranCode("Q006");
transForm.initCommonParams("Q006");
transForm.setSubmitUrl(Q006_SUBMIT_URL);
transForm.setUserId("1231243124");
transForm.setEnpAcct("21341242423423423");
return transForm;
}
private static Q007TransForm getQ007TransForm() {
Q007TransForm transForm = new Q007TransForm();
transForm.setTranCode("Q007");
transForm.initCommonParams("Q007");
transForm.setSubmitUrl(Q007_SUBMIT_URL);
transForm.setUserId("1231243124");
transForm.setEnpAcct("21341242423423423");
transForm.setStartDate("20200729");
transForm.setEndDate("20200729");
transForm.setPageSize("10");
transForm.setPageNum("1");
return transForm;
}
private static Q008TransForm getQ008TransForm() {
Q008TransForm transForm = new Q008TransForm();
transForm.setTranCode("Q008");
transForm.initCommonParams("Q008");
transForm.setSubmitUrl(Q008_SUBMIT_URL);
transForm.setOriChannelSerialNo("1231243124");
return transForm;
}
private static Q009TransForm getQ009TransForm() {
Q009TransForm transForm = new Q009TransForm();
transForm.setTranCode("Q009");
transForm.initCommonParams("Q009");
transForm.setSubmitUrl(Q009_SUBMIT_URL);
transForm.setEnpAcct("21341242423423423");
transForm.setIdentityType("2");
transForm.setIdentityCode("1231241234324");
return transForm;
}
private static Q001TransForm getQ001TransForm() {
Q001TransForm transForm = new Q001TransForm();
transForm.setTranCode("Q001");
transForm.initCommonParams("Q001");
transForm.setSubmitUrl(Q001_SUBMIT_URL);
transForm.setUserId("100000002285");
return transForm;
}
private static Q002TransForm getQ002TransForm() {
Q002TransForm transForm = new Q002TransForm();
transForm.setTranCode("Q002");
transForm.initCommonParams("Q002");
transForm.setSubmitUrl(Q002_SUBMIT_URL);
transForm.setTranMerOrderId("T006_20190614180952");
transForm.setQueryType("RECV");
return transForm;
}
private static Q004TransForm getQ004TransForm() {
Q004TransForm transForm = new Q004TransForm();
transForm.setTranCode("Q004");
transForm.initCommonParams("Q004");
transForm.setSubmitUrl(Q004_SUBMIT_URL);
transForm.setUserId("11000000111");
transForm.setAcctType("1");
transForm.setStartDate("20181230");
transForm.setEndDate("20181231");
transForm.setPageNum("1");
return transForm;
}
private static R001TransForm getR001TransForm() {
R001TransForm transForm = new R001TransForm();
transForm.setTranCode("R001");
transForm.initCommonParams("R001");
transForm.setSubmitUrl(R001_SUBMIT_URL);
transForm.setMerUserId("11000000111");
transForm.setUserName("某某公司");
transForm.setMobile("13211111111");
transForm.setCertType("2");
transForm.setCertNo("112312431241231");
transForm.setCertValidate("20201020");
transForm.setCardNo("320102000");
transForm.setBankCode("ICBC");
transForm.setProvince("北京");
transForm.setCity("北京市");
transForm.setBranch("北京支行");
return transForm;
}
private static R002TransForm getR002TransForm() {
R002TransForm transForm = new R002TransForm();
transForm.setTranCode("R002");
transForm.initCommonParams("R002");
transForm.setSubmitUrl(R002_SUBMIT_URL);
transForm.setUserId("11000000111");
transForm.setBindCardAgrNo("10000000000000000000");
transForm.setMobile("13211111111");
transForm.setCardNo("320102000");
transForm.setBankCode("ICBC");
transForm.setProvince("北京");
transForm.setCity("北京市");
transForm.setBranch("北京支行");
return transForm;
}
private static R003TransForm getR003TransForm() {
R003TransForm transForm = new R003TransForm();
transForm.setTranCode("R003");
transForm.initCommonParams("R003");
transForm.setSubmitUrl(R003_SUBMIT_URL);
transForm.setUserId("11000000111");
transForm.setCertFileType("1");
return transForm;
}
private static R004TransForm getR004TransForm() {
R004TransForm transForm = new R004TransForm();
transForm.setTranCode("R004");
transForm.initCommonParams("R004");
transForm.setSubmitUrl(R004_SUBMIT_URL);
transForm.setUserId("11000000111");
transForm.setCertFileType("1");
return transForm;
}
private static R007TransForm getR007TransForm() {
R007TransForm transForm = new R007TransForm();
transForm.setTranCode("R007");
transForm.initCommonParams("R007");
transForm.setSubmitUrl(R007_SUBMIT_URL);
transForm.setCardNo("21321423412343");
transForm.setHolderName("刘备");
transForm.setCardAvailableDate("0320");
transForm.setCvv2("318");
transForm.setMobileNo("13212121212");
transForm.setIdentityType("1");
transForm.setIdentityCode("12331341241234124234");
transForm.setUserId("11000000111");
transForm.setMerUserIp("211.12.38.88");
return transForm;
}
private static R008TransForm getR008TransForm() {
R008TransForm transForm = new R008TransForm();
transForm.setTranCode("R008");
transForm.initCommonParams("R008");
transForm.setSubmitUrl(R008_SUBMIT_URL);
transForm.setNcountOrderId("2017032312244422");
transForm.setSmsCode("788900");
transForm.setMerUserIp("211.12.38.88");
return transForm;
}
private static R009TransForm getR009TransForm() {
R009TransForm transForm = new R009TransForm();
transForm.setTranCode("R009");
transForm.initCommonParams("R009");
transForm.setSubmitUrl(R009_SUBMIT_URL);
transForm.setOriBindCardAgrNo("2017032312244422");
transForm.setUserId("11000000111");
return transForm;
}
private static R010TransForm getR010TransForm() {
R010TransForm transForm = new R010TransForm();
transForm.setTranCode("R010");
transForm.initCommonParams("R010");
transForm.setSubmitUrl(R010_SUBMIT_URL);
transForm.setMerUserId("2017032312244422");
transForm.setMobile("13212121212");
transForm.setUserName("张飞");
transForm.setCertNo("123123124234235");
return transForm;
}
private static R011TransForm getR011TransForm() {
R011TransForm transForm = new R011TransForm();
transForm.setTranCode("R011");
transForm.initCommonParams("R011");
transForm.setSubmitUrl(R011_SUBMIT_URL);
transForm.setUserId("2017032312244422");
transForm.setCertNo("13212121212");
transForm.setUserName("公司名称");
transForm.setMobile("18888888888");
transForm.setCertValidate("20200107");
return transForm;
}
private static T002TransForm getT002TransForm() {
T002TransForm transForm = new T002TransForm();
transForm.setTranCode("T002");
transForm.initCommonParams("T002");
transForm.setSubmitUrl(T002_SUBMIT_URL);
transForm.setTranAmount("1212.12");
transForm.setUserId("13212121212");
transForm.setBindCardAgrNo("1231242354235");
transForm.setNotifyUrl("http://www.xxx.com/response.do");
transForm.setPaymentTerminalInfo("01|10001");
transForm.setDeviceInfo("192.168.0.1|E1E2E3E4E5E6|12456789012345|20000|12345678901234567890|H1H2H3H4H5H6|AABBCC");
return transForm;
}
private static T003TransForm getT003TransForm() {
T003TransForm transForm = new T003TransForm();
transForm.setTranCode("T003");
transForm.initCommonParams("T003");
transForm.setSubmitUrl(T003_SUBMIT_URL);
transForm.setPayUserId("11000000111");
transForm.setReceiveUserId("11000000112");
transForm.setTranAmount("12.12");
transForm.setBusinessType("02");
return transForm;
}
private static T004TransForm getT004TransForm() {
T004TransForm transForm = new T004TransForm();
transForm.setTranCode("T004");
transForm.initCommonParams("T004");
transForm.setSubmitUrl(T004_SUBMIT_URL);
transForm.setTranAmount("100.01");
transForm.setBankCode("PBOC");
transForm.setCurrencyType("1");
transForm.setRemark("");
transForm.setReceiveUserId("11000000111");
transForm.setMerUserIp("211.12.38.88");
transForm.setNotifyUrl("http://www.xxx.com/response.do");
transForm.setBusinessType("01");
return transForm;
}
private static T005TransForm getT005TransForm() {
T005TransForm transForm = new T005TransForm();
transForm.setTranCode("T005");
transForm.initCommonParams("T005");
transForm.setSubmitUrl(T005_SUBMIT_URL);
transForm.setSerialId("1231234124123");
transForm.setOrgMerOrderId("1232134325423");
transForm.setOrgSubmitTime("20200101121212");
transForm.setOrderAmount("12.12");
transForm.setRefundSource("1");
transForm.setDestType("1");
transForm.setRefundType("1");
transForm.setRefundAmount("12.12");
transForm.setNotifyUrl("http://www.xxx.com/response.do");
transForm.setRemark("备注信息");
return transForm;
}
private static T006TransForm getT006TransForm() {
T006TransForm transForm = new T006TransForm();
transForm.setTranCode("T006");
transForm.initCommonParams("T006");
transForm.setSubmitUrl(T006_SUBMIT_URL);
transForm.setTranAmount("12.12");
transForm.setOrgCode("WECHATPAY");
transForm.setCurrencyType("1");
transForm.setRemark("备注信息");
transForm.setNotifyServerUrl("http://www.xxx.com/response.do");
transForm.setMerUserIp("211.12.38.88");
transForm.setExpireTime("120");
transForm.setRiskExpand("111");
transForm.setGoodsInfo("111");
transForm.setOrderSubject("111");
transForm.setOrderDesc("1212");
transForm.setPayLimit("1");
transForm.setAppId("1231241434");
transForm.setOpenId("123123424");
transForm.setAliAppId("");
transForm.setBuyerLogonId("");
transForm.setBuyerId("备注信息");
transForm.setMerchantId("111accSSVV");
transForm.setReceiveUserId("213124234");
transForm.setBusinessType("03");
transForm.setFeeType("1");
transForm.setDivideAcctDtl("[{\"ledgerUserId \": \"220000001390\",\"amount\": \"50\"},{\"ledgerUserId\":\"220000001408\",\"amount\":\"50\"}]");
transForm.setFeeAmountUser("");
return transForm;
}
private static T007TransForm getT007TransForm() {
T007TransForm transForm = new T007TransForm();
transForm.setTranCode("T007");
transForm.initCommonParams("T007");
transForm.setSubmitUrl(T007_SUBMIT_URL);
transForm.setTranAmount("12.12");
transForm.setPayType("2");
transForm.setCardNo("121220200101121212");
transForm.setHolderName("赵子龙");
transForm.setCardAvailableDate("");
transForm.setCvv2("");
transForm.setMobileNo("13212121212");
transForm.setIdentityType("1");
transForm.setIdentityCode("123124235345646");
transForm.setBindCardAgrNo("http://www.xxx.com/response.do");
transForm.setNotifyUrl("备注信息");
transForm.setOrderExpireTime("");
transForm.setUserId("");
transForm.setReceiveUserId("备注信息");
transForm.setMerUserIp("211.12.38.88");
transForm.setRiskExpand("");
transForm.setGoodsInfo("商品信息");
transForm.setSubMerchantId("123123");
transForm.setDivideFlag("0");
transForm.setDivideDetail("");
return transForm;
}
private static T008TransForm getT008TransForm() {
T008TransForm transForm = new T008TransForm();
transForm.setTranCode("T008");
transForm.initCommonParams("T008");
transForm.setSubmitUrl(T008_SUBMIT_URL);
transForm.setNcountOrderId("1231234124123");
transForm.setSmsCode("121212");
transForm.setMerUserIp("211.12.38.88");
transForm.setPaymentTerminalInfo("01|10001");
transForm.setReceiverTerminalInfo("01|00001|CN|110000");
transForm.setDeviceInfo("192.168.0.1|E1E2E3E4E5E6|12456789012345|20000|12345678901234567890|H1H2H3H4H5H6|AABBCC");
transForm.setBusinessType("03");
transForm.setFeeType("1");
transForm.setDivideAcctDtl("[{\"ledgerUserId \": \"220000001390\",\"amount\": \"50\"},{\"ledgerUserId\":\"220000001408\",\"amount\":\"50\"}]");
transForm.setFeeAmountUser("");
return transForm;
}
private static R015TransForm getR015TransForm() {
R015TransForm transForm = new R015TransForm();
transForm.setTranCode("R015");
transForm.initCommonParams("R015");
transForm.setSubmitUrl(R015_SUBMIT_URL);
transForm.setCardNo("6230200017171717");
transForm.setUserId("");
transForm.setMobileNo("13212121212");
transForm.setFrontUrl("http://www.xxx.com/response.do");
transForm.setNotifyUrl("https://www.baidu.com ");
transForm.setMerUserIp("211.12.38.88");
transForm.setPageStyle("1");
return transForm;
}
private static T009TransForm getT009TransForm() {
T009TransForm transForm = new T009TransForm();
transForm.setTranCode("T009");
transForm.initCommonParams("T009");
transForm.setSubmitUrl(T009_SUBMIT_URL);
transForm.setTranAmount("12.12");
transForm.setOrgCode("WECHATPAY");
transForm.setCurrencyType("1");
transForm.setRemark("备注信息");
transForm.setNotifyServerUrl("http://www.xxx.com/response.do");
transForm.setMerUserIp("211.12.38.88");
transForm.setExpireTime("120");
transForm.setRiskExpand("111");
transForm.setGoodsInfo("111");
transForm.setOrderSubject("111");
transForm.setOrderDesc("1212");
transForm.setPayLimit("1");
transForm.setMerchantId("111accSSVV");
transForm.setReceiveUserId("213124234");
transForm.setBusinessType("03");
transForm.setFeeType("1");
transForm.setDivideAcctDtl("[{\"ledgerUserId \": \"220000001390\",\"amount\": \"50\"},{\"ledgerUserId\":\"220000001408\",\"amount\":\"50\"}]");
transForm.setFeeAmountUser("");
return transForm;
}
private static T010TransForm getT010TransForm() {
T010TransForm transForm = new T010TransForm();
transForm.setTranCode("T010");
transForm.initCommonParams("T010");
transForm.setSubmitUrl(T010_SUBMIT_URL);
transForm.setMerUserIp("211.12.38.88");
transForm.setGoodsInfo("111");
transForm.setTranAmount("12.12");
transForm.setPayType("BANK_B2C");
transForm.setBankCode("ICBC");
transForm.setCurrencyType("1");
transForm.setDirectFlag("1");
transForm.setNotifyFrontUrl("http://www.xxx.com/response.do");
transForm.setNotifyServerUrl("http://www.xxx.com/response.do");
transForm.setReceiveUserId("213124234");
transForm.setPaymentTerminalInfo("01|10001");
transForm.setReceiverTerminalInfo("01|00001|CN|110000");
transForm.setDeviceInfo("192.168.0.1|E1E2E3E4E5E6|12456789012345|20000|12345678901234567890|H1H2H3H4H5H6|AABBCC");
transForm.setBusinessType("03");
transForm.setFeeType("1");
transForm.setDivideAcctDtl("[{\"ledgerUserId \": \"220000001390\",\"amount\": \"50\"},{\"ledgerUserId\":\"220000001408\",\"amount\":\"50\"}]");
transForm.setFeeAmountUser("");
return transForm;
}
private static T011TransForm getT011TransForm() {
T011TransForm transForm = new T011TransForm();
transForm.setTranCode("T011");
transForm.initCommonParams("T011");
transForm.setSubmitUrl(T011_SUBMIT_URL);
transForm.setNcountOrderId("1231242345");
transForm.setBusinessType("03");
transForm.setOrgTranCode("T010");
return transForm;
}
private static T012TransForm getT012TransForm() {
T012TransForm transForm = new T012TransForm();
transForm.setTranCode("T012");
transForm.initCommonParams("T012");
transForm.setSubmitUrl(T012_SUBMIT_URL);
transForm.setColDate("20191224");
return transForm;
}
private static T013TransForm getT013TransForm() {
T013TransForm transForm = new T013TransForm();
transForm.setTranCode("T013");
transForm.initCommonParams("T013");
transForm.setSubmitUrl(T013_SUBMIT_URL);
transForm.setTranAmount("12.12");
transForm.setCurrencyType("1");
transForm.setPayType("BANK_B2C");
transForm.setReceiveUserId("213124234");
transForm.setNotifyFrontUrl("http://www.xxx.com/response.do");
transForm.setNotifyServerUrl("http://www.xxx.com/response.do");
transForm.setRiskExpand("111");
transForm.setGoodsInfo("111");
transForm.setOrderSubject("111");
transForm.setOrderDesc("1212");
transForm.setMerchantId("111accSSVV");
transForm.setMerUserIp("211.12.38.88");
transForm.setPayLimit("1");
return transForm;
}
private static F001TransForm getF001TransForm() {
F001TransForm transForm = new F001TransForm();
transForm.setTranCode("F001");
transForm.initCommonParams("F001");
transForm.setSubmitUrl(F001_SUBMIT_URL);
transForm.setOrgMerOrderId("T006_1021345435");
transForm.setDivideId("123456789");
transForm.setDivideDtlId("223456789");
return transForm;
}
private static T019TransForm getT019TransForm() {
T019TransForm transForm = new T019TransForm();
transForm.setTranCode("T019");
transForm.initCommonParams("T019");
transForm.setSubmitUrl(T019_SUBMIT_URL);
transForm.setTranAmount("100");
transForm.setReceiveUserId("123456789");
transForm.setMerUserIp("211.12.38.88");
transForm.setNotifyUrl("https//www.xxx.com/request.do");
transForm.setBusinessType("03");
transForm.setFeeType("0");
return transForm;
}
private static T020TransForm getT020TransForm() {
T020TransForm transForm = new T020TransForm();
transForm.setTranCode("T020");
transForm.initCommonParams("T020");
transForm.setSubmitUrl(T020_SUBMIT_URL);
transForm.setMerchantId("123");
transForm.setTranAmount("1");
transForm.setScanCodeId("28149154864202839");
transForm.setBusinessType("03");
transForm.setFeeType("0");
transForm.setCurrencyType("1");
transForm.setOrderSubject("测试");
transForm.setHolderName("张三");
transForm.setIdentityType("01");
transForm.setIdentityCode("");
transForm.setMinAge("10");
transForm.setRiskExpand("测试");
transForm.setTerminalId("123");
transForm.setTerminalIp("211.12.38.88");
transForm.setLocation("");
transForm.setReceiveUserId("");
transForm.setMerUserIp("211.12.38.88");
transForm.setNotifyServerUrl("");
transForm.setRemark("");
return transForm;
}
private static T021TransForm getT021TransForm() {
T021TransForm transForm = new T021TransForm();
transForm.setTranCode("T021");
transForm.initCommonParams("T021");
transForm.setSubmitUrl(T021_SUBMIT_URL);
transForm.setMerchantId("123");
transForm.setTerminalId("123");
transForm.setTerminalType("01");
transForm.setSerialNum("");
transForm.setTerminalAddress("");
return transForm;
}
private static T022TransForm getT022TransForm() {
T022TransForm transForm = new T022TransForm();
transForm.setTranCode("T022");
transForm.initCommonParams("T022");
transForm.setSubmitUrl(T022_SUBMIT_URL);
transForm.setMerchantId("123");
transForm.setTerminalId("123");
return transForm;
}
public static String getVerifyDataByTranCode(String tranCode, Map<String, Object> responseMap) {
StringBuffer sb = new StringBuffer();
String[] verifyFields = getVerifyArrByTranCode(tranCode);
for (int i = 0; i < verifyFields.length; i++) {
sb.append(verifyFields[i]);
sb.append("=[");
sb.append(responseMap.get(verifyFields[i]) == null ? "" : responseMap.get(verifyFields[i]));
sb.append("]");
}
return sb.toString();
}
private static String[] getVerifyArrByTranCode(String tranCode) {
switch (tranCode) {
case "R012":
return R012TransForm.verifyArr;
case "R013":
return R013TransForm.verifyArr;
case "R014":
return R014TransForm.verifyArr;
case "Q006":
return Q006TransForm.verifyArr;
case "Q007":
return Q007TransForm.verifyArr;
case "Q008":
return Q008TransForm.verifyArr;
case "Q009":
return Q009TransForm.verifyArr;
case "Q001":
return Q001TransForm.verifyArr;
case "Q002":
return Q002TransForm.verifyArr;
case "Q004":
return Q004TransForm.verifyArr;
case "R001":
return R001TransForm.verifyArr;
case "R002":
return R002TransForm.verifyArr;
case "R003":
return R003TransForm.verifyArr;
case "R004":
return R004TransForm.verifyArr;
case "R007":
return R007TransForm.verifyArr;
case "R008":
return R008TransForm.verifyArr;
case "R009":
return R009TransForm.verifyArr;
case "R010":
return R010TransForm.verifyArr;
case "R011":
return R011TransForm.verifyArr;
case "T002":
return T002TransForm.verifyArr;
case "T003":
return T003TransForm.verifyArr;
case "T004":
return T004TransForm.verifyArr;
case "T005":
return T005TransForm.verifyArr;
case "T006":
return T006TransForm.verifyArr;
case "T007":
return T007TransForm.verifyArr;
case "T008":
return T008TransForm.verifyArr;
case "R015":
return R015TransForm.verifyArr;
case "T009":
return T009TransForm.verifyArr;
case "T010":
return T010TransForm.verifyArr;
case "T011":
return T011TransForm.verifyArr;
case "T012":
return T012TransForm.verifyArr;
case "T013":
return T013TransForm.verifyArr;
case "F001":
return F001TransForm.verifyArr;
case "T019":
return T019TransForm.verifyArr;
case "T020":
return T020TransForm.verifyArr;
case "T021":
return T021TransForm.verifyArr;
case "T022":
return T022TransForm.verifyArr;
default:
return null;
}
}
}

23
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/service/HnaPayService.java

@ -0,0 +1,23 @@
package com.shop.cereshop.app.pay.hnapay.service;
import com.shop.cereshop.app.pay.PayService;
import com.shop.cereshop.app.pay.xs.domain.XsCallBackRequestVo;
/**
* 描述新生支付新账通分账服务类
*
* @author stevenhu
* @version 2025/02/13 15:23
*/
public interface HnaPayService extends PayService {
/**
* 解析新生支付的回调接口
* @param msg
* @return
* @throws Exception
*/
XsCallBackRequestVo parseCallBackRequestVo(String msg) throws Exception;
}

378
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/service/impl/HnaPayServiceImpl.java

@ -0,0 +1,378 @@
package com.shop.cereshop.app.pay.hnapay.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.gson.Gson;
import com.shop.cereshop.app.dao.business.CerePlatformBusinessDAO;
import com.shop.cereshop.app.dao.order.CereOrderProductDAO;
import com.shop.cereshop.app.dao.order.CereShopOrderDAO;
import com.shop.cereshop.app.pay.hnapay.domain.DivideAcctDtlVo;
import com.shop.cereshop.app.pay.hnapay.request.form.T005TransForm;
import com.shop.cereshop.app.pay.hnapay.request.form.T006TransForm;
import com.shop.cereshop.app.pay.hnapay.request.form.T009TransForm;
import com.shop.cereshop.app.pay.hnapay.request.init.InitForm;
import com.shop.cereshop.app.pay.hnapay.service.HnaPayService;
import com.shop.cereshop.app.pay.hnapay.utils.HttpUtils;
import com.shop.cereshop.app.pay.hnapay.utils.JsonUtils;
import com.shop.cereshop.app.pay.xs.domain.XsCallBackRequestVo;
import com.shop.cereshop.app.pay.xs.utils.CommonUtils;
import com.shop.cereshop.app.service.business.CerePlatformBusinessService;
import com.shop.cereshop.app.service.buyer.CereBuyerUserService;
import com.shop.cereshop.app.service.shop.CerePlatformShopService;
import com.shop.cereshop.app.utils.ContextUtil;
import com.shop.cereshop.commons.config.HnaPayConfig;
import com.shop.cereshop.commons.config.XspayConfig;
import com.shop.cereshop.commons.domain.business.CerePlatformBusiness;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.order.CereOrderParent;
import com.shop.cereshop.commons.domain.order.CereOrderProduct;
import com.shop.cereshop.commons.domain.order.CereShopOrder;
import com.shop.cereshop.commons.domain.shop.CerePlatformShop;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.EmptyUtils;
import com.shop.cereshop.commons.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* 描述
*
* @author stevenhu
* @version 2025/02/13 15:35
*/
@Service(value = "HnaPayService")
@Slf4j
public class HnaPayServiceImpl implements HnaPayService {
@Autowired
private CereShopOrderDAO cereShopOrderDAO;
@Autowired
private CereBuyerUserService cereBuyerUserService;
@Autowired
private CereOrderProductDAO cereOrderProductDAO;
@Autowired
private CerePlatformShopService cerePlatformShopService;
@Autowired
private CerePlatformBusinessService cerePlatformBusinessService;
@Autowired
private CerePlatformBusinessDAO cerePlatformBusinessDAO;
@Override
public Map<String, String> gotoPay(String orderFormid, BigDecimal money, String openid, String ip, Integer type, Integer huabeiPeriod) throws CoBusinessException, Exception {
List<CereShopOrder> orderList = null;
String cereOrderFormId = orderFormid;
String[] split = orderFormid.split("-");
if (!EmptyUtils.isEmpty(split)) {
cereOrderFormId = split[0];
}
//查询是否为父订单编号
CereOrderParent parent = cereShopOrderDAO.findByParentFormid(cereOrderFormId);
if (parent != null) {
//查询所有子订单数据
orderList = cereShopOrderDAO.findByParentId(parent.getParentId());
} else {
//子订单支付回调
orderList = cereShopOrderDAO.findByFormid(cereOrderFormId);
}
if (orderList.isEmpty()) {
throw new CoBusinessException("10000", "订单查找出错", "");
}
CereBuyerUser user = cereBuyerUserService.selectByBuyerUserId(orderList.get(0).getBuyerUserId());
if (user == null) {
throw new CoBusinessException("10000", "系统出错,请联系管理员", "");
}
List<CereOrderProduct> cereOrderProductList = cereOrderProductDAO.findByOrderIds(orderList.stream().map(CereShopOrder::getOrderId).collect(Collectors.toList()));
log.info("cereOrderProductList:" + new Gson().toJson(cereOrderProductList));
List<Long> shopIdList = orderList.stream().map(CereShopOrder::getShopId).distinct().collect(Collectors.toList());
List<CerePlatformShop> cerePlatformShopList = cerePlatformShopService.getByIdList(shopIdList);
List<Long> businessIdList = cerePlatformShopList.stream().map(CerePlatformShop::getBusinessId).distinct().collect(Collectors.toList());
List<CerePlatformBusiness> cerePlatformBusinessList = cerePlatformBusinessService.getByIdList(businessIdList);
for (CerePlatformBusiness cerePlatformBusiness : cerePlatformBusinessList) {
if (StringUtils.isEmpty(cerePlatformBusiness.getXsPayId())) {
//校验商家是否注册新账通商户
throw new CoBusinessException("10000", "商家" + cerePlatformBusiness.getBusinessName() + "未进行支付信息认证,请联系管理员", "");
}
}
T006TransForm transForm = new T006TransForm();
transForm.setTranCode("T006");
transForm.initCommonParams("T006");
transForm.setMerOrderId(orderFormid);
transForm.setSubmitUrl(InitForm.T006_SUBMIT_URL);
transForm.setTranAmount(String.valueOf(money));
transForm.setOrgCode("WECHATPAY");
transForm.setCurrencyType("1");
transForm.setRemark("备注信息");
transForm.setNotifyServerUrl(HnaPayConfig.APP_NOTICE_URL);
transForm.setMerUserIp(HnaPayConfig.IP);
transForm.setExpireTime("");
transForm.setRiskExpand("");
transForm.setGoodsInfo("商品名称");
transForm.setOrderSubject("商品名称");
transForm.setOrderDesc("");
//1-仅能使用借记卡 为空表示不限制
transForm.setPayLimit("1");
transForm.setAppId(XspayConfig.wxAppid);
transForm.setOpenId(user.getWechatOpenId());
transForm.setAliAppId("");
transForm.setBuyerLogonId("");
transForm.setBuyerId("");
transForm.setMerchantId(HnaPayConfig.MERCHANT_ID);
String project = ContextUtil.getProject();
String xsPayId = cerePlatformBusinessDAO.findXsPayIdByProject(project);
String merId = project.equals("0") ? HnaPayConfig.MERCHANT_ID : xsPayId;
//收款方id即收款方的新账通id
transForm.setReceiveUserId(merId);
transForm.setBusinessType("03");
transForm.setFeeType("1");
transForm.setDivideAcctDtl(this.buildSubMerchantOrderDetails(orderList, cereOrderProductList, cerePlatformShopList, cerePlatformBusinessList));
transForm.setFeeAmountUser("");
String result = "";
try {
result = HttpUtils.commonReq(transForm, false);
} catch (Exception e) {
e.printStackTrace();
}
//解析返回结果
JSONObject jsonObject = JSONObject.parseObject(result);
String payInfoStr = jsonObject.getJSONObject("content").getJSONObject("payInfo").getString("payInfo");
payInfoStr = payInfoStr.replace("{", "").replace("}", "");
String[] payInfoDetailArray = payInfoStr.split(",");
Map<String, String> resultMap = new HashMap<>();
for (String payInfoDetail : payInfoDetailArray) {
if (StringUtils.isNotBlank(payInfoDetail) && payInfoDetail.contains("=")) {
int firstIndex = payInfoDetail.indexOf("=");
String key = payInfoDetail.substring(0, firstIndex).trim();
String value = payInfoDetail.substring(firstIndex + 1).trim();
if (!StringUtils.isEmpty(XspayConfig.WX_SIGN_TYPE) && StringUtils.equals(key, "signType")) {
value = XspayConfig.WX_SIGN_TYPE;
}
resultMap.put(key, value);
}
}
return resultMap;
}
private String buildSubMerchantOrderDetails(List<CereShopOrder> orderList,
List<CereOrderProduct> cereOrderProductList,
List<CerePlatformShop> cerePlatformShopList,
List<CerePlatformBusiness> cerePlatformBusinessList) {
if(cereOrderProductList.isEmpty()){
return null;
}
List<DivideAcctDtlVo> divideAcctDtlVos = new ArrayList<>();
for (CereShopOrder cereShopOrder : orderList) {
CerePlatformShop cerePlatformShop = cerePlatformShopList.stream().filter(item ->
item.getShopId().equals(cereShopOrder.getShopId())).findFirst().orElse(null);
CerePlatformBusiness cerePlatformBusiness = cerePlatformBusinessList.stream().filter(item ->
item.getBusinessId().equals(cerePlatformShop.getBusinessId())).findFirst().orElse(null);
List<CereOrderProduct> orderProductList = cereOrderProductList.stream().filter(item -> item.getOrderId().equals(cereShopOrder.getOrderId())).collect(Collectors.toList());
BigDecimal prodTotalAmount = BigDecimal.ZERO;
for (CereOrderProduct cereOrderProduct : orderProductList) {
BigDecimal productShareAmount = cereOrderProduct.getActualPrice().add(cereOrderProduct.getLogisticsPrice())
.subtract(cereOrderProduct.getUseCreditAmount())
.subtract(cereOrderProduct.getPlatformCommission());
prodTotalAmount = prodTotalAmount.add(productShareAmount);
}
DivideAcctDtlVo divideAcctDtlVo = new DivideAcctDtlVo();
divideAcctDtlVo.setLedgerUserId(cerePlatformBusiness.getXsPayId());
divideAcctDtlVo.setAmount(String.valueOf(prodTotalAmount));
divideAcctDtlVos.add(divideAcctDtlVo);
//平台
BigDecimal platformShareAmount = cereShopOrder.getPlatformCommission();
DivideAcctDtlVo platDivideAcctDtlVo = new DivideAcctDtlVo();
platDivideAcctDtlVo.setLedgerUserId(HnaPayConfig.MER_ID);
platDivideAcctDtlVo.setAmount(String.valueOf(platformShareAmount));
divideAcctDtlVos.add(platDivideAcctDtlVo);
}
return JSONUtil.toJsonStr(divideAcctDtlVos);
}
@Override
public Map<String, String> refund(String orderFormid, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
return null;
}
@Override
public Map<String, String> orderRefund(String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
String result = "";
T005TransForm transForm = new T005TransForm();
transForm.setTranCode("T005");
transForm.initCommonParams("T005");
transForm.setSubmitUrl(InitForm.T005_SUBMIT_URL);
transForm.setSerialId("thee" + System.currentTimeMillis());
transForm.setOrgMerOrderId(outTradeNo);
//transForm.setOrgSubmitTime(orderInfo.getPaySubmitTime());
transForm.setOrderAmount(String.valueOf(total));
transForm.setRefundSource("1");
transForm.setDestType("1");
//退款类型 1:全额退款 2部分退款
transForm.setRefundType("1");
transForm.setRefundAmount(String.valueOf(refund));
transForm.setNotifyUrl(HnaPayConfig.REFUND_NOTICE_URL);
transForm.setRemark("退款备注信息");
try {
result = HttpUtils.commonReq(transForm, false);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public Map<String, String> refundBond(String orderFormid, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
return null;
}
@Override
public String getCollectionCode(String orderFormid, BigDecimal money, String ip, String tradeType) throws CoBusinessException, Exception {
return null;
}
@Override
public String getOrderCollectionCode(String orderFormid, BigDecimal money, String ip, String tradeType) throws CoBusinessException, Exception {
List<CereShopOrder> orderList = null;
String cereOrderFormId = orderFormid;
String[] split = orderFormid.split("-");
if(!EmptyUtils.isEmpty(split)) {
cereOrderFormId = split[0];
}
//查询是否为父订单编号
CereOrderParent parent = cereShopOrderDAO.findByParentFormid(cereOrderFormId);
if (parent != null) {
//查询所有子订单数据
orderList = cereShopOrderDAO.findByParentId(parent.getParentId());
} else {
//子订单支付回调
orderList = cereShopOrderDAO.findByFormid(cereOrderFormId);
}
if(orderList.isEmpty()){
throw new CoBusinessException("10000","订单查找出错", "");
}
log.info("orderList:" + new Gson().toJson(orderList));
CereBuyerUser user = cereBuyerUserService.selectByBuyerUserId(orderList.get(0).getBuyerUserId());
if(user == null){
throw new CoBusinessException("10000","系统出错,请联系管理员", "");
}
List<CereOrderProduct> cereOrderProductList = cereOrderProductDAO.findByOrderIds(orderList.stream().map(CereShopOrder::getOrderId).collect(Collectors.toList()));
log.info("cereOrderProductList:" + new Gson().toJson(cereOrderProductList));
List<Long> shopIdList = orderList.stream().map(CereShopOrder::getShopId).distinct().collect(Collectors.toList());
List<CerePlatformShop> cerePlatformShopList = cerePlatformShopService.getByIdList(shopIdList);
List<Long> businessIdList = cerePlatformShopList.stream().map(CerePlatformShop::getBusinessId).distinct().collect(Collectors.toList());
List<CerePlatformBusiness> cerePlatformBusinessList = cerePlatformBusinessService.getByIdList(businessIdList);
for (CerePlatformBusiness cerePlatformBusiness : cerePlatformBusinessList) {
if(StringUtils.isEmpty(cerePlatformBusiness.getXsPayId())){
throw new CoBusinessException("10000","商家" + cerePlatformBusiness.getBusinessName() + "未进行支付信息认证,请联系管理员", "");
}
}
String result = "";
T009TransForm transForm = new T009TransForm();
transForm.setTranCode("T009");
transForm.initCommonParams("T009");
transForm.setSubmitUrl(InitForm.T009_SUBMIT_URL);
transForm.setTranAmount(String.valueOf(money));
//tradeType: WECHATPAY-微信支付 ALIPAY-支付宝支付 TENPAY-腾讯 UNIONPAY-银联
transForm.setOrgCode(tradeType);
transForm.setCurrencyType("1");
//transForm.setRemark("");
transForm.setNotifyServerUrl(HnaPayConfig.APP_NOTICE_URL);
transForm.setMerUserIp(HnaPayConfig.IP);
//transForm.setExpireTime("");
transForm.setRiskExpand("");
transForm.setGoodsInfo("");
transForm.setOrderSubject("");
transForm.setOrderDesc("");
transForm.setPayLimit("1");
transForm.setMerchantId(HnaPayConfig.MERCHANT_ID);
String project = ContextUtil.getProject();
String xsPayId = cerePlatformBusinessDAO.findXsPayIdByProject(project);
String merId = project.equals("0") ? HnaPayConfig.MERCHANT_ID : xsPayId;
//收款方id即收款方的新账通id
transForm.setReceiveUserId(merId);
transForm.setBusinessType("03");
transForm.setFeeType("1");
transForm.setDivideAcctDtl(this.buildSubMerchantOrderDetails(orderList, cereOrderProductList, cerePlatformShopList, cerePlatformBusinessList));
transForm.setFeeAmountUser("");
try {
result = HttpUtils.commonReq(transForm, false);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获取订单二维码
* @param msg
* @return
* @throws Exception
*/
@Override
public XsCallBackRequestVo parseCallBackRequestVo(String msg) throws Exception {
//base64 decode
String msgStr = new String(Base64.getDecoder().decode(msg));
//LinkedHashMap json字符串转map时保持字段顺序不变
JSONObject headContentMap = JSONObject.parseObject(msgStr);
String resSign = headContentMap.getString("sign");
headContentMap.remove("sign");
//headContentMap 转为json字符串时保留字段值为null的字段
SerializerFeature[] serializerFeatures = new SerializerFeature[]{SerializerFeature.WriteMapNullValue};
String headContentJson = JSONObject.toJSONString(headContentMap,serializerFeatures);
CommonUtils.verifySignature(headContentJson, resSign);
JSONObject head = headContentMap.getJSONObject("head");
JSONObject content = headContentMap.getJSONObject("content");
String responseCode = content.getString("responseCode");
if(StrUtil.isNotBlank(responseCode) && StrUtil.isNotBlank(responseCode) && !StrUtil.equals(responseCode, "0")
&& !StrUtil.equals(responseCode, "0000") && !StrUtil.equals(responseCode, "0001")){
String errorMsg = content.getString("responseDesc");
throw new CoBusinessException(responseCode, errorMsg);
}
XsCallBackRequestVo xsCallBackRequestVo = new XsCallBackRequestVo();
xsCallBackRequestVo.setHead(head);
xsCallBackRequestVo.setContent(content);
return xsCallBackRequestVo;
}
}

61
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/Base64Util.java

@ -0,0 +1,61 @@
/*
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* www.hnapay.com
*/
package com.shop.cereshop.app.pay.hnapay.utils;
import java.util.Base64;
/**
* base64编码工具类
*/
@SuppressWarnings({"all"})
public class Base64Util {
/**
* s 进行 BASE64 编码
*
* @param s
* @return
*/
public static String encode(byte[] s) {
if (s == null)
return null;
return Base64.getEncoder().encodeToString(s);
}
/**
* s 进行 BASE64 编码
*
* @param s
* @return
*/
public static String encode(String s) {
if (s == null)
return null;
return encode(s.getBytes());
}
/**
* BASE64 编码的字符串 s 进行解码
*
* @param s
* @return
*/
public static byte[] decode(String s) {
if (s == null)
return null;
try {
byte[] b = Base64.getDecoder().decode(s);
return b;
} catch (Exception e) {
return null;
}
}
}

102
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HexStringByte.java

@ -0,0 +1,102 @@
/*
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* www.hnapay.com
*/
package com.shop.cereshop.app.pay.hnapay.utils;
/**
* 十六进制转换
*/
public class HexStringByte {
/**
* 字符串转换成十六进制值
* @param bin String 我们看到的要转换成十六进制的字符串
* @return
*/
public static String stringToHex(String bin) {
char[] digital = "0123456789ABCDEF".toCharArray();
StringBuffer sb = new StringBuffer("");
byte[] bs = bin.getBytes();
int bit;
for (int i = 0; i < bs.length; i++) {
bit = (bs[i] & 0x0f0) >> 4;
sb.append(digital[bit]);
bit = bs[i] & 0x0f;
sb.append(digital[bit]);
}
return sb.toString();
}
/**
* 十六进制转换字符串
* @param hex String 十六进制
* @return String 转换后的字符串
*/
public static String hexToString(String hex) {
String digital = "0123456789ABCDEF";
char[] hex2char = hex.toCharArray();
byte[] bytes = new byte[hex.length() / 2];
int temp;
for (int i = 0; i < bytes.length; i++) {
temp = digital.indexOf(hex2char[2 * i]) * 16;
temp += digital.indexOf(hex2char[2 * i + 1]);
bytes[i] = (byte) (temp & 0xff);
}
return new String(bytes);
}
/**
* java字节码转字符串
* @param bts
* @return
*/
public static String byteToHex(byte[] bts) {
String des = "";
String tmp = null;
for (int i = 0; i < bts.length; i++) {
tmp = (Integer.toHexString(bts[i] & 0xFF));
if (tmp.length() == 1) {
des += "0";
}
des += tmp;
}
return des;
}
/**
* hex2byte.
*
* @param hexStr hexStr
* @return byte[]
*/
public static byte[] hex2byte(String hexStr) {
byte[] bts = new byte[hexStr.length() / 2];
for (int i = 0, j = 0; j < bts.length; j++) {
bts[j] = (byte) Integer.parseInt(hexStr.substring(i, i + 2), 16);
i += 2;
}
return bts;
}
/**
* 字符串转java字节码
* @param b
* @return
*/
public static byte[] hexToByte(byte[] b) {
if ((b.length % 2) != 0) {
throw new IllegalArgumentException("长度不是偶数");
}
byte[] b2 = new byte[b.length / 2];
for (int n = 0; n < b.length; n += 2) {
String item = new String(b, n, 2);
// 两位一组表示一个字节,把这样表示的16进制字符串还原成一个进制字节
b2[n / 2] = (byte) Integer.parseInt(item, 16);
}
b = null;
return b2;
}
}

195
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HnaPayDateUtils.java

@ -0,0 +1,195 @@
package com.shop.cereshop.app.pay.hnapay.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class HnaPayDateUtils {
/** 时间格式:yyyyMMddHHmmss'. */
public static String DEFAULT_PATTERN = "yyyyMMddHHmmss";
/** 时间格式:yyyyMMdd'. */
public static String yyyyMMdd = "yyyyMMdd";
/** 时间格式:yyyy-MM-dd'. */
public static String yyyy_MM_dd = "yyyy-MM-dd";
/** 时间格式:HH:mm:ss'. */
public static String HH_mm_ss = "HH:mm:ss";
/** 时间格式:yyyy-MM-dd' 'HH:mm:ss'. */
public static String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd' 'HH:mm:ss";
/** 时间格式:yyyy-MM-dd' 'HH:mm'. */
public static String yyyy_MM_dd_HH_mm = "yyyy-MM-dd' 'HH:mm";
/**
* 获取当前时间(格式:yyyyMMddHHmmss)
*
* @return
*/
public static String getCurrDate() {
return getCurrDate(DEFAULT_PATTERN);
}
/**
* 字符串转日期默认格式为yyyyMMddHHmmss
*
* @param str
* @return
*/
public static Date strToDate(String str) {
return strToDate(str, DEFAULT_PATTERN);
}
/**
* 日期格式化默认格式为yyyyMMddHHmmss
*
* @param date
* 日期
* @return
*/
public static String format(Date date) {
return HnaPayDateUtils.format(date, DEFAULT_PATTERN);
}
/**
* 字符串转日期
*
* @param str
* 时间
* @param pattern
* 格式
* @return
*/
public static Date strToDate(String str, String pattern) {
SimpleDateFormat format = new SimpleDateFormat(pattern);
Date date = null;
try {
date = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 日期格式化
*
* @param date
* 日期
* @param pattern
* 格式
* @return
*/
public static String format(Date date, String pattern) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(date);
}
/**
* 获取当前时间
*
* @param pattern
* 格式
* @return
*/
public static String getCurrDate(String pattern) {
long d = System.currentTimeMillis();
Date date = new Date(d);
return format(date, pattern);
}
/**
* 获取系统当前时间
*
* @return
*/
public static Date getSystemDate() {
long d = System.currentTimeMillis();
Date date = new Date(d);
return date;
}
/**
* 格式化时间
*
* @param strTime
* @param pattern
* @return
*/
public static String getTime(String strTime, String pattern) {
SimpleDateFormat s = new SimpleDateFormat(pattern);
try {
return String.valueOf(s.parse(strTime).getTime());// 时间戳
} catch (ParseException e) {
e.printStackTrace();
return String.valueOf(new Date().getTime());
}
}
/**
* 格式化日期格式
*
* @param date
* @param mask
* @return
*/
public static final String date2string(Date date, String style) {
SimpleDateFormat sdf = new SimpleDateFormat(style);
return sdf.format(date);
}
/**
* 获取本地日期时间.
*
* @return 本地日期时间yyyyMMddHHmmss
*/
public static String getLocalFullDateTime14() {
return date2string(new Date(), DEFAULT_PATTERN);
}
/**
* 返回指定格式时间
* @param mask
* @return
*/
public static final String now2string(String mask){
return date2string(new Date(), mask);
}
/**
*
* @param date
* @param field
* @param amount
* @return 对指定的日期做加减运算<br>
* add(new Date(), Calendar.DATE, -1)返回昨天的日期<br>
* add(new Date(), Calendar.YEAR, 1)返回一年后的今天
*/
public static Date add(Date date, int field, int amount) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(field, amount);
return c.getTime();
}
/**
* 返回需要格式的字符串时间
* @param str 字符串时间
* @param patternS 字符串格式
* @param patternE 格式化后的格式
* @return
*/
public static String strToStr(String str, String patternS,String patternE){
return format(strToDate(str,patternS),patternE);
}
}

167
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HnapaySign.java

@ -0,0 +1,167 @@
/*
* Copyright (c) 2015.
* www.hnapay.com
*/
package com.shop.cereshop.app.pay.hnapay.utils;
import com.shop.cereshop.commons.config.HnaPayConfig;
import com.shop.cereshop.commons.exception.CoBusinessException;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.security.Key;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
/**
* 签名 验签 加解密
*/
public class HnapaySign {
/**
* RSA最大加密明文大小
*/
private static final int MAX_ENCRYPT_BLOCK = 117;
/**
* 签名
*
* @param privateKey
* 企业用户编号
* @param merData
* 明文串
* @return 签名后的消息
* @throws CoBusinessException
*/
public static byte[] sign(PrivateKey privateKey, String merData) throws CoBusinessException {
try {
return RSAAlgorithms.sign(privateKey, merData);
} catch (Exception e) {
throw new CoBusinessException("读取密钥异常", e);
}
}
/**
* 验证签名
*
* @param merData
* 明文串
* @param signMsg
* 签名消息
* @return 验证签名的结果 true--成功 false--失败
* @throws CoBusinessException
*/
public static boolean verify(String merData, String signMsg) throws CoBusinessException {
boolean result = false;
String hexPublicKey = HexStringByte.byteToHex(Base64Util.decode(HnaPayConfig.NCOUNT_PUBLIC_KEY));
String signVal = HexStringByte.byteToHex(Base64Util.decode(signMsg));
result = verifySignatureByRSA(merData, signVal, "UTF-8", hexPublicKey);
return result;
}
/**
* @param src
* @param dit
* @param charsetType
* @param publicKey
* @return
* @throws CoBusinessException
*/
private static boolean verifySignatureByRSA(String src, String dit, String charsetType, String publicKey)
throws CoBusinessException {
if ((src == null) || ("".equals(src.trim()))) {
throw new CoBusinessException("src is empty ,verifySignatureByRSA无法执行");
}
if ((dit == null) || ("".equals(dit.trim()))) {
throw new CoBusinessException("dit is empty ,verifySignatureByRSA无法执行");
}
try {
return RSAAlgorithms.verify(publicKey, src, dit);
} catch (Exception e) {
e.printStackTrace();
throw new CoBusinessException("验证签名出现异常:请检查输入参数");
}
}
/**
* <p>
* 公钥加密
* </p>
*
* @param data
* 源数据
* @return
* @throws Exception
*/
public static byte[] encryptByPublicKey(byte[] data, String key) throws Exception {
if (data == null) {
throw new Exception("需要加密的数据为空");
}
PublicKey publicKey = getPublicKey(key);
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(publicKey.getEncoded());
KeyFactory keyFactory = KeyFactory.getInstance(HnaPayConfig.ALGORITHM);
Key publicK = keyFactory.generatePublic(x509KeySpec);
// 对数据加密
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
cipher.init(Cipher.ENCRYPT_MODE, publicK);
int inputLen = data.length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] cache;
int i = 0;
// 对数据分段加密
while (inputLen - offSet > 0) {
if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
} else {
cache = cipher.doFinal(data, offSet, inputLen - offSet);
}
out.write(cache, 0, cache.length);
i++;
offSet = i * MAX_ENCRYPT_BLOCK;
}
byte[] encryptedData = out.toByteArray();
out.close();
return encryptedData;
}
/**
* @param publicKey
* 密钥信息
* @return 返回公钥
* @throws Exception
*/
private static PublicKey getPublicKey(String publicKey) throws Exception {
PublicKey pubKey = null;
try {
KeyFactory keyFactory = KeyFactory.getInstance(HnaPayConfig.ALGORITHM);
pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(Base64Util.decode(publicKey)));
} catch (InvalidKeySpecException e) {
throw new Exception("公钥无效!", e);
}
return pubKey;
}
/**
* hex2byte.
*
* @param hexStr
* hexStr
* @return byte[]
*/
public static byte[] hex2byte(String hexStr) {
byte[] bts = new byte[hexStr.length() / 2];
for (int i = 0, j = 0; j < bts.length; j++) {
bts[j] = (byte) Integer.parseInt(hexStr.substring(i, i + 2), 16);
i += 2;
}
return bts;
}
}

148
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HttpClientUtils.java

@ -0,0 +1,148 @@
/*
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* www.hnapay.com
*/
package com.shop.cereshop.app.pay.hnapay.utils;
import com.shop.cereshop.commons.exception.CoBusinessException;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import javax.naming.CommunicationException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* HttpClient工具类
*
*/
public class HttpClientUtils {
private String sendEncoding = "UTF-8";
private int retryConnTimes = 1;
private int timeout = 5*60*1000;
/**
* HTTP请求
*
* @param obj
* @return
* @throws CommunicationException
*/
/* String url=this.notifyBtJumpPath+"?contractId="+contractId+"&inTxnCd="+IntTxnCd._00203.value;*/
public String submit(Object obj ,String url) throws CoBusinessException {
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(url);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(retryConnTimes, false));
client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
client.getHttpConnectionManager().getParams().setSoTimeout(timeout);
if (StringUtils.isNotEmpty(this.sendEncoding)) {
method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, sendEncoding);
}
method.setRequestHeader("User-Agent", "Rich Powered/1.0");
if (obj != null) {
if (obj instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, String> paraMap = (Map<String, String>) obj;
for (Iterator<String> iter = paraMap.keySet().iterator(); iter.hasNext();) {
String key = iter.next();
String value = "";
if (paraMap.get(key) != null) {
value = paraMap.get(key);
}
method.addParameter(key, value);
}
} else if (obj instanceof byte[]) {
method.setRequestEntity(new ByteArrayRequestEntity((byte[]) obj));
} else {
throw new IllegalArgumentException("submit(Object obj): obj should be Map or byte[]");
}
}
int statusCode = 0;
byte[] responseBody = null;
String result = "";
try {
statusCode = client.executeMethod(method);
responseBody = method.getResponseBody();
result = new String(responseBody, sendEncoding);
} catch (HttpException e) {
} catch (IOException e) {
} finally {
method.releaseConnection();
client.getHttpConnectionManager().closeIdleConnections(0);
}
if (statusCode != HttpStatus.SC_OK) {
throw new CoBusinessException("HTTP状态:"+String.valueOf(statusCode));
}
return result;
}
public String query(Object obj ,String url) throws CoBusinessException {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(retryConnTimes, false));
client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
client.getHttpConnectionManager().getParams().setSoTimeout(timeout);
if (StringUtils.isNotEmpty(this.sendEncoding)) {
method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, sendEncoding);
}
method.setRequestHeader("User-Agent", "Rich Powered/1.0");
List<NameValuePair> params = new ArrayList<NameValuePair>();
if (obj != null) {
if (obj instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, String> paraMap = (Map<String, String>) obj;
for (Iterator<String> iter = paraMap.keySet().iterator(); iter.hasNext();) {
String key = iter.next();
String value = "";
if (paraMap.get(key) != null) {
value = paraMap.get(key);
}
params.add(new NameValuePair(key,value));
}
} else if (obj instanceof byte[]) {
} else {
throw new IllegalArgumentException("submit(Object obj): obj should be Map or byte[]");
}
}
int statusCode = 0;
byte[] responseBody = null;
String result = "";
try {
NameValuePair[] temp = new NameValuePair[params.size()];
method.setQueryString(params.toArray(temp));
statusCode = client.executeMethod(method);
responseBody = method.getResponseBody();
result = new String(responseBody, sendEncoding);
} catch (HttpException e) {
} catch (IOException e) {
} finally {
method.releaseConnection();
client.getHttpConnectionManager().closeIdleConnections(0);
}
if (statusCode != HttpStatus.SC_OK) {
throw new CoBusinessException("HTTP状态:"+String.valueOf(statusCode));
}
return result;
}
}

114
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HttpUtils.java

@ -0,0 +1,114 @@
package com.shop.cereshop.app.pay.hnapay.utils;
import com.shop.cereshop.app.pay.hnapay.request.form.BaseTransForm;
import com.shop.cereshop.app.pay.hnapay.request.init.InitForm;
import com.shop.cereshop.commons.config.HnaPayConfig;
import com.shop.cereshop.commons.utils.Base64Util;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
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 java.io.File;
import java.io.FileInputStream;
import java.security.PrivateKey;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class HttpUtils {
public static String httpPost(String url,String msg) throws Exception {
//发送请求
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
//此处设值防止新生将该次请求当成手机端请求
httpPost.setHeader("User-Agent","Mozilla/5.0(Windows NT 6.1;Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0");
List<NameValuePair> params=new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("msg",msg));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params,"UTF-8");
httpPost.setEntity(entity);
CloseableHttpResponse response = httpclient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
String responseStr = EntityUtils.toString(responseEntity, "UTF-8");
return responseStr;
}
public static String httpPostFile(String url,String msg,File attachedFile) throws Exception {
//发送请求
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
//设置请求参数
MultipartEntityBuilder builder = MultipartEntityBuilder.create().setMode(HttpMultipartMode.RFC6532);
builder.addTextBody("msg", msg, ContentType.TEXT_PLAIN);
//把文件加到HTTP的post请求中
if(attachedFile != null) {
builder.addBinaryBody("attachedFile", new FileInputStream(attachedFile), ContentType.APPLICATION_OCTET_STREAM, attachedFile.getName());
}
HttpEntity multipart = builder.build();
httpPost.setEntity(multipart);
CloseableHttpResponse response = httpclient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
String responseStr = EntityUtils.toString(responseEntity, "UTF-8");
return responseStr;
}
public static String commonReq(BaseTransForm base, boolean isUploadFile) throws Exception {
//1加载商户私钥
PrivateKey privateKey = KeyUtils.loadPrivateKey(HnaPayConfig.MER_PRIVATE_KEY);
//4获取加密字段的json串明文
String encryptStr = base.getEncryptJsonStr();
System.out.println("待加密字符串为:"+encryptStr);
//5使用平台公钥进行rsa加密
String msgCipherText = Base64Util.encode(HnapaySign.encryptByPublicKey(encryptStr.getBytes(), HnaPayConfig.NCOUNT_PUBLIC_KEY)).replace("\n", "").replace("\r", "");
System.out.println("加密后字符串为:"+msgCipherText);
base.setMsgCiphertext(msgCipherText);
//6使用商户私钥进行签名
String signValue = Base64Util.encode(HnapaySign.sign(privateKey, base.getCommonSignStr())).replace("\n", "").replace("\r", "");
System.out.println("签名后字符串为:"+signValue);
base.setSignValue(signValue);
//7构建提交至平台的请求参数
Map<String,Object> reqMap = base.getCommonReqSignParams(isUploadFile);
reqMap.put("signValue", base.getSignValue());
reqMap.put("charset", "1");
System.out.println("提交字符串为:"+ JsonUtils.toJson(reqMap));
String response = null;
if (base.getSubmitUrl().startsWith("https://")) {
HttpsTransport httpsTransport = new HttpsTransport();
httpsTransport.setSendEncoding("UTF-8");
httpsTransport.setUrl(base.getSubmitUrl());
response = (String) httpsTransport.submit(reqMap);
} else {
HttpClientUtils httpClientUtils = new HttpClientUtils();
response = httpClientUtils.submit(reqMap, base.getSubmitUrl());
}
System.out.println("响应字符串为:"+JsonUtils.toJson(response));
//8返回参数转map
Map<String,Object> responseMap = JsonUtils.jsonToMap(response);
//9根据交易码构建不同接口验签明文串
String verifyFieldStr = InitForm.getVerifyDataByTranCode(base.getTranCode(), responseMap);
System.out.println("验签明文字符串为:"+verifyFieldStr);
//10使用平台公钥进行验签
boolean verifyResult = HnapaySign.verify(verifyFieldStr, responseMap.get("signValue").toString());
System.out.println("验签结果为:"+verifyResult);
return verifyResult ? response : null;
}
}

211
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/HttpsTransport.java

@ -0,0 +1,211 @@
/*
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* www.hnapay.com
*/
package com.shop.cereshop.app.pay.hnapay.utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.*;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import javax.naming.CommunicationException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* 使用httpClient形式发送报文
*
*/
public class HttpsTransport {
private String url = null;
private int timeout = 5*60*1000;
private int retryConnTimes = 5;
private String sendEncoding = null;
public HttpsTransport() {
}
public Object submit(Object obj) throws CommunicationException {
CloseableHttpClient httpClient = HttpClients.custom()
.setRetryHandler(new DefaultHttpRequestRetryHandler(retryConnTimes, false))
.build();
HttpPost method = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(timeout)
.setConnectTimeout(timeout)
.setConnectionRequestTimeout(timeout)
.build();
if (StringUtils.isNotEmpty(this.sendEncoding)) {
method.setHeader(HTTP.CONTENT_ENCODING, sendEncoding);
}
method.setHeader(HTTP.USER_AGENT, "Rich Powered/1.0");
method.setConfig(requestConfig);
if (obj instanceof Map) {
Map paraMap = (Map) obj;
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
for (Iterator iter = paraMap.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
nvps.add(new BasicNameValuePair(key, (String) paraMap.get(key)));
}
try {
method.setEntity(new UrlEncodedFormEntity(nvps, this.sendEncoding));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} else if (obj instanceof byte[]) {
method.setEntity(new ByteArrayEntity((byte[]) obj));
} else if(obj instanceof String){
try{
StringEntity entity = new StringEntity( obj.toString(), this.sendEncoding);
if( this.sendEncoding != null){
entity.setContentEncoding( this.sendEncoding);
}
entity.setContentType( "text/xml");
method.setEntity(entity);
}catch(Exception e){
}
}else {
throw new IllegalArgumentException("submit(Object obj): obj should be Map ,String,or byte[]");
}
int statusCode = 0;
String result = "";
CloseableHttpResponse response = null;
try {
response = httpClient.execute(method);
statusCode = response.getStatusLine().getStatusCode();
HttpEntity responseEntity = response.getEntity();
result = EntityUtils.toString(responseEntity, sendEncoding);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (response != null)
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (statusCode != HttpStatus.SC_OK) {
throw new CommunicationException(String.valueOf(statusCode));
}
return result;
}
public Object query(Object obj) throws CommunicationException {
CloseableHttpClient httpClient = HttpClients.custom()
.setRetryHandler(new DefaultHttpRequestRetryHandler(retryConnTimes, false))
.build();
HttpGet method = null;
if (obj instanceof Map) {
Map paraMap = (Map) obj;
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
for (Iterator iter = paraMap.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
nvps.add(new BasicNameValuePair(key, (String) paraMap.get(key)));
}
try {
//method.setEntity(new UrlEncodedFormEntity(nvps, this.sendEncoding));
String str = EntityUtils.toString(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
method = new HttpGet(url + "?" + str);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if (obj instanceof byte[]) {
} else if(obj instanceof String){
method = new HttpGet(url + "?" + obj.toString());
}else {
throw new IllegalArgumentException("submit(Object obj): obj should be Map ,String,or byte[]");
}
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(timeout)
.setConnectTimeout(timeout)
.setConnectionRequestTimeout(timeout)
.build();
if (StringUtils.isNotEmpty(this.sendEncoding)) {
method.setHeader(HTTP.CONTENT_ENCODING, sendEncoding);
}
method.setHeader(HTTP.USER_AGENT, "Rich Powered/1.0");
method.setConfig(requestConfig);
int statusCode = 0;
String result = "";
CloseableHttpResponse response = null;
try {
response = httpClient.execute(method);
statusCode = response.getStatusLine().getStatusCode();
HttpEntity responseEntity = response.getEntity();
result = EntityUtils.toString(responseEntity, sendEncoding);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (response != null)
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (statusCode != HttpStatus.SC_OK) {
throw new CommunicationException(String.valueOf(statusCode));
}
return result;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public void setUrl(String url) {
this.url = url;
}
public void setRetryConnTimes(int retryConnTimes) {
this.retryConnTimes = retryConnTimes;
}
public void setSendEncoding(String sendEncoding) {
this.sendEncoding = sendEncoding;
}
}

82
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/JsonUtils.java

@ -0,0 +1,82 @@
/*
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* www.hnapay.com
*/
package com.shop.cereshop.app.pay.hnapay.utils;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* JSON操作工具类
*
*/
public class JsonUtils {
/**
* 将JSON串转为Map
*
* @param json
* @return
* @throws JsonParseException
* @throws JsonMappingException
* @throws IOException
*/
@SuppressWarnings("unchecked")
public static Map<String, Object> jsonToMap(String json) {
if (StringUtils.isBlank(json)) {
return null;
}
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
try {
model = mapper.readValue(json, Map.class);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return model;
}
/**
* 将对象解析为json串
*
* @param obj
* @return
* @throws JsonGenerationException
* @throws JsonMappingException
* @throws IOException
*/
public static String toJson(Object obj) throws JsonGenerationException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(obj);
return json;
}
/**
* JSON数组转LIST
* @param json
* @param clazz
* @param <T>
* @return
*/
public static <T> List<T> jsonArrayToList(String json,Class<T> clazz){
return JSONArray.parseArray(json,clazz);
}
}

32
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/KeyUtils.java

@ -0,0 +1,32 @@
package com.shop.cereshop.app.pay.hnapay.utils;
import com.shop.cereshop.commons.config.HnaPayConfig;
import com.shop.cereshop.commons.exception.CoBusinessException;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
public class KeyUtils {
/**
* 加载私钥
*
*/
public static PrivateKey loadPrivateKey(String privateKey) throws CoBusinessException {
// 去除头尾标志
// 去除换行符
privateKey = privateKey.replace("\r", "").replace("\n", "").replace(" ", "");
byte[] bPriKey = Base64Util.decode(privateKey);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bPriKey);
KeyFactory keyFactory;
try {
keyFactory = KeyFactory.getInstance(HnaPayConfig.ALGORITHM);
PrivateKey key = keyFactory.generatePrivate(keySpec);
return key;
} catch (Exception e) {
e.printStackTrace();
throw new CoBusinessException("加载私钥异常", e);
}
}
}

105
cereshop-app/src/main/java/com/shop/cereshop/app/pay/hnapay/utils/RSAAlgorithms.java

@ -0,0 +1,105 @@
/*
* Copyright (c) 2016. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* www.hnapay.com
*/
package com.shop.cereshop.app.pay.hnapay.utils;
import com.shop.cereshop.commons.config.HnaPayConfig;
import com.shop.cereshop.commons.exception.CoBusinessException;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
/**
* 签名验签
*/
public class RSAAlgorithms {
/**
* @param publicKey
* 公钥HEX字符串
* @return 返回公钥
* @throws Exception
*/
public static PublicKey getPublicKey(String publicKey) throws CoBusinessException {
PublicKey pubKey = null;
try {
byte[] encodedKey = HexStringByte.hexToByte(publicKey.getBytes());
KeyFactory keyFactory = KeyFactory.getInstance(HnaPayConfig.ALGORITHM);
pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey));
} catch (InvalidKeySpecException e) {
throw new CoBusinessException("公钥无效!", e);
} catch (NoSuchAlgorithmException e) {
throw new CoBusinessException("算法类型无效!", e);
}
return pubKey;
}
/**
* @param priKey
* 私钥
* @param data
* 要签名的数据
* @return 签名消息
* @throws Exception
*/
public static byte[] sign(PrivateKey priKey, String data) throws CoBusinessException {
try {
Signature signet = Signature.getInstance(HnaPayConfig.SIGN_ALGORITHM);
signet.initSign(priKey);
signet.update(data.getBytes("UTF-8"));
return signet.sign();
} catch (Exception e) {
throw new CoBusinessException(e.getMessage());
}
}
/**
* 验证签名
*
* @param publicKey
* 公钥HEX字符串
* @param merData
* 签名数据
* @param signMsg
* 签名消息
* @return 返回验证结果 true 成功 false 失败
* @throws Exception
*/
public static Boolean verify(String publicKey, String merData, String signMsg) throws CoBusinessException {
boolean bVerify = false;
Signature signet = null;
try {
signet = Signature.getInstance(HnaPayConfig.SIGN_ALGORITHM);
} catch (NoSuchAlgorithmException e) {
throw new CoBusinessException("算法类型不能为空!", e);
}
PublicKey pubKey = getPublicKey(publicKey);
try {
signet.initVerify(pubKey);
} catch (InvalidKeyException e) {
throw new CoBusinessException("公钥无效!", e);
}
try {
signet.update(merData.getBytes("UTF-8"));
} catch (SignatureException e) {
throw new CoBusinessException("验签时符号异常!", e);
} catch (UnsupportedEncodingException e) {
throw new CoBusinessException("不支持的编码方式", e);
}
try {
bVerify = signet.verify(HexStringByte.hex2byte(signMsg));
} catch (SignatureException e) {
throw new CoBusinessException("验签异常!", e);
}
return bVerify;
}
}

4
cereshop-app/src/main/resources/mybatis/mapper/business/CerePlatformBusinessDAO.xml

@ -325,4 +325,8 @@
<select id="findByDomain" resultType="com.shop.cereshop.commons.domain.business.CerePlatformBusiness">
SELECT business_id FROM cere_platform_business where pc_domain=#{domain} or mobile_domain=#{domain}
</select>
<select id="findXsPayIdByProject" resultType="java.lang.String">
SELECT xs_pay_id FROM cere_platform_business where business_id=#{project}
</select>
</mapper>

62
cereshop-commons/src/main/java/com/shop/cereshop/commons/config/HnaPayConfig.java

@ -0,0 +1,62 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.commons.config;
import org.springframework.stereotype.Component;
@Component
public class HnaPayConfig {
//新生签名使用的算法
public static String ALGORITHM = "RSA";
//类型
public static String SIGN_ALGORITHM = "SHA1withRSA";
//前置系统公钥(平台公钥)
public static String NCOUNT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9vGvYjivDF5uPBNDXMtoAtjYQ2YPSsfareduDG6kHL/N3A05rFHA11Dbr+UON82Y4V0RFKAQeZFPWcTLjcy6ntZVI8XoYLpuVQBPsb0Ya+PwbzR8/TmUdUf91ru8APtJgqkULgPVrO1hhzZ1tQMznosNLTOqbknMnnMcwzB5yYwIDAQAB";
public static String MER_PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIk/o9rSLWxkM3c6+sK5ucqLVGZuffSeIH4NCuwSTruQFm1t9snLasmVgNcGF5buxK/6GFzfRJyRwJX7yfTTNLJVVzXb60Xz0HtMJu2mXh3Aj8DuYRXLS28p56xbw/UEfFjf5mfFur8yDKhFQ7tAoFbh2pLlMzKQ5A9FqsP+KehDAgMBAAECgYBrY6dC3Xd7Oz/lx/lTidzstW45o7TcRSnpVy03n++I5OoXf5Y9OPP6fQdNt8+XYoX1p7uOV4go9gZ5lITmEqhEvt3uAk84YxCDqP9b8KNvp+zyGyHcnDWNoaxZtIN2zOToqLbNsFc/xbyDGQ1HksTlS3FWPeL+kMybI/JaRPA4UQJBAPC/7H2cqg23N3Knit1dSYpK8tQS9t9+hijdZNF4vP79Z9aquxPGI6adGj9r3Y0Z35legiA7bMZmo5pVvsqO19sCQQCR8U7tuYFsWh8QVTij5MQKRg2RxqauZ4MuFzpC6cH08+2jYMFfXP2wNSVOe/g9dcgIJ93zonoakgyO6drGjTG5AkBNP/g9chiq4ABdvN71GurvAg+a9x7aJfocgLXJ9SkH1P4NxqjStoBYBQ8YDJ+BmCzERKwSdZ74ppSWgC8BRgaDAkAL/nLoIpi6WOW4p+hRv9lEpuEym8rTBnrHbO1C1oc0JF/hT3BU8AWBV7zLKHEMTAO2d+BLx4yVZm9Vx25NZwkxAkBgjj8DE9Jue2DQSymBZb9ro/gD88au/aFNcgPerNuN/A1hUtyXL8Xo6K9ksK2eC7QYSa6skAcmNxKWPKwh3mw+";
//测试环境商户私钥
/* public static String MER_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAM2Ak5XX86FypU3t\n" +
"DSXlDQp+eXgowPLjBoEt0ZfEfhUtLIrU8J4YzUiz9tUzI6o6mGafDltUasdyRtt3\n" +
"+NdSQuFq7MhZyWwGUqle3ybGswYVkN8+LMADCQEOYphM4p0j/OGw7QYcL/ERHsUW\n" +
"2MGPR6M/9xe0KURIDdeJC0ulxQ8TAgMBAAECgYEAqgTfldBl68PbSb5+60Q25uC+\n" +
"hJBLGmiDwCp1Rng1zDVkrbQBIvvoE2d5Jui5cCQsZHLhwOP1t+8u+nKmuRaA51vB\n" +
"sQ+F01SqYrmS/TV/iD5xjAteSXmTf76doP7FwrHuRQ391KcdIn+W0R7cv1tLBY5B\n" +
"oRnAcAwWhQMiRWf+yPECQQD6TtJ7kETd5Rl3YryFMTvfW73oHxss87jz6/tUIPxF\n" +
"rXYu+ywD4Ut1AWwtN6Td6kZhWOUhG2d4OUVYP0FtjjprAkEA0izql6EQB7SF8AE5\n" +
"j8U7Weg8IqPk8b78neav8y1CpjSuwOaRxcS1Mk+W2/AXRvTRL2VUw+Az4boAz3MS\n" +
"WnP3+QJBAJW6vtfhRgDCQciTjJfUCq+irmgC63upUzK+L7p0fNOlXrPd1ceAZmXY\n" +
"cwBdb8a7lFw5E98JCIz3HU8bj6TcVn8CQQC3EfLBYsSwwXjNBnQaHAVHmfcPgU0B\n" +
"mYc3DuKB4hGk7kytr+iXqHDgQt039FiCMOso6o28FEV8v+TGzgfVjCAZAkA9NWuj\n" +
"VEHwFLZLtftLDQxGfJmWJGl4CipOjv6YpQEw0A2NBtUp5tuiJ09DNq5RaKJbfWUY\n" +
"fQJkAZ0tsrXBWqgK";*/
// public static String MER_ID = "110000002003";
/**
* 商户会员号 merCode 商户ID
*/
public static String MER_ID = "10000000381";
//报备编号
public static String MERCHANT_ID = "2410251102593947577";
public static String IP = "36.138.125.206";
// 支付结果通知地址
public static String APP_NOTICE_URL = "http://36.138.125.206/ceres-app-api/extend/hnaPay/pay/notify";
// 退款回调地址
public static String REFUND_NOTICE_URL = "http://36.138.125.206/ceres-app-api/extend/hnaPay/refund/notify";
}

2
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/business/CerePlatformBusiness.java

@ -174,7 +174,7 @@ public class CerePlatformBusiness implements Serializable {
/**
* 新生支付方开通的商家Id
* 新生支付方开通的商家Id(或新账通开通的商家id)
*/
@ApiModelProperty(value = "新生支付方开通的商家Id")
private String xsPayId;

Loading…
Cancel
Save