xixi178 преди 1 година
родител
ревизия
b4c073d21c

+ 0 - 73
.drone.yml

@@ -1,73 +0,0 @@
-kind: pipeline
-type: docker
-name: pipeline-example-maven
-
-trigger:
-  branch:
-    - develop
-
-clone:
-  disable: true # 禁用自带的clone
-
-  # clone代码
-steps:
-  - name: clone
-    image: alpine/git
-    volumes: # 将容器内目录挂载到宿主机,仓库需要开启Trusted设置
-      - name: host-mount
-        path: /data # 将maven下载依赖的目录挂载出来,防止重复下载
-    commands:
-      - git clone http://124.222.247.184:3000/root/courtBooking.git
-      # 把这里改成了自己的仓库地址
-      # http://124.222.247.184:3000/wteamYD/promotesai-background.git .
-      - git checkout develop
-      - cp *.sh /data
-    when:
-      event:
-        - push # 当代码 push 时才重新拉取
-
-  # 传输shell脚本到目标主机
-  - name: scp files
-    image: ryjer/drone-scp
-    volumes: #将主机的shell脚本与容器共享
-      - name: host-mount
-        path: /data
-    settings:
-      host: 42.194.177.220
-      username: root
-      password:
-        from_secret: 42.194.177.220_password # 从Secret中读取SSH密码
-      port: 22
-      rm: true
-      source:
-        - /data
-      target:
-        - /data/sh/
-    environment:
-      AUTO_CREATE_DIR: "true" # 自动创建目标目录
-    when:
-      event:
-        - push # 当代码 push 时才重新上传
-
-  # 启动shell脚本
-  - name: spring-start 部署并重启
-    image: appleboy/drone-ssh # SSH工具镜像
-    settings:
-      host: 42.194.177.220 # 远程连接地址
-      username: root # 远程连接账号
-      password:
-        from_secret: 42.194.177.220_password # 从Secret中读取SSH密码
-      port: 22 # 远程连接端口
-      command_timeout: 5m # 远程执行命令超时时间
-      script:
-        - cd /data/sh # 进入宿主机构建目录
-        - chmod +x develop.sh # 更改为可执行脚本
-        - ./develop.sh  # 运行脚本打包应用镜像并运行
-    when:
-      event:
-        - push # 当代码 push 时才重新上传
-
-volumes: # 定义流水线挂载目录,用于共享shell脚本
-  - name: host-mount
-    host:
-      path: /mydata/sh/ # 从宿主机中挂载的目录

+ 35 - 5
.idea/workspace.xml

@@ -4,7 +4,23 @@
     <option name="autoReloadType" value="SELECTIVE" />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="8eaaf244-eba9-47b2-a128-7c46802a5971" name="Changes" comment="finally" />
+    <list default="true" id="8eaaf244-eba9-47b2-a128-7c46802a5971" name="Changes" comment="finally">
+      <change beforePath="$PROJECT_DIR$/.drone.yml" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/client-api/src/main/java/com/wteam/controller/card/CardController.java" beforeDir="false" afterPath="$PROJECT_DIR$/client-api/src/main/java/com/wteam/controller/card/CardController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/client-api/src/main/java/com/wteam/controller/hardware/HardwareController.java" beforeDir="false" afterPath="$PROJECT_DIR$/client-api/src/main/java/com/wteam/controller/hardware/HardwareController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/common/enums/ResultCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/common/enums/ResultCode.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/book/entity/OrderInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/book/entity/OrderInfo.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/book/entity/Venue.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/book/entity/Venue.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/book/entity/vo/TimeCodeVo.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/book/entity/vo/TimeCodeVo.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/book/service/impl/CardServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/book/service/impl/CardServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/hardware/QrCodeRegistrationUtil.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/hardware/QrCodeRegistrationUtil.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/pay/serviceimpl/WxV3PayPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/pay/serviceimpl/WxV3PayPlugin.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/pay/serviceimpl/handler/MyPayMessageHandler.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/pay/serviceimpl/handler/MyPayMessageHandler.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/user/service/impl/UserServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/framework/src/main/java/com/wteam/framework/modules/user/service/impl/UserServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/target/classes/com/wteam/framework/common/enums/ResultCode.class" beforeDir="false" afterPath="$PROJECT_DIR$/framework/target/classes/com/wteam/framework/common/enums/ResultCode.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/framework/target/classes/com/wteam/framework/modules/user/service/impl/UserServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/framework/target/classes/com/wteam/framework/modules/user/service/impl/UserServiceImpl.class" afterDir="false" />
+    </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -63,7 +79,7 @@
     &quot;ToolWindowRun.ShowToolbar&quot;: &quot;false&quot;,
     &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
     &quot;git-widget-placeholder&quot;: &quot;master&quot;,
-    &quot;last_opened_file_path&quot;: &quot;D:/pojo/dts-shop&quot;,
+    &quot;last_opened_file_path&quot;: &quot;D:/pojo/courtBooking/court_booking&quot;,
     &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
     &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
     &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
@@ -72,7 +88,7 @@
     &quot;project.structure.last.edited&quot;: &quot;Project&quot;,
     &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
     &quot;project.structure.side.proportion&quot;: &quot;0.0&quot;,
-    &quot;settings.editor.selected.configurable&quot;: &quot;reference.settingsdialog.IDE.editor.colors.Language Defaults&quot;,
+    &quot;settings.editor.selected.configurable&quot;: &quot;preferences.toDoOptions&quot;,
     &quot;spring.configuration.checksum&quot;: &quot;8c885b1d9b6b77e9df49058579a3cf2a&quot;,
     &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
   },
@@ -90,6 +106,7 @@
       <recent name="com.wteam.framework.modules.image.mapper.service.impl" />
     </key>
     <key name="CopyFile.RECENT_KEYS">
+      <recent name="D:\pojo\courtBooking\court_booking" />
       <recent name="D:\pojo\courtBooking\court_booking\framework\src\main\java\com\wteam\framework\modules\pay" />
       <recent name="D:\pojo\courtBooking\court_booking\framework\src\main\java\com\wteam\framework\modules\sms\entity\dos" />
       <recent name="D:\pojo\courtBooking\background-template\framework\src\main\java\com\wteam\framework\modules" />
@@ -282,7 +299,12 @@
       <workItem from="1697610300076" duration="13582000" />
       <workItem from="1697626429470" duration="6966000" />
       <workItem from="1697713030681" duration="1835000" />
-      <workItem from="1697715484067" duration="363000" />
+      <workItem from="1697715484067" duration="2070000" />
+      <workItem from="1697722778763" duration="2300000" />
+      <workItem from="1697876913258" duration="7935000" />
+      <workItem from="1697887182792" duration="6858000" />
+      <workItem from="1698057786406" duration="186000" />
+      <workItem from="1698059500668" duration="4236000" />
     </task>
     <task id="LOCAL-00001" summary="init2">
       <created>1696846465336</created>
@@ -299,7 +321,15 @@
       <option name="project" value="LOCAL" />
       <updated>1697715825395</updated>
     </task>
-    <option name="localTasksCounter" value="3" />
+    <task id="LOCAL-00003" summary="finally">
+      <option name="closed" value="true" />
+      <created>1697715996611</created>
+      <option name="number" value="00003" />
+      <option name="presentableId" value="LOCAL-00003" />
+      <option name="project" value="LOCAL" />
+      <updated>1697715996611</updated>
+    </task>
+    <option name="localTasksCounter" value="4" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">

+ 6 - 0
client-api/src/main/java/com/wteam/controller/card/CardController.java

@@ -95,6 +95,12 @@ public class CardController {
      * 两者都是如果支付成功就将状态改为已使用
      */
 
+
+
+
+
+
+
     /**
      * 使用储值卡支付
      *

+ 99 - 61
client-api/src/main/java/com/wteam/controller/hardware/HardwareController.java

@@ -47,6 +47,7 @@ import java.util.regex.Pattern;
 @RequestMapping("/v1/hardware")
 public class HardwareController {
 
+
     @Autowired
     private OrderInfoMapper orderInfoMapper;
     @Autowired
@@ -76,7 +77,7 @@ public class HardwareController {
                 Date currentDateTime = sdf.parse(currentTime);
                 Date lastRequestDateTime = sdf.parse(lastRequestTime);
                 long timeElapsed = currentDateTime.getTime() - lastRequestDateTime.getTime();
-                return timeElapsed >= 5000; // 5秒等于5000毫秒
+                return timeElapsed >= 10000; // 10秒等于10000毫秒
             } catch (Exception e) {
                 e.printStackTrace();
                 return true; // 如果出现异常,默认返回true以执行程序
@@ -147,6 +148,7 @@ public class HardwareController {
         }
 
         OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
+
         log.info("此时的订单信息为{}", orderInfo);
 
         //这里先判断是什么订单
@@ -209,7 +211,7 @@ public class HardwareController {
                     log.info("使用次卡二维码出门的时间为:{}", currentTime);
                     orderInfo.setOrderState(String.valueOf(OrderStatusEnum.USED));
                     orderInfoMapper.updateById(orderInfo);
-
+//                    return ResultUtil.success(ResultCode.TICKET_ORDER_FINISH);
                 }
             }
         }
@@ -260,20 +262,20 @@ public class HardwareController {
         //获取订单信息
         OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
 
-        // 处理时间格式
-        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
-        // 获取当前日期和时间
-        Date currentDate = new Date();
-        String format = sdf1.format(currentDate);
+//        // 处理时间格式
+//        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
+//        // 获取当前日期和时间
+//        Date currentDate = new Date();
+//        String format = sdf1.format(currentDate);
 
         Date date = sdf.parse(time);
         log.info("此刻的传入的时间为:{}", date);
 
-        // 设置不同时间段的价格
-        Date startTime1 = sdf.parse(format + " 09:30:00");
-        Date endTime1 = sdf.parse(format + " 18:00:00");
-        Date startTime2 = sdf.parse(format + " 18:30:00");
-        log.info("此时格式化的三个时间段为:{},{},{}", startTime1, endTime1, startTime2);
+//        // 设置不同时间段的价格
+//        Date startTime1 = sdf.parse(format + " 09:30:00");
+//        Date endTime1 = sdf.parse(format + " 18:00:00");
+//        Date startTime2 = sdf.parse(format + " 18:30:00");
+//        log.info("此时格式化的三个时间段为:{},{},{}", startTime1, endTime1, startTime2);
 
         //先处理订场订单的情况
         if (orderInfo.getStartTime() == null) {
@@ -284,29 +286,29 @@ public class HardwareController {
             log.info("此时第一次调用接口设置的计时订单的进场时间为:{}", date);
             orderInfoMapper.updateById(orderInfo);
 
-            if (date.after(startTime1) && date.before(endTime1)) {
-
-                // 当前时间在 09:30 - 18:00 之间,价格为 8 元/小时
-                double initialPrice = 8.0;
-                orderInfo.setOrderPrice(initialPrice);
-                orderInfo.setOrderState(String.valueOf(OrderStatusEnum.WAITING_TO_PAY));
-                log.info("09:30 - 18:00这个时间段的订单信息为:{}", orderInfo);
-                orderInfoService.updateById(orderInfo);
-
-            } else if (date.after(startTime2)) {
-
-                // 当前时间在 18:30 之后,价格为 10 元/小时
-                double initialPrice = 10.0;
-                orderInfo.setOrderPrice(initialPrice);
-                orderInfo.setOrderState(String.valueOf(OrderStatusEnum.WAITING_TO_PAY));
-                log.info("18 :30 之后的这个时间段的订单信息为:{}", orderInfo);
-                orderInfoService.updateById(orderInfo);
-
-            }
+//            if (date.after(startTime1) && date.before(endTime1)) {
+//
+//                // 当前时间在 09:30 - 18:00 之间,价格为 8 元/小时
+//                double initialPrice = 8.0;
+//                orderInfo.setOrderPrice(initialPrice);
+//                orderInfo.setOrderState(String.valueOf(OrderStatusEnum.WAITING_TO_PAY));
+//                log.info("09:30 - 18:00这个时间段的订单信息为:{}", orderInfo);
+//                orderInfoService.updateById(orderInfo);
+//
+//            } else if (date.after(startTime2)) {
+//
+//                // 当前时间在 18:30 之后,价格为 10 元/小时
+//                double initialPrice = 10.0;
+//                orderInfo.setOrderPrice(initialPrice);
+//                orderInfo.setOrderState(String.valueOf(OrderStatusEnum.WAITING_TO_PAY));
+//                log.info("18 :30 之后的这个时间段的订单信息为:{}", orderInfo);
+//                orderInfoService.updateById(orderInfo);
+//
+//            }
 
         } else {
 
-            if (orderInfo.getEndTime() == null) {
+            if (orderInfo.getEndTime() == null && orderInfo.getStartTime() != null) {
 
                 // 第二次调用接口,设置endTime,并计算费用
                 orderInfo.setEndTime(date);
@@ -333,15 +335,15 @@ public class HardwareController {
                     orderInfo.setOverPrice(totalPrice);
                     log.info("计时订单超时金额为:{}", totalPrice);
                     orderInfo.setOrderState(String.valueOf(OrderStatusEnum.WAITING_SUPPLEMENTS));
-
+                    orderInfo.setOverTime((int) extraMinutes);
                     orderInfoService.updateById(orderInfo);
+                    return ResultUtil.success(ResultCode.TIME_ORDER_OVER_FINISH);
                 }
-
                 //如果没有超时 该计时订单完成
                 orderInfo.setOrderState(String.valueOf(OrderStatusEnum.USED));
                 log.info("使用完成的计时订单信息为:{}", orderInfo);
                 orderInfoService.updateById(orderInfo);
-
+                return ResultUtil.success(ResultCode.TIME_ORDER_FINISH);
             }
         }
         return ResultUtil.error(ResultCode.TIMER_HARD_ERROR);
@@ -367,6 +369,7 @@ public class HardwareController {
         log.info("此刻的时间为:{}", currentTime);
 
 
+        //todo:第2个问题,订场还没有到点的,然后拿着二维码去扫是进不去的,但是只要有这个操作后台就会显示已使用,然后二维码就找不到了。
         //处理可能会出现提前扫码的情况
         // 1-->保证在订场开始时间的前30分钟扫码才有效
         // 获取原始时间
@@ -377,16 +380,19 @@ public class HardwareController {
         // 减去30分钟
         calendar.add(Calendar.MINUTE, -30);
         Date newTime = calendar.getTime();
+        Date parse = sdf.parse(newTime.toString());
         log.info("该订单开始时间减去30分钟之后的时间为:{}", newTime);
 
         // 判断时间
-        if (currentTime.after(newTime)) {
+        if (currentTime.before(parse)) {
             return ResultUtil.success(ResultCode.TIME_BU_DAO);
         }
 
         //先处理订场订单的情况
         if (orderTypeEnum.RENTAL.toString().equals(orderInfo.getOrderType())) {
 
+            //如果来回进出场地 或者说用户分享给朋友进行使用的情况
+            // 进入时间就是第一次扫码的时间 但是出门时间要设置为在订单前后的时间
             if (orderInfo.getStartTime() == null && orderInfo.getOrderState().equals(OrderStatusEnum.WAITING_TO_USE)) {
 
                 // 第一次调用接口,设置startTime
@@ -408,9 +414,16 @@ public class HardwareController {
                     if (currentTime.before(orderInfo.getOrderEd())) {
 
                         // 在ordered时间之前,返回状态码200
-                        orderInfo.setOrderState(String.valueOf(OrderStatusEnum.USED));
+                        orderInfo.setOrderState(String.valueOf(OrderStatusEnum.IN_USE));
                         orderInfoMapper.updateById(orderInfo);
 
+                        if (currentTime.after(orderInfo.getOrderEd())) {
+
+                            orderInfo.setOrderState(String.valueOf(OrderStatusEnum.USED));
+                            orderInfoMapper.updateById(orderInfo);
+                            return ResultUtil.success(ResultCode.RENTAL_ORDER_FINISH);
+
+                        }
                     } else {
 
                         // 超过ordered时间,计算超过的分钟数
@@ -427,6 +440,7 @@ public class HardwareController {
                         log.info("租场超时金额为:{}", v1);
                         orderInfo.setOverPrice(v1);
                         orderInfoService.updateById(orderInfo);
+                        return ResultUtil.success(ResultCode.RENTAL_ORDER_OVER_FINISH);
 
                     }
                 }
@@ -488,24 +502,56 @@ public class HardwareController {
      */
     @Operation(summary = "计时卡")
     @PostMapping("/timeCard/{accessToken}")
-    public ResultMessage timeCard(@PathVariable("accessToken") String accessToken) {
+    public ResultMessage timeCard(@PathVariable("accessToken") String accessToken) throws ParseException {
         //解析校验token获得用户id
         AuthUser authUser = UserContext.getAuthUser(accessToken);
         assert authUser != null;
         String userId = authUser.getId();
+
+        if (userId.isEmpty()) {
+            return ResultUtil.error(ResultCode.USER_NEED_LOGIN);
+        }
         log.info("此时的用户id为:{}", userId);
         //根据userId查询user信息
         User user = userMapper.selectById(userId);
         // 处理nickName为null的情况
-        String nickName = (user.getNickName() != null) ? user.getNickName() : "";
-        // 获取当前日期
-        LocalDate currentDate = LocalDate.now();
-        // 格式化日期为字符串
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
-        String formattedDate = currentDate.format(formatter);
-        /**
-         * 这里存储计时订单信息
-         */
+        //生成一个随机数字
+        String numbersUser = RandomUtil.randomNumbers(4);
+        String nickName = (user.getNickName() != null) ? user.getNickName() : "用户+" + numbersUser;
+
+        // 获取当前时间
+        Date now = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 格式化当前时间为字符串
+        String date = sdf.format(now);
+        long time = sdf.parse(date).getTime();
+        log.info("此刻使用计时码的时间为其对应的时间戳为:{},{}", date, time);
+
+        // 处理时间格式
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
+
+        // 获取当前日期和时间
+        Date currentDate = new Date();
+        String format = sdf1.format(currentDate);
+
+        // 设置不同时间段的价格
+        long startTime1 = sdf.parse(format + " 09:30:00").getTime();
+        long endTime1 = sdf.parse(format + " 18:00:00").getTime();
+        long startTime2 = sdf.parse(format + " 18:30:00").getTime();
+        log.info("此时格式化的三个时间段的时间戳为:{},{},{}", startTime1, endTime1, startTime2);
+
+
+        //根据不同的时间判断进场价格
+        double initPrice = 0.0;
+
+        if (time >= startTime1 && time <= endTime1) {
+            initPrice = 8.0;
+        } else if (time >= startTime2) {
+            initPrice = 10.0;
+        }
+        log.info("此时的初始价格为:{}", initPrice);
+
+        //根据不同的时间判断进场价格
         OrderInfo orderInfo = new OrderInfo();
         String orderId = RandomUtil.randomNumbers(9);
         orderInfo.setId(orderId);
@@ -513,24 +559,16 @@ public class HardwareController {
         orderInfo.setCreateTime(new Date());
         orderInfo.setStoreId(9376L);
         orderInfo.setOrderType(String.valueOf(orderTypeEnum.TIMER));
-        orderInfoService.save(orderInfo);
-
-        //生成一个随机数字
-        String numbers = RandomUtil.randomNumbers(5);
-
-        String data = "pxo_" + formattedDate + "_" + numbers + "_" + orderInfo.getId() + "_00";
-
-        Boolean flag = QrCodeRegistrationUtil.registerTimerQrCode(data);
+        orderInfo.setOrderState(String.valueOf(OrderStatusEnum.WAITING_TO_PAY));
+        orderInfo.setOrderPrice(initPrice);
+        boolean save = orderInfoService.save(orderInfo);
 
-        if (flag) {
-            orderInfo.setQrCode(data);
-            orderInfoService.updateById(orderInfo);
-            //判断响应结果
+        if (save) {
             TimeCodeVo timeCodeVo = new TimeCodeVo();
-            timeCodeVo.setCode(data);
+            timeCodeVo.setOrderInfo(orderInfo);
             timeCodeVo.setNickName(nickName);
             return ResultUtil.data(timeCodeVo);
         }
-        return ResultUtil.error(ResultCode.TIME_CODE_ERROR);
+        return ResultUtil.error(ResultCode.PRICE);
     }
 }

+ 7 - 1
framework/src/main/java/com/wteam/framework/common/enums/ResultCode.java

@@ -540,7 +540,13 @@ public enum ResultCode {
     ORDER_INFO_NOT_EXIT(1034, "订单信息或者卡信息不存在"),
     HARD_CALL_BACK_DATA_ERROR(1035, "硬件回调数据格式错误!"),
     SAOMA_TIME_TAI_DUAN(1036, "扫码间隔太短,可能是短时间多次扫码,不需要记录此时时间!"),
-    TIME_BU_DAO(1037, "扫码时间过早,防止二维码失效!");
+    TIME_BU_DAO(1037, "扫码时间过早,防止二维码失效!"),
+    PRICE(1038, "根据时间判断价格有误!"),
+    TIME_ORDER_OVER_FINISH(1039, "计时订单超时金额设置完成!"),
+    TIME_ORDER_FINISH(1040, "计时订单完成!"),
+    RENTAL_ORDER_FINISH(1041, "租场订单完成!"),
+    RENTAL_ORDER_OVER_FINISH(1043, "租场订单超时金额设置完成!"),
+    TICKET_ORDER_FINISH(1042, "次卡订单完成!");
 
 
     private final Integer code;

+ 2 - 0
framework/src/main/java/com/wteam/framework/modules/book/entity/OrderInfo.java

@@ -92,4 +92,6 @@ public class OrderInfo {
     private String transactionId;
     //订单超时金额
     private Double overPrice;
+    //订单超时时间
+    private Integer overTime;
 }

+ 3 - 0
framework/src/main/java/com/wteam/framework/modules/book/entity/Venue.java

@@ -4,6 +4,7 @@ import java.util.Date;
 
 import java.io.Serializable;
 
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -57,6 +58,8 @@ public class Venue {
     //TODO:新添加的
     //场地起订时间
     private Double leadTime;
+    @Schema(description = "场地分享次数")
+    private Integer shareFrequency;
 
 
 }

+ 2 - 1
framework/src/main/java/com/wteam/framework/modules/book/entity/vo/TimeCodeVo.java

@@ -1,5 +1,6 @@
 package com.wteam.framework.modules.book.entity.vo;
 
+import com.wteam.framework.modules.book.entity.OrderInfo;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -12,6 +13,6 @@ import lombok.NoArgsConstructor;
 @AllArgsConstructor
 @NoArgsConstructor
 public class TimeCodeVo {
-    private String code;
+    private OrderInfo orderInfo;
     private String nickName;
 }

+ 24 - 9
framework/src/main/java/com/wteam/framework/modules/book/service/impl/CardServiceImpl.java

@@ -22,6 +22,7 @@ import com.wteam.framework.common.vo.ResultMessage;
 import com.wteam.framework.modules.book.entity.Card;
 import com.wteam.framework.modules.book.entity.OrderInfo;
 import com.wteam.framework.modules.book.entity.Store;
+import com.wteam.framework.modules.book.entity.Venue;
 import com.wteam.framework.modules.book.entity.dto.OrderCardReq;
 import com.wteam.framework.modules.book.entity.dto.StoredCardDto;
 import com.wteam.framework.modules.book.entity.vo.CardVo;
@@ -29,6 +30,7 @@ import com.wteam.framework.modules.book.entity.vo.OrderVo;
 import com.wteam.framework.modules.book.mapper.CardMapper;
 import com.wteam.framework.modules.book.mapper.OrderInfoMapper;
 import com.wteam.framework.modules.book.mapper.StoreMapper;
+import com.wteam.framework.modules.book.mapper.VenueMapper;
 import com.wteam.framework.modules.book.service.CardService;
 import com.wteam.framework.modules.book.service.OrderInfoService;
 import com.wteam.framework.modules.card.entity.CbCardAdmin;
@@ -81,7 +83,7 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
     @Autowired
     private CardService cardService;
     @Autowired
-    private CashierSupport cashierSupport;
+    private VenueMapper venueMapper;
     @Autowired
     private UserMapper userMapper;
     @Autowired
@@ -320,9 +322,9 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
         OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
         log.info("此时的订单信息为:{}", orderInfo);
 
-        Long storeId = orderInfo.getStoreId();
-        Store store = storeMapper.selectById(storeId);
-        Integer realTime = Integer.valueOf(store.getRealTime());
+        Long venueId = orderInfo.getVenueId();
+        Venue venue = venueMapper.selectById(venueId);
+        Integer realTime = Integer.valueOf(venue.getShareFrequency());
         realTime = realTime * 2;
         log.info("此时的核销次数为:{}", realTime);
 
@@ -454,6 +456,8 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
                         //获取订单开始和结束时间
                         Date orderSt = orderInfo.getOrderSt();
                         Date orderEd = orderInfo.getOrderEd();
+
+                        // todo:第1个问题订场提前半小时内可以进,刚才离开开场前33分钟也能进
                         // 转化为时间戳
                         // 前30后30
                         // 获取当前时间的时间戳(秒级)
@@ -461,9 +465,11 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
 
                         // 将订单开始时间前推30分钟并转换为时间戳
                         long orderStTimestamp = (orderSt.getTime() / 1000) - (30 * 60);
+                        log.info("开场进场时间戳为:{}", orderStTimestamp);
 
                         // 将订单结束时间后推30分钟并转换为时间戳
                         long orderEdTimestamp = (orderEd.getTime() / 1000) + (30 * 60);
+                        log.info("退场出门时间戳为:{}", orderEdTimestamp);
 
 
                         // 如果需要确保不早于当前时间,可以添加以下逻辑
@@ -476,7 +482,14 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
 
 
                         //调用hutool接口注册二维码信息
-                        HttpResponse response = HttpRequest.post(apiUrl).form("mac", macParam).form("tk", tk).form("qcodetxt", data).form("starttime", orderStTimestamp).form("enabletime", orderEdTimestamp).form("enablecount", realTime).execute();
+                        HttpResponse response = HttpRequest.post(apiUrl)
+                                .form("mac", macParam)
+                                .form("tk", tk)
+                                .form("qcodetxt", data)
+                                .form("starttime", orderStTimestamp)
+                                .form("enabletime", orderEdTimestamp)
+                                .form("enablecount", realTime)
+                                .execute();
 
                         String body = response.body();
                         JSONObject json = new JSONObject(body);
@@ -641,13 +654,13 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
             // 获得订单价格和卡余额和折扣信息
             Double orderPrice = orderInfo.getOrderPrice();
             Double currentBalance = card.getCurrentBalance();
-            Float discountValue = card.getDiscountValue() != null ? card.getDiscountValue() : 1.0f;
+            Float discountValue = card.getDiscountValue() != null ? card.getDiscountValue() / 10 : 1.0f;
 
             // 获取需要支付的金额
             double v = orderPrice * discountValue;
 
             // 超时金额
-            Double overdueAmount = orderInfo.getOrderPrice() != null ? orderInfo.getOrderPrice() : 0.0;
+            Double overdueAmount = orderInfo.getOverPrice() != null ? orderInfo.getOverPrice() : 0.0;
             log.info("此时的超时金额为:{}", overdueAmount);
 
 
@@ -671,7 +684,7 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
                 }
             }
 
-            if (v < currentBalance) {
+            if (v <= currentBalance && orderInfo.getOrderState().equals(OrderStatusEnum.WAITING_TO_PAY.name())) {
                 double totalAmountToDeduct = v;
                 if (totalAmountToDeduct <= currentBalance) {
                     double newBalance = currentBalance - totalAmountToDeduct;
@@ -680,6 +693,8 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
 
                     // 修改订单状态
                     orderInfo.setOrderState(OrderStatusEnum.IN_USE.toString());
+                    String qrCode = QrCodeRegistrationUtil.registerCode(orderInfo);
+                    orderInfo.setQrCode(qrCode);
                     orderInfoService.updateById(orderInfo);
                     return ResultUtil.success(ResultCode.PAY_SUCCESS);
                 } else {
@@ -688,7 +703,7 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
                 }
             }
         }
-        return ResultUtil.success(ResultCode.ORDER_TAKE_ERROR);
+        return ResultUtil.success(ResultCode.CURRENTBALANCE_NOT);
 
     }
 

+ 25 - 0
framework/src/main/java/com/wteam/framework/modules/hardware/QrCodeRegistrationUtil.java

@@ -1,11 +1,16 @@
 package com.wteam.framework.modules.hardware;
 
+import cn.hutool.core.util.RandomUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.json.JSONObject;
 import com.wteam.framework.common.exception.ServiceException;
+import com.wteam.framework.modules.book.entity.OrderInfo;
 import lombok.extern.slf4j.Slf4j;
 
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
 @Slf4j
 public class QrCodeRegistrationUtil {
 
@@ -148,4 +153,24 @@ public class QrCodeRegistrationUtil {
         log.info("此时接口响应数据为:{} (不要记录敏感信息在日志中)", body);
         return data;
     }
+
+    public static String registerCode(OrderInfo orderInfo) {
+        // 获取当前日期
+        LocalDate currentDate1 = LocalDate.now();
+        // 格式化日期为字符串
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        String formattedDate = currentDate1.format(formatter);
+
+        //生成一个随机数字
+        String numbers = RandomUtil.randomNumbers(5);
+
+        String data = "pxo_" + formattedDate + "_" + numbers + "_" + orderInfo.getId() + "_00";
+
+        Boolean b = QrCodeRegistrationUtil.registerTimerQrCode(data);
+
+        if (b) {
+            return data;
+        }
+        return "注册二维码错误!";
+    }
 }

+ 2 - 1
framework/src/main/java/com/wteam/framework/modules/pay/serviceimpl/WxV3PayPlugin.java

@@ -57,6 +57,7 @@ import java.util.Map;
 @Component
 public class WxV3PayPlugin implements Payment {
 
+
     private WxPayService service = null;
 
     @Autowired
@@ -96,7 +97,7 @@ public class WxV3PayPlugin implements Payment {
         wxPayConfigStorage.setMchId(wechatPaymentSetting.getMchId());
 // V3密钥 https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay3_2.shtml
         wxPayConfigStorage.setV3ApiKey(wechatPaymentSetting.getApiKey3());
-        wxPayConfigStorage.setNotifyUrl("http://139.9.38.185:8889/v1/payment/callback/WECHAT");
+        wxPayConfigStorage.setNotifyUrl("http://h5.hengyuesports.com/v1/payment/callback/WECHAT");
         wxPayConfigStorage.setReturnUrl("http://sailinmu.iok.la/wxV3/payBack.json");
         wxPayConfigStorage.setInputCharset("utf-8");
         // 使用证书时设置为true

+ 74 - 10
framework/src/main/java/com/wteam/framework/modules/pay/serviceimpl/handler/MyPayMessageHandler.java

@@ -13,13 +13,17 @@ import com.egzosn.pay.common.exception.PayErrorException;
 import com.wteam.framework.common.enums.CardTypeEnum;
 import com.wteam.framework.common.enums.OrderStatus;
 import com.wteam.framework.common.enums.OrderStatusEnum;
+import com.wteam.framework.common.enums.ResultCode;
 import com.wteam.framework.common.exception.ServiceException;
 import com.wteam.framework.modules.book.entity.Card;
 import com.wteam.framework.modules.book.entity.OrderInfo;
 import com.wteam.framework.modules.book.entity.Store;
+import com.wteam.framework.modules.book.entity.Venue;
+import com.wteam.framework.modules.book.entity.vo.TimeCodeVo;
 import com.wteam.framework.modules.book.mapper.CardMapper;
 import com.wteam.framework.modules.book.mapper.OrderInfoMapper;
 import com.wteam.framework.modules.book.mapper.StoreMapper;
+import com.wteam.framework.modules.book.mapper.VenueMapper;
 import com.wteam.framework.modules.book.service.CardService;
 import com.wteam.framework.modules.book.service.OrderInfoService;
 import com.wteam.framework.modules.card.entity.CbCardAdmin;
@@ -58,7 +62,7 @@ public class MyPayMessageHandler implements PayMessageHandler {
     @Autowired
     private UserMapper userMapper;
     @Autowired
-    private StoreMapper storeMapper;
+    private VenueMapper venueMapper;
 
     /**
      * 重写这个接口处理支付业务请求
@@ -546,6 +550,61 @@ public class MyPayMessageHandler implements PayMessageHandler {
         orderInfo.setPaymentMethods("WECHAT");
         log.info("此时的PaymentMethods信息为{}", orderInfo.getPaymentMethods());
 
+        // 获取当前日期
+        LocalDate currentDate1 = LocalDate.now();
+        // 格式化日期为字符串
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        String formattedDate = currentDate1.format(formatter);
+
+        //生成一个随机数字
+        String numbers = RandomUtil.randomNumbers(5);
+
+        String data = "pxo_" + formattedDate + "_" + numbers + "_" + orderInfo.getId() + "_00";
+
+        // 获取当前时间戳
+        long currentTime = System.currentTimeMillis() / 1000;
+
+        // 获取60秒之后的时间戳
+        long sixtySecondsLater = currentTime + 60;
+
+
+        String apiUrl = "https://xiaofeng.pankzone.com/api/openapi/reg_access_qcode.x";
+        String mac1 = "863569068849199";
+        String mac2 = "863569068848969";
+        String tk = ApiCallerUtil.callApi(mac1);
+        log.info("此时获取到的token为:{} ", tk);
+
+        String macParam = mac1 + "_" + mac2;
+        log.info("此时拼接的macParam为:{}", macParam);
+
+        HttpResponse response = HttpRequest.post(apiUrl)
+                .form("mac", macParam)
+                .form("tk", tk)
+                .form("qcodetxt", data)
+                .form("starttime", currentTime)
+                .form("enabletime", sixtySecondsLater)
+                .form("enablecount", 2)
+                .execute();
+
+        String body = response.body();
+        JSONObject json = new JSONObject(body);
+        int code = json.getInt("code");
+        log.info("此时返回的code为:{}", code);
+        String qcodetxt = json.getStr("qcodetxt");
+        log.info("此时返回的qcodetxt为:{}", qcodetxt);
+        String desc = json.getStr("desc");
+        log.info("此时返回的desc为:{}", desc);
+
+        if (code != 0 && code != 4) {
+            throw new ServiceException("硬件回调url设置接口异常!");
+        }
+
+        log.info("此时接口响应数据为:{} (不要记录敏感信息在日志中)", body);
+
+
+        orderInfo.setQrCode(data);
+
+
         int i = orderInfoMapper.updateById(orderInfo);
 
 //        //设置进出时间
@@ -560,9 +619,13 @@ public class MyPayMessageHandler implements PayMessageHandler {
         if (i > 0) {
             return PayOutMessage.TEXT().content("success").build();
         }
-
         // 返回适当的PayOutMessage
-        return PayOutMessage.TEXT().content("fail").build();
+        return PayOutMessage.TEXT().
+
+                content("fail").
+
+                build();
+
     }
 
 
@@ -685,9 +748,9 @@ public class MyPayMessageHandler implements PayMessageHandler {
         orderInfo.setPaymentMethods("WECHAT");
         log.info("此时的PaymentMethods信息为{}", orderInfo.getPaymentMethods());
 
-        Long storeId = orderInfo.getStoreId();
-        Store store = storeMapper.selectById(storeId);
-        Integer realTime = Integer.valueOf(store.getRealTime());
+        Long venueId = orderInfo.getVenueId();
+        Venue venue = venueMapper.selectById(venueId);
+        Integer realTime = Integer.valueOf(venue.getShareFrequency());
         realTime = realTime * 2;
         log.info("此时的核销次数为:{}", realTime);
 
@@ -728,10 +791,11 @@ public class MyPayMessageHandler implements PayMessageHandler {
             Date orderSt = orderInfo.getOrderSt();
             Date orderEd = orderInfo.getOrderEd();
 
+            // todo:第1个问题订场提前半小时内可以进,刚才离开开场前33分钟也能进
             // 转化为时间戳
             // 前30后30
             // 获取当前时间的时间戳(秒级)
-//            long currentTimeMillis = System.currentTimeMillis() / 1000;
+            long currentTimeMillis = System.currentTimeMillis() / 1000;
 
             // 将订单开始时间前推30分钟并转换为时间戳
             long orderStTimestamp = (orderSt.getTime() / 1000) - (30 * 60);
@@ -746,9 +810,9 @@ public class MyPayMessageHandler implements PayMessageHandler {
             Date endTime = new Date(orderEdTimestamp * 1000);
             log.info("订单{}" + "的订单结束时间(二维码失效时间)为:{}", id, endTime);
 
-//            // 如果需要确保不早于当前时间,可以添加以下逻辑
-//            orderStTimestamp = Math.max(orderStTimestamp, currentTimeMillis);
-//            orderEdTimestamp = Math.max(orderEdTimestamp, currentTimeMillis);
+            // 如果需要确保不早于当前时间,可以添加以下逻辑
+            orderStTimestamp = Math.max(orderStTimestamp, currentTimeMillis);
+            orderEdTimestamp = Math.max(orderEdTimestamp, currentTimeMillis);
 
             // 拼接两个 MAC 地址,以逗号分隔
             String macParam = mac1 + "_" + mac2;

+ 4 - 0
framework/src/main/java/com/wteam/framework/modules/user/service/impl/UserServiceImpl.java

@@ -331,6 +331,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         if ("TICKET".equals(orderType) || "MONTHLY".equals(orderType)) {
             return ResultUtil.data(qrCode);
         }
+
+        if ("TIMER".equals(orderType)) {
+            return ResultUtil.data(orderInfo);
+        }
         Long venueId = orderInfo.getVenueId();
         log.info("此时获得的场地id为:{}", venueId);
         Venue venue = venueMapper.selectById(venueId);

BIN
framework/target/classes/com/wteam/framework/common/enums/ResultCode.class


BIN
framework/target/classes/com/wteam/framework/modules/user/service/impl/UserServiceImpl.class