|  |  |  | 
|---|
|  |  |  | package com.ruoyi.order.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.afterturn.easypoi.excel.ExcelExportUtil; | 
|---|
|  |  |  | import cn.afterturn.easypoi.excel.entity.ExportParams; | 
|---|
|  |  |  | import com.ruoyi.account.api.feignClient.AppUserCarClient; | 
|---|
|  |  |  | import com.ruoyi.account.api.feignClient.AppUserClient; | 
|---|
|  |  |  | 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.common.core.domain.R; | 
|---|
|  |  |  | import com.ruoyi.common.core.utils.DateUtils; | 
|---|
|  |  |  | import com.ruoyi.common.core.utils.WebUtils; | 
|---|
|  |  |  | import com.ruoyi.common.core.web.domain.AjaxResult; | 
|---|
|  |  |  | import com.ruoyi.common.core.web.page.PageInfo; | 
|---|
|  |  |  | import com.ruoyi.common.log.annotation.Log; | 
|---|
|  |  |  | import com.ruoyi.common.log.enums.BusinessType; | 
|---|
|  |  |  | import com.ruoyi.common.redis.service.RedisService; | 
|---|
|  |  |  | import com.ruoyi.common.security.service.TokenService; | 
|---|
|  |  |  | import com.ruoyi.order.api.dto.SettlementConfirmAdd; | 
|---|
|  |  |  | import com.ruoyi.order.api.model.ChargingListQuery; | 
|---|
|  |  |  | import com.ruoyi.order.api.model.TChargingOrder; | 
|---|
|  |  |  | import com.ruoyi.order.api.model.TSettlementConfirm; | 
|---|
|  |  |  | import com.ruoyi.order.api.query.SettlementListQuery; | 
|---|
|  |  |  | import com.ruoyi.order.api.query.TOrderInvoiceQuery; | 
|---|
|  |  |  | import com.ruoyi.order.api.vo.ChargingOrderListVO; | 
|---|
|  |  |  | import com.ruoyi.order.api.vo.SettlementTotalVO; | 
|---|
|  |  |  | import com.ruoyi.order.api.vo.TOrderInvoiceVO; | 
|---|
|  |  |  | import com.ruoyi.order.export.OrderInvoiceExport; | 
|---|
|  |  |  | import com.ruoyi.order.export.TChargingOrderExport; | 
|---|
|  |  |  | import com.ruoyi.order.vo.ChargingOrderListInfoVO; | 
|---|
|  |  |  | import com.ruoyi.order.api.vo.ChargingOrderTimeVO; | 
|---|
|  |  |  | import com.ruoyi.order.dto.ChargingListQuery; | 
|---|
|  |  |  | import com.ruoyi.order.service.*; | 
|---|
|  |  |  | import com.ruoyi.payment.api.feignClient.AliPaymentClient; | 
|---|
|  |  |  | import com.ruoyi.payment.api.feignClient.WxPaymentClient; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import io.swagger.annotations.ApiParam; | 
|---|
|  |  |  | import org.apache.poi.ss.usermodel.Workbook; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import javax.servlet.ServletOutputStream; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.net.URLEncoder; | 
|---|
|  |  |  | import java.time.format.DateTimeFormatter; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private TChargingOrderService chargingOrderService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TokenService tokenService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TOrderEvaluateService orderEvaluateService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private WxPaymentClient wxPaymentClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private RedisService redisService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private AliPaymentClient aliPaymentClient; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private TShoppingOrderService shoppingOrderService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | private TSettlementConfirmService tSettlementConfirmService; | 
|---|
|  |  |  | @PostMapping(value = "/chargingList") | 
|---|
|  |  |  | @ApiOperation(value = "充电时段统计列表", tags = {"管理后台-财务结算"}) | 
|---|
|  |  |  | public AjaxResult<ChargingOrderTimeVO> chargingList(@RequestBody ChargingListQuery dto) { | 
|---|
|  |  |  | ChargingOrderTimeVO res = chargingOrderService.chargingList(dto); | 
|---|
|  |  |  | return AjaxResult.success(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @GetMapping(value = "/chargingInfo") | 
|---|
|  |  |  | @ApiOperation(value = "充电时段统计列表-查看详情", tags = {"管理后台-财务结算"}) | 
|---|
|  |  |  | public AjaxResult<ChargingOrderListInfoVO> chargingInfo(String uid) { | 
|---|
|  |  |  | ChargingOrderListInfoVO res = chargingOrderService.chargingInfo(uid); | 
|---|
|  |  |  | return AjaxResult.success(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ApiOperation(value = "充电时段统计-导出", tags = {"管理后台-财务结算"}) | 
|---|
|  |  |  | @PutMapping("/export") | 
|---|
|  |  |  | public void export(@RequestBody ChargingListQuery dto) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ChargingOrderTimeVO res = chargingOrderService.chargingList(dto); | 
|---|
|  |  |  | List<TChargingOrderExport> tChargingOrderExports = new ArrayList<>(); | 
|---|
|  |  |  | List<ChargingOrderListVO> exportList = res.getExportList(); | 
|---|
|  |  |  | for (ChargingOrderListVO chargingOrderListVO : exportList) { | 
|---|
|  |  |  | TChargingOrderExport tChargingOrderExport = new TChargingOrderExport(); | 
|---|
|  |  |  | BeanUtils.copyProperties(chargingOrderListVO,tChargingOrderExport); | 
|---|
|  |  |  | tChargingOrderExports.add(tChargingOrderExport); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TChargingOrderExport.class, tChargingOrderExports); | 
|---|
|  |  |  | HttpServletResponse response = WebUtils.response(); | 
|---|
|  |  |  | response.setContentType("application/vnd.ms-excel"); | 
|---|
|  |  |  | response.setCharacterEncoding("utf-8"); | 
|---|
|  |  |  | ServletOutputStream outputStream = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String fileName = URLEncoder.encode("充电时段统计导出.xls", "utf-8"); | 
|---|
|  |  |  | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); | 
|---|
|  |  |  | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); | 
|---|
|  |  |  | response.setHeader("Pragma", "no-cache"); | 
|---|
|  |  |  | response.setHeader("Cache-Control", "no-cache"); | 
|---|
|  |  |  | outputStream = response.getOutputStream(); | 
|---|
|  |  |  | workbook.write(outputStream); | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } finally { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | outputStream.close(); | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @GetMapping(value = "/settlementTotal") | 
|---|
|  |  |  | @ApiOperation(value = "结算汇总-列表查询", tags = {"管理后台-财务结算"}) | 
|---|
|  |  |  | @ApiParam(name = "time", value = "汇报时间2024-01") | 
|---|
|  |  |  | public AjaxResult<SettlementTotalVO> settlementTotal(String time) { | 
|---|
|  |  |  | time = time+"-01 00:00:00"; | 
|---|
|  |  |  | SettlementTotalVO res = chargingOrderService.settlementTotal(time); | 
|---|
|  |  |  | return AjaxResult.success(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @GetMapping(value = "/settlementTotalR") | 
|---|
|  |  |  | public R<SettlementTotalVO> settlementTotalR(String time) { | 
|---|
|  |  |  | time = time+"-01 00:00:00"; | 
|---|
|  |  |  | SettlementTotalVO res = chargingOrderService.settlementTotal(time); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @PostMapping(value = "/settlementAdd") | 
|---|
|  |  |  | @ApiOperation(value = "结算确认表-生成/保存结算确认表", tags = {"管理后台-财务结算"}) | 
|---|
|  |  |  | public R<TSettlementConfirm> settlementAdd(@RequestBody SettlementConfirmAdd dto) { | 
|---|
|  |  |  | TSettlementConfirm res = chargingOrderService.settlementAdd(dto); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @PostMapping(value = "/settlementList") | 
|---|
|  |  |  | @ApiOperation(value = "结算表记录-列表查询", tags = {"管理后台-财务结算"}) | 
|---|
|  |  |  | public R<PageInfo<TSettlementConfirm>> settlementList(@RequestBody SettlementListQuery dto) { | 
|---|
|  |  |  | PageInfo<TSettlementConfirm> res = chargingOrderService.settlementList(dto); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @GetMapping(value = "/downloadSettlement/{uid}") | 
|---|
|  |  |  | public R<TSettlementConfirm> downloadSettlement(@PathVariable("uid") String uid) { | 
|---|
|  |  |  | TSettlementConfirm byId = tSettlementConfirmService.getById(uid); | 
|---|
|  |  |  | if (byId!=null){ | 
|---|
|  |  |  | List<TChargingOrder> list = chargingOrderService.lambdaQuery().eq(TChargingOrder::getSiteId, byId.getSiteId()) | 
|---|
|  |  |  | .between(TChargingOrder::getStartTime, byId.getStartTime(), byId.getEndTime()) | 
|---|
|  |  |  | .eq(TChargingOrder::getStatus, 5) | 
|---|
|  |  |  | .eq(TChargingOrder::getRechargePaymentStatus, 2).list(); | 
|---|
|  |  |  | byId.setList(list); | 
|---|
|  |  |  | String format = byId.getStartTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); | 
|---|
|  |  |  | String format1 = byId.getEndTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); | 
|---|
|  |  |  | byId.setTime(format+"至"+format1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(byId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|