| | |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.page.TableDataInfo; |
| | | import com.ruoyi.sales.dto.InvoiceLedgerDto; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import com.ruoyi.sales.mapper.InvoiceLedgerMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.service.ICommonFileService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 销售台账Controller |
| | |
| | | |
| | | private ICommonFileService commonFileService; |
| | | |
| | | @Autowired |
| | | private InvoiceLedgerMapper invoiceLedgerMapper; |
| | | |
| | | /** |
| | | * 查询销售台账列表 |
| | | */ |
| | |
| | | public TableDataInfo list(SalesLedgerDto salesLedgerDto) { |
| | | startPage(); |
| | | List<SalesLedger> list = salesLedgerService.selectSalesLedgerList(salesLedgerDto); |
| | | // 计算已开票金额/未开票金额(已填写发票金额为准) |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return getDataTable(list); |
| | | } |
| | | List<Long> salesLedgerIds = list.stream().map(SalesLedger::getId).collect(Collectors.toList()); |
| | | List<InvoiceLedgerDto> invoiceLedgerDtoList = invoiceLedgerMapper.invoicedTotal(salesLedgerIds); |
| | | if(CollectionUtils.isEmpty(invoiceLedgerDtoList)){ |
| | | return getDataTable(list); |
| | | } |
| | | for (SalesLedger salesLedger : list) { |
| | | for (InvoiceLedgerDto invoiceLedgerDto : invoiceLedgerDtoList) { |
| | | if (salesLedger.getId().intValue() == invoiceLedgerDto.getSalesLedgerId()) { |
| | | BigDecimal noInvoiceAmountTotal = salesLedger.getContractAmount().subtract(invoiceLedgerDto.getInvoiceTotal()); |
| | | salesLedger.setNoInvoiceAmountTotal(noInvoiceAmountTotal); |
| | | } |
| | | } |
| | | } |
| | | return getDataTable(list); |
| | | } |
| | | |
| | |
| | | @GetMapping("/getContractAmount") |
| | | public AjaxResult getContractAmount() { |
| | | try { |
| | | BigDecimal amount = salesLedgerService.getContractAmount(); |
| | | return AjaxResult.success(amount != null ? amount : BigDecimal.ZERO); |
| | | BigDecimal contractAmount = salesLedgerService.getContractAmount(); |
| | | return AjaxResult.success(contractAmount != null ? contractAmount : BigDecimal.ZERO); |
| | | } catch (Exception e) { |
| | | return AjaxResult.error("获取合同金额失败:" + e.getMessage()); |
| | | } |
| | |
| | | public AjaxResult getTopFiveList() { |
| | | return AjaxResult.success(salesLedgerService.getTopFiveList()); |
| | | } |
| | | |
| | | /** |
| | | * 近半年开票,回款金额 |
| | | */ |
| | | @GetMapping("/getAmountHalfYear") |
| | | public AjaxResult getAmountHalfYear() { |
| | | return AjaxResult.success(salesLedgerService.getAmountHalfYear()); |
| | | } |
| | | } |