|
@@ -0,0 +1,228 @@
|
|
|
|
|
+package com.uas.platform.b2c.fa.payment.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.uas.platform.b2c.fa.payment.constant.B2CField;
|
|
|
|
|
+import com.uas.platform.b2c.fa.payment.constant.PingAnField;
|
|
|
|
|
+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 org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
+
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 平安service 的impl
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author yuj 2017-12-20 20:32
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class BankReceiptsServiceImpl implements BankReceiptsService {
|
|
|
|
|
+
|
|
|
|
|
+ private final RestTemplate restTemplate;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserInfoSupport userInfoSupport;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ public BankReceiptsServiceImpl(RestTemplate restTemplate, UserInfoSupport userInfoSupport) {
|
|
|
|
|
+ this.restTemplate = restTemplate;
|
|
|
|
|
+ this.userInfoSupport = userInfoSupport;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 绑卡的动作
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request 请求
|
|
|
|
|
+ * @param isPersonal 是否是个人账户
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String bindCard(HttpServletRequest request, Boolean isPersonal) {
|
|
|
|
|
+ Map<String, String> map = userInfoSupport.getUserInfoMap(isPersonal);
|
|
|
|
|
+ map.put(B2CField.USERUU, "1000103422");
|
|
|
|
|
+ map.put(B2CField.ENUU, "1000103423");
|
|
|
|
|
+ map.put(B2CField.DISSOCIATIVE, Boolean.FALSE.toString());
|
|
|
|
|
+ map.put(B2CField.ISPERSONAL, Boolean.TRUE.toString());
|
|
|
|
|
+ String httpEntity = restTemplate.postForObject("http://192.168.253.119:20280/UnionPay/bindCard", map, String.class);
|
|
|
|
|
+ return httpEntity;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询跨行绑卡的信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param isPersonal 是否是个人
|
|
|
|
|
+ * @return String
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String queryBindCard(Boolean isPersonal) {
|
|
|
|
|
+ Map<String, String> map = userInfoSupport.getUserInfoMap(isPersonal);
|
|
|
|
|
+ String resultStr = restTemplate.postForObject("http://192.168.253.119:20280/UnionPay/bindCard/query", map, String.class);
|
|
|
|
|
+ return resultStr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 银联快捷支付 获取短信验证码的信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param json 传入的支付信息
|
|
|
|
|
+ * @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, "20003111462017122041072723");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String amount = json.getString(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;
|
|
|
|
|
+ }
|
|
|
|
|
+ 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("http://192.168.253.119:20280/UnionPay/sms", infoMap, String.class);
|
|
|
|
|
+ System.out.println(resultStr);
|
|
|
|
|
+ return resultStr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 传入的数据
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param json json 交易的信息
|
|
|
|
|
+ * @param isPersonal 是否是个人
|
|
|
|
|
+ * @return String
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String khPay(JSONObject json, Boolean isPersonal) {
|
|
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
|
|
+ Map<String, String> infoMap = userInfoSupport.getUserInfoMap(isPersonal);
|
|
|
|
|
+ if ((json != null) && (json.size() != 0)) {
|
|
|
|
|
+ String orderid = json.getString(PingAnField.ORDERID);
|
|
|
|
|
+ if (StringUtils.isEmpty(orderid)) {
|
|
|
|
|
+ throw new IllegalArgumentException("传入的支付流水号为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put(PingAnField.ORDERID, orderid);
|
|
|
|
|
+ String payDate = json.getString(PingAnField.PAYDATE);
|
|
|
|
|
+ if (StringUtils.isEmpty(payDate)) {
|
|
|
|
|
+ throw new IllegalArgumentException("传入的支付时间为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put(PingAnField.PAYDATE, payDate);
|
|
|
|
|
+
|
|
|
|
|
+ String amout = json.getString(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);
|
|
|
|
|
+ if (StringUtils.isEmpty(verifyCode)) {
|
|
|
|
|
+ throw new IllegalArgumentException("传入的动态验证码为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put(PingAnField.VERIFYCODE, verifyCode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ map.putAll(infoMap);
|
|
|
|
|
+ map.put(PingAnField.ORDERID, "200031114620180109UHTX1CS0");
|
|
|
|
|
+ map.put(PingAnField.CURRENCY, "RMB");
|
|
|
|
|
+ map.put("amount", "10.00");
|
|
|
|
|
+ map.put("paydate", "20180109112109");
|
|
|
|
|
+ map.put("customerId", "19901120");
|
|
|
|
|
+ map.put("verifyCode", "111111");
|
|
|
|
|
+ map.put("issInsCode", "HXB");
|
|
|
|
|
+ map.put("objectName", "付款");
|
|
|
|
|
+ map.put("OpenId", "20003111462017122041072723");
|
|
|
|
|
+ map.put("payCardType", "01");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String resultStr = restTemplate.postForObject("http://192.168.253.119:20280/UnionPay/pay", map, String.class);
|
|
|
|
|
+ System.out.println(resultStr);
|
|
|
|
|
+ /*
|
|
|
|
|
+ * orderId 支付的流水号必须和发送短信的接口一致
|
|
|
|
|
+ * paydate 支付的时间,必须与获取短信的时间一致
|
|
|
|
|
+ * opendid 银行卡的开户行id 在查询的时候就会把信息带过去
|
|
|
|
|
+ * currency 币种 RMB
|
|
|
|
|
+ * amount 金额 12整数,2小数
|
|
|
|
|
+ * objectName 订单款项描述
|
|
|
|
|
+ * verifyCode 短信验证码
|
|
|
|
|
+ * payCardType 支付卡类型,01:借记卡,02:信用卡
|
|
|
|
|
+ * issInsCode 发卡机构代码 查询绑卡信息时返回结果之后,会查询我们建的表信息,返回前端会带着个信息
|
|
|
|
|
+ * */
|
|
|
|
|
+
|
|
|
|
|
+ return resultStr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 网关支付接口
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param json
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String eBankPay(JSONObject json, Boolean isPersonal) {
|
|
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
|
|
+ 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");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //TODO
|
|
|
|
|
+ }
|
|
|
|
|
+ String loadHtml = restTemplate.postForObject("http://192.168.253.119:20280/eBank/pay", map, String.class);
|
|
|
|
|
+ return loadHtml;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 微信预支付的接口
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param json 传入的支付信息
|
|
|
|
|
+ * @return String
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String weChatPrePay(JSONObject json) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 微信支付的接口
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param json 传入的数据
|
|
|
|
|
+ * @return String
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String weChatPay(@RequestBody JSONObject json) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|