|
|
@@ -1,193 +0,0 @@
|
|
|
-package com.uas.platform.b2c.fa.payment.facade.impl;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.uas.platform.b2c.common.account.model.User;
|
|
|
-import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
-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.facade.PingAnFacade;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-/**
|
|
|
- * 平安facade 的impl
|
|
|
- *
|
|
|
- * @author yuj 2017-12-20 20:32
|
|
|
- */
|
|
|
-@Service
|
|
|
-public class PingAnFacadeImpl implements PingAnFacade {
|
|
|
-
|
|
|
- private final RestTemplate restTemplate;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- public PingAnFacadeImpl(RestTemplate restTemplate) {
|
|
|
- this.restTemplate = restTemplate;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 绑卡的动作
|
|
|
- *
|
|
|
- * @param request 请求
|
|
|
- * @param isPersonal 是否是个人账户
|
|
|
- */
|
|
|
- @Override
|
|
|
- public String bindCard(HttpServletRequest request, Boolean isPersonal) {
|
|
|
- Map<String, String> map = 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 = getUserInfoMap(isPersonal);
|
|
|
- String resultStr = restTemplate.postForObject("http://192.168.253.119:20280/UnionPay/bindCard/query", map, String.class);
|
|
|
- return resultStr;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 组装个人的信息
|
|
|
- *
|
|
|
- * @param isPersonal 是否是个人信息
|
|
|
- * @return Map<String, String>
|
|
|
- */
|
|
|
- private Map<String, String> getUserInfoMap(Boolean isPersonal) {
|
|
|
- HashMap<String, String> map = new HashMap<>();
|
|
|
- User user = SystemSession.getUser();
|
|
|
- isPersonal = true;
|
|
|
- if (isPersonal) {
|
|
|
- map.put(B2CField.USERUU, String.valueOf(user.getUserUU()));
|
|
|
- if (user.getEnterprise() != null) {
|
|
|
- map.put(B2CField.ENUU, String.valueOf(user.getEnterprise().getUu()));
|
|
|
- map.put(B2CField.DISSOCIATIVE, Boolean.FALSE.toString());
|
|
|
- } else {
|
|
|
- map.put(B2CField.DISSOCIATIVE, Boolean.TRUE.toString());
|
|
|
- }
|
|
|
- map.put(B2CField.ISPERSONAL, Boolean.TRUE.toString());
|
|
|
- } else {
|
|
|
- map.put(B2CField.ENUU, user.getEnterprise().getUu().toString());
|
|
|
- map.put(B2CField.DISSOCIATIVE, Boolean.FALSE.toString());
|
|
|
- map.put(B2CField.ISPERSONAL, Boolean.FALSE.toString());
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 银联快捷支付 获取短信验证码的信息
|
|
|
- *
|
|
|
- * @param json 传入的支付信息
|
|
|
- * @param isPersonal 是否是个人
|
|
|
- * @return String
|
|
|
- */
|
|
|
- @Override
|
|
|
- public String khPaySMS(JSONObject json, Boolean isPersonal) {
|
|
|
- HashMap<String, String> map = new HashMap<>();
|
|
|
- if (json == null) {
|
|
|
- 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 = 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<>();
|
|
|
- if (json != null) {
|
|
|
- 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);
|
|
|
- }
|
|
|
- Map<String, String> infoMap = getUserInfoMap(isPersonal);
|
|
|
- /*
|
|
|
- * orderId 支付的流水号必须和发送短信的接口一致
|
|
|
- * paydate 支付的时间,必须与获取短信的时间一致
|
|
|
- * opendid 银行卡的开户行id 在查询的时候就会把信息带过去
|
|
|
- * currency 币种 RMB
|
|
|
- * amount 金额 12整数,2小数
|
|
|
- * objectName 订单款项描述
|
|
|
- * verifyCode 短信验证码
|
|
|
- * payCardType 支付卡类型,01:借记卡,02:信用卡
|
|
|
- * issInsCode 发卡机构代码 查询绑卡信息时返回结果之后,会查询我们建的表信息,返回前端会带着个信息
|
|
|
- * */
|
|
|
-
|
|
|
- map.put("paydate", "");
|
|
|
- infoMap.putAll(map);
|
|
|
- map.put("currency", "RMB");
|
|
|
- map.put("amount", "");
|
|
|
- return null;
|
|
|
- }
|
|
|
-}
|