From 73b750200f25df08aa64124da49e7461f9de6653 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 13 十二月 2024 15:09:49 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/NTTravel

---
 UserNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 112 insertions(+), 1 deletions(-)

diff --git a/UserNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java b/UserNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
index 7fe2a3d..7e086e7 100644
--- a/UserNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
+++ b/UserNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -10,6 +10,8 @@
 import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
 import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
 import com.stylefeng.guns.modular.system.model.Driver;
+import com.stylefeng.guns.modular.system.model.TActivityGeneralization;
+import com.stylefeng.guns.modular.system.model.UserCouponRecord;
 import com.stylefeng.guns.modular.system.model.UserInfo;
 import com.stylefeng.guns.modular.system.service.*;
 import com.stylefeng.guns.modular.system.util.*;
@@ -267,7 +269,7 @@
                 Map<String, Object> map = new HashMap<>();
                 map.put("money", transactionDetails1.getMoney());
                 map.put("time", sdf.format(transactionDetails1.getInsertTime()));
-                map.put("name", transactionDetails1.getOrderType() == 3 ? "直通车订单取消退款" : transactionDetails1.getOrderType() == 4 ? "小件物流订单取消退款" : "");
+                map.put("name", transactionDetails1.getOrderType() == 3 ? "跨城订单取消退款" : transactionDetails1.getOrderType() == 4 ? "小件物流订单取消退款" : "");
                 map.put("insertTime", Double.valueOf(transactionDetails1.getInsertTime().getTime() / 1000).intValue());
                 list4.add(map);
             }
@@ -1008,6 +1010,8 @@
         }
     }
 
+    @Autowired
+    private IUserCouponRecordService userCouponRecordService;
 
 
     /**
@@ -1049,6 +1053,50 @@
                     list = orderTransferService.queryCoupon(orderId, uid, pageNum, size);
                     break;
             }
+            //将activityType=5的数据进行处理
+
+//            List<Integer> ids = new ArrayList<>();
+
+//            if (list != null && list.size() > 0) {
+//                Map<Object, Integer> couponIdMonthlyCount = new HashMap<>(); // 用来统计每个月各couponId的出现次数
+//                Date currentDate = new Date(); // 获取当前日期
+//                Calendar cal = Calendar.getInstance();
+//                cal.setTime(currentDate);
+//                int currentMonth = cal.get(Calendar.MONTH) + 1; // 获取当前月份(注意Calendar.MONTH是从0开始的)
+//
+//                // 首先,统计每个月各couponId的出现次数
+//                for (Map<String, Object> map : list) {
+//                    if (map.get("activityType").equals(5)) {
+//                        for (UserCouponRecord userCouponRecord : userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("couponId", map.get("couponId")))) {
+//                            Date endTime = userCouponRecord.getEndTime();
+//                            Calendar recordCal = Calendar.getInstance();
+//                            if (endTime==null){
+//                                continue;
+//                            }
+//                            recordCal.setTime(endTime);
+//                            int recordMonth = recordCal.get(Calendar.MONTH) + 1;
+//
+//                            if (recordMonth == currentMonth) {
+//                                Object couponId = map.get("couponId");
+//                                couponIdMonthlyCount.put(couponId, couponIdMonthlyCount.getOrDefault(couponId, 0) + 1);
+//                            }
+//                        }
+//                    }
+//                }
+//
+//                // 然后,根据统计结果移除当月数量超过1的couponId对应的记录
+//                List<Map<String, Object>> newList = new ArrayList<>();
+//                for (Map<String, Object> map : list) {
+//                    Object couponId = map.get("couponId");
+//                    if (!couponIdMonthlyCount.containsKey(couponId) || couponIdMonthlyCount.get(couponId) <= 1) {
+//                        newList.add(map);
+//                    }
+//                }
+//                list.clear();
+//                list.addAll(newList);
+//            }
+
+
             return ResultUtil.success(CouponWarpper.getCouponWarppers(list));
         }catch (Exception e){
             e.printStackTrace();
@@ -1056,6 +1104,69 @@
         }
     }
 
+    @Autowired
+    private ITActivityGeneralizationService activityGeneralizationService;
+    @ResponseBody
+    @PostMapping("/api/taxi/check")
+    @ApiOperation(value = "判断是否到到当月限额", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城","用户端-接送机"}, notes = "")
+    @ApiImplicitParams({
+            @ApiImplicitParam(value = "id", name = "id", required = true, dataType = "int"),
+            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
+    })
+    public ResultUtil check(Integer id,HttpServletRequest request){
+        try {
+            Integer uid = userInfoService.getUserIdFormRedis(request);
+            if(null == uid){
+                return ResultUtil.tokenErr();
+            }
+            // 查询当前活动的限制数量
+            UserCouponRecord userCouponRecords1 = userCouponRecordService.selectById(id);
+
+            List<UserCouponRecord> userCouponRecords = userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("couponId", userCouponRecords1.getCouponId()));
+
+            // 获取活动限制数量
+            TActivityGeneralization tActivityGeneralization = activityGeneralizationService.selectById(userCouponRecords.get(0).getCouponActivityId());
+            if (tActivityGeneralization == null) {
+                throw new RuntimeException("未能找到对应的活动信息");
+            }
+            int limitQuantity = tActivityGeneralization.getMonthUseCount(); // 假设limitQuantity字段代表限制数量
+
+            // 判断当月的优惠券是否超过限制
+            Calendar currentCal = Calendar.getInstance();
+            int currentMonth = currentCal.get(Calendar.MONTH) + 1; // 当前月份
+
+            // 统计当月的优惠券使用数量
+            int usedThisMonth = 0;
+            for (UserCouponRecord record : userCouponRecords) {
+                if (record.getEndTime()==null){
+                    continue;
+                }
+                Calendar recordCal = Calendar.getInstance();
+                recordCal.setTime(record.getEndTime());
+                int recordMonth = recordCal.get(Calendar.MONTH) + 1;
+
+                // 判断endTime是否在当月
+                if (recordMonth == currentMonth) {
+                    usedThisMonth++;
+                }
+            }
+
+            // 判断是否超过限制
+            if (usedThisMonth >= limitQuantity) {
+                return ResultUtil.error("本月使用数量已经超出限制");
+                // 这里可以添加更多的逻辑处理,比如抛出异常、记录日志等
+            } else {
+                return ResultUtil.success();
+            }
+
+
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultUtil.runErr();
+        }
+    }
+
+
 
 
 

--
Gitblit v1.7.1