Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
1015eb90
Commit
1015eb90
authored
Jun 03, 2022
by
季圣华
Browse files
优化客户对账和供应商对账
parent
9ff1d99a
Changes
5
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java
View file @
1015eb90
...
...
@@ -280,44 +280,54 @@ public class DepotHeadController {
* @param beginTime
* @param endTime
* @param organId
* @param supType
* @param sup
plier
Type
* @param request
* @return
*/
@GetMapping
(
value
=
"/
find
StatementAccount"
)
@GetMapping
(
value
=
"/
get
StatementAccount"
)
@ApiOperation
(
value
=
"对账单接口"
)
public
BaseResponseInfo
find
StatementAccount
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"beginTime"
)
String
beginTime
,
@RequestParam
(
"endTime"
)
String
endTime
,
@RequestParam
(
value
=
"organId"
,
required
=
false
)
Integer
organId
,
@RequestParam
(
"supType"
)
String
supType
,
HttpServletRequest
request
)
throws
Exception
{
public
BaseResponseInfo
get
StatementAccount
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"beginTime"
)
String
beginTime
,
@RequestParam
(
"endTime"
)
String
endTime
,
@RequestParam
(
value
=
"organId"
,
required
=
false
)
Integer
organId
,
@RequestParam
(
"sup
plier
Type"
)
String
sup
plier
Type
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
try
{
String
type
=
""
;
String
subType
=
""
;
if
((
"供应商"
).
equals
(
supplierType
))
{
type
=
"入库"
;
subType
=
"采购"
;
}
else
if
((
"客户"
).
equals
(
supplierType
))
{
type
=
"出库"
;
subType
=
"销售"
;
}
beginTime
=
Tools
.
parseDayToTime
(
beginTime
,
BusinessConstants
.
DAY_FIRST_TIME
);
endTime
=
Tools
.
parseDayToTime
(
endTime
,
BusinessConstants
.
DAY_LAST_TIME
);
List
<
DepotHeadVo4StatementAccount
>
list
=
depotHeadService
.
findStatementAccount
(
beginTime
,
endTime
,
organId
,
supType
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
int
total
=
depotHeadService
.
findStatementAccountCount
(
beginTime
,
endTime
,
organId
,
supType
);
List
<
DepotHeadVo4StatementAccount
>
list
=
depotHeadService
.
getStatementAccount
(
beginTime
,
endTime
,
organId
,
supplierType
,
type
,
subType
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
int
total
=
depotHeadService
.
getStatementAccountCount
(
beginTime
,
endTime
,
organId
,
supplierType
,
type
,
subType
);
for
(
DepotHeadVo4StatementAccount
item:
list
)
{
BigDecimal
preNeed
=
item
.
getBeginNeed
().
add
(
item
.
getPreDebtMoney
()).
subtract
(
item
.
getPreBackMoney
());
item
.
setPreNeed
(
preNeed
);
BigDecimal
allNeedGet
=
preNeed
.
add
(
item
.
getDebtMoney
()).
subtract
(
item
.
getBackMoney
());
item
.
setAllNeed
(
allNeedGet
);
}
map
.
put
(
"rows"
,
list
);
map
.
put
(
"total"
,
total
);
if
(
null
!=
organId
)
{
Supplier
supplier
=
supplierService
.
getSupplier
(
organId
);
BigDecimal
beginNeed
=
BigDecimal
.
ZERO
;
if
((
"客户"
).
equals
(
supType
))
{
if
(
supplier
.
getBeginNeedGet
()!=
null
)
{
beginNeed
=
supplier
.
getBeginNeedGet
();
}
}
else
if
((
"供应商"
).
equals
(
supType
))
{
if
(
supplier
.
getBeginNeedPay
()!=
null
)
{
beginNeed
=
supplier
.
getBeginNeedPay
();
}
List
<
DepotHeadVo4StatementAccount
>
totalPayList
=
depotHeadService
.
getStatementAccountTotalPay
(
beginTime
,
endTime
,
organId
,
supplierType
,
type
,
subType
);
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
.
getPreBackMoney
());
lastMoney
=
firstMoney
.
add
(
totalPayItem
.
getDebtMoney
()).
subtract
(
totalPayItem
.
getBackMoney
());
}
BigDecimal
firstMoney
=
depotHeadService
.
findTotalPay
(
organId
,
beginTime
,
supType
)
.
subtract
(
accountHeadService
.
findTotalPay
(
organId
,
beginTime
,
supType
)).
add
(
beginNeed
);
BigDecimal
lastMoney
=
depotHeadService
.
findTotalPay
(
organId
,
endTime
,
supType
)
.
subtract
(
accountHeadService
.
findTotalPay
(
organId
,
endTime
,
supType
)).
add
(
beginNeed
);
map
.
put
(
"firstMoney"
,
firstMoney
);
//期初
map
.
put
(
"lastMoney"
,
lastMoney
);
//期末
}
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapperEx.java
View file @
1015eb90
...
...
@@ -121,19 +121,31 @@ public interface DepotHeadMapperEx {
@Param
(
"depotFList"
)
List
<
Long
>
depotFList
,
@Param
(
"remark"
)
String
remark
);
List
<
DepotHeadVo4StatementAccount
>
find
StatementAccount
(
List
<
DepotHeadVo4StatementAccount
>
get
StatementAccount
(
@Param
(
"beginTime"
)
String
beginTime
,
@Param
(
"endTime"
)
String
endTime
,
@Param
(
"organId"
)
Integer
organId
,
@Param
(
"supType"
)
String
supType
,
@Param
(
"supplierType"
)
String
supplierType
,
@Param
(
"type"
)
String
type
,
@Param
(
"subType"
)
String
subType
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"rows"
)
Integer
rows
);
int
findStatementAccountCount
(
int
getStatementAccountCount
(
@Param
(
"beginTime"
)
String
beginTime
,
@Param
(
"endTime"
)
String
endTime
,
@Param
(
"organId"
)
Integer
organId
,
@Param
(
"supplierType"
)
String
supplierType
,
@Param
(
"type"
)
String
type
,
@Param
(
"subType"
)
String
subType
);
List
<
DepotHeadVo4StatementAccount
>
getStatementAccountTotalPay
(
@Param
(
"beginTime"
)
String
beginTime
,
@Param
(
"endTime"
)
String
endTime
,
@Param
(
"organId"
)
Integer
organId
,
@Param
(
"supType"
)
String
supType
);
@Param
(
"supplierType"
)
String
supplierType
,
@Param
(
"type"
)
String
type
,
@Param
(
"subType"
)
String
subType
);
BigDecimal
findAllMoney
(
@Param
(
"supplierId"
)
Integer
supplierId
,
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/vo/DepotHeadVo4StatementAccount.java
View file @
1015eb90
...
...
@@ -5,103 +5,133 @@ import java.math.BigDecimal;
public
class
DepotHeadVo4StatementAccount
{
private
String
number
;
private
Long
id
;
private
String
type
;
private
String
supplier
;
private
BigDecimal
dis
co
u
nt
LastMoney
;
private
String
cont
acts
;
private
BigDecimal
otherM
one
y
;
private
String
teleph
one
;
private
BigDecimal
billMoney
;
private
String
phoneNum
;
private
BigDecimal
changeAmount
;
private
String
email
;
private
BigDecimal
allPrice
;
private
BigDecimal
beginNeed
;
private
String
supplierName
;
private
BigDecimal
preDebtMoney
;
private
String
oTime
;
private
BigDecimal
preBackMoney
;
private
Long
tenantI
d
;
private
BigDecimal
preNee
d
;
public
String
getNumber
()
{
return
number
;
private
BigDecimal
debtMoney
;
private
BigDecimal
backMoney
;
private
BigDecimal
allNeed
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getSupplier
()
{
return
supplier
;
}
public
void
setSupplier
(
String
supplier
)
{
this
.
supplier
=
supplier
;
}
public
String
getContacts
()
{
return
contacts
;
}
public
void
setContacts
(
String
contacts
)
{
this
.
contacts
=
contacts
;
}
public
String
getTelephone
()
{
return
telephone
;
}
public
void
set
Number
(
String
number
)
{
this
.
number
=
number
;
public
void
set
Telephone
(
String
telephone
)
{
this
.
telephone
=
telephone
;
}
public
String
get
Type
()
{
return
type
;
public
String
get
PhoneNum
()
{
return
phoneNum
;
}
public
void
set
Type
(
String
type
)
{
this
.
type
=
type
;
public
void
set
PhoneNum
(
String
phoneNum
)
{
this
.
phoneNum
=
phoneNum
;
}
public
BigDecimal
getDiscountLastMoney
()
{
return
discountLastMoney
;
public
String
getEmail
()
{
return
email
;
}
public
void
set
DiscountLastMoney
(
BigDecimal
discountLastMoney
)
{
this
.
discountLastMoney
=
discountLastMoney
;
public
void
set
Email
(
String
email
)
{
this
.
email
=
email
;
}
public
BigDecimal
get
OtherMoney
()
{
return
otherMoney
;
public
BigDecimal
get
BeginNeed
()
{
return
beginNeed
;
}
public
void
set
OtherMoney
(
BigDecimal
otherMoney
)
{
this
.
otherMoney
=
otherMoney
;
public
void
set
BeginNeed
(
BigDecimal
beginNeed
)
{
this
.
beginNeed
=
beginNeed
;
}
public
BigDecimal
get
Bill
Money
()
{
return
bill
Money
;
public
BigDecimal
get
PreDebt
Money
()
{
return
preDebt
Money
;
}
public
void
set
Bill
Money
(
BigDecimal
bill
Money
)
{
this
.
bill
Money
=
bill
Money
;
public
void
set
PreDebt
Money
(
BigDecimal
preDebt
Money
)
{
this
.
preDebt
Money
=
preDebt
Money
;
}
public
BigDecimal
get
ChangeAmount
()
{
return
changeAmount
;
public
BigDecimal
get
PreBackMoney
()
{
return
preBackMoney
;
}
public
void
set
ChangeAmount
(
BigDecimal
changeAmount
)
{
this
.
changeAmount
=
changeAmount
;
public
void
set
PreBackMoney
(
BigDecimal
preBackMoney
)
{
this
.
preBackMoney
=
preBackMoney
;
}
public
BigDecimal
get
AllPrice
()
{
return
allPrice
;
public
BigDecimal
get
PreNeed
()
{
return
preNeed
;
}
public
void
set
AllPrice
(
BigDecimal
allPrice
)
{
this
.
allPrice
=
allPrice
;
public
void
set
PreNeed
(
BigDecimal
preNeed
)
{
this
.
preNeed
=
preNeed
;
}
public
String
getSupplierName
()
{
return
supplierName
;
public
BigDecimal
getDebtMoney
()
{
return
debtMoney
;
}
public
void
set
SupplierName
(
String
supplierName
)
{
this
.
supplierName
=
supplierName
;
public
void
set
DebtMoney
(
BigDecimal
debtMoney
)
{
this
.
debtMoney
=
debtMoney
;
}
public
String
getoTime
()
{
return
oTime
;
public
BigDecimal
getBackMoney
()
{
return
backMoney
;
}
public
void
set
oTime
(
String
oTime
)
{
this
.
oTime
=
oTime
;
public
void
set
BackMoney
(
BigDecimal
backMoney
)
{
this
.
backMoney
=
backMoney
;
}
public
Long
getTenantI
d
()
{
return
tenantI
d
;
public
BigDecimal
getAllNee
d
()
{
return
allNee
d
;
}
public
void
set
TenantId
(
Long
tenantI
d
)
{
this
.
tenantId
=
tenantI
d
;
public
void
set
AllNeed
(
BigDecimal
allNee
d
)
{
this
.
allNeed
=
allNee
d
;
}
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
View file @
1015eb90
...
...
@@ -511,72 +511,39 @@ public class DepotHeadService {
return
result
;
}
public
List
<
DepotHeadVo4StatementAccount
>
findStatementAccount
(
String
beginTime
,
String
endTime
,
Integer
organId
,
String
supType
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
public
List
<
DepotHeadVo4StatementAccount
>
getStatementAccount
(
String
beginTime
,
String
endTime
,
Integer
organId
,
String
supplierType
,
String
type
,
String
subType
,
Integer
offset
,
Integer
rows
)
{
List
<
DepotHeadVo4StatementAccount
>
list
=
null
;
try
{
int
j
=
1
;
if
(
supType
.
equals
(
"客户"
))
{
//客户
j
=
1
;
}
else
if
(
supType
.
equals
(
"供应商"
))
{
//供应商
j
=
-
1
;
}
list
=
depotHeadMapperEx
.
findStatementAccount
(
beginTime
,
endTime
,
organId
,
supType
,
offset
,
rows
);
if
(
null
!=
list
)
{
for
(
DepotHeadVo4StatementAccount
dha
:
list
)
{
dha
.
setNumber
(
dha
.
getNumber
());
//单据编号
dha
.
setType
(
dha
.
getType
());
//类型
String
type
=
dha
.
getType
();
BigDecimal
p1
=
BigDecimal
.
ZERO
;
BigDecimal
p2
=
BigDecimal
.
ZERO
;
if
(
dha
.
getDiscountLastMoney
()
!=
null
)
{
p1
=
dha
.
getDiscountLastMoney
();
}
if
(
dha
.
getChangeAmount
()
!=
null
)
{
p2
=
dha
.
getChangeAmount
();
}
BigDecimal
allPrice
=
BigDecimal
.
ZERO
;
if
((
p1
.
compareTo
(
BigDecimal
.
ZERO
))==-
1
)
{
p1
=
p1
.
abs
();
}
if
(
dha
.
getOtherMoney
()!=
null
)
{
p1
=
p1
.
add
(
dha
.
getOtherMoney
());
//与其它费用相加
}
if
((
p2
.
compareTo
(
BigDecimal
.
ZERO
))==-
1
)
{
p2
=
p2
.
abs
();
}
if
(
type
.
equals
(
"采购入库"
))
{
allPrice
=
p2
.
subtract
(
p1
);
}
else
if
(
type
.
equals
(
"销售出库"
))
{
allPrice
=
p1
.
subtract
(
p2
);
}
else
if
(
type
.
equals
(
"收款"
))
{
allPrice
=
BigDecimal
.
ZERO
.
subtract
(
p1
);
}
else
if
(
type
.
equals
(
"付款"
))
{
allPrice
=
p1
;
}
dha
.
setBillMoney
(
p1
);
//单据金额
dha
.
setChangeAmount
(
p2
);
//实际支付
DecimalFormat
df
=
new
DecimalFormat
(
".##"
);
dha
.
setAllPrice
(
new
BigDecimal
(
df
.
format
(
allPrice
.
multiply
(
new
BigDecimal
(
j
)))));
//本期变化
dha
.
setSupplierName
(
dha
.
getSupplierName
());
//单位名称
dha
.
setoTime
(
dha
.
getoTime
());
//单据日期
}
}
list
=
depotHeadMapperEx
.
getStatementAccount
(
beginTime
,
endTime
,
organId
,
supplierType
,
type
,
subType
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
int
findStatementAccountCount
(
String
beginTime
,
String
endTime
,
Integer
organId
,
String
supType
)
throws
Exception
{
public
int
getStatementAccountCount
(
String
beginTime
,
String
endTime
,
Integer
organId
,
String
supplierType
,
String
type
,
String
subType
)
{
int
result
=
0
;
try
{
result
=
depotHeadMapperEx
.
find
StatementAccountCount
(
beginTime
,
endTime
,
organId
,
supType
);
}
catch
(
Exception
e
){
result
=
depotHeadMapperEx
.
get
StatementAccountCount
(
beginTime
,
endTime
,
organId
,
sup
plierType
,
type
,
sub
Type
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
DepotHeadVo4StatementAccount
>
getStatementAccountTotalPay
(
String
beginTime
,
String
endTime
,
Integer
organId
,
String
supplierType
,
String
type
,
String
subType
)
{
List
<
DepotHeadVo4StatementAccount
>
list
=
null
;
try
{
list
=
depotHeadMapperEx
.
getStatementAccountTotalPay
(
beginTime
,
endTime
,
organId
,
supplierType
,
type
,
subType
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
BigDecimal
findAllMoney
(
Integer
supplierId
,
String
type
,
String
subType
,
String
mode
,
String
endTime
)
throws
Exception
{
String
modeName
=
""
;
BigDecimal
allOtherMoney
=
BigDecimal
.
ZERO
;
...
...
jshERP-boot/src/main/resources/mapper_xml/DepotHeadMapperEx.xml
View file @
1015eb90
...
...
@@ -473,53 +473,123 @@
ORDER BY oper_time DESC,number desc
</select>
<select
id=
"findStatementAccount"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"ResultStatementAccount"
>
select dh.number,concat(dh.sub_type,dh.type) as type,dh.discount_last_money,dh.other_money,dh.change_amount,s.supplier supplierName,
date_format(dh.oper_time,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depot_head dh
left join jsh_supplier s on s.id=dh.organ_id and ifnull(s.delete_Flag,'0') !='1'
where s.type=#{supType} and (dh.sub_type='采购' or dh.sub_type='销售')
and dh.oper_time >=#{beginTime} and dh.oper_time
<
=#{endTime}
<if
test=
"organId != null"
>
and dh.organ_id=#{organId}
</if>
and ifnull(dh.delete_flag,'0') !='1'
UNION ALL
select ah.bill_no number,ah.type as newType,ah.total_price discount_last_money, 0 other_money,ah.change_amount,s.supplier supplierName,
date_format(ah.bill_time,'%Y-%m-%d %H:%i:%S') as oTime from jsh_account_head ah
left join jsh_supplier s on s.id=ah.organ_id and ifnull(s.delete_Flag,'0') !='1'
where s.type=#{supType} and (ah.type='收款' or ah.type='付款')
and ah.bill_time >=#{beginTime} and ah.bill_time
<
=#{endTime}
<select
id=
"getStatementAccount"
resultType=
"com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount"
>
select * from
(select s.id, s.supplier, s.contacts, s.telephone, s.phone_num, s.email,
(case when s.type='供应商' then ifnull(s.begin_need_pay,0) else ifnull(s.begin_need_get,0) end) begin_need,
(select
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
from jsh_depot_head dh
where dh.organ_id=s.id
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time
<
= #{beginTime}
and ifnull(dh.delete_flag,'0') !='1') preDebtMoney,
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where dh.organ_id=s.id
and dh.oper_time
<
= #{beginTime}
and ifnull(ai.delete_flag,'0') !='1') preBackMoney,
(select
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
from jsh_depot_head dh
where dh.organ_id=s.id
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time>#{beginTime} and dh.oper_time
<
= #{endTime}
and ifnull(dh.delete_flag,'0') !='1') debtMoney,
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where dh.organ_id=s.id
and dh.oper_time>#{beginTime} and dh.oper_time
<
= #{endTime}
and ifnull(ai.delete_flag,'0') !='1') backMoney
from jsh_supplier s
where s.enabled=1
and s.type=#{supplierType}
<if
test=
"organId != null"
>
and
ah.organ_id=
#{organId}
and
s.id =
#{organId}
</if>
and ifnull(ah.delete_flag,'0') !='1'
ORDER BY oTime desc
and ifnull(s.delete_flag,'0') !='1') tb
where begin_need+preDebtMoney-preBackMoney+debtMoney-backMoney>0
order by begin_need+preDebtMoney-preBackMoney+debtMoney-backMoney desc
<if
test=
"offset != null and rows != null"
>
limit #{offset},#{rows}
</if>
</select>
<select
id=
"findStatementAccountCount"
resultType=
"java.lang.Integer"
>
select sum(a) from
(
select count(1) a from jsh_depot_head dh
left join jsh_supplier s on s.id=dh.organ_id and ifnull(s.delete_Flag,'0') !='1'
where s.type=#{supType} and (dh.sub_type='采购' or dh.sub_type='销售')
and dh.oper_time >=#{beginTime} and dh.oper_time
<
=#{endTime}
<if
test=
"organId != null"
>
and dh.organ_id=#{organId}
</if>
and ifnull(dh.delete_flag,'0') !='1'
UNION ALL
select count(1) a from jsh_account_head ah
left join jsh_supplier s on s.id=ah.organ_id and ifnull(s.delete_Flag,'0') !='1'
where s.type=#{supType} and (ah.type='收款' or ah.type='付款')
and ah.bill_time >=#{beginTime} and ah.bill_time
<
=#{endTime}
<if
test=
"organId != null"
>
and ah.organ_id=#{organId}
</if>
and ifnull(ah.delete_flag,'0') !='1'
) cc
<select
id=
"getStatementAccountCount"
resultType=
"java.lang.Integer"
>
select count(1) from
(select s.id, s.supplier, s.contacts, s.telephone, s.phone_num, s.email,
(case when s.type='供应商' then ifnull(s.begin_need_pay,0) else ifnull(s.begin_need_get,0) end) begin_need,
(select
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
from jsh_depot_head dh
where dh.organ_id=s.id
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time
<
= #{beginTime}
and ifnull(dh.delete_flag,'0') !='1') preDebtMoney,
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where dh.organ_id=s.id
and dh.oper_time
<
= #{beginTime}
and ifnull(ai.delete_flag,'0') !='1') preBackMoney,
(select
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
from jsh_depot_head dh
where dh.organ_id=s.id
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time>#{beginTime} and dh.oper_time
<
= #{endTime}
and ifnull(dh.delete_flag,'0') !='1') debtMoney,
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where dh.organ_id=s.id
and dh.oper_time>#{beginTime} and dh.oper_time
<
= #{endTime}
and ifnull(ai.delete_flag,'0') !='1') backMoney
from jsh_supplier s
where s.enabled=1
and s.type=#{supplierType}
<if
test=
"organId != null"
>
and s.id = #{organId}
</if>
and ifnull(s.delete_flag,'0') !='1') tb
where begin_need+preDebtMoney-preBackMoney+debtMoney-backMoney>0
</select>
<select
id=
"getStatementAccountTotalPay"
resultType=
"com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount"
>
select sum(begin_need) begin_need, sum(preDebtMoney) preDebtMoney, sum(preBackMoney) preBackMoney,
sum(debtMoney) debtMoney, sum(backMoney) backMoney from
(select s.id,
(case when s.type='供应商' then ifnull(s.begin_need_pay,0) else ifnull(s.begin_need_get,0) end) begin_need,
(select
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
from jsh_depot_head dh
where dh.organ_id=s.id
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time
<
= #{beginTime}
and ifnull(dh.delete_flag,'0') !='1') preDebtMoney,
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where dh.organ_id=s.id
and dh.oper_time
<
= #{beginTime}
and ifnull(ai.delete_flag,'0') !='1') preBackMoney,
(select
ifnull(sum(dh.discount_last_money),0)+ifnull(sum(dh.other_money),0)-ifnull(sum(dh.deposit),0)-abs(ifnull(sum(dh.change_amount),0))
from jsh_depot_head dh
where dh.organ_id=s.id
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time>#{beginTime} and dh.oper_time
<
= #{endTime}
and ifnull(dh.delete_flag,'0') !='1') debtMoney,
(select abs(ifnull(sum(ai.each_amount),0)) from jsh_account_item ai
left join jsh_depot_head dh on ai.bill_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where dh.organ_id=s.id
and dh.oper_time>#{beginTime} and dh.oper_time
<
= #{endTime}
and ifnull(ai.delete_flag,'0') !='1') backMoney
from jsh_supplier s
where s.enabled=1
and s.type=#{supplierType}
<if
test=
"organId != null"
>
and s.id = #{organId}
</if>
and ifnull(s.delete_flag,'0') !='1') tb
where begin_need+preDebtMoney-preBackMoney+debtMoney-backMoney>0
</select>
<select
id=
"findAllMoney"
resultType=
"java.math.BigDecimal"
>
...
...
@@ -714,4 +784,5 @@
and dh.number!=#{number}
and ifnull(dh.delete_flag,'0') !='1'
</select>
</mapper>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment