| | |
| | | Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); |
| | | competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); |
| | | cttService.updateById(competition); |
| | | if (operatorId!=null && operatorId!=0){ |
| | | // 休眠两分钟后再调用分账接口 避免提示订单正在处理中 |
| | | Thread.sleep(120000); |
| | | // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | String proportionByOperatorId = storeClient.getProportionByOperatorId(operatorId); |
| | | String[] split = proportionByOperatorId.split(","); |
| | | String s1 = split[0]; |
| | | if (!s1.equals("未设置")){ |
| | | BigDecimal bigDecimal = new BigDecimal(s1); |
| | | // 分账比例 |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(operatorId); |
| | | String nonce_str = UUIDUtil.getRandomCode(16); |
| | | paymentCompetition.setFenzhangOrderNo(nonce_str); |
| | | ResultUtil fenzhang = payMoneyUtil.fenzhang(transaction_id, money.multiply(bigDecimal1), s2,nonce_str); |
| | | if (!fenzhang.getCode().equals(500)){ |
| | | System.err.println("分账失败 原因是:"+fenzhang.getMsg()); |
| | | }else{ |
| | | paymentCompetition.setFenzhangNo(fenzhang.getMsg()); |
| | | paymentCompetition.setFenzhangAmount(money.multiply(bigDecimal1)); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | } |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) { |
| | |
| | | public void moneyOut() throws AlipayApiException { |
| | | Date date = new Date(); |
| | | List<Competition> list = competitionService.list(new QueryWrapper<Competition>().lt("endTime",date).ne("isOut",1)); |
| | | List<Integer> coms = new ArrayList<>(); |
| | | for (Competition competition : list) { |
| | | coms.add(competition.getId()); |
| | | competition.setIsOut(1); |
| | | if(list.size() > 0){ |
| | | List<Integer> coms = new ArrayList<>(); |
| | | for (Competition competition : list) { |
| | | coms.add(competition.getId()); |
| | | competition.setIsOut(1); |
| | | } |
| | | List<PaymentCompetition> pays = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>().in("competitionId", coms)); |
| | | for (PaymentCompetition pay : pays) { |
| | | moneyOut(pay.getPayOrderNo(),pay.getPayOrderNo(),pay.getCode()); |
| | | } |
| | | competitionService.updateBatchById(list); |
| | | } |
| | | List<PaymentCompetition> pays = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>().in("competitionId", coms)); |
| | | for (PaymentCompetition pay : pays) { |
| | | moneyOut(pay.getPayOrderNo(),pay.getPayOrderNo(),pay.getCode()); |
| | | } |
| | | competitionService.updateBatchById(list); |
| | | |
| | | |
| | | } |