| | |
| | | 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.order.api.model.ExportUidDto; |
| | | import com.ruoyi.order.api.model.TChargingBill; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.*; |
| | | import com.ruoyi.order.api.query.TOrderInvoiceQuery; |
| | | import com.ruoyi.order.api.vo.AccountListVO; |
| | | import com.ruoyi.order.api.vo.ChargingBillListVO; |
| | | import com.ruoyi.order.api.vo.ChargingBillVO; |
| | | import com.ruoyi.order.api.model.ChargingListQuery; |
| | | import com.ruoyi.order.api.vo.TOrderInvoiceVO; |
| | | import com.ruoyi.order.export.*; |
| | | import com.ruoyi.order.service.*; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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 java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.ArrayList; |
| | |
| | | public R<AccountListVO> accountBillList(@RequestBody ChargingListQuery dto) { |
| | | AccountListVO accountListVO = new AccountListVO(); |
| | | ChargingBillVO res = chargingBillService.chargingBillList1(dto); |
| | | |
| | | ChargingBillVO res1 = chargingBillService.chargingBillList1(dto); |
| | | List<ChargingBillListVO> records = res1.getList().getRecords(); |
| | | List<ChargingBillListVO> records = res.getList().getRecords(); |
| | | accountListVO.setBillCount(records.size()); |
| | | accountListVO.setTotalAmount(res1.getPaymentAmount().subtract(res1.getRefundAmount()).subtract(res1.getCommissionAmount()).subtract(res1.getSharingAmount())); |
| | | accountListVO.setPaymentAmount(res1.getPaymentAmount()); |
| | | accountListVO.setRefundAmount(res1.getRefundAmount()); |
| | | accountListVO.setCommissionAmount(res1.getCommissionAmount()); |
| | | accountListVO.setSharingAmount(res1.getSharingAmount()); |
| | | accountListVO.setTotalAmount(res.getOrderAmount()); |
| | | accountListVO.setPaymentAmount(res.getPaymentAmount()); |
| | | accountListVO.setRefundAmount(res.getRefundAmount()); |
| | | accountListVO.setCommissionAmount(res.getCommissionAmount()); |
| | | accountListVO.setSharingAmount(res.getSharingAmount()); |
| | | accountListVO.setList(res.getList()); |
| | | return R.ok(accountListVO); |
| | | } |
| | |
| | | } |
| | | } |
| | | @ApiOperation(value = "导出", tags = {"管理后台-账户结算账单"}) |
| | | @PostMapping("/exportAccount") |
| | | @PutMapping("/exportAccount") |
| | | public void exportAccount(@RequestBody ChargingListQuery dto) |
| | | { |
| | | ChargingBillVO res = chargingBillService.chargingBillList1(dto); |
| | |
| | | for (ChargingBillListVO orderInvoiceVO : list) { |
| | | TChargingBillExport tChargingBillExport = new TChargingBillExport(); |
| | | tChargingBillExport.setCode(orderInvoiceVO.getCode()); |
| | | switch (orderInvoiceVO.getTimeType()){ |
| | | switch (orderInvoiceVO.getOrderState()){ |
| | | case 1: |
| | | tChargingBillExport.setBillType("日账单"); |
| | | break; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private TChargingOrderRefundService tChargingOrderRefundService; |
| | | @ApiOperation(value = "下载-未出账", tags = {"管理后台-充电算账单"}) |
| | | @PutMapping("/download") |
| | | public void download(@RequestBody ExportUidDto uid) |
| | |
| | | TChargingBill byId = chargingBillService.getById(uid.getUid()); |
| | | ChargingBillExport chargingBillExport = new ChargingBillExport(); |
| | | chargingBillExport.setCode(byId.getCode()); |
| | | // todo 确认商户类型 |
| | | chargingBillExport.setAccountType("商户类型"); |
| | | chargingBillExport.setAccountType("微信商户"); |
| | | chargingBillExport.setType(byId.getType().toString()); |
| | | chargingBillExport.setBillType("月结"); |
| | | LocalDateTime billTime = byId.getBillTime(); |
| | | // 将billTime 减去一个月 转化为yyyy-MM格式字符串 |
| | | billTime = billTime.minusMonths(1); |
| | | chargingBillExport.setBillWeek(DateUtils.parseDateToStr("yyyy-MM",DateUtils.toDate(billTime))); |
| | | |
| | | chargingBillExport.setBillTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(billTime))); |
| | | chargingBillExport.setState("未出账"); |
| | | List<Site> data = siteClient.getSiteByIds(Arrays.asList(byId.getSiteId())).getData(); |
| | | if (!data.isEmpty()){ |
| | | chargingBillExport.setSiteName(data.get(0).getName()); |
| | | } |
| | | // 根据账单的出账时间 查询上个月的充电订单 |
| | | LocalDateTime localDate = byId.getBillTime().minusMonths(1); |
| | | // 账单周期 |
| | | // // 根据账单的出账时间 查询上个月的充电订单 |
| | | // LocalDateTime localDate = byId.getBillTime().minusMonths(1); |
| | | // // 账单周期 |
| | | // // 获取 LocalDate 对象 |
| | | // LocalDate date = localDate.toLocalDate(); |
| | | // // 获取该月份的第一天 |
| | | // LocalDate firstDayOfMonth = date.withDayOfMonth(1); |
| | | LocalDateTime localDate = byId.getBillTime().minusDays(1); |
| | | // todo 临时修改为前一天 |
| | | // 获取 LocalDate 对象 |
| | | LocalDate date = localDate.toLocalDate(); |
| | | // 获取该月份的第一天 |
| | | LocalDate firstDayOfMonth = date.withDayOfMonth(1); |
| | | // // 获取该月份的第一天 |
| | | // LocalDate firstDayOfMonth = date.withDayOfMonth(1); |
| | | // // 获取该月份的最后一天 |
| | | // LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); |
| | | // todo 临时修改为查询昨天凌晨00:00:00 到 23:59:59 |
| | | LocalDateTime firstDayOfMonth = LocalDateTime.of(date, LocalTime.MIN); |
| | | LocalDateTime lastDayOfMonth = LocalDateTime.of(date, LocalTime.MAX); |
| | | // 获取该月份的最后一天 |
| | | LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); |
| | | // LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); |
| | | QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>() |
| | | .between("create_time", firstDayOfMonth, lastDayOfMonth) |
| | | .eq("status", 5) |
| | |
| | | } |
| | | BigDecimal paymentAmount = new BigDecimal("0"); |
| | | BigDecimal refundAmount = new BigDecimal("0"); |
| | | BigDecimal income = new BigDecimal("0"); |
| | | |
| | | List<TChargingOrder> tChargingOrders = chargingOrderService.list(eq); |
| | | // 累加支付金额 |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | int i =1; |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | // 账单信息 |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()); |
| | | if (tChargingOrder.getRefundStatus()!=null && tChargingOrder.getRefundStatus()==2){ |
| | | refundAmount = refundAmount.add(tChargingOrder.getRefundAmount()); |
| | | } |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getOrderAmount()); |
| | | |
| | | // 退款信息 |
| | | ChargingBillRefundExport chargingBillRefundExport = new ChargingBillRefundExport(); |
| | | ChargingBillPayExport chargingBillPayExport = new ChargingBillPayExport(); |
| | |
| | | chargingBillPayExport.setPlatformPay("支付宝小程序支付"); |
| | | |
| | | } |
| | | chargingBillRefundExport.setRechargeSerialNumber(tChargingOrder.getRechargeSerialNumber()); |
| | | chargingBillRefundExport.setCode(tChargingOrder.getCode()); |
| | | chargingBillRefundExport.setPayTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getPayTime()))); |
| | | if (tChargingOrder.getRefundTime()!=null){ |
| | | chargingBillRefundExport.setRefundTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getRefundTime()))); |
| | | List<TChargingOrderRefund> one1 = tChargingOrderRefundService.lambdaQuery() |
| | | .eq(TChargingOrderRefund::getChargingOrderId, tChargingOrder.getId()) |
| | | .eq(TChargingOrderRefund::getRefundStatus, 2) |
| | | .list(); |
| | | for (TChargingOrderRefund one : one1) { |
| | | refundAmount= refundAmount.add(one.getRefundAmount()); |
| | | chargingBillRefundExport.setRechargeSerialNumber(tChargingOrder.getRechargeSerialNumber()); |
| | | chargingBillRefundExport.setCode(tChargingOrder.getCode()); |
| | | chargingBillRefundExport.setPayTime(tChargingOrder.getCreateTime()!=null?DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getCreateTime())):""); |
| | | if (one.getRefundTime()!=null){ |
| | | chargingBillRefundExport.setRefundTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(one.getRefundTime()))); |
| | | } |
| | | chargingBillRefundExport.setRefundMoney(one.getRefundAmount().toString()); |
| | | chargingBillRefundExport.setRefundRemark(one.getRefundReason()); |
| | | chargingBillRefundExport.setRefundCode(one.getRefundCode()); |
| | | chargingBillRefundExport.setRefundSerialNumber(one.getRefundSerialNumber()); |
| | | chargingBillRefundExports.add(chargingBillRefundExport); |
| | | } |
| | | chargingBillRefundExport.setRefundMoney(tChargingOrder.getRefundAmount().toString()); |
| | | chargingBillRefundExport.setRefundRemark(tChargingOrder.getRefundReason()); |
| | | chargingBillRefundExport.setRefundCode(tChargingOrder.getRefundCode()); |
| | | chargingBillRefundExport.setRefundSerialNumber(tChargingOrder.getRefundSerialNumber()); |
| | | chargingBillRefundExports.add(chargingBillRefundExport); |
| | | |
| | | // 支付信息 |
| | | chargingBillPayExport.setId(i+""); |
| | | chargingBillPayExport.setRechargeSerialNumber(tChargingOrder.getRechargeSerialNumber()); |
| | | chargingBillPayExport.setCode(tChargingOrder.getCode()); |
| | | chargingBillPayExport.setPayTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getPayTime()))); |
| | | chargingBillPayExport.setPaymentAmount(tChargingOrder.getPaymentAmount().toString()); |
| | | chargingBillPayExport.setPayTime(tChargingOrder.getPayTime()!=null?DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getPayTime())):""); |
| | | chargingBillPayExport.setPaymentAmount(tChargingOrder.getOrderAmount().toString()); |
| | | chargingBillPayExport.setTotal(""); |
| | | chargingBillPayExports.add(chargingBillPayExport); |
| | | i++; |
| | | bigDecimal = bigDecimal.add(tChargingOrder.getOrderAmount()); |
| | | } |
| | | if (!chargingBillPayExports.isEmpty()){ |
| | | chargingBillPayExports.get(0).setTotal(bigDecimal+""); |
| | | } |
| | | if (byId.getSiteId()==0){ |
| | | chargingBillExport.setSiteName("全站"); |
| | | }else{ |
| | | List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(byId.getSiteId())).getData(); |
| | | if (data1!=null&&(!data1.isEmpty())){ |
| | | String name = data1.get(0).getName(); |
| | | chargingBillExport.setSiteName(name); |
| | | } |
| | | |
| | | } |
| | | chargingBillExport.setPaymentAmount(paymentAmount); |
| | | chargingBillExport.setRefundAmount(refundAmount); |
| | |
| | | |
| | | // 导出 |
| | | List<Map<String, Object>> sheetsList = new ArrayList<>(); |
| | | AtomicInteger atomicInteger = new AtomicInteger(); |
| | | |
| | | for (int i1 = 0; i1 < 3; i1++) { |
| | | for (int i1 = 1; i1 <= 3; i1++) { |
| | | String sheetName=""; |
| | | switch (i1){ |
| | | case 1: |