|
|
@@ -0,0 +1,88 @@
|
|
|
+package com.uas.platform.b2c.fa.payment.facade.impl;
|
|
|
+
|
|
|
+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.facade.PingAnFacade;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+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;
|
|
|
+ }
|
|
|
+}
|