| | |
| | | return userWithdrawRecordVOPage; |
| | | } |
| | | @Override |
| | | public Page<UserWithdrawRecordVO> withdrawPage1(List<String> cityList,List<Integer> userIds,String nickname, String userPhone, String applyForTime, Integer state, Page<UserWithdrawRecordVO> page) { |
| | | Page<UserWithdrawRecordVO> userWithdrawRecordVOPage = baseMapper.withdrawPage1(cityList,userIds,nickname, userPhone, applyForTime, state, page); |
| | | public Page<UserWithdrawRecordVO> withdrawPage1(List<String> cityList,List<Integer> userIds,String nickname, String userPhone, String applyForTime, Integer state, Page<UserWithdrawRecordVO> page,List<String> siteIds) { |
| | | Page<UserWithdrawRecordVO> userWithdrawRecordVOPage = baseMapper.withdrawPage1(cityList,userIds,nickname, userPhone, applyForTime, state, page,siteIds); |
| | | |
| | | return userWithdrawRecordVOPage; |
| | | } |
| | |
| | | throw new GlobalException("当前订单提现申请已通过!"); |
| | | } |
| | | |
| | | return weChatPay(order.getOrderMoney(), openId,list.get(0).getId()); |
| | | return weChatPay(order.getSubsidy()!=null?order.getSubsidy().add(order.getOrderMoney()):order.getOrderMoney(), openId,list.get(0).getId(),order.getServeName()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | String startDateStr = String.valueOf(startDate); |
| | | String endDateStr = String.valueOf(endDate); |
| | | BigDecimal withdrawalTotalMoney; |
| | | if (request.getSiteIds()==null){ |
| | | request.setSiteIds(new ArrayList<>()); |
| | | } |
| | | if (OrderConstants.QUARTER.equals(type)) { |
| | | // 用户提现总额 |
| | | withdrawalTotalMoney = baseMapper.withdrawalTotalMoney(cityList, startDateStr, endDateStr); |
| | | withdrawalTotalMoney = baseMapper.withdrawalTotalMoney(cityList, startDateStr, endDateStr,request.getSiteIds()); |
| | | } else if (OrderConstants.YEAR.equals(type)) { |
| | | // 用户提现总额 |
| | | withdrawalTotalMoney = baseMapper.withdrawalTotalMoneyByYear(cityList); |
| | | withdrawalTotalMoney = baseMapper.withdrawalTotalMoneyByYear(cityList,request.getSiteIds()); |
| | | } else if (OrderConstants.MONTH.equals(type)) { |
| | | // 用户提现总额 |
| | | withdrawalTotalMoney = baseMapper.withdrawalTotalMoneyByMonth(cityList); |
| | | withdrawalTotalMoney = baseMapper.withdrawalTotalMoneyByMonth(cityList,request.getSiteIds()); |
| | | } else { |
| | | // 数量初始化 |
| | | withdrawalTotalMoney = BigDecimal.ZERO; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Page<UserWithdrawRecordVO> withdrawList1(List<String> cityList,Integer userId, Page<UserWithdrawRecordVO> page) { |
| | | Page<UserWithdrawRecordVO> userWithdrawRecordVOPage = baseMapper.withdrawList1(cityList,userId, page); |
| | | public Page<UserWithdrawRecordVO> withdrawList1(List<String> cityList,Integer userId, Page<UserWithdrawRecordVO> page,List<String> siteIds) { |
| | | Page<UserWithdrawRecordVO> userWithdrawRecordVOPage = baseMapper.withdrawList1(cityList,userId, page,siteIds); |
| | | for (UserWithdrawRecordVO record : userWithdrawRecordVOPage.getRecords()) { |
| | | R<UserDto> user = userClient.getUser(record.getUserId()); |
| | | System.err.println("==="+user.getData()); |
| | |
| | | .eq(Withdraw::getOrderId, orderId).list(); |
| | | List<Integer> stateList = list.stream().map(Withdraw::getState).collect(Collectors.toList()); |
| | | if (stateList.contains(Constants.ZERO)) { |
| | | throw new GlobalException("当前订单已提交提现申请,请等待审核!"); |
| | | return false; |
| | | // throw new GlobalException("当前订单已提交提现申请,请等待审核!"); |
| | | } else if (stateList.contains(Constants.ONE)) { |
| | | throw new GlobalException("当前订单已完成提现,请勿重复提现!"); |
| | | } |
| | |
| | | // 已通过 |
| | | withdraw.setState(Constants.ONE); |
| | | // 商家微信打款至微信零钱 |
| | | boolean update = weChatPay(order.getOrderMoney(), openId,withdraw.getId()); |
| | | if (!update) { |
| | | throw new GlobalException("交易提现失败,请检查是否绑定微信!"); |
| | | } |
| | | boolean update = weChatPay(order.getOrderMoney(), openId,withdraw.getId(),order.getServerName()); |
| | | // if (!update) { |
| | | // throw new GlobalException("交易提现失败,请检查是否绑定微信!"); |
| | | // } |
| | | } else { |
| | | // 待审核 |
| | | withdraw.setState(Constants.ZERO); |
| | |
| | | @Resource |
| | | private WithdrawDetailService withdrawDetailService; |
| | | |
| | | private boolean weChatPay(BigDecimal orderMoney, String openId,String withdrawId) { |
| | | // private boolean weChatPay(BigDecimal orderMoney, String openId,String withdrawId) { |
| | | // if (StringUtils.isBlank(openId)) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // BigDecimal maxTransferAmount = new BigDecimal("20000"); // 单次转账限额,单位为分 |
| | | // int totalTransfers = orderMoney.multiply(new BigDecimal("100")).divide(maxTransferAmount, 0, RoundingMode.UP).intValue(); |
| | | // boolean allTransfersSuccessful = true; |
| | | // |
| | | // for (int i = 0; i < totalTransfers; i++) { |
| | | // BigDecimal transferAmount; |
| | | // if (i < totalTransfers - 1) { |
| | | // transferAmount = maxTransferAmount; |
| | | // } else { |
| | | // // 最后一笔转账,金额为剩余金额 |
| | | // transferAmount = orderMoney.multiply(new BigDecimal("100")).subtract(maxTransferAmount.multiply(new BigDecimal(i))).setScale(0, RoundingMode.DOWN); |
| | | // } |
| | | // |
| | | // Map<String, Object> postMap = new HashMap<>(8); |
| | | // postMap.put(WechatConstants.APP_ID, "wx98563d0ec9cf21c8"); |
| | | // postMap.put(WechatConstants.OUT_BATCH_NO, String.valueOf(UUID.randomUUID()).replaceAll("-", "")); |
| | | // System.err.println("====="+postMap.get(WechatConstants.OUT_BATCH_NO)); |
| | | // postMap.put(WechatConstants.BATCH_NAME, "二手回收提现"); |
| | | // postMap.put(WechatConstants.BATCH_REMARK, "二手回收提现"); |
| | | // postMap.put(WechatConstants.TOTAL_AMOUNT, transferAmount); |
| | | // postMap.put(WechatConstants.TOTAL_NUM, Constants.ONE); |
| | | // |
| | | // List<Map<String, Object>> list = new ArrayList<>(); |
| | | // Map<String, Object> subMap = new HashMap<>(4); |
| | | // subMap.put(WechatConstants.OUT_DETAIL_NO, String.valueOf(SNOW_FLAKE_ID_WORKER.nextId())); |
| | | // subMap.put(WechatConstants.TRANSFER_AMOUNT, transferAmount); |
| | | // subMap.put(WechatConstants.TRANSFER_REMARK, "二手回收提现到账"); |
| | | // subMap.put(WechatConstants.OPEN_ID, openId); |
| | | // list.add(subMap); |
| | | // postMap.put(WechatConstants.TRANSFER_DETAIL_LIST, list); |
| | | // |
| | | // // 使用类加载器获取资源 URL |
| | | //// String path = ClassLoader.getSystemResource("/usr/local/vx/apiclient_key.pem").getPath(); |
| | | // |
| | | //// String result = HttpUtil.postTransBatRequest( |
| | | //// WechatConstants.WE_CHAT_URL_PRE, |
| | | //// JSONObject.toJSONString(postMap), |
| | | //// "7EEA04429B006E12AAA421C002EC48BBEED5BE94", |
| | | //// "1665330417", |
| | | //// "/usr/local/vx/apiclient_key.pem", WechatConstants.WE_CHAT_URL_SUF); |
| | | // String result = HttpUtil.postTransBatRequest( |
| | | // WechatConstants.WE_CHAT_URL_PRE, |
| | | // JSONObject.toJSONString(postMap), |
| | | // "7EEA04429B006E12AAA421C002EC48BBEED5BE94", |
| | | // "1665330417", |
| | | // "D:\\study\\JiaDianHuiShou\\ruoyi-service\\ruoyi-order\\src\\main\\java\\com\\ruoyi\\order\\vx\\apiclient_key.pem", WechatConstants.WE_CHAT_URL_SUF); |
| | | // |
| | | // JSONObject jsonObject = JSONObject.parseObject(result); |
| | | // |
| | | // WithdrawDetail withdrawDetail = new WithdrawDetail(); |
| | | // withdrawDetail.setWithdrawId(withdrawId); |
| | | // withdrawDetail.setMoney(transferAmount); |
| | | // withdrawDetail.setOutBatchNo((String) postMap.get(WechatConstants.OUT_BATCH_NO)); |
| | | // withdrawDetailService.save(withdrawDetail); |
| | | // |
| | | // if (jsonObject.containsKey(WechatConstants.CREATE_TIME)) { |
| | | // // 转账成功 |
| | | // //保存转账明细 |
| | | //// WithdrawDetail withdrawDetail = new WithdrawDetail(); |
| | | //// withdrawDetail.setWithdrawId(withdrawId); |
| | | //// withdrawDetail.setMoney(transferAmount); |
| | | //// withdrawDetail.setOutBatchNo((String) postMap.get(WechatConstants.OUT_BATCH_NO)); |
| | | //// withdrawDetailService.save(withdrawDetail); |
| | | // |
| | | // |
| | | // } else { |
| | | // allTransfersSuccessful = false; |
| | | // break; |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // return allTransfersSuccessful; |
| | | // } |
| | | |
| | | // 上架打款到用户零钱接口已弃用 用新版商家转账接口 |
| | | private boolean weChatPay(BigDecimal orderMoney, String openId,String withdrawId,String serverName) { |
| | | if (StringUtils.isBlank(openId)) { |
| | | return false; |
| | | } |
| | | |
| | | BigDecimal maxTransferAmount = new BigDecimal("20000"); // 单次转账限额,单位为分 |
| | | BigDecimal maxTransferAmount = new BigDecimal("200000"); // 单次转账限额,单位为分 |
| | | int totalTransfers = orderMoney.multiply(new BigDecimal("100")).divide(maxTransferAmount, 0, RoundingMode.UP).intValue(); |
| | | boolean allTransfersSuccessful = true; |
| | | |
| | | for (int i = 0; i < totalTransfers; i++) { |
| | | BigDecimal transferAmount; |
| | | if (i < totalTransfers - 1) { |
| | |
| | | |
| | | Map<String, Object> postMap = new HashMap<>(8); |
| | | postMap.put(WechatConstants.APP_ID, "wx98563d0ec9cf21c8"); |
| | | postMap.put(WechatConstants.OUT_BATCH_NO, String.valueOf(UUID.randomUUID()).replaceAll("-", "")); |
| | | System.err.println("====="+postMap.get(WechatConstants.OUT_BATCH_NO)); |
| | | postMap.put(WechatConstants.BATCH_NAME, "二手回收提现"); |
| | | postMap.put(WechatConstants.BATCH_REMARK, "二手回收提现"); |
| | | postMap.put(WechatConstants.TOTAL_AMOUNT, transferAmount); |
| | | postMap.put(WechatConstants.TOTAL_NUM, Constants.ONE); |
| | | |
| | | // 订单号 |
| | | postMap.put("out_bill_no", String.valueOf(UUID.randomUUID()).replaceAll("-", "")); |
| | | System.err.println("====="+postMap.get("out_bill_no")); |
| | | postMap.put(WechatConstants.OPEN_ID, openId); |
| | | // 转账金额 |
| | | postMap.put("transfer_amount", transferAmount); |
| | | postMap.put("transfer_scene_id", "1010"); |
| | | // 转账备注 |
| | | postMap.put("transfer_remark", "二手回收提现确认收款"); |
| | | // 回调地址 |
| | | postMap.put("notify_url", "https://hyhsbqgc.com/api/ruoyi-order/wx/wxChatPay"); |
| | | // 转账场景报备信息 |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | Map<String, Object> subMap = new HashMap<>(4); |
| | | subMap.put(WechatConstants.OUT_DETAIL_NO, String.valueOf(SNOW_FLAKE_ID_WORKER.nextId())); |
| | | subMap.put(WechatConstants.TRANSFER_AMOUNT, transferAmount); |
| | | subMap.put(WechatConstants.TRANSFER_REMARK, "二手回收提现到账"); |
| | | subMap.put(WechatConstants.OPEN_ID, openId); |
| | | list.add(subMap); |
| | | postMap.put(WechatConstants.TRANSFER_DETAIL_LIST, list); |
| | | |
| | | // 使用类加载器获取资源 URL |
| | | // String path = ClassLoader.getSystemResource("/usr/local/vx/apiclient_key.pem").getPath(); |
| | | |
| | | // String result = HttpUtil.postTransBatRequest( |
| | | // WechatConstants.WE_CHAT_URL_PRE, |
| | | // JSONObject.toJSONString(postMap), |
| | | // "7EEA04429B006E12AAA421C002EC48BBEED5BE94", |
| | | // "1665330417", |
| | | // "/usr/local/vx/apiclient_key.pem", WechatConstants.WE_CHAT_URL_SUF); |
| | | Map<String, Object> info = new HashMap<>(); |
| | | info.put("info_type","回收商品名称"); |
| | | info.put("info_content",serverName); |
| | | list.add(info); |
| | | postMap.put("transfer_scene_report_infos", list); |
| | | String result = HttpUtil.postTransBatRequest( |
| | | WechatConstants.WE_CHAT_URL_PRE, |
| | | WechatConstants.WE_CHAT_PAY_URL_PRE, |
| | | JSONObject.toJSONString(postMap), |
| | | "7EEA04429B006E12AAA421C002EC48BBEED5BE94", |
| | | "1665330417", |
| | | "D:\\study\\JiaDianHuiShou\\ruoyi-service\\ruoyi-order\\src\\main\\java\\com\\ruoyi\\order\\vx\\apiclient_key.pem", WechatConstants.WE_CHAT_URL_SUF); |
| | | |
| | | "/usr/local/vx/apiclient_key.pem", "/v3/fund-app/mch-transfer/transfer-bills"); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | // WithdrawDetail withdrawDetail = new WithdrawDetail(); |
| | | // withdrawDetail.setWithdrawId(withdrawId); |
| | | // withdrawDetail.setMoney(transferAmount); |
| | | // withdrawDetail.setOutBatchNo((String) postMap.get(WechatConstants.OUT_BATCH_NO)); |
| | | // withdrawDetailService.save(withdrawDetail); |
| | | System.err.println(jsonObject); |
| | | // WithdrawDetail withdrawDetail = new WithdrawDetail(); |
| | | // withdrawDetail.setWithdrawId(withdrawId); |
| | | // withdrawDetail.setMoney(transferAmount); |
| | | // withdrawDetail.setOutBatchNo((String) postMap.get(WechatConstants.OUT_BATCH_NO)); |
| | | // withdrawDetailService.save(withdrawDetail); |
| | | if (jsonObject.containsKey(WechatConstants.CREATE_TIME)) { |
| | | String string = jsonObject.getString("package_info"); |
| | | Withdraw withdraw = this.getById(withdrawId); |
| | | |
| | | Order order = orderService.getById(withdraw.getOrderId()); |
| | | order.setIsWithdrawal(2); |
| | | order.setPackageInfo(string); |
| | | orderService.updateById(order); |
| | | // 转账成功 |
| | | //保存转账明细 |
| | | WithdrawDetail withdrawDetail = new WithdrawDetail(); |
| | | withdrawDetail.setWithdrawId(withdrawId); |
| | | withdrawDetail.setMoney(transferAmount); |
| | | withdrawDetail.setOutBatchNo((String) postMap.get(WechatConstants.OUT_BATCH_NO)); |
| | | withdrawDetail.setOutBatchNo(postMap.get("out_bill_no")+""); |
| | | withdrawDetailService.save(withdrawDetail); |
| | | |
| | | |
| | |
| | | allTransfersSuccessful = false; |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | return allTransfersSuccessful; |