From aa33bb96ba9f14b16c6c7832e21bfbd88983ba6d Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期三, 24 一月 2024 18:02:39 +0800
Subject: [PATCH] zjh 2024/01/24--3

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/app/ReservationController.java |  124 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 111 insertions(+), 13 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/app/ReservationController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/app/ReservationController.java
index 40e6f00..19a01d9 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/app/ReservationController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/app/ReservationController.java
@@ -1,11 +1,14 @@
 package com.ltkj.web.controller.app;
 
+import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.base.Joiner;
 import com.ltkj.common.core.controller.BaseController;
 import com.ltkj.common.core.domain.AjaxResult;
+import com.ltkj.common.task.TaskService;
 import com.ltkj.common.utils.StringUtils;
 import com.ltkj.framework.config.MatchUtils;
 import com.ltkj.framework.config.UserHoder;
@@ -15,6 +18,8 @@
 import com.ltkj.mall.service.IMallTimeConfigService;
 import com.ltkj.system.service.ISysConfigService;
 import com.ltkj.web.config.redis.OrderDelayService;
+import com.ltkj.web.config.task.TjReservationTask;
+import com.ltkj.web.wxUtils.WxUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -24,10 +29,7 @@
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * @Author: 瑗垮畨璺嘲绉戞妧鏈夐檺鍏徃
@@ -56,8 +58,10 @@
     private IMallTimeConfigService mallTimeConfigService;
     @Resource
     private ISysConfigService configService;
-    @Resource
-    private OrderDelayService delayService;
+//    @Resource
+//    private OrderDelayService delayService;
+    @Autowired
+    private TaskService taskService;
 
     @PostMapping
     @ApiOperation(value = "涓汉棰勭害")
@@ -106,7 +110,9 @@
             tjReservation.setProIds(join);
         }
         if (reservationService.save(tjReservation)) {
-            delayService.reservation(tjReservation.getId());
+
+            taskService.addTask(new TjReservationTask(tjReservation.getId(),
+                    DateUtil.between(new Date(),DateUtil.endOfDay(tjReservation.getReservationTime()), DateUnit.MS)));
 
             TjCustomer one = customerService.getOne(new LambdaQueryWrapper<TjCustomer>().eq(TjCustomer::getCusIdcard,tjReservation.getIdCard()));
             if(null !=one){
@@ -153,6 +159,47 @@
                 config.setNowNum(config.getNowNum()-1);
                 mallTimeConfigService.updateById(config);
             }
+
+            //鍙戣鍗曚俊鎭粰wx璁㈤槄鏈嶅姟娑堟伅鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�攕tart鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺��
+            Map<String, Object> res = new HashMap<>();
+            res.put("touser",wxuser.getOpenid());
+            res.put("template_id","M4K_BNVG7g4hOAcrIDO18ux8KOTneHeNide5GdPW3kc");
+            res.put("page","pages/mine/index");
+            res.put("miniprogram_state","trial");
+            //璁㈤槄娑堟伅鍙傛暟鍊�
+            JSONObject data = new JSONObject();
+
+            JSONObject name1 = new JSONObject();
+            name1.put("value",tjReservation.getName());
+            data.put("thing1", name1);
+
+            JSONObject amount3 = new JSONObject();
+            amount3.put("value", "浣撴涓績");
+            data.put("thing2", amount3);
+
+            JSONObject time4 = new JSONObject();
+            String dateFormat = DateUtil.format(tjReservation.getReservationTime(), "yyyy-MM-dd");
+            time4.put("value", dateFormat);
+            data.put("time4", time4);
+
+            final TjPackage byId = packageService.getById(tjReservation.getPacId());
+            if (byId!=null){
+                JSONObject thing5 = new JSONObject();
+                thing5.put("value",byId.getPacName());
+                data.put("thing5", thing5);
+            }else {
+                JSONObject thing5 = new JSONObject();
+                thing5.put("value","鏈煡");
+                data.put("thing5", thing5);
+            }
+
+
+            JSONObject thing6 = new JSONObject();
+            thing6.put("value", "浣撴鍓嶄竴澶╄鎮ㄨ繘娓呮贰楗,鍕块ギ閰掞紒");
+            data.put("thing6", thing6);
+            WxUtil.sendCommonSubscribeMessage(res,data);
+            //鍙戣鍗曚俊鎭粰wx璁㈤槄鏈嶅姟娑堟伅鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�攅nd鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺��
+
             return AjaxResult.success("棰勭害鎴愬姛!!!",tjReservation.getId());
         }
         return AjaxResult.error("棰勭害澶辫触");
@@ -162,10 +209,16 @@
     @ApiOperation(value = "鎾ら攢涓汉棰勭害")
     @Transactional
     public AjaxResult cusDeletedReservation(@RequestBody TjReservation reservation) {
-        LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>();
-        wq.eq(TjReservation::getIdCard, reservation.getIdCard());
-        wq.eq(TjReservation::getIsExpire, 2);
-        TjReservation one = reservationService.getOne(wq);
+        Wxuser wxuser = UserHoder.getWxuser();
+//        LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>();
+//        wq.eq(TjReservation::getIdCard, reservation.getIdCard());
+//        wq.eq(TjReservation::getIsExpire, 2);
+//        TjReservation one = reservationService.getOne(wq);
+        if (reservation.getId()==null){
+            return AjaxResult.success("鍑洪敊浜嗭紝璇疯仈绯诲伐浣滀汉鍛橈紒");
+        }
+        taskService.removeTask(new TjReservationTask(reservation.getId()));
+        TjReservation one = reservationService.getById(reservation.getId());
         if (null != one) {
             String isPays = configService.selectConfigByKey("isPay");
             if(null !=isPays  && isPays.equals("true") ){
@@ -181,7 +234,47 @@
 
             transitionService.deletedTbTransitionByCusId(reservation.getIdCard());
             reservationService.removeById(one);
-            return AjaxResult.success();
+
+
+            //鍙戣鍗曚俊鎭粰wx璁㈤槄鏈嶅姟娑堟伅鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�攕tart鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺��
+            Map<String, Object> res = new HashMap<>();
+            res.put("touser",wxuser.getOpenid());
+            res.put("template_id","X467Xtd8HnFDNk-IoT0ChcdoBnClLZJQQwP7DMztYQ8");
+            res.put("page","pages/mine/index");
+            res.put("miniprogram_state","trial");
+            //璁㈤槄娑堟伅鍙傛暟鍊�
+            JSONObject data = new JSONObject();
+
+            JSONObject amount3 = new JSONObject();
+            amount3.put("value", "浣撴涓績");
+            data.put("thing3", amount3);
+
+            JSONObject name1 = new JSONObject();
+            name1.put("value",reservation.getName());
+            data.put("name1", name1);
+
+            final TjPackage byId = packageService.getById(reservation.getPacId());
+            if (byId!=null){
+                JSONObject thing5 = new JSONObject();
+                thing5.put("value",byId.getPacName());
+                data.put("thing4", thing5);
+            }else {
+                JSONObject thing5 = new JSONObject();
+                thing5.put("value","鏈煡");
+                data.put("thing4", thing5);
+            }
+
+            JSONObject time4 = new JSONObject();
+            String dateFormat = DateUtil.format(reservation.getReservationTime(), "yyyy-MM-dd");
+            time4.put("value", dateFormat);
+            data.put("date2", time4);
+
+            JSONObject thing6 = new JSONObject();
+            thing6.put("value", "鎮ㄥ凡鎴愬姛鍙栨秷鏈棰勭害锛屾杩庡啀娆′娇鐢紒");
+            data.put("thing5", thing6);
+            WxUtil.sendCommonSubscribeMessage(res,data);
+            //鍙戣鍗曚俊鎭粰wx璁㈤槄鏈嶅姟娑堟伅鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�攅nd鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺��
+            return AjaxResult.success("鍙栨秷鎴愬姛");
         }
         return AjaxResult.success("鏆傛棤棰勭害淇℃伅");
     }
@@ -249,7 +342,12 @@
             mallTimeConfigService.updateById(config1);
 
             one.setReservationTime(tjReservation.getReservationTime());
-            reservationService.updateById(one);
+            if (reservationService.updateById(one)) {
+                taskService.removeTask(new TjReservationTask(tjReservation.getId()));
+                taskService.addTask(new TjReservationTask(tjReservation.getId(),
+                        DateUtil.between(new Date(),DateUtil.endOfDay(tjReservation.getReservationTime()), DateUnit.MS)));
+            }
+
             return AjaxResult.success("鎿嶄綔鎴愬姛");
         }
         return AjaxResult.error("棰勭害涓嶅瓨鍦ㄦ垨宸茶秴鏃� 涓嶅彲淇敼!");

--
Gitblit v1.8.0