From c19572d66b72775dc3a1674fc948f30acc93f9de Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期四, 18 四月 2024 21:44:34 +0800
Subject: [PATCH] 4.17

---
 common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/CounsellingOrderServiceImpl.java |  146 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 113 insertions(+), 33 deletions(-)

diff --git a/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/CounsellingOrderServiceImpl.java b/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/CounsellingOrderServiceImpl.java
index 7346db6..0215c01 100644
--- a/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/CounsellingOrderServiceImpl.java
+++ b/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/CounsellingOrderServiceImpl.java
@@ -29,6 +29,7 @@
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -155,39 +156,43 @@
                     Boolean update = customerService.updateCustomerRemoveCache(customer);
                     counsellingOrder.setUserInfoJson(JSONUtil.toJsonStr(customerUpdateRequest));
                 }
+//                Date firstAppointmentDate = counsellingOrderRequest.getFirstAppointmentDate();
+//// 创建一个 SimpleDateFormat 实例,指定日期格式为 "yyyy-MM-dd"
+//                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+//
+//// 使用 formatter 将 Date 对象转换为字符串
+//                String formattedDate = formatter.format(firstAppointmentDate);
+//                // 发送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("预约成功"+",请注意预约时间:"+formattedDate+counsellingOrderRequest.getFirstAppointmentTimes())
+////                    .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
+//
+//
+//            );
 
-
-                            // 发送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
-
-
-            );
-
-                //将此条消息加入到可聊天的表中t_mental_appointment
-                MentalAppointment mentalAppointment = MentalAppointment.builder()
-                        .userId(counsellingOrder.getUserId())
-                        .appointmentDay(counsellingOrderRequest.getFirstAppointmentDate())
-                        .beginTimePoint(counsellingOrderRequest.getFirstAppointmentTimes().split("-")[0])
-                        .endTimePoint(counsellingOrderRequest.getFirstAppointmentTimes().split("-")[1])
-                        .workerId(counsellingInfo.getUserId())
-                        .build();
-                // 用户信息
-                CustomerInfo customerInfo = customerService.getCustomerInfoById(counsellingOrder.getUserId());
-                mentalAppointment.setUserName(customerInfo.getRealName());
-                mentalAppointment.setPhone(customerInfo.getLinkPhone());
-                mentalAppointmentService.save(mentalAppointment);
+//                //将此条消息加入到可聊天的表中t_mental_appointment
+//                MentalAppointment mentalAppointment = MentalAppointment.builder()
+//                        .userId(counsellingOrder.getUserId())
+//                        .appointmentDay(counsellingOrderRequest.getFirstAppointmentDate())
+//                        .beginTimePoint(counsellingOrderRequest.getFirstAppointmentTimes().split("-")[0])
+//                        .endTimePoint(counsellingOrderRequest.getFirstAppointmentTimes().split("-")[1])
+//                        .workerId(counsellingInfo.getUserId())
+//                        .build();
+//                // 用户信息
+//                CustomerInfo customerInfo = customerService.getCustomerInfoById(counsellingOrder.getUserId());
+//                mentalAppointment.setUserName(customerInfo.getRealName());
+//                mentalAppointment.setPhone(customerInfo.getLinkPhone());
+//                mentalAppointmentService.save(mentalAppointment);
 
             }
             if (counsellingUserOld != null && counsellingUserOld.getConsultantUserId() != null){
@@ -513,7 +518,82 @@
             counsellingOrderReservation.setStauts(2);
             this.counsellingOrderReservationService.save(counsellingOrderReservation);
             //新增
-            iImGroupService.createGroup(2,null,null,counsellingInfo.getUserId(),null,null,counsellingOrder.getUserId(),counsellingOrder.getCounsellingInfoId());
+//            iImGroupService.createGroup(2,null,null,counsellingInfo.getUserId(),null,null,counsellingOrder.getUserId(),counsellingOrder.getCounsellingInfoId());
+
+
+            //新增
+
+
+            //将此条消息加入到可聊天的表中t_mental_appointment
+            MentalAppointment mentalAppointment = MentalAppointment.builder()
+                    .userId(counsellingOrder.getUserId())
+                    .type("1")
+                    .statusFlag(1)
+                    .appointmentDay(counsellingOrder.getFirstAppointmentDate())
+                    .beginTimePoint(counsellingOrder.getFirstAppointmentTimes().split("-")[0])
+                    .endTimePoint(counsellingOrder.getFirstAppointmentTimes().split("-")[1])
+                    .workerId(counsellingInfo.getUserId())
+                    .build();
+            // 用户信息
+            CustomerInfo customerInfo = customerService.getCustomerInfoById(counsellingOrder.getUserId());
+            mentalAppointment.setUserName(customerInfo.getRealName());
+            mentalAppointment.setPhone(customerInfo.getLinkPhone());
+            mentalAppointmentService.save(mentalAppointment);
+
+            // 创建一个 SimpleDateFormat 实例,指定日期格式为 "yyyy-MM-dd"
+            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+
+// 使用 formatter 将 Date 对象转换为字符串
+            String formattedDate = formatter.format(counsellingOrder.getFirstAppointmentDate());
+            // 发送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("预约成功"+",请注意预约时间:"+formattedDate+counsellingOrder.getFirstAppointmentTimes())
+//                    .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("通知")
+                    .data1(ObjUtil.toString(counsellingInfo.getUserId()))
+                    .data2(ObjUtil.toString(counsellingOrder.getUserId()))
+                    .content(pushContent)
+//                    .extra("("+DateUtil.formatDate(counsellingOrder.getFirstAppointmentDate())+" "+counsellingOrder.getFirstAppointmentTimes()+")")
+                    .build();
+            // 发送首次预约
+            imBizService.messageSendSystem(counsellingOrderReservation.getUserId()+"", new String[]{counsellingOrderReservation.getUserId()+""}, pushData, ImUserTypeEnum.USER, null, true);
+
+
+            //给咨询师发消息
+            Customer customerOld = this.customerService.getById(counsellingOrderReservation.getUserId());
+
+            String pushContent1 = "你有新的预约,请注意查收。预约用户:"+customerOld.getNickName()+",预约时间:"+DateUtil.formatDate(counsellingOrder.getFirstAppointmentDate())+" "+counsellingOrder.getFirstAppointmentTimes();
+//                    +"预约时间:"+counsellingOrder.getEffectiveEndTime()+"~"+counsellingOrder.getEffectiveEndTime();
+            // IM推送数据json
+            ImPushDataDTO pushData2 = ImPushDataDTO.builder()
+                    .type(ImPushTypeEnum.S_TO_W_TIP_CONSULT_PAY_GROUP_SUCCESS.getCode())
+                    .objId(ObjUtil.toString(counsellingInfo.getUserId()))
+                    .title("通知")
+                    .content(pushContent1)
+                    .data1(ObjUtil.toString(counsellingOrder.getUserId()))
+                    .data2(ObjUtil.toString(counsellingInfo.getUserId()))
+//                    .extra("去查看。")
+                    .build();
+            // 发送预约提示
+            imBizService.messageSendSystem(counsellingOrder.getUserId()+"", new String[]{counsellingInfo.getUserId()+""}, pushData2, ImUserTypeEnum.WORKER, PostIdEnum.PO_22, true);
+
 
             // 推送消息内容
 //            String pushContent = "我购买了心理咨询疗程,需要咨询";

--
Gitblit v1.7.1