| | |
| | | } |
| | | |
| | | if (paymentCompetitionVo.getPayType() == 2) {//支付宝 |
| | | String resSmid=smid; |
| | | // 判断当前赛事属于哪个运营商 |
| | | Competition byId = competitionService.getById(paymentCompetitionVo.getId()); |
| | | String[] split = byId.getStoreId().split(","); |
| | |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil aliPaymentCompetition(Integer operatorId,String smid,String code, BigDecimal money) throws Exception { |
| | | String resSmid=smid; |
| | | ResultUtil alipay = payMoneyUtil.alipay |
| | | (smid,"报名赛事", "", "", code, money.toString(), "/base/competition/aliPaymentCompetitionCallback"); |
| | | // if (alipay.getCode() == 200) { |
| | | // new Thread(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // try { |
| | | // int num = 1; |
| | | // int wait = 0; |
| | | // while (num <= 10) { |
| | | // int min = 5000; |
| | | // wait += (min * num); |
| | | // Thread.sleep(wait); |
| | | // PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 2)); |
| | | // if (paymentCompetition.getPayStatus() == 2) { |
| | | // break; |
| | | // } |
| | | // AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | // if (resultUtil.getCode().equals("10000") && paymentCompetition.getPayStatus() == 1) { |
| | | // /** |
| | | // * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | // * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | // * TRADE_SUCCESS(交易支付成功)、 |
| | | // * TRADE_FINISHED(交易结束,不可退款) |
| | | // */ |
| | | //// Map<String, String> data1 = resultUtil.getData(); |
| | | //// String s = data1.get("tradeStatus"); |
| | | //// String tradeNo = data1.get("tradeNo"); |
| | | // String tradeNo = resultUtil.getTradeNo(); |
| | | // String s = resultUtil.getTradeStatus(); |
| | | // |
| | | // if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | // paymentCompetition.setAppUserId(null); |
| | | // paymentCompetition.setState(3); |
| | | // userCompetitionService.remove(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId())); |
| | | // |
| | | // break; |
| | | // } |
| | | // if ("TRADE_SUCCESS".equals(s)) { |
| | | // paymentCompetition.setAppUserId(null); |
| | | // paymentCompetition.setPayStatus(2); |
| | | // paymentCompetition.setPayTime(new Date()); |
| | | // paymentCompetition.setPayOrderNo(tradeNo); |
| | | // paymentCompetitionService.updateById(paymentCompetition); |
| | | // |
| | | // Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); |
| | | // competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); |
| | | // cttService.updateById(competition); |
| | | // |
| | | // // 结算资金到商户账号 |
| | | // payMoneyUtil.confirm(smid,code,tradeNo,money.toString()); |
| | | // if (operatorId == null || operatorId == 0){ |
| | | // // 属于平台的赛事 资金不做冻结 不做分账处理 |
| | | // payMoneyUtil.confirm1(smid,code,tradeNo,money.toString()); |
| | | // }else{ |
| | | // // 资金冻结 |
| | | // payMoneyUtil.confirm(smid,code,tradeNo,money.toString()); |
| | | // // 分账处理 |
| | | // extracted(operatorId, money, tradeNo); |
| | | // } |
| | | // // 结算资金到商户账号 |
| | | // //分账 |
| | | //// moneyOut(tradeNo, tradeNo,code); |
| | | // break; |
| | | // } |
| | | // if ("WAIT_BUYER_PAY".equals(s)) { |
| | | // num++; |
| | | // } |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }).start(); |
| | | // } |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10) { |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 2)); |
| | | if (paymentCompetition.getPayStatus() == 2) { |
| | | break; |
| | | } |
| | | AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if (resultUtil.getCode().equals("10000") && paymentCompetition.getPayStatus() == 1) { |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | // Map<String, String> data1 = resultUtil.getData(); |
| | | // String s = data1.get("tradeStatus"); |
| | | // String tradeNo = data1.get("tradeNo"); |
| | | String tradeNo = resultUtil.getTradeNo(); |
| | | String s = resultUtil.getTradeStatus(); |
| | | |
| | | if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetition.setState(3); |
| | | userCompetitionService.remove(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId())); |
| | | |
| | | break; |
| | | } |
| | | if ("TRADE_SUCCESS".equals(s)) { |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetition.setPayStatus(2); |
| | | paymentCompetition.setPayTime(new Date()); |
| | | paymentCompetition.setPayOrderNo(tradeNo); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); |
| | | competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); |
| | | cttService.updateById(competition); |
| | | // 结算资金到商户账号 |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(resSmid,code,tradeNo,money.toString()); |
| | | break; |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return alipay; |
| | | } |
| | | private void extracted(Integer operatorId, BigDecimal money, String tradeNo) throws Exception { |