| | |
| | | import com.jilongda.common.basic.PageInfo; |
| | | import com.jilongda.optometrist.authority.model.SecUser; |
| | | import com.jilongda.optometrist.authority.service.SecUserService; |
| | | import com.jilongda.optometrist.model.TOptometrist; |
| | | import com.jilongda.optometrist.model.*; |
| | | import com.jilongda.optometrist.query.TOptometristQuery; |
| | | import com.jilongda.optometrist.query.TicketQuery; |
| | | import com.jilongda.optometrist.service.TLineUpService; |
| | | import com.jilongda.optometrist.service.TOptometristService; |
| | | import com.jilongda.optometrist.service.*; |
| | | import com.jilongda.optometrist.utils.LoginInfoUtil; |
| | | import com.jilongda.optometrist.vo.TAddOptometryVO; |
| | | import com.jilongda.optometrist.vo.TLineUpDetailVO; |
| | | import com.jilongda.optometrist.vo.TOptometristVO; |
| | | import com.jilongda.optometrist.vo.TOptometryDetailVO; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private LoginInfoUtil loginInfoUtil; |
| | | @Autowired |
| | | private SecUserService secUserService; |
| | | // @ApiOperation(value = "首页") |
| | | // @PostMapping(value = "/pageList") |
| | | // public ApiResult<TOptometristVO> pageList() { |
| | | // Long userId = loginInfoUtil.getUserId(); |
| | | // |
| | | // return ApiResult.success(); |
| | | // } |
| | | @Autowired |
| | | private TStoreService storeService; |
| | | @Autowired |
| | | private TOptometryService optometryService; |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | @Autowired |
| | | private TOrderService orderService; |
| | | @Autowired |
| | | private TOptometryDetailService optometryDetailService; |
| | | @ApiOperation(value = "首页") |
| | | @PostMapping(value = "/index") |
| | | public ApiResult<TOptometristVO> index() { |
| | | TOptometristVO tOptometristVO = new TOptometristVO(); |
| | | |
| | | @ApiOperation(value = "通过门店id查询验光师列表") |
| | | @PostMapping(value = "/queryListByStoreId") |
| | | public ApiResult<List<TOptometrist>> queryListByStoreId(@RequestParam Integer storeId) { |
| | | List<TOptometrist> optometristVOPageInfo = optometristService.list(Wrappers.lambdaQuery(TOptometrist.class) |
| | | .eq(TOptometrist::getStoreId,storeId)); |
| | | return ApiResult.success(optometristVOPageInfo); |
| | | Long userId = loginInfoUtil.getUserId(); |
| | | SecUser byId = secUserService.getById(userId); |
| | | TStore byId1 = storeService.getById(byId.getStoreId()); |
| | | tOptometristVO.setStoreName(byId1.getName()); |
| | | int size = optometryService.lambdaQuery().eq(TOptometry::getOptometristId, userId) |
| | | .eq(TOptometry::getStatus, 3).list().size(); |
| | | tOptometristVO.setOptometryCount(size); |
| | | // 查询今日的排号列表 |
| | | List<TLineUp> list = tLineUpService.lambdaQuery().eq(TLineUp::getStoreId, byId.getStoreId()) |
| | | .ne(TLineUp::getStatus, 3) |
| | | .ne(TLineUp::getStatus, 5).list(); |
| | | for (TLineUp tLineUp : list) { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime createTime = tLineUp.getCreateTime(); |
| | | long minutesDifference = createTime.until(now, java.time.temporal.ChronoUnit.MINUTES); |
| | | if (minutesDifference < 0) { |
| | | minutesDifference = 0; |
| | | } |
| | | tLineUp.setWaitTime((int) minutesDifference); |
| | | } |
| | | tOptometristVO.setList(list); |
| | | return ApiResult.success(tOptometristVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "验光师添加") |
| | | @ApiOperation(value = "预约详情") |
| | | @GetMapping(value = "/getLineUpDetail") |
| | | public ApiResult<TLineUpDetailVO> getLineUpDetail(Integer id) { |
| | | TLineUpDetailVO tLineUpDetailVO = new TLineUpDetailVO(); |
| | | TLineUp byId = tLineUpService.getById(id); |
| | | BeanUtils.copyProperties(byId, tLineUpDetailVO); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime createTime = byId.getCreateTime(); |
| | | long minutesDifference = createTime.until(now, java.time.temporal.ChronoUnit.MINUTES); |
| | | if (minutesDifference < 0) { |
| | | minutesDifference = 0; |
| | | } |
| | | tLineUpDetailVO.setWaitTime((int) minutesDifference); |
| | | if (byId.getUserId()!=null){ |
| | | TAppUser byId1 = appUserService.getById(byId.getUserId()); |
| | | if (byId1!=null){ |
| | | tLineUpDetailVO.setName(byId1.getName()); |
| | | tLineUpDetailVO.setPhone(byId1.getPhone()); |
| | | tLineUpDetailVO.setAvatar(byId1.getAvatar()); |
| | | } |
| | | // 查询消费次数,验光次数 |
| | | long l = optometryService.count(Wrappers.<TOptometry>lambdaQuery() |
| | | .eq(TOptometry::getUserId, byId.getUserId()) |
| | | .eq(TOptometry::getStatus,3)); |
| | | tLineUpDetailVO.setOptometryCount((int) l); |
| | | long count = orderService.count(Wrappers.<TOrder>lambdaQuery() |
| | | .eq(TOrder::getUserId, byId.getUserId())); |
| | | tLineUpDetailVO.setSaleCount((int) count); |
| | | } |
| | | return ApiResult.success(tLineUpDetailVO); |
| | | } |
| | | @ApiOperation(value = "开始验光") |
| | | @GetMapping(value = "/startOptometry") |
| | | public ApiResult startOptometry(Integer id) { |
| | | Long userId = loginInfoUtil.getUserId(); |
| | | List<TLineUp> list = tLineUpService.lambdaQuery().eq(TLineUp::getStatus, 2) |
| | | .eq(TLineUp::getOptometristId, userId).list(); |
| | | if (!list.isEmpty())return ApiResult.failed("当前还有未结束的验光单"); |
| | | TLineUp lineUp = tLineUpService.getById(id); |
| | | lineUp.setStatus(2); |
| | | tLineUpService.updateById(lineUp); |
| | | return ApiResult.success(); |
| | | } |
| | | @ApiOperation(value = "取消排号") |
| | | @GetMapping(value = "/cancelLineUp") |
| | | public ApiResult cancelLineUp(Integer id) { |
| | | TLineUp lineUp = tLineUpService.getById(id); |
| | | lineUp.setStatus(5); |
| | | tLineUpService.updateById(lineUp); |
| | | return ApiResult.success(); |
| | | } |
| | | @ApiOperation(value = "填写验光信息完成") |
| | | @PostMapping(value = "/add") |
| | | public ApiResult<String> add(@RequestBody TOptometrist dto) { |
| | | optometristService.save(dto); |
| | | public ApiResult<String> add(@RequestBody TAddOptometryVO dto) { |
| | | TLineUp byId = tLineUpService.getById(dto.getId()); |
| | | TAppUser byId1 = appUserService.getById(byId.getUserId()); |
| | | TOptometry tOptometry = new TOptometry(); |
| | | tOptometry.setUserId(byId.getUserId()); |
| | | tOptometry.setAge(byId.getAge()); |
| | | tOptometry.setGender(byId.getGender()); |
| | | if (byId1!=null){ |
| | | tOptometry.setPhone(byId1.getPhone()); |
| | | } |
| | | Long userId = loginInfoUtil.getUserId(); |
| | | SecUser byId2 = secUserService.getById(userId); |
| | | tOptometry.setRealName(byId.getUserName()); |
| | | tOptometry.setOptometristId(userId.intValue()); |
| | | tOptometry.setStoreId(byId2.getStoreId()); |
| | | optometryService.save(tOptometry); |
| | | List<TOptometryDetail> tOptometryDetails = new ArrayList<>(); |
| | | |
| | | for (TOptometryDetailVO optometryDetailVO : dto.getOptometryDetailVOS()) { |
| | | TOptometryDetail tOptometryDetail = new TOptometryDetail(); |
| | | tOptometryDetail.setType(optometryDetailVO.getType()); |
| | | tOptometryDetail.setOptometryId(tOptometry.getId()); |
| | | tOptometryDetail.setBallMirror(optometryDetailVO.getBallMirror()); |
| | | tOptometryDetail.setColumnMirror(optometryDetailVO.getColumnMirror()); |
| | | tOptometryDetail.setAxis(optometryDetailVO.getAxis()); |
| | | tOptometryDetail.setAdd(optometryDetailVO.getAdd()); |
| | | tOptometryDetail.setPupilHeight(optometryDetailVO.getPupilHeight()); |
| | | tOptometryDetail.setPupilDistance(optometryDetailVO.getPupilDistance()); |
| | | tOptometryDetail.setCorrect(optometryDetailVO.getCorrect()); |
| | | tOptometryDetail.setStoreId(byId2.getStoreId()); |
| | | tOptometryDetail.setStatus(optometryDetailVO.getStatus()); |
| | | tOptometryDetails.add(tOptometryDetail); |
| | | } |
| | | optometryDetailService.saveBatch(tOptometryDetails); |
| | | // 验光完成 |
| | | byId.setStatus(3); |
| | | tLineUpService.updateById(byId); |
| | | return ApiResult.success(); |
| | | } |
| | | |