| | |
| | | package com.ruoyi.order.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.query.TChargingCountQuery; |
| | | import com.ruoyi.order.dto.GetMyChargingOrderList; |
| | | import com.ruoyi.order.dto.GetNoInvoicedOrder; |
| | | import com.ruoyi.order.dto.MyChargingOrderInfo; |
| | | import com.ruoyi.order.dto.MyChargingOrderList; |
| | | import com.ruoyi.order.service.TChargingOrderService; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private TChargingOrderService chargingOrderService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 查询用户最近一次充电记录使用的车辆 |
| | | * @param |
| | | * @return |
| | | */ |
| | | @GetMapping(value = "/getCar") |
| | | public R<Long> getCar() { |
| | | List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>() |
| | | .eq(TChargingOrder::getAppUserId, tokenService.getLoginUserApplet().getUserId()) |
| | | .isNotNull(TChargingOrder::getAppUserCarId)); |
| | | if (!list.isEmpty()){ |
| | | // 最近使用的车辆id |
| | | Long size = list.get(0).getAppUserCarId(); |
| | | return R.ok(size); |
| | | }else{ |
| | | return R.ok(-1L); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询会员在本月有多少次享受了充电折扣 |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/getChargingCount") |
| | | public R<Integer> getChargingCount(@RequestBody TChargingCountQuery req) { |
| | | int size = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>() |
| | | .eq(TChargingOrder::getAppUserId, req.getUserId()) |
| | | .eq(TChargingOrder::getRechargePaymentStatus,2) |
| | | .between(TChargingOrder::getStartTime, req.getStartTime(), req.getEndTime())).size(); |
| | | return R.ok(size); |
| | | } |
| | | //用户订单数量 |
| | | @PostMapping(value = "/useOrderCount") |
| | | public R<Long> useOrderCount(@RequestParam Long userId) { |
| | | public R<Long> useOrderCount(@RequestParam("userId") Long userId) { |
| | | Long count = chargingOrderService.lambdaQuery().eq(TChargingOrder::getAppUserId, userId).count(); |
| | | |
| | | return R.ok(count); |
| | | } |
| | | |
| | | //订单详情 |
| | | @PostMapping(value = "/detail") |
| | | public R<TChargingOrder> detail(@RequestParam("orderId") Long orderId) { |
| | | return R.ok(chargingOrderService.getById(orderId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据充电枪id获取正在进行中的订单 |
| | | * @param chargingGunId 充电枪id |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/getOrderDetailByGunId") |
| | | public R<TChargingOrder> getOrderDetailByGunId(@RequestParam("chargingGunId") Integer chargingGunId){ |
| | | TChargingOrder one = chargingOrderService.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getChargingGunId, chargingGunId) |
| | | .eq(TChargingOrder::getDelFlag, 0).eq(TChargingOrder::getStatus, 3)); |
| | | return R.ok(one); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/getMyChargingOrderList") |
| | | @ApiOperation(value = "获取充电记录列表", tags = {"小程序-充电记录"}) |
| | | public AjaxResult<Map<String, Object>> getMyChargingOrderList(GetMyChargingOrderList query){ |
| | | Map<String, Object> orderList = chargingOrderService.getMyChargingOrderList(query); |
| | | return AjaxResult.success(orderList); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/getMyChargingOrderInfo") |
| | | @ApiOperation(value = "获取充电记订单明细", tags = {"小程序-充电记录"}) |
| | | public AjaxResult<MyChargingOrderInfo> getMyChargingOrderInfo(String id){ |
| | | MyChargingOrderInfo myChargingOrderInfo = chargingOrderService.getMyChargingOrderInfo(id); |
| | | return AjaxResult.success(myChargingOrderInfo); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/getNoInvoicedOrder") |
| | | @ApiOperation(value = "获取未开票的订单数据", tags = {"小程序-充电发票"}) |
| | | public AjaxResult<List<MyChargingOrderList>> getNoInvoicedOrder(@RequestBody GetNoInvoicedOrder query){ |
| | | List<MyChargingOrderList> list = chargingOrderService.getNoInvoicedOrder(query); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | } |
| | | |