Browse Source

支付 删除多余代码

huangct 8 years ago
parent
commit
e0c7c9cb07

+ 2 - 41
donate-service/src/main/java/com/uas/service/donate/controller/AlipayController.java

@@ -217,34 +217,6 @@ public class AlipayController {
 
     }
 
-    /**
-     * 创建订单
-     */
-/*    @ResponseBody
-    @RequestMapping("/tradeCreate")
-    public String tradeCreate(){
-        String outTradeNo = NumberGenerator.generateId();
-
-        String notifyUrl = AlipayConfig.notify_url;
-
-        AlipayTradeCreateModel model = new AlipayTradeCreateModel();
-        model.setTimeoutExpress("2m");//该笔订单允许的最晚付款时间,逾期将关闭交易。取值范围:1m~15d。该参数数值不接受小数点, 如 1.5h,可转换为 90m。
-        model.setOutTradeNo(outTradeNo);
-        model.setTotalAmount("13.14");
-        model.setBody("收单测试body");//对交易或商品的描述
-        model.setSubject("测试统一收单交易创建接口");//订单标题
-        model.setBuyerLogonId("xfnwjs8936@sandbox.com");//买家支付宝账号,和buyer_id不能同时为空
-        model.setSellerId("2088102171369624");//卖家支付宝用户ID。如果该值为空,则默认为商户签约账号对应的支付宝用户ID
-        try {
-            AlipayTradeCreateResponse response = AlipayApi.tradeCreate(model,alipayClient,notifyUrl);
-            if (response.isSuccess()) {
-                return  response.getBody();
-            }
-        } catch (AlipayApiException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }*/
 
     /**
      * notify_url 异步通知  异步通知验签
@@ -422,14 +394,7 @@ public class AlipayController {
     }
 
 
-
-
-
-
-
-
-
-
+/*在需要获取支付宝用户信息时,才需要去获取access_Token*/
 
     /**
      * 判断是否需要用户授权获取会员信息
@@ -465,11 +430,7 @@ public class AlipayController {
         //String sandBoxUrl = "https://openauth.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=" + app_id + "&scope=" + scope + "&redirect_uri=" + redirect_url;
         String url = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=" + app_id + "&scope=" + scope + "&redirect_uri=" + redirect_url;
 
-        com.uas.sso.common.util.HttpUtil.ResponseWrap responseWrap = com.uas.sso.common.util.HttpUtil.doGet(url);
-        response.setContentType("text/html;charset=" + AlipayConfig.CHARSET);
-        response.getWriter().write(responseWrap.getContent());//直接将完整的表单html输出到页面
-        response.getWriter().flush();
-        response.getWriter().close();
+        response.sendRedirect(url);
     }
 
 

+ 1 - 0
donate-service/src/main/java/com/uas/service/donate/controller/IndexController.java

@@ -60,6 +60,7 @@ public class IndexController {
                 //String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wxPayApi.getConfig().getAppId() + "&redirect_uri=" + URLEncoder.encode("http://lj.ubtob.com/", "UTF-8") + "&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";
                 String url = WechatConnector.createAuthorizeUrl(WxConfig.oauthUserScope, wxPayApi.getConfig().getAppId(), URLEncoder.encode("http://lj.ubtob.com", "UTF-8"));
                 response.sendRedirect(url);
+                return null;
             }
         }
 

+ 2 - 38
donate-service/src/main/java/com/uas/service/donate/controller/WxpayController.java

@@ -147,6 +147,7 @@ public class WxpayController {
             logger.info("公众号支付缺少openId:--需要用户授权");
             String url = WechatConnector.createAuthorizeUrl(WxConfig.oauthUserScope, wxPayApi.getConfig().getAppId(), URLEncoder.encode("http://lj.ubtob.com", "UTF-8"));
             response.sendRedirect(url);
+            return null;
         }
 
         logger.info("公众号支付处理:openId=" + openId);
@@ -400,7 +401,7 @@ public class WxpayController {
 
 
     /**
-     * 获取token  这大概是基础支持token  一日上限2000次  用具体用户授权无关
+     * 获取token  基础支持token  一日上限2000次  与用户网页授权无关  与支付无关
      * @return
      * @throws Exception
      */
@@ -440,12 +441,6 @@ public class WxpayController {
             logger.info("公众号获取:authCode=" + code + ",state=" + state);
             //String xmlResult = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding());
             String openId = wxPayApi.authcode2Openid(code);
-            User user = SystemSession.getUser();
-            if (user == null) {
-                user = new User();
-            }
-            user.setWxOpenId(openId);
-            SystemSession.setUser(user);
         } catch (WxPayException e) {
             e.printStackTrace();
         }
@@ -488,37 +483,6 @@ public class WxpayController {
 //
 
 
-
-//    /**
-//     * 获取验签秘钥API
-//     * https://pay.weixin.qq.com/wiki/doc/api/jsapi_sl.php?chapter=23_1
-//     *  mch_id 商户号
-//     *  partnerKey 商户平台设置的密钥key
-//     * @return {String}
-//     */
-//    @ResponseBody
-//    @RequestMapping("/getsignkey")
-//    public String getsignkey() throws Exception {
-//        Map<String, String> map =new HashMap<String, String>();
-//        String mch_id = "";
-//        String partnerKey = "";//商户平台设置的密钥key
-//        String nonce_str = String.valueOf(System.currentTimeMillis());
-//        map.put("mch_id", mch_id);//商户号
-//        map.put("nonce_str", nonce_str);//随机字符串
-//        map.put("sign", WxSign.createSign(map, partnerKey));
-//
-//        String url = null;
-//        if (isSandBox) {
-//            url = WXPayConstants.SANDBOX_GETSINGKEY_URL;
-//        }else {
-//            //url = WXPayConstants.UGETSINGKEY_URL;
-//        }
-//        HttpUtil.Response result = HttpUtil.sendPostRequest(url, map);
-//
-//        return result.getResponseText();
-//    }
-//
-
     private WxPayUnifiedOrderRequest createWxPayUnifiedOrderRequest(HttpServletRequest request, ProjectRecode projectRecode, String tradeType) {
         //Project project = projectRecode.getProject();
         WxPayUnifiedOrderRequest wxPayUnifiedOrderRequest = new WxPayUnifiedOrderRequest();

+ 0 - 11
donate-service/src/main/java/com/uas/service/donate/model/User.java

@@ -54,8 +54,6 @@ public class User implements Serializable{
     @Column(name = "user_type")
     private String type;
 
-    private String wxOpenId;
-
     public User() {
 
     }
@@ -131,14 +129,6 @@ public class User implements Serializable{
         this.type = type;
     }
 
-    public String getWxOpenId() {
-        return wxOpenId;
-    }
-
-    public void setWxOpenId(String wxOpenId) {
-        this.wxOpenId = wxOpenId;
-    }
-
     @Override
     public String toString() {
         return "User{" +
@@ -149,7 +139,6 @@ public class User implements Serializable{
                 ", organization='" + org.getName() + '\'' +
                 ", userIMId=" + userIMId +
                 ", type='" + type + '\'' +
-                ", wxOpenId='" + wxOpenId + '\'' +
                 '}';
     }
 }

+ 1 - 0
donate-service/src/main/webapp/resources/js/pay.js

@@ -220,6 +220,7 @@ function onBridgeReady(resJsonObj){
         //微信签名   
     },
     function (res) {
+        alert(JSON.stringify(res));
         // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回    ok,但并不保证它绝对可靠。
         if (res.err_msg == 'get_brand_wcpay_request:ok') {
             toastr.success("支付成功!");