package cn.stylefeng.guns.modular.business.controller;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.date.DateField;
|
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
import cn.stylefeng.guns.modular.business.dto.CounsellingOrderReservationRequestDTO;
|
import cn.stylefeng.guns.modular.business.dto.CounsellingOrderReservationResponseDTO;
|
import cn.stylefeng.guns.modular.business.entity.*;
|
import cn.stylefeng.guns.modular.business.service.*;
|
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.util.StrUtil;
|
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
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;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.rule.annotation.BusinessLog;
|
import cn.stylefeng.roses.kernel.rule.enums.CustomerWorkStatusEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.PostIdEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.PostTypeEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.ResBizTypeEnum;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ErrorResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
/**
|
* 咨询师信息管理类
|
* @author guo
|
*/
|
@RestController
|
@Api(tags = "咨询师信息管理类")
|
@ApiResource(name = "咨询师信息管理类", resBizType = ResBizTypeEnum.BUSINESS)
|
@RequestMapping("/business")
|
public class CounsellingInfoController {
|
|
@Resource
|
private ICounsellingInfoService counsellingInfoService;
|
|
@Resource
|
private ICounsellingTagService counsellingTagService;
|
|
@Resource
|
private ICounsellingSetMealService counsellingSetMealService;
|
|
@Resource
|
private CustomerService customerService;
|
|
@Resource
|
private ICounsellingTimeConfigService counsellingTimeConfigService;
|
|
@Resource
|
private ICounsellingSpecialTimeConfigService counsellingSpecialTimeConfigService;
|
|
@Resource
|
private ICounsellingOrderReservationService counsellingOrderReservationService;
|
|
/**
|
* 添加咨询师信息
|
*/
|
@ApiOperation("添加咨询师信息")
|
@PostResource(name = "添加咨询师信息", path = "/counsellingInfo/add")
|
@BusinessLog
|
public ResponseData<?> add(@RequestBody CounsellingInfo counsellingInfo) {
|
long count = this.counsellingInfoService.count(new LambdaQueryWrapper<CounsellingInfo>().eq(CounsellingInfo::getUserId,counsellingInfo.getUserId())
|
.eq(CounsellingInfo::getIsDelete,false));
|
if (count > 0){
|
return new ErrorResponseData<>("500","咨询师已存在,请勿重新添加!");
|
}
|
this.counsellingInfoService.saveOrUpdateCounsellingInfo(counsellingInfo);
|
return new SuccessResponseData<>();
|
}
|
|
/**
|
* 删除咨询师信息
|
*/
|
@ApiOperation("删除咨询师信息")
|
@PostResource(name = "删除咨询师信息", path = "/counsellingInfo/delete")
|
@BusinessLog
|
public ResponseData<?> delete(@RequestParam String ids) {
|
if (StrUtil.isBlank(ids)){
|
return new ErrorResponseData<>("500","id不能为空");
|
}
|
LambdaUpdateWrapper<CounsellingInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<CounsellingInfo>().set(CounsellingInfo::getIsDelete,true);
|
lambdaUpdateWrapper.in(CounsellingInfo::getId, ListUtil.toList(ids.split(",")));
|
this.counsellingInfoService.update(lambdaUpdateWrapper);
|
return new SuccessResponseData<>();
|
}
|
|
/**
|
* 修改咨询师信息
|
*/
|
@ApiOperation("修改咨询师信息")
|
@PostResource(name = "修改咨询师信息", path = "/counsellingInfo/edit")
|
@BusinessLog
|
public ResponseData<?> edit(@RequestBody CounsellingInfo counsellingInfo) {
|
long count = this.counsellingInfoService.count(new LambdaQueryWrapper<CounsellingInfo>().eq(CounsellingInfo::getUserId,counsellingInfo.getUserId())
|
.eq(CounsellingInfo::getIsDelete,false).ne(CounsellingInfo::getUserId,counsellingInfo.getUserId()));
|
if (count > 0){
|
return new ErrorResponseData<>("500","咨询师已存在,请勿重新添加!");
|
}
|
this.counsellingInfoService.saveOrUpdateCounsellingInfo(counsellingInfo);
|
return new SuccessResponseData<>();
|
}
|
|
/**
|
* 获取咨询师信息详情
|
*/
|
@ApiOperation("获取咨询师信息详情")
|
@GetResource(name = "获取咨询师信息详情", path = "/counsellingInfo/detail/{id}", requiredPermission = false)
|
public ResponseData<CounsellingInfo> detail(@PathVariable("id") Long id) {
|
CounsellingInfo counsellingInfo = this.counsellingInfoService.getById(id);
|
//获取课程标签名称
|
LambdaQueryWrapper<CounsellingTag> counsellingTagLambdaQueryWrapper = new QueryWrapper<CounsellingTag>().select(" GROUP_CONCAT(tag_name) tagName ").lambda();
|
Map<String,Object> map = counsellingTagService.getMap(counsellingTagLambdaQueryWrapper.in(CounsellingTag::getId,counsellingInfo.getCounsellingTagIds().split(",")));
|
if (ObjectUtil.isNotEmpty(map)){
|
counsellingInfo.setCounsellingTagNames(map.get("tagName").toString());
|
}
|
//查询套餐信息
|
counsellingInfo.setCounsellingSetMealList(this.counsellingSetMealService.list(new LambdaQueryWrapper<CounsellingSetMeal>().eq(CounsellingSetMeal::getCounsellingInfoId,counsellingInfo.getId()).eq(CounsellingSetMeal::getIsDelete,false)));
|
//根据客户信息
|
Customer customer = this.customerService.getById(counsellingInfo.getUserId());
|
if (customer != null){
|
counsellingInfo.setUserName(customer.getNickName());
|
}
|
|
return new SuccessResponseData<>(counsellingInfo);
|
}
|
|
@ApiOperation("获取咨询师信息详情-根据用户id")
|
@GetResource(name = "获取咨询师信息详情-根据用户id", path = "/counsellingInfo/detail/user/{userId}", requiredPermission = false)
|
public ResponseData<CounsellingInfo> userDetail(@PathVariable("userId") Long userId) {
|
CounsellingInfo counsellingInfo = this.counsellingInfoService.getOne(new LambdaQueryWrapper<CounsellingInfo>()
|
.eq(CounsellingInfo::getUserId,userId).eq(CounsellingInfo::getIsDelete,0));
|
if (counsellingInfo == null){
|
return new SuccessResponseData<>(null);
|
}
|
//获取课程标签名称
|
LambdaQueryWrapper<CounsellingTag> counsellingTagLambdaQueryWrapper = new QueryWrapper<CounsellingTag>().select(" GROUP_CONCAT(tag_name) tagName ").lambda();
|
Map<String,Object> map = counsellingTagService.getMap(counsellingTagLambdaQueryWrapper.in(CounsellingTag::getId,counsellingInfo.getCounsellingTagIds().split(",")));
|
if (ObjectUtil.isNotEmpty(map)){
|
counsellingInfo.setCounsellingTagNames(map.get("tagName").toString());
|
}
|
//查询套餐信息
|
counsellingInfo.setCounsellingSetMealList(this.counsellingSetMealService.list(new LambdaQueryWrapper<CounsellingSetMeal>().eq(CounsellingSetMeal::getCounsellingInfoId,counsellingInfo.getId()).eq(CounsellingSetMeal::getIsDelete,false)));
|
//根据客户信息
|
Customer customer = this.customerService.getById(counsellingInfo.getUserId());
|
if (customer != null){
|
counsellingInfo.setUserName(customer.getNickName());
|
}
|
|
return new SuccessResponseData<>(counsellingInfo);
|
}
|
|
|
/**
|
* 获取咨询师信息列表
|
*
|
*/
|
@ApiOperation("获取咨询师信息列表")
|
@GetResource(name = "获取咨询师信息列表", path = "/counsellingInfo/list", requiredPermission = false)
|
public ResponseData<List<CounsellingInfo>> list(CounsellingInfo counsellingInfo) {
|
LambdaQueryWrapper<CounsellingInfo> lambdaQueryWrapper = new LambdaQueryWrapper<CounsellingInfo>().eq(CounsellingInfo::getIsDelete,false)
|
.orderByDesc(CounsellingInfo::getId);
|
lambdaQueryWrapper.eq(counsellingInfo.getListingStatus() != null,CounsellingInfo::getListingStatus,counsellingInfo.getListingStatus());
|
List<Customer> customerList = this.customerService.getWorkerListByLineStatusAndPost(null, PostTypeEnum.CONSULT.getCode(), 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);
|
}else{
|
lambdaQueryWrapper.eq(CounsellingInfo::getUserId,-1);
|
}
|
List<CounsellingInfo> list = counsellingInfoService.list(lambdaQueryWrapper);
|
if (CollectionUtil.isNotEmpty(list)){
|
list.forEach(counsellingInfo1 -> {
|
Customer customer = this.customerService.getById(counsellingInfo1.getUserId());
|
if (customer != null){
|
counsellingInfo1.setUserName(customer.getNickName());
|
}
|
});
|
}
|
return new SuccessResponseData<>(list);
|
}
|
|
/**
|
* 获取咨询师信息列表(分页)
|
*/
|
@ApiOperation("获取咨询师信息列表(分页)")
|
@GetResource(name = "获取咨询师信息列表(分页)", path = "/counsellingInfo/page", requiredPermission = false)
|
public ResponseData<PageResult<CounsellingInfo>> page(CounsellingInfo counsellingInfo) {
|
LambdaQueryWrapper<CounsellingInfo> lambdaQueryWrapper = new LambdaQueryWrapper<CounsellingInfo>().eq(CounsellingInfo::getIsDelete,false)
|
.orderByAsc(CounsellingInfo::getSort);
|
lambdaQueryWrapper.eq(counsellingInfo.getListingStatus() != null,CounsellingInfo::getListingStatus,counsellingInfo.getListingStatus());
|
if (StrUtil.isNotBlank(counsellingInfo.getUserName())){
|
List<Long> customerIds = this.customerService.list(new LambdaQueryWrapper<Customer>().select(Customer::getCustomerId).like(Customer::getNickName,counsellingInfo.getUserName())
|
.eq(Customer::getStatusFlag,1).eq(Customer::getUserType,1)).stream().map(Customer::getCustomerId).collect(Collectors.toList());
|
if (CollectionUtil.isNotEmpty(customerIds)){
|
lambdaQueryWrapper.in(CounsellingInfo::getUserId,customerIds);
|
}else{
|
lambdaQueryWrapper.eq(CounsellingInfo::getUserId,-1);
|
}
|
|
}
|
|
Page<CounsellingInfo> page = this.counsellingInfoService.page(PageFactory.defaultPage(), lambdaQueryWrapper);
|
if (CollectionUtil.isNotEmpty(page.getRecords())){
|
page.getRecords().forEach(counsellingInfo1 -> {
|
Customer customer = this.customerService.getById(counsellingInfo1.getUserId());
|
if (customer != null){
|
counsellingInfo1.setUserName(customer.getNickName());
|
}
|
});
|
}
|
return new SuccessResponseData<>(PageResultFactory.createPageResult(page));
|
}
|
|
@ApiOperation("修改咨询师上架状态")
|
@PostResource(name = "修改咨询师上架状态", path = "/counsellingInfo/updateStatus")
|
@BusinessLog
|
public ResponseData<?> updateStatus(String ids, Integer status) {
|
if (StrUtil.isBlank(ids)){
|
return new ErrorResponseData<>("500","id不能为空");
|
}
|
LambdaUpdateWrapper<CounsellingInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<CounsellingInfo>();
|
lambdaUpdateWrapper.in(CounsellingInfo::getId, ListUtil.toList(ids.split(",")));
|
lambdaUpdateWrapper.set(CounsellingInfo::getListingStatus,status)
|
.set(CounsellingInfo::getUpdateUser, LoginContext.me().getLoginUser().getUserId());
|
this.counsellingInfoService.update(lambdaUpdateWrapper);
|
return new SuccessResponseData<>();
|
}
|
|
@ApiOperation("咨询预约特殊时间配置")
|
@PostResource(name = "咨询预约特殊时间配置", path = "/counsellingInfo/saveOrUpdateSpecialTimeConfig")
|
@BusinessLog
|
public ResponseData<?> saveOrUpdateSpecialTimeConfig(@RequestBody List<CounsellingSpecialTimeConfig> counsellingSpecialTimeConfigs){
|
|
if (CollectionUtil.isNotEmpty(counsellingSpecialTimeConfigs)){
|
this.counsellingSpecialTimeConfigService.remove(new LambdaQueryWrapper<CounsellingSpecialTimeConfig>().eq(CounsellingSpecialTimeConfig::getCounsellingInfoId,counsellingSpecialTimeConfigs.get(0).getCounsellingInfoId())
|
.eq(CounsellingSpecialTimeConfig::getSpecialDay,DateUtil.formatDate(counsellingSpecialTimeConfigs.get(0).getSpecialDay())));
|
if (counsellingSpecialTimeConfigs.get(0).getIsCancelDay().intValue() ==1){
|
CounsellingSpecialTimeConfig counsellingSpecialTimeConfig = counsellingSpecialTimeConfigs.get(0);
|
|
counsellingSpecialTimeConfig.setSpecialBeginTimePoint(null);
|
counsellingSpecialTimeConfig.setSpecialEndTimePoint(null);
|
this.counsellingSpecialTimeConfigService.save(counsellingSpecialTimeConfig);
|
return new SuccessResponseData<>();
|
|
}
|
this.counsellingSpecialTimeConfigService.saveOrUpdateBatch(counsellingSpecialTimeConfigs);
|
}
|
|
return new SuccessResponseData<>();
|
}
|
|
|
@ApiOperation("置空咨询预约特殊时间配置")
|
@PostResource(name = "置空咨询预约特殊时间配置", path = "/counsellingInfo/restSpecialTimeConfig")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "counsellingInfoId", value = "咨询师id", dataTypeClass = Long.class, paramType = "query"),
|
@ApiImplicitParam(name = "specialDay", value = "日期 yyyy-MM-dd)", dataTypeClass = String.class, paramType = "query")
|
})
|
@BusinessLog
|
public ResponseData<?> restSpecialTimeConfig(Long counsellingInfoId,String specialDay){
|
this.counsellingSpecialTimeConfigService.remove(new LambdaQueryWrapper<CounsellingSpecialTimeConfig>()
|
.eq(CounsellingSpecialTimeConfig::getCounsellingInfoId,counsellingInfoId).eq(CounsellingSpecialTimeConfig::getSpecialDay,specialDay));
|
return new SuccessResponseData<>();
|
}
|
|
@ApiOperation("获取指定咨询师近30天的特殊时间配置")
|
@GetResource (name = "获取指定咨询师近30天的特殊时间配置", path = "/counsellingInfo/getCounsellingSpecialTimeConfigByCounsellingInfoId")
|
@BusinessLog
|
public ResponseData<List<CounsellingSpecialTimeConfig>> getCounsellingSpecialTimeConfigByCounsellingInfoId(Long counsellingInfoId){
|
Date beginDate = new Date();
|
Date endDate = DateUtil.offsetDay(beginDate,30);
|
List<CounsellingSpecialTimeConfig> counsellingSpecialTimeConfigList = this.counsellingSpecialTimeConfigService.list(new LambdaQueryWrapper<CounsellingSpecialTimeConfig>().ge(CounsellingSpecialTimeConfig::getSpecialDay,DateUtil.formatDate(beginDate))
|
.le(CounsellingSpecialTimeConfig::getSpecialDay,DateUtil.formatDate(endDate)).eq(CounsellingSpecialTimeConfig::getCounsellingInfoId,counsellingInfoId));
|
return new SuccessResponseData<>(counsellingSpecialTimeConfigList);
|
}
|
|
|
|
/**
|
* 获取咨询订单预约记录列表(分页)
|
*/
|
@ApiOperation("查看日程(分页)")
|
@GetResource(name = "查看日程(分页)", path = "/counsellingInfo/pageCounsellingOrderReservation", requiredPermission = false)
|
public ResponseData<PageResult<CounsellingOrderReservation>> pageCounsellingOrderReservation(CounsellingOrderReservationRequestDTO counsellingOrderReservationRequestDTO) {
|
Page<CounsellingOrderReservation> page = this.counsellingOrderReservationService.findPage(PageFactory.defaultPage(), counsellingOrderReservationRequestDTO);
|
return new SuccessResponseData<>(PageResultFactory.createPageResult(page));
|
}
|
|
@ApiOperation("获取指定咨询师近30天的预约记录")
|
@GetResource(name = "获取指定咨询师近30天的预约记录", path = "/counsellingInfo/getCounsellingOrderReservationByCounsellingInfoId", requiredPermission = false)
|
public ResponseData<List<CounsellingOrderReservationResponseDTO>> getCounsellingOrderReservationByCounsellingInfoId(Long counsellingInfoId) {
|
CounsellingOrderReservationRequestDTO counsellingOrderReservationRequestDTO = new CounsellingOrderReservationRequestDTO();
|
counsellingOrderReservationRequestDTO.setCounsellingInfoId(counsellingInfoId);
|
counsellingOrderReservationRequestDTO.setPageNo(1);
|
counsellingOrderReservationRequestDTO.setPageSize(Integer.MAX_VALUE);
|
counsellingOrderReservationRequestDTO.setSearchEndTime(DateUtil.formatDateTime(new Date()));
|
counsellingOrderReservationRequestDTO.setSearchBeginTime(DateUtil.offsetDay(new Date(),-30).toString());
|
Page<CounsellingOrderReservation> page = this.counsellingOrderReservationService.findPage(PageFactory.defaultPage(counsellingOrderReservationRequestDTO), counsellingOrderReservationRequestDTO);
|
if (CollectionUtil.isNotEmpty(page.getRecords())){
|
return new SuccessResponseData<>(BeanUtil.copyToList(page.getRecords(),CounsellingOrderReservationResponseDTO.class));
|
}
|
return new SuccessResponseData<>();
|
}
|
|
@ApiOperation("获取指定咨询师星期时间点配置")
|
@GetResource(name = "获取指定咨询师星期时间点配置", path = "/counsellingInfo/getCounsellingTimeConfigByCounsellingInfoId", requiredPermission = false)
|
public ResponseData<List<CounsellingTimeConfig>> getCounsellingTimeConfigByCounsellingInfoId(Long counsellingInfoId){
|
List<CounsellingTimeConfig> counsellingTimeConfigs = this.counsellingTimeConfigService.list(new LambdaQueryWrapper<CounsellingTimeConfig>().eq(CounsellingTimeConfig::getCounsellingInfoId,counsellingInfoId));
|
return new SuccessResponseData<>(counsellingTimeConfigs);
|
|
}
|
|
}
|