lyhzzz 2 سال پیش
والد
کامیت
92d6619c44
1فایلهای تغییر یافته به همراه14 افزوده شده و 80 حذف شده
  1. 14 80
      src/main/java/com/fdkankan/ucenter/service/impl/OrderServiceImpl.java

+ 14 - 80
src/main/java/com/fdkankan/ucenter/service/impl/OrderServiceImpl.java

@@ -218,90 +218,24 @@ public class OrderServiceImpl extends ServiceImpl<IOrderMapper, Order> implement
 
     @Override
     public boolean queryOrderStatus(OrderParam param) throws Exception {
-        boolean success = false;
         String orderSn = param.getOrderSn();
-        switch (param.getOrderType()){
-            case 0:
-                orderSn += "_entity";
-                break;
-            case 1:
-                orderSn += "_recharge";
-                break;
-            case 2:
-                orderSn += "_expansion";
-                break;
-            case 3:
-                orderSn += "_commerce";
-                break;
-            case 4:   //国内参数
-            case 6:   //国际服参数
-                orderSn += "_increment";
-                break;
-            case 5:
-                orderSn += "_download";
-                break;
+        if(StringUtils.isBlank(orderSn)){
+            return false;
         }
-        if(param.getPayType()!= 2 && !redisUtil.hasKey(RedisKeyUtil.QRCODE + orderSn)){
-            String wxPngPath =  QrCodeFilePath.WEIXIN_QRCODE_FOLDER + orderSn + ".png";
-            String aliPngPath =  QrCodeFilePath.ALI_QRCODE_FOLDER + orderSn + ".png";
-            FileUtils.deleteFile(wxPngPath);
-            FileUtils.deleteFile(aliPngPath);
-            //throw new BusinessException(LoginConstant.FAILURE_CODE_3035,LoginConstant.FAILURE_MSG_3035);
+        Order order = orderService.getByOrderSn(orderSn);
+        //付款状态(未付款unpaid、已付款paid、已取消cancel, 部分支付partPayment, 部分退款partRefund, 全额退款refunded)
+        if(order != null && order.getPaymentStatus().equals("paid")){
+            return true;
         }
-        switch (param.getPayType()){
-            // 微信
-            case 0:
-                String orderSnE = redisUtil.get(orderSn);
-                log.warn("out_trade_no:" + orderSnE);
-                if (StringUtils.isNotEmpty(orderSnE)){
-                    Map<String, String> data = new HashMap<String, String>();
-                    data.put("out_trade_no", orderSnE);
-                    WXPayDefaultConfig config = new WXPayDefaultConfig();
-                    WXPay wxPay = new WXPay(config);
-                    Map<String, String> resp = wxPay.orderQuery(data);
-                    if (resp.get("trade_state") != null && resp.get("trade_state").equals(WXPayConstants.SUCCESS)) {
-                        redisUtil.del(orderSnE);
-                        success = true;
-                    }
-                }
-                break;
-            // 支付宝
-            case 1:
-                log.warn("alipay out_trade_no:" + orderSn);
-                String type = alipayService.tradeQuery(orderSn);
-                log.warn("alipay type:" + type);
-                if ("SUCCESS".equals(type)){
-                    success = true;
-                }
-                break;
-            // paypal
-            case 2:
-                String[] str = orderSn.split("_");
-                orderSn = str[0];
-                String key = str[1];
-
-                if(key.equals("increment")){
-                    log.warn("paypal out_trade_no:" + orderSn);
-                    IncrementOrder orderEntity = incrementOrderService.getByOrderSn(orderSn);
-                    if (orderEntity.getPayStatus().equals(1)){
-                        success = true;
-                    }
-                } else if(key.equals("download")) {
-                    log.warn("paypal out_trade_no:" + orderSn);
-                    DownloadOrder orderEntity = downloadOrderService.getByOrderSn(orderSn);
-                    if (orderEntity.getPayStatus().equals(1)) {
-                        success = true;
-                    }
-                }else{
-                    log.warn("paypal out_trade_no:" + orderSn);
-                    Order orderEntity = orderService.getByOrderSn(orderSn);
-                    if (PaymentStatus.paid.name().equals(orderEntity.getPaymentStatus())){
-                        success = true;
-                    }
-                }
-                break;
+        DownloadOrder downloadOrder = downloadOrderService.getByOrderSn(orderSn);
+        if(downloadOrder != null && downloadOrder.getPayStatus() == 1){
+            return true;
+        }
+        IncrementOrder incrementOrder = incrementOrderService.getByOrderSn(orderSn);
+        if(incrementOrder != null && incrementOrder.getPayStatus() == 1){
+            return true;
         }
-        return success;
+        return false;
     }
 
     @Override