| | |
| | | import com.ltkj.mall.domain.MallTimeConfig; |
| | | 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; |
| | |
| | | private IMallTimeConfigService mallTimeConfigService; |
| | | @Resource |
| | | private ISysConfigService configService; |
| | | // @Resource |
| | | // @Resource |
| | | // private OrderDelayService delayService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | |
| | | @GetMapping("/isStartYy") |
| | | @ApiOperation(value = "查询预约功能是否开启") |
| | | public AjaxResult isStartYy() { |
| | | String isStartYy = configService.selectConfigByKey("is_start_yy"); |
| | | return AjaxResult.success(isStartYy); |
| | | } |
| | | |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "个人预约") |
| | |
| | | if (!(MatchUtils.isMobileNO(tjReservation.getPhoe()))) |
| | | return AjaxResult.error("手机号错误"); |
| | | |
| | | if(tjReservation.getIdCard().length()==18){ |
| | | if (tjReservation.getIdCard().length() == 18) { |
| | | if (!MatchUtils.isIdCard(tjReservation.getIdCard())) { |
| | | return AjaxResult.error("身份证号码错误"); |
| | | } |
| | | } |
| | | if(tjReservation.getIdCard().length()==9){ |
| | | if (tjReservation.getIdCard().length() == 9) { |
| | | if (!MatchUtils.cardValidates(tjReservation.getIdCard())) { |
| | | return AjaxResult.error("身份证号码错误"); |
| | | } |
| | |
| | | TjReservation reservation = reservationService.getOne(wq); |
| | | if (null != reservation) return AjaxResult.success("您已成功预约,无需再约"); |
| | | try { |
| | | tjReservation.setBirthday(DateUtil.parse(MatchUtils.getBirthDayByIdCard(tjReservation.getIdCard()), "yyyy-MM-dd")); |
| | | tjReservation.setBirthday(MatchUtils.getBirthDayByIdCard(tjReservation.getIdCard())); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | tjReservation.setUpdateTime(new Date()); |
| | | tjReservation.setWechat(String.valueOf(wxuser.getOpenid())); |
| | | tjReservation.setConnect(String.valueOf(wxuser.getId())); |
| | | if(null !=tjReservation.getProIdList() && tjReservation.getProIdList().size()>0){ |
| | | if (null != tjReservation.getProIdList() && tjReservation.getProIdList().size() > 0) { |
| | | String join = Joiner.on(",").join(tjReservation.getProIdList()); |
| | | tjReservation.setProIds(join); |
| | | } |
| | | if (reservationService.save(tjReservation)) { |
| | | |
| | | taskService.addTask(new TjReservationTask(tjReservation.getId(), |
| | | DateUtil.between(new Date(),DateUtil.endOfDay(tjReservation.getReservationTime()), DateUnit.MS))); |
| | | 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){ |
| | | TjCustomer one = customerService.getOne(new LambdaQueryWrapper<TjCustomer>().eq(TjCustomer::getCusIdcard, tjReservation.getIdCard())); |
| | | if (null != one) { |
| | | one.setWechat(String.valueOf(wxuser.getId())); |
| | | one.setConnect(wxuser.getOpenid()); |
| | | customerService.updateById(one); |
| | | }else { |
| | | TjCustomer customer=new TjCustomer(); |
| | | } else { |
| | | TjCustomer customer = new TjCustomer(); |
| | | customer.setCusName(tjReservation.getName()); |
| | | customer.setCusSex(Long.valueOf(tjReservation.getSex())); |
| | | customer.setCusBrithday(tjReservation.getBirthday()); |
| | |
| | | if ((null == tjReservation.getProIdList() || tjReservation.getProIdList().size() == 0) && (null == tjReservation.getPacId())) { |
| | | transitionService.deletedTbTransitionByCusId(tjReservation.getIdCard()); |
| | | } |
| | | if(null !=tjReservation.getPacId()){ |
| | | asyncService.addRedisTransitionPac(tjReservation.getIdCard(), Long.valueOf(tjReservation.getPacId()),ppservice.getTjPackageProjectListByPacId(tjReservation.getPacId())); |
| | | if (null != tjReservation.getPacId()) { |
| | | asyncService.addRedisTransitionPac(tjReservation.getIdCard(), Long.valueOf(tjReservation.getPacId()), ppservice.getTjPackageProjectListByPacId(tjReservation.getPacId())); |
| | | } |
| | | |
| | | if(null !=tjReservation.getProIdList() && tjReservation.getProIdList().size()>0){ |
| | | asyncService.addRedisTransitionPro(tjReservation.getIdCard(),tjReservation.getProIdList()); |
| | | if (null != tjReservation.getProIdList() && tjReservation.getProIdList().size() > 0) { |
| | | asyncService.addRedisTransitionPro(tjReservation.getIdCard(), tjReservation.getProIdList()); |
| | | } |
| | | |
| | | String isPays = configService.selectConfigByKey("isPay"); |
| | | if(null !=isPays && isPays.equals("true") ){ |
| | | if (null != isPays && isPays.equals("true")) { |
| | | //对应预约时间数量减1 |
| | | final TjReservation byId = reservationService.getById(tjReservation.getId()); |
| | | final Date reservationTime = byId.getReservationTime(); |
| | | LambdaQueryWrapper<MallTimeConfig> wq111=new LambdaQueryWrapper<>(); |
| | | wq111.eq(MallTimeConfig::getTime,reservationTime); |
| | | LambdaQueryWrapper<MallTimeConfig> wq111 = new LambdaQueryWrapper<>(); |
| | | wq111.eq(MallTimeConfig::getTime, reservationTime); |
| | | final MallTimeConfig config = mallTimeConfigService.getOne(wq111); |
| | | config.setNowNum(config.getNowNum()-1); |
| | | 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"); |
| | | 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()); |
| | | name1.put("value", tjReservation.getName()); |
| | | data.put("thing1", name1); |
| | | |
| | | JSONObject amount3 = new JSONObject(); |
| | |
| | | data.put("time4", time4); |
| | | |
| | | final TjPackage byId = packageService.getById(tjReservation.getPacId()); |
| | | if (byId!=null){ |
| | | if (byId != null) { |
| | | JSONObject thing5 = new JSONObject(); |
| | | thing5.put("value",byId.getPacName()); |
| | | thing5.put("value", byId.getPacName()); |
| | | data.put("thing5", thing5); |
| | | }else { |
| | | } else { |
| | | JSONObject thing5 = new JSONObject(); |
| | | thing5.put("value","未知"); |
| | | thing5.put("value", "未知"); |
| | | data.put("thing5", thing5); |
| | | } |
| | | |
| | |
| | | JSONObject thing6 = new JSONObject(); |
| | | thing6.put("value", "体检前一天请您进清淡饮食,勿饮酒!"); |
| | | data.put("thing6", thing6); |
| | | WxUtil.sendCommonSubscribeMessage(res,data); |
| | | WxUtil.sendCommonSubscribeMessage(res, data); |
| | | //发订单信息给wx订阅服务消息————————————————end———————————————————————————————————————— |
| | | |
| | | return AjaxResult.success("预约成功!!!",tjReservation.getId()); |
| | | return AjaxResult.success("预约成功!!!", tjReservation.getId()); |
| | | } |
| | | return AjaxResult.error("预约失败"); |
| | | } |
| | |
| | | // wq.eq(TjReservation::getIdCard, reservation.getIdCard()); |
| | | // wq.eq(TjReservation::getIsExpire, 2); |
| | | // TjReservation one = reservationService.getOne(wq); |
| | | if (reservation.getId()==null){ |
| | | 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") ){ |
| | | if (null != isPays && isPays.equals("true")) { |
| | | //对应预约时间数量+1 |
| | | final TjReservation byId = reservationService.getById(one.getId()); |
| | | final Date reservationTime = byId.getReservationTime(); |
| | | LambdaQueryWrapper<MallTimeConfig> wq111=new LambdaQueryWrapper<>(); |
| | | wq111.eq(MallTimeConfig::getTime,reservationTime); |
| | | LambdaQueryWrapper<MallTimeConfig> wq111 = new LambdaQueryWrapper<>(); |
| | | wq111.eq(MallTimeConfig::getTime, reservationTime); |
| | | final MallTimeConfig config = mallTimeConfigService.getOne(wq111); |
| | | config.setNowNum(config.getNowNum()+1); |
| | | 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","X467Xtd8HnFDNk-IoT0ChcdoBnClLZJQQwP7DMztYQ8"); |
| | | res.put("page","pages/mine/index"); |
| | | res.put("miniprogram_state","trial"); |
| | | 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(); |
| | | |
| | |
| | | data.put("thing3", amount3); |
| | | |
| | | JSONObject name1 = new JSONObject(); |
| | | name1.put("value",reservation.getName()); |
| | | name1.put("value", reservation.getName()); |
| | | data.put("name1", name1); |
| | | |
| | | final TjPackage byId = packageService.getById(reservation.getPacId()); |
| | | if (byId!=null){ |
| | | if (byId != null) { |
| | | JSONObject thing5 = new JSONObject(); |
| | | thing5.put("value",byId.getPacName()); |
| | | thing5.put("value", byId.getPacName()); |
| | | data.put("thing4", thing5); |
| | | }else { |
| | | } else { |
| | | JSONObject thing5 = new JSONObject(); |
| | | thing5.put("value","未知"); |
| | | thing5.put("value", "未知"); |
| | | data.put("thing4", thing5); |
| | | } |
| | | |
| | |
| | | JSONObject thing6 = new JSONObject(); |
| | | thing6.put("value", "您已成功取消本次预约,欢迎再次使用!"); |
| | | data.put("thing5", thing6); |
| | | WxUtil.sendCommonSubscribeMessage(res,data); |
| | | WxUtil.sendCommonSubscribeMessage(res, data); |
| | | //发订单信息给wx订阅服务消息————————————————end———————————————————————————————————————— |
| | | return AjaxResult.success("取消成功"); |
| | | } |
| | |
| | | LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjReservation::getConnect, wxuser.getId()); |
| | | // wq.eq(TjReservation::getIsExpire, 2); |
| | | wq.eq(TjReservation::getPhoe,wxuser.getPhone()); |
| | | wq.eq(TjReservation::getPhoe, wxuser.getPhone()); |
| | | List<TjReservation> reservationList = reservationService.list(wq); |
| | | if (null != reservationList && reservationList.size()>0) { |
| | | if (null != reservationList && reservationList.size() > 0) { |
| | | for (TjReservation one : reservationList) { |
| | | TjPackage tjPackage = packageService.getById(one.getPacId()); |
| | | if (null != tjPackage) { |
| | |
| | | @Transactional |
| | | public AjaxResult updateReservationTime(@RequestBody @ApiParam(value = "体检预约对象") TjReservation tjReservation) { |
| | | TjReservation one = reservationService.getById(tjReservation.getId()); |
| | | if(null !=one && one.getIsExpire().equals(2)){ |
| | | if (null != one && one.getIsExpire().equals(2)) { |
| | | //原时间段数加1 |
| | | LambdaQueryWrapper<MallTimeConfig> wq111=new LambdaQueryWrapper<>(); |
| | | wq111.eq(MallTimeConfig::getTime,one.getReservationTime()); |
| | | LambdaQueryWrapper<MallTimeConfig> wq111 = new LambdaQueryWrapper<>(); |
| | | wq111.eq(MallTimeConfig::getTime, one.getReservationTime()); |
| | | final MallTimeConfig config = mallTimeConfigService.getOne(wq111); |
| | | config.setNowNum(config.getNowNum()+1); |
| | | config.setNowNum(config.getNowNum() + 1); |
| | | mallTimeConfigService.updateById(config); |
| | | |
| | | //修改后时间段数-1 |
| | | LambdaQueryWrapper<MallTimeConfig> wq=new LambdaQueryWrapper<>(); |
| | | wq.eq(MallTimeConfig::getTime,tjReservation.getReservationTime()); |
| | | LambdaQueryWrapper<MallTimeConfig> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(MallTimeConfig::getTime, tjReservation.getReservationTime()); |
| | | final MallTimeConfig config1 = mallTimeConfigService.getOne(wq); |
| | | config1.setNowNum(config1.getNowNum()-1); |
| | | config1.setNowNum(config1.getNowNum() - 1); |
| | | mallTimeConfigService.updateById(config1); |
| | | |
| | | one.setReservationTime(tjReservation.getReservationTime()); |
| | | 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))); |
| | | DateUtil.between(new Date(), DateUtil.endOfDay(tjReservation.getReservationTime()), DateUnit.MS))); |
| | | } |
| | | |
| | | return AjaxResult.success("操作成功"); |
| | |
| | | Wxuser wxuser = UserHoder.getWxuser(); |
| | | LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjReservation::getConnect, wxuser.getId()); |
| | | wq.eq(TjReservation::getPhoe,wxuser.getPhone()); |
| | | wq.eq(TjReservation::getPhoe, wxuser.getPhone()); |
| | | wq.orderByDesc(TjReservation::getCreateTime); |
| | | List<TjReservation> reservationList = reservationService.list(wq); |
| | | if (null != reservationList && reservationList.size() > 0) { |
| | |
| | | @ApiOperation(value = "根据身份证号查看预约信息") |
| | | public AjaxResult getReservationByIdCard(@RequestParam @ApiParam(value = "身份证号") String idCard) { |
| | | LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjReservation::getIdCard,idCard); |
| | | wq.eq(TjReservation::getIdCard, idCard); |
| | | wq.orderByDesc(TjReservation::getCreateTime); |
| | | TjReservation one = reservationService.list(wq).get(0); |
| | | if (null != one) { |
| | | // for (TjReservation one : reservationList) { |
| | | TjPackage tjPackage = packageService.getById(one.getPacId()); |
| | | if (null != tjPackage) { |
| | | LambdaQueryWrapper<TjPackageProject> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjPackageProject::getPacId, one.getPacId()); |
| | | List<TjPackageProject> projectList = ppservice.list(wq1); |
| | | if (null != projectList && projectList.size() > 0) { |
| | | List<TjProject> tjProjectList = new ArrayList<>(); |
| | | for (TjPackageProject packageProject : projectList) { |
| | | tjProjectList.add(projectService.getById(packageProject.getProId())); |
| | | } |
| | | tjPackage.setTjProjectList(tjProjectList); |
| | | TjPackage tjPackage = packageService.getById(one.getPacId()); |
| | | if (null != tjPackage) { |
| | | LambdaQueryWrapper<TjPackageProject> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjPackageProject::getPacId, one.getPacId()); |
| | | List<TjPackageProject> projectList = ppservice.list(wq1); |
| | | if (null != projectList && projectList.size() > 0) { |
| | | List<TjProject> tjProjectList = new ArrayList<>(); |
| | | for (TjPackageProject packageProject : projectList) { |
| | | tjProjectList.add(projectService.getById(packageProject.getProId())); |
| | | } |
| | | one.setTjPackage(tjPackage); |
| | | tjPackage.setTjProjectList(tjProjectList); |
| | | } |
| | | if (null != one.getProIds()) { |
| | | String[] proIds = StringUtils.split(one.getProIds(), ","); |
| | | if (null != proIds && proIds.length > 0) { |
| | | List<TjProject> projectList = new ArrayList<>(); |
| | | for (String proId : proIds) { |
| | | projectList.add(projectService.getById(proId)); |
| | | } |
| | | one.setProjectList(projectList); |
| | | one.setTjPackage(tjPackage); |
| | | } |
| | | if (null != one.getProIds()) { |
| | | String[] proIds = StringUtils.split(one.getProIds(), ","); |
| | | if (null != proIds && proIds.length > 0) { |
| | | List<TjProject> projectList = new ArrayList<>(); |
| | | for (String proId : proIds) { |
| | | projectList.add(projectService.getById(proId)); |
| | | } |
| | | one.setProjectList(projectList); |
| | | } |
| | | } |
| | | // } |
| | | return AjaxResult.success(one); |
| | | } |