From a4fc8d1a88374ee4e1aba8acde5567e0abe9f659 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 30 八月 2024 09:50:40 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java |  269 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 209 insertions(+), 60 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
index d9a6601..ce20d5a 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -1,8 +1,21 @@
 package com.ruoyi.order.controller;
 
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ruoyi.account.api.feignClient.AppUserCarClient;
 import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.TAppUserCar;
+import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
+import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
+import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient;
+import com.ruoyi.chargingPile.api.feignClient.SiteClient;
+import com.ruoyi.chargingPile.api.model.Site;
+import com.ruoyi.chargingPile.api.model.TChargingGun;
+import com.ruoyi.chargingPile.api.model.TChargingPile;
+import com.ruoyi.chargingPile.api.model.TParkingRecord;
 import com.ruoyi.chargingPile.api.vo.SiteVO;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.redis.service.RedisService;
@@ -10,8 +23,7 @@
 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.model.TOrderEvaluate;
+import com.ruoyi.order.api.model.*;
 import com.ruoyi.order.api.query.ChargingOrderQuery;
 import com.ruoyi.order.api.query.TChargingCountQuery;
 import com.ruoyi.order.api.vo.ChargingOrderVO;
@@ -22,9 +34,7 @@
 import com.ruoyi.order.dto.MyChargingOrderList;
 import com.ruoyi.order.dto.OrderEvaluateVo;
 import com.ruoyi.order.dto.*;
-import com.ruoyi.order.service.TChargingOrderService;
-import com.ruoyi.order.service.TOrderEvaluateService;
-import com.ruoyi.order.service.TOrderEvaluateTagService;
+import com.ruoyi.order.service.*;
 import com.ruoyi.payment.api.feignClient.AliPaymentClient;
 import com.ruoyi.payment.api.feignClient.WxPaymentClient;
 import com.ruoyi.payment.api.vo.AliQueryOrder;
@@ -39,13 +49,14 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.PrintWriter;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.List;
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author xiaochen
@@ -62,37 +73,175 @@
     private TokenService tokenService;
     @Autowired
     private TOrderEvaluateService orderEvaluateService;
-    
+
     @Resource
     private WxPaymentClient wxPaymentClient;
-    
+
     @Resource
     private RedisService redisService;
-    
+
     @Resource
     private AliPaymentClient aliPaymentClient;
-    
+    @Resource
+    private TShoppingOrderService shoppingOrderService;
+
     @Autowired
     private AppUserClient appUserClient;
 
-    
-    
-    
-    
-    
+    @Resource
+    private TVipOrderService vipOrderService;
+    @Resource
+    private ParkingLotClient parkingLotClient;
+    @Resource
+    private TChargingOrderRefundService chargingOrderRefundService;
+
+    @Resource
+    private TShoppingOrderRefundService shoppingOrderRefundService;
+    @Resource
+    private TVipOrderRefundService vipOrderRefundService;
+    @Resource
+    private SiteClient siteClient;
+    @Resource
+    private ChargingPileClient chargingPileClient;
+    @Resource
+    private ChargingGunClient chargingGunClient;
+    @Resource
+    private AppUserCarClient appUserCarClient;
+    @Resource
+    private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService;
+
+    @ResponseBody
+    @PostMapping(value = "/pay/order/list")
+    @ApiOperation(value = "列表", tags = {"管理后台-支付订单-订单信息"})
+    public R<PageInfo<PayOrderDto>> payOrderList(@RequestBody PayOrderQueryDto payOrderQueryDto) {
+        return chargingOrderService.payOrderQuery(payOrderQueryDto);
+    }
+
+    @ResponseBody
+    @GetMapping(value = "/pay/order/pay/detail")
+    @ApiOperation(value = "支付信息", tags = {"管理后台-支付订单-订单信息"})
+    public R<PayOrderInfoDto> payOrderList(Long orderId, Integer type) {
+        switch (type) {
+            case 1:
+                TChargingOrder byId = chargingOrderService.getById(orderId);
+                PayOrderInfoDto payOrderInfoDto = new PayOrderInfoDto();
+                payOrderInfoDto.setOrderId(byId.getId().toString());
+                payOrderInfoDto.setCode(byId.getCode());
+                payOrderInfoDto.setTradeNo(byId.getRechargeSerialNumber());
+                payOrderInfoDto.setPayType(byId.getRechargePaymentType());
+                payOrderInfoDto.setPayAmount(byId.getPaymentAmount());
+                payOrderInfoDto.setPayTime(byId.getPayTime());
+                payOrderInfoDto.setRefundAmount(byId.getRefundAmount());
+                return R.ok(payOrderInfoDto);
+            case 2:
+                TShoppingOrder byId1 = shoppingOrderService.getById(orderId);
+                PayOrderInfoDto payOrderInfoDto1 = new PayOrderInfoDto();
+                payOrderInfoDto1.setOrderId(byId1.getId().toString());
+                payOrderInfoDto1.setCode(byId1.getCode());
+                payOrderInfoDto1.setTradeNo(byId1.getSerialNumber());
+                payOrderInfoDto1.setPayType(byId1.getPaymentType());
+                payOrderInfoDto1.setPayAmount(byId1.getPaymentAmount());
+                payOrderInfoDto1.setPayTime(byId1.getPayTime());
+                payOrderInfoDto1.setRefundAmount(byId1.getRefundAmount());
+                return R.ok(payOrderInfoDto1);
+            case 3:
+                TVipOrder byId2 = vipOrderService.getById(orderId);
+                PayOrderInfoDto payOrderInfoDto2 = new PayOrderInfoDto();
+                payOrderInfoDto2.setOrderId(byId2.getId().toString());
+                payOrderInfoDto2.setCode(byId2.getCode());
+                payOrderInfoDto2.setTradeNo(byId2.getSerialNumber());
+                payOrderInfoDto2.setPayType(byId2.getPaymentType());
+                payOrderInfoDto2.setPayAmount(byId2.getPaymentAmount());
+                payOrderInfoDto2.setPayTime(byId2.getPayTime());
+                payOrderInfoDto2.setRefundAmount(byId2.getRefundAmount());
+                return R.ok(payOrderInfoDto2);
+            //todo luo 停车场订单
+//                case 4:
+//                    TParkingRecord byId3 = parkingLotClient.getRecordById(orderId).getData();
+//                    PayOrderInfoDto payOrderInfoDto3 = new PayOrderInfoDto();
+//                    payOrderInfoDto3.setOrderId(byId3.getId().toString());
+//                    payOrderInfoDto3.setCode(byId3.getCode());
+//                    payOrderInfoDto3.setTradeNo(byId3);
+//                    payOrderInfoDto3.setPayType(0);
+//                    payOrderInfoDto3.setPayAmount(new BigDecimal("0"));
+//                    payOrderInfoDto3.setPayTime(LocalDateTime.now());
+//                    payOrderInfoDto3.setRefundAmount(new BigDecimal("0"));
+
+
+        }
+        return R.ok();
+
+    }
+
+    @ResponseBody
+    @GetMapping(value = "/pay/order/refund/detail")
+    @ApiOperation(value = "退款信息", tags = {"管理后台-支付订单-订单信息"})
+    public R refundDetail(Long orderId, Integer type) {
+        switch (type) {
+            case 1:
+                List<TChargingOrderRefund> byId = chargingOrderRefundService.lambdaQuery().eq(TChargingOrderRefund::getChargingOrderId, orderId).orderByDesc(TChargingOrderRefund::getRefundTime).list();
+                return R.ok(byId);
+            case 2:
+                List<TShoppingOrderRefund> list = shoppingOrderRefundService.lambdaQuery().eq(TShoppingOrderRefund::getShoppingOrderId, orderId).orderByDesc(TShoppingOrderRefund::getRefundTime).list();
+                return R.ok(list);
+            case 3:
+                List<TVipOrderRefund> list1 = vipOrderRefundService.lambdaQuery().eq(TVipOrderRefund::getVipOrderId, orderId).orderByDesc(TVipOrderRefund::getRefundTime).list();
+                return R.ok(list1);
+
+        }
+        return R.ok();
+
+    }
+
+    @ResponseBody
+    @GetMapping(value = "/pay/order/charging")
+    @ApiOperation(value = "充电信息", tags = {"管理后台-支付订单-订单信息"})
+    public R refundDetail(Long orderId) {
+        PayOrderChargingInfo payOrderChargingInfo = new PayOrderChargingInfo();
+        TChargingOrder byId = chargingOrderService.getById(orderId);
+        List<Site> data = siteClient.getSiteByIds(Collections.singletonList(byId.getSiteId())).getData();
+        payOrderChargingInfo.setSiteName(data.get(0).getName());
+        TChargingPile data1 = chargingPileClient.getChargingPileById(byId.getChargingPileId()).getData();
+        payOrderChargingInfo.setChargingName(data1.getName());
+        TChargingGun data2 = chargingGunClient.getChargingGunById(byId.getChargingGunId()).getData();
+        payOrderChargingInfo.setGunName(data2.getName());
+        List<TAppUserCar> data3 = appUserCarClient.getCarByIds(Collections.singletonList(byId.getAppUserCarId())).getData();
+        payOrderChargingInfo.setCarNum(data3.get(0).getLicensePlate());
+        return R.ok();
+    }
+
+    @ResponseBody
+    @GetMapping(value = "/pay/order/charging/details")
+    @ApiOperation(value = "充电明细", tags = {"管理后台-支付订单-订单信息"})
+    public R<List<TChargingOrderAccountingStrategy>> chargingDetail(Long orderId) {
+        List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId).orderByDesc(TChargingOrderAccountingStrategy::getStartTime).list();
+        return R.ok(list);
+    }
+
+
+    @ResponseBody
+    @PostMapping(value = "/pay/order/refund/list")
+    @ApiOperation(value = "充电信息", tags = {"管理后台-支付订单-退款订单"})
+    public R<PageInfo<TChargingOrderRefund>> refundList(@RequestBody ChargingRefundDto chargingRefundDto) {
+        return chargingOrderService.getRefundList(chargingRefundDto);
+
+    }
+
+
     @ResponseBody
     @PostMapping(value = "/chargingOrder")
     @ApiOperation(value = "充电桩订单列表", tags = {"管理后台-订单管理"})
-    public AjaxResult<TCharingOrderVO> chargingOrder(@RequestBody ChargingOrderQuery dto){
+    public AjaxResult<TCharingOrderVO> chargingOrder(@RequestBody ChargingOrderQuery dto) {
         List<Long> data = appUserClient.getUserIdsByPhone(dto.getPhone()).getData();
         dto.setUserIds(data);
         TCharingOrderVO res = chargingOrderService.chargingOrder(dto);
         return AjaxResult.success(res);
     }
+
     @ResponseBody
     @PostMapping(value = "/chargingOrderInfo")
     @ApiOperation(value = "充电桩订单列表查看详情", tags = {"管理后台-订单管理"})
-    public AjaxResult<TCharingOrderVO> chargingOrderInfo(String orderId){
+    public AjaxResult<TCharingOrderVO> chargingOrderInfo(String orderId) {
 
         return AjaxResult.success();
     }
@@ -100,13 +249,15 @@
     @ResponseBody
     @PostMapping(value = "/addEvaluate")
     @ApiOperation(value = "添加评价", tags = {"小程序-扫一扫"})
-    public AjaxResult getMyChargingOrderList(@RequestBody OrderEvaluateVo dto){
+    public AjaxResult getMyChargingOrderList(@RequestBody OrderEvaluateVo dto) {
         dto.setAppUserId(tokenService.getLoginUserApplet().getUserId());
         orderEvaluateService.addOrderEvaluate(dto);
         return AjaxResult.success();
     }
+
     /**
      * 查询用户最近一次充电记录使用的车辆
+     *
      * @param
      * @return
      */
@@ -115,17 +266,18 @@
         List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>()
                 .eq(TChargingOrder::getAppUserId, tokenService.getLoginUserApplet().getUserId())
                 .isNotNull(TChargingOrder::getAppUserCarId));
-        if (!list.isEmpty()){
+        if (!list.isEmpty()) {
             // 最近使用的车辆id
             Long size = list.get(0).getAppUserCarId();
             return R.ok(size);
-        }else{
+        } else {
             return R.ok(-1L);
         }
     }
 
     /**
      * 查询会员在本月有多少次享受了充电折扣
+     *
      * @param req
      * @return
      */
@@ -133,10 +285,11 @@
     public R<Integer> getChargingCount(@RequestBody TChargingCountQuery req) {
         int size = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>()
                 .eq(TChargingOrder::getAppUserId, req.getUserId())
-                        .eq(TChargingOrder::getRechargePaymentStatus,2)
+                .eq(TChargingOrder::getRechargePaymentStatus, 2)
                 .between(TChargingOrder::getStartTime, req.getStartTime(), req.getEndTime())).size();
         return R.ok(size);
     }
+
     //用户订单数量
     @PostMapping(value = "/useOrderCount")
     public R<Long> useOrderCount(@RequestParam("userId") Long userId) {
@@ -144,141 +297,137 @@
 
         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){
+    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){
+    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){
+    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(GetNoInvoicedOrder query){
+    public AjaxResult<List<MyChargingOrderList>> getNoInvoicedOrder(GetNoInvoicedOrder query) {
         List<MyChargingOrderList> list = chargingOrderService.getNoInvoicedOrder(query);
         return AjaxResult.success(list);
     }
-    
-    
-    
+
+
     @ResponseBody
     @PostMapping(value = "/paymentChargingOrder")
     @ApiOperation(value = "支付充电充值费用", tags = {"小程序-扫一扫"})
-    public AjaxResult paymentChargingOrder(@RequestBody AddChargingOrder addChargingOrder){
+    public AjaxResult paymentChargingOrder(@RequestBody AddChargingOrder addChargingOrder) {
         return chargingOrderService.paymentChargingOrder(addChargingOrder);
     }
-    
+
     /**
      * 充电充值支付回调
+     *
      * @param request
      */
     @ResponseBody
     @PostMapping(value = "/chargingOrderWXCallback")
-    public void chargingOrderWXCallback(HttpServletRequest request){
+    public void chargingOrderWXCallback(HttpServletRequest request) {
         Map<String, Object> data = wxPaymentClient.payNotify(request).getData();
-        if(null != data){
+        if (null != data) {
             String out_trade_no = data.get("out_trade_no").toString();
             String transaction_id = data.get("transaction_id").toString();
             String attach = data.get("attach").toString();
             AjaxResult ajaxResult = chargingOrderService.chargingOrderCallback(1, out_trade_no, transaction_id, attach);
-            if(ajaxResult.isSuccess()){
+            if (ajaxResult.isSuccess()) {
                 wxPaymentClient.ack();
             }
         }
     }
-    
-    
+
+
     /**
      * 支付宝支付成功后的回调
      */
     @ResponseBody
     @PostMapping(value = "/chargingOrderALICallback")
-    public void chargingOrderALICallback(@RequestBody AliQueryOrder aliQueryOrder, HttpServletResponse response){
+    public void chargingOrderALICallback(@RequestBody AliQueryOrder aliQueryOrder, HttpServletResponse response) {
         try {
             String out_trade_no = aliQueryOrder.getOutTradeNo();
             String transaction_id = aliQueryOrder.getTradeNo();
             String attach = aliQueryOrder.getPassbackParams();
             AjaxResult ajaxResult = chargingOrderService.chargingOrderCallback(2, out_trade_no, transaction_id, attach);
-            if(ajaxResult.isSuccess()){
+            if (ajaxResult.isSuccess()) {
                 PrintWriter writer = response.getWriter();
                 writer.println("success");
                 writer.flush();
                 writer.close();
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
-    
-    
-    
+
+
     @ResponseBody
     @GetMapping(value = "/preChargeCheck/{id}")
     @ApiOperation(value = "获取安全检测数据", tags = {"小程序-扫一扫"})
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "充电枪id", required = true)
     })
-    public AjaxResult<PreChargeCheck> preChargeCheck(@PathVariable Integer id){
+    public AjaxResult<PreChargeCheck> preChargeCheck(@PathVariable Integer id) {
         String key = "AQJC_" + id;
         Object cacheObject = redisService.getCacheObject(key);
         return AjaxResult.success(cacheObject);
     }
-    
-    
-    
+
+
     @ResponseBody
     @GetMapping(value = "/getChargingDetails/{id}")
     @ApiOperation(value = "获取充电中页面数据", tags = {"小程序-扫一扫"})
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "充电枪id", required = true)
     })
-    public AjaxResult<ChargingDetails> getChargingDetails(@PathVariable Integer id){
+    public AjaxResult<ChargingDetails> getChargingDetails(@PathVariable Integer id) {
         ChargingDetails chargingDetails = chargingOrderService.getChargingDetails(id);
         return AjaxResult.success(chargingDetails);
     }
-    
-    
-    
+
+
     @ResponseBody
     @PutMapping(value = "/stopCharging/{id}")
     @ApiOperation(value = "手动停止充电", tags = {"小程序-扫一扫"})
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "订单id", required = true)
     })
-    public AjaxResult stopCharging(@PathVariable String id){
+    public AjaxResult stopCharging(@PathVariable String id) {
         return chargingOrderService.stopCharging(id);
     }
 }

--
Gitblit v1.7.1