| | |
| | | package com.ruoyi.order.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.vo.PaperInVo; |
| | | import com.ruoyi.common.core.vo.Path; |
| | | import com.ruoyi.order.entity.*; |
| | | import com.ruoyi.order.entity.ChangeDispatch; |
| | | import com.ruoyi.order.entity.Evaluate; |
| | | import com.ruoyi.order.entity.Order; |
| | | import com.ruoyi.order.entity.ServeCoordinate; |
| | | import com.ruoyi.order.entity.ServeRecord; |
| | | import com.ruoyi.order.request.OrderCountDataRequest; |
| | | import com.ruoyi.order.request.OrderRequest; |
| | | import com.ruoyi.order.request.OrderSubmitRequest; |
| | | import com.ruoyi.order.request.UserOrderRequest; |
| | | import com.ruoyi.order.service.*; |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.order.service.ChangeDispatchService; |
| | | import com.ruoyi.order.service.EvaluateService; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.service.ServeCoordinateService; |
| | | import com.ruoyi.order.service.ServeRecordService; |
| | | import com.ruoyi.order.vo.MoneyQueryRequest; |
| | | import com.ruoyi.order.vo.OrderCountRequest; |
| | | import com.ruoyi.order.vo.OrderCountVO; |
| | | import com.ruoyi.order.vo.OrderDetailVO; |
| | | import com.ruoyi.order.vo.OrderPageCountVO; |
| | | import com.ruoyi.order.vo.OrderQueryRequest; |
| | | import com.ruoyi.order.vo.OrderResultVO; |
| | | import com.ruoyi.order.vo.WorkerOrderCountVO; |
| | | import com.ruoyi.order.vo.WorkerOrderRankVO; |
| | | import com.ruoyi.user.api.feignClient.UserClient; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | .eq(Order::getIsDelete, 0).list()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单列表 |
| | | * |
| | |
| | | return R.ok(orderService.lambdaUpdate() |
| | | .eq(Order::getId, orderId).set(Order::getState, state).update()); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "订单列表-增加打印次数", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/count") |
| | | public R<Boolean> count(@RequestParam("orderId") String orderId) { |
| | | Order byId = orderService.getById(orderId); |
| | | byId.setPrintCount(byId.getPrintCount()==null?1:byId.getPrintCount()+1); |
| | | orderService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 增加发送短信次数 |
| | | * @param orderId 订单id |
| | | */ |
| | | @ApiOperation(value = "订单列表-增加发送短信次数", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/msgCount") |
| | | public R<?> messageCount(@RequestParam("orderId") String orderId) { |
| | | orderService.messageCount(orderId); |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation(value = "订单列表-获取入库单", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/papercount") |
| | | public R<List<PaperInVo>> inpaper(@RequestParam("workId") String workId,@RequestParam("date") String date) { |
| | | |
| | | List<PaperInVo> paper = orderService.papercout(workId,date); |
| | | return R.ok(paper); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 更改订单状态且清空到达时间 |
| | |
| | | BigDecimal subsidy = order.getSubsidy(); |
| | | if (null == subsidy) { |
| | | order.setSubsidy(bigDecimal); |
| | | order.setOrderMoney(order.getOrderMoney().add(bigDecimal)); |
| | | } else { |
| | | BigDecimal add = order.getSubsidy().add(bigDecimal); |
| | | order.setSubsidy(add); |
| | | order.setOrderMoney(order.getOrderMoney().add(bigDecimal)); |
| | | } |
| | | return R.ok(orderService.updateById(order)); |
| | | } |
| | |
| | | return R.ok(orderService.save(order)); |
| | | } |
| | | |
| | | @PostMapping(value = "/queryIdsBycode") |
| | | public R<List<Integer>> queryIdsBycode(@RequestBody List<String> cityList) { |
| | | List<Integer> collect = orderService.lambdaQuery().eq(BaseEntity::getIsDelete,0).in(Order::getCityCode, cityList).list().stream().map(Order::getUserId).collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更改订单信息 |
| | | * |
| | |
| | | return R.ok(order); |
| | | } |
| | | |
| | | @Resource |
| | | private UserClient userClient; |
| | | /** |
| | | * 新增订单 |
| | | * 后台订单为指定订单,默认为待上门状态 |
| | |
| | | @ApiOperation(value = "订单列表-新增订单", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/save") |
| | | public R<Boolean> save(@RequestBody OrderRequest orderRequest) { |
| | | |
| | | R<BigDecimal> servePrice = userClient.getServePrice(orderRequest.getServeId(), orderRequest.getCityCode()); |
| | | if (servePrice.getData()!=null){ |
| | | orderRequest.setOrderMoney(servePrice.getData()); |
| | | } |
| | | |
| | | |
| | | |
| | | Order order = new Order(); |
| | | order.setCity(orderRequest.getCity()); |
| | | order.setOrderNumber(orderRequest.getOrderNumber()); |
| | |
| | | order.setSiteName(orderRequest.getSiteName()); |
| | | order.setServeId(orderRequest.getServeId()); |
| | | order.setServeName(orderRequest.getServeName()); |
| | | order.setServePrice(orderRequest.getServePrice()); |
| | | order.setServePrice(orderRequest.getOrderMoney()); |
| | | order.setSiteName(orderRequest.getSiteName()); |
| | | // 预约信息 |
| | | order.setReservationName(orderRequest.getReservationName()); |
| | | order.setReservationPhone(orderRequest.getReservationPhone()); |
| | | order.setReservationAddress(orderRequest.getReservationAddress()); |
| | | |
| | | order.setTime(orderRequest.getTime()); |
| | | order.setAcceptTime(orderRequest.getAcceptTime()); |
| | | // order.setAcceptTime(new Date()); |
| | | // 师傅信息 |
| | | order.setServerId(orderRequest.getServerId()); |
| | | order.setServerName(orderRequest.getServerName()); |
| | |
| | | order.setCancelReason(orderRequest.getCancelReason()); |
| | | order.setApplyReason(orderRequest.getApplyReason()); |
| | | order.setIsEvaluate(Constants.ZERO); |
| | | order.setCityCode(orderRequest.getCityCode()); |
| | | order.setOrderMoney(orderRequest.getOrderMoney()); |
| | | order.setProvinceCode(orderRequest.getProvinceCode()); |
| | | order.setAreaCode(orderRequest.getAreaCode()); |
| | | return R.ok(orderService.save(order)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "订单列表-新增订单", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/edit") |
| | | public R<Boolean> edit(@RequestBody OrderRequest orderRequest) { |
| | | |
| | | R<BigDecimal> servePrice = userClient.getServePrice(orderRequest.getServeId(), orderRequest.getCityCode()); |
| | | if (servePrice.getData()!=null){ |
| | | orderRequest.setOrderMoney(servePrice.getData()); |
| | | } |
| | | |
| | | |
| | | Order order = orderService.getById(orderRequest.getOrderId()); |
| | | if (order.getState()!=6) { |
| | | if ((!Objects.equals(order.getServerId(), orderRequest.getServerId())) || (!Objects.equals(order.getTime(), orderRequest.getTime()))) { |
| | | order.setState(1); |
| | | order.setArriveTime(null); |
| | | order.setAcceptTime(new Date()); |
| | | orderService.lambdaUpdate() |
| | | .eq(Order::getId, order.getId() |
| | | ).set(Order::getArriveTime, null).update(); |
| | | |
| | | } |
| | | } |
| | | |
| | | order.setId(orderRequest.getOrderId()); |
| | | order.setCity(orderRequest.getCity()); |
| | | order.setOrderNumber(orderRequest.getOrderNumber()); |
| | | order.setUserId(orderRequest.getUserId()); |
| | | order.setSiteId(orderRequest.getSiteId()); |
| | | order.setSiteName(orderRequest.getSiteName()); |
| | | order.setServeId(orderRequest.getServeId()); |
| | | order.setServeName(orderRequest.getServeName()); |
| | | order.setServePrice(orderRequest.getOrderMoney()); |
| | | order.setSiteName(orderRequest.getSiteName()); |
| | | order.setTime(orderRequest.getTime()); |
| | | // 预约信息 |
| | | order.setReservationName(orderRequest.getReservationName()); |
| | | order.setReservationPhone(orderRequest.getReservationPhone()); |
| | | order.setReservationAddress(orderRequest.getReservationAddress()); |
| | | // order.setTime(orderRequest.getTime()); |
| | | // order.setAcceptTime(orderRequest.getAcceptTime()); |
| | | // 师傅信息 |
| | | order.setServerId(orderRequest.getServerId()); |
| | | order.setServerName(orderRequest.getServerName()); |
| | | order.setServerPhone(orderRequest.getServerPhone()); |
| | | order.setReservationRemark(orderRequest.getReservationRemark()); |
| | | |
| | | order.setArriveTime(orderRequest.getArriveTime()); |
| | | // order.setType(orderRequest.getType()); |
| | | order.setLongitude(orderRequest.getLongitude()); |
| | | order.setLatitude(orderRequest.getLatitude()); |
| | | order.setCompleteTime(orderRequest.getCompleteTime()); |
| | | // order.setSubsidy(orderRequest.getSubsidy()); |
| | | order.setIsWithdrawal(orderRequest.getIsWithdrawal()); |
| | | order.setAddress(orderRequest.getAddress()); |
| | | order.setCancelReason(orderRequest.getCancelReason()); |
| | | order.setApplyReason(orderRequest.getApplyReason()); |
| | | order.setIsEvaluate(Constants.ZERO); |
| | | order.setCityCode(orderRequest.getCityCode()); |
| | | order.setOrderMoney(orderRequest.getServePrice()); |
| | | if (order.getSubsidy()!=null){ |
| | | order.setOrderMoney(order.getServePrice().add(order.getSubsidy())); |
| | | } |
| | | order.setProvinceCode(orderRequest.getProvinceCode()); |
| | | order.setAreaCode(orderRequest.getAreaCode()); |
| | | return R.ok(orderService.updateById(order)); |
| | | } |
| | | |
| | | |
| | |
| | | List<String> idList = Arrays.stream(ids.split(",")).collect(Collectors.toList()); |
| | | List<Order> list = orderService.lambdaQuery().in(Order::getId, idList).list(); |
| | | list.forEach(data -> data.setIsDelete(1)); |
| | | |
| | | List<ChangeDispatch> list1 = changeDispatchService.lambdaQuery().in(ChangeDispatch::getOrderId, idList).list(); |
| | | if (!list1.isEmpty()) { |
| | | list1.forEach(data -> data.setIsDelete(1)); |
| | | changeDispatchService.updateBatchById(list1); |
| | | } |
| | | return R.ok(orderService.updateBatchById(list)); |
| | | } |
| | | |
| | |
| | | return R.ok(orderService.orderCountHome(orderCount)); |
| | | } |
| | | |
| | | //获取师傅当天的订单 |
| | | @PostMapping(value = "/workday") |
| | | public R<List<Order>> workday(@RequestBody Integer workId) { |
| | | // 获取当前日期 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | |
| | | // 使用 format 方法将 LocalDate 对象转换为字符串 |
| | | String formattedToday = LocalDate.now().format(formatter); |
| | | |
| | | System.out.println(formattedToday); // 输出:2023-09-12(假设今天是2023年9月12日) |
| | | |
| | | |
| | | // 构建 Lambda 查询条件 |
| | | LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper |
| | | .eq(Order::getTime, formattedToday) // 当天开始时间 |
| | | ; // 当天结束时间 |
| | | |
| | | // 执行查询 |
| | | List<Order> orders = orderService.list(queryWrapper.eq(Order::getServerId,workId)); |
| | | |
| | | // 处理查询结果 |
| | | for (Order order : orders) { |
| | | System.out.println(order); |
| | | } |
| | | return R.ok(orders); |
| | | } |
| | | /** |
| | | * 用户所关联订单记录分页列表 |
| | | * |
| | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @GetMapping(value = "/orderList1") |
| | | public R<Page<Order>> orderList1(@RequestParam("userId") Integer userId, @RequestParam("cityList") List<String> cityList, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Page<Order> page = orderService.lambdaQuery().eq(Order::getUserId, userId) |
| | | .eq(Order::getIsDelete, 0).in(!cityList.isEmpty(),Order::getCityCode, cityList).page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @GetMapping(value = "/workOrderList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "师傅id", name = "workId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Page<Order>> workOrderList(@RequestParam("workId") Integer workId, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Page<Order> page = orderService.lambdaQuery().eq(Order::getServerId, workId) |
| | | .eq(Order::getIsDelete, 0).page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | /** |
| | | * 根据类型获取交易额 |
| | | * |
| | |
| | | * @return 交易额 |
| | | */ |
| | | @ApiOperation(value = "根据类型获取交易额", tags = {"后台-用户管理-用户列表"}) |
| | | @PostMapping(value = "/tradeMoney") |
| | | @PostMapping (value = "/tradeMoney") |
| | | public R<BigDecimal> tradeMoney(@RequestBody MoneyQueryRequest moneyQueryRequest) { |
| | | return R.ok(orderService.tradeMoney(moneyQueryRequest)); |
| | | } |
| | |
| | | public R<OrderDetailVO> orderDetail(@RequestParam("orderId") String orderId) { |
| | | // 订单信息 |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, orderId).eq(Order::getIsDelete, 0).one(); |
| | | order.setReservationAddress(order.getReservationAddress() + order.getAddress()); |
| | | if (order.getAddress()!=null) { |
| | | order.setReservationAddress(order.getReservationAddress() + order.getAddress()); |
| | | } |
| | | // 服务信息(服务备注、上门时间、完成时间、完成所拍现场照片) |
| | | ServeRecord serveRecord = serveRecordService.lambdaQuery().eq(ServeRecord::getOrderId, orderId) |
| | | .eq(ServeRecord::getIsDelete, 0).one(); |
| | |
| | | } |
| | | order.setCompleteTime(new Date()); |
| | | order.setState(Constants.THREE); |
| | | order.setFake(orderSubmitRequest.getFake()); |
| | | boolean update = orderService.updateById(order); |
| | | // 服务记录 |
| | | ServeRecord serveRecord = new ServeRecord(); |
| | | serveRecord.setOrderId(order.getId()); |
| | | serveRecord.setPhoto(String.join(",", orderSubmitRequest.getPhoto())); |
| | | serveRecord.setPaperPic(orderSubmitRequest.getPaperPic()); |
| | | serveRecord.setCardPic(orderSubmitRequest.getCardPic()); |
| | | serveRecord.setMachinePic(orderSubmitRequest.getMachinePic()); |
| | | boolean save = serveRecordService.save(serveRecord); |
| | | return R.ok(update && save); |
| | | } |
| | |
| | | * |
| | | * @param workerId 师傅id |
| | | */ |
| | | @ApiOperation(value = "代办列表", tags = {"师傅端"}) |
| | | |
| | | |
| | | // ... |
| | | |
| | | @ApiOperation(value = "代办列表", tags ={"师傅端"}) |
| | | @GetMapping(value = "/orderNotHandle") |
| | | public R<List<Order>> orderNotHandle(@RequestParam("workerId") Integer workerId) { |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | |
| | | // 格式化日期字符串,假设数据库中的日期格式为 yyyy-MM-dd |
| | | String todayStr = today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | |
| | | QueryWrapper<Order> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("server_id", workerId) |
| | | .in("state", 1, 2) |
| | | .eq("is_delete", Constants.ZERO) |
| | | .eq("DATE(time)", todayStr) // 添加这一行来筛选当天的订单 |
| | | .orderByAsc("CASE WHEN topSort IS NULL THEN 1 ELSE 0 END") |
| | | .orderByAsc("topSort"); |
| | | return R.ok(orderService.list(wrapper)); |
| | | |
| | | List<Order> list = orderService.list(wrapper); |
| | | for (Order order : list) { |
| | | if (order.getAcceptTime()==null){ |
| | | order.setAcceptTime(order.getCreateTime()); |
| | | } |
| | | } |
| | | |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 师傅端-订单代办列表 |
| | | */ |