优化对账单的查询接口
This commit is contained in:
@@ -311,41 +311,50 @@ public class DepotHeadController {
|
||||
String subType = "";
|
||||
String typeBack = "";
|
||||
String subTypeBack = "";
|
||||
String billType = "";
|
||||
if (("供应商").equals(supplierType)) {
|
||||
type = "入库";
|
||||
subType = "采购";
|
||||
typeBack = "出库";
|
||||
subTypeBack = "采购退货";
|
||||
billType = "付款";
|
||||
} else if (("客户").equals(supplierType)) {
|
||||
type = "出库";
|
||||
subType = "销售";
|
||||
typeBack = "入库";
|
||||
subTypeBack = "销售退货";
|
||||
billType = "收款";
|
||||
}
|
||||
String [] organArray = depotHeadService.getOrganArray(subType, "");
|
||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
List<DepotHeadVo4StatementAccount> list = depotHeadService.getStatementAccount(beginTime, endTime, organId, organArray,
|
||||
supplierType, type, subType,typeBack, subTypeBack, (currentPage-1)*pageSize, pageSize);
|
||||
supplierType, type, subType,typeBack, subTypeBack, billType, (currentPage-1)*pageSize, pageSize);
|
||||
int total = depotHeadService.getStatementAccountCount(beginTime, endTime, organId, organArray,
|
||||
supplierType, type, subType,typeBack, subTypeBack);
|
||||
supplierType, type, subType,typeBack, subTypeBack, billType);
|
||||
for(DepotHeadVo4StatementAccount item: list) {
|
||||
//期初 = 起始期初金额+上期欠款金额-上期退货的欠款金额-上期收付款
|
||||
BigDecimal preNeed = item.getBeginNeed().add(item.getPreDebtMoney()).subtract(item.getPreReturnDebtMoney()).subtract(item.getPreBackMoney());
|
||||
item.setPreNeed(preNeed);
|
||||
//实际欠款 = 本期欠款-本期退货的欠款金额
|
||||
BigDecimal realDebtMoney = item.getDebtMoney().subtract(item.getReturnDebtMoney());
|
||||
item.setDebtMoney(realDebtMoney);
|
||||
//期末 = 期初+实际欠款-本期收款
|
||||
BigDecimal allNeedGet = preNeed.add(realDebtMoney).subtract(item.getBackMoney());
|
||||
item.setAllNeed(allNeedGet);
|
||||
}
|
||||
map.put("rows", list);
|
||||
map.put("total", total);
|
||||
List<DepotHeadVo4StatementAccount> totalPayList = depotHeadService.getStatementAccountTotalPay(beginTime, endTime, organId, organArray, supplierType, type, subType, typeBack, subTypeBack);
|
||||
List<DepotHeadVo4StatementAccount> totalPayList = depotHeadService.getStatementAccountTotalPay(beginTime, endTime, organId, organArray,
|
||||
supplierType, type, subType, typeBack, subTypeBack, billType);
|
||||
if(totalPayList.size()>0) {
|
||||
DepotHeadVo4StatementAccount totalPayItem = totalPayList.get(0);
|
||||
BigDecimal firstMoney = BigDecimal.ZERO;
|
||||
BigDecimal lastMoney = BigDecimal.ZERO;
|
||||
if(totalPayItem!=null) {
|
||||
//期初 = 起始期初金额+上期欠款金额-上期退货的欠款金额-上期收付款
|
||||
firstMoney = totalPayItem.getBeginNeed().add(totalPayItem.getPreDebtMoney()).subtract(totalPayItem.getPreReturnDebtMoney()).subtract(totalPayItem.getPreBackMoney());
|
||||
//期末 = 期初+本期欠款-本期退货的欠款金额-本期收款
|
||||
lastMoney = firstMoney.add(totalPayItem.getDebtMoney()).subtract(totalPayItem.getReturnDebtMoney()).subtract(totalPayItem.getBackMoney());
|
||||
}
|
||||
map.put("firstMoney", firstMoney); //期初
|
||||
|
||||
@@ -151,6 +151,7 @@ public interface DepotHeadMapperEx {
|
||||
@Param("subType") String subType,
|
||||
@Param("typeBack") String typeBack,
|
||||
@Param("subTypeBack") String subTypeBack,
|
||||
@Param("billType") String billType,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("rows") Integer rows);
|
||||
|
||||
@@ -163,7 +164,8 @@ public interface DepotHeadMapperEx {
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("typeBack") String typeBack,
|
||||
@Param("subTypeBack") String subTypeBack);
|
||||
@Param("subTypeBack") String subTypeBack,
|
||||
@Param("billType") String billType);
|
||||
|
||||
List<DepotHeadVo4StatementAccount> getStatementAccountTotalPay(
|
||||
@Param("beginTime") String beginTime,
|
||||
@@ -174,7 +176,8 @@ public interface DepotHeadMapperEx {
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("typeBack") String typeBack,
|
||||
@Param("subTypeBack") String subTypeBack);
|
||||
@Param("subTypeBack") String subTypeBack,
|
||||
@Param("billType") String billType);
|
||||
|
||||
BigDecimal findAllMoney(
|
||||
@Param("supplierId") Integer supplierId,
|
||||
|
||||
@@ -675,10 +675,10 @@ public class DepotHeadService {
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4StatementAccount> getStatementAccount(String beginTime, String endTime, Integer organId, String [] organArray,
|
||||
String supplierType, String type, String subType, String typeBack, String subTypeBack, Integer offset, Integer rows) {
|
||||
String supplierType, String type, String subType, String typeBack, String subTypeBack, String billType, Integer offset, Integer rows) {
|
||||
List<DepotHeadVo4StatementAccount> list = null;
|
||||
try{
|
||||
list = depotHeadMapperEx.getStatementAccount(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack, offset, rows);
|
||||
list = depotHeadMapperEx.getStatementAccount(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack, billType, offset, rows);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -686,10 +686,10 @@ public class DepotHeadService {
|
||||
}
|
||||
|
||||
public int getStatementAccountCount(String beginTime, String endTime, Integer organId,
|
||||
String [] organArray, String supplierType, String type, String subType, String typeBack, String subTypeBack) {
|
||||
String [] organArray, String supplierType, String type, String subType, String typeBack, String subTypeBack, String billType) {
|
||||
int result = 0;
|
||||
try{
|
||||
result = depotHeadMapperEx.getStatementAccountCount(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack);
|
||||
result = depotHeadMapperEx.getStatementAccountCount(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack, billType);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -698,10 +698,10 @@ public class DepotHeadService {
|
||||
|
||||
public List<DepotHeadVo4StatementAccount> getStatementAccountTotalPay(String beginTime, String endTime, Integer organId,
|
||||
String [] organArray, String supplierType,
|
||||
String type, String subType, String typeBack, String subTypeBack) {
|
||||
String type, String subType, String typeBack, String subTypeBack, String billType) {
|
||||
List<DepotHeadVo4StatementAccount> list = null;
|
||||
try{
|
||||
list = depotHeadMapperEx.getStatementAccountTotalPay(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack);
|
||||
list = depotHeadMapperEx.getStatementAccountTotalPay(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack, billType);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
|
||||
@@ -411,9 +411,9 @@ public class SupplierService {
|
||||
} else if("客户".equals(supplier.getType())) {
|
||||
needDebt = supplier.getBeginNeedGet();
|
||||
}
|
||||
BigDecimal finishDebt = accountItemMapperEx.getFinishDebtByOrganId(organId);
|
||||
BigDecimal finishDebt = accountItemMapperEx.getFinishDebtByOrganId(organId).abs();
|
||||
BigDecimal eachAmount = BigDecimal.ZERO;
|
||||
if(needDebt != null && finishDebt != null) {
|
||||
if(needDebt != null) {
|
||||
eachAmount = needDebt.subtract(finishDebt);
|
||||
}
|
||||
//应收欠款
|
||||
|
||||
Reference in New Issue
Block a user