From 20943c22ea68ef1dc4be8dd0e6721c7336ca3400 Mon Sep 17 00:00:00 2001
From: yanghb <yanghb>
Date: 星期四, 11 四月 2024 16:09:16 +0800
Subject: [PATCH] 4.9

---
 rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java |   64 ++++++++++++++++++++++++++------
 1 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java b/rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java
index 4995c54..e07c9c7 100644
--- a/rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java
+++ b/rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java
@@ -25,6 +25,7 @@
 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.customer.api.pojo.CustomerInfo;
 import cn.stylefeng.roses.kernel.customer.modular.entity.Customer;
 import cn.stylefeng.roses.kernel.customer.modular.service.CustomerService;
 import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
@@ -56,6 +57,8 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
@@ -115,6 +118,8 @@
 
     @Resource
     private AliPayController aliPayController;
+    @Resource
+    private IMentalAppointmentService mentalAppointmentService;
 
     @Value("${refund.alipay-url}")
     private String refundAlipayUrl;
@@ -481,9 +486,10 @@
     }
 
 
+
     @ApiOperation("咨询订单预约")
     @PostResource(name = "咨询订单预约", path = "/counsellingOrderReservation/saveCounsellingOrderReservation")
-    public ResponseData<CounsellingOrderReservation> saveCounsellingOrderReservation(@RequestBody CounsellingReservationRequest counsellingReservationRequest){
+    public ResponseData<CounsellingOrderReservation> saveCounsellingOrderReservation(@RequestBody CounsellingReservationRequest counsellingReservationRequest) throws ParseException {
         //查询咨询师当天是否取消预约
         CounsellingSpecialTimeConfig specialTimeConfig = this.counsellingSpecialTimeConfigService.getOne(new LambdaQueryWrapper<CounsellingSpecialTimeConfig>().eq(CounsellingSpecialTimeConfig::getCounsellingInfoId,counsellingReservationRequest.getCounsellingId())
                 .eq(CounsellingSpecialTimeConfig::getSpecialDay,counsellingReservationRequest.getDayTime()).eq(CounsellingSpecialTimeConfig::getIsCancelDay,1));
@@ -576,18 +582,50 @@
             this.counsellingOrderService.updateById(counsellingOrder);
             this.counsellingUserService.updateById(counsellingUserOld);
 
-            // 推送消息内容
-            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()+")")
+
+            //将此条消息加入到可聊天的表中t_mental_appointment
+            MentalAppointment mentalAppointment = MentalAppointment.builder()
+                    .userId(counsellingOrder.getUserId())
+                    .statusFlag(1)
+                    .appointmentDay(new SimpleDateFormat("yyyy-MM-dd").parse(counsellingReservationRequest.getDayTime()))
+                    .beginTimePoint(counsellingReservationRequest.getTimePoint().split("-")[0])
+                    .endTimePoint(counsellingReservationRequest.getTimePoint().split("-")[1])
+                    .workerId(counsellingUserOld.getUserId())
                     .build();
-            // 发送首次预约
-            imBizService.messageSendSystem(counsellingOrderReservation.getUserId()+"", new String[]{counsellingOrderReservation.getUserId()+""}, pushData, ImUserTypeEnum.USER, null, true);
+            // 用户信息
+            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("预约成功!")
+                    .objId(ObjUtil.toString(counsellingInfo.getId()))
+                    .data1(ObjUtil.toString(counsellingOrder.getUserId()))
+                    .data2(ObjUtil.toString(counsellingInfo.getUserId()))
+                    .build();
+            imBizService.messageSendPrivate(
+                    ObjUtil.toString(counsellingOrder.getUserId()),
+                    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);
         }else{
             counsellingOrderReservation.setStauts(1);
             counsellingOrderReservation.setReservationType(2);
@@ -664,6 +702,8 @@
             counsellingOrderReservationRequestDTO.setCustomerId(LoginContext.me().getLoginUser().getUserId());
         }
         Page<CounsellingOrderReservation> page = this.counsellingOrderReservationService.findReservationPage(PageFactory.defaultPage(), counsellingOrderReservationRequestDTO);
+
+
         return new SuccessResponseData<>(PageResultFactory.createPageResult(page));
     }
 

--
Gitblit v1.7.1