| | |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.order.service.CommissionService; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.util.payment.model.RefundCallbackResult; |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.other.api.domain.BaseSetting; |
| | | import com.ruoyi.other.api.feignClient.BaseSettingClient; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | }) |
| | | @GetMapping("/cancel/{orderId}") |
| | | public R<Void> cancel(@PathVariable("orderId") Long orderId){ |
| | | orderService.update(new LambdaUpdateWrapper<Order>() |
| | | .eq(Order::getId, orderId) |
| | | .set(Order::getOrderStatus, OrderStatus.CANCELLED.getCode())); |
| | | return R.ok(); |
| | | public R cancel(@PathVariable("orderId") Long orderId){ |
| | | return orderService.cancel(orderId); |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | @GetMapping("/confirm/{orderId}") |
| | | public R<Void> confirm(@PathVariable("orderId") Long orderId){ |
| | | boolean update = orderService.update(new LambdaUpdateWrapper<Order>() |
| | | .eq(Order::getId, orderId) |
| | | .eq(Order::getOrderStatus, OrderStatus.PENDING_RECEIPT.getCode()) |
| | | .set(Order::getOrderStatus, OrderStatus.COMPLETED.getCode())); |
| | | if(!update){ |
| | | return R.fail("订单状态异常"); |
| | | } |
| | | R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(5); |
| | | if (R.isError(baseSettingR)) { |
| | | return R.fail("售后设置获取失败"); |
| | |
| | | String content = baseSetting.getContent(); |
| | | JSONObject jsonObject = JSONObject.parseObject(content); |
| | | Long days = jsonObject.getLong("days"); |
| | | commissionService.addToCommissionDelayQueue(orderId, LocalDateTime.now().plusDays(days)); |
| | | Order order = orderService.getById(orderId); |
| | | order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); |
| | | order.setIsCommission(0); |
| | | order.setOrderStatus(OrderStatus.COMPLETED.getCode()); |
| | | orderService.updateById(order); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | } |
| | | @PostMapping("/byShopId") |
| | | public R<List<Order>> byShopId(@RequestParam("shopId") Integer shopId){ |
| | | return R.ok(orderService.lambdaQuery().isNotNull(Order::getEndTime).eq(Order::getShopId, shopId).groupBy(Order::getAppUserId).list()); |
| | | return R.ok(orderService.lambdaQuery().isNotNull(Order::getEndTime).eq(Order::getShopId, shopId).list()); |
| | | } |
| | | |
| | | |
| | |
| | | @RequestParam("endTime") String endTime){ |
| | | |
| | | List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>() |
| | | .between(Order::getCreateTime, LocalDateTime.parse(startTime), LocalDateTime.parse(endTime))); |
| | | .between(Order::getCreateTime, LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); |
| | | |
| | | |
| | | Map<String, List<Order>> map = orderList.stream().collect(Collectors.groupingBy(item -> item.getCreateTime() |
| | |
| | | orderStatisticsDetail.setTotal(total); |
| | | orderStatisticsDetails.add(orderStatisticsDetail); |
| | | }); |
| | | OrderStatistics orderStatistics = orderMapper.getOrderStatistics(LocalDateTime.parse(startTime), LocalDateTime.parse(endTime)); |
| | | orderStatistics.setOrderStatisticsDetailList(orderStatisticsDetails); |
| | | OrderStatistics orderStatistics = orderMapper.getOrderStatistics(startTime, endTime); |
| | | if(null != orderStatistics){ |
| | | orderStatistics.setOrderStatisticsDetailList(orderStatisticsDetails); |
| | | } |
| | | return R.ok(orderStatistics); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单取消支付回退 |
| | | * @param refundCallbackResult |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/refundPayMoneyCallback") |
| | | public void refundPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response){ |
| | | R callback = orderService.refundPayMoneyCallback(refundCallbackResult); |
| | | if(callback.getCode() == 200){ |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消订单快递费回退 |
| | | * @param refundCallbackResult |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/refundExpressPayMoneyCallback") |
| | | public void refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response){ |
| | | R callback = orderService.refundExpressPayMoneyCallback(refundCallbackResult); |
| | | if(callback.getCode() == 200){ |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取商品销售数量 |
| | | * @param goodsId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getGoodsSaleNum") |
| | | public R<Integer> getGoodsSaleNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("type") Integer type){ |
| | | Integer goodsSaleNum = orderService.getGoodsSaleNum(goodsId, type); |
| | | return R.ok(goodsSaleNum); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取门店销售订单数量 |
| | | * @param shopId 门店id |
| | | * @param type 1:服务订单,2:单品订单 |
| | | * @return |
| | | */ |
| | | @PostMapping("/getShopSaleNum") |
| | | public R<Integer> getShopSaleNum(@RequestParam("shopId") Integer shopId, @RequestParam("type") Integer type){ |
| | | Integer shopSaleNum = orderService.getShopSaleNum(shopId, type); |
| | | return R.ok(shopSaleNum); |
| | | } |
| | | |
| | | } |
| | | |