| | |
| | | siteBooking.setPayOrderNo(transaction_id); |
| | | siteBookingService.updateById(siteBooking); |
| | | |
| | | if (byId.getOperatorId()!=null && byId.getOperatorId()!=0){ |
| | | // 休眠两分钟后再调用分账接口 避免提示订单正在处理中 |
| | | Thread.sleep(120000); |
| | | // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | OperatorUser operatorId = operatorUserService.getOne( |
| | | new QueryWrapper<OperatorUser>().eq("operatorId",byId.getOperatorId()) |
| | | ); |
| | | if (operatorId.getWechatProportion() == null){ |
| | | operatorId.setWechatProportion("0"); |
| | | } |
| | | if (operatorId.getAlipayProportion() == null){ |
| | | operatorId.setAlipayProportion("0"); |
| | | } |
| | | String proportion= operatorId.getWechatProportion()+","+operatorId.getAlipayProportion(); |
| | | String[] split = proportion.split(","); |
| | | String s1 = split[0]; |
| | | if (!s1.equals("未设置")){ |
| | | BigDecimal bigDecimal = new BigDecimal(s1); |
| | | // 分账比例 |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2); |
| | | // 微信商户号 |
| | | String s2 =siteService.getmerchantNumberByOperatorId(byId.getOperatorId()); |
| | | String nonce_str = UUIDUtil.getRandomCode(16); |
| | | BigDecimal bigDecimal2 = new BigDecimal(paymentPrice); |
| | | ResultUtil fenzhang = payMoneyUtil.fenzhang(transaction_id, bigDecimal2.multiply(bigDecimal1), s2,nonce_str); |
| | | if (!fenzhang.getCode().equals(500)){ |
| | | System.err.println("分账失败 原因是:"+fenzhang.getMsg()); |
| | | }else{ |
| | | siteBooking.setFenzhangNo(fenzhang.getMsg()); |
| | | siteBooking.setFenzhangOrderNo(nonce_str); |
| | | siteBooking.setFenzhangAmount(bigDecimal2.multiply(bigDecimal1)); |
| | | siteBookingService.updateById(siteBooking); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | break; |
| | | } |
| | |
| | | String randomCode = UUIDUtil.getRandomCode(16); |
| | | String randomCode1 = UUIDUtil.getRandomCode(16); |
| | | if (byId.getOperatorId()!=null && byId.getOperatorId()!=0){ |
| | | // 休眠两分钟后再调用分账接口 避免提示订单正在处理中 |
| | | // 微信商户号 |
| | | String s2 =siteService.getmerchantNumberByOperatorId(byId.getOperatorId()); |
| | | ResultUtil resultUtil = payMoneyUtil.fenzhangRefund(siteBooking.getFenzhangNo(), siteBooking.getFenzhangAmount(), s2, randomCode, randomCode1); |
| | | if (!resultUtil.getCode().equals(500)){ |
| | | System.err.println("分账回退失败 原因是:"+resultUtil.getMsg()); |
| | | ResultUtil resultUtil = payMoneyUtil.fenzhangRefund(siteBooking.getFenzhangNo(), siteBooking.getFenzhangAmount().multiply(new BigDecimal("100")), s2, randomCode, randomCode1); |
| | | if (!resultUtil.getCode().equals(200)){ |
| | | System.err.println("分账回退失败 原因是:"+resultUtil.getMsg()+resultUtil.getData()); |
| | | }else{ |
| | | siteBooking.setFenzhangRefundNo(resultUtil.getMsg()); |
| | | siteBookingService.updateById(siteBooking); |