package cn.stylefeng.guns.modular.business.controller;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.util.StrUtil;
|
import cn.stylefeng.guns.modular.business.entity.StoreAppointment;
|
import cn.stylefeng.guns.modular.business.service.IStoreAppointmentService;
|
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
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.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 cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 门店预约管理类
|
* @author guo
|
*/
|
@RestController
|
@Api(tags = "门店预约管理类")
|
@ApiResource(name = "门店预约管理类", resBizType = ResBizTypeEnum.BUSINESS)
|
@RequestMapping("/business")
|
public class StoreAppointmentController {
|
|
@Resource
|
private IStoreAppointmentService storeAppointmentService;
|
|
@Resource
|
private SysUserService sysUserService;
|
|
// @ApiOperation("添加门店预约")
|
// @PostResource(name = "添加门店预约", path = "/storeAppointment/add")
|
// @BusinessLog
|
// public ResponseData<?> add(@RequestBody StoreAppointment storeAppointment) {
|
// this.storeAppointmentService.save(storeAppointment);
|
// return new SuccessResponseData<>();
|
// }
|
|
/**
|
* 删除门店预约
|
*/
|
@ApiOperation("删除门店预约")
|
@PostResource(name = "删除门店预约", path = "/storeAppointment/delete")
|
@BusinessLog
|
public ResponseData<?> delete(@RequestParam String ids) {
|
if (StrUtil.isBlank(ids)){
|
return new ErrorResponseData<>("500","id不能为空");
|
}
|
LambdaUpdateWrapper<StoreAppointment> lambdaUpdateWrapper = new LambdaUpdateWrapper<StoreAppointment>().set(StoreAppointment::getIsDelete,true);
|
lambdaUpdateWrapper.in(StoreAppointment::getId, ListUtil.toList(ids.split(",")));
|
this.storeAppointmentService.update(lambdaUpdateWrapper);
|
return new SuccessResponseData<>();
|
}
|
|
// @ApiOperation("修改门店预约")
|
// @PostResource(name = "修改门店预约", path = "/storeAppointment/edit")
|
// @BusinessLog
|
// public ResponseData<?> edit(@RequestBody StoreAppointment storeAppointment) {
|
// this.storeAppointmentService.updateById(storeAppointment);
|
// return new SuccessResponseData<>();
|
// }
|
|
/**
|
* 修改门店预约状态
|
*/
|
@ApiOperation("修改门店预约状态")
|
@ApiImplicitParams({@ApiImplicitParam(name = "status",value = "状态:0预约中/未跟进,2已跟进")})
|
@PostResource(name = "修改门店预约状态", path = "/storeAppointment/updateStatus")
|
@BusinessLog
|
public ResponseData<?> updateStatus(String ids, Integer status) {
|
if (StrUtil.isBlank(ids)){
|
return new ErrorResponseData<>("500","id不能为空");
|
}
|
LambdaUpdateWrapper<StoreAppointment> lambdaUpdateWrapper = new LambdaUpdateWrapper<StoreAppointment>().set(StoreAppointment::getStatusFlag,status);
|
lambdaUpdateWrapper.set(StoreAppointment::getFollowUserId, LoginContext.me().getLoginUser().getUserId());
|
lambdaUpdateWrapper.set(StoreAppointment::getFollowTime,new Date());
|
lambdaUpdateWrapper.in(StoreAppointment::getId, ListUtil.toList(ids.split(",")));
|
this.storeAppointmentService.update(lambdaUpdateWrapper);
|
return new SuccessResponseData<>();
|
}
|
|
/**
|
* 获取门店预约详情
|
*/
|
@ApiOperation("获取门店预约详情")
|
@GetResource(name = "获取门店预约详情", path = "/storeAppointment/detail/{id}", requiredPermission = false)
|
public ResponseData<StoreAppointment> detail(@PathVariable("id") Long id) {
|
StoreAppointment storeAppointment = this.storeAppointmentService.getById(id);
|
return new SuccessResponseData<>(storeAppointment);
|
}
|
|
/**
|
* 获取门店预约列表
|
*
|
*/
|
@ApiOperation("获取门店预约列表")
|
@GetResource(name = "获取门店预约列表", path = "/storeAppointment/list", requiredPermission = false)
|
public ResponseData<List<StoreAppointment>> list(StoreAppointment storeAppointment) {
|
LambdaQueryWrapper<StoreAppointment> lambdaQueryWrapper = new LambdaQueryWrapper<StoreAppointment>().eq(StoreAppointment::getIsDelete,false)
|
.orderByDesc(StoreAppointment::getId);
|
return new SuccessResponseData<>(storeAppointmentService.list(lambdaQueryWrapper));
|
}
|
|
/**
|
* 获取门店预约列表(分页)
|
*/
|
@ApiOperation("获取门店预约列表(分页)")
|
@GetResource(name = "获取门店预约列表(分页)", path = "/storeAppointment/page", requiredPermission = false)
|
public ResponseData<PageResult<StoreAppointment>> page(StoreAppointment storeAppointment) {
|
LambdaQueryWrapper<StoreAppointment> lambdaQueryWrapper = new LambdaQueryWrapper<StoreAppointment>()
|
.eq(StoreAppointment::getIsDelete, false)
|
.orderByAsc(StoreAppointment::getStatusFlag);
|
lambdaQueryWrapper.like(StrUtil.isNotBlank(storeAppointment.getUserName()), StoreAppointment::getUserName, storeAppointment.getUserName());
|
lambdaQueryWrapper.like(StrUtil.isNotBlank(storeAppointment.getPhone()), StoreAppointment::getPhone, storeAppointment.getPhone());
|
if (storeAppointment.getStatusFlag() != null){
|
if (storeAppointment.getStatusFlag().intValue() == 0){
|
lambdaQueryWrapper.eq(StoreAppointment::getStatusFlag,storeAppointment.getStatusFlag());
|
}else {
|
lambdaQueryWrapper.in(StoreAppointment::getStatusFlag,ListUtil.toList(1,2));
|
}
|
}
|
Page<StoreAppointment> page = this.storeAppointmentService.page(PageFactory.defaultPage(), lambdaQueryWrapper);
|
if (CollectionUtil.isNotEmpty(page.getRecords())){
|
page.getRecords().forEach(storeAppointment1 -> {
|
if (storeAppointment1.getFollowUserId() != null){
|
SysUser followUser = sysUserService.getById(storeAppointment1.getFollowUserId());
|
if (followUser != null){
|
storeAppointment1.setFollowUserName(followUser.getNickName());
|
}
|
}
|
});
|
}
|
return new SuccessResponseData<>(PageResultFactory.createPageResult(page));
|
}
|
|
}
|