| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.core.constant.WechatConstants; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.vo.UserDto; |
| | | import com.ruoyi.order.entity.Order; |
| | | import com.ruoyi.order.entity.Withdraw; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | |
| | | |
| | | /** |
| | |
| | | @Scheduled(fixedRate = 1000 * 3600) |
| | | public void taskMinute(){ |
| | | try { |
| | | List<Withdraw> list1 = withdrawService.list(); |
| | | List<Withdraw> list1 = withdrawService.lambdaQuery().eq(Withdraw::getId,"1938794177477832705").list(); |
| | | List<WithdrawDetail> list = withdrawDetailService.lambdaQuery() |
| | | .isNotNull(WithdrawDetail::getOutBatchNo).ne(WithdrawDetail::getStatus, "SUCCESS").list(); |
| | | |
| | |
| | | orderService.updateById(order); |
| | | withdrawDetail.setStatus("SUCCESS"); |
| | | withdrawDetailService.updateById(withdrawDetail); |
| | | } else if (s.equals("FAIL")||s.equals("CANCELING")||s.equals("CANCELLED")) { |
| | | } else if (string.equals("FAIL")||string.equals("CANCELING")||string.equals("CANCELLED")) { |
| | | // 重新发起一笔转账 |
| | | withdrawDetail.setStatus("FAIL"); |
| | | withdrawDetailService.updateById(withdrawDetail); |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean weChatPay(BigDecimal orderMoney, String openId, String withdrawId, String serverName) { |
| | | private boolean weChatPay(BigDecimal orderMoney, String openId,String withdrawId,String serverName) { |
| | | if (com.ruoyi.common.core.utils.StringUtils.isBlank(openId)) { |
| | | return false; |
| | | } |
| | |
| | | Map<String, Object> postMap = new HashMap<>(8); |
| | | postMap.put(WechatConstants.APP_ID, "wx98563d0ec9cf21c8"); |
| | | // 订单号 |
| | | String s = String.valueOf(UUID.randomUUID()).replaceAll("-", ""); |
| | | postMap.put("out_bill_no", s); |
| | | 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> info = new HashMap<>(); |
| | | info.put("info_type","回收商品名称"); |
| | | info.put("info_content",serverName); |
| | | postMap.put("transfer_scene_report_infos", com.alibaba.fastjson2.JSONObject.toJSONString(info)); |
| | | list.add(info); |
| | | postMap.put("transfer_scene_report_infos", list); |
| | | String result = HttpUtil.postTransBatRequest( |
| | | WechatConstants.WE_CHAT_PAY_URL_PRE, |
| | | com.alibaba.fastjson2.JSONObject.toJSONString(postMap), |
| | |
| | | // 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 = withdrawService.getById(withdrawId); |
| | | WithdrawDetail one = withdrawDetailService.lambdaQuery().eq(WithdrawDetail::getWithdrawId, withdrawId).last("limit 1").one(); |
| | | if (one!=null){ |
| | | one.setOutBatchNo(s); |
| | | |
| | | Order order = orderService.getById(withdraw.getOrderId()); |
| | | order.setIsWithdrawal(2); |
| | | order.setPackageInfo(string); |
| | | orderService.updateById(order); |
| | | // 转账成功 |
| | | //保存转账明细 |
| | | WithdrawDetail one = withdrawDetailService.lambdaQuery().eq(WithdrawDetail::getWithdrawId, withdrawId).last("limit 1") |
| | | .one(); |
| | | if(one!=null){ |
| | | one.setOutBatchNo(postMap.get("out_bill_no")+""); |
| | | one.setStatus("PENDING"); |
| | | withdrawDetailService.updateById(one); |
| | | Order order = orderService.getById(withdraw.getOrderId()); |
| | | order.setPackageInfo(string); |
| | | order.setIsWithdrawal(2); |
| | | orderService.updateById(order); |
| | | withdrawDetailService.updateById( one); |
| | | }else{ |
| | | WithdrawDetail withdrawDetail = new WithdrawDetail(); |
| | | withdrawDetail.setWithdrawId(withdrawId); |
| | | withdrawDetail.setMoney(transferAmount); |
| | | withdrawDetail.setOutBatchNo(postMap.get("out_bill_no")+""); |
| | | withdrawDetailService.save(withdrawDetail); |
| | | } |
| | | |
| | | } else { |
| | | allTransfersSuccessful = false; |
| | | break; |
| | | throw new GlobalException("提现失败,失败原因:"+jsonObject.getString("message")); |
| | | // allTransfersSuccessful = false; |
| | | // break; |
| | | } |
| | | |
| | | } |
| | | |
| | | return allTransfersSuccessful; |
| | | } |
| | | |