Bläddra i källkod

编辑器新增字段

lyhzzz 1 år sedan
förälder
incheckning
ceb0f57d9c
62 ändrade filer med 54 tillägg och 5401 borttagningar
  1. 0 16
      pom.xml
  2. 0 100
      src/main/java/com/fdkankan/ucenter/controller/OrderAlipayController.java
  3. 0 245
      src/main/java/com/fdkankan/ucenter/controller/OrderPaypalController.java
  4. 0 259
      src/main/java/com/fdkankan/ucenter/controller/OrderWechatPayController.java
  5. 0 116
      src/main/java/com/fdkankan/ucenter/mq/consumer/AutoOrderConsumer.java
  6. 0 90
      src/main/java/com/fdkankan/ucenter/mq/consumer/OrderDownConsumer.java
  7. 0 3
      src/main/java/com/fdkankan/ucenter/mq/consumer/ScenePayStatusConsumer.java
  8. 0 90
      src/main/java/com/fdkankan/ucenter/pay/alipay/AlipayDefaultConfig.java
  9. 0 81
      src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipayConfig.java
  10. 0 60
      src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipayGoodsDetail.java
  11. 0 160
      src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipayService.java
  12. 0 38
      src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipayUtil.java
  13. 0 113
      src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipaymentEx.java
  14. 0 14
      src/main/java/com/fdkankan/ucenter/pay/factory/PayEntity.java
  15. 0 39
      src/main/java/com/fdkankan/ucenter/pay/factory/PayFactory.java
  16. 0 277
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/PayOrderService.java
  17. 0 58
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/commerce/AlipayCommerce.java
  18. 0 56
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/commerce/PaypalCommerce.java
  19. 0 55
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/commerce/WechatCommerce.java
  20. 0 73
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/down/AlipayDownload.java
  21. 0 62
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/down/PaypalDownload.java
  22. 0 65
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/down/WechatDownload.java
  23. 0 82
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/expansion/AlipayExpansion.java
  24. 0 64
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/expansion/PaypalExpansion.java
  25. 0 81
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/expansion/WechatExpansion.java
  26. 0 77
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/goods/AlipayGoods.java
  27. 0 70
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/goods/PaypalGoods.java
  28. 0 73
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/goods/WechatGoods.java
  29. 0 72
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/increment/AlipayIncrement.java
  30. 0 86
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/increment/PaypalIncrement.java
  31. 0 65
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/increment/WechatIncrement.java
  32. 0 59
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/recharge/AlipayRecharge.java
  33. 0 59
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/recharge/PaypalRecharge.java
  34. 0 55
      src/main/java/com/fdkankan/ucenter/pay/factory/impl/recharge/WechatRecharge.java
  35. 0 56
      src/main/java/com/fdkankan/ucenter/pay/paypal/PayPalDefaultConfig.java
  36. 0 25
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/AutoPaypalVo.java
  37. 0 43
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PayPalConfig.java
  38. 0 130
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PayPalmentEx.java
  39. 0 88
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalOrderAddressEx.java
  40. 0 59
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalOrderItemEx.java
  41. 0 5
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalPaymentIntent.java
  42. 0 5
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalPaymentMethod.java
  43. 0 267
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalService.java
  44. 0 66
      src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/UrlUtils.java
  45. 0 12
      src/main/java/com/fdkankan/ucenter/pay/strategy/OrderItemStrategy.java
  46. 0 9
      src/main/java/com/fdkankan/ucenter/pay/strategy/OrderStrategy.java
  47. 0 67
      src/main/java/com/fdkankan/ucenter/pay/strategy/OrderStrategyFactory.java
  48. 0 58
      src/main/java/com/fdkankan/ucenter/pay/strategy/impl/DownloadOrderImpl.java
  49. 0 55
      src/main/java/com/fdkankan/ucenter/pay/strategy/impl/EntityOrderImpl.java
  50. 0 77
      src/main/java/com/fdkankan/ucenter/pay/strategy/impl/ExpansionOrderImpl.java
  51. 0 129
      src/main/java/com/fdkankan/ucenter/pay/strategy/impl/IncrementOrderImpl.java
  52. 0 47
      src/main/java/com/fdkankan/ucenter/pay/strategy/impl/RechargeOrderImpl.java
  53. 0 673
      src/main/java/com/fdkankan/ucenter/pay/wx/WXPay.java
  54. 0 53
      src/main/java/com/fdkankan/ucenter/pay/wx/WXPayConfig.java
  55. 0 45
      src/main/java/com/fdkankan/ucenter/pay/wx/WXPayConstants.java
  56. 0 62
      src/main/java/com/fdkankan/ucenter/pay/wx/WXPayDefaultConfig.java
  57. 0 307
      src/main/java/com/fdkankan/ucenter/pay/wx/WXPayUtil.java
  58. 0 8
      src/main/java/com/fdkankan/ucenter/service/IIncrementAutoOrderService.java
  59. 0 2
      src/main/java/com/fdkankan/ucenter/service/IIncrementOrderService.java
  60. 0 42
      src/main/java/com/fdkankan/ucenter/service/impl/IncrementAutoOrderServiceImpl.java
  61. 54 92
      src/main/java/com/fdkankan/ucenter/service/impl/IncrementOrderServiceImpl.java
  62. 0 6
      src/main/java/com/fdkankan/ucenter/service/impl/OrderServiceImpl.java

+ 0 - 16
pom.xml

@@ -128,23 +128,7 @@
             <artifactId>easyexcel</artifactId>
             <version>3.1.0</version>
         </dependency>
-        <!-- Alipay  -->
-        <dependency>
-            <groupId>com.alipay</groupId>
-            <artifactId>alipay-sdk-java</artifactId>
-            <version>20170324180803</version>
-        </dependency>
-        <dependency>
-            <groupId>com.alipay</groupId>
-            <artifactId>alipay-trade-sdk</artifactId>
-            <version>20161215</version>
-        </dependency>
 
-        <dependency>
-            <groupId>com.paypal.sdk</groupId>
-            <artifactId>rest-api-sdk</artifactId>
-            <version>1.14.0</version>
-        </dependency>
 
         <dependency>
             <groupId>org.projectlombok</groupId>

+ 0 - 100
src/main/java/com/fdkankan/ucenter/controller/OrderAlipayController.java

@@ -1,100 +0,0 @@
-package com.fdkankan.ucenter.controller;
-
-import com.alibaba.fastjson.JSON;
-import com.alipay.api.internal.util.AlipaySignature;
-import com.fdkankan.ucenter.common.BaseController;
-import com.fdkankan.ucenter.common.Result;
-import com.fdkankan.ucenter.pay.alipay.AlipayDefaultConfig;
-import com.fdkankan.ucenter.pay.factory.PayFactory;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategyFactory;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-@Log4j2
-/**支付中心-支付宝支付模块*/
-@RestController
-@RequestMapping("/ucenter/order/pay")
-public class OrderAlipayController extends BaseController {
-    @Autowired
-    private AlipayDefaultConfig alipayDefaultConfig;
-    @Autowired
-    private OrderStrategyFactory orderStrategyFactory;
-    @Autowired
-    private PayFactory payFactory;
-
-    @RequestMapping(value = "/alipay", method = RequestMethod.POST)
-    public Result alipay(@RequestBody PlaceOrderParam order) throws Exception {
-        return Result.success(payFactory.scanPay("alipay", order));
-    }
-
-    @RequestMapping(value = "/aliMobilePay", method = RequestMethod.POST)
-    public Result aliMobilePay(@RequestBody PlaceOrderParam order) throws Exception {
-        return  Result.success(payFactory.h5Pay("alipay", order, null));
-    }
-
-    @RequestMapping(value = "/alipay/async_notify", method = RequestMethod.POST)
-    public String async_notify() {
-        //获取支付宝POST过来反馈信息
-        Map<String, String> params = new HashMap<String, String>();
-        Map<String, String[]> requestParams = request.getParameterMap();
-        for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext(); ) {
-            String name = (String) iter.next();
-            String[] values = (String[]) requestParams.get(name);
-            String valueStr = "";
-            for (int i = 0; i < values.length; i++) {
-                valueStr = (i == values.length - 1) ? valueStr + values[i]
-                        : valueStr + values[i] + ",";
-            }
-            //乱码解决,这段代码在出现乱码时使用
-            //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
-            params.put(name, valueStr);
-        }
-        //调用SDK验证签名
-        try {
-            boolean signVerified = AlipaySignature.rsaCheckV1(params, alipayDefaultConfig.getAlipayPublicKey(), alipayDefaultConfig.getCharset(), alipayDefaultConfig.getSignType());
-            if (signVerified) {
-                log.info("支付宝回调签名认证成功");
-                //商户订单号
-                String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
-                //支付宝交易号
-                String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"), "UTF-8");
-                //交易状态
-                String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"), "UTF-8");
-                //交易body
-                String body = new String(request.getParameter("body").getBytes("ISO-8859-1"), "UTF-8");
-                log.info("支付宝回调返回body:" + body);
-                //付款金额
-//                String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"), "UTF-8");
-                String openid = new String(request.getParameter("seller_id").getBytes("ISO-8859-1"),"UTF-8");
-                String orderSn = out_trade_no.split("_")[0];
-                if(body.split("_").length == 2){
-                    orderSn += "_" + body.split("_")[1];
-                }
-                if ("TRADE_FINISHED".equals(trade_status)){
-                    log.warn("支付宝——交易结束了!" + out_trade_no);
-                }else if ("TRADE_SUCCESS".equals(trade_status)){
-                    orderStrategyFactory.doHandler(orderSn, trade_no, openid, out_trade_no.split("_")[1], 1);
-                }else {
-                    log.error("订单号:" + orderSn + "支付宝回调交易状态异常:" + trade_status);
-                }
-                return "success";
-            }else{
-                log.warn("支付宝回调签名认证失败,signVerified=false, paramsJson:{}", JSON.toJSONString(params));
-                return "failure";
-            }
-        } catch (Exception e) {
-            log.error("支付宝回调签名认证失败,paramsJson:{},errorMsg:{}", JSON.toJSONString(params), e.getMessage());
-            return "failure";
-        }
-    }
-
-}

+ 0 - 245
src/main/java/com/fdkankan/ucenter/controller/OrderPaypalController.java

@@ -1,245 +0,0 @@
-package com.fdkankan.ucenter.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.ucenter.common.BaseController;
-import com.fdkankan.ucenter.common.Result;
-import com.fdkankan.ucenter.common.ResultData;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.pay.factory.PayFactory;
-import com.fdkankan.ucenter.pay.paypal.PayPalDefaultConfig;
-import com.fdkankan.ucenter.pay.paypal.sdk.PaypalService;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategyFactory;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import com.paypal.api.payments.Payment;
-import com.paypal.base.rest.PayPalRESTException;
-import lombok.extern.log4j.Log4j2;
-import okhttp3.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Enumeration;
-
-@Log4j2
-/**支付中心-paypal支付模块*/
-@Controller
-@RequestMapping("/ucenter/order/pay")
-public class OrderPaypalController extends BaseController {
-
-    @Autowired
-    private OrderStrategyFactory orderStrategyFactory;
-    @Autowired
-    private PayFactory payFactory;
-    @Autowired
-    private PaypalService paypalService;
-    @Autowired
-    private PayPalDefaultConfig config;
-
-    //正式环境或测试环境
-    @Value("${spring.profiles.active}")
-    private String ev;
-
-    /**
-     * Paypal付款
-     * orderId      订单id
-     * orderType    订单类型,0购买相机,1点数重置,2扩容,3商业版,4增值服务,5场景下载
-     * spaceId      0表示国内订单,1表示国外订单
-     */
-    @ResponseBody
-    @RequestMapping(value = "/paypal", method = RequestMethod.POST)
-    public Result paypal(@RequestBody PlaceOrderParam order) throws Exception {
-        JSONObject jsonObject = payFactory.scanPay("paypal", order);
-        return Result.success(jsonObject);
-    }
-
-    @RequestMapping(value = "/paypalH5", method = RequestMethod.POST)
-    public String paypalH5(PlaceOrderParam order) throws Exception {
-        JSONObject jsonObject = payFactory.h5Pay("paypal", order, null);
-        if (jsonObject != null && jsonObject.get("redirect") != null){
-            return "redirect:" + jsonObject.getString("redirect");
-        }
-        return  "redirect:" + NacosProperty.getMainUrl() + config.getH5FailUrl();
-    }
-
-    /**
-     * 支付成功
-     * @param paymentId
-     * @param payerId
-     * @return
-     */
-    @RequestMapping(value = "/paypal/callback", method = RequestMethod.GET)
-    public String successPay(@RequestParam("paymentId") String paymentId,
-                             @RequestParam("PayerID") String payerId) {
-        try {
-            log.warn("=====paypal支付回调=====\npaymentId:"+paymentId+"\npayerId:"+payerId);
-            Payment payment = paypalService.executePayment(paymentId, payerId);
-            if (payment.getState().equals("approved")) {
-                log.info("paypal支付成功回调");
-                String custom = payment.getTransactions().get(0).getCustom();
-                String txnId = payment.getTransactions().get(0).getRelatedResources().get(0).getSale().getId();
-                String payerEmail  = payment.getTransactions().get(0).getPayee().getEmail();
-                log.warn("=====custom:"+custom+"\ntxnId:"+txnId+"\npayerEmail:"+payerEmail);
-
-                String orderSn = custom.split("_")[0];
-                if(custom.split("_").length > 2 && custom.split("_")[2].matches("^-?[0-9]+")){
-                    orderSn += "_" + custom.split("_")[2];
-                }
-                orderStrategyFactory.doHandler(orderSn, txnId, payerEmail, custom.split("_")[1], 2);
-                return "redirect:" + NacosProperty.getMainUrl() + config.getSuccessUrl();
-            }
-        } catch (PayPalRESTException e) {
-            log.error(e.getMessage());
-        } catch (Exception e) {
-            log.error("paypal支付回调异常,errorMsg:{}", e.getMessage());
-        }
-        return "redirect:" + NacosProperty.getMainUrl() + config.getFailUrl();
-    }
-
-    /**
-     * 支付成功
-     * @param paymentId
-     * @param payerId
-     * @return
-     */
-    @RequestMapping(value = "/paypal/callbackH5", method = RequestMethod.GET)
-    public String successPayH5(@RequestParam("paymentId") String paymentId,
-                               @RequestParam("PayerID") String payerId) {
-        try {
-            log.warn("=====paypal支付回调=====\npaymentId:"+paymentId+"\npayerId:"+payerId);
-            Payment payment = paypalService.executePayment(paymentId, payerId);
-            if (payment.getState().equals("approved")) {
-                log.info("paypal支付成功回调");
-                String custom = payment.getTransactions().get(0).getCustom();
-                String txnId = payment.getTransactions().get(0).getRelatedResources().get(0).getSale().getId();
-                String payerEmail  = payment.getTransactions().get(0).getPayee().getEmail();
-                log.warn("=====custom:"+custom+"\ntxnId:"+txnId+"\npayerEmail:"+payerEmail);
-                String orderSn = custom.split("_")[0];
-                if(custom.split("_").length > 2 && custom.split("_")[2].matches("^-?[0-9]+")){
-                    orderSn += "_" + custom.split("_")[2];
-                }
-                orderStrategyFactory.doHandler(orderSn, txnId, payerEmail, custom.split("_")[1], 2);
-                return "redirect:" + NacosProperty.getMainUrl() + config.getH5SuccessUrl();
-            }
-        } catch (PayPalRESTException e) {
-            log.error(e.getMessage());
-        } catch (Exception e) {
-            log.error("paypal支付回调异常,errorMsg:{}", e.getMessage());
-        }
-        return "redirect:" + NacosProperty.getMainUrl() + config.getH5FailUrl();
-    }
-
-    /**
-     * 取消支付
-     * @return
-     */
-    @RequestMapping(value = "/paypal/cancel", method = RequestMethod.GET)
-    public String cancelPay(){
-        return "redirect:" + NacosProperty.getMainUrl() + config.getFailUrl();
-    }
-
-    /**
-     * 取消支付
-     * @return
-     */
-    @RequestMapping(value = "/paypal/cancelH5", method = RequestMethod.GET)
-    public String cancelPayH5(){
-        return "redirect:" + NacosProperty.getMainUrl() + config.getH5FailUrl();
-    }
-
-    /**
-     *  Paypal的INP异步通知服务器, 需要修改Paypal官网即时付款通知IPN通告URL
-     */
-    @ResponseBody
-    @RequestMapping(value = "/paypal/notify", method = RequestMethod.POST)
-    public void callback() {
-        Enumeration en = request.getParameterNames();
-        String str = "cmd=_notify-validate";
-        while (en.hasMoreElements()) {
-            String paramName = (String) en.nextElement();
-            String paramValue = request.getParameter(paramName);
-            try {
-                str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue, "utf-8");
-            } catch (UnsupportedEncodingException e) {
-                StringWriter trace=new StringWriter();
-                e.printStackTrace(new PrintWriter(trace));
-                log.error(trace.toString());
-            }
-            //此处的编码一定要和自己的网站编码一致,不然会出现乱码,paypal回复的通知为‘INVALID’
-        }
-        final String itemName = request.getParameter("item_name");//商品名
-        final String itemNumber = request.getParameter("item_number");//购买数量
-        final String paymentDate = request.getParameter("payment_date");//交易时间
-        final String receiverEmail = request.getParameter("receiver_email");//收款人email
-        final String payerEmail = request.getParameter("payer_email");//付款人email
-        final String paymentAmount = request.getParameter("mc_gross");//交易钱数
-        final String paymentCurrency = request.getParameter("mc_currency");//货币种类
-        final String paymentStatus = request.getParameter("payment_status");//交易状态
-        final String txnId = request.getParameter("txn_id");//交易id
-        String custom = request.getParameter("custom");//发送payment请求时候自定义的业务服务器订单号
-
-        log.info("itemName:"+itemName);
-        log.info("itemNumber:"+itemNumber);
-        log.info("paymentDate:"+paymentDate);
-        log.info("receiverEmail:"+receiverEmail);
-        log.info("payerEmail:"+payerEmail);
-        log.info("paymentAmount:"+paymentAmount);
-        log.info("paymentCurrency:"+paymentCurrency);
-        log.info("paymentStatus:"+paymentStatus);
-        log.info("txnId:"+txnId);
-        log.info("custom:"+custom);
-        String orderSn = custom.split("_")[0];
-        try {
-
-
-            if ("Completed".equals(paymentStatus)) {
-                //根据自己业务进行处理(修改订单状态,支付时间等等操作)
-                try {
-                    log.info("paypal支付成功回调");
-                    //表示续费,有消费记录id
-                    if (custom.split("_").length > 2 && custom.split("_")[2].matches("^-?[0-9]+")) {
-                        orderStrategyFactory.doHandler(custom.split("_")[0] + "_" + custom.split("_")[2], txnId, payerEmail, custom.split("_")[1], 2);
-                    } else {
-                        orderStrategyFactory.doHandler(orderSn, txnId, payerEmail, custom.split("_")[1], 2);
-                    }
-                } catch (Exception e) {
-                    log.error("paypal支付回调异常,errorMsg:{}", e.getMessage());
-                }
-            }
-        }catch (Exception e) {
-            log.error("paypal支付回调异常,errorMsg:{}", e.getMessage());
-        }
-
-    }
-
-    @RequestMapping(value = "/paypalresult", method = RequestMethod.GET)
-    @org.springframework.web.bind.annotation.ResponseBody
-    public Result paypalresult(HttpServletRequest request) throws Exception {
-        if(!ev.equals("test-eur")){
-            return  Result.failure("正式环境不允许调用!");
-        }
-
-        String orderSn = request.getParameter("orderSn");
-        String txnId = request.getParameter("txnId");
-        String payerEmail = request.getParameter("payer_email");//付款人email
-        String type = request.getParameter("type");//付款人email
-
-
-        //download  ,increment
-
-        orderStrategyFactory.doHandler(orderSn, txnId, payerEmail, type, 2);
-        return  Result.success();
-
-    }
-
-}

+ 0 - 259
src/main/java/com/fdkankan/ucenter/controller/OrderWechatPayController.java

@@ -1,259 +0,0 @@
-package com.fdkankan.ucenter.controller;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ConstantUrl;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.redis.util.RedisUtil;
-import com.fdkankan.ucenter.common.BaseController;
-import com.fdkankan.ucenter.common.Result;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.entity.*;
-import com.fdkankan.ucenter.pay.factory.PayFactory;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.pay.paypal.sdk.UrlUtils;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategyFactory;
-import com.fdkankan.ucenter.pay.wx.WXPayConstants;
-import com.fdkankan.ucenter.pay.wx.WXPayDefaultConfig;
-import com.fdkankan.ucenter.pay.wx.WXPayUtil;
-import com.fdkankan.ucenter.service.*;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import java.io.BufferedOutputStream;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-@Log4j2
-/**支付中心-微信支付模块"*/
-@Controller
-@RequestMapping("/ucenter/order/pay")
-public class OrderWechatPayController extends BaseController {
-    @Autowired
-    private OrderStrategyFactory orderStrategyFactory;
-    @Autowired
-    private PayFactory payFactory;
-    @Autowired
-    private IOrderService orderService;
-    @Autowired
-    private IVirtualOrderService virtualOrderService;
-    @Autowired
-    private IExpansionOrderService expansionOrderService;
-
-    @Autowired
-    private IIncrementOrderService incrementOrderService;
-    @Autowired
-    IOrderItemService orderItemService;
-    @Autowired
-    RedisUtil redisUtil;
-    @Autowired
-    PayOrderService payOrderService;
-
-
-    @ResponseBody
-    @RequestMapping(value = "/wechatPay", method = RequestMethod.POST)
-    public Result wechatPay(@RequestBody PlaceOrderParam order) throws Exception {
-        return Result.success(payFactory.scanPay("wechat", order));
-    }
-
-    @ResponseBody
-    @RequestMapping(value = "/wechatMobilePay", method = RequestMethod.POST)
-    public Result wechatMobilePay(@RequestBody PlaceOrderParam order) throws Exception {
-        return Result.success(payFactory.h5Pay("wechat", order, UrlUtils.getIpAddr(request)));
-    }
-
-    @RequestMapping(value = "/wechatPreJsPay")
-    public String wechatPreJsPay(Long orderId, int orderType, String code, Long spaceId) throws Exception {
-        InputStream is = null;
-        WXPayDefaultConfig config = new WXPayDefaultConfig();
-        // 这个url链接地址和参数皆不能变
-        String url = ConstantUrl.WEIXIN_TOKEN_URL1 + config.getAppID() + "&secret=" + config.getSecret() + "&grant_type=authorization_code" + "&code=" + code;
-        try {
-            URL urlGet = new URL(url);
-            HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
-            http.setRequestMethod("GET"); // 必须是get方式请求
-            http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
-            http.setDoOutput(true);
-            http.setDoInput(true);
-            System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒
-            System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒
-            http.connect();
-            is = http.getInputStream();
-            int size = is.available();
-            byte[] jsonBytes = new byte[size];
-            is.read(jsonBytes);
-            String message = new String(jsonBytes, "UTF-8");
-            log.debug("获取access_token返回的message:"+message);
-            JSONObject oppidObj = JSONObject.parseObject(message);
-            String access_token = (String) oppidObj.get("access_token");
-            String openid = (String) oppidObj.get("openid");
-
-            String orderSn = null;
-            StringBuilder sb = new StringBuilder();
-            BigDecimal totalFee = null;
-            switch (orderType){
-                case 0:
-                    Order responseOrder = orderService.getById(orderId);
-                    if (responseOrder.getId() == null) return "redirect:" + NacosProperty.getMainUrl() + "mobile.html#/payresult/fail";
-
-                    List<OrderItem> items = orderItemService.getByOrderId(orderId);
-                    for (int i = 0; i < items.size(); i++){
-                        sb.append(items.get(i).getGoodsCount()).append("*").append(items.get(i).getGoodsName());
-                        if (i != items.size() - 1){
-                            sb.append(",");
-                        }
-                    }
-                    totalFee = responseOrder.getTotalAmount().multiply(new BigDecimal(100));
-                    orderSn = responseOrder.getOrderSn();
-                    orderSn += "_entity";
-                    break;
-                case 1:
-                    VirtualOrder virtualOrderEntity = virtualOrderService.getById(orderId);
-                    if (virtualOrderEntity == null){
-                        return "redirect:" + NacosProperty.getMainUrl() + "mobile.html#/payresult/fail";
-                    }
-                    sb.append(Constant.PAY_SUBJECT + ":" + virtualOrderEntity.getPoints());
-                    totalFee = new BigDecimal(virtualOrderEntity.getPoints()).multiply(new BigDecimal(100));
-                    orderSn = virtualOrderEntity.getOrderSn();
-                    orderSn += "_recharge";
-                    break;
-                case 2:
-                    ExpansionOrder expansion = expansionOrderService.getById(orderId);
-                    if (expansion == null){
-                        return "redirect:" + NacosProperty.getMainUrl() + "mobile.html#/payresult/fail";
-                    }
-                    //订单金额为国外金额就报错
-                    if(expansion.getAbroad() == 1){
-                        throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-                    }
-                    String date = "1年";
-                    if(expansion.getMonth() < 12){
-                        date = expansion.getMonth() + "个月";
-                    }
-                    String subject = Constant.EXPANSION_SUBJECT + ":" + expansion.getUnitSize() + expansion.getUnit() + "/" + date;
-                    sb.append(subject);
-                    totalFee = expansion.getAmount().multiply(new BigDecimal(100));
-                    orderSn = expansion.getOrderSn();
-                    orderSn += "_expansion";
-                    break;
-                case 3:
-                    break;
-                case 4:
-                    IncrementOrder incrementOrderEntity = incrementOrderService.getById(orderId);
-                    if (incrementOrderEntity == null){
-                        return "redirect:" + NacosProperty.getMainUrl() + "mobile.html#/payresult/fail";
-                    }
-                    //订单金额为国外金额就报错
-                    if(incrementOrderEntity.getAbroad() == 1){
-                        throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-                    }
-                    sb.append(Constant.INCREMENT_SUBJECT + ":" + incrementOrderEntity.getCount() + "个/年");
-                    totalFee = incrementOrderEntity.getAmount().multiply(new BigDecimal(100));
-                    orderSn = incrementOrderEntity.getOrderSn();
-                    orderSn += "_increment";
-                    break;
-                case 5:
-                    break;
-            }
-            String body = sb.toString();
-            if(spaceId != null){
-                orderSn = orderSn.replace("expansion", String.valueOf(spaceId));
-            }
-            Map<String, String> resp = payOrderService.wechatPay(orderSn, sb.toString(), body, totalFee, UrlUtils.getIpAddr(request), openid);
-            String timeStamp = String.valueOf(System.currentTimeMillis() / 1000);
-            return "redirect:" + NacosProperty.getMainUrl() + ConstantUrl.WEIXIN_MOBILE_PAY_URL + timeStamp + "&signType=MD5&appId=" + resp.get("appid")
-                    + "&nonceStr=" + resp.get("nonce_str") + "&prepay_id=" + resp.get("prepay_id") + "&paySign=" + resp.get("paySign");
-        }catch (Exception e){
-            log.debug("获取access_token发生异常",e);
-        }finally {
-            if (is != null){
-                is.close();
-            }
-        }
-        return "redirect:" + NacosProperty.getMainUrl() + "mobile.html#/payresult/fail";
-    }
-
-    @RequestMapping(value = "/wechatPay/notify", method = RequestMethod.POST)
-    public void callback() {
-        log.warn("微信回调接口方法 start");
-        String inputLine = "";
-        String notifyXml = "";
-        try {
-            while((inputLine = request.getReader().readLine()) != null){
-                notifyXml += inputLine;
-            }
-            //关闭流
-            request.getReader().close();
-            log.warn("微信回调内容信息:"+notifyXml);
-            //解析成Map
-            Map<String,String> map = WXPayUtil.xmlToMap(notifyXml);
-
-            WXPayDefaultConfig config = new WXPayDefaultConfig();
-            if (WXPayUtil.isSignatureValid(map, config.getKey(), WXPayConstants.SignType.MD5) || WXPayUtil.isSignatureValid(map, config.getKey(), WXPayConstants.SignType.HMACSHA256)) {
-                //判断 支付是否成功
-                if("SUCCESS".equals(map.get("result_code"))){
-                    log.warn("微信回调返回是否支付成功:是");
-                    //获得 返回的商户订单号
-                    String out_trade_no = map.get("out_trade_no");
-                    String trade_no = map.get("transaction_id");
-                    String openid = map.get("openid");
-                    log.warn("微信回调返回商户订单号:" + out_trade_no);
-                    //修改订单状态
-                    String orderSnE = out_trade_no.substring(0, out_trade_no.lastIndexOf("_"));
-
-                    String orderSn = out_trade_no.split("_")[0];
-                    if(!out_trade_no.contains("recharge") && !out_trade_no.contains("commerce") &&
-                            !out_trade_no.contains("entity") && !out_trade_no.contains("expansion") &&
-                            !out_trade_no.contains("increment") && !out_trade_no.contains("download")){
-//                        orderSn += "_" + out_trade_no.split("_")[1];
-
-                        log.warn("orderSnE:" + orderSn + "_expansion");
-                        if (redisUtil.hasKey(orderSn + "_expansion")){
-                            redisUtil.del(orderSn + "_expansion");
-                        }
-                        redisUtil.set(orderSn + "_expansion", out_trade_no,5*60);
-                    }else {
-                        log.warn("orderSnE:" + orderSnE);
-                        if (redisUtil.hasKey(orderSnE)){
-                            redisUtil.del(orderSnE);
-                        }
-                        redisUtil.set(orderSnE, out_trade_no,5*60);
-                    }
-                    orderStrategyFactory.doHandler(orderSn, trade_no, openid, out_trade_no.split("_")[1], 0);
-                    log.warn("微信支付成功,订单号:"  + orderSn);
-                    //通知微信服务器已经支付成功
-                    notifyXml = "<xml><return_code><![CDATA[SUCCESS]]></return_code>"
-                            + "<return_msg><![CDATA[OK]]></return_msg></xml> ";
-                }else{
-                    notifyXml = "<xml><return_code><![CDATA[FAIL]]></return_code>"
-                            + "<return_msg><![CDATA[报文为空]]></return_msg></xml> ";
-                }
-            } else{
-                log.error("签名验证错误");
-                notifyXml = "<xml><return_code><![CDATA[FAIL]]></return_code>"
-                        + "<return_msg><![CDATA[签名验证错误]]></return_msg></xml>";
-            }
-            BufferedOutputStream out = new BufferedOutputStream(
-                    response.getOutputStream());
-            out.write(notifyXml.getBytes());
-            out.flush();
-            out.close();
-
-        } catch (Exception e) {
-            log.error("微信支付回调数据异常, errorMsg:{}", e.getMessage());
-        }
-    }
-
-
-}

+ 0 - 116
src/main/java/com/fdkankan/ucenter/mq/consumer/AutoOrderConsumer.java

@@ -1,116 +0,0 @@
-package com.fdkankan.ucenter.mq.consumer;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.ucenter.entity.*;
-import com.fdkankan.ucenter.httpClient.vo.PayOrderVo;
-import com.fdkankan.ucenter.pay.paypal.sdk.AutoPaypalVo;
-import com.fdkankan.ucenter.pay.strategy.impl.DownloadOrderImpl;
-import com.fdkankan.ucenter.pay.strategy.impl.EntityOrderImpl;
-import com.fdkankan.ucenter.pay.strategy.impl.IncrementOrderImpl;
-import com.fdkankan.ucenter.service.*;
-import com.fdkankan.ucenter.util.DateUserUtil;
-import com.rabbitmq.client.Channel;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-
-@Slf4j
-@Component
-public class AutoOrderConsumer {
-
-
-    @Autowired
-    IUserIncrementService userIncrementService;
-    @Autowired
-    IMailTemplateService mailTemplateService;
-    @Autowired
-    IUserService userService;
-    @Autowired
-    IncrementOrderImpl incrementOrderImpl;
-    @Autowired
-    IIncrementAutoOrderService autoOrderService;
-
-
-    @RabbitListener(
-            queuesToDeclare = @Queue("${queue.pay.auto-paypal:pay-auto-paypal}")
-            ,concurrency = "1"
-    )
-    public void consumerQueue(Channel channel, Message message)  {
-        try {
-            String messageId = message.getMessageProperties().getMessageId();
-            String msg = new String(message.getBody(), StandardCharsets.UTF_8);
-            log.info("autoPaypal-result-mq--messageId:{},msg:{}",messageId,msg);
-
-            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-
-            AutoPaypalVo order = JSONObject.parseObject(msg, AutoPaypalVo.class);
-            if(order == null){
-                return;
-            }
-            IncrementAutoOrder incrementAutoOrder = autoOrderService.getByOrderSn(order.getSubscriptionOrderSn());
-            if(incrementAutoOrder == null){
-                incrementAutoOrder = autoOrderService.getDelOrder(order.getSubscriptionOrderSn());
-                if(incrementAutoOrder != null){
-                    autoOrderService.updateDelStatus(incrementAutoOrder.getId());
-                }
-            }
-            if(incrementAutoOrder == null){
-                return;
-            }
-            if(incrementAutoOrder.getSubscriptionId() == null){
-                autoOrderService.subOrder(order.getSubscriptionOrderSn(),order.getSubscriptionId());
-            }
-
-            switch (order.getEventType()){
-                case "PAYMENT.SALE.COMPLETED" :     //每日扣款
-                    //Enum: "completed" "partially_refunded" "pending" "refunded" "denied"
-                    switch (order.getState()){
-                        case "completed" :      //扣款完成
-                            autoOrderService.paySuccess(incrementAutoOrder,order);
-                            break;
-                        case "partially_refunded" :
-                            break;
-                        case "pending" :        //等待
-                            break;
-                        case "refunded" :       //退还
-                            break;
-                        case "denied" :         //支付失败
-                            autoOrderService.payError(incrementAutoOrder,order);
-                            break;
-                    }
-                    break;
-                case "BILLING.SUBSCRIPTION.CANCELLED" :     //取消订阅
-                    autoOrderService.subscriptionCancelled(incrementAutoOrder,order);
-                    break;
-                case "BILLING.SUBSCRIPTION.PAYMENT.FAILED" :     //订阅付款失败
-                    autoOrderService.payError(incrementAutoOrder,order);
-                    break;
-                case "BILLING.SUBSCRIPTION.SUSPENDED" :     //订阅暂停
-                    List<UserIncrement> userIncrementList = userIncrementService.getByAutoOrderSn(order.getSubscriptionId());
-                    for (UserIncrement userIncrement : userIncrementList) {
-                        userIncrementService.cancelSubscription(userIncrement.getId());
-                    }
-                    break;
-                default:
-                    break;
-            }
-
-
-        }catch (Exception e){
-            log.info("order-payResult----消费失败",e);
-        }finally {
-
-        }
-
-    }
-
-}

+ 0 - 90
src/main/java/com/fdkankan/ucenter/mq/consumer/OrderDownConsumer.java

@@ -1,90 +0,0 @@
-package com.fdkankan.ucenter.mq.consumer;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.rabbitmq.util.RabbitMqProducer;
-import com.fdkankan.ucenter.entity.DownloadOrder;
-import com.fdkankan.ucenter.httpClient.vo.PayOrderVo;
-import com.fdkankan.ucenter.pay.strategy.impl.DownloadOrderImpl;
-import com.fdkankan.ucenter.pay.strategy.impl.EntityOrderImpl;
-import com.fdkankan.ucenter.pay.strategy.impl.IncrementOrderImpl;
-import com.fdkankan.ucenter.service.IIncrementAutoOrderService;
-import com.fdkankan.ucenter.service.IIncrementOrderService;
-import com.rabbitmq.client.Channel;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.amqp.core.ExchangeTypes;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Exchange;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.QueueBinding;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-import sun.rmi.runtime.Log;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-
-@Slf4j
-@Component
-public class OrderDownConsumer {
-
-
-    @Autowired
-    IncrementOrderImpl incrementOrder;
-    @Autowired
-    DownloadOrderImpl downloadOrder;
-    @Autowired
-    EntityOrderImpl entityOrder;
-    @Autowired
-    IIncrementAutoOrderService autoOrderService;
-
-
-    @RabbitListener(
-            queuesToDeclare = @Queue("${queue.orderPay.order-payResult:order-payResult}")
-            ,concurrency = "1"
-    )
-    public void consumerQueue(Channel channel, Message message)  {
-        try {
-            String messageId = message.getMessageProperties().getMessageId();
-            String msg = new String(message.getBody(), StandardCharsets.UTF_8);
-            log.info("接受下单结果mq--messageId:{},msg:{}",messageId,msg);
-
-            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-
-            PayOrderVo order = JSONObject.parseObject(msg, PayOrderVo.class);
-            if(order == null ){
-                return;
-            }
-            if(order.getAutoPay() != null && order.getAutoPay() == 1){
-                autoOrderService.subOrder(order.getOrderSn(),order.getTradeNo());
-                return;
-            }
-            //更新订单状态
-            Integer payType = 3;
-            //付款方式,0表示微信,1表示支付宝,2表示paypal,3表示其他
-            switch (order.getPayType()){
-                case 0 : case 1: case 2: payType = 0;break;
-                case 3 : case 4:  payType = 1;break;
-                case 5 :   payType = 2;break;
-            }
-            if("incrementOrder".equals(order.getOrderType())){
-                incrementOrder.handleOrder(order.getOrderSn(),order.getTradeNo(),order.getOpenId(),payType,null);
-            }
-            if("downOrder".equals(order.getOrderType())){
-                downloadOrder.handleOrder(order.getOrderSn(),order.getTradeNo(),order.getOpenId(),payType,null);
-            }
-            if("partOrder".equals(order.getOrderType())){
-                entityOrder.handleOrder(order.getOrderSn(),order.getTradeNo(),order.getOpenId(),payType,null);
-            }
-        }catch (Exception e){
-            log.error("order-payResult----消费失败",e);
-        }finally {
-
-        }
-
-    }
-
-}

+ 0 - 3
src/main/java/com/fdkankan/ucenter/mq/consumer/ScenePayStatusConsumer.java

@@ -3,9 +3,6 @@ package com.fdkankan.ucenter.mq.consumer;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.ucenter.httpClient.vo.PayOrderVo;
 import com.fdkankan.ucenter.mq.vo.ScenePayStatusVo;
-import com.fdkankan.ucenter.pay.strategy.impl.DownloadOrderImpl;
-import com.fdkankan.ucenter.pay.strategy.impl.EntityOrderImpl;
-import com.fdkankan.ucenter.pay.strategy.impl.IncrementOrderImpl;
 import com.fdkankan.ucenter.service.ISceneProService;
 import com.rabbitmq.client.Channel;
 import lombok.extern.slf4j.Slf4j;

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 90
src/main/java/com/fdkankan/ucenter/pay/alipay/AlipayDefaultConfig.java


+ 0 - 81
src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipayConfig.java

@@ -1,81 +0,0 @@
-package com.fdkankan.ucenter.pay.alipay.sdk;
-
-import com.alipay.demo.trade.service.AlipayTradeService;
-import com.alipay.demo.trade.service.impl.AlipayTradeServiceImpl;
-import org.springframework.context.annotation.Bean;
-import org.springframework.stereotype.Component;
-
-@Component
-public abstract class AlipayConfig {
-
-    /** 签名类型 */
-    private String signType = "RSA2";
-    /** 格式 */
-    private String formate = "json";
-    /** 编码 */
-    private String charset = "UTF-8";
-    /** 最大查询次数 */
-    private int maxQueryRetry = 5;
-    /** 查询间隔(毫秒) */
-    private long queryDuration = 5000;
-    /** 最大撤销次数 */
-    private int maxCancelRetry = 3;
-    /** 撤销间隔(毫秒) */
-    private long cancelDuration = 3000;
-
-    /** 支付宝gatewayUrl */
-    abstract public String getGatewayUrl();
-
-    /** 商户应用id */
-    abstract public String getAppid();
-
-    /** RSA私钥,用于对商户请求报文加签 */
-    abstract public String getAppPrivateKey();
-
-    /** 支付宝RSA公钥,用于验签支付宝应答 */
-    abstract public String getAlipayPublicKey();
-
-    /** 同步地址 */
-    abstract public String getReturnUrl();
-    /** 异步地址 */
-    abstract public String getNotifyUrl();
-
-    public String getSignType(){
-        return signType;
-    }
-
-    public String getFormate(){
-        return formate;
-    }
-
-    public String getCharset(){
-        return charset;
-    }
-
-    public int getMaxQueryRetry() {
-        return maxQueryRetry;
-    }
-
-    public long getQueryDuration() {
-        return queryDuration;
-    }
-
-    public int getMaxCancelRetry() {
-        return maxCancelRetry;
-    }
-
-    public long getCancelDuration() {
-        return cancelDuration;
-    }
-
-    @Bean
-    public AlipayTradeService alipayTradeService() {
-        return new AlipayTradeServiceImpl.ClientBuilder()
-                .setGatewayUrl(getGatewayUrl())
-                .setAppid(getAppid())
-                .setPrivateKey(getAppPrivateKey())
-                .setAlipayPublicKey(getAlipayPublicKey())
-                .setSignType(getSignType())
-                .build();
-    }
-}

+ 0 - 60
src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipayGoodsDetail.java

@@ -1,60 +0,0 @@
-package com.fdkankan.ucenter.pay.alipay.sdk;
-
-import java.io.Serializable;
-
-public class AlipayGoodsDetail implements Serializable {
-
-    private static final long serialVersionUID = -8875896136641533825L;
-
-    public AlipayGoodsDetail() {
-    }
-
-    public static AlipayGoodsDetail newInstance(String goodsId, String goodsName, long price, int quantity) {
-        AlipayGoodsDetail info = new AlipayGoodsDetail();
-        info.setGoodsId(goodsId);
-        info.setGoodsName(goodsName);
-        info.setPrice(price);
-        info.setQuantity(quantity);
-        return info;
-    }
-    // 必填,商品的编号,length=32
-    private String goodsId;
-    // 必填,商品的名称,length=256
-    private String goodsName;
-    // 必填,商品数量
-    private int quantity;
-    // 必填,商品单价,单位为元
-    private long price;
-
-    public String getGoodsId() {
-        return goodsId;
-    }
-
-    public void setGoodsId(String goodsId) {
-        this.goodsId = goodsId;
-    }
-
-    public String getGoodsName() {
-        return goodsName;
-    }
-
-    public void setGoodsName(String goodsName) {
-        this.goodsName = goodsName;
-    }
-
-    public int getQuantity() {
-        return quantity;
-    }
-
-    public void setQuantity(int quantity) {
-        this.quantity = quantity;
-    }
-
-    public long getPrice() {
-        return price;
-    }
-
-    public void setPrice(long price) {
-        this.price = price;
-    }
-}

+ 0 - 160
src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipayService.java

@@ -1,160 +0,0 @@
-package com.fdkankan.ucenter.pay.alipay.sdk;
-
-import com.alipay.api.AlipayApiException;
-import com.alipay.api.AlipayResponse;
-import com.alipay.api.domain.TradeFundBill;
-import com.alipay.api.response.AlipayTradePrecreateResponse;
-import com.alipay.api.response.AlipayTradeQueryResponse;
-import com.alipay.demo.trade.model.GoodsDetail;
-import com.alipay.demo.trade.model.builder.AlipayTradePrecreateRequestBuilder;
-import com.alipay.demo.trade.model.builder.AlipayTradeQueryRequestBuilder;
-import com.alipay.demo.trade.model.result.AlipayF2FPrecreateResult;
-import com.alipay.demo.trade.model.result.AlipayF2FQueryResult;
-import com.alipay.demo.trade.service.AlipayTradeService;
-import com.alipay.demo.trade.utils.Utils;
-import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Log4j2
-@Service
-public class AlipayService {
-
-    @Autowired
-    private AlipayTradeService alipayTradeService;
-
-    /**
-     * 当面付-扫码付
-     *
-     * 扫码支付,指用户打开支付宝钱包中的“扫一扫”功能,扫描商户针对每个订单实时生成的订单二维码,并在手机端确认支付。
-     *
-     * 发起预下单请求,同步返回订单二维码
-     *
-     * 适用场景:商家获取二维码展示在屏幕上,然后用户去扫描屏幕上的二维码
-     * @return
-     * @throws AlipayApiException
-     */
-    public Map<String, String> tradePrecreate(AlipaymentEx alipaymentEx, String notifyUrl) throws AlipayApiException {
-        if (StringUtils.isEmpty(alipaymentEx.getOutTradeNo())){
-            throw new AlipayApiException("outTradeNo should not be null");
-        }else if (StringUtils.isEmpty(alipaymentEx.getSubject())){
-            throw new AlipayApiException("subject should not be null");
-        }else if (StringUtils.isEmpty(alipaymentEx.getBody())){
-            throw new AlipayApiException("body should not be null");
-        }else if (alipaymentEx.getTotalAmount() == null){
-            throw new AlipayApiException("totalAmout should not be null");
-        }else if (StringUtils.isEmpty(alipaymentEx.getStoreId())){
-            throw new AlipayApiException("storeid should not be null");
-        }else if (alipaymentEx.getGoodsDetailList() == null || alipaymentEx.getGoodsDetailList().size() == 0){
-            throw new AlipayApiException("goodsDetailList should not be null");
-        }else if (StringUtils.isEmpty(notifyUrl)){
-            throw new AlipayApiException("notifyUrl should not be null");
-        }
-
-        List<AlipayGoodsDetail> alipayGoodsDetails = alipaymentEx.getGoodsDetailList();
-        List<GoodsDetail> goodsDetailList = new ArrayList<>();
-        for (AlipayGoodsDetail alipayGoodsDetail : alipayGoodsDetails){
-            GoodsDetail goods1 = GoodsDetail.newInstance(alipayGoodsDetail.getGoodsId(),
-                    alipayGoodsDetail.getGoodsName(), alipayGoodsDetail.getPrice(), alipayGoodsDetail.getQuantity());
-            goodsDetailList.add(goods1);
-        }
-
-        AlipayTradePrecreateRequestBuilder builder = new AlipayTradePrecreateRequestBuilder()
-                .setSubject(alipaymentEx.getSubject())
-                .setTotalAmount(alipaymentEx.getTotalAmount().toString())
-                .setOutTradeNo(alipaymentEx.getOutTradeNo())
-                .setUndiscountableAmount(alipaymentEx.getUndiscountableAmount() == null ? "" : alipaymentEx.getUndiscountableAmount().toString())
-                .setSellerId(alipaymentEx.getSellerId() == null ? "" : alipaymentEx.getSellerId())
-                .setBody(alipaymentEx.getBody())
-                .setOperatorId(alipaymentEx.getOperatorId() == null ? "" : alipaymentEx.getOperatorId())
-                .setStoreId(alipaymentEx.getStoreId())
-                .setTimeoutExpress(alipaymentEx.getTimeoutExpress())
-                //支付宝服务器主动通知商户服务器里指定的页面http路径,根据需要设置
-                .setNotifyUrl(notifyUrl)
-                .setGoodsDetailList(goodsDetailList);
-
-        Map<String, String> resp = new HashMap<>();
-        AlipayF2FPrecreateResult result = alipayTradeService.tradePrecreate(builder);
-        AlipayTradePrecreateResponse res = result.getResponse();
-        switch (result.getTradeStatus()) {
-            case SUCCESS:
-                dumpResponse(res);
-                log.info("支付宝预下单成功。");
-                resp.put("code", "0");
-                resp.put("out_trade_no", res.getOutTradeNo());
-                resp.put("qr_code", res.getQrCode());
-                break;
-
-            case FAILED:
-                log.error("支付宝预下单失败,code:" + res.getCode() + ",msg:" + res.getMsg());
-                resp.put("code", "-1");
-                break;
-
-            case UNKNOWN:
-                log.error("系统异常,预下单状态未知,code:" + res.getCode() + ",msg:" + res.getMsg());
-                resp.put("code", "-2");
-                break;
-
-            default:
-                log.error("不支持的交易状态,交易返回异常,code:" + res.getCode() + ",msg:" + res.getMsg());
-                resp.put("code", "-3");
-                break;
-        }
-        return resp;
-    }
-
-    public String tradeQuery(String outTradeNo) {
-        // (必填) 商户订单号,通过此商户订单号查询当面付的交易状态
-        String Type;
-        // 创建查询请求builder,设置请求参数
-        AlipayTradeQueryRequestBuilder builder = new AlipayTradeQueryRequestBuilder()
-                .setOutTradeNo(outTradeNo);
-        System.out.println("请求参数:" + builder);
-        AlipayF2FQueryResult result = alipayTradeService.queryTradeResult(builder);
-        switch (result.getTradeStatus()) {
-            case SUCCESS:
-                log.info("查询返回该订单支付成功: )");
-                Type = "SUCCESS";
-                AlipayTradeQueryResponse response = result.getResponse();
-                dumpResponse(response);
-                log.info(response.getTradeStatus());
-                if (Utils.isListNotEmpty(response.getFundBillList())) {
-                    for (TradeFundBill bill : response.getFundBillList()) {
-                        log.info(bill.getFundChannel() + ":" + bill.getAmount());
-                    }
-                }
-                break;
-            case FAILED:
-                log.error("查询返回该订单支付失败或被关闭!!!");
-                Type = "FAILED";
-                break;
-            case UNKNOWN:
-                log.error("系统异常,订单支付状态未知!!!");
-                Type = "UNKNOWN";
-                break;
-            default:
-                log.error("不支持的交易状态,交易返回异常!!!");
-                Type = "default";
-                break;
-        }
-        return Type;
-    }
-
-    // 简单打印应答
-    private void dumpResponse(AlipayResponse response) {
-        if (response != null) {
-            log.info(String.format("code:%s, msg:%s", response.getCode(), response.getMsg()));
-            if (StringUtils.isNotEmpty(response.getSubCode())) {
-                log.info(String.format("subCode:%s, subMsg:%s", response.getSubCode(),
-                        response.getSubMsg()));
-            }
-            log.info("body:" + response.getBody());
-        }
-    }
-}

+ 0 - 38
src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipayUtil.java

@@ -1,38 +0,0 @@
-package com.fdkankan.ucenter.pay.alipay.sdk;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.EncodeHintType;
-import com.google.zxing.MultiFormatWriter;
-import com.google.zxing.WriterException;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
-
-import java.awt.image.BufferedImage;
-import java.util.Hashtable;
-import java.util.Map;
-
-public class AlipayUtil {
-
-    /**
-     * 根据url生成二位图片对象
-     *
-     * @param codeUrl
-     * @return
-     * @throws WriterException
-     */
-    public static BufferedImage getQRCodeImge(String codeUrl) throws WriterException {
-        Map<EncodeHintType, Object> hints = new Hashtable();
-        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
-        hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
-        int width = 300;
-        BitMatrix bitMatrix = (new MultiFormatWriter()).encode(codeUrl, BarcodeFormat.QR_CODE, width, width, hints);
-        BufferedImage image = new BufferedImage(width, width, 1);
-        for(int x = 0; x < width; ++x) {
-            for(int y = 0; y < width; ++y) {
-                image.setRGB(x, y, bitMatrix.get(x, y) ? -16777216 : -1);
-            }
-        }
-
-        return image;
-    }
-}

+ 0 - 113
src/main/java/com/fdkankan/ucenter/pay/alipay/sdk/AlipaymentEx.java

@@ -1,113 +0,0 @@
-package com.fdkankan.ucenter.pay.alipay.sdk;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.List;
-
-public class AlipaymentEx implements Serializable {
-
-    private static final long serialVersionUID = 8082279987959002563L;
-    // (必填) 商户网站订单系统中唯一订单号,64个字符以内,只能包含字母、数字、下划线,
-    private String outTradeNo;
-    // (必填) 订单标题,粗略描述用户的支付目的。如“喜士多(浦东店)消费”
-    private String subject;
-    // 订单描述,可以对交易或商品进行一个详细地描述,比如填写"购买商品2件共15.00元"
-    private String body;
-    // (必填) 订单总金额,单位为元,不能超过1亿元
-    // 如果同时传入了【打折金额】,【不可打折金额】,【订单总金额】三者,则必须满足如下条件:【订单总金额】=【打折金额】+【不可打折金额】
-    private BigDecimal totalAmount;
-    // (可选) 订单不可打折金额,可以配合商家平台配置折扣活动,如果酒水不参与打折,则将对应金额填写至此字段
-    // 如果该值未传入,但传入了【订单总金额】,【打折金额】,则该值默认为【订单总金额】-【打折金额】
-    private BigDecimal undiscountableAmount;
-    // 卖家支付宝账号ID,用于支持一个签约账号下支持打款到不同的收款账号,(打款到sellerId对应的支付宝账号)
-    // 如果该字段为空,则默认为与支付宝签约的商户的PID,也就是appid对应的PID
-    private String sellerId;
-    // (必填) 商户门店编号,通过门店号和商家后台可以配置精准到门店的折扣信息,详询支付宝技术支持
-    private String storeId;
-    // 商户操作员编号,添加此参数可以为商户操作员做销售统计
-    private String operatorId;
-    // 支付超时,线下扫码交易定义为5分钟
-    private String timeoutExpress = "5m";
-    // 商品明细列表,需填写购买商品详细信息
-    private List<AlipayGoodsDetail> goodsDetailList;
-
-    public String getOutTradeNo() {
-        return outTradeNo;
-    }
-
-    public void setOutTradeNo(String outTradeNo) {
-        this.outTradeNo = outTradeNo;
-    }
-
-    public String getSubject() {
-        return subject;
-    }
-
-    public void setSubject(String subject) {
-        this.subject = subject;
-    }
-
-    public String getBody() {
-        return body;
-    }
-
-    public void setBody(String body) {
-        this.body = body;
-    }
-
-    public BigDecimal getTotalAmount() {
-        return totalAmount;
-    }
-
-    public void setTotalAmount(BigDecimal totalAmount) {
-        this.totalAmount = totalAmount;
-    }
-
-    public BigDecimal getUndiscountableAmount() {
-        return undiscountableAmount;
-    }
-
-    public void setUndiscountableAmount(BigDecimal undiscountableAmount) {
-        this.undiscountableAmount = undiscountableAmount;
-    }
-
-    public String getSellerId() {
-        return sellerId;
-    }
-
-    public void setSellerId(String sellerId) {
-        this.sellerId = sellerId;
-    }
-
-    public String getStoreId() {
-        return storeId;
-    }
-
-    public void setStoreId(String storeId) {
-        this.storeId = storeId;
-    }
-
-    public String getOperatorId() {
-        return operatorId;
-    }
-
-    public void setOperatorId(String operatorId) {
-        this.operatorId = operatorId;
-    }
-
-    public String getTimeoutExpress() {
-        return timeoutExpress;
-    }
-
-    public void setTimeoutExpress(String timeoutExpress) {
-        this.timeoutExpress = timeoutExpress;
-    }
-
-    public List<AlipayGoodsDetail> getGoodsDetailList() {
-        return goodsDetailList;
-    }
-
-    public void setGoodsDetailList(List<AlipayGoodsDetail> goodsDetailList) {
-        this.goodsDetailList = goodsDetailList;
-    }
-}

+ 0 - 14
src/main/java/com/fdkankan/ucenter/pay/factory/PayEntity.java

@@ -1,14 +0,0 @@
-package com.fdkankan.ucenter.pay.factory;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-
-public interface PayEntity {
-
-    JSONObject scanPay(PlaceOrderParam order) throws Exception;
-
-    JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception;
-
-    String getType();
-
-}

+ 0 - 39
src/main/java/com/fdkankan/ucenter/pay/factory/PayFactory.java

@@ -1,39 +0,0 @@
-package com.fdkankan.ucenter.pay.factory;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import com.fdkankan.ucenter.common.SpringUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Component
-@Slf4j
-public class PayFactory implements InitializingBean {
-
-    @Autowired
-    private SpringUtil applicationContextHelper;
-
-    private Map<String, PayEntity> payMap = new ConcurrentHashMap<>();
-
-    @Override
-    public void afterPropertiesSet() throws Exception {
-        Map<String, PayEntity> payHandles = applicationContextHelper.getBeansOfType(PayEntity.class);
-        for (Map.Entry<String, PayEntity> payHandle : payHandles.entrySet()) {
-            payMap.put(payHandle.getValue().getType(), payHandle.getValue());
-        }
-    }
-
-    public JSONObject scanPay(String type, PlaceOrderParam order) throws Exception {
-        log.warn("scanPay:" + type + "_" + order.getOrderType() + "----------payMap:" + payMap.get(type + "_" + order.getOrderType()));
-        return payMap.get(type + "_" + order.getOrderType()).scanPay(order);
-    }
-
-    public JSONObject h5Pay(String type, PlaceOrderParam order, String ipAddr) throws Exception {
-        return payMap.get(type + "_" + order.getOrderType()).h5Pay(order, ipAddr);
-    }
-}

+ 0 - 277
src/main/java/com/fdkankan/ucenter/pay/factory/impl/PayOrderService.java

@@ -1,277 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.alipay.api.AlipayApiException;
-import com.alipay.api.AlipayClient;
-import com.alipay.api.DefaultAlipayClient;
-import com.alipay.api.domain.AlipayTradeWapPayModel;
-import com.alipay.api.request.AlipayTradeWapPayRequest;
-import com.fdkankan.ucenter.common.constants.ConstantFilePath;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.common.util.MD5;
-import com.fdkankan.redis.util.RedisUtil;
-import com.fdkankan.ucenter.common.RedisKeyUtil;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.constant.QrCodeFilePath;
-import com.fdkankan.ucenter.pay.alipay.AlipayDefaultConfig;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayGoodsDetail;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayService;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayUtil;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipaymentEx;
-import com.fdkankan.ucenter.pay.paypal.sdk.PayPalmentEx;
-import com.fdkankan.ucenter.pay.paypal.sdk.PaypalService;
-import com.fdkankan.ucenter.pay.wx.WXPay;
-import com.fdkankan.ucenter.pay.wx.WXPayDefaultConfig;
-import com.fdkankan.ucenter.pay.wx.WXPayUtil;
-import com.paypal.api.payments.Links;
-import com.paypal.api.payments.Payment;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import javax.imageio.ImageIO;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.math.BigDecimal;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-@Service
-@Slf4j
-public class PayOrderService {
-
-    @Autowired
-    private AlipayService alipayService;
-    @Autowired
-    private AlipayDefaultConfig alipayDefaultConfig;
-    @Autowired
-    private PaypalService paypalService;
-
-    @Autowired
-    RedisUtil redisUtil;
-
-    public JSONObject aliPayScanPay(String orderSn, String subject, String body, BigDecimal totalFee, List<AlipayGoodsDetail> goodsDetailList) throws Exception{
-        AlipaymentEx alipaymentEx = new AlipaymentEx();
-        alipaymentEx.setOutTradeNo(orderSn);
-        alipaymentEx.setSubject(subject);
-        alipaymentEx.setBody(body);
-        alipaymentEx.setTotalAmount(totalFee);
-        alipaymentEx.setStoreId("test_store_id");
-        alipaymentEx.setOperatorId("test_operator_id");
-        alipaymentEx.setTimeoutExpress("120m");
-        alipaymentEx.setGoodsDetailList(goodsDetailList);
-        String pngPath = QrCodeFilePath.ALI_QRCODE_FOLDER + orderSn + ".png";
-        try {
-            Map<String, String> alipayMap = alipayService.tradePrecreate(alipaymentEx, NacosProperty.getMainUrl() + alipayDefaultConfig.getNotifyUrl());
-            if ("0".equals(alipayMap.get("code"))){
-                BufferedImage image = AlipayUtil.getQRCodeImge(alipayMap.get("qr_code"));
-                File file = new File(pngPath);
-                if(!file.getParentFile().exists()){
-                    file.mkdirs();
-                }
-                if (file.exists()){
-                    file.delete();
-                }
-                ImageIO.write(image, "png", file);
-            }else{
-                throw new BusinessException(ErrorCode.ERROR_MSG);
-            }
-        } catch (AlipayApiException e) {
-           log.error(e.getMessage());
-            throw new BusinessException(ErrorCode.ERROR_MSG);
-        }
-        redisUtil.set(RedisKeyUtil.QRCODE + orderSn,orderSn,5*60);
-        JSONObject j = new JSONObject();
-        j.put("src", pngPath.replace(ConstantFilePath.BASE_PATH, ""));
-        j.put("price", totalFee);
-
-        return j;
-    }
-
-    public JSONObject aliPayH5Pay(String orderSn, String subject, String body, BigDecimal totalFee) {
-        // 超时时间 可空
-        String timeoutExpress = "2m";
-        // 销售产品码 必填
-        String productCode = "QUICK_WAP_WAY";
-        /**********************/
-        // SDK 公共请求类,包含公共请求参数,以及封装了签名与验签,开发者无需关注签名与验签
-        //调用RSA签名方式,这个不用你管,只要你配置文件是正确的
-        AlipayClient client = new DefaultAlipayClient(alipayDefaultConfig.getGatewayUrl(),
-                alipayDefaultConfig.getAppid(), alipayDefaultConfig.getAppPrivateKey(), alipayDefaultConfig.getFormate(),
-                alipayDefaultConfig.getCharset(), alipayDefaultConfig.getAlipayPublicKey(), alipayDefaultConfig.getSignType());
-        AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();
-        // 封装请求支付信息
-        AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
-        //带!的都是你需要传递的参数 其他的是支付宝必须的
-        //!本地生成的订单编号
-        model.setOutTradeNo(orderSn);
-        //!商品名称
-        model.setSubject(subject);
-        //!商品价格
-        model.setTotalAmount(String.valueOf(totalFee));
-        //!商品介绍
-        model.setBody(body);
-        //超时时间
-        model.setTimeoutExpress(timeoutExpress);
-        //产品销售码
-        model.setProductCode(productCode);
-        //将参数传入到 BizModel中
-        alipayRequest.setBizModel(model);
-        //异步回调地址
-        alipayRequest.setNotifyUrl(NacosProperty.getMainUrl() + alipayDefaultConfig.getNotifyUrl());
-        //同步回调地址
-        alipayRequest.setReturnUrl(NacosProperty.getMainUrl() + alipayDefaultConfig.getReturnUrl());
-
-        String result = "";
-        try {
-            // 调用SDK生成表单
-            //get方式生成表单 主要解决在微信中对支付宝屏蔽问题,如果不是在微信中可post提交,将form的注释解开,result注释掉即可
-            result = client.pageExecute(alipayRequest, "get").getBody();
-            log.warn("支付宝调用SDK生成表单:" + result);
-            //form = client.pageExecute(alipay_request).getBody();
-//                System.out.println(form);
-        } catch (AlipayApiException e) {
-            e.printStackTrace();
-            log.error("生成表单失败!");
-        }
-        JSONObject j = new JSONObject();
-        j.put("form", result);
-        return j;
-    }
-
-    public JSONObject payPalPay(String orderSn, String subject, String body, BigDecimal totalFee, BigDecimal goodsFee, String successUrl, String cancelUrl) throws Exception {
-        PayPalmentEx payPalmentEx = new PayPalmentEx();
-        payPalmentEx.setOrderSn(orderSn);
-        payPalmentEx.setOrderTotal(totalFee);
-        payPalmentEx.setSubTotal(goodsFee);
-        payPalmentEx.setDescription(body);
-
-        Payment payment = paypalService.createPayment(payPalmentEx, successUrl, cancelUrl);
-        for(Links links : payment.getLinks()){
-            if(links.getRel().equals("approval_url")){
-                // 客户付款登陆地址
-                JSONObject j = new JSONObject();
-                j.put("redirect", links.getHref());
-                j.put("price", totalFee);
-                return j;
-            }
-        }
-        throw new BusinessException(ErrorCode.FAILURE_CODE_8002);
-    }
-
-    public JSONObject wechatScanPay(String orderSn, String subject, String body, BigDecimal totalFee) throws Exception {
-        WXPayDefaultConfig config = new WXPayDefaultConfig();
-        WXPay wxPay = new WXPay(config);
-
-        Map<String, String> data = new HashMap<String, String>();
-        data.put("body", body);
-        data.put("detail", subject);
-        data.put("out_trade_no", orderSn + "_" + new Random().nextInt(100));
-        data.put("device_info", "WEB");
-        data.put("fee_type", "CNY");
-        data.put("total_fee", totalFee.stripTrailingZeros().toPlainString());
-        data.put("spbill_create_ip", config.getCreateIP());
-        data.put("notify_url", NacosProperty.getMainUrl() + config.getNotifyURL());
-        data.put("trade_type", "NATIVE");  // 此处指定为扫码支付
-        data.put("product_id", orderSn); //多个商品,使用订单号
-
-        String pngPath = QrCodeFilePath.WEIXIN_QRCODE_FOLDER + orderSn + ".png";
-        try {
-            //发起支付
-            log.warn("wechatScanPay:{}",data);
-            Map<String, String> resp = wxPay.unifiedOrder(data);
-            BufferedImage image = AlipayUtil.getQRCodeImge(resp.get("code_url"));
-            File file = new File(pngPath);
-            if(!file.getParentFile().exists()){
-                file.mkdirs();
-            }
-            if (file.exists()){
-                file.delete();
-            }
-            ImageIO.write(image, "png", file);
-        } catch (Exception e) {
-            log.error(e.getMessage());
-            throw new BusinessException(ErrorCode.ERROR_MSG);
-        }
-        redisUtil.set(RedisKeyUtil.QRCODE + orderSn,orderSn,5*60);
-        JSONObject j = new JSONObject();
-        j.put("src", pngPath.replace(ConstantFilePath.BASE_PATH, ""));
-        j.put("price", totalFee.divide(new BigDecimal("100"), 2));
-        return j;
-    }
-
-    public JSONObject wechatH5Pay(String orderSn, String subject, String body, BigDecimal totalFee, String ipAddress) throws Exception {
-        log.warn("ipAddress:"+ipAddress);
-        WXPayDefaultConfig config = new WXPayDefaultConfig();
-        WXPay wxPay = new WXPay(config);
-
-        Map<String, String> data = new HashMap<String, String>();
-        data.put("body", subject);
-        data.put("detail", body);
-        data.put("out_trade_no", orderSn + "_" + new Random().nextInt(100));
-        data.put("device_info", "H5");
-        data.put("fee_type", "CNY");
-        data.put("total_fee", totalFee.stripTrailingZeros().toPlainString());
-        data.put("spbill_create_ip", ipAddress);
-        data.put("notify_url", NacosProperty.getMainUrl() + config.getNotifyURL());
-        data.put("trade_type", "MWEB");  // 此处指定为扫码支付
-        data.put("product_id", orderSn); //多个商品,使用订单号
-        data.put("nonce_str", MD5.getMessageDigest(String.valueOf(new Random().nextInt(10000)).getBytes()));
-
-        String mweb_url = "";
-        Map<String, String> resp = wxPay.unifiedOrder(data);
-        log.warn("wechatH5Pay" + resp);
-        String return_code = resp.get("return_code");
-        String return_msg = resp.get("return_msg");
-        if ("SUCCESS".equals(return_code) && "OK".equals(return_msg)) {
-            mweb_url = resp.get("mweb_url");//调微信支付接口地址
-            mweb_url += "&redirect_url=" + URLEncoder.encode(NacosProperty.getMainUrl() + config.getH5RedirectURL(), "UTF-8");
-            log.warn("mweb_url=" + mweb_url);
-        } else {
-            log.error("微信统一支付接口获取预支付订单出错");
-        }
-        JSONObject j = new JSONObject();
-        j.put("mweb_url", mweb_url);
-        return j;
-    }
-
-    public Map<String, String> wechatPay(String orderSn, String subject, String body, BigDecimal totalFee, String ipAddress, String openid) throws Exception {
-        WXPayDefaultConfig config = new WXPayDefaultConfig();
-        WXPay wxPay = new WXPay(config);
-
-        Map<String, String> data = new HashMap<String, String>();
-        data.put("body", subject);
-        data.put("detail", body);
-        data.put("out_trade_no", orderSn + "_" + new Random().nextInt(100));
-        data.put("device_info", "wechat");
-        data.put("fee_type", "CNY");
-        data.put("total_fee", totalFee.stripTrailingZeros().toPlainString());
-        data.put("spbill_create_ip", ipAddress);
-        data.put("notify_url", NacosProperty.getMainUrl() + config.getNotifyURL());
-        data.put("trade_type", "JSAPI");
-        data.put("product_id", orderSn);
-        data.put("openid", openid);
-
-        Map<String, String> resp = wxPay.unifiedOrder(data);
-        log.warn("wechatPay" + resp);
-
-        Map<String, String> sign = new HashMap<>();
-        sign.put("package", "prepay_id="+resp.get("prepay_id"));
-        sign.put("appId", config.getAppID());
-        sign.put("timeStamp",String.valueOf(System.currentTimeMillis() / 1000));
-        sign.put("nonceStr", resp.get("nonce_str"));
-        sign.put("signType", "MD5");
-        String paySign = WXPayUtil.generateSignature(sign, config.getKey());
-
-        resp.put("signType", "MD5");
-        resp.put("paySign", paySign);
-        log.warn("wechatPay" + resp);
-        return resp;
-    }
-
-}

+ 0 - 58
src/main/java/com/fdkankan/ucenter/pay/factory/impl/commerce/AlipayCommerce.java

@@ -1,58 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.commerce;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.CommerceOrder;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayGoodsDetail;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.ICommerceOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class AlipayCommerce implements PayEntity {
-
-    @Autowired
-    private ICommerceOrderService commerceOrderService;
-    @Autowired
-    private PayOrderService payOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        CommerceOrder commerce = commerceOrderService.getById(order.getOrderId());
-        if (commerce == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.COMMERCE_SUBJECT;
-        List<AlipayGoodsDetail> goodsDetailList = new ArrayList<>();
-        AlipayGoodsDetail goodsDetail = AlipayGoodsDetail.newInstance(commerce.getOrderSn(), subject, commerce.getAmount().intValue(), 1);
-        goodsDetailList.add(goodsDetail);
-        String orderSn = commerce.getOrderSn();
-        orderSn += "_commerce";
-        return payOrderService.aliPayScanPay(orderSn, subject, subject, commerce.getAmount(), goodsDetailList);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        CommerceOrder commerce = commerceOrderService.getById(order.getOrderId());
-        if (commerce == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.COMMERCE_SUBJECT;
-        String orderSn = commerce.getOrderSn();
-        orderSn += "_commerce";
-        return payOrderService.aliPayH5Pay(orderSn, subject, subject, commerce.getAmount());
-    }
-
-    @Override
-    public String getType() {
-        return "alipay_3";
-    }
-}

+ 0 - 56
src/main/java/com/fdkankan/ucenter/pay/factory/impl/commerce/PaypalCommerce.java

@@ -1,56 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.commerce;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.entity.CommerceOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.pay.paypal.PayPalDefaultConfig;
-import com.fdkankan.ucenter.service.ICommerceOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-@Component
-public class PaypalCommerce implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private ICommerceOrderService commerceOrderService;
-    @Autowired
-    private PayPalDefaultConfig payPalDefaultConfig;
-
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getPaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getCancelUrl());
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getH5PaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getH5CancelUrl());
-    }
-
-    private JSONObject getResult(PlaceOrderParam order, String successUrl, String cancelUrl) throws Exception {
-        CommerceOrder commerce = commerceOrderService.getById(order.getOrderId());
-        if (commerce == null) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.COMMERCE_SUBJECT;
-        String orderSn = commerce.getOrderSn();
-        orderSn += "_commerce";
-        return payOrderService.payPalPay(orderSn, subject, subject, commerce.getAmount(), commerce.getAmount(),
-                successUrl,
-                cancelUrl);
-    }
-
-    @Override
-    public String getType() {
-        return "paypal_3";
-    }
-}

+ 0 - 55
src/main/java/com/fdkankan/ucenter/pay/factory/impl/commerce/WechatCommerce.java

@@ -1,55 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.commerce;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.CommerceOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.ICommerceOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-
-@Component
-public class WechatCommerce implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private ICommerceOrderService commerceOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        CommerceOrder commerce = commerceOrderService.getById(order.getOrderId());
-        if (commerce == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.COMMERCE_SUBJECT;
-        BigDecimal totalFee = commerce.getAmount().multiply(new BigDecimal(100));
-        String orderSn = commerce.getOrderSn();
-        orderSn += "_commerce";
-        return payOrderService.wechatScanPay(orderSn, subject, subject, totalFee);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        CommerceOrder commerce = commerceOrderService.getById(order.getOrderId());
-        if (commerce == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.COMMERCE_SUBJECT;
-        BigDecimal totalFee = commerce.getAmount().multiply(new BigDecimal(100));
-        String orderSn = commerce.getOrderSn();
-        orderSn += "_commerce";
-        return payOrderService.wechatH5Pay(orderSn, subject, subject, totalFee, ip);
-    }
-
-    @Override
-    public String getType() {
-        return "wechat_3";
-    }
-}

+ 0 - 73
src/main/java/com/fdkankan/ucenter/pay/factory/impl/down/AlipayDownload.java

@@ -1,73 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.down;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.DownloadOrder;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayGoodsDetail;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IDownloadOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * 增值权益
- */
-@Component
-public class AlipayDownload implements PayEntity {
-
-    @Autowired
-    private IDownloadOrderService downloadOrderService;
-    @Autowired
-    private PayOrderService payOrderService;
-
-
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        DownloadOrder downloadOrderEntity = downloadOrderService.getById(order.getOrderId());
-        if (downloadOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(downloadOrderEntity.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String subject = Constant.DOWNLOAD_SUBJECT + ":" + downloadOrderEntity.getCount() + "次";
-        List<AlipayGoodsDetail> goodsDetailList = new ArrayList<>();
-        AlipayGoodsDetail goodsDetail = AlipayGoodsDetail.newInstance(downloadOrderEntity.getOrderSn(), subject, downloadOrderEntity.getAmount().intValue(), 1);
-        goodsDetailList.add(goodsDetail);
-        String orderSn = downloadOrderEntity.getOrderSn();
-        orderSn += "_download";
-        String body = subject;
-        return payOrderService.aliPayScanPay(orderSn, subject, body, downloadOrderEntity.getAmount(), goodsDetailList);    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        DownloadOrder downloadOrderEntity = downloadOrderService.getById(order.getOrderId());
-        if (downloadOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(downloadOrderEntity.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String subject = Constant.DOWNLOAD_SUBJECT + ":" + downloadOrderEntity.getCount() + "次";
-        String orderSn = downloadOrderEntity.getOrderSn();
-        orderSn += "_increment";
-        String body = subject;
-        return payOrderService.aliPayH5Pay(orderSn, subject, body, downloadOrderEntity.getAmount());    }
-
-
-    @Override
-    public String getType() {
-        return "alipay_5";
-    }
-}

+ 0 - 62
src/main/java/com/fdkankan/ucenter/pay/factory/impl/down/PaypalDownload.java

@@ -1,62 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.down;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.common.EnLang;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.entity.DownloadOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.pay.paypal.PayPalDefaultConfig;
-import com.fdkankan.ucenter.service.IDownloadOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-@Component
-public class PaypalDownload implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IDownloadOrderService downloadOrderService;
-    @Autowired
-    private PayPalDefaultConfig payPalDefaultConfig;
-
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getPaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getCancelUrl());
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getH5PaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getH5CancelUrl());
-    }
-
-    private JSONObject getResult(PlaceOrderParam order, String successUrl, String cancelUrl) throws Exception {
-        DownloadOrder downloadOrderEntity = downloadOrderService.getById(order.getOrderId());
-        if (downloadOrderEntity == null) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = EnLang.Scene_Download_en + ":" + downloadOrderEntity.getCount() + EnLang.next_en;
-        if("en".equals(order.getLang())){
-            subject = EnLang.Scene_Download_en + ":" + downloadOrderEntity.getCount() + EnLang.next_en;
-        }
-        if("zh".equals(order.getLang())){
-            subject = EnLang.Scene_Download_cn + ":" + downloadOrderEntity.getCount() + EnLang.next_cn;
-        }
-        String orderSn = downloadOrderEntity.getOrderSn();
-        orderSn += "_download";
-        String body = subject;
-        return payOrderService.payPalPay(orderSn, subject, body, downloadOrderEntity.getAmount(), downloadOrderEntity.getAmount(), successUrl, cancelUrl);
-    }
-
-    @Override
-    public String getType() {
-        return "paypal_5";
-    }
-}

+ 0 - 65
src/main/java/com/fdkankan/ucenter/pay/factory/impl/down/WechatDownload.java

@@ -1,65 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.down;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.DownloadOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IDownloadOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-
-@Component
-public class WechatDownload implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IDownloadOrderService downloadOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        DownloadOrder downloadOrderEntity = downloadOrderService.getById(order.getOrderId());
-        if (downloadOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(downloadOrderEntity.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String subject = Constant.DOWNLOAD_SUBJECT + ":" + downloadOrderEntity.getCount() + "次";
-        BigDecimal totalFee = downloadOrderEntity.getAmount().multiply(new BigDecimal(100));
-        String orderSn = downloadOrderEntity.getOrderSn();
-        String body = subject;
-        orderSn += "_download";
-        return payOrderService.wechatScanPay(orderSn, subject, body, totalFee);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        DownloadOrder downloadOrderEntity = downloadOrderService.getById(order.getOrderId());
-        if (downloadOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(downloadOrderEntity.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String subject = Constant.DOWNLOAD_SUBJECT + ":" + downloadOrderEntity.getCount() + "次";
-        BigDecimal totalFee = downloadOrderEntity.getAmount().multiply(new BigDecimal(100));
-        String orderSn = downloadOrderEntity.getOrderSn();
-        String body = subject;
-        orderSn += "_download";
-        return payOrderService.wechatH5Pay(orderSn, subject, body, totalFee, ip);
-    }
-
-    @Override
-    public String getType() {
-        return "wechat_5";
-    }
-}

+ 0 - 82
src/main/java/com/fdkankan/ucenter/pay/factory/impl/expansion/AlipayExpansion.java

@@ -1,82 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.expansion;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.ExpansionOrder;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayGoodsDetail;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IExpansionOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class AlipayExpansion implements PayEntity {
-
-    @Autowired
-    private IExpansionOrderService expansionOrderService;
-    @Autowired
-    private PayOrderService payOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        ExpansionOrder expansion = expansionOrderService.getById(order.getOrderId());
-        if (expansion == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(expansion.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String date = "1年";
-        if(expansion.getMonth() < 12){
-            date = expansion.getMonth() + "个月";
-        }
-        String subject = Constant.EXPANSION_SUBJECT + ":" + expansion.getUnitSize() + expansion.getUnit() + "/" + date;
-        List<AlipayGoodsDetail> goodsDetailList = new ArrayList<>();
-        AlipayGoodsDetail goodsDetail = AlipayGoodsDetail.newInstance(expansion.getOrderSn(), subject, expansion.getAmount().intValue(), 1);
-        goodsDetailList.add(goodsDetail);
-        String orderSn = expansion.getOrderSn();
-        orderSn += "_expansion";
-        String body = subject;
-        if(order.getSpaceId() != null){
-            body += "_" + order.getSpaceId();
-        }
-        return payOrderService.aliPayScanPay(orderSn, subject, body, expansion.getAmount(), goodsDetailList);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        ExpansionOrder expansion = expansionOrderService.getById(order.getOrderId());
-        if (expansion == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(expansion.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String date = "1年";
-        if(expansion.getMonth() < 12){
-            date = expansion.getMonth() + "个月";
-        }
-        String subject = Constant.EXPANSION_SUBJECT + ":" + expansion.getUnitSize() + expansion.getUnit() + "/" + date;
-        String orderSn = expansion.getOrderSn();
-        orderSn += "_expansion";
-        String body = subject;
-        if(order.getSpaceId() != null){
-            body += "_" + order.getSpaceId();
-        }
-        return payOrderService.aliPayH5Pay(orderSn, subject, body, expansion.getAmount());
-    }
-
-    @Override
-    public String getType() {
-        return "alipay_2";
-    }
-}

+ 0 - 64
src/main/java/com/fdkankan/ucenter/pay/factory/impl/expansion/PaypalExpansion.java

@@ -1,64 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.expansion;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.entity.ExpansionOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.pay.paypal.PayPalDefaultConfig;
-import com.fdkankan.ucenter.service.IExpansionOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-@Component
-public class PaypalExpansion implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IExpansionOrderService expansionOrderService;
-    @Autowired
-    private PayPalDefaultConfig payPalDefaultConfig;
-
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getPaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getCancelUrl());
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getH5PaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getH5CancelUrl());
-    }
-
-    private JSONObject getResult(PlaceOrderParam order, String successUrl, String cancelUrl) throws Exception {
-        ExpansionOrder expansion = expansionOrderService.getById(order.getOrderId());
-        if (expansion == null) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String date = "1年";
-        if(expansion.getMonth() < 12){
-            date = expansion.getMonth() + "个月";
-        }
-        String subject = Constant.EXPANSION_SUBJECT + ":" + expansion.getUnitSize() + expansion.getUnit() + "/" + date;
-        String orderSn = expansion.getOrderSn();
-        orderSn += "_expansion";
-        String body = subject;
-        if(order.getSpaceId() != null){
-            orderSn += "_" + order.getSpaceId();
-        }
-        return payOrderService.payPalPay(orderSn, subject, body, expansion.getAmount(), expansion.getAmount(),
-                successUrl,
-                cancelUrl);
-    }
-
-    @Override
-    public String getType() {
-        return "paypal_2";
-    }
-}

+ 0 - 81
src/main/java/com/fdkankan/ucenter/pay/factory/impl/expansion/WechatExpansion.java

@@ -1,81 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.expansion;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.ExpansionOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IExpansionOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-
-@Component
-public class WechatExpansion implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IExpansionOrderService expansionOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        ExpansionOrder expansion = expansionOrderService.getById(order.getOrderId());
-        if (expansion == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(expansion.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String date = "1年";
-        if(expansion.getMonth() < 12){
-            date = expansion.getMonth() + "个月";
-        }
-        String subject = Constant.EXPANSION_SUBJECT + ":" + expansion.getUnitSize() + expansion.getUnit() + "/" + date;
-        BigDecimal totalFee = expansion.getAmount().multiply(new BigDecimal(100));
-        String orderSn = expansion.getOrderSn();
-        String body = subject;
-        if(order.getSpaceId() != null){
-            orderSn += "_" + order.getSpaceId();
-        }else {
-            orderSn += "_expansion";
-        }
-        return payOrderService.wechatScanPay(orderSn, subject, body, totalFee);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        ExpansionOrder expansion = expansionOrderService.getById(order.getOrderId());
-        if (expansion == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(expansion.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String date = "1年";
-        if(expansion.getMonth() < 12){
-            date = expansion.getMonth() + "个月";
-        }
-        String subject = Constant.EXPANSION_SUBJECT + ":" + expansion.getUnitSize() + expansion.getUnit() + "/" + date;
-        BigDecimal totalFee = expansion.getAmount().multiply(new BigDecimal(100));
-        String orderSn = expansion.getOrderSn();
-        String body = subject;
-        if(order.getSpaceId() != null){
-            orderSn += "_" + order.getSpaceId();
-        }else {
-            orderSn += "_expansion";
-        }
-        return payOrderService.wechatH5Pay(orderSn, subject, body, totalFee, ip);
-    }
-
-    @Override
-    public String getType() {
-        return "wechat_2";
-    }
-}

+ 0 - 77
src/main/java/com/fdkankan/ucenter/pay/factory/impl/goods/AlipayGoods.java

@@ -1,77 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.goods;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.Order;
-import com.fdkankan.ucenter.entity.OrderItem;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayGoodsDetail;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IOrderItemService;
-import com.fdkankan.ucenter.service.IOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class AlipayGoods implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IOrderService orderService;
-    @Autowired
-    private IOrderItemService orderItemService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        Order responseOrder = orderService.getById(order.getOrderId());
-        if (responseOrder.getId() == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        List<AlipayGoodsDetail> goodsDetailList = new ArrayList<>();
-        List<OrderItem> items = orderItemService.getByOrderId(order.getOrderId());
-        StringBuilder sb = new StringBuilder();
-        AlipayGoodsDetail goodsDetail = null;
-        for (int i = 0; i < items.size(); i++){
-            sb.append(items.get(i).getGoodsCount()).append("*").append(items.get(i).getGoodsName());
-            if (i != items.size() - 1){
-                sb.append(",");
-            }
-
-            goodsDetail = AlipayGoodsDetail.newInstance(items.get(i).getGoodsSn(), items.get(i).getGoodsName(), items.get(i).getGoodsPrice().intValue(), items.get(i).getGoodsCount());
-            goodsDetailList.add(goodsDetail);
-        }
-        String orderSn = responseOrder.getOrderSn();
-        orderSn += "_entity";
-        return payOrderService.aliPayScanPay(orderSn, "四维看看官网-商品", sb.toString(), responseOrder.getTotalAmount(), goodsDetailList);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        Order responseOrder = orderService.getById(order.getOrderId());
-        if (responseOrder.getId() == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        List<OrderItem> items = orderItemService.getByOrderId(order.getOrderId());
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < items.size(); i++) {
-            sb.append(items.get(i).getGoodsCount()).append("*").append(items.get(i).getGoodsName());
-            if (i != items.size() - 1) {
-                sb.append(",");
-            }
-        }
-        String orderSn = responseOrder.getOrderSn();
-        orderSn += "_entity";
-        return payOrderService.aliPayH5Pay(orderSn, "四维看看官网-商品", sb.toString(),  responseOrder.getTotalAmount());
-    }
-
-    @Override
-    public String getType() {
-        return "alipay_0";
-    }
-}

+ 0 - 70
src/main/java/com/fdkankan/ucenter/pay/factory/impl/goods/PaypalGoods.java

@@ -1,70 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.goods;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.entity.Order;
-import com.fdkankan.ucenter.entity.OrderItem;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayGoodsDetail;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.pay.paypal.PayPalDefaultConfig;
-import com.fdkankan.ucenter.service.IOrderItemService;
-import com.fdkankan.ucenter.service.IOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class PaypalGoods implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IOrderService orderService;
-    @Autowired
-    private PayPalDefaultConfig payPalDefaultConfig;
-    @Autowired
-    private IOrderItemService orderItemService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getPaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getCancelUrl());
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getH5PaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getH5CancelUrl());
-    }
-
-    @Override
-    public String getType() {
-        return "paypal_0";
-    }
-
-    private JSONObject getResult(PlaceOrderParam order, String successUrl, String cancelUrl) throws Exception {
-        Order responseOrder = orderService.getById(order.getOrderId());
-        if (responseOrder.getId() == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        List<OrderItem> items = orderItemService.getByOrderId(order.getOrderId());
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < items.size(); i++) {
-            sb.append(items.get(i).getGoodsCount()).append("*").append(items.get(i).getGoodsName());
-            if (i != items.size() - 1) {
-                sb.append(",");
-            }
-        }
-        String orderSn = responseOrder.getOrderSn();
-        orderSn += "_entity";
-        return payOrderService.payPalPay(orderSn, sb.toString(), sb.toString(),
-                responseOrder.getTotalAmount(), responseOrder.getGoodsAmount(),
-                successUrl,
-                cancelUrl);
-    }
-}

+ 0 - 73
src/main/java/com/fdkankan/ucenter/pay/factory/impl/goods/WechatGoods.java

@@ -1,73 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.goods;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.Order;
-import com.fdkankan.ucenter.entity.OrderItem;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IOrderItemService;
-import com.fdkankan.ucenter.service.IOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-@Component
-public class WechatGoods implements PayEntity {
-
-    @Autowired
-    private IOrderService orderService;
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IOrderItemService orderItemService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        Order responseOrder = orderService.getById(order.getOrderId());
-        if (responseOrder.getId() == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        List<OrderItem> items = orderItemService.getByOrderId(order.getOrderId());
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < items.size(); i++){
-            sb.append(items.get(i).getGoodsCount()).append("*").append(items.get(i).getGoodsName());
-            if (i != items.size() - 1){
-                sb.append(",");
-            }
-        }
-        BigDecimal totalFee = responseOrder.getTotalAmount().multiply(new BigDecimal(100));
-        String orderSn = responseOrder.getOrderSn();
-        orderSn += "_entity";
-        return payOrderService.wechatScanPay(orderSn, "四维看看官网-商品", sb.toString(), totalFee);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        Order responseOrder = orderService.getById(order.getOrderId());
-        if (responseOrder.getId() == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        List<OrderItem> items = orderItemService.getByOrderId(order.getOrderId());
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < items.size(); i++){
-            sb.append(items.get(i).getGoodsCount()).append("*").append(items.get(i).getGoodsName());
-            if (i != items.size() - 1){
-                sb.append(",");
-            }
-        }
-        BigDecimal totalFee = responseOrder.getTotalAmount().multiply(new BigDecimal(100));
-        String orderSn = responseOrder.getOrderSn();
-        orderSn += "_entity";
-        return payOrderService.wechatH5Pay(orderSn, "四维看看官网-商品", sb.toString(), totalFee, ip);
-    }
-
-    @Override
-    public String getType() {
-        return "wechat_0";
-    }
-}

+ 0 - 72
src/main/java/com/fdkankan/ucenter/pay/factory/impl/increment/AlipayIncrement.java

@@ -1,72 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.increment;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.IncrementOrder;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayGoodsDetail;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IIncrementOrderService;
-import com.fdkankan.ucenter.service.IOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 增值权益
- */
-@Component
-public class AlipayIncrement implements PayEntity {
-
-    @Autowired
-    private IIncrementOrderService iIncrementOrderService;
-    @Autowired
-    private PayOrderService payOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        IncrementOrder incrementOrderEntity = iIncrementOrderService.getById(order.getOrderId());
-        if (incrementOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(incrementOrderEntity.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String subject = Constant.INCREMENT_SUBJECT + ":" + incrementOrderEntity.getCount() + "个/年";
-        List<AlipayGoodsDetail> goodsDetailList = new ArrayList<>();
-        AlipayGoodsDetail goodsDetail = AlipayGoodsDetail.newInstance(incrementOrderEntity.getOrderSn(), subject, incrementOrderEntity.getAmount().intValue(), 1);
-        goodsDetailList.add(goodsDetail);
-        String orderSn = incrementOrderEntity.getOrderSn();
-        orderSn += "_increment";
-        String body = subject;
-        return payOrderService.aliPayScanPay(orderSn, subject, body, incrementOrderEntity.getAmount(), goodsDetailList);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        IncrementOrder incrementOrderEntity = iIncrementOrderService.getById(order.getOrderId());
-        if (incrementOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(incrementOrderEntity.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String subject = Constant.INCREMENT_SUBJECT + ":" + incrementOrderEntity.getCount() + "个/年";
-        String orderSn = incrementOrderEntity.getOrderSn();
-        orderSn += "_increment";
-        String body = subject;
-        return payOrderService.aliPayH5Pay(orderSn, subject, body, incrementOrderEntity.getAmount());
-    }
-
-    @Override
-    public String getType() {
-        return "alipay_4";
-    }
-}

+ 0 - 86
src/main/java/com/fdkankan/ucenter/pay/factory/impl/increment/PaypalIncrement.java

@@ -1,86 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.increment;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.common.EnLang;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.entity.IncrementOrder;
-import com.fdkankan.ucenter.entity.IncrementType;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.pay.paypal.PayPalDefaultConfig;
-import com.fdkankan.ucenter.service.IIncrementOrderService;
-import com.fdkankan.ucenter.service.IIncrementTypeService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-@Component
-public class PaypalIncrement implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IIncrementOrderService incrementOrderService;
-    @Autowired
-    private PayPalDefaultConfig payPalDefaultConfig;
-    @Autowired
-    private IIncrementTypeService incrementTypeService;
-
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getPaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getCancelUrl());
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getH5PaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getH5CancelUrl());
-    }
-
-    private JSONObject getResult(PlaceOrderParam order, String successUrl, String cancelUrl) throws Exception {
-        IncrementOrder incrementOrderEntity = incrementOrderService.getById(order.getOrderId());
-        if (incrementOrderEntity == null) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = null;
-        if(incrementOrderEntity.getIncrementType()!=null){
-            IncrementType incrementType = incrementTypeService.getById(incrementOrderEntity.getIncrementType());
-            subject =  getSubject(incrementOrderEntity,incrementType,order.getLang());
-        }else {
-            subject =  EnLang.senior_en + ":" + incrementOrderEntity.getCount() +EnLang.month_en ;
-        }
-        String orderSn = incrementOrderEntity.getOrderSn();
-        orderSn += "_increment";
-        String body = subject;
-        return payOrderService.payPalPay(orderSn, subject, body, incrementOrderEntity.getAmount(), incrementOrderEntity.getAmount(),
-                successUrl,
-                cancelUrl);
-    }
-
-    private String getSubject(IncrementOrder order,IncrementType incrementType, String lang) {
-        if("en".equals(lang) && incrementType.getValidTimeType() == 0){
-            return EnLang.premium_en + ":" + order.getCount() +EnLang.year_en ;
-        }
-        if("en".equals(lang) && incrementType.getValidTimeType() == 1){
-            return EnLang.senior_en + ":" + order.getCount() +EnLang.month_en ;
-        }
-        if("zh".equals(lang) && incrementType.getValidTimeType() == 0){
-            return EnLang.premium_cn + ":" + order.getCount() +EnLang.year_cn ;
-        }
-        if("zh".equals(lang) && incrementType.getValidTimeType() == 1){
-            return EnLang.senior_cn + ":" + order.getCount() +EnLang.month_cn ;
-        }
-        return EnLang.senior_en + ":" + order.getCount() +EnLang.month_en ;
-    }
-
-
-    @Override
-    public String getType() {
-        return "paypal_4";
-    }
-}

+ 0 - 65
src/main/java/com/fdkankan/ucenter/pay/factory/impl/increment/WechatIncrement.java

@@ -1,65 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.increment;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.IncrementOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IIncrementOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-
-@Component
-public class WechatIncrement implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IIncrementOrderService incrementOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        IncrementOrder incrementOrderEntity = incrementOrderService.getById(order.getOrderId());
-        if (incrementOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(incrementOrderEntity.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String subject = Constant.INCREMENT_SUBJECT + ":" + incrementOrderEntity.getCount() + "个/年";
-        BigDecimal totalFee = incrementOrderEntity.getAmount().multiply(new BigDecimal(100));
-        String orderSn = incrementOrderEntity.getOrderSn();
-        String body = subject;
-        orderSn += "_increment";
-        return payOrderService.wechatScanPay(orderSn, subject, body, totalFee);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        IncrementOrder incrementOrderEntity = incrementOrderService.getById(order.getOrderId());
-        if (incrementOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        //订单金额为国外金额就报错
-        if(incrementOrderEntity.getAbroad() == 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8004);
-        }
-        String subject = Constant.INCREMENT_SUBJECT + ":" + incrementOrderEntity.getCount() + "个/年";
-        BigDecimal totalFee = incrementOrderEntity.getAmount().multiply(new BigDecimal(100));
-        String orderSn = incrementOrderEntity.getOrderSn();
-        String body = subject;
-        orderSn += "_increment";
-        return payOrderService.wechatH5Pay(orderSn, subject, body, totalFee, ip);
-    }
-
-    @Override
-    public String getType() {
-        return "wechat_4";
-    }
-}

+ 0 - 59
src/main/java/com/fdkankan/ucenter/pay/factory/impl/recharge/AlipayRecharge.java

@@ -1,59 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.recharge;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.VirtualOrder;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayGoodsDetail;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IVirtualOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class AlipayRecharge implements PayEntity {
-
-    @Autowired
-    private IVirtualOrderService virtualOrderService;
-    @Autowired
-    private PayOrderService payOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        VirtualOrder virtualOrderEntity = virtualOrderService.getById(order.getOrderId());
-        if (virtualOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.PAY_SUBJECT + ":" + virtualOrderEntity.getPoints();
-        List<AlipayGoodsDetail> goodsDetailList = new ArrayList<>();
-        AlipayGoodsDetail goodsDetail = AlipayGoodsDetail.newInstance(virtualOrderEntity.getOrderSn(), subject, new BigDecimal(virtualOrderEntity.getPoints()).intValue(), 1);
-        goodsDetailList.add(goodsDetail);
-        String orderSn = virtualOrderEntity.getOrderSn();
-        orderSn += "_recharge";
-        return payOrderService.aliPayScanPay(orderSn, subject, subject, new BigDecimal(virtualOrderEntity.getPoints()), goodsDetailList);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        VirtualOrder virtualOrderEntity = virtualOrderService.getById(order.getOrderId());
-        if (virtualOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.PAY_SUBJECT + ":" + virtualOrderEntity.getPoints();
-        String orderSn = virtualOrderEntity.getOrderSn();
-        orderSn += "_recharge";
-        return payOrderService.aliPayH5Pay(orderSn, subject, subject, new BigDecimal(virtualOrderEntity.getPoints()));
-    }
-
-    @Override
-    public String getType() {
-        return "alipay_1";
-    }
-}

+ 0 - 59
src/main/java/com/fdkankan/ucenter/pay/factory/impl/recharge/PaypalRecharge.java

@@ -1,59 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.recharge;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.entity.VirtualOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.pay.paypal.PayPalDefaultConfig;
-import com.fdkankan.ucenter.service.IVirtualOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-
-@Component
-public class PaypalRecharge implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IVirtualOrderService virtualOrderService;
-    @Autowired
-    private PayPalDefaultConfig payPalDefaultConfig;
-
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getPaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getCancelUrl());
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        return getResult(order, NacosProperty.getMainUrl() + payPalDefaultConfig.getH5PaySuccessUrl(), NacosProperty.getMainUrl() + payPalDefaultConfig.getH5CancelUrl());
-    }
-
-    private JSONObject getResult(PlaceOrderParam order, String successUrl, String cancelUrl) throws Exception {
-        VirtualOrder virtualOrderEntity = virtualOrderService.getById(order.getOrderId());
-        if (virtualOrderEntity == null) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.PAY_SUBJECT + ":" + virtualOrderEntity.getPoints();
-        String orderSn = virtualOrderEntity.getOrderSn();
-        orderSn += "_recharge";
-        return payOrderService.payPalPay(orderSn, subject, subject,
-                new BigDecimal(virtualOrderEntity.getPoints()), new BigDecimal(virtualOrderEntity.getPoints()),
-                successUrl,
-                cancelUrl);
-    }
-
-    @Override
-    public String getType() {
-        return "paypal_1";
-    }
-}

+ 0 - 55
src/main/java/com/fdkankan/ucenter/pay/factory/impl/recharge/WechatRecharge.java

@@ -1,55 +0,0 @@
-package com.fdkankan.ucenter.pay.factory.impl.recharge;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.Constant;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.ucenter.entity.VirtualOrder;
-import com.fdkankan.ucenter.pay.factory.PayEntity;
-import com.fdkankan.ucenter.pay.factory.impl.PayOrderService;
-import com.fdkankan.ucenter.service.IVirtualOrderService;
-import com.fdkankan.ucenter.vo.request.PlaceOrderParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-
-@Component
-public class WechatRecharge implements PayEntity {
-
-    @Autowired
-    private PayOrderService payOrderService;
-    @Autowired
-    private IVirtualOrderService virtualOrderService;
-
-    @Override
-    public JSONObject scanPay(PlaceOrderParam order) throws Exception {
-        VirtualOrder virtualOrderEntity = virtualOrderService.getById(order.getOrderId());
-        if (virtualOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.PAY_SUBJECT + ":" + virtualOrderEntity.getPoints();
-        BigDecimal totalFee = new BigDecimal(virtualOrderEntity.getPoints()).multiply(new BigDecimal(100));
-        String orderSn = virtualOrderEntity.getOrderSn();
-        orderSn += "_recharge";
-        return payOrderService.wechatScanPay(orderSn, subject, subject, totalFee);
-    }
-
-    @Override
-    public JSONObject h5Pay(PlaceOrderParam order, String ip) throws Exception {
-        VirtualOrder virtualOrderEntity = virtualOrderService.getById(order.getOrderId());
-        if (virtualOrderEntity == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_8001);
-        }
-        String subject = Constant.PAY_SUBJECT + ":" + virtualOrderEntity.getPoints();
-        BigDecimal totalFee = new BigDecimal(virtualOrderEntity.getPoints()).multiply(new BigDecimal(100));
-        String orderSn = virtualOrderEntity.getOrderSn();
-        orderSn += "_recharge";
-        return payOrderService.wechatH5Pay(orderSn, subject, subject, totalFee, ip);
-    }
-
-    @Override
-    public String getType() {
-        return "wechat_1";
-    }
-}

+ 0 - 56
src/main/java/com/fdkankan/ucenter/pay/paypal/PayPalDefaultConfig.java

@@ -1,56 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal;
-
-import com.fdkankan.ucenter.pay.paypal.sdk.PayPalConfig;
-import org.springframework.stereotype.Component;
-
-@Component
-public class PayPalDefaultConfig extends PayPalConfig {
-
-    @Override
-    public String getClientId() {
-        return "AZJEGWlvvI2q52bR4k_mC1ftW8tEnlaJj30huGQTBsdAjwmKlMDiEiMixVKbfrdw6fB55NSj_BAE8FPP";
-    }
-
-    @Override
-    public String getSecret() {
-        return "EL-RGNmsbFpcKT7QuIlxMxX7MQplp8rCyaGDZ5KOCMQ9BkOhY5OYZyVInAeHT8_4tXoPth8tOEZY_3s_";
-    }
-
-    @Override
-    public String getMode() {
-        return "live";
-    }
-
-    public String getPaySuccessUrl(){
-        return "api/order/pay/paypal/callback";
-    }
-
-    public String getH5PaySuccessUrl(){
-        return "api/order/pay/paypal/callbackH5";
-    }
-
-    public String getCancelUrl(){
-        return "api/order/pay/paypal/cancel";
-    }
-
-    public String getH5CancelUrl(){
-        return "api/order/pay/paypal/cancelH5";
-    }
-
-    public String getSuccessUrl(){
-        return "index.html#/payresult/success/recharge";
-    }
-
-    public String getFailUrl(){
-        return "#/payresult/fail/recharge";
-    }
-
-    public String getH5SuccessUrl(){
-        return "mobile.html#/payresult/success";
-    }
-
-    public String getH5FailUrl(){
-        return "mobile.html#/payresult/fail";
-    }
-
-}

+ 0 - 25
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/AutoPaypalVo.java

@@ -1,25 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-import lombok.Data;
-
-@Data
-public class AutoPaypalVo {
-    private String orderSn;
-    /**
-     * BILLING.SUBSCRIPTION.CANCELLED
-     * PAYMENT.SALE.COMPLETED
-     */
-    private String eventType;
-    /**
-     * Enum: "completed" "partially_refunded" "pending" "refunded" "denied"
-     */
-    private String state;
-
-    private String amount;
-
-    private String tradeNo;
-
-    private String subscriptionId;
-
-    private String subscriptionOrderSn;
-}

+ 0 - 43
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PayPalConfig.java

@@ -1,43 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-import com.paypal.base.rest.APIContext;
-import com.paypal.base.rest.OAuthTokenCredential;
-import com.paypal.base.rest.PayPalRESTException;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.annotation.Bean;
-import org.springframework.stereotype.Component;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@Slf4j
-@Component
-public abstract class PayPalConfig {
-
-    abstract public String getClientId();
-
-    abstract public String getSecret();
-
-    abstract public String getMode();
-
-    @Bean
-    public Map<String, String> paypalSdkConfig(){
-        Map<String, String> sdkConfig = new HashMap<>();
-        sdkConfig.put("mode", getMode());
-        return sdkConfig;
-    }
-
-    @Bean
-    public OAuthTokenCredential authTokenCredential(){
-        return new OAuthTokenCredential(getClientId(), getSecret(), paypalSdkConfig());
-    }
-
-    @Bean
-    public APIContext apiContext() throws PayPalRESTException {
-        String accessToken = authTokenCredential().getAccessToken();
-        log.info("paypal新的accessToken:" + accessToken);
-        APIContext apiContext = new APIContext(accessToken);
-        apiContext.setConfigurationMap(paypalSdkConfig());
-        return apiContext;
-    }
-}

+ 0 - 130
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PayPalmentEx.java

@@ -1,130 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.List;
-
-public class PayPalmentEx implements Serializable {
-
-    private static final long serialVersionUID = 5027458587257867876L;
-    /**
-     * 订单Id
-     */
-    private String orderSn;
-    /**
-     * 支付的总价
-     */
-    private BigDecimal orderTotal;
-    /**
-     * 商品总价
-     */
-    private BigDecimal subTotal;
-    /**
-     * 税费
-     */
-    private BigDecimal tax;
-    /**
-     * 描述
-     */
-    private String description;
-    /**
-     * 成功回调url
-     */
-    private String successUrl;
-    /**
-     * 支付失败url
-     */
-    private String failUrl;
-    /**
-     * 取消支付url
-     */
-    private String cancelUrl;
-    /**
-     * 收货地址
-     */
-    private PaypalOrderAddressEx paypayOrderAddressEx;
-    /**
-     * 订单商品明细
-     */
-    private List<PaypalOrderItemEx> paypalOrderItemExList;
-
-    public String getOrderSn() {
-        return orderSn;
-    }
-
-    public void setOrderSn(String orderSn) {
-        this.orderSn = orderSn;
-    }
-
-    public BigDecimal getOrderTotal() {
-        return orderTotal;
-    }
-
-    public void setOrderTotal(BigDecimal orderTotal) {
-        this.orderTotal = orderTotal;
-    }
-
-    public BigDecimal getSubTotal() {
-        return subTotal;
-    }
-
-    public void setSubTotal(BigDecimal subTotal) {
-        this.subTotal = subTotal;
-    }
-
-    public BigDecimal getTax() {
-        return tax;
-    }
-
-    public void setTax(BigDecimal tax) {
-        this.tax = tax;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public String getSuccessUrl() {
-        return successUrl;
-    }
-
-    public void setSuccessUrl(String successUrl) {
-        this.successUrl = successUrl;
-    }
-
-    public String getFailUrl() {
-        return failUrl;
-    }
-
-    public void setFailUrl(String failUrl) {
-        this.failUrl = failUrl;
-    }
-
-    public String getCancelUrl() {
-        return cancelUrl;
-    }
-
-    public void setCancelUrl(String cancelUrl) {
-        this.cancelUrl = cancelUrl;
-    }
-
-    public PaypalOrderAddressEx getPaypayOrderAddressEx() {
-        return paypayOrderAddressEx;
-    }
-
-    public void setPaypayOrderAddressEx(PaypalOrderAddressEx paypayOrderAddressEx) {
-        this.paypayOrderAddressEx = paypayOrderAddressEx;
-    }
-
-    public List<PaypalOrderItemEx> getPaypalOrderItemExList() {
-        return paypalOrderItemExList;
-    }
-
-    public void setPaypalOrderItemExList(List<PaypalOrderItemEx> paypalOrderItemExList) {
-        this.paypalOrderItemExList = paypalOrderItemExList;
-    }
-}

+ 0 - 88
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalOrderAddressEx.java

@@ -1,88 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-import java.io.Serializable;
-
-public class PaypalOrderAddressEx implements Serializable {
-
-    private static final long serialVersionUID = 5667747195118555705L;
-
-    private String firstName;
-
-    private String lastName;
-
-    private String countryCode;
-
-    private String state;
-
-    private String city;
-
-    private String address;
-
-    private String phone;
-
-    private String postalCode;
-
-    public String getFirstName() {
-        return firstName;
-    }
-
-    public void setFirstName(String firstName) {
-        this.firstName = firstName;
-    }
-
-    public String getLastName() {
-        return lastName;
-    }
-
-    public void setLastName(String lastName) {
-        this.lastName = lastName;
-    }
-
-    public String getCountryCode() {
-        return countryCode;
-    }
-
-    public void setCountryCode(String countryCode) {
-        this.countryCode = countryCode;
-    }
-
-    public String getState() {
-        return state;
-    }
-
-    public void setState(String state) {
-        this.state = state;
-    }
-
-    public String getCity() {
-        return city;
-    }
-
-    public void setCity(String city) {
-        this.city = city;
-    }
-
-    public String getAddress() {
-        return address;
-    }
-
-    public void setAddress(String address) {
-        this.address = address;
-    }
-
-    public String getPhone() {
-        return phone;
-    }
-
-    public void setPhone(String phone) {
-        this.phone = phone;
-    }
-
-    public String getPostalCode() {
-        return postalCode;
-    }
-
-    public void setPostalCode(String postalCode) {
-        this.postalCode = postalCode;
-    }
-}

+ 0 - 59
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalOrderItemEx.java

@@ -1,59 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-public class PaypalOrderItemEx implements Serializable {
-
-    private static final long serialVersionUID = 7764234386178614511L;
-
-    private String sku;
-
-    private String name;
-
-    private BigDecimal price;
-
-    private int quantity;
-
-    private String currency;
-
-    public String getSku() {
-        return sku;
-    }
-
-    public void setSku(String sku) {
-        this.sku = sku;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public BigDecimal getPrice() {
-        return price;
-    }
-
-    public void setPrice(BigDecimal price) {
-        this.price = price;
-    }
-
-    public int getQuantity() {
-        return quantity;
-    }
-
-    public void setQuantity(int quantity) {
-        this.quantity = quantity;
-    }
-
-    public String getCurrency() {
-        return currency;
-    }
-
-    public void setCurrency(String currency) {
-        this.currency = currency;
-    }
-}

+ 0 - 5
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalPaymentIntent.java

@@ -1,5 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-public enum PaypalPaymentIntent {
-	sale, authorize, order
-}

+ 0 - 5
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalPaymentMethod.java

@@ -1,5 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-public enum PaypalPaymentMethod {
-	credit_card, paypal
-}

+ 0 - 267
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/PaypalService.java

@@ -1,267 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.ucenter.pay.paypal.PayPalDefaultConfig;
-import com.paypal.api.payments.*;
-import com.paypal.base.codec.binary.Base64;
-import com.paypal.base.rest.APIContext;
-import com.paypal.base.rest.PayPalRESTException;
-import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-@Log4j2
-@Service
-public class PaypalService {
-
-    @Autowired
-    private APIContext apiContext;
-    @Autowired
-    private PayPalDefaultConfig config;
-
-    private static final String CURRENCY = "USD";
-
-    /**
-     * 创建支付
-     *
-     * @param paymentEx
-     * @return
-     * @throws PayPalRESTException
-     */
-    @Transactional(rollbackFor = Exception.class)
-    public Payment createPayment(PayPalmentEx paymentEx, String successUrl, String cancelUrl) throws PayPalRESTException {
-        if (StringUtils.isEmpty(successUrl) || StringUtils.isEmpty(cancelUrl)) {
-            throw new PayPalRESTException("缺少url");
-        }
-        Transaction transaction = new Transaction();
-        transaction.setDescription(paymentEx.getDescription());
-        // 将我们的订单ID保存到支付信息中,用于后面支付回传
-        if (null != paymentEx.getOrderSn()) {
-            transaction.setCustom(paymentEx.getOrderSn());
-        }
-        //订单价格
-        Amount amount = new Amount();
-        amount.setCurrency(CURRENCY);
-        // 支付的总价,paypal会校验 total = subTotal + tax + ...
-        amount.setTotal(paymentEx.getOrderTotal().toString());
-        // 设置各种费用
-        Details details = new Details();
-        // 商品总价
-        if (paymentEx.getSubTotal() != null) {
-            details.setSubtotal(paymentEx.getSubTotal().toString());
-        }
-        // 税费
-        if (paymentEx.getTax() != null) {
-            details.setTax(paymentEx.getTax().toString());
-        }
-
-        amount.setDetails(details);
-
-        transaction.setAmount(amount);
-
-        ItemList itemList = new ItemList();
-        // 收货地址
-        PaypalOrderAddressEx orderAddress = paymentEx.getPaypayOrderAddressEx();
-        if (orderAddress != null) {
-            ShippingAddress shippingAddress = new ShippingAddress();
-            if (StringUtils.isNotEmpty(orderAddress.getFirstName()) && StringUtils.isNotEmpty(orderAddress.getLastName())) {
-                shippingAddress.setRecipientName(orderAddress.getFirstName() + "." + orderAddress.getLastName());
-            }
-            shippingAddress.setCountryCode(orderAddress.getCountryCode());
-            shippingAddress.setState(orderAddress.getState());
-            shippingAddress.setCity(orderAddress.getCity());
-            shippingAddress.setLine1(orderAddress.getAddress());
-            shippingAddress.setPhone(orderAddress.getPhone());
-            shippingAddress.setPostalCode(orderAddress.getPostalCode());
-
-            itemList.setShippingAddress(shippingAddress);
-            itemList.setShippingPhoneNumber(orderAddress.getPhone());
-        }
-
-        // 商品明细
-        List<PaypalOrderItemEx> orderItemList = paymentEx.getPaypalOrderItemExList();
-        if (orderItemList != null && orderItemList.size() > 0) {
-            List<Item> items = new ArrayList<>();
-            for (PaypalOrderItemEx orderItemEx : orderItemList) {
-                Item item = new Item();
-                item.setSku(orderItemEx.getSku());
-                item.setName(orderItemEx.getName());
-                item.setPrice(orderItemEx.getPrice().toString());
-                item.setQuantity(String.valueOf(orderItemEx.getQuantity()));
-                item.setCurrency(CURRENCY);
-                items.add(item);
-            }
-            itemList.setItems(items);
-            transaction.setItemList(itemList);
-        }
-
-        List<Transaction> transactions = new ArrayList<>();
-        transactions.add(transaction);
-
-        // 支付信息
-        Payer payer = new Payer();
-        payer.setPaymentMethod(PaypalPaymentMethod.paypal.toString());
-
-        Payment payment = new Payment();
-        //刷新accessToken时间;
-        apiContext = new APIContext("Bearer " + getAccessToken());
-        apiContext.setConfigurationMap(config.paypalSdkConfig());
-
-        payment.setIntent(PaypalPaymentIntent.sale.toString());
-        payment.setPayer(payer);
-        payment.setTransactions(transactions);
-
-        //回调地址
-        RedirectUrls redirectUrls = new RedirectUrls();
-        redirectUrls.setReturnUrl(successUrl);
-        redirectUrls.setCancelUrl(cancelUrl);
-        payment.setRedirectUrls(redirectUrls);
-
-        return payment.create(apiContext);
-    }
-
-    /**
-     * 执行支付
-     *
-     * @param paymentId
-     * @param payerId
-     * @return
-     * @throws PayPalRESTException
-     */
-    public Payment executePayment(String paymentId, String payerId) throws PayPalRESTException {
-        Payment payment = new Payment();
-        payment.setId(paymentId);
-        PaymentExecution paymentExecute = new PaymentExecution();
-        paymentExecute.setPayerId(payerId);
-        apiContext = new APIContext("Bearer " + getAccessToken());
-        apiContext.setConfigurationMap(config.paypalSdkConfig());
-        return payment.execute(apiContext, paymentExecute);
-    }
-
-    /**
-      * 获取token
-      * 了解更多:https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
-      * @return
-      */
-    private String getAccessToken() {
-        BufferedReader reader = null;
-        try {
-            URL url = new URL(UrlUtils.TOKEN_URL);
-            String authorization = config.getClientId() + ":" + config.getSecret();
-            authorization = Base64.encodeBase64String(authorization.getBytes());
-
-            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-            conn.setRequestMethod("POST");// 提交模式
-            //设置请求头header
-            conn.setRequestProperty("Accept", "application/json");
-            conn.setRequestProperty("Accept-Language", "en_US");
-            conn.setRequestProperty("Authorization", "Basic " + authorization);
-            // conn.setConnectTimeout(10000);//连接超时 单位毫秒
-            // conn.setReadTimeout(2000);//读取超时 单位毫秒
-            conn.setDoOutput(true);// 是否输入参数
-            String params = "grant_type=client_credentials";
-            conn.getOutputStream().write(params.getBytes());// 输入参数
-
-            InputStreamReader inStream = new InputStreamReader(conn.getInputStream());
-            reader = new BufferedReader(inStream);
-            StringBuilder result = new StringBuilder();
-            String lineTxt = null;
-            while ((lineTxt = reader.readLine()) != null) {
-                result.append(lineTxt);
-            }
-            reader.close();
-            String accessTokey = JSONObject.parseObject(result.toString()).getString("access_token");
-            log.info("getAccessToken:" + accessTokey);
-            return accessTokey;
-        } catch (Exception err) {
-            err.printStackTrace();
-        } finally {
-            if (reader != null){
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return null;
-    }
-
-    public String getPaymentDetails(String paymentId) {
-        BufferedReader reader = null;
-        try {
-            URL url = new URL(UrlUtils.PAYMENT_DETAIL + paymentId);
-            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-            conn.setRequestMethod("GET");// 提交模式
-            //设置请求头header
-            conn.setRequestProperty("Accept", "application/json");
-            conn.setRequestProperty("Authorization", "Bearer " + getAccessToken());
-            // conn.setConnectTimeout(10000);//连接超时 单位毫秒
-            // conn.setReadTimeout(2000);//读取超时 单位毫秒
-            InputStreamReader inStream = new InputStreamReader(conn.getInputStream());
-            reader = new BufferedReader(inStream);
-            StringBuilder result = new StringBuilder();
-            String lineTxt = null;
-            while ((lineTxt = reader.readLine()) != null) {
-                result.append(lineTxt);
-            }
-            reader.close();
-            return result.toString();
-        } catch (Exception err) {
-            err.printStackTrace();
-        }finally {
-            if (reader != null){
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return null;
-    }
-
-    public boolean verifyPayment(String paymentId){
-        //从PayPal获取付款详情
-        String str = getPaymentDetails(paymentId);
-        JSONObject detail = JSONObject.parseObject(str);
-        //校验订单是否完成
-        if("approved".equals(detail.getString("state"))){
-            JSONObject transactions = detail.getJSONArray("transactions").getJSONObject(0);
-            JSONObject amount = transactions.getJSONObject("amount");
-            JSONArray relatedResources = transactions.getJSONArray("related_resources");
-            //从数据库查询总金额与Paypal校验支付总金额
-            double total = 0;
-            if( total != amount.getDouble("total") ){
-                return false;
-            }
-            //校验交易货币类型
-            String currency = "USD";
-            if( !currency.equals(amount.getString("currency")) ){
-                return false;
-            }
-            //校验每个子订单是否完成
-            for (int i = 0,j = relatedResources.size(); i < j; i++) {
-                JSONObject sale = relatedResources.getJSONObject(i).getJSONObject("sale");
-                if( !"completed".equals(sale.getString("state")) ){
-                    System.out.println("子订单未完成,订单状态:"+sale.getString("state"));
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-
-
-}

+ 0 - 66
src/main/java/com/fdkankan/ucenter/pay/paypal/sdk/UrlUtils.java

@@ -1,66 +0,0 @@
-package com.fdkankan.ucenter.pay.paypal.sdk;
-
-import javax.servlet.http.HttpServletRequest;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class UrlUtils {
-
-    //沙箱链接
-//    public static final String TOKEN_URL = "https://api.sandbox.paypal.com/v1/oauth2/token";
-    public static final String TOKEN_URL = "https://api.paypal.com/v1/oauth2/token";
-    public static final String PAYMENT_DETAIL = "https://api.sandbox.paypal.com/v1/payments/payment/";
-
-    public static String getBaseURl(HttpServletRequest request) {
-        String scheme = request.getScheme();
-        String serverName = request.getServerName();
-        int serverPort = request.getServerPort();
-        String contextPath = request.getContextPath();
-        StringBuffer url =  new StringBuffer();
-        url.append(scheme).append("://").append(serverName);
-        if ((serverPort != 80) && (serverPort != 443)) {
-            url.append(":").append(serverPort);
-        }
-        url.append(contextPath);
-        if(url.toString().endsWith("/")){
-            url.append("/");
-        }
-        return url.toString();
-    }
-
-    /**
-     * 获取用户实际ip
-     * @param request
-     * @return
-     */
-    public static String getIpAddr(HttpServletRequest request){
-        String ipAddress = request.getHeader("x-forwarded-for");
-        if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-            ipAddress = request.getHeader("Proxy-Client-IP");
-        }
-        if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-            ipAddress = request.getHeader("WL-Proxy-Client-IP");
-        }
-        if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-            ipAddress = request.getRemoteAddr();
-            if(ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")){
-                //根据网卡取本机配置的IP
-                InetAddress inet=null;
-                try {
-                    inet = InetAddress.getLocalHost();
-                } catch (UnknownHostException e) {
-                    e.printStackTrace();
-                }
-                ipAddress= inet.getHostAddress();
-            }
-        }
-        //对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
-        if(ipAddress!=null && ipAddress.length()>15){ //"***.***.***.***".length() = 15
-            if(ipAddress.indexOf(",")>0){
-                ipAddress = ipAddress.substring(0,ipAddress.indexOf(","));
-            }
-        }
-        return ipAddress;
-    }
-
-}

+ 0 - 12
src/main/java/com/fdkankan/ucenter/pay/strategy/OrderItemStrategy.java

@@ -1,12 +0,0 @@
-package com.fdkankan.ucenter.pay.strategy;
-
-
-import com.fdkankan.ucenter.entity.OrderItem;
-import com.fdkankan.ucenter.vo.response.OrderItemVo;
-
-public interface OrderItemStrategy {
-
-    public void handleOrderItem(Long userId, OrderItemVo orderItem) throws Exception;
-
-    public String getType();
-}

+ 0 - 9
src/main/java/com/fdkankan/ucenter/pay/strategy/OrderStrategy.java

@@ -1,9 +0,0 @@
-package com.fdkankan.ucenter.pay.strategy;
-
-public interface OrderStrategy {
-
-    public void handleOrder(String orderSn, String tradeNo, String openId, int paymentTypeName, Long spaceId) throws Exception;
-
-    public String getType();
-
-}

+ 0 - 67
src/main/java/com/fdkankan/ucenter/pay/strategy/OrderStrategyFactory.java

@@ -1,67 +0,0 @@
-package com.fdkankan.ucenter.pay.strategy;
-
-import com.fdkankan.ucenter.vo.response.OrderItemVo;
-import com.fdkankan.ucenter.common.SpringUtil;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Log4j2
-@Component
-public class OrderStrategyFactory implements InitializingBean {
-
-    @Autowired
-    private SpringUtil applicationContextHelper;
-
-    private Map<String, OrderStrategy> orderHandleMap = new ConcurrentHashMap<>();
-
-    private Map<String, OrderItemStrategy> orderItemHandleMap = new ConcurrentHashMap<>();
-
-    @Override
-    public void afterPropertiesSet() throws Exception {
-        Map<String, OrderItemStrategy> orderItemHandles = applicationContextHelper.getBeansOfType(OrderItemStrategy.class);
-        for (Map.Entry<String, OrderItemStrategy> orderHandle : orderItemHandles.entrySet()) {
-
-            String type = orderHandle.getValue().getType();
-            String[] types = type.split(",");
-            if (types.length > 1){
-                for (String str : types){
-                    orderItemHandleMap
-                            .put(str, orderHandle.getValue());
-                }
-            }
-            else{
-                orderItemHandleMap
-                        .put(orderHandle.getValue().getType(), orderHandle.getValue());
-            }
-        }
-
-
-        Map<String, OrderStrategy> orderHandles = applicationContextHelper.getBeansOfType(OrderStrategy.class);
-        for (Map.Entry<String, OrderStrategy> orderHandle : orderHandles.entrySet()) {
-            orderHandleMap.put(orderHandle.getValue().getType(), orderHandle.getValue());
-        }
-    }
-
-    public void doHandler(Long userId, OrderItemVo t) throws Exception{
-        log.warn("sku:"+t.getSkuSn());
-        orderItemHandleMap.get(t.getSkuSn()).handleOrderItem(userId, t);
-    }
-    public void doHandler(String orderSn, String tradeNo, String openId, String type, int paymentTypeName) throws Exception{
-        Long spaceId = null;
-        log.info("进入doHandler");
-        if(orderSn.split("_").length == 2){
-            spaceId = Long.valueOf(orderSn.split("_")[1]);
-            orderSn = orderSn.split("_")[0];
-        }
-        if(type.matches("^-?[0-9]+")){
-            type = "expansion";
-        }
-        log.info("type:" + type);
-        log.info("orderSn:" + orderSn);
-        orderHandleMap.get(type).handleOrder(orderSn, tradeNo, openId, paymentTypeName, spaceId);
-    }
-}

+ 0 - 58
src/main/java/com/fdkankan/ucenter/pay/strategy/impl/DownloadOrderImpl.java

@@ -1,58 +0,0 @@
-package com.fdkankan.ucenter.pay.strategy.impl;
-
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fdkankan.ucenter.common.constants.NacosProperty;
-import com.fdkankan.ucenter.entity.*;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategy;
-import com.fdkankan.ucenter.service.*;
-import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Log4j2
-@Component
-public class DownloadOrderImpl implements OrderStrategy {
-    @Autowired
-    private IDownloadOrderService downloadOrderService;
-    @Autowired
-    private IUserService userService;
-    @Autowired
-    private ISceneProService sceneProService;
-    @Autowired
-    ICameraTypeService cameraTypeService;
-    @Override
-    public void handleOrder(String orderSn, String tradeNo, String openId, int paymentTypeName, Long spaceId) throws Exception {
-        DownloadOrder downloadOrder = downloadOrderService.getByOrderSnNoPay(orderSn);
-        if (downloadOrder == null) {
-            log.error("找不到订单:" + orderSn);
-            throw new Exception("找不到订单,out_trade_no错误");
-        }
-        // 更新场景下载订单
-        boolean result = downloadOrderService.paySuccessDownloadOrder(orderSn, tradeNo, paymentTypeName);
-        if (!result){
-            log.error("更新增值权益订单失败");
-            throw new Exception("更新增值权益订单失败");
-        }
-        //更新用户下载次数
-        LambdaUpdateWrapper<User> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(User::getId,downloadOrder.getUserId());
-        if(StringUtils.isNotBlank(downloadOrder.getSceneNum())){
-            CameraType cameraType = cameraTypeService.getByNum(downloadOrder.getSceneNum());
-            if(!"aws".equals(NacosProperty.uploadType) && cameraType!= null && cameraType.getIsLaser() == 1){    //深时场景
-                wrapper.setSql("ss_download_num_total = ss_download_num_total + " + downloadOrder.getCount());
-            }else {
-                wrapper.setSql("download_num_total = download_num_total + " + downloadOrder.getCount());
-            }
-        }else {
-            wrapper.setSql("download_num_total = download_num_total + " + downloadOrder.getCount());
-        }
-        userService.update(wrapper);
-    }
-
-    @Override
-    public String getType() {
-        return "download";
-    }
-}

+ 0 - 55
src/main/java/com/fdkankan/ucenter/pay/strategy/impl/EntityOrderImpl.java

@@ -1,55 +0,0 @@
-package com.fdkankan.ucenter.pay.strategy.impl;
-
-import com.fdkankan.ucenter.entity.Order;
-import com.fdkankan.ucenter.entity.OrderItem;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategy;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategyFactory;
-import com.fdkankan.ucenter.service.IOrderItemService;
-import com.fdkankan.ucenter.service.IOrderService;
-import com.fdkankan.ucenter.vo.response.OrderItemVo;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-@Log4j2
-@Component
-public class EntityOrderImpl implements OrderStrategy {
-    @Autowired
-    private IOrderService orderService;
-    @Autowired
-    private OrderStrategyFactory orderStrategyFactory;
-    @Autowired
-    private IOrderItemService orderItemService;
-
-    @Override
-    public void handleOrder(String orderSn, String tradeNo, String openId, int paymentTypeName, Long spaceId) throws Exception {
-        log.warn("购物支付处理....");
-        Order orderEntity = orderService.getByOrderSnNoPay(orderSn);
-        if (orderEntity == null) {
-            log.error("找不到订单:" + orderSn);
-            throw new Exception("找不到订单,out_trade_no错误");
-        }
-        boolean result = orderService.paySuccessEntityOrder(orderSn, tradeNo, paymentTypeName);
-        if (!result){
-            log.error("更新订单失败");
-            throw new Exception("更新订单失败");
-        }
-
-        List<OrderItem> byOrderId = orderItemService.getByOrderId(orderEntity.getId());
-        for (OrderItem orderItem : byOrderId){
-            OrderItemVo orderItemVo = new OrderItemVo();
-            BeanUtils.copyProperties(orderItem,orderItemVo);
-            orderItemVo.setOpenid(openId);
-            log.warn("orderStrategyFactory:"+orderStrategyFactory);
-            orderStrategyFactory.doHandler(orderEntity.getUserId(), orderItemVo);
-        }
-    }
-
-    @Override
-    public String getType() {
-        return "entity";
-    }
-}

+ 0 - 77
src/main/java/com/fdkankan/ucenter/pay/strategy/impl/ExpansionOrderImpl.java

@@ -1,77 +0,0 @@
-package com.fdkankan.ucenter.pay.strategy.impl;
-
-import com.fdkankan.ucenter.entity.CameraDetail;
-import com.fdkankan.ucenter.entity.CameraSpace;
-import com.fdkankan.ucenter.entity.ExpansionOrder;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategy;
-import com.fdkankan.ucenter.service.ICameraDetailService;
-import com.fdkankan.ucenter.service.ICameraSpaceService;
-import com.fdkankan.ucenter.service.IExpansionOrderService;
-import com.fdkankan.ucenter.service.ISceneProService;
-import lombok.extern.log4j.Log4j2;
-import org.joda.time.DateTime;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Log4j2
-@Component
-public class ExpansionOrderImpl implements OrderStrategy {
-    @Autowired
-    private IExpansionOrderService expansionOrderService;
-    @Autowired
-    private ICameraSpaceService cameraSpaceService;
-    @Autowired
-    private ICameraDetailService cameraDetailService;
-    @Autowired
-    private ISceneProService sceneProService;
-
-    @Override
-    public void handleOrder(String orderSn, String tradeNo, String openId, int paymentTypeName, Long spaceId) throws Exception {
-        ExpansionOrder expansionOrder = expansionOrderService.getByOrderSnNoPay(orderSn);
-        if (expansionOrder == null) {
-            log.error("找不到订单:" + orderSn);
-            throw new Exception("找不到订单,out_trade_no错误");
-        }
-        //1表示充值,0表示系统赠送,2表示升级套餐
-        int status = 1;
-        if(spaceId == null){
-            status = 2;
-        }
-        // 更新扩容订单
-        boolean result = expansionOrderService.paySuccessExpansionOrder(orderSn, tradeNo, paymentTypeName, status);
-        if (!result){
-            log.error("更新扩容订单失败");
-            throw new Exception("更新扩容订单失败");
-        }
-
-        CameraSpace cameraSpaceEntity = new CameraSpace();
-        if(spaceId == null){
-            //新的容量套餐方案
-            cameraSpaceService.removeByCameraId(expansionOrder.getCameraId());
-            cameraSpaceEntity = cameraSpaceService.saveByExpansionOrder(expansionOrder);
-            CameraDetail detailEntity = cameraDetailService.getByCameraId(expansionOrder.getCameraId());
-            detailEntity.setTotalSpace(cameraSpaceEntity.getSpace());
-            cameraDetailService.updateById(detailEntity);
-            sceneProService.lockOrUnLockBySpace(detailEntity,detailEntity.getCameraId() );
-        }else {
-            cameraSpaceEntity = cameraSpaceService.getById(spaceId);
-            DateTime date = null;
-            if(expansionOrder.getMonth() == 12){
-                date = new DateTime(cameraSpaceEntity.getSpaceEndTime()).plusYears(1);
-                if(cameraSpaceEntity.getSpaceEndTime().getYear() % 4 == 0){
-                    date.plusDays(1);
-                }
-            }else {
-                date = new DateTime(cameraSpaceEntity.getSpaceEndTime()).plusDays(expansionOrder.getMonth() * 31);
-            }
-            cameraSpaceEntity.setSpaceEndTime(date.toDate());
-            cameraSpaceEntity.setOrderSn(cameraSpaceEntity.getOrderSn() + "," + orderSn);
-            cameraSpaceService.updateById(cameraSpaceEntity);
-        }
-    }
-
-    @Override
-    public String getType() {
-        return "expansion";
-    }
-}

+ 0 - 129
src/main/java/com/fdkankan/ucenter/pay/strategy/impl/IncrementOrderImpl.java

@@ -1,129 +0,0 @@
-package com.fdkankan.ucenter.pay.strategy.impl;
-
-import com.fdkankan.ucenter.entity.*;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategy;
-import com.fdkankan.ucenter.service.*;
-import com.fdkankan.ucenter.util.DateUserUtil;
-import lombok.extern.log4j.Log4j2;
-import org.joda.time.DateTime;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.UUID;
-
-@Log4j2
-@Component
-public class IncrementOrderImpl implements OrderStrategy {
-    @Autowired
-    private IIncrementOrderService incrementOrderService;
-    @Autowired
-    private IUserIncrementService userIncrementService;
-    @Autowired
-    private IUserService userService;
-    @Autowired
-    ISceneProService sceneProService;
-    @Autowired
-    ICameraDetailService cameraDetailService;
-    @Autowired
-    IIncrementTypeService incrementTypeService;
-    @Autowired
-    IAgentNewLogService agentNewLogService;
-    @Autowired
-    IIncrementAutoOrderService incrementAutoOrderService;
-
-    @Override
-    public void handleOrder(String orderSn, String tradeNo, String openId, int paymentTypeName, Long incrementId) throws Exception {
-
-        IncrementOrder responseIncrementOrder = incrementOrderService.getByOrderSnNoPay(orderSn);
-        if (responseIncrementOrder == null) {
-            log.error("找不到订单:" + orderSn);
-            throw new Exception("找不到订单,out_trade_no错误");
-        }
-        IncrementAutoOrder incrementAutoOrder = null;
-        if(responseIncrementOrder.getAutoOrderId() != null){
-            incrementAutoOrder = incrementAutoOrderService.getById(responseIncrementOrder.getAutoOrderId());
-            if(incrementAutoOrder != null && incrementAutoOrder.getUserIncrementId() !=null){
-                responseIncrementOrder.setIncrementId(incrementAutoOrder.getUserIncrementId());
-            }
-        }
-        // 更新增值权益订单
-        boolean result = incrementOrderService.paySuccessIncrementOrder(orderSn, tradeNo, paymentTypeName);
-        if (!result){
-            log.error("更新增值权益订单失败");
-            throw new Exception("更新增值权益订单失败");
-        }
-        UserIncrement userIncrementEntity = null;
-        IncrementType incrementType = incrementTypeService.getById(responseIncrementOrder.getIncrementType());
-        if(incrementType == null){
-            throw new Exception("更新增值权益订单失败");
-        }
-        Integer expired = 0;
-        Date date =  new Date();
-        if(responseIncrementOrder.getIncrementId() == null){
-            //新的增值权益套餐方案
-            date = DateUserUtil.getDateTime(new Date(),incrementType,responseIncrementOrder.getMonthQy()).toDate();
-
-            if(responseIncrementOrder.getCount() > 0){
-                for(int i = 0, len = responseIncrementOrder.getCount(); i < len; i++){
-                    userIncrementEntity = new UserIncrement();
-                    userIncrementEntity.setKeyWord(UUID.randomUUID().toString().replace("-", ""));
-                    userIncrementEntity.setUserId(responseIncrementOrder.getUserId());
-                    userIncrementEntity.setOrderSn(orderSn);
-                    userIncrementEntity.setIncrementStartTime(DateUserUtil.getDate(new Date()));
-                    userIncrementEntity.setIncrementEndTime(DateUserUtil.getDate(date));
-                    userIncrementEntity.setIsExpired(expired);
-                    userIncrementEntity.setIncrementTypeId(responseIncrementOrder.getIncrementType());
-                    userIncrementEntity.setMemberLevels(responseIncrementOrder.getMemberLevels());
-                    if(incrementAutoOrder!= null){
-                        userIncrementEntity.setSubscriptionOrder(incrementAutoOrder.getSubscriptionId());
-                    }
-                    userIncrementService.save(userIncrementEntity);
-                    incrementAutoOrderService.setIncrementId(incrementAutoOrder,userIncrementEntity.getId());
-                }
-            }
-        }else {
-            userIncrementEntity = userIncrementService.getById(responseIncrementOrder.getIncrementId());
-            date = DateUserUtil.getDateTime(DateUserUtil.getDate(userIncrementEntity.getIncrementEndTime()),incrementType,responseIncrementOrder.getMonthQy()).toDate();
-
-            userIncrementEntity.setIncrementEndTime(DateUserUtil.getDate(date));
-            userIncrementEntity.setOrderSn(userIncrementEntity.getOrderSn() + "," + orderSn);
-            userIncrementEntity.setUpdateTime(DateUserUtil.getDate(new Date()));
-            userIncrementEntity.setIsExpired(expired);
-            if(incrementAutoOrder!= null){
-                userIncrementEntity.setSubscriptionOrder(incrementAutoOrder.getSubscriptionId());
-            }
-            userIncrementService.updateById(userIncrementEntity);
-
-            if(userIncrementEntity.getAgentId() != null){
-                agentNewLogService.addByUserIncrement(userIncrementEntity);
-            }
-
-            //解封所有场景
-            if(userIncrementEntity.getUserId() != null && userIncrementEntity.getCameraId() != null){
-                CameraDetail cameraDetail = cameraDetailService.getByCameraId(userIncrementEntity.getCameraId());
-                sceneProService.lockOrUnLockBySpace(cameraDetail, userIncrementEntity.getCameraId());
-            }
-        }
-
-        //增加用户下载次数
-        if(userIncrementEntity != null && userIncrementEntity.getUserId()!=null){
-            User userEntity = userService.getById(userIncrementEntity.getUserId());
-            if(userEntity != null && incrementType.getDownloadNum() >0){
-                userEntity.setDownloadNumTotal(userEntity.getDownloadNumTotal() + (responseIncrementOrder.getMonthQy() == null?1:responseIncrementOrder.getMonthQy()) * responseIncrementOrder.getCount() * incrementType.getDownloadNum() );
-                userService.updateById(userEntity);
-            }
-        }
-    }
-
-
-    @Override
-    public String getType() {
-        return "increment";
-    }
-
-
-
-}

+ 0 - 47
src/main/java/com/fdkankan/ucenter/pay/strategy/impl/RechargeOrderImpl.java

@@ -1,47 +0,0 @@
-package com.fdkankan.ucenter.pay.strategy.impl;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fdkankan.ucenter.entity.VirtualOrder;
-import com.fdkankan.ucenter.pay.strategy.OrderStrategy;
-import com.fdkankan.ucenter.service.ICameraDetailService;
-import com.fdkankan.ucenter.service.IVirtualOrderService;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Log4j2
-@Component
-public class RechargeOrderImpl implements OrderStrategy {
-    @Autowired
-    private IVirtualOrderService virtualOrderService;
-    @Autowired
-    private ICameraDetailService cameraDetailService;
-    @Autowired
-    private ObjectMapper mapper;
-
-    @Override
-    public void handleOrder(String orderSn, String tradeNo, String openId, int paymentTypeName, Long spaceId) throws Exception {
-        VirtualOrder responseVirtualOrder = virtualOrderService.getByOrderSnNoPay(orderSn);
-        if (responseVirtualOrder == null) {
-            log.error("找不到订单:" + orderSn);
-            throw new Exception("找不到订单,out_trade_no错误");
-        }
-
-        // 更新充值订单
-        boolean result = cameraDetailService.updateCameraBalance(responseVirtualOrder.getCameraId(), 0, responseVirtualOrder.getPoints());
-        if (!result){
-            log.error("更新相机余额错误");
-            throw new Exception("更新相机余额错误");
-        }
-        boolean result2 = virtualOrderService.paySuccessVirtualOrder(orderSn, tradeNo, paymentTypeName);
-        if (!result2){
-            log.error("更新充值订单失败");
-            throw new Exception("更新充值订单失败");
-        }
-    }
-
-    @Override
-    public String getType() {
-        return "recharge";
-    }
-}

+ 0 - 673
src/main/java/com/fdkankan/ucenter/pay/wx/WXPay.java

@@ -1,673 +0,0 @@
-package com.fdkankan.ucenter.pay.wx;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.security.KeyStore;
-import java.security.SecureRandom;
-import java.util.HashMap;
-import java.util.Map;
-
-public class WXPay {
-
-    private WXPayConfig config;
-    private WXPayConstants.SignType signType;
-    private boolean useSandbox;
-
-    public WXPay(final WXPayConfig config) {
-        this(config, WXPayConstants.SignType.MD5, false);
-    }
-
-    public WXPay(final WXPayConfig config, final WXPayConstants.SignType signType) {
-        this(config, signType, false);
-    }
-
-    public WXPay(final WXPayConfig config, final WXPayConstants.SignType signType, final boolean useSandbox) {
-        this.config = config;
-        this.signType = signType;
-        this.useSandbox = useSandbox;
-    }
-
-
-    /**
-     * 向 Map 中添加 appid、mch_id、nonce_str、sign_type、sign <br>
-     * 该函数适用于商户适用于统一下单等接口,不适用于红包、代金券接口
-     *
-     * @param reqData
-     * @return
-     * @throws Exception
-     */
-    public Map<String, String> fillRequestData(Map<String, String> reqData) throws Exception {
-        reqData.put("appid", config.getAppID());
-        reqData.put("mch_id", config.getMchID());
-        reqData.put("nonce_str", WXPayUtil.generateNonceStr());
-        if (WXPayConstants.SignType.MD5.equals(this.signType)) {
-            reqData.put("sign_type", WXPayConstants.MD5);
-        }
-        else if (WXPayConstants.SignType.HMACSHA256.equals(this.signType)) {
-            reqData.put("sign_type", WXPayConstants.HMACSHA256);
-        }
-        reqData.put("sign", WXPayUtil.generateSignature(reqData, config.getKey(), this.signType));
-        return reqData;
-    }
-
-    /**
-     * 判断xml数据的sign是否有效,必须包含sign字段,否则返回false。
-     *
-     * @param reqData 向wxpay post的请求数据
-     * @return 签名是否有效
-     * @throws Exception
-     */
-    public boolean isResponseSignatureValid(Map<String, String> reqData) throws Exception {
-        // 返回数据的签名方式和请求中给定的签名方式是一致的
-        return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), this.signType);
-    }
-
-    /**
-     * 判断支付结果通知中的sign是否有效
-     *
-     * @param reqData 向wxpay post的请求数据
-     * @return 签名是否有效
-     * @throws Exception
-     */
-    public boolean isPayResultNotifySignatureValid(Map<String, String> reqData) throws Exception {
-        String signTypeInData = reqData.get(WXPayConstants.FIELD_SIGN_TYPE);
-        WXPayConstants.SignType signType;
-        if (signTypeInData == null) {
-            signType = WXPayConstants.SignType.MD5;
-        }
-        else {
-            signTypeInData = signTypeInData.trim();
-            if (signTypeInData.length() == 0) {
-                signType = WXPayConstants.SignType.MD5;
-            }
-            else if (WXPayConstants.MD5.equals(signTypeInData)) {
-                signType = WXPayConstants.SignType.MD5;
-            }
-            else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
-                signType = WXPayConstants.SignType.HMACSHA256;
-            }
-            else {
-                throw new Exception(String.format("Unsupported sign_type: %s", signTypeInData));
-            }
-        }
-        return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), signType);
-    }
-
-
-    /**
-     * 不需要证书的请求
-     * @param strUrl String
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 超时时间,单位是毫秒
-     * @param readTimeoutMs 超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public String requestWithoutCert(String strUrl, Map<String, String> reqData,
-                                     int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String UTF8 = "UTF-8";
-        String reqBody = WXPayUtil.mapToXml(reqData);
-        URL httpUrl = new URL(strUrl);
-        HttpURLConnection httpURLConnection = (HttpURLConnection) httpUrl.openConnection();
-        httpURLConnection.setDoOutput(true);
-        httpURLConnection.setRequestMethod("POST");
-        httpURLConnection.setConnectTimeout(connectTimeoutMs);
-        httpURLConnection.setReadTimeout(readTimeoutMs);
-        httpURLConnection.connect();
-        OutputStream outputStream = httpURLConnection.getOutputStream();
-        outputStream.write(reqBody.getBytes(UTF8));
-
-        // if (httpURLConnection.getResponseCode()!= 200) {
-        //     throw new Exception(String.format("HTTP response code is %d, not 200", httpURLConnection.getResponseCode()));
-        // }
-
-        //获取内容
-        InputStream inputStream = httpURLConnection.getInputStream();
-        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, UTF8));
-        final StringBuffer stringBuffer = new StringBuffer();
-        String line = null;
-        while ((line = bufferedReader.readLine()) != null) {
-            stringBuffer.append(line).append("\n");
-        }
-        String resp = stringBuffer.toString();
-        if (stringBuffer!=null) {
-            try {
-                bufferedReader.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        if (inputStream!=null) {
-            try {
-                inputStream.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        if (outputStream!=null) {
-            try {
-                outputStream.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        // if (httpURLConnection!=null) {
-        //     httpURLConnection.disconnect();
-        // }
-
-        return resp;
-    }
-
-
-    /**
-     * 需要证书的请求
-     * @param strUrl String
-     * @param reqData 向wxpay post的请求数据  Map
-     * @param connectTimeoutMs 超时时间,单位是毫秒
-     * @param readTimeoutMs 超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public String requestWithCert(String strUrl, Map<String, String> reqData,
-                                  int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String UTF8 = "UTF-8";
-        String reqBody = WXPayUtil.mapToXml(reqData);
-        URL httpUrl = new URL(strUrl);
-        char[] password = config.getMchID().toCharArray();
-        InputStream certStream = config.getCertStream();
-        KeyStore ks = KeyStore.getInstance("PKCS12");
-        ks.load(certStream, password);
-
-        // 实例化密钥库 & 初始化密钥工厂
-        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
-        kmf.init(ks, password);
-
-        // 创建SSLContext
-        SSLContext sslContext = SSLContext.getInstance("TLS");
-        sslContext.init(kmf.getKeyManagers(), null, new SecureRandom());
-        HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
-
-        HttpURLConnection httpURLConnection = (HttpURLConnection) httpUrl.openConnection();
-
-        httpURLConnection.setDoOutput(true);
-        httpURLConnection.setRequestMethod("POST");
-        httpURLConnection.setConnectTimeout(connectTimeoutMs);
-        httpURLConnection.setReadTimeout(readTimeoutMs);
-        httpURLConnection.connect();
-        OutputStream outputStream = httpURLConnection.getOutputStream();
-        outputStream.write(reqBody.getBytes(UTF8));
-
-        // if (httpURLConnection.getResponseCode()!= 200) {
-        //     throw new Exception(String.format("HTTP response code is %d, not 200", httpURLConnection.getResponseCode()));
-        // }
-
-        //获取内容
-        InputStream inputStream = httpURLConnection.getInputStream();
-        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, UTF8));
-        final StringBuffer stringBuffer = new StringBuffer();
-        String line = null;
-        while ((line = bufferedReader.readLine()) != null) {
-            stringBuffer.append(line);
-        }
-        String resp = stringBuffer.toString();
-        if (stringBuffer!=null) {
-            try {
-                bufferedReader.close();
-            } catch (IOException e) {
-                // e.printStackTrace();
-            }
-        }
-        if (inputStream!=null) {
-            try {
-                inputStream.close();
-            } catch (IOException e) {
-                // e.printStackTrace();
-            }
-        }
-        if (outputStream!=null) {
-            try {
-                outputStream.close();
-            } catch (IOException e) {
-                // e.printStackTrace();
-            }
-        }
-        if (certStream!=null) {
-            try {
-                certStream.close();
-            } catch (IOException e) {
-                // e.printStackTrace();
-            }
-        }
-        // if (httpURLConnection!=null) {
-        //     httpURLConnection.disconnect();
-        // }
-
-        return resp;
-    }
-
-    /**
-     * 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
-     * @param xmlStr API返回的XML格式数据
-     * @return Map类型数据
-     * @throws Exception
-     */
-    public Map<String, String> processResponseXml(String xmlStr) throws Exception {
-        String RETURN_CODE = "return_code";
-        String return_code;
-        Map<String, String> respData = WXPayUtil.xmlToMap(xmlStr);
-        if (respData.containsKey(RETURN_CODE)) {
-            return_code = respData.get(RETURN_CODE);
-        }
-        else {
-            throw new Exception(String.format("No `return_code` in XML: %s", xmlStr));
-        }
-
-        if (return_code.equals(WXPayConstants.FAIL)) {
-            return respData;
-        }
-        else if (return_code.equals(WXPayConstants.SUCCESS)) {
-           if (this.isResponseSignatureValid(respData)) {
-               return respData;
-           }
-           else {
-               throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
-           }
-        }
-        else {
-            throw new Exception(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr));
-        }
-    }
-
-    /**
-     * 作用:提交刷卡支付<br>
-     * 场景:刷卡支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> microPay(Map<String, String> reqData) throws Exception {
-        return this.microPay(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:提交刷卡支付<br>
-     * 场景:刷卡支付
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> microPay(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_MICROPAY_URL;
-        }
-        else {
-            url = WXPayConstants.MICROPAY_URL;
-        }
-        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-    /**
-     * 作用:统一下单<br>
-     * 场景:公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> unifiedOrder(Map<String, String> reqData) throws Exception {
-        return this.unifiedOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:统一下单<br>
-     * 场景:公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> unifiedOrder(Map<String, String> reqData,  int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_UNIFIEDORDER_URL;
-        }
-        else {
-            url = WXPayConstants.UNIFIEDORDER_URL;
-        }
-        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-    /**
-     * 作用:查询订单<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> orderQuery(Map<String, String> reqData) throws Exception {
-        return this.orderQuery(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:查询订单<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据 int
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> orderQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_ORDERQUERY_URL;
-        }
-        else {
-            url = WXPayConstants.ORDERQUERY_URL;
-        }
-        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-    /**
-     * 作用:撤销订单<br>
-     * 场景:刷卡支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> reverse(Map<String, String> reqData) throws Exception {
-        return this.reverse(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:撤销订单<br>
-     * 场景:刷卡支付<br>
-     * 其他:需要证书
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> reverse(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_REVERSE_URL;
-        }
-        else {
-            url = WXPayConstants.REVERSE_URL;
-        }
-        String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-    /**
-     * 作用:关闭订单<br>
-     * 场景:公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> closeOrder(Map<String, String> reqData) throws Exception {
-        return this.closeOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:关闭订单<br>
-     * 场景:公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> closeOrder(Map<String, String> reqData,  int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_CLOSEORDER_URL;
-        }
-        else {
-            url = WXPayConstants.CLOSEORDER_URL;
-        }
-        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-    /**
-     * 作用:申请退款<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> refund(Map<String, String> reqData) throws Exception {
-        return this.refund(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:申请退款<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付<br>
-     * 其他:需要证书
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> refund(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_REFUND_URL;
-        }
-        else {
-            url = WXPayConstants.REFUND_URL;
-        }
-        String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-    /**
-     * 作用:退款查询<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> refundQuery(Map<String, String> reqData) throws Exception {
-        return this.refundQuery(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:退款查询<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> refundQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_REFUNDQUERY_URL;
-        }
-        else {
-            url = WXPayConstants.REFUNDQUERY_URL;
-        }
-        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-    /**
-     * 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> downloadBill(Map<String, String> reqData) throws Exception {
-        return this.downloadBill(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:对账单下载<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付<br>
-     * 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data,
-     *      其中return_code为`SUCCESS`,data为对账单数据。
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return 经过封装的API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> downloadBill(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_DOWNLOADBILL_URL;
-        }
-        else {
-            url = WXPayConstants.DOWNLOADBILL_URL;
-        }
-        String respStr = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs).trim();
-        Map<String, String> ret;
-        // 出现错误,返回XML数据
-        if (respStr.indexOf("<") == 0) {
-            ret = WXPayUtil.xmlToMap(respStr);
-        }
-        else {
-            // 正常返回csv数据
-            ret = new HashMap<String, String>();
-            ret.put("return_code", WXPayConstants.SUCCESS);
-            ret.put("return_msg", "sdk");
-            ret.put("data", respStr);
-        }
-        return ret;
-    }
-
-
-    /**
-     * 作用:交易保障<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> report(Map<String, String> reqData) throws Exception {
-        return this.report(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:交易保障<br>
-     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> report(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_REPORT_URL;
-        }
-        else {
-            url = WXPayConstants.REPORT_URL;
-        }
-        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return WXPayUtil.xmlToMap(respXml);
-    }
-
-
-    /**
-     * 作用:转换短链接<br>
-     * 场景:刷卡支付、扫码支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> shortUrl(Map<String, String> reqData) throws Exception {
-        return this.shortUrl(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:转换短链接<br>
-     * 场景:刷卡支付、扫码支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> shortUrl(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_SHORTURL_URL;
-        }
-        else {
-            url = WXPayConstants.SHORTURL_URL;
-        }
-        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-    /**
-     * 作用:授权码查询OPENID接口<br>
-     * 场景:刷卡支付
-     * @param reqData 向wxpay post的请求数据
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> authCodeToOpenid(Map<String, String> reqData) throws Exception {
-        return this.authCodeToOpenid(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
-    }
-
-
-    /**
-     * 作用:授权码查询OPENID接口<br>
-     * 场景:刷卡支付
-     * @param reqData 向wxpay post的请求数据
-     * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
-     * @return API返回数据
-     * @throws Exception
-     */
-    public Map<String, String> authCodeToOpenid(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String url;
-        if (this.useSandbox) {
-            url = WXPayConstants.SANDBOX_AUTHCODETOOPENID_URL;
-        }
-        else {
-            url = WXPayConstants.AUTHCODETOOPENID_URL;
-        }
-        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
-        return this.processResponseXml(respXml);
-    }
-
-
-} // end class

+ 0 - 53
src/main/java/com/fdkankan/ucenter/pay/wx/WXPayConfig.java

@@ -1,53 +0,0 @@
-package com.fdkankan.ucenter.pay.wx;
-
-import java.io.InputStream;
-
-public interface WXPayConfig {
-
-
-    /**
-     * 获取 App ID
-     *
-     * @return App ID
-     */
-    public String getAppID();
-
-
-    /**
-     * 获取 Mch ID
-     *
-     * @return Mch ID
-     */
-    public String getMchID();
-
-
-    /**
-     * 获取 API 密钥
-     *
-     * @return API密钥
-     */
-    public String getKey();
-
-
-    /**
-     * 获取商户证书内容
-     *
-     * @return 商户证书内容
-     */
-    public InputStream getCertStream();
-
-    /**
-     * HTTP(S) 连接超时时间,单位毫秒
-     *
-     * @return
-     */
-    public int getHttpConnectTimeoutMs();
-
-    /**
-     * HTTP(S) 读数据超时时间,单位毫秒
-     *
-     * @return
-     */
-    public int getHttpReadTimeoutMs();
-
-}

+ 0 - 45
src/main/java/com/fdkankan/ucenter/pay/wx/WXPayConstants.java

@@ -1,45 +0,0 @@
-package com.fdkankan.ucenter.pay.wx;
-
-/**
- * 常量
- */
-public class WXPayConstants {
-
-    public enum SignType {
-        MD5, HMACSHA256
-    }
-
-    public static final String FAIL     = "FAIL";
-    public static final String SUCCESS  = "SUCCESS";
-    public static final String HMACSHA256 = "HMAC-SHA256";
-    public static final String MD5 = "MD5";
-
-    public static final String FIELD_SIGN = "sign";
-    public static final String FIELD_SIGN_TYPE = "sign_type";
-
-    public static final String MICROPAY_URL     = "https://api.mch.weixin.qq.com/pay/micropay";
-    public static final String UNIFIEDORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
-    public static final String ORDERQUERY_URL   = "https://api.mch.weixin.qq.com/pay/orderquery";
-    public static final String REVERSE_URL      = "https://api.mch.weixin.qq.com/secapi/pay/reverse";
-    public static final String CLOSEORDER_URL   = "https://api.mch.weixin.qq.com/pay/closeorder";
-    public static final String REFUND_URL       = "https://api.mch.weixin.qq.com/secapi/pay/refund";
-    public static final String REFUNDQUERY_URL  = "https://api.mch.weixin.qq.com/pay/refundquery";
-    public static final String DOWNLOADBILL_URL = "https://api.mch.weixin.qq.com/pay/downloadbill";
-    public static final String REPORT_URL       = "https://api.mch.weixin.qq.com/payitil/report";
-    public static final String SHORTURL_URL     = "https://api.mch.weixin.qq.com/tools/shorturl";
-    public static final String AUTHCODETOOPENID_URL = "https://api.mch.weixin.qq.com/tools/authcodetoopenid";
-
-    // sandbox
-    public static final String SANDBOX_MICROPAY_URL     = "https://api.mch.weixin.qq.com/sandboxnew/pay/micropay";
-    public static final String SANDBOX_UNIFIEDORDER_URL = "https://api.mch.weixin.qq.com/sandboxnew/pay/unifiedorder";
-    public static final String SANDBOX_ORDERQUERY_URL   = "https://api.mch.weixin.qq.com/sandboxnew/pay/orderquery";
-    public static final String SANDBOX_REVERSE_URL      = "https://api.mch.weixin.qq.com/sandboxnew/secapi/pay/reverse";
-    public static final String SANDBOX_CLOSEORDER_URL   = "https://api.mch.weixin.qq.com/sandboxnew/pay/closeorder";
-    public static final String SANDBOX_REFUND_URL       = "https://api.mch.weixin.qq.com/sandboxnew/secapi/pay/refund";
-    public static final String SANDBOX_REFUNDQUERY_URL  = "https://api.mch.weixin.qq.com/sandboxnew/pay/refundquery";
-    public static final String SANDBOX_DOWNLOADBILL_URL = "https://api.mch.weixin.qq.com/sandboxnew/pay/downloadbill";
-    public static final String SANDBOX_REPORT_URL       = "https://api.mch.weixin.qq.com/sandboxnew/payitil/report";
-    public static final String SANDBOX_SHORTURL_URL     = "https://api.mch.weixin.qq.com/sandboxnew/tools/shorturl";
-    public static final String SANDBOX_AUTHCODETOOPENID_URL = "https://api.mch.weixin.qq.com/sandboxnew/tools/authcodetoopenid";
-
-}

+ 0 - 62
src/main/java/com/fdkankan/ucenter/pay/wx/WXPayDefaultConfig.java

@@ -1,62 +0,0 @@
-package com.fdkankan.ucenter.pay.wx;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-public class WXPayDefaultConfig implements WXPayConfig {
-
-    private byte[] certData;
-
-    public WXPayDefaultConfig() throws Exception {
-        /*String certPath = CONSTANTFILEPATH.WEIXINCERT;
-        File file = new File(certPath);
-        InputStream certStream = new FileInputStream(file);
-        this.certData = new byte[(int) file.length()];
-        certStream.read(this.certData);
-        certStream.close();*/
-    }
-
-    public String getAppID() {
-        return "wx779dbafb46bab697";
-    }
-
-    public String getMchID() {
-        return "1627275258";
-    }
-
-    public String getKey() {
-        return "4DAGE1684DAGE1684DAGE1684DAGE168";
-    }
-
-    public String getSecret() {
-        return "306d0d03b372232e03dca1107525f4fc";
-    }
-
-    public String getCreateIP() {
-        return "47.104.99.106";
-    }
-
-    public String getH5RedirectURL() {
-        return "mobile.html#/check";
-    }
-
-    public String getNotifyURL() {
-        return "api/order/pay/wechatPay/notify";
-    }
-
-    public String getOrderURL() {
-        return "https://api.mch.weixin.qq.com/pay/unifiedorder";
-    }
-
-    public InputStream getCertStream() {
-        return new ByteArrayInputStream(this.certData);
-    }
-
-    public int getHttpConnectTimeoutMs() {
-        return 8000;
-    }
-
-    public int getHttpReadTimeoutMs() {
-        return 10000;
-    }
-}

+ 0 - 307
src/main/java/com/fdkankan/ucenter/pay/wx/WXPayUtil.java

@@ -1,307 +0,0 @@
-package com.fdkankan.ucenter.pay.wx;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.EncodeHintType;
-import com.google.zxing.MultiFormatWriter;
-import com.google.zxing.WriterException;
-import com.google.zxing.common.BitMatrix;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.security.MessageDigest;
-import java.util.*;
-
-
-public class WXPayUtil {
-
-    /**
-     * XML格式字符串转换为Map
-     *
-     * @param strXML XML字符串
-     * @return XML数据转换后的Map
-     * @throws Exception
-     */
-    public static Map<String, String> xmlToMap(String strXML) throws Exception {
-        Map<String, String> data = new HashMap<String, String>();
-        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
-
-        // 禁用XML外部实体注入
-        /**
-         * XXE
-         * XML 外部实体注入漏洞(XML External Entity Injection,简称 XXE),
-         * 是一种容易被忽视,但危害巨大的漏洞。它可以利用 XML 外部实体加载注入,
-         * 执行不可预控的代码,可导致读取任意文件、执行系统命令、探测内网端口、攻击内网网站等危害。
-         */
-
-        /**
-         * 原理:
-         * 通常,我们在使用微信支付时,商家会有一个通知的 URL 来接收异步支付结果。
-         * 然而,微信在 JAVA 版本的 SDK 存在一个 XXE 漏洞来处理这个结果。
-         * 由此攻击者可以向通知的 URL 中构建恶意的回调数据,以便根据需要窃取商家服务器上的任意信息。
-         * 一旦攻击者获得商家的关键安全密钥(md5-key 和merchant-Id),
-         * 那么他们可以通过发送伪造的信息来欺骗商家而无需付费购买任意商品。
-         */
-        documentBuilderFactory.setExpandEntityReferences(false);
-        documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-        DocumentBuilder documentBuilder= documentBuilderFactory.newDocumentBuilder();
-        InputStream stream = new ByteArrayInputStream(strXML.getBytes("UTF-8"));
-        org.w3c.dom.Document doc = documentBuilder.parse(stream);
-        doc.getDocumentElement().normalize();
-        NodeList nodeList = doc.getDocumentElement().getChildNodes();
-        for (int idx=0; idx<nodeList.getLength(); ++idx) {
-            Node node = nodeList.item(idx);
-            if (node.getNodeType() == Node.ELEMENT_NODE) {
-                org.w3c.dom.Element element = (org.w3c.dom.Element) node;
-                data.put(element.getNodeName(), element.getTextContent());
-            }
-        }
-        try {
-            stream.close();
-        }
-        catch (Exception ex) {
-
-        }
-        return data;
-    }
-
-    /**
-     * 将Map转换为XML格式的字符串
-     *
-     * @param data Map类型数据
-     * @return XML格式的字符串
-     * @throws Exception
-     */
-    public static String mapToXml(Map<String, String> data) throws Exception {
-        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
-        DocumentBuilder documentBuilder= documentBuilderFactory.newDocumentBuilder();
-        org.w3c.dom.Document document = documentBuilder.newDocument();
-        org.w3c.dom.Element root = document.createElement("xml");
-        document.appendChild(root);
-        for (String key: data.keySet()) {
-            String value = data.get(key);
-            if (value == null) {
-                value = "";
-            }
-            value = value.trim();
-            org.w3c.dom.Element filed = document.createElement(key);
-            filed.appendChild(document.createTextNode(value));
-            root.appendChild(filed);
-        }
-        TransformerFactory tf = TransformerFactory.newInstance();
-        Transformer transformer = tf.newTransformer();
-        DOMSource source = new DOMSource(document);
-        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-        StringWriter writer = new StringWriter();
-        StreamResult result = new StreamResult(writer);
-        transformer.transform(source, result);
-        String output = writer.getBuffer().toString(); //.replaceAll("\n|\r", "");
-        try {
-            writer.close();
-        }
-        catch (Exception ex) {
-        }
-        return output;
-    }
-
-
-    /**
-     * 生成带有 sign 的 XML 格式字符串
-     *
-     * @param data Map类型数据
-     * @param key API密钥
-     * @return 含有sign字段的XML
-     */
-    public static String generateSignedXml(final Map<String, String> data, String key) throws Exception {
-        return generateSignedXml(data, key, WXPayConstants.SignType.MD5);
-    }
-
-    /**
-     * 生成带有 sign 的 XML 格式字符串
-     *
-     * @param data Map类型数据
-     * @param key API密钥
-     * @param signType 签名类型
-     * @return 含有sign字段的XML
-     */
-    public static String generateSignedXml(final Map<String, String> data, String key, WXPayConstants.SignType signType) throws Exception {
-        String sign = generateSignature(data, key, signType);
-        data.put(WXPayConstants.FIELD_SIGN, sign);
-        return mapToXml(data);
-    }
-
-
-    /**
-     * 判断签名是否正确
-     *
-     * @param xmlStr XML格式数据
-     * @param key API密钥
-     * @return 签名是否正确
-     * @throws Exception
-     */
-    public static boolean isSignatureValid(String xmlStr, String key) throws Exception {
-        Map<String, String> data = xmlToMap(xmlStr);
-        if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) {
-            return false;
-        }
-        String sign = data.get(WXPayConstants.FIELD_SIGN);
-        return generateSignature(data, key).equals(sign);
-    }
-
-    /**
-     * 判断签名是否正确,必须包含sign字段,否则返回false。使用MD5签名。
-     *
-     * @param data Map类型数据
-     * @param key API密钥
-     * @return 签名是否正确
-     * @throws Exception
-     */
-    public static boolean isSignatureValid(Map<String, String> data, String key) throws Exception {
-        return isSignatureValid(data, key, WXPayConstants.SignType.MD5);
-    }
-
-    /**
-     * 判断签名是否正确,必须包含sign字段,否则返回false。
-     *
-     * @param data Map类型数据
-     * @param key API密钥
-     * @param signType 签名方式
-     * @return 签名是否正确
-     * @throws Exception
-     */
-    public static boolean isSignatureValid(Map<String, String> data, String key, WXPayConstants.SignType signType) throws Exception {
-        if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) {
-            return false;
-        }
-        String sign = data.get(WXPayConstants.FIELD_SIGN);
-        return generateSignature(data, key, signType).equals(sign);
-    }
-
-    /**
-     * 生成签名
-     *
-     * @param data 待签名数据
-     * @param key API密钥
-     * @return 签名
-     */
-    public static String generateSignature(final Map<String, String> data, String key) throws Exception {
-        return generateSignature(data, key, WXPayConstants.SignType.MD5);
-    }
-
-    /**
-     * 生成签名. 注意,若含有sign_type字段,必须和signType参数保持一致。
-     *
-     * @param data 待签名数据
-     * @param key API密钥
-     * @param signType 签名方式
-     * @return 签名
-     */
-    public static String generateSignature(final Map<String, String> data, String key, WXPayConstants.SignType signType) throws Exception {
-        Set<String> keySet = data.keySet();
-        String[] keyArray = keySet.toArray(new String[keySet.size()]);
-        Arrays.sort(keyArray);
-        StringBuilder sb = new StringBuilder();
-        for (String k : keyArray) {
-            if (k.equals(WXPayConstants.FIELD_SIGN)) {
-                continue;
-            }
-            if (data.get(k).trim().length() > 0) // 参数值为空,则不参与签名
-                sb.append(k).append("=").append(data.get(k).trim()).append("&");
-        }
-        sb.append("key=").append(key);
-        if (WXPayConstants.SignType.MD5.equals(signType)) {
-            return MD5(sb.toString()).toUpperCase();
-        }
-        else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) {
-            return HMACSHA256(sb.toString(), key);
-        }
-        else {
-            throw new Exception(String.format("Invalid sign_type: %s", signType));
-        }
-    }
-
-
-    /**
-     * 获取随机字符串 Nonce Str
-     *
-     * @return String 随机字符串
-     */
-    public static String generateNonceStr() {
-        return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32);
-    }
-
-
-    /**
-     * 生成 MD5
-     *
-     * @param data 待处理数据
-     * @return MD5结果
-     */
-    public static String MD5(String data) throws Exception {
-        MessageDigest md = MessageDigest.getInstance("MD5");
-        byte[] array = md.digest(data.getBytes("UTF-8"));
-        StringBuilder sb = new StringBuilder();
-        for (byte item : array) {
-            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
-        }
-        return sb.toString().toUpperCase();
-    }
-
-    /**
-     * 生成 HMACSHA256
-     * @param data 待处理数据
-     * @param key 密钥
-     * @return 加密结果
-     * @throws Exception
-     */
-    public static String HMACSHA256(String data, String key) throws Exception {
-        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
-        SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
-        sha256_HMAC.init(secret_key);
-        byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
-        StringBuilder sb = new StringBuilder();
-        for (byte item : array) {
-            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
-        }
-        return sb.toString().toUpperCase();
-    }
-
-    /**
-     * 根据url生成二位图片对象
-     *
-     * @param codeUrl
-     * @return
-     * @throws WriterException
-     */
-    public static BufferedImage getQRCodeImge(String codeUrl) throws WriterException {
-        int width = 300;
-        //根据url生成二维码
-        MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
-        // 设置二维码参数
-        Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
-        hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
-        BitMatrix bitMatrix = multiFormatWriter.encode(codeUrl, BarcodeFormat.QR_CODE, width, width, hints);
-        BufferedImage image = new BufferedImage(width, width, 1);
-        for(int x = 0; x < width; ++x) {
-            for(int y = 0; y < width; ++y) {
-                image.setRGB(x, y, bitMatrix.get(x, y) ? -16777216 : -1);
-            }
-        }
-        return image;
-
-    }
-}

+ 0 - 8
src/main/java/com/fdkankan/ucenter/service/IIncrementAutoOrderService.java

@@ -3,7 +3,6 @@ package com.fdkankan.ucenter.service;
 import com.fdkankan.ucenter.entity.IncrementAutoOrder;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.ucenter.httpClient.vo.PayOrderVo;
-import com.fdkankan.ucenter.pay.paypal.sdk.AutoPaypalVo;
 
 /**
  * <p>
@@ -23,13 +22,6 @@ public interface IIncrementAutoOrderService extends IService<IncrementAutoOrder>
 
     IncrementAutoOrder getBySubId(String subscriptionId);
 
-    void paySuccess(IncrementAutoOrder incrementAutoOrder, AutoPaypalVo order) throws Exception;
-
-    void payError(IncrementAutoOrder incrementAutoOrder, AutoPaypalVo order);
-
-    void subscriptionCancelled(IncrementAutoOrder incrementAutoOrder, AutoPaypalVo order);
-
-    void setIncrementId(IncrementAutoOrder incrementAutoOrder, Long incrmentId);
 
     void delByIncrementId(Long incrementId);
 

+ 0 - 2
src/main/java/com/fdkankan/ucenter/service/IIncrementOrderService.java

@@ -6,7 +6,6 @@ import com.fdkankan.ucenter.entity.IncrementOrder;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.ucenter.entity.IncrementType;
 import com.fdkankan.ucenter.entity.User;
-import com.fdkankan.ucenter.pay.paypal.sdk.AutoPaypalVo;
 import com.fdkankan.ucenter.vo.request.DownNumParam;
 import com.fdkankan.ucenter.vo.request.IncrementOrderParam;
 import com.fdkankan.ucenter.vo.request.OrderParam;
@@ -39,5 +38,4 @@ public interface IIncrementOrderService extends IService<IncrementOrder> {
 
     IncrementOrder getByOrderSnNoPay(String orderSn);
 
-    void addNewOrderByOrder(IncrementAutoOrder incrementAutoOrder, AutoPaypalVo order);
 }

+ 0 - 42
src/main/java/com/fdkankan/ucenter/service/impl/IncrementAutoOrderServiceImpl.java

@@ -13,8 +13,6 @@ import com.fdkankan.ucenter.entity.User;
 import com.fdkankan.ucenter.entity.UserIncrement;
 import com.fdkankan.ucenter.httpClient.vo.PayOrderVo;
 import com.fdkankan.ucenter.mapper.IIncrementAutoOrderMapper;
-import com.fdkankan.ucenter.pay.paypal.sdk.AutoPaypalVo;
-import com.fdkankan.ucenter.pay.strategy.impl.IncrementOrderImpl;
 import com.fdkankan.ucenter.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,8 +34,6 @@ public class IncrementAutoOrderServiceImpl extends ServiceImpl<IIncrementAutoOrd
     @Autowired
     IIncrementOrderService incrementOrderService;
     @Autowired
-    IncrementOrderImpl incrementOrder;
-    @Autowired
     IMailTemplateService mailTemplateService;
     @Autowired
     IUserService userService;
@@ -74,47 +70,9 @@ public class IncrementAutoOrderServiceImpl extends ServiceImpl<IIncrementAutoOrd
         return this.getOne(wrapper);
     }
 
-    @Override
-    public void paySuccess(IncrementAutoOrder incrementAutoOrder, AutoPaypalVo order) throws Exception {
-        incrementOrderService.addNewOrderByOrder(incrementAutoOrder,order);
-
-        incrementOrder.handleOrder(order.getOrderSn(),order.getTradeNo(),order.getOrderSn(),2,null);
 
-    }
-
-    @Override
-    public void payError(IncrementAutoOrder incrementAutoOrder, AutoPaypalVo order) {
-        User user = userService.getById(incrementAutoOrder.getUserId());
-        if(user != null){
-            List<UserIncrement> userIncrements = userIncrementService.getByAutoOrderSn(order.getSubscriptionId());
-            if(userIncrements.size() >0){
-                mailTemplateService.sendPayErrorMail(user.getUserName(),userIncrements.get(0).getMemberLevels());
-            }
-        }
-    }
 
-    @Override
-    public void subscriptionCancelled(IncrementAutoOrder incrementAutoOrder, AutoPaypalVo order) {
-        List<UserIncrement> userIncrements = userIncrementService.getByAutoOrderSn(order.getSubscriptionId());
-        for (UserIncrement increment : userIncrements) {
-            userIncrementService.cancelSubscriptions(increment);
-            User user = userService.getById(increment.getUserId());
-            if(user != null){
-                mailTemplateService.sendSubcriptionCancelledMail(user.getUserName(),increment.getMemberLevels());
-            }
-        }
-        this.removeById(incrementAutoOrder.getId());
-    }
 
-    @Override
-    public void setIncrementId(IncrementAutoOrder incrementAutoOrder, Long incrmentId) {
-        if(incrementAutoOrder != null){
-            LambdaUpdateWrapper<IncrementAutoOrder> wrapper = new LambdaUpdateWrapper<>();
-            wrapper.eq(IncrementAutoOrder::getId,incrementAutoOrder.getId());
-            wrapper.set(IncrementAutoOrder::getUserIncrementId,incrmentId);
-            this.update(wrapper);
-        }
-    }
 
     @Override
     public void delByIncrementId(Long incrementId) {

+ 54 - 92
src/main/java/com/fdkankan/ucenter/service/impl/IncrementOrderServiceImpl.java

@@ -22,7 +22,6 @@ import com.fdkankan.ucenter.httpClient.param.PayGoods;
 import com.fdkankan.ucenter.httpClient.service.PayService;
 import com.fdkankan.ucenter.httpClient.vo.PayOrderVo;
 import com.fdkankan.ucenter.mapper.IIncrementOrderMapper;
-import com.fdkankan.ucenter.pay.paypal.sdk.AutoPaypalVo;
 import com.fdkankan.ucenter.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.ucenter.util.DateUserUtil;
@@ -74,29 +73,29 @@ public class IncrementOrderServiceImpl extends ServiceImpl<IIncrementOrderMapper
     public PageInfo pageList(IncrementOrderParam param) {
         User user = userService.getByUserName(param.getUserName());
         LambdaQueryWrapper<IncrementOrder> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(IncrementOrder::getUserId,user.getId());
-        wrapper.eq(IncrementOrder::getPayStatus,1);
+        wrapper.eq(IncrementOrder::getUserId, user.getId());
+        wrapper.eq(IncrementOrder::getPayStatus, 1);
         wrapper.orderByDesc(IncrementOrder::getTradeTime);
         Page<IncrementOrder> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
 
-        List<IncrementOrderVo> listVo  =new ArrayList<>();
+        List<IncrementOrderVo> listVo = new ArrayList<>();
 
         Set<String> orderSn = page.getRecords().stream().map(IncrementOrder::getOrderSn).collect(Collectors.toSet());
         Set<Long> ids = page.getRecords().stream().map(IncrementOrder::getId).collect(Collectors.toSet());
-        HashMap<String,List<Long>> map = userIncrementService.getByOrderSnList(orderSn);
-        HashMap<Long,Invoice> invoiceHashMap = invoiceService.getByIncrementOrderIds(ids);
+        HashMap<String, List<Long>> map = userIncrementService.getByOrderSnList(orderSn);
+        HashMap<Long, Invoice> invoiceHashMap = invoiceService.getByIncrementOrderIds(ids);
         for (IncrementOrder record : page.getRecords()) {
-            if(StringUtils.isNotBlank(record.getTradeTime())){
-                record.setTradeTime(DateUserUtil.AddMinute(record.getTradeTime(),record.getTimeZoneOff()));
+            if (StringUtils.isNotBlank(record.getTradeTime())) {
+                record.setTradeTime(DateUserUtil.AddMinute(record.getTradeTime(), record.getTimeZoneOff()));
             }
             Invoice invoice = invoiceHashMap.get(record.getId());
             IncrementOrderVo vo = new IncrementOrderVo();
-            BeanUtils.copyProperties(record,vo);
+            BeanUtils.copyProperties(record, vo);
             vo.setIncrementIds(map.get(record.getOrderSn()));
             vo.setInvoice(invoice);
             listVo.add(vo);
         }
-        Page<IncrementOrderVo> pageVo = new Page<>(param.getPageNum(),param.getPageSize());
+        Page<IncrementOrderVo> pageVo = new Page<>(param.getPageNum(), param.getPageSize());
         pageVo.setRecords(listVo);
         pageVo.setTotal(page.getTotal());
         return PageInfo.PageInfo(pageVo);
@@ -104,39 +103,39 @@ public class IncrementOrderServiceImpl extends ServiceImpl<IIncrementOrderMapper
 
     @Override
     public GoodsSkuVo getDownloadPrice(OrderParam param) {
-        if(param.getDateType() == null){
+        if (param.getDateType() == null) {
             throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
         }
         // 5 专业会员,6 下载 , 7 高级会员
-        if(param.getDateType() != 6 && param.getIncrementTypeId() == null && param.getUserIncrementId() == null){
+        if (param.getDateType() != 6 && param.getIncrementTypeId() == null && param.getUserIncrementId() == null) {
             throw new BusinessException(SceneConstant.FAILURE_CODE_5012, SceneConstant.FAILURE_MSG_5012);
         }
-        return getGoodsSkuVo(param.getDateType(), param.getUserIncrementId(),param.getMonthQy(),param.getIncrementTypeId());
+        return getGoodsSkuVo(param.getDateType(), param.getUserIncrementId(), param.getMonthQy(), param.getIncrementTypeId());
 
     }
 
-    private GoodsSkuVo getGoodsSkuVo (Integer dateType,Integer userIncrementId,Integer monthDy,Integer incrementTypeId){
+    private GoodsSkuVo getGoodsSkuVo(Integer dateType, Integer userIncrementId, Integer monthDy, Integer incrementTypeId) {
         GoodsSkuVo goodsSkuVo = new GoodsSkuVo();
-        if(userIncrementId != null){
+        if (userIncrementId != null) {
             UserIncrement userIncrement = userIncrementService.getById(userIncrementId);
             incrementTypeId = userIncrement.getIncrementTypeId();
         }
         IncrementType incrementType = null;
-        if(incrementTypeId != null){       //购买会员
+        if (incrementTypeId != null) {       //购买会员
             incrementType = incrementTypeService.getById(incrementTypeId);
-            if(incrementType == null){
+            if (incrementType == null) {
                 throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
             }
             goodsSkuVo.setPrice(incrementType.getPrice());
             goodsSkuVo.setSkuSn(incrementType.getId().toString());
-            goodsSkuVo.setDeadLine(getDateTime(incrementType,userIncrementId,monthDy).toDate().getTime());
+            goodsSkuVo.setDeadLine(getDateTime(incrementType, userIncrementId, monthDy).toDate().getTime());
             return goodsSkuVo;
         }
-        if(dateType == 6){ //下载场景
+        if (dateType == 6) { //下载场景
             incrementType = incrementTypeService.list().get(0);
             goodsSkuVo.setPrice(incrementType.getDownloadPrice());
             goodsSkuVo.setSkuSn(incrementType.getId().toString());
-            goodsSkuVo.setDeadLine(getDateTime(incrementType,userIncrementId,monthDy).toDate().getTime());
+            goodsSkuVo.setDeadLine(getDateTime(incrementType, userIncrementId, monthDy).toDate().getTime());
             return goodsSkuVo;
         }
 
@@ -144,19 +143,19 @@ public class IncrementOrderServiceImpl extends ServiceImpl<IIncrementOrderMapper
     }
 
     @Override
-    public DateTime getDateTime(IncrementType incrementType, Integer userIncrementId,Integer count) {
+    public DateTime getDateTime(IncrementType incrementType, Integer userIncrementId, Integer count) {
         Date userTime = new Date();
-        if(userIncrementId != null){
+        if (userIncrementId != null) {
             UserIncrement userIncrement = userIncrementService.getById(userIncrementId);
             userTime = DateUserUtil.getDate(userIncrement.getIncrementEndTime());
         }
-        return  DateUserUtil.getDateTime(userTime, incrementType,count);
+        return DateUserUtil.getDateTime(userTime, incrementType, count);
     }
 
 
-    public GoodsSkuVo getIncrementOrDownloadPrice(Integer dateType)  {
+    public GoodsSkuVo getIncrementOrDownloadPrice(Integer dateType) {
         String skuStr = SkuEnum.skusMap.get(String.valueOf(dateType));
-        if (StringUtils.isEmpty(skuStr)){
+        if (StringUtils.isEmpty(skuStr)) {
             skuStr = SkuEnum.skusMap.get("5");
         }
 
@@ -166,20 +165,21 @@ public class IncrementOrderServiceImpl extends ServiceImpl<IIncrementOrderMapper
 
         return responseGoodsSku;
     }
+
     @Autowired
     PayService payService;
 
     @Override
-    public IncrementOrder insertIncrementOrder(User user, DownNumParam param,IncrementType incrementType) {
+    public IncrementOrder insertIncrementOrder(User user, DownNumParam param, IncrementType incrementType) {
 
         BigDecimal total = incrementType.getPrice().multiply(new BigDecimal(param.getCount()));
-        if(param.getMonthQy() != null){
+        if (param.getMonthQy() != null) {
             total = total.multiply(new BigDecimal(param.getMonthQy()));  //高级会员月份
         }
-        if(param.getIncrementId() != null){
-            IncrementAutoOrder autoOrder2 =  incrementAutoOrderService.getByIncrementId(param.getIncrementId());
-            if(autoOrder2 != null){
-                throw new BusinessException(ResultCode.FAILURE_CODE_400007,ResultCode.FAILURE_MSG_400007);
+        if (param.getIncrementId() != null) {
+            IncrementAutoOrder autoOrder2 = incrementAutoOrderService.getByIncrementId(param.getIncrementId());
+            if (autoOrder2 != null) {
+                throw new BusinessException(ResultCode.FAILURE_CODE_400007, ResultCode.FAILURE_MSG_400007);
             }
         }
 
@@ -188,27 +188,27 @@ public class IncrementOrderServiceImpl extends ServiceImpl<IIncrementOrderMapper
         String autoStartTime = null;
         String autoPayTime = null;
         UserIncrement userIncrement = null;
-        if(param.getAutoPay() != null && param.getAutoPay() == 1){
-            if(param.getIncrementId() != null){
+        if (param.getAutoPay() != null && param.getAutoPay() == 1) {
+            if (param.getIncrementId() != null) {
                 userIncrement = userIncrementService.getById(param.getIncrementId());
-                if(userIncrement != null){
+                if (userIncrement != null) {
                     autoStartTime = userIncrement.getIncrementEndTime();
                 }
             }
         }
-        if(incrementType.getValidTimeType() == 0){
+        if (incrementType.getValidTimeType() == 0) {
             incrementOrderEntity.setMemberLevels("PR");
             autoPayTime = "YEAR";
         }
-        if(incrementType.getValidTimeType() == 1){
+        if (incrementType.getValidTimeType() == 1) {
             incrementOrderEntity.setMemberLevels("SE");
             autoPayTime = "MONTH";
         }
-        autoPayVo =new PayAutoPayVo(param.getAutoPay(),autoPayTime,autoStartTime);
-        PayGoods payGoods = new PayGoods(incrementType.getName(),param.getCount(),incrementType.getValidTimeType(),param.getMonthQy());
-        PayOrderVo payOrderVo = payService.downOrder(total, "incrementOrder",user.getUserName(),user.getNickName(), Arrays.asList(payGoods),autoPayVo);
-        if(payOrderVo == null){
-            throw new BusinessException(OrderConstant.FAILURE_CODE_8005,OrderConstant.FAILURE_MSG_8005);
+        autoPayVo = new PayAutoPayVo(param.getAutoPay(), autoPayTime, autoStartTime);
+        PayGoods payGoods = new PayGoods(incrementType.getName(), param.getCount(), incrementType.getValidTimeType(), param.getMonthQy());
+        PayOrderVo payOrderVo = payService.downOrder(total, "incrementOrder", user.getUserName(), user.getNickName(), Arrays.asList(payGoods), autoPayVo);
+        if (payOrderVo == null) {
+            throw new BusinessException(OrderConstant.FAILURE_CODE_8005, OrderConstant.FAILURE_MSG_8005);
         }
 
         incrementOrderEntity.setOrderSn(payOrderVo.getOrderSn());
@@ -227,8 +227,8 @@ public class IncrementOrderServiceImpl extends ServiceImpl<IIncrementOrderMapper
         incrementOrderEntity.setMonthQy(param.getMonthQy());
         incrementOrderEntity.setTimeZoneOff(param.getTimeZoneOff());
         incrementOrderEntity.setAutoPay(param.getAutoPay());
-        if(param.getAutoPay() != null && param.getAutoPay()==1){
-            incrementAutoOrderService.addOrder(user.getId(),incrementType.getId(),param.getIncrementId(),incrementOrderEntity.getOrderSn());
+        if (param.getAutoPay() != null && param.getAutoPay() == 1) {
+            incrementAutoOrderService.addOrder(user.getId(), incrementType.getId(), param.getIncrementId(), incrementOrderEntity.getOrderSn());
             return incrementOrderEntity;
         }
         this.save(incrementOrderEntity);
@@ -238,9 +238,9 @@ public class IncrementOrderServiceImpl extends ServiceImpl<IIncrementOrderMapper
     @Override
     public IncrementOrder getByOrderSn(String orderSn) {
         QueryWrapper<IncrementOrder> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(IncrementOrder::getOrderSn,orderSn);
+        queryWrapper.lambda().eq(IncrementOrder::getOrderSn, orderSn);
         List<IncrementOrder> list = this.list(queryWrapper);
-        if(list == null || list.size()<=0){
+        if (list == null || list.size() <= 0) {
             return null;
         }
         return list.get(0);
@@ -249,62 +249,24 @@ public class IncrementOrderServiceImpl extends ServiceImpl<IIncrementOrderMapper
     @Override
     public IncrementOrder getByOrderSnNoPay(String orderSn) {
         QueryWrapper<IncrementOrder> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(IncrementOrder::getOrderSn,orderSn);
-        queryWrapper.lambda().ne(IncrementOrder::getPayStatus,1);
+        queryWrapper.lambda().eq(IncrementOrder::getOrderSn, orderSn);
+        queryWrapper.lambda().ne(IncrementOrder::getPayStatus, 1);
         List<IncrementOrder> list = this.list(queryWrapper);
-        if(list == null || list.size()<=0){
+        if (list == null || list.size() <= 0) {
             return null;
         }
-        return list.get(0);    }
+        return list.get(0);
+    }
 
     @Override
     public boolean paySuccessIncrementOrder(String orderSn, String tradeNo, int paymentTypeName) {
         LambdaUpdateWrapper<IncrementOrder> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(IncrementOrder::getPayType,paymentTypeName)
-                .set(IncrementOrder::getNumber,tradeNo)
+        updateWrapper.set(IncrementOrder::getPayType, paymentTypeName)
+                .set(IncrementOrder::getNumber, tradeNo)
                 .set(IncrementOrder::getPayStatus, 1)
                 .set(IncrementOrder::getTradeTime, new Date())
-                .eq(IncrementOrder::getOrderSn,orderSn);
+                .eq(IncrementOrder::getOrderSn, orderSn);
         return this.update(updateWrapper);
     }
-
-    @Override
-    public void addNewOrderByOrder(IncrementAutoOrder incrementAutoOrder, AutoPaypalVo order) {
-
-        IncrementOrder incrementOrder = new IncrementOrder();
-        incrementOrder.setOrderSn(order.getOrderSn());
-        incrementOrder.setAmount(new BigDecimal(order.getAmount()));
-        incrementOrder.setPayType(2);
-        incrementOrder.setPayStatus(-1);
-        incrementOrder.setUserId(incrementAutoOrder.getUserId());
-        incrementOrder.setCount(1);
-        incrementOrder.setNumber(order.getTradeNo());
-        incrementOrder.setAbroad(1);
-        incrementOrder.setStatus(incrementAutoOrder.getUserIncrementId() == null ? 1 : 2);
-        incrementOrder.setIncrementId(incrementAutoOrder.getUserIncrementId());
-        incrementOrder.setRecStatus("A");
-        incrementOrder.setCreateTime(DateUserUtil.getDate(new Date()));
-        incrementOrder.setUpdateTime(DateUserUtil.getDate(new Date()));
-        incrementOrder.setIncrementType(incrementAutoOrder.getIncrementTypeId());
-        incrementOrder.setMonthQy(1);
-        incrementOrder.setAutoPay(1);
-        incrementOrder.setAutoOrderId(incrementAutoOrder.getId());
-        incrementOrder.setTimeZoneOff(-480);
-
-        IncrementType incrementType = incrementTypeService.getById(incrementAutoOrder.getIncrementTypeId());
-        if(incrementType != null && incrementType.getValidTimeType() == 0){
-            incrementOrder.setMemberLevels("PR");
-        }
-        if(incrementType != null && incrementType.getValidTimeType() == 1){
-            incrementOrder.setMemberLevels("SE");
-        }
-        if(incrementType != null && incrementType.getPrice() != null && StringUtils.isNotBlank(order.getAmount())){
-            BigDecimal payAmount = new BigDecimal(order.getAmount());
-            BigDecimal price = incrementType.getPrice();
-            Integer monthQy = payAmount.divide(price,2, RoundingMode.HALF_UP).intValue();
-            incrementOrder.setMonthQy(monthQy <=0 ? 1 : monthQy);
-        }
-
-        this.save(incrementOrder);
-    }
 }
+

+ 0 - 6
src/main/java/com/fdkankan/ucenter/service/impl/OrderServiceImpl.java

@@ -17,10 +17,6 @@ import com.fdkankan.ucenter.httpClient.param.PayGoods;
 import com.fdkankan.ucenter.httpClient.service.PayService;
 import com.fdkankan.ucenter.httpClient.vo.PayOrderVo;
 import com.fdkankan.ucenter.mapper.IOrderMapper;
-import com.fdkankan.ucenter.pay.alipay.sdk.AlipayService;
-import com.fdkankan.ucenter.pay.wx.WXPay;
-import com.fdkankan.ucenter.pay.wx.WXPayConstants;
-import com.fdkankan.ucenter.pay.wx.WXPayDefaultConfig;
 import com.fdkankan.ucenter.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.ucenter.util.DateUserUtil;
@@ -69,8 +65,6 @@ public class OrderServiceImpl extends ServiceImpl<IOrderMapper, Order> implement
     @Autowired
     RedisUtil redisUtil;
     @Autowired
-    AlipayService alipayService;
-    @Autowired
     IDownloadOrderService downloadOrderService;
     @Autowired
     IIncrementTypeService incrementTypeService;