Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
precision-effect
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
precision-effect
Commits
6a992956
Commit
6a992956
authored
Jun 15, 2023
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资金变动
parent
456c3375
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
241 additions
and
15 deletions
+241
-15
TTradeProjectController.java
...g/web/controller/transaction/TTradeProjectController.java
+10
-0
TTradeProjectMapper.java
...in/java/com/zehong/system/mapper/TTradeProjectMapper.java
+7
-0
ITTradeProjectService.java
...java/com/zehong/system/service/ITTradeProjectService.java
+7
-0
TTradeProjectServiceImpl.java
.../zehong/system/service/impl/TTradeProjectServiceImpl.java
+24
-11
SettlementTrade.java
.../system/service/impl/tradeSettlement/SettlementTrade.java
+158
-0
TTradeProjectMapper.xml
...rc/main/resources/mapper/business/TTradeProjectMapper.xml
+8
-0
tradeProject.js
precision-effect-web/src/api/transaction/tradeProject.js
+9
-0
index.vue
precision-effect-web/src/views/account/index.vue
+3
-2
Approval.vue
precision-effect-web/src/views/trade/components/Approval.vue
+2
-1
OperatorButton.vue
...-effect-web/src/views/trade/components/OperatorButton.vue
+13
-1
No files found.
precision-effect-admin/src/main/java/com/zehong/web/controller/transaction/TTradeProjectController.java
View file @
6a992956
...
...
@@ -101,4 +101,14 @@ public class TTradeProjectController extends BaseController
{
return
toAjax
(
tTradeProjectService
.
deleteTTradeProjectByIds
(
tradeIds
));
}
/**
* 交易结算
* @param tTradeProject
* @return
*/
@PostMapping
(
"/settlementTrade"
)
public
AjaxResult
settlementTrade
(
@RequestBody
TTradeProject
tTradeProject
){
return
toAjax
(
tTradeProjectService
.
settlementTrade
(
tTradeProject
));
}
}
precision-effect-system/src/main/java/com/zehong/system/mapper/TTradeProjectMapper.java
View file @
6a992956
...
...
@@ -58,4 +58,11 @@ public interface TTradeProjectMapper
* @return 结果
*/
public
int
deleteTTradeProjectByIds
(
Long
[]
tradeIds
);
/**
* 获取进货交易尾款
* @param tradeDeptId 进货部门id
* @return
*/
List
<
TTradeProject
>
getTradePendingPaymentInfo
(
Long
tradeDeptId
);
}
precision-effect-system/src/main/java/com/zehong/system/service/ITTradeProjectService.java
View file @
6a992956
...
...
@@ -65,4 +65,11 @@ public interface ITTradeProjectService
* @return 结果
*/
public
int
deleteTTradeProjectById
(
Long
tradeId
);
/**
* 交易结算
* @param tTradeProject
* @return
*/
int
settlementTrade
(
TTradeProject
tTradeProject
);
}
precision-effect-system/src/main/java/com/zehong/system/service/impl/TTradeProjectServiceImpl.java
View file @
6a992956
...
...
@@ -7,14 +7,17 @@ import com.zehong.common.utils.SecurityUtils;
import
com.zehong.system.domain.TTradeProject
;
import
com.zehong.system.mapper.TTradeProjectMapper
;
import
com.zehong.system.service.ITTradeProjectService
;
import
com.zehong.system.service.impl.tradeRoles.
*
;
import
com.zehong.system.service.impl.tradeRoles.
TradeRoles
;
import
com.zehong.system.service.impl.tradeRoles.roles.DeptLeader
;
import
com.zehong.system.service.impl.tradeRoles.roles.DoubleRoles
;
import
com.zehong.system.service.impl.tradeRoles.roles.OtherRoles
;
import
com.zehong.system.service.impl.tradeRoles.roles.Transactor
;
import
com.zehong.system.service.impl.tradeSettlement.SettlementTrade
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -30,6 +33,9 @@ public class TTradeProjectServiceImpl implements ITTradeProjectService
@Autowired
private
TTradeProjectMapper
tTradeProjectMapper
;
@Resource
private
SettlementTrade
settlementTrade
;
/**
* 查询交易项目
*
...
...
@@ -120,18 +126,8 @@ public class TTradeProjectServiceImpl implements ITTradeProjectService
public
int
updateTTradeProject
(
TTradeProject
tTradeProject
)
{
tTradeProject
.
setUpdateTime
(
DateUtils
.
getNowDate
());
//如果卖方部门长审批通过,则需要账户资金划拨
//暂时未判断账户可用金额等信息,仅第一版演示临时用 lizhichao-0612
if
(
"3"
.
equals
(
tTradeProject
.
getTradeStatus
()))
{
tTradeProject
.
setPendingPayment
(
tTradeProject
.
getDealPrice
());
}
return
tTradeProjectMapper
.
updateTTradeProject
(
tTradeProject
);
}
//资金划拨
private
int
cumputeAccount
(
TTradeProject
tTradeProject
){
return
1
;
}
/**
* 批量删除交易项目
*
...
...
@@ -155,4 +151,21 @@ public class TTradeProjectServiceImpl implements ITTradeProjectService
{
return
tTradeProjectMapper
.
deleteTTradeProjectById
(
tradeId
);
}
/**
* 交易结算
* @param tTradeProject
* @return
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
settlementTrade
(
TTradeProject
tTradeProject
){
TTradeProject
tradeInfo
=
tTradeProjectMapper
.
selectTTradeProjectById
(
tTradeProject
.
getTradeId
());
//交易结算
settlementTrade
.
settleAbleAmount
(
tradeInfo
);
tradeInfo
.
setTradeStatus
(
tTradeProject
.
getTradeStatus
());
tradeInfo
.
setApplyDeptManagerId
(
tTradeProject
.
getApplyDeptManagerId
());
return
tTradeProjectMapper
.
updateTTradeProject
(
tradeInfo
);
}
}
precision-effect-system/src/main/java/com/zehong/system/service/impl/tradeSettlement/SettlementTrade.java
0 → 100644
View file @
6a992956
package
com
.
zehong
.
system
.
service
.
impl
.
tradeSettlement
;
import
com.zehong.system.domain.TAccount
;
import
com.zehong.system.domain.TCashOperate
;
import
com.zehong.system.domain.TTradeProject
;
import
com.zehong.system.mapper.TAccountMapper
;
import
com.zehong.system.mapper.TCashOperateMapper
;
import
com.zehong.system.mapper.TTradeProjectMapper
;
import
io.jsonwebtoken.lang.Collections
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author geng
* 交易结算
*/
@Component
public
class
SettlementTrade
{
private
TTradeProject
tradeProject
;
@Resource
private
TAccountMapper
tAccountMapper
;
@Resource
private
TTradeProjectMapper
tTradeProjectMapper
;
@Resource
private
TCashOperateMapper
cashOperateMapper
;
/**
* 可用账户结算
*/
public
void
settleAbleAmount
(
TTradeProject
tradeProject
){
this
.
tradeProject
=
tradeProject
;
//买方结算
settleBuyerAbleAmount
();
//卖方结算
settleSellerAbleAmount
();
}
/**
* 买方结算
*/
private
void
settleBuyerAbleAmount
()
{
TAccount
account
=
getAccountInfo
(
this
.
tradeProject
.
getTradeDeptId
());
//判断买方可用额度是否为0
if
(
account
.
getAbleAmount
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
){
this
.
tradeProject
.
setPendingPayment
(
this
.
tradeProject
.
getDealPrice
());
return
;
}
//买方可用额度为0,计算尾款
BigDecimal
pendingPayment
=
account
.
getAbleAmount
().
compareTo
(
tradeProject
.
getDealPrice
())
==
1
?
new
BigDecimal
(
"0"
)
:
this
.
tradeProject
.
getDealPrice
().
subtract
(
account
.
getAbleAmount
());
this
.
tradeProject
.
setPendingPayment
(
pendingPayment
);
//买方可用额度计算
BigDecimal
payment
=
pendingPayment
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
this
.
tradeProject
.
getDealPrice
().
negate
()
:
account
.
getAbleAmount
().
negate
();
updateAccount
(
account
,
payment
);
}
/**
* 卖方结算
*/
private
void
settleSellerAbleAmount
()
{
TAccount
account
=
getAccountInfo
(
this
.
tradeProject
.
getApplyDeptId
());
//进账
BigDecimal
incomeAmount
=
this
.
tradeProject
.
getDealPrice
().
subtract
(
this
.
tradeProject
.
getPendingPayment
());
//判断是否有进账
if
(
incomeAmount
.
compareTo
(
BigDecimal
.
ZERO
)
==
1
&&
account
.
getAbleAmount
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
){
//结算本部尾款
List
<
TTradeProject
>
pendingPaymentInfo
=
tTradeProjectMapper
.
getTradePendingPaymentInfo
(
this
.
tradeProject
.
getApplyDeptId
());
for
(
TTradeProject
project
:
pendingPaymentInfo
){
if
(
incomeAmount
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
){
return
;
}
BigDecimal
amount
=
updatePendingPayment
(
incomeAmount
,
project
);
//重新计算进账金额
incomeAmount
=
incomeAmount
.
subtract
(
amount
);
}
}
//更新可用额度
updateAccount
(
account
,
incomeAmount
);
}
/**
* 获取账户信息
* @param deptId
* @return
*/
private
TAccount
getAccountInfo
(
Long
deptId
){
TAccount
tAccount
=
new
TAccount
();
tAccount
.
setDeptId
(
deptId
);
List
<
TAccount
>
accounts
=
tAccountMapper
.
selectTAccountList
(
tAccount
);
assert
!
Collections
.
isEmpty
(
accounts
)
:
"部门资金账户不能为空,部门id:"
+
tradeProject
.
getApplyDeptId
();
return
accounts
.
get
(
0
);
}
/**
* 更新账户可用金额
* @param tAccount 账户信息
* @param amount 账户变动金额
*/
private
void
updateAccount
(
TAccount
tAccount
,
BigDecimal
amount
){
if
(
amount
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
return
;
tAccount
.
setAbleAmount
(
tAccount
.
getAbleAmount
().
add
(
amount
));
tAccountMapper
.
updateTAccount
(
tAccount
);
//更新资金变动日志
TCashOperate
operate
=
OperatorParam
(
tAccount
.
getDeptId
(),
amount
,
this
.
tradeProject
.
getReceiptNum
());
operate
.
setOperateType
(
amount
.
compareTo
(
BigDecimal
.
ZERO
)
==
1
?
"1"
:
"2"
);
cashOperateMapper
.
insertTCashOperate
(
operate
);
}
/**
* 更新尾款信息
* @param incomeAmount 进账金额
* @param project 交易项目
*/
private
BigDecimal
updatePendingPayment
(
BigDecimal
incomeAmount
,
TTradeProject
project
){
//资金变动金额
BigDecimal
amount
=
incomeAmount
.
compareTo
(
project
.
getPendingPayment
())
==
1
?
project
.
getPendingPayment
()
:
incomeAmount
;
//尾款
BigDecimal
pendingPayment
=
incomeAmount
.
compareTo
(
project
.
getPendingPayment
())
==
-
1
?
project
.
getPendingPayment
().
subtract
(
incomeAmount
)
:
new
BigDecimal
(
"0"
);
project
.
setPendingPayment
(
pendingPayment
);
tTradeProjectMapper
.
updateTTradeProject
(
project
);
//更新资金变动日志
TCashOperate
operate
=
OperatorParam
(
project
.
getTradeDeptId
(),
amount
,
project
.
getReceiptNum
());
operate
.
setOperateType
(
"3"
);
cashOperateMapper
.
insertTCashOperate
(
operate
);
return
amount
;
}
/**
*
* @param deptId 部门id
* @param amount 变动金额
* @param receiptNum 单据号
* @return
*/
private
TCashOperate
OperatorParam
(
Long
deptId
,
BigDecimal
amount
,
String
receiptNum
){
TCashOperate
operate
=
new
TCashOperate
();
operate
.
setOperateDeptId
(
deptId
);
operate
.
setOperateAmount
(
amount
.
compareTo
(
BigDecimal
.
ZERO
)
==
1
?
amount:
amount
.
abs
());
operate
.
setOperateTime
(
new
Date
());
operate
.
setRelationDoc
(
receiptNum
);
return
operate
;
}
}
precision-effect-system/src/main/resources/mapper/business/TTradeProjectMapper.xml
View file @
6a992956
...
...
@@ -214,4 +214,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{tradeId}
</foreach>
</delete>
<select
id=
"getTradePendingPaymentInfo"
parameterType=
"Long"
resultMap=
"TTradeProjectResult"
>
<include
refid=
"selectTTradeProjectVo"
/>
t_trade_project
WHERE trade_dept_id = #{tradeDeptId}
AND trade_status = '3'
AND pending_payment > 0
</select>
</mapper>
\ No newline at end of file
precision-effect-web/src/api/transaction/tradeProject.js
View file @
6a992956
...
...
@@ -60,3 +60,12 @@ export function exportProject(query) {
params
:
query
})
}
//交易结算
export
function
settlementTrade
(
data
)
{
return
request
({
url
:
'/trade/project/settlementTrade'
,
method
:
'post'
,
data
:
data
})
}
precision-effect-web/src/views/account/index.vue
View file @
6a992956
...
...
@@ -122,8 +122,9 @@
<el-table-column
label=
"操作部门"
align=
"center"
prop=
"operateDeptName"
/>
<el-table-column
label=
"操作类型"
align=
"center"
prop=
"operateType"
>
<
template
slot-scope=
"scope"
>
<span
v-if=
"scope.row.operateType == '1'"
>
借贷
</span>
<span
v-if=
"scope.row.operateType == '2'"
>
借支
</span>
<span
v-if=
"scope.row.operateType == '1'"
>
收入
</span>
<span
v-if=
"scope.row.operateType == '2'"
>
支出
</span>
<span
v-if=
"scope.row.operateType == '3'"
>
尾款扣除
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"金额"
align=
"center"
prop=
"operateAmount"
/>
...
...
precision-effect-web/src/views/trade/components/Approval.vue
View file @
6a992956
...
...
@@ -47,6 +47,7 @@
<
script
>
import
CommonInfo
from
"./CommonInfo"
;
import
{
settlementTrade
}
from
"@/api/transaction/tradeProject.js"
;
export
default
{
name
:
"approval"
,
props
:{
...
...
@@ -79,7 +80,7 @@
return
false
;
},
submitSuggestion
(){
return
{
tradeId
:
this
.
tradeData
.
tradeId
,
tradeStatus
:
this
.
tradeStatus
,
dealPrice
:
this
.
tradeData
.
dealPrice
,
applyDeptManagerId
:
this
.
$store
.
state
.
user
.
userId
};
return
{
tradeId
:
this
.
tradeData
.
tradeId
,
tradeStatus
:
this
.
tradeStatus
,
applyDeptManagerId
:
this
.
$store
.
state
.
user
.
userId
};
}
}
}
...
...
precision-effect-web/src/views/trade/components/OperatorButton.vue
View file @
6a992956
...
...
@@ -12,7 +12,7 @@
</
template
>
<
script
>
import
{
getProject
,
updateProject
}
from
"@/api/transaction/tradeProject.js"
;
import
{
getProject
,
updateProject
,
settlementTrade
}
from
"@/api/transaction/tradeProject.js"
;
import
tradeDetail
from
"./TradeDetail"
;
import
evaluate
from
"./Evaluate"
;
import
confirm
from
"./Confirm"
;
...
...
@@ -75,6 +75,18 @@
if
(
this
.
$refs
.
currentCom
.
checkParam
()){
return
;
}
if
(
this
.
operatorName
==
"approval"
){
settlementTrade
(
this
.
$refs
.
currentCom
.
submitSuggestion
()).
then
(
res
=>
{
if
(
res
.
code
==
200
){
this
.
open
=
false
;
this
.
$emit
(
"getList"
);
this
.
$message
.
success
(
"复核成功!"
);
}
else
{
this
.
$message
.
success
(
"复核失败!"
);
}
})
return
;
}
let
that
=
this
;
updateProject
(
this
.
$refs
.
currentCom
.
submitSuggestion
()).
then
(
res
=>
{
if
(
res
.
code
==
200
){
...
...
Write
Preview
Markdown
is supported
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