From 6bc25b33e90d45904d1843e927fa709dfeb51d7f Mon Sep 17 00:00:00 2001 From: yanghb <yanghb> Date: 星期一, 15 四月 2024 15:57:41 +0800 Subject: [PATCH] 4.15 --- rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java | 187 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 158 insertions(+), 29 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 e07c9c7..cb47674 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 @@ -15,16 +15,15 @@ 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.cache.api.CacheOperatorApi; 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; @@ -39,6 +38,7 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource; import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource; import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource; +import cn.stylefeng.roses.kernel.system.modular.role.entity.SysRole; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -166,6 +166,10 @@ } + @Resource + private CacheOperatorApi<List<CounsellinginfoResponseDTO>> roleInfoCacheApi; + + /** * 获取咨询师信息列表(分页) */ @@ -176,9 +180,14 @@ @ApiImplicitParam(name = "pageSize", value = "分页:每页大小(默认10)", dataTypeClass = Integer.class, paramType = "query"), @ApiImplicitParam(name = "searchType", value = "查询类型 1-严选,2-普通查询,默认2", dataTypeClass = Integer.class, paramType = "query") }) - public ResponseData<PageResult<CounsellinginfoResponseDTO>> page(Integer pageNo, Integer pageSize,Integer searchType) { + public ResponseData<List<CounsellinginfoResponseDTO>> page(Integer pageNo, Integer pageSize,Integer searchType) { + if (roleInfoCacheApi.get("customer")!=null){ + List<CounsellinginfoResponseDTO> customer = roleInfoCacheApi.get("customer"); + return new SuccessResponseData<>(customer); + } + LambdaQueryWrapper<CounsellingInfo> lambdaQueryWrapper = new LambdaQueryWrapper<CounsellingInfo>().eq(CounsellingInfo::getIsDelete,false) - .orderByDesc(CounsellingInfo::getSort,CounsellingInfo::getCreateTime).eq(CounsellingInfo::getListingStatus,1); + .orderByDesc(CounsellingInfo::getSort,CounsellingInfo::getCreateTime).eq(CounsellingInfo::getListingStatus,1); //默认普通查询 if (searchType != null && searchType.intValue() == 1){ List<Customer> customerList = customerService.getWorkerListByLineStatusAndPost(null, null, PostIdEnum.PO_22.getCode(), CustomerWorkStatusEnum.ON_WORK.getCode()); @@ -187,9 +196,9 @@ lambdaQueryWrapper.in(CounsellingInfo::getUserId,customerIds); } } - Page<CounsellingInfo> page = this.counsellingInfoService.page(PageFactory.defaultPage(), lambdaQueryWrapper); - if (CollectionUtil.isNotEmpty(page.getRecords())){ - List<Long> counseIds = page.getRecords().stream().map(CounsellingInfo::getId).collect(Collectors.toList()); + List<CounsellingInfo> page = this.counsellingInfoService.list(lambdaQueryWrapper); + if (CollectionUtil.isNotEmpty(page)){ + List<Long> counseIds = page.stream().map(CounsellingInfo::getId).collect(Collectors.toList()); QueryWrapper<CounsellingOrder> orderQueryWrapper = new QueryWrapper<CounsellingOrder>().select("counselling_info_id counsellingInfoId,count(1) num "); //查询是否首次咨询 orderQueryWrapper.lambda().eq(CounsellingOrder::getUserId,LoginContext.me().getLoginUser().getUserId()).in(CounsellingOrder::getStatusFlag,1,2).in(CounsellingOrder::getCounsellingInfoId,counseIds) @@ -205,14 +214,14 @@ //查询标签总条数 List<CounsellingTag> counsellingTags = this.counsellingTagService.list(new LambdaQueryWrapper<CounsellingTag>() .select(CounsellingTag::getId,CounsellingTag::getTagName)); - List<Long> custommerIds = page.getRecords().stream().map(CounsellingInfo::getUserId).collect(Collectors.toList()); + List<Long> custommerIds = page.stream().map(CounsellingInfo::getUserId).collect(Collectors.toList()); //查询客户ids List<Customer> customerList = this.customerService.list(new LambdaQueryWrapper<Customer>().select(Customer::getCustomerId,Customer::getNickName).in(Customer::getCustomerId,custommerIds)); //查询套餐最低价 List<Map<String,Object>> lowMapList = this.counsellingSetMealService.listMaps(new QueryWrapper<CounsellingSetMeal>().select(" counselling_info_id counsellingInfoId,IFNULL(min(price),0) price ").lambda().in(CounsellingSetMeal::getCounsellingInfoId,counseIds) .eq(CounsellingSetMeal::getSetMealType,1).eq(CounsellingSetMeal::getIsDelete,0)); - List<CounsellinginfoResponseDTO> counsellinginfoResponseDTOS = BeanUtil.copyToList(page.getRecords(),CounsellinginfoResponseDTO.class, CopyOptions.create()); + List<CounsellinginfoResponseDTO> counsellinginfoResponseDTOS = BeanUtil.copyToList(page,CounsellinginfoResponseDTO.class, CopyOptions.create()); counsellinginfoResponseDTOS.stream().forEach(counsellinginfoResponseDTO -> { if (fristMap.get(counsellinginfoResponseDTO.getId()) != null){ counsellinginfoResponseDTO.setIsFirstBuy(true); @@ -224,7 +233,7 @@ // LambdaQueryWrapper<CounsellingTag> counsellingTagLambdaQueryWrapper = new QueryWrapper<CounsellingTag>().select(" GROUP_CONCAT(tag_name) tagName ").lambda(); // Map<String,Object> map = counsellingTagService.getMap(counsellingTagLambdaQueryWrapper.in(CounsellingTag::getId,counsellinginfoResponseDTO.getCounsellingTagIds().split(","))); // if (ObjectUtil.isNotEmpty(map)){ - counsellinginfoResponseDTO.setCounsellingTagNames(tagNames); + counsellinginfoResponseDTO.setCounsellingTagNames(tagNames); // } } counsellinginfoResponseDTO.setPersonalProfile(null); @@ -249,10 +258,93 @@ }); - return new SuccessResponseData<>(PageResultFactory.createPageResult(counsellinginfoResponseDTOS,page.getTotal(), Convert.toInt(page.getSize()),Convert.toInt(page.getCurrent()))); + + return new SuccessResponseData<>(counsellinginfoResponseDTOS); } - return new SuccessResponseData<>(PageResultFactory.createPageResult(new ArrayList<CounsellinginfoResponseDTO>(),page.getTotal(), Convert.toInt(page.getSize()),Convert.toInt(page.getCurrent()))); + return new SuccessResponseData<>(); + + + + + + +// LambdaQueryWrapper<CounsellingInfo> lambdaQueryWrapper = new LambdaQueryWrapper<CounsellingInfo>().eq(CounsellingInfo::getIsDelete,false) +// .orderByDesc(CounsellingInfo::getSort,CounsellingInfo::getCreateTime).eq(CounsellingInfo::getListingStatus,1); +// //默认普通查询 +// if (searchType != null && searchType.intValue() == 1){ +// List<Customer> customerList = customerService.getWorkerListByLineStatusAndPost(null, null, PostIdEnum.PO_22.getCode(), CustomerWorkStatusEnum.ON_WORK.getCode()); +// if (CollectionUtil.isNotEmpty(customerList)){ +// List<Long> customerIds = customerList.stream().map(Customer::getCustomerId).collect(Collectors.toList()); +// lambdaQueryWrapper.in(CounsellingInfo::getUserId,customerIds); +// } +// } +// Page<CounsellingInfo> page = this.counsellingInfoService.page(PageFactory.defaultPage(), lambdaQueryWrapper); +// if (CollectionUtil.isNotEmpty(page.getRecords())){ +// List<Long> counseIds = page.getRecords().stream().map(CounsellingInfo::getId).collect(Collectors.toList()); +// QueryWrapper<CounsellingOrder> orderQueryWrapper = new QueryWrapper<CounsellingOrder>().select("counselling_info_id counsellingInfoId,count(1) num "); +// //查询是否首次咨询 +// orderQueryWrapper.lambda().eq(CounsellingOrder::getUserId,LoginContext.me().getLoginUser().getUserId()).in(CounsellingOrder::getStatusFlag,1,2).in(CounsellingOrder::getCounsellingInfoId,counseIds) +// .eq(CounsellingOrder::getOrderType,1).groupBy(CounsellingOrder::getCounsellingInfoId).having(" num > 0 "); +// List<Map<String,Object>> mapList = this.counsellingOrderService.listMaps(orderQueryWrapper); +// Map<Long,Object> fristMap = new HashMap<>(); +// if (CollectionUtil.isNotEmpty(mapList)){ +// +// mapList.stream().forEach(stringObjectMap -> { +// fristMap.put(Long.parseLong(stringObjectMap.get("counsellingInfoId").toString()),stringObjectMap.get("num")); +// }); +// } +// //查询标签总条数 +// List<CounsellingTag> counsellingTags = this.counsellingTagService.list(new LambdaQueryWrapper<CounsellingTag>() +// .select(CounsellingTag::getId,CounsellingTag::getTagName)); +// List<Long> custommerIds = page.getRecords().stream().map(CounsellingInfo::getUserId).collect(Collectors.toList()); +// //查询客户ids +// List<Customer> customerList = this.customerService.list(new LambdaQueryWrapper<Customer>().select(Customer::getCustomerId,Customer::getNickName).in(Customer::getCustomerId,custommerIds)); +// //查询套餐最低价 +// List<Map<String,Object>> lowMapList = this.counsellingSetMealService.listMaps(new QueryWrapper<CounsellingSetMeal>().select(" counselling_info_id counsellingInfoId,IFNULL(min(price),0) price ").lambda().in(CounsellingSetMeal::getCounsellingInfoId,counseIds) +// .eq(CounsellingSetMeal::getSetMealType,1).eq(CounsellingSetMeal::getIsDelete,0)); +// +// List<CounsellinginfoResponseDTO> counsellinginfoResponseDTOS = BeanUtil.copyToList(page.getRecords(),CounsellinginfoResponseDTO.class, CopyOptions.create()); +// counsellinginfoResponseDTOS.stream().forEach(counsellinginfoResponseDTO -> { +// if (fristMap.get(counsellinginfoResponseDTO.getId()) != null){ +// counsellinginfoResponseDTO.setIsFirstBuy(true); +// } +// if (StrUtil.isNotBlank(counsellinginfoResponseDTO.getCounsellingTagIds())){ +// List<String> counsellingTagList = Arrays.asList(counsellinginfoResponseDTO.getCounsellingTagIds().split(",")); +// String tagNames = counsellingTags.stream().filter(cou -> counsellingTagList.contains(cou.getId().toString())).map(CounsellingTag::getTagName).collect(Collectors.joining(",")); +// //获取课程标签名称 +//// LambdaQueryWrapper<CounsellingTag> counsellingTagLambdaQueryWrapper = new QueryWrapper<CounsellingTag>().select(" GROUP_CONCAT(tag_name) tagName ").lambda(); +//// Map<String,Object> map = counsellingTagService.getMap(counsellingTagLambdaQueryWrapper.in(CounsellingTag::getId,counsellinginfoResponseDTO.getCounsellingTagIds().split(","))); +//// if (ObjectUtil.isNotEmpty(map)){ +// counsellinginfoResponseDTO.setCounsellingTagNames(tagNames); +//// } +// } +// counsellinginfoResponseDTO.setPersonalProfile(null); +// +// counsellinginfoResponseDTO.setNikeName(customerList.stream().filter(cus -> counsellinginfoResponseDTO.getUserId().longValue() == cus.getCustomerId().longValue()).findFirst().get().getNickName()); +// +//// BigDecimal lowPrice = this.counsellingSetMealService.getObj(new QueryWrapper<CounsellingSetMeal>().select(" counselling_info_id counsellingInfoId,IFNULL(min(price),0) price ").lambda().eq(CounsellingSetMeal::getCounsellingInfoId,counsellinginfoResponseDTO.getId()) +//// .eq(CounsellingSetMeal::getSetMealType,1).eq(CounsellingSetMeal::getIsDelete,0),Convert::toBigDecimal); +// +// +// if (CollectionUtil.isNotEmpty(lowMapList)){ +// lowMapList.stream().forEach(stringObjectMap -> { +// if (stringObjectMap.get("counsellingInfoId") != null){ +// counsellinginfoResponseDTO.setLowPrice(new BigDecimal(stringObjectMap.get("price").toString())); +// } +// }); +// if (counsellinginfoResponseDTO.getLowPrice() == null){ +// counsellinginfoResponseDTO.setLowPrice(new BigDecimal(0)); +// } +// } +// +// +// }); +// +// return new SuccessResponseData<>(PageResultFactory.createPageResult(counsellinginfoResponseDTOS,page.getTotal(), Convert.toInt(page.getSize()),Convert.toInt(page.getCurrent()))); +// } +// +// return new SuccessResponseData<>(PageResultFactory.createPageResult(new ArrayList<CounsellinginfoResponseDTO>(),page.getTotal(), Convert.toInt(page.getSize()),Convert.toInt(page.getCurrent()))); } @@ -583,27 +675,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 +710,39 @@ 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("通知") + .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); }else{ counsellingOrderReservation.setStauts(1); counsellingOrderReservation.setReservationType(2); @@ -653,6 +770,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); } -- Gitblit v1.7.1