From b1fb83530b7105e4aa73e4101727dea945eb01c2 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 29 八月 2025 21:48:15 +0800
Subject: [PATCH] bug修改
---
cloud-server-account/src/main/java/com/dsh/account/controller/UseBenefitsController.java | 126 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 119 insertions(+), 7 deletions(-)
diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/UseBenefitsController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/UseBenefitsController.java
index d3347a1..f22844f 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/controller/UseBenefitsController.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/controller/UseBenefitsController.java
@@ -1,6 +1,7 @@
package com.dsh.account.controller;
+import com.alibaba.fastjson.JSONObject;
import com.dsh.account.entity.TAppUser;
import com.dsh.account.feignclient.activity.model.IntegralCommodity;
import com.dsh.account.feignclient.other.SysLogClient;
@@ -8,9 +9,12 @@
import com.dsh.account.service.RechargeRecordsService;
import com.dsh.account.service.TAppUserService;
import com.dsh.account.service.UserIntegralChangesService;
+import com.dsh.account.util.PayMoneyUtil;
import com.dsh.account.util.ResultUtil;
import com.dsh.account.util.TokenUtil;
import com.dsh.account.util.ToolUtil;
+import com.dsh.account.util.wx.WxV3PayConfig;
+import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@@ -20,8 +24,13 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.List;
+import java.util.Map;
/**
* 使用福利 控制器
@@ -49,10 +58,15 @@
private final SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
+ @Autowired
+ private PayMoneyUtil payMoneyUtil;
+ @Autowired
+ private TAppUserService appUserService;
+
@ResponseBody
@PostMapping("/api/useBenefit/indexOfAppUser")
- @ApiOperation(value = "福利主页", tags = {"APP-使用福利"})
+ @ApiOperation(value = "福利主页【2.0】", tags = {"APP-使用福利"})
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
@ApiImplicitParam(name = "lat", value = "经度", dataType = "string"),
@@ -70,6 +84,15 @@
commodities = commodities.subList(0, 5);
}
indexOfUserBenefirVo.setCommodities(commodities);
+ TAppUser byId = appUserService.getById(appUserId);
+ if (byId.getIsVip()!=null && byId.getIsVip()==1){
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ if (byId.getVipEndTime().getTime() > System.currentTimeMillis()) {
+ indexOfUserBenefirVo.setVipEndTime(simpleDateFormat.format(byId.getVipEndTime()));
+ } else {
+ indexOfUserBenefirVo.setVipEndTime("");
+ }
+ }
return ResultUtil.success(indexOfUserBenefirVo);
} catch (Exception e) {
e.printStackTrace();
@@ -307,12 +330,7 @@
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
})
public ResultUtil<List<Goods>> pointsMallList(MallRequest request) {
-// try {
- System.out.println("======request========" + request);
return ResultUtil.success(tauService.queryAppUserIntegral(request));
-// }catch (Exception e){
-// return ResultUtil.runErr();
-// }
}
@@ -407,7 +425,7 @@
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
})
- public synchronized ResultUtil productRedemptionOperation(GoodsExchangeVo exchangeType) {
+ public ResultUtil productRedemptionOperation(GoodsExchangeVo exchangeType) {
try {
Integer userIdFormRedis = tokenUtil.getUserIdFormRedis();
if (null == userIdFormRedis) {
@@ -421,6 +439,100 @@
/**
+ * V3版本回调
+ * @param request
+ * @param response
+ */
+ @ResponseBody
+ @PostMapping("/base/coupon/weChatPaymentCouponCallback1")
+ public void weChatPaymentCouponCallback1(HttpServletRequest request, HttpServletResponse response){
+ try {
+ System.err.println("微信回调");
+ 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);
+ JSONObject jsonObject = JSONObject.parseObject(requestBody.toString());
+ JSONObject resource = jsonObject.getJSONObject("resource");
+
+ AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8));
+ String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8),
+ resource.getString("ciphertext"));
+ System.err.println("微信解密的字符串信息" + decryptedData);
+ JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData);
+ String code = jsonInfo.getString("out_trade_no");
+ String trade_no = jsonInfo.getString("transaction_id");
+ String trade_state = jsonInfo.getString("trade_state");
+ if (trade_state.equals("SUCCESS")) {
+ ResultUtil resultUtil = tauService.paymentCouponCallback(code, trade_no);
+ if(resultUtil.getCode() == 200){
+ PrintWriter out = response.getWriter();
+ out.print("SUCCESS");
+ out.flush();
+ out.close();
+ }
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @ResponseBody
+ @PostMapping("/base/coupon/weChatPaymentCouponCallback")
+ public void weChatPaymentCouponCallback(HttpServletRequest request, HttpServletResponse response){
+ try {
+ Map<String, String> map = payMoneyUtil.weixinpayCallback(request);
+ if(null != map){
+ String code = map.get("out_trade_no");
+ String trade_no = map.get("transaction_id");
+ String result = map.get("result");
+ ResultUtil resultUtil = tauService.paymentCouponCallback(code, trade_no);
+ if(resultUtil.getCode() == 200){
+ PrintWriter out = response.getWriter();
+ out.print(result);
+ out.flush();
+ out.close();
+ }
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @ResponseBody
+ @PostMapping("/base/coupon/aliPaymentCouponCallback")
+ public void aliPaymentCouponCallback(HttpServletRequest request, HttpServletResponse response){
+ try {
+ Map<String, String> map = payMoneyUtil.alipayCallback(request);
+ if(null != map){
+ String code = map.get("out_trade_no");
+ String trade_no = map.get("trade_no");
+ ResultUtil resultUtil = tauService.paymentCouponCallback(code, trade_no);
+ if(resultUtil.getCode() == 200){
+ PrintWriter out = response.getWriter();
+ out.print("success");
+ out.flush();
+ out.close();
+ }
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+
+
+
+
+
+
+ /**
* 积分明细
*/
@ResponseBody
--
Gitblit v1.7.1