common-buiness/src/main/java/cn/stylefeng/guns/modular/business/mapper/mapping/MentalAppointmentMapper.xml
@@ -10,6 +10,7 @@ t_mental_appointment o LEFT JOIN toc_customer wu ON o.worker_id = wu.customer_id <where> o.`type` is null <if test="statusFlagList != null and statusFlagList.size != 0"> AND o.status_flag IN <foreach item="item" collection="statusFlagList" index="index" open="(" separator="," close=")"> rest/src/main/java/cn/stylefeng/rest/modular/order/controller/MentalTestOrderController.java
@@ -1,5 +1,6 @@ package cn.stylefeng.rest.modular.order.controller; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; import cn.stylefeng.guns.modular.business.dto.request.CreateOrderConsultOneRequest; @@ -13,6 +14,10 @@ import cn.stylefeng.guns.modular.business.service.IOrderConsultOneService; import cn.stylefeng.guns.modular.business.service.IOrderMentalTestService; import cn.stylefeng.rest.modular.order.service.MentalTestOrderBizService; import cn.stylefeng.roses.kernel.auth.api.context.LoginContext; import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser; import cn.stylefeng.roses.kernel.customer.modular.entity.Customer; import cn.stylefeng.roses.kernel.customer.modular.service.CustomerService; import cn.stylefeng.roses.kernel.rule.pojo.request.BaseIdRequest; import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData; import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData; @@ -69,12 +74,24 @@ return new SuccessResponseData(list); } @Resource private CustomerService customerService; @ApiOperation(value = "1V1咨询预约性格分析下单") @PostResource(name = "1V1咨询预约性格分析下单", path = "/createOrderConsultOne") public ResponseData<OrderConsultOne> createOrderConsultOne(@RequestBody CreateOrderConsultOneRequest req) { Assert.isTrue(StrUtil.isNotBlank(req.getRealName()), "姓名不能为空"); Assert.isTrue(StrUtil.isNotBlank(req.getLinkPhone()), "联系电话不能为空"); OrderConsultOne o = mentalTestOrderBizService.createOrderConsultOne(req); try { Customer customer =new Customer(); BeanUtil.copyProperties(req,customer); LoginUser loginUser = LoginContext.me().getLoginUser(); customer.setCustomerId(loginUser.getUserId()); customerService.updateById(customer); }catch (Exception e){ log.info("修改用户信息报错"); } return new SuccessResponseData(o); } rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java
@@ -15,16 +15,14 @@ import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; import cn.stylefeng.guns.modular.business.dto.*; import cn.stylefeng.guns.modular.business.dto.request.CounsellingOrderRequest; import cn.stylefeng.guns.modular.business.dto.request.CounsellingReservationRequest; import cn.stylefeng.guns.modular.business.dto.request.CounsellingUserRequest; import cn.stylefeng.guns.modular.business.dto.request.CreateCounsellingOrderRequest; import cn.stylefeng.guns.modular.business.dto.request.*; import cn.stylefeng.guns.modular.business.entity.*; import cn.stylefeng.guns.modular.business.service.*; import cn.stylefeng.guns.modular.business.service.impl.ImBizService; import cn.stylefeng.rest.ijpay.controller.AliPayController; import cn.stylefeng.rest.ijpay.controller.WxPayController; import cn.stylefeng.roses.kernel.auth.api.context.LoginContext; import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser; import cn.stylefeng.roses.kernel.customer.api.pojo.CustomerInfo; import cn.stylefeng.roses.kernel.customer.modular.entity.Customer; import cn.stylefeng.roses.kernel.customer.modular.service.CustomerService; @@ -583,27 +581,31 @@ this.counsellingUserService.updateById(counsellingUserOld); CounsellingInfo counsellingInfo = this.counsellingInfoService.getById(counsellingOrder.getCounsellingInfoId()); //将此条消息加入到可聊天的表中t_mental_appointment MentalAppointment mentalAppointment = MentalAppointment.builder() .userId(counsellingOrder.getUserId()) .type("1") .statusFlag(1) .appointmentDay(new SimpleDateFormat("yyyy-MM-dd").parse(counsellingReservationRequest.getDayTime())) .beginTimePoint(counsellingReservationRequest.getTimePoint().split("-")[0]) .endTimePoint(counsellingReservationRequest.getTimePoint().split("-")[1]) .workerId(counsellingUserOld.getUserId()) .workerId(counsellingInfo.getUserId()) .build(); // 用户信息 CustomerInfo customerInfo = customerService.getCustomerInfoById(counsellingOrder.getUserId()); mentalAppointment.setUserName(customerInfo.getRealName()); mentalAppointment.setPhone(customerInfo.getLinkPhone()); mentalAppointmentService.save(mentalAppointment); CounsellingInfo counsellingInfo = this.counsellingInfoService.getById(counsellingOrder.getCounsellingInfoId()); // 发送IM消息 ImPushDataDTO pushData1 = ImPushDataDTO.builder() .type(ImPushTypeEnum.C_TO_W_IM_1V1_START_CONSULT.getCode()) .title(ImPushTypeEnum.C_TO_W_IM_1V1_START_CONSULT.getName()) .content("预约成功"+",请注意预约时间:"+counsellingOrder.getEffectiveEndTime()+"~"+counsellingOrder.getEffectiveEndTime()) .content("预约成功"+",请注意预约时间:"+counsellingReservationRequest.getDayTime()+counsellingReservationRequest.getTimePoint()) // .content("预约成功!") .objId(ObjUtil.toString(counsellingInfo.getId())) .data1(ObjUtil.toString(counsellingOrder.getUserId())) @@ -614,18 +616,18 @@ new String[]{ObjUtil.toString(counsellingInfo.getUserId())}, pushData1); // // 推送消息内容 // String pushContent = "你的预约("+DateUtil.formatDate(counsellingOrder.getFirstAppointmentDate())+" "+counsellingOrder.getFirstAppointmentTimes()+")已确认,请按时参加"; // // IM推送数据json // ImPushDataDTO pushData = ImPushDataDTO.builder() // .type(ImPushTypeEnum.S_TO_W_TIP_CONSULT_PAY_SUCCESS.getCode()) // .objId(ObjUtil.toString(counsellingOrderReservation.getId())) // .title("通知") // .content(pushContent) //// .extra("("+DateUtil.formatDate(counsellingOrder.getFirstAppointmentDate())+" "+counsellingOrder.getFirstAppointmentTimes()+")") // .build(); // // 发送首次预约 // imBizService.messageSendSystem(counsellingOrderReservation.getUserId()+"", new String[]{counsellingOrderReservation.getUserId()+""}, pushData, ImUserTypeEnum.USER, null, true); // 推送消息内容 String pushContent = "你的预约("+DateUtil.formatDate(counsellingOrder.getFirstAppointmentDate())+" "+counsellingOrder.getFirstAppointmentTimes()+")已确认,请按时参加"; // IM推送数据json ImPushDataDTO pushData = ImPushDataDTO.builder() .type(ImPushTypeEnum.S_TO_W_TIP_CONSULT_PAY_SUCCESS.getCode()) .objId(ObjUtil.toString(counsellingOrderReservation.getId())) .title("通知") .content(pushContent) // .extra("("+DateUtil.formatDate(counsellingOrder.getFirstAppointmentDate())+" "+counsellingOrder.getFirstAppointmentTimes()+")") .build(); // 发送首次预约 imBizService.messageSendSystem(counsellingOrderReservation.getUserId()+"", new String[]{counsellingOrderReservation.getUserId()+""}, pushData, ImUserTypeEnum.USER, null, true); }else{ counsellingOrderReservation.setStauts(1); counsellingOrderReservation.setReservationType(2); @@ -653,6 +655,18 @@ customerService.updateCustomerRemoveCache(customer); } try { CustomerUpdateRequest customerUpdateRequest = counsellingReservationRequest.getCustomerUpdateRequest(); Customer customer = new Customer(); BeanUtil.copyProperties(customerUpdateRequest,customer); LoginUser loginUser = LoginContext.me().getLoginUser(); customer.setCustomerId(loginUser.getUserId()); customerService.updateById(customer); }catch (Exception e){ e.printStackTrace(); log.info("编辑用户报错"); } return new SuccessResponseData<>(counsellingOrderReservation); } rest/src/main/java/cn/stylefeng/rest/modular/work/MentalAppointmentWork.java
@@ -47,11 +47,11 @@ * Corn表达式 @Scheduled(cron = Corn表达式) * @Scheduled(cron = "0 0/30 * * * *") */ @Scheduled(fixedRate = 1000 * 30) public void autoStartMentalAppointment() { // 当前时间 DateTime dateTime = DateUtil.date(); // 待开始预约单 List<MentalAppointment> mentalAppointmentList = mentalAppointmentService.list( Wrappers.<MentalAppointment>lambdaUpdate() @@ -68,10 +68,11 @@ } for (MentalAppointment o : mentalAppointmentList) { MentalTestMyTestTopicDTO mentalTestMyTestTopicDTO = myTestRecordTopicList.stream().filter(rt -> rt.getMentalAppointmentId().equals(o.getId())).findFirst().orElse(new MentalTestMyTestTopicDTO()); if (o.getType()==null) { MentalTestMyTestTopicDTO mentalTestMyTestTopicDTO = myTestRecordTopicList.stream().filter(rt -> rt.getMentalAppointmentId().equals(o.getId())).findFirst().orElse(new MentalTestMyTestTopicDTO()); // 发送IM消息 ImPushDataDTO pushData = ImPushDataDTO.builder() // 发送IM消息 ImPushDataDTO pushData = ImPushDataDTO.builder() .type(ImPushTypeEnum.C_TO_W_IM_1V1_START_CONSULT.getCode()) .title(ImPushTypeEnum.C_TO_W_IM_1V1_START_CONSULT.getName()) .content("做了" @@ -82,11 +83,12 @@ .data2(ObjUtil.toString(o.getWorkerId())) .data3(ObjUtil.toString(mentalTestMyTestTopicDTO.getId())) .build(); imBizService.messageSendPrivate( ObjUtil.toString(o.getUserId()), new String[]{ObjUtil.toString(o.getWorkerId())}, pushData ); imBizService.messageSendPrivate( ObjUtil.toString(o.getUserId()), new String[]{ObjUtil.toString(o.getWorkerId())}, pushData ); } // 开始预约咨询 mentalAppointmentService.update( @@ -99,6 +101,32 @@ } } // @Scheduled(fixedRate = 1000 * 30) // public void autoStartMentalAppointment1() { // // 当前时间 // DateTime dateTime = DateUtil.date(); // // 待开始预约单 // List<MentalAppointment> mentalAppointmentList = mentalAppointmentService.list( // Wrappers.<MentalAppointment>lambdaUpdate() // .eq(MentalAppointment::getStatusFlag, MentalAppointmentStatusEnum.WAIT_SERVICE.getCode()) // .eq(MentalAppointment::getType,"1") // .apply("DATE_ADD(appointment_day, INTERVAL TIME_TO_SEC(begin_time_point) SECOND) < NOW()") //// .le(MentalAppointment::getAppointmentDay, dateTime.toDateStr()) //// .le(MentalAppointment::getBeginTimePoint, DateUtil.format(dateTime, "HH:mm")) // ); // // for (MentalAppointment o : mentalAppointmentList) { // // 开始预约咨询 // mentalAppointmentService.update( // Wrappers.<MentalAppointment>lambdaUpdate() // .eq(MentalAppointment::getId, o.getId()) // .set(MentalAppointment::getStatusFlag, MentalAppointmentStatusEnum.IN_SERVICE.getCode()) // .set(MentalAppointment::getConsultStatus, MentalAppointmentConsultStatusEnum.IN_CONSULT.getCode()) // ); // log.info("开始预约咨询: {}", JSONUtil.toJsonStr(o)); // } // } @Scheduled(fixedRate = 1000 * 60) public void autoEndMentalAppointment() { // 当前时间