From 40965cea50fc7f50ab06f7472cf3aa3d32985a25 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期日, 23 三月 2025 15:06:46 +0800 Subject: [PATCH] 冥想 --- xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 105 insertions(+), 0 deletions(-) diff --git a/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java b/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java index 0e6e7d2..adacb14 100644 --- a/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java +++ b/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java @@ -110,6 +110,15 @@ JSONObject jsonObject = JuHeFuUtil.queryPayment(orderId); return R.ok(jsonObject.getString("status")); } + @GetMapping("/getMeditationIsBuyAll/{id}") + public R<List<Order>> getMeditationIsBuyAll(@PathVariable("id")Long id) { + List<Order> list = orderService.lambdaQuery() + .eq(Order::getAppUserId, id) + .eq(Order::getOrderFrom, 1) + .eq(Order::getPaymentStatus, 2) + .ne(Order::getRefundStatus, 3).list(); + return R.ok(list); + } @GetMapping("/getMeditationIsBuy/{id}/{meditationId}") public R<Integer> getMeditationIsBuy(@PathVariable("id")Long id,@PathVariable("meditationId")Long meditationId) { List<Order> list = orderService.lambdaQuery().eq(Order::getBusinessId, meditationId) @@ -123,6 +132,7 @@ return R.ok(1); } } + @PostMapping("/payOrder") @ApiOperation(value = "已购详情-待支付状态-页面数据",tags = "我的已购") @ApiImplicitParams({ @@ -471,6 +481,101 @@ return R.ok(); } + /** + * 处理苹果退款 回调通知 + * @param request + * @param response + */ + @ResponseBody + @PostMapping("/refundApple") + public void refundApple(HttpServletRequest request, HttpServletResponse response) { + try { + System.err.println("请求"+request); + BufferedReader reader = request.getReader(); + String string1 = reader.toString(); + System.err.println("请求reader"+string1); + StringBuilder requestBody = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + requestBody.append(line); + } + System.err.println("全部请求体"+requestBody); + org.json.JSONObject jsonObject1 = new org.json.JSONObject(requestBody.toString()); + System.err.println("json串"+jsonObject1); + String o = jsonObject1.getString("signedPayload"); + com.alibaba.fastjson.JSONObject payload = verifyAndGet(o); + String notificationType = payload.get("notificationType").toString(); + + com.alibaba.fastjson.JSONObject data = payload.getJSONObject("data"); + String signedTransactionInfo = data.get("signedTransactionInfo").toString(); + com.alibaba.fastjson.JSONObject transactionInfo = verifyAndGet(signedTransactionInfo); + System.err.println("解签后的json串"+transactionInfo); + System.err.println("data"+data); + // 苹果流水号 + String string = transactionInfo.getString("originalTransactionId"); + OrderPaymentRecord one = orderPaymentRecordService.getOne(new QueryWrapper<OrderPaymentRecord>() + .eq("pay_order_no", string) + .eq("payment_type", 3)); + Order order = orderService.getById(one.getOrderId()); + + if (one!=null && one.getPaymentStatus() == 2){ + one.setPaymentStatus(3); + + switch (order.getOrderFrom()){ + case 1: + // 冥想订单 删除 + break; + case 2: + // 删除用户与课程的关系表 + remoteAppUserService.deleteAppUserCourse(order.getBusinessId(),order.getAppUserId()); + break; + case 3: + // 会员订单 将用户会员到期时间回退 + if (order.getBuyContent().contains("月")){ + remoteAppUserService.subVipExpireTime(order.getAppUserId(),1); + }else if (order.getBuyContent().contains("季")){ + remoteAppUserService.subVipExpireTime(order.getAppUserId(),2); + }else if (order.getBuyContent().contains("年")){ + remoteAppUserService.subVipExpireTime(order.getAppUserId(),3); + } + break; + } + // 内购+余额支付 需要退回余额 并删除余额支付记录 + if (order.getPayType() == 7){ + // 查询余额支付 + OrderPaymentRecord two = orderPaymentRecordService.getOne(new QueryWrapper<OrderPaymentRecord>() + .eq("order_id", order.getId()) + .eq("payment_type", 4) + .eq("payment_status", 2) + ); + two.setPaymentStatus(3); + orderPaymentRecordService.updateById(two); + AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord(); + appUserWalletRecord.setAppUserId(order.getAppUserId()); + appUserWalletRecord.setChangeType(1); + appUserWalletRecord.setReason("后台退款"); + appUserWalletRecord.setOrderId(order.getId()); + appUserWalletRecord.setAmount(two.getPayAmount()); + remoteAppUserService.addBalanceRecord(appUserWalletRecord); + remoteAppUserService.addBalance(order.getAppUserId(),two.getPayAmount()); + } + order.setRefundStatus(3); + order.setRefundRemark("后台退款"); + order.setRefundTime(LocalDateTime.now()); + order.setPaymentStatus(3); + order.setCancelTime(LocalDateTime.now()); + orderPaymentRecordService.updateById(one); + orderService.updateById(order); + } + System.err.println("苹果流水号"+string); + PrintWriter out = response.getWriter(); + out.write("success"); + out.flush(); + out.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } private static final TrustManager myX509TrustManager = new X509TrustManager() { @Override public X509Certificate[] getAcceptedIssuers() { -- Gitblit v1.7.1