1
lige
2023-12-22 cb7ba105e4d14d1c2d6fb9db287bc4cc58417c1b
ltkj-admin/src/main/java/com/ltkj/web/controller/app/ReservationController.java
@@ -1,6 +1,7 @@
package com.ltkj.web.controller.app;
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;
@@ -15,6 +16,7 @@
import com.ltkj.mall.service.IMallTimeConfigService;
import com.ltkj.system.service.ISysConfigService;
import com.ltkj.web.config.redis.OrderDelayService;
import com.ltkj.web.wxUtils.WxUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -24,10 +26,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: 西安路泰科技有限公司
@@ -153,6 +152,47 @@
                config.setNowNum(config.getNowNum()-1);
                mallTimeConfigService.updateById(config);
            }
            //发订单信息给wx订阅服务消息————————————————start————————————————————————————————————————
            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订阅服务消息————————————————end————————————————————————————————————————
            return AjaxResult.success("预约成功!!!",tjReservation.getId());
        }
        return AjaxResult.error("预约失败");
@@ -162,10 +202,15 @@
    @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("出错了,请联系工作人员!");
        }
        TjReservation one = reservationService.getById(reservation.getId());
        if (null != one) {
            String isPays = configService.selectConfigByKey("isPay");
            if(null !=isPays  && isPays.equals("true") ){
@@ -181,7 +226,46 @@
            transitionService.deletedTbTransitionByCusId(reservation.getIdCard());
            reservationService.removeById(one);
            return AjaxResult.success();
            //发订单信息给wx订阅服务消息————————————————start————————————————————————————————————————
            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订阅服务消息————————————————end————————————————————————————————————————
            return AjaxResult.success("取消成功");
        }
        return AjaxResult.success("暂无预约信息");
    }