From 572df690f72ed4a077d934823f261dec39b3cc7d Mon Sep 17 00:00:00 2001
From: 刘帅 <rr.iii@qq.com>
Date: 星期二, 08 九月 2026 17:11:34 +0800
Subject: [PATCH] feat&bug:文档内容修改

---
 cloud-server-activity/src/main/java/com/dsh/activity/controller/HuiminController.java |  169 +++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 142 insertions(+), 27 deletions(-)

diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/HuiminController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/HuiminController.java
index 78f5e2d..760a91e 100644
--- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/HuiminController.java
+++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/HuiminController.java
@@ -7,6 +7,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.dsh.activity.entity.*;
+import com.dsh.activity.enums.HuiminCardPaymentTypeEnum;
 import com.dsh.activity.feignclient.account.AppUserClient;
 import com.dsh.activity.feignclient.account.CityClient;
 import com.dsh.activity.feignclient.account.StoreStaffClient;
@@ -28,6 +29,7 @@
 import com.dsh.activity.model.response.*;
 import com.dsh.activity.service.*;
 import com.dsh.activity.util.*;
+import com.dsh.activity.util.wx.WxV3PayConfig;
 import com.google.gson.Gson;
 import io.swagger.annotations.*;
 import io.swagger.models.auth.In;
@@ -84,6 +86,7 @@
     @Autowired
     private TokenUtil tokenUtil;
     private String smid = "2088330203191220";//平台支付宝商户号
+
 
 
     /**
@@ -157,10 +160,20 @@
             System.err.println("支付数据" + tPayHuimin);
             payHuiminService.save(tPayHuimin);
             BigDecimal bigDecimal = new BigDecimal(studentIds.split(",").length);
+            if (tPayHuimin.getSalesMoney().compareTo(BigDecimal.ZERO)==0){
+                // 零元购
+                tPayHuimin.setStatus(2);
+                tPayHuimin.setPaymentTime(new Date());
+                payHuiminService.updateById(tPayHuimin);
+                return ResultUtil.success();
+            }
             switch (payType) {
                 case 1:
-                    return payMoneyUtil.weixinpay("购买玩湃惠民卡" + "-" + 0, "", tPayHuimin.getCode(), tPayHuimin.getSalesMoney().toString(),
+                    // todo 惠民卡收入属于平台商户 定死
+                    return payMoneyUtil.weixinpay("购买玩湃惠民卡", "", tPayHuimin.getCode(), tPayHuimin.getSalesMoney().toString(),
                             "/base/huimin/callBack/weixinPayHuiminCallback", "APP", "");
+//                return payMoneyUtil.weixinpayV3("1720719391","购买玩湃惠民卡",tPayHuimin.getCode(),
+//                        "/base/huimin/callBack/weixinPayHuiminCallback1",tPayHuimin.getSalesMoney().toString());
                 case 2:
                     String string = tPayHuimin.getSalesMoney().toString();
                     return payMoneyUtil.alipay(smid, "购买玩湃惠民卡", "购买玩湃惠民卡", "", tPayHuimin.getCode(), string,
@@ -269,6 +282,7 @@
             if (null == uid) {
                 return ResultUtil.tokenErr();
             }
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             HuiminAgreementVO huiminAgreementVO = new HuiminAgreementVO();
             List<THuiminCard> cardList = huiminCardService.getHuiminAgreementAndList(pageNo, pageSize, storeId);
             List<THuiminCard> list = huiminCardService.list();
@@ -376,17 +390,39 @@
                                 Date start = DateUtil.parse(s1, "yyyy-MM-dd HH:mm:ss");
                                 Date end = DateUtil.parse(e1, "yyyy-MM-dd HH:mm:ss");
                                 if (new Date().after(start) && new Date().before(end)) {
-//                                    jsonObject2.put("start_time", start.getTime() / 1000);
+//                                    
                                     Date date1 = new Date();
-                                    jsonObject2.put("start_time", date1.getTime() / 1000);
+                                    jsonObject2.put("start_time", date1.getTime()/ 1000);
                                     date1.setTime(date1.getTime() + 30 * 1000);
                                     if (start.before(end)) {
-                                        jsonObject2.put("end_time", date1.getTime() / 1000);
+                                        jsonObject2.put("end_time", date1.getTime()/ 1000);
                                         jsonArray.add(jsonObject2);
                                     }
                                 }
                             }
                         }
+                        if (jsonArray.isEmpty()){
+                            // 返回过期的二维码 保证开门失败即可
+                            JSONObject jsonObject3 = new JSONObject();
+                            Date date1 = new Date();
+                            date1.setTime(date1.getTime() - 300 * 1000);
+                            jsonObject3.put("end_time", date1.getTime()/ 1000);
+                            jsonObject3.put("start_time", date1.getTime()/ 1000);
+
+                            jsonArray.add(jsonObject3);
+                        }
+                    }
+                }
+                else{
+                    if (jsonArray.isEmpty()){
+                        // 返回过期的二维码 保证开门失败即可
+                        JSONObject jsonObject3 = new JSONObject();
+                        Date date1 = new Date();
+                        date1.setTime(date1.getTime() - 300 * 1000);
+                        jsonObject3.put("end_time", date1.getTime()/ 1000);
+                        jsonObject3.put("start_time", date1.getTime()/ 1000);
+
+                        jsonArray.add(jsonObject3);
                     }
                 }
                 if (!jsonArray.isEmpty()) {
@@ -394,9 +430,17 @@
                     TStudent tStudent = tStudents.stream().filter(e -> e.getId().equals(Integer.valueOf(payHuimin.getStudentId().split(",")[0]))).findFirst().orElse(null);
                     if (tStudent!=null){
                         huiminCardVO1.setStudentName(tStudent.getName());
+//                        String temp = "{\"id\":"+payHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tStudent.getId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + ",\"codeType\":"+4+"\"dataId\":"+payHuimin.getId()+"}";
+                        String temp = "{\"id\":"+payHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tStudent.getId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 +"}";
+                        huiminCardVO1.setQrCode(temp);
+
+                    }else{
+                        huiminCardVO1.setStudentName("");
+
+//                        String temp = "{\"id\":"+payHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + 0 + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + ",\"codeType\":"+4+"\"dataId\":"+payHuimin.getId()+"}";
+                        String temp = "{\"id\":"+payHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + 0 + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 +"}";
+                        huiminCardVO1.setQrCode(temp);
                     }
-                    String temp = "{\"id\":"+payHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + payHuimin.getStudentId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}";
-                    huiminCardVO1.setQrCode(temp);
                     huiminCardVOS.add(huiminCardVO1);
                     integers.add(payHuimin.getCardId());
 
@@ -465,6 +509,7 @@
             if (null == uid) {
                 return ResultUtil.tokenErr();
             }
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             List<TPayHuimin> payHuimins = payHuiminService.list(new LambdaQueryWrapper<TPayHuimin>()
                     .eq(TPayHuimin::getAppUserId, uid)
                     .eq(TPayHuimin::getCardId, id)
@@ -520,17 +565,38 @@
                                     Date start = DateUtil.parse(s1, "yyyy-MM-dd HH:mm:ss");
                                     Date end = DateUtil.parse(e1, "yyyy-MM-dd HH:mm:ss");
                                     if (new Date().after(start) && new Date().before(end)) {
-//                                    jsonObject2.put("start_time", start.getTime() / 1000);
+//
                                         Date date1 = new Date();
-                                        jsonObject2.put("start_time", date1.getTime() / 1000);
+                                        jsonObject2.put("start_time", date1.getTime()/ 1000);
                                         date1.setTime(date1.getTime() + 30 * 1000);
                                         if (start.before(end)) {
-                                            jsonObject2.put("end_time", date1.getTime() / 1000);
+                                            jsonObject2.put("end_time", date1.getTime()/ 1000);
                                             jsonArray.add(jsonObject2);
                                         }
                                     }
                                 }
                             }
+                            if (jsonArray.isEmpty()){
+                                // 返回过期的二维码 保证开门失败即可
+                                JSONObject jsonObject3 = new JSONObject();
+                                Date date1 = new Date();
+                                date1.setTime(date1.getTime() - 300 * 1000);
+                                jsonObject3.put("end_time", date1.getTime()/ 1000);
+                                jsonObject3.put("start_time", date1.getTime()/ 1000);
+
+                                jsonArray.add(jsonObject3);
+                            }
+                        }
+                    }else{
+                        if (jsonArray.isEmpty()){
+                            // 返回过期的二维码 保证开门失败即可
+                            JSONObject jsonObject3 = new JSONObject();
+                            Date date1 = new Date();
+                            date1.setTime(date1.getTime() - 300 * 1000);
+                            jsonObject3.put("end_time", date1.getTime()/ 1000);
+                            jsonObject3.put("start_time", date1.getTime()/ 1000);
+
+                            jsonArray.add(jsonObject3);
                         }
                     }
                     if (!jsonArray.isEmpty()) {
@@ -567,6 +633,7 @@
             if (null == uid) {
                 return ResultUtil.tokenErr();
             }
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             List<TStudent> tStudents = studentClient.queryStudentList(uid);
 
             List<TPayHuimin> payHuimins = payHuiminService.list(new LambdaQueryWrapper<TPayHuimin>()
@@ -628,29 +695,56 @@
                                 // 转化为Date类型
                                 Date start = DateUtil.parse(s1, "yyyy-MM-dd HH:mm:ss");
                                 Date end = DateUtil.parse(e1, "yyyy-MM-dd HH:mm:ss");
-                                jsonObject2.put("start_time", start.getTime() / 1000);
+                                
                                 start.setTime(start.getTime() + 30 * 1000);
                                 if (new Date().after(start) && new Date().before(end)) {
-//                                    jsonObject2.put("start_time", start.getTime() / 1000);
+//                                    
                                     Date date1 = new Date();
-                                    jsonObject2.put("start_time", date1.getTime() / 1000);
+                                    jsonObject2.put("start_time", date1.getTime()/ 1000);
                                     date1.setTime(date1.getTime() + 30 * 1000);
                                     if (start.before(end)) {
-                                        jsonObject2.put("end_time", date1.getTime() / 1000);
+                                        jsonObject2.put("end_time", date1.getTime()/ 1000);
                                         jsonArray.add(jsonObject2);
                                     }
                                 }
                             }
                         }
+                        if (jsonArray.isEmpty()){
+                            // 返回过期的二维码 保证开门失败即可
+                            JSONObject jsonObject3 = new JSONObject();
+                            Date date1 = new Date();
+                            date1.setTime(date1.getTime() - 300 * 1000);
+                            jsonObject3.put("end_time", date1.getTime()/ 1000);
+                            jsonObject3.put("start_time", date1.getTime()/ 1000);
+
+                            jsonArray.add(jsonObject3);
+                        }
+                    }
+                }else{
+                    if (jsonArray.isEmpty()){
+                        // 返回过期的二维码 保证开门失败即可
+                        JSONObject jsonObject3 = new JSONObject();
+                        Date date1 = new Date();
+                        date1.setTime(date1.getTime() - 300 * 1000);
+                        jsonObject3.put("end_time", date1.getTime()/ 1000);
+                        jsonObject3.put("start_time", date1.getTime()/ 1000);
+
+                        jsonArray.add(jsonObject3);
                     }
                 }
-
-                String temp = "{\"id\":"+tPayHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tPayHuimin.getStudentId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}";
-                huiminCardStudentVO.setQrCode(temp);
                 TStudent tStudent = tStudents.stream().filter(e -> e.getId().equals(studentId)).findFirst().orElse(null);
                 if (tStudent!=null){
                     huiminCardStudentVO.setStudentName(tStudent.getName());
+//                    String temp = "{\"id\":"+tPayHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tStudent.getId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + ",\"codeType\":"+4+"\"dataId\":"+tPayHuimin.getId()+"}";
+                    String temp = "{\"id\":"+tPayHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tStudent.getId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 +"}";
+                    huiminCardStudentVO.setQrCode(temp);
+                }else{
+                    huiminCardStudentVO.setStudentName("");
+//                    String temp = "{\"id\":"+tPayHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + 0 + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + ",\"codeType\":"+4+"\"dataId\":"+tPayHuimin.getId()+"}";
+                    String temp = "{\"id\":"+tPayHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + 0 + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 +"}";
+                    huiminCardStudentVO.setQrCode(temp);
                 }
+
             }
 
 
@@ -741,14 +835,11 @@
                 return ResultUtil.tokenErr();
             }
             TPayHuimin tPayHuimin = payHuiminService.getById(id);
-            if (tPayHuimin.getPaymentType()==3){
-                // 后台录入直接退款
-                tPayHuimin.setStatus(3);
-                payHuiminService.updateById(tPayHuimin);
-                return ResultUtil.success();
-            }
             if (tPayHuimin == null) {
                 return ResultUtil.error("订单不存在");
+            }
+            if (HuiminCardPaymentTypeEnum.isGift(tPayHuimin.getPaymentType())){
+                return ResultUtil.error("赠送惠民卡不允许退款");
             }
             if (tPayHuimin.getStatus() == 3 && tPayHuimin.getRefundStatus() != 1) {
                 return ResultUtil.error("不可重复退款");
@@ -820,6 +911,7 @@
             if (tPayHuimin == null) {
                 return ResultUtil.error("玩湃惠民卡不存在");
             }
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             THuiminCard byId = huiminCardService.getById(tPayHuimin.getCardId());
             MyHuiminCardDetailVO myHuiminCardDetailVO = new MyHuiminCardDetailVO();
             List<TStudent> studentByIds1 = studentClient.getStudentByIds(tPayHuimin.getStudentId());
@@ -870,24 +962,46 @@
                             // 转化为Date类型
                             Date start = DateUtil.parse(s1, "yyyy-MM-dd HH:mm:ss");
                             Date end = DateUtil.parse(e1, "yyyy-MM-dd HH:mm:ss");
-                            jsonObject2.put("start_time", start.getTime() / 1000);
+                            
                             start.setTime(start.getTime() + 30 * 1000);
                             if (new Date().after(start) && new Date().before(end)) {
-//                                    jsonObject2.put("start_time", start.getTime() / 1000);
+//                                    
                                 Date date1 = new Date();
-                                jsonObject2.put("start_time", date1.getTime() / 1000);
+                                jsonObject2.put("start_time", date1.getTime()/ 1000);
                                 date1.setTime(date1.getTime() + 30 * 1000);
                                 if (start.before(end)) {
-                                    jsonObject2.put("end_time", date1.getTime() / 1000);
+                                    jsonObject2.put("end_time", date1.getTime()/ 1000);
                                     jsonArray.add(jsonObject2);
                                 }
                             }
                         }
                     }
+                    if (jsonArray.isEmpty()){
+                        // 返回过期的二维码 保证开门失败即可
+                        JSONObject jsonObject3 = new JSONObject();
+                        Date date1 = new Date();
+                        date1.setTime(date1.getTime() - 300 * 1000);
+                        jsonObject3.put("end_time", date1.getTime()/ 1000);
+                        jsonObject3.put("start_time", date1.getTime()/ 1000);
+
+                        jsonArray.add(jsonObject3);
+                    }
+                }
+            }else{
+                if (jsonArray.isEmpty()){
+                    // 返回过期的二维码 保证开门失败即可
+                    JSONObject jsonObject3 = new JSONObject();
+                    Date date1 = new Date();
+                    date1.setTime(date1.getTime() - 300 * 1000);
+                    jsonObject3.put("end_time", date1.getTime()/ 1000);
+                    jsonObject3.put("start_time", date1.getTime()/ 1000);
+
+                    jsonArray.add(jsonObject3);
                 }
             }
 
-            String temp = "{\"id\":"+tPayHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tPayHuimin.getStudentId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}";
+//            String temp = "{\"id\":"+tPayHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tPayHuimin.getStudentId().split(",")[0] + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + ",\"codeType\":"+4+"\"dataId\":"+tPayHuimin.getId()+"}";
+            String temp = "{\"id\":"+tPayHuimin.getId()  + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tPayHuimin.getStudentId().split(",")[0] + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 +"}";
             myHuiminCardDetailVO.setQrCode(temp);
             myHuiminCardDetailVO.setCardId(tPayHuimin.getCardId());
             myHuiminCardDetailVO.setHuiminCard(byId);
@@ -903,6 +1017,7 @@
         }
     }
 
+
     /**
      * 获取添加人员、选择人员说明文案
      */

--
Gitblit v1.7.1