Commit 44d7f643 authored by zhangfeng's avatar zhangfeng

feat(wealth): 银行收支明细(未联调)

parent ece88681
package cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemReq;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemResp;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemReq;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -17,7 +14,11 @@ public interface BankReceiptDetailsMapper {
long GetCount(ReceiptItemReq req);
void getBankIncomeItemPage(IPage<BankIncomeItemResp> page, @Param("req") BankIncomeItemReq req);
IPage<BankIncomeItemResp> getBankIncomeItemPage(IPage<BankIncomeItemResp> page, @Param("req") BankIncomeItemReq req);
BigDecimal calculateAccountBalance(String accountNo);
List<ReceiptItemActualAmount> calculateCurrentAmount(@Param("req") BankIncomeItemReq req);
List<ReceiptItemActualAmount> calculateTotalAmount();
}
......@@ -8,10 +8,7 @@ import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import cn.iocoder.yudao.module.wealth.dal.mysql.receipt.ReceiptMapper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem.BankReceiptDetailsMapper;
import cn.iocoder.yudao.module.wealth.vo.receipt.ReceiptRelationOrderInfoVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemReq;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemResp;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemReq;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
......@@ -72,11 +69,11 @@ public class BankReceiptDetailsImpl implements BankReceiptDetailsService {
}
@Override
public PageResult<BankIncomeItemResp> getBankIncomeItemPage(BankIncomeItemReq req) {
public BankIncomePageResult<BankIncomeItemResp> getBankIncomeItemPage(BankIncomeItemReq req) {
IPage<BankIncomeItemResp> mpPage = MyBatisUtils.buildPage(req);
bankReceiptDetailsMapper.getBankIncomeItemPage(mpPage, req);
if (mpPage.getTotal() == 0) {
return PageResult.empty();
return BankIncomePageResult.empty();
}
// 计算账号余额
List<BankIncomeItemResp> records = mpPage.getRecords();
......@@ -88,10 +85,14 @@ public class BankReceiptDetailsImpl implements BankReceiptDetailsService {
record.setAccountBalance(bankReceiptDetailsMapper.calculateAccountBalance(record.getAccountNo()));
accountBalanceMap.put(record.getAccountNo(), record.getAccountBalance());
}
List<ReceiptRelationOrderInfoVO> orderInfoByReceiptId = receiptMapper.getOrderInfoByReceiptId(Long.parseLong(record.getReceiptId()));
record.setOrderInfoList(orderInfoByReceiptId);
}
// 汇总不同币种总额
//bankReceiptDetailsMapper.
return PageResult.of(mpPage);
BankIncomePageResult<BankIncomeItemResp> result = BankIncomePageResult.of(mpPage);
result.setCurrentAmount(bankReceiptDetailsMapper.calculateCurrentAmount(req));
result.setTotalAmount(bankReceiptDetailsMapper.calculateTotalAmount());
return result;
}
/*
......
package cn.iocoder.yudao.module.wealth.service.receiptItem;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemReq;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemResp;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemReq;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.*;
public interface BankReceiptDetailsService {
PageResult<ReceiptItemRespVO> getBankReceiptDetailsList(ReceiptItemReq req);
PageResult<BankIncomeItemResp> getBankIncomeItemPage(BankIncomeItemReq req);
BankIncomePageResult<BankIncomeItemResp> getBankIncomeItemPage(BankIncomeItemReq req);
}
......@@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import cn.iocoder.yudao.module.ecw.api.currency.dto.ExchangeRateRespDTO;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.wealth.convert.receipt.ReceiptConvert;
import cn.iocoder.yudao.module.wealth.convert.receiptItem.ReceiptItemConvert;
import cn.iocoder.yudao.module.wealth.convert.receivable.ReceivableConvert;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptBankWriteoffRangeDO;
......@@ -734,6 +735,8 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
throw exception(RECEIPT_ITEM_NOT_FOUND);
}
ReceiptItemBackVO itemBackVO = ReceiptItemConvert.INSTANCE.convert(receiptItemDO);
ReceiptDO receiptDO = receiptMapper.selectById(receiptItemDO.getReceiptId());
itemBackVO.setReceiptNo(receiptDO.getReceiptNo());
List<ReceivableInItemVO> listForCreateReceiptItem = receivableService.getListForCreateReceiptItem(receiptItemDO.getReceiptId());
itemBackVO.setReceivableList(listForCreateReceiptItem);
return itemBackVO;
......
package cn.iocoder.yudao.module.wealth.vo.receiptItem;
import cn.iocoder.yudao.module.wealth.vo.receipt.ReceiptRelationOrderInfoVO;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
......@@ -22,21 +23,8 @@ public class BankIncomeItemResp {
@ApiModelProperty(value = "收款账号")
private String accountNo;
/**
* 当次实收金额不含税
*/
private java.math.BigDecimal amount;
/**
* 税点
*/
private java.math.BigDecimal taxPoint;
/**
* 当次实收金额含税
*/
private java.math.BigDecimal taxAmount;
/**
* 收款账号名称
*/
@ApiModelProperty(value = "收款账号名称")
private String accountName;
@ApiModelProperty(value = "收款账号银行名称")
......@@ -52,15 +40,9 @@ public class BankIncomeItemResp {
@ApiModelProperty(value = "收款单编号")
private String receiptNo;
@ApiModelProperty(value = "订单ID")
private long orderId;
@ApiModelProperty(value = "订单编号")
private String orderNo;
@ApiModelProperty(value = "提单编号")
private String tidanNo;
@ApiModelProperty(value = "账号余额")
private java.math.BigDecimal accountBalance;
@ApiModelProperty(value = "相关订单信息列表")
private List<ReceiptRelationOrderInfoVO> orderInfoList;
}
package cn.iocoder.yudao.module.wealth.vo.receiptItem;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel("分页结果")
public final class BankIncomePageResult<T> implements Serializable {
@ApiModelProperty(value = "数据", required = true)
private List<T> list;
@ApiModelProperty(value = "总量", required = true, example = "0")
private Long total = 0L;
@ApiModelProperty(value = "每页记录数", required = true, example = "10")
private Long rows = 10L;
@ApiModelProperty(value = "当前页数", required = true, example = "1")
private Long page = 1L;
@ApiModelProperty(value = "总页数", required = true, example = "0")
private Long pages = 0L;
@ApiModelProperty(value = "当前搜索条件汇总")
List<ReceiptItemActualAmount> currentAmount;
@ApiModelProperty(value = "总合计")
List<ReceiptItemActualAmount> totalAmount;
public BankIncomePageResult() {}
public BankIncomePageResult(List<T> list, long total) {
this.list = list;
this.total = total;
}
public BankIncomePageResult(List<T> list, long total, long rows, long page, long pages) {
this.list = list;
this.rows = rows;
this.page = page;
this.pages = pages;
this.total = total;
}
public BankIncomePageResult(long total) {
this.list = new ArrayList<>();
this.total = total;
}
public static <T> BankIncomePageResult<T> empty() {
return new BankIncomePageResult<>();
}
public static <T> BankIncomePageResult<T> empty(long total) {
return new BankIncomePageResult<>(total);
}
/****
* 分页转换
* @param pager
* @return
*/
public static <T> BankIncomePageResult<T> of(IPage<T> pager){
return new BankIncomePageResult<>(pager.getRecords(), pager.getTotal(), pager.getSize(), pager.getCurrent(), pager.getPages());
}
/****
* 分页转换
* @param pager
* @return
*/
public static <T> BankIncomePageResult<T> of(PageInfo<T> pager){
return new BankIncomePageResult<>(pager.getList(), pager.getTotal(), pager.getPageSize(), pager.getPageNum(), pager.getPages());
}
}
......@@ -33,6 +33,9 @@ public class ReceiptItemBackVO {
@ApiModelProperty(value = "收款单id")
private Long receiptId;
@ApiModelProperty(value = "收款单号")
private String receiptNo;
@ExcelProperty("收款账号")
@ApiModelProperty(value = "收款账号")
private String accountNo;
......
......@@ -4,17 +4,12 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.wealth.dal.mysql.receipt.ReceiptMapper;
import cn.iocoder.yudao.module.wealth.service.receiptItem.BankReceiptDetailsService;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemReq;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemResp;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemReq;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -38,9 +33,9 @@ public class BankReceiptDetailsControl {
return success(bankReceiptDetailsService.getBankReceiptDetailsList(req));
}
@GetMapping("/income/page")
@PostMapping("/income/page")
@ApiOperation("银行账号收支明细列表")
public CommonResult<PageResult<BankIncomeItemResp>> getBankIncomeItemPage(BankIncomeItemReq req) {
public CommonResult<BankIncomePageResult<BankIncomeItemResp>> getBankIncomeItemPage(@RequestBody BankIncomeItemReq req) {
return success(bankReceiptDetailsService.getBankIncomeItemPage(req));
}
}
......@@ -85,7 +85,7 @@
<include refid="WherePage"/>
ORDER BY p.receipt_id desc,p.create_time
</select>
<select id="getBankIncomeItemPage">
<select id="getBankIncomeItemPage" resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.BankIncomeItemResp">
SELECT
eri.id,
eri.receipt_id,
......@@ -95,15 +95,27 @@
eri.amount,
eri.currency_id,
er.receipt_no,
eo.tidan_no,
eo.order_no,
eri.amount_date,
eri.remark
FROM ecw_receipt_item eri
LEFT JOIN ecw_receipt er ON eri.receipt_id = er.id
LEFT JOIN ecw_order eo ON eo.order_id = er.order_id
INNER JOIN (SELECT receipt_id, order_id FROM ecw_receivable GROUP BY receipt_id, order_id) rb
ON rb.receipt_id = er.id
LEFT JOIN ecw_order eo ON eo.order_id = rb.order_id
LEFT JOIN ecw_receipt_account era ON era.receipt_id = eri.receipt_id
WHERE eri.status = 1
<include refid="incomePageCondition"/>
GROUP BY eri.id
<!-- <if test="req.isAsc != null">-->
<!-- <if test="req.isAsc">-->
<!-- ORDER BY eri.amount_date-->
<!-- </if>-->
<!-- <if test="!req.isAsc">-->
<!-- ORDER BY eri.amount_date DESC-->
<!-- </if>-->
<!-- </if>-->
</select>
<sql id="incomePageCondition">
<if test="req.relationNo != null and req.relationNo != ''">
AND (er.receipt_no LIKE concat('%',#{req.receiptNo},'%') OR eo.order_no LIKE
concat('%',#{req.relationNo},'%') OR eo.tidan_no = #{req.relationNo})
......@@ -129,20 +141,39 @@
<if test="req.amountDateStart != null and req.amountDateEnd != null">
AND eri.amount_date BETWEEN #{req.amountDateStart} AND #{req.amountDateEnd}
</if>
<if test="req.isAsc != null">
<if test="req.isAsc">
ORDER BY eri.amount_date
</if>
<if test="!req.isAsc">
ORDER BY eri.amount_date DESC
</if>
</if>
</select>
</sql>
<select id="calculateAccountBalance" resultType="java.math.BigDecimal">
SELECT SUM(amount)
FROM ecw_receipt_item
WHERE
account_no = #{accountNo} AND status = 1
</select>
<select id="calculateCurrentAmount"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemActualAmount">
SELECT
SUM(t.amount) AS amount,
t.currency_id AS currencyId
FROM (
SELECT eri.amount,
eri.currency_id
FROM ecw_receipt_item eri
LEFT JOIN ecw_receipt er ON eri.receipt_id = er.id
INNER JOIN (SELECT receipt_id, order_id FROM ecw_receivable GROUP BY receipt_id, order_id) rb
ON rb.receipt_id = er.id
LEFT JOIN ecw_order eo ON eo.order_id = rb.order_id
LEFT JOIN ecw_receipt_account era ON era.receipt_id = eri.receipt_id
WHERE eri.status = 1
<include refid="incomePageCondition"/>
GROUP BY eri.id) AS t
GROUP BY t.currency_id
</select>
<select id="calculateTotalAmount"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemActualAmount">
SELECT
SUM(amount) AS amount,
currency_id AS currencyId
FROM ecw_receipt_item
WHERE status = 1
GROUP BY currency_id
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment