|
|
@@ -7,7 +7,9 @@ import com.uas.platform.b2c.fa.payment.constant.PingAnRequestUrlPostfix;
|
|
|
import com.uas.platform.b2c.fa.payment.constant.StringConstant;
|
|
|
import com.uas.platform.b2c.fa.payment.service.BankReceiptsService;
|
|
|
import com.uas.platform.b2c.fa.payment.support.UserInfoSupport;
|
|
|
+import com.uas.platform.b2c.trade.support.CodeType;
|
|
|
import com.uas.platform.b2c.trade.support.ResultMap;
|
|
|
+import org.apache.commons.collections.MapUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
@@ -46,7 +48,11 @@ public class BankReceiptsServiceImpl implements BankReceiptsService {
|
|
|
public String bindCard(Boolean isPersonal) {
|
|
|
Map<String, String> map = userInfoSupport.getUserInfoMap(isPersonal);
|
|
|
ResultMap resultMap = restTemplate.postForObject(sysConf.getPingAnUrl() + PingAnRequestUrlPostfix.BINDCARD, map, ResultMap.class);
|
|
|
- return resultMap.getMessage();
|
|
|
+ if (resultMap.getCode() == CodeType.OK.code()) {
|
|
|
+ return resultMap.getData().toString();
|
|
|
+ } else {
|
|
|
+ return resultMap.getMessage();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -66,40 +72,31 @@ public class BankReceiptsServiceImpl implements BankReceiptsService {
|
|
|
/**
|
|
|
* 银联快捷支付 获取短信验证码的信息
|
|
|
*
|
|
|
- * @param json 传入的支付信息
|
|
|
+ * @param map 传入的支付信息
|
|
|
* @param isPersonal 是否是个人
|
|
|
* @return String
|
|
|
*/
|
|
|
@Override
|
|
|
- public String khPaySMS(JSONObject json, Boolean isPersonal) {
|
|
|
- HashMap<String, String> map = new HashMap<>();
|
|
|
- if ((json == null) || json.size() == 0) {
|
|
|
- map.put(PingAnField.AMOUNT, "10");
|
|
|
- map.put(PingAnField.CURRENCY, "RMB");
|
|
|
- map.put(PingAnField.OBJECTNAME, "test");
|
|
|
- map.put(PingAnField.OPENID, "20007991842018011032103750");
|
|
|
+ public String khPaySMS(HashMap<String, String> map, Boolean isPersonal) {
|
|
|
+ if (MapUtils.isEmpty(map)) {
|
|
|
+ throw new IllegalArgumentException("传入的交易信息为空");
|
|
|
} else {
|
|
|
- String amount = json.getString(PingAnField.AMOUNT);
|
|
|
+ String amount = map.get(PingAnField.AMOUNT);
|
|
|
if (StringUtils.isEmpty(amount)) {
|
|
|
throw new IllegalArgumentException("传入的金额合计为空");
|
|
|
}
|
|
|
- map.put(PingAnField.AMOUNT, amount);
|
|
|
-
|
|
|
- String currency = json.getString(PingAnField.CURRENCY);
|
|
|
- if (StringUtils.isEmpty(currency)) {
|
|
|
- currency = StringConstant.RMB_String;
|
|
|
+ String currency = map.get(PingAnField.CURRENCY);
|
|
|
+ if (StringUtils.isEmpty(currency) || !StringConstant.RMB_String.equals(currency)) {
|
|
|
+ throw new IllegalArgumentException("支付币别类型为空或部位人民币");
|
|
|
+ }
|
|
|
+ String OpenId = map.get(PingAnField.OPENID);
|
|
|
+ if (StringUtils.isEmpty(OpenId)) {
|
|
|
+ throw new IllegalArgumentException("传入的银行编号为空");
|
|
|
}
|
|
|
- map.put(PingAnField.CURRENCY, currency);
|
|
|
-
|
|
|
- String objectName = json.getString(PingAnField.OBJECTNAME);
|
|
|
- map.put(PingAnField.OBJECTNAME, objectName == null ? "" : objectName);
|
|
|
- //绑卡之后,会从银联返回一个OpenId;
|
|
|
- map.put(PingAnField.OPENID, "20003111462017122041072723");
|
|
|
}
|
|
|
- isPersonal = true;
|
|
|
Map<String, String> infoMap = userInfoSupport.getUserInfoMap(isPersonal);
|
|
|
infoMap.putAll(map);
|
|
|
- String resultStr = restTemplate.postForObject(sysConf.getPingAnUrl() + "/UnionPay/sms", infoMap, String.class);
|
|
|
+ String resultStr = restTemplate.postForObject(sysConf.getPingAnUrl() + PingAnRequestUrlPostfix.KHPAYSMS, infoMap, String.class);
|
|
|
System.out.println(resultStr);
|
|
|
return resultStr;
|
|
|
}
|
|
|
@@ -107,58 +104,51 @@ public class BankReceiptsServiceImpl implements BankReceiptsService {
|
|
|
/**
|
|
|
* 传入的数据
|
|
|
*
|
|
|
- * @param json json 交易的信息
|
|
|
+ * @param map json 交易的信息
|
|
|
* @param isPersonal 是否是个人
|
|
|
- * @return String
|
|
|
+ * @return ResultMap
|
|
|
*/
|
|
|
@Override
|
|
|
- public String khPay(JSONObject json, Boolean isPersonal) {
|
|
|
- HashMap<String, String> map = new HashMap<>();
|
|
|
+ public ResultMap khPay(HashMap<String, String> map, Boolean isPersonal) {
|
|
|
Map<String, String> infoMap = userInfoSupport.getUserInfoMap(isPersonal);
|
|
|
- if ((json != null) && (json.size() != 0)) {
|
|
|
- String orderid = json.getString(PingAnField.ORDERID);
|
|
|
+ if (MapUtils.isEmpty(map)) {
|
|
|
+ throw new IllegalArgumentException("传入的交易信息为空");
|
|
|
+ } else {
|
|
|
+ String orderid = map.get(PingAnField.ORDERID);
|
|
|
if (StringUtils.isEmpty(orderid)) {
|
|
|
throw new IllegalArgumentException("传入的支付流水号为空");
|
|
|
}
|
|
|
- map.put(PingAnField.ORDERID, orderid);
|
|
|
- String payDate = json.getString(PingAnField.PAYDATE);
|
|
|
+ String payDate = map.get(PingAnField.PAYDATE);
|
|
|
if (StringUtils.isEmpty(payDate)) {
|
|
|
throw new IllegalArgumentException("传入的支付时间为空");
|
|
|
}
|
|
|
- map.put(PingAnField.PAYDATE, payDate);
|
|
|
|
|
|
- String amout = json.getString(PingAnField.AMOUNT);
|
|
|
+ String amout = map.get(PingAnField.AMOUNT);
|
|
|
if (StringUtils.isEmpty(amout)) {
|
|
|
throw new IllegalArgumentException("传入的支付金额为空");
|
|
|
}
|
|
|
- map.put(PingAnField.AMOUNT, amout);
|
|
|
|
|
|
- String objName = json.getString(PingAnField.OBJECTNAME);
|
|
|
- if (StringUtils.isEmpty(objName)) {
|
|
|
- objName = StringConstant.EMPTY_STRING;
|
|
|
- }
|
|
|
- map.put(PingAnField.OBJECTNAME, objName);
|
|
|
-
|
|
|
- String verifyCode = json.getString(PingAnField.VERIFYCODE);
|
|
|
+ String verifyCode = map.get(PingAnField.VERIFYCODE);
|
|
|
if (StringUtils.isEmpty(verifyCode)) {
|
|
|
throw new IllegalArgumentException("传入的动态验证码为空");
|
|
|
}
|
|
|
- map.put(PingAnField.VERIFYCODE, verifyCode);
|
|
|
- } else {
|
|
|
+
|
|
|
map.putAll(infoMap);
|
|
|
- map.put(PingAnField.ORDERID, "200079918420180115W2DYA220");
|
|
|
- map.put(PingAnField.CURRENCY, "RMB");
|
|
|
- map.put("amount", "10.00");
|
|
|
- map.put("paydate", "20180115220144");
|
|
|
- map.put("customerId", "19901120");
|
|
|
- map.put("verifyCode", "111111");
|
|
|
- map.put("issInsCode", "HXB");
|
|
|
- map.put("objectName", "付款");
|
|
|
- map.put("OpenId", "20007991842018011032103750");
|
|
|
- map.put("payCardType", "01");
|
|
|
}
|
|
|
|
|
|
- String resultStr = restTemplate.postForObject(sysConf.getPingAnUrl() + "/UnionPay/pay", map, String.class);
|
|
|
+// map.putAll(infoMap);
|
|
|
+// map.put(PingAnField.ORDERID, "200079918420180115W2DYA220");
|
|
|
+// map.put(PingAnField.CURRENCY, "RMB");
|
|
|
+// map.put("amount", "10.00");
|
|
|
+// map.put("paydate", "20180115220144");
|
|
|
+// map.put("customerId", "19901120");
|
|
|
+// map.put("verifyCode", "111111");
|
|
|
+// map.put("issInsCode", "HXB");
|
|
|
+// map.put("objectName", "付款");
|
|
|
+// map.put("OpenId", "20007991842018011032103750");
|
|
|
+// map.put("payCardType", "01");
|
|
|
+
|
|
|
+ ResultMap resultStr = restTemplate.postForObject(sysConf.getPingAnUrl() + PingAnRequestUrlPostfix.KHPAY, map, ResultMap.class);
|
|
|
System.out.println(resultStr);
|
|
|
/*
|
|
|
* orderId 支付的流水号必须和发送短信的接口一致
|
|
|
@@ -178,27 +168,66 @@ public class BankReceiptsServiceImpl implements BankReceiptsService {
|
|
|
/**
|
|
|
* 网关支付接口
|
|
|
*
|
|
|
- * @param json
|
|
|
+ * @param map 需要支付的数据
|
|
|
+ * @param isPersonal 是否是个人用户
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public String eBankPay(JSONObject json, Boolean isPersonal) {
|
|
|
- HashMap<String, String> map = new HashMap<>();
|
|
|
+ public ResultMap eBankPay(HashMap<String, String> map, Boolean isPersonal) {
|
|
|
Map<String, String> infoMap = userInfoSupport.getUserInfoMap(isPersonal);
|
|
|
- if (json == null || json.size() == 0) {
|
|
|
- map.putAll(infoMap);
|
|
|
- map.put("currency", "RMB");
|
|
|
- map.put("amount", "11.00");
|
|
|
- map.put("objectName", "测试");
|
|
|
-// map.put("payType", "02");
|
|
|
-// map.put("issInsCode", "CZSB");
|
|
|
-// map.put("payCardType", "01");
|
|
|
- map.put("payType", "01");
|
|
|
- map.put("issInsCode", "PSBC");
|
|
|
+ if (MapUtils.isEmpty(map)) {
|
|
|
+ throw new IllegalArgumentException("传入的交易信息为空");
|
|
|
} else {
|
|
|
- //TODO
|
|
|
+ String amount = map.get(PingAnField.AMOUNT);
|
|
|
+ if (StringUtils.isEmpty(amount)) {
|
|
|
+ throw new IllegalArgumentException("传入的金额合计为空");
|
|
|
+ }
|
|
|
+ String currency = map.get(PingAnField.CURRENCY);
|
|
|
+ if (StringUtils.isEmpty(currency) || !StringConstant.RMB_String.equals(currency)) {
|
|
|
+ throw new IllegalArgumentException("支付币别类型为空或部位人民币");
|
|
|
+ }
|
|
|
+ String OpenId = map.get(PingAnField.OPENID);
|
|
|
+ if (StringUtils.isEmpty(OpenId)) {
|
|
|
+ throw new IllegalArgumentException("传入的银行编号为空");
|
|
|
+ }
|
|
|
+ String payType = map.get(PingAnField.PAYTYPE);
|
|
|
+ if (StringUtils.isEmpty(payType)) {
|
|
|
+ throw new IllegalArgumentException("支付方式为空");
|
|
|
+ } else if (!StringConstant.EBANK_B2B_PAY.equals(payType) && StringConstant.EBANK_B2C_PAY.equals(payType)) {
|
|
|
+ throw new IllegalArgumentException("支付方式只能为B2C支付或B2B支付");
|
|
|
+ }
|
|
|
+
|
|
|
+ String issInsCode = map.get(PingAnField.ISSINSCODE);
|
|
|
+ if (StringUtils.isEmpty(issInsCode)) {
|
|
|
+ throw new IllegalArgumentException("银行代码为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ String payCardType = map.get(PingAnField.PAYCARDTYPE);
|
|
|
+ if (StringConstant.EBANK_B2C_PAY.equals(payType)) {
|
|
|
+ if (StringUtils.isEmpty(payCardType)) {
|
|
|
+ throw new IllegalArgumentException("支付的银行卡类型为空");
|
|
|
+ } else if(!StringConstant.CREDIT_CARD.equals(payCardType) && !StringConstant.DEBIT_CARD.equals(payCardType)){
|
|
|
+ throw new IllegalArgumentException("B2C支付方式下,只能选择通过借记卡或者贷记卡");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.putAll(infoMap);
|
|
|
}
|
|
|
- String loadHtml = restTemplate.postForObject(sysConf.getPingAnUrl() + PingAnRequestUrlPostfix.EBANKPAY, map, String.class);
|
|
|
+// if (json == null || json.size() == 0) {
|
|
|
+// map.putAll(infoMap);
|
|
|
+// map.put("currency", "RMB");
|
|
|
+// map.put("amount", "11.00");
|
|
|
+// map.put("objectName", "测试");
|
|
|
+ // b2c 支付时 必须选择银行卡类型
|
|
|
+ //// map.put("payType", "02");
|
|
|
+ //// map.put("issInsCode", "CZSB");
|
|
|
+ //// map.put("payCardType", "01");
|
|
|
+// map.put("payType", "01");
|
|
|
+// map.put("issInsCode", "PSBC");
|
|
|
+// } else {
|
|
|
+// //TODO
|
|
|
+// }
|
|
|
+ ResultMap loadHtml = restTemplate.postForObject(sysConf.getPingAnUrl() + PingAnRequestUrlPostfix.EBANKPAY, map, ResultMap.class);
|
|
|
return loadHtml;
|
|
|
}
|
|
|
|