Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bailuntec-cost
Overview
Overview
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
huluobin
bailuntec-cost
Commits
be3599ce
Commit
be3599ce
authored
Nov 09, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
010151a1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
314 additions
and
644 deletions
+314
-644
CostListAddController.java
...t/other/module/cost/controller/CostListAddController.java
+0
-143
CostPlanNewController.java
...odule/cost/controller/costplan/CostPlanNewController.java
+5
-11
CostDomain.java
...main/java/com/blt/other/module/cost/model/CostDomain.java
+37
-69
CostService.java
...n/java/com/blt/other/module/cost/service/CostService.java
+7
-0
AbstractCostService.java
...er/module/cost/service/impl/cost/AbstractCostService.java
+7
-1
Lend2PayCostServiceImpl.java
...odule/cost/service/impl/cost/Lend2PayCostServiceImpl.java
+40
-58
DepartmentCheckState.java
...ule/cost/service/impl/costcheck/DepartmentCheckState.java
+4
-3
FinalCheckState.java
...r/module/cost/service/impl/costcheck/FinalCheckState.java
+1
-2
FinancialCheckState.java
...dule/cost/service/impl/costcheck/FinancialCheckState.java
+1
-2
AbstractCostPlanService.java
...e/cost/service/impl/costplan/AbstractCostPlanService.java
+1
-0
CostPlanNewLend1ServiceImpl.java
...st/service/impl/costplan/CostPlanNewLend1ServiceImpl.java
+6
-6
CostPlanNewLend2ServiceImpl.java
...st/service/impl/costplan/CostPlanNewLend2ServiceImpl.java
+149
-150
CostUtils.java
.../main/java/com/blt/other/module/cost/utils/CostUtils.java
+0
-146
CostPlanDomain.java
...a/com/blt/other/module/database/model/CostPlanDomain.java
+56
-53
No files found.
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/controller/CostListAddController.java
View file @
be3599ce
package
com
.
blt
.
other
.
module
.
cost
.
controller
;
import
com.blt.other.common.util.AxiosUtil
;
import
com.blt.other.common.util.PathUtil
;
import
com.blt.other.module.cost.dao.CostDao
;
import
com.blt.other.module.cost.model.CostDomain
;
import
com.blt.other.module.cost.service.CostService
;
import
com.blt.other.module.cost.service.UserCostFinansysService
;
import
com.blt.other.module.cost.utils.CostFileUtil
;
import
com.blt.other.module.cost.utils.CostUtils
;
import
com.blt.other.module.database.model.UserCostFinansysDomain
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.HashMap
;
import
java.util.Map
;
@Deprecated
@RestController
...
...
@@ -30,129 +12,4 @@ public class CostListAddController {
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
CostListAddController
.
class
);
@Autowired
private
CostService
costService
;
@Autowired
CostDao
costDao
;
@Autowired
private
UserCostFinansysService
userCostFinansysService
;
/**
* 保存费用单(带附件)
*
* @param response
* @param request
* @param file
* @return
*/
@Deprecated
@PostMapping
(
"affirmFile"
)
public
Map
<
String
,
Object
>
affirmFile
(
HttpServletResponse
response
,
HttpServletRequest
request
,
@RequestParam
(
"fileSelect"
)
MultipartFile
file
)
{
AxiosUtil
.
setCors
(
response
,
request
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
String
costNo
=
CostUtils
.
getIdNum
();
CostDomain
costDomainByNo
=
costDao
.
selectByCostNo
(
costNo
);
while
(
null
!=
costDomainByNo
&&
null
!=
costDomainByNo
.
getId
())
{
costNo
=
CostUtils
.
getIdNum
();
}
CostDomain
costDomain
=
CostUtils
.
createCostDomain
(
request
,
costNo
);
// 文件上传的路径
String
filePath
=
PathUtil
.
getBasePath
()
+
PathUtil
.
getPath
(
"cost/"
+
costDomain
.
getCostNo
()
+
"/"
);
// 调用工具类执行保存,并返回 path
String
path
=
CostFileUtil
.
upload
(
file
,
filePath
);
costDomain
.
setFilePath
(
path
);
// 保存表单中的银行卡信息
if
(
hasRecord
(
costDomain
))
{
Integer
finansyRecord
=
doSaveFinansyRecord
(
costDomain
);
}
Integer
integer
=
costService
.
saveNewCost
(
costDomain
);
if
(
null
!=
integer
&&
integer
>=
1
)
{
result
.
put
(
"msg"
,
"费用单已创建"
);
result
.
put
(
"costNo"
,
costDomain
.
getCostNo
());
result
.
put
(
"costDomain"
,
costDomain
);
return
result
;
}
result
.
put
(
"msg"
,
"费用单创建失败"
);
result
.
put
(
"costNo"
,
null
);
return
result
;
}
/**
* 保存费用单(不带附件)
*
* @param response
* @param request
* @return
*/
@PostMapping
(
"affirmNoFile"
)
public
Map
<
String
,
Object
>
affirmNoFile
(
HttpServletResponse
response
,
HttpServletRequest
request
)
{
AxiosUtil
.
setCors
(
response
,
request
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
String
costNo
=
CostUtils
.
getIdNum
();
CostDomain
costDomainByNo
=
costDao
.
selectByCostNo
(
costNo
);
while
(
null
!=
costDomainByNo
&&
null
!=
costDomainByNo
.
getId
())
{
costNo
=
CostUtils
.
getIdNum
();
}
CostDomain
costDomain
=
CostUtils
.
createCostDomain
(
request
,
costNo
);
// 保存表单中的银行卡信息
if
(
hasRecord
(
costDomain
))
{
Integer
finansyRecord
=
doSaveFinansyRecord
(
costDomain
);
}
Integer
integer
=
costService
.
saveNewCost
(
costDomain
);
if
(
null
!=
integer
&&
integer
>=
1
)
{
result
.
put
(
"msg"
,
"费用单已创建"
);
result
.
put
(
"costNo"
,
costDomain
.
getCostNo
());
return
result
;
}
result
.
put
(
"msg"
,
"费用单已创建"
);
result
.
put
(
"costNo"
,
costDomain
.
getCostNo
());
result
.
put
(
"costDomain"
,
costDomain
);
return
result
;
}
/**
* 保存填写的财务信息
*
* @return
*/
private
Integer
doSaveFinansyRecord
(
CostDomain
costDomain
)
{
UserCostFinansysDomain
finansyRecordByCostDomain
=
userCostFinansysService
.
createFinansyRecordByCostDomain
(
costDomain
);
Integer
integer
=
userCostFinansysService
.
saveFinansysRecord
(
finansyRecordByCostDomain
);
return
integer
;
}
/**
* 判断是否需要记录财务信息
*
* @param costDomain
* @return
*/
private
boolean
hasRecord
(
CostDomain
costDomain
)
{
UserCostFinansysDomain
finansyRecordByCostDomain
=
userCostFinansysService
.
createFinansyRecordByCostDomain
(
costDomain
);
UserCostFinansysDomain
byUserCostFinansysDetail
=
userCostFinansysService
.
getByUserCostFinansysDetail
(
finansyRecordByCostDomain
);
if
(
null
!=
byUserCostFinansysDetail
&&
null
!=
byUserCostFinansysDetail
.
getId
())
{
return
false
;
}
else
{
// 判断是否是付款费用或借支单
if
(
1
==
costDomain
.
getCostForm
())
{
return
true
;
}
else
if
(
2
==
costDomain
.
getCostForm
())
{
return
false
;
}
else
{
if
(
1
==
costDomain
.
getIsLend
())
{
return
true
;
}
else
{
return
false
;
}
}
}
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/controller/costplan/CostPlanNewController.java
View file @
be3599ce
...
...
@@ -8,7 +8,6 @@ import com.blt.other.module.database.model.CostPlanDomain;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -46,17 +45,12 @@ public class CostPlanNewController {
@PostMapping
(
"/affirm"
)
public
Map
<
String
,
Object
>
affirm
(
@RequestParam
String
costPlanNo
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
try
{
CostPlanService
costPlanService
=
CostPlanServiceFactory
.
getCostPlanService
(
costPlanNo
);
CostPlanService
costPlanService
=
CostPlanServiceFactory
.
getCostPlanService
(
costPlanNo
);
Integer
affirm
=
costPlanService
.
affirm
(
costPlanNo
);
result
.
put
(
"success"
,
true
);
result
.
put
(
"msg"
,
"已生成 "
+
affirm
+
" 张付款费用单"
);
Integer
affirm
=
costPlanService
.
affirm
(
costPlanNo
);
result
.
put
(
"success"
,
true
);
result
.
put
(
"msg"
,
"已生成 "
+
affirm
+
" 张付款费用单"
);
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
(),
ex
);
result
.
put
(
"success"
,
false
);
result
.
put
(
"msg"
,
"付款计划不存在或发生其他错误"
);
}
return
result
;
}
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/model/CostDomain.java
View file @
be3599ce
...
...
@@ -52,54 +52,41 @@ public class CostDomain implements Serializable {
// 费用单编号
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
// 费用单编号
@ApiModelProperty
(
"费用单编号"
)
private
String
costNo
;
// 费用计划编号
@ApiModelProperty
(
"费用计划编号"
)
private
String
costPlanNo
;
// 主体编号
@ApiModelProperty
(
"主体编号"
)
private
String
companyNo
;
// 主体名称
@ApiModelProperty
(
"主体名称"
)
private
String
companyName
;
// 类型编号
@ApiModelProperty
(
"类型编号"
)
private
String
typeNo
;
// 类型标题
@ApiModelProperty
(
"类型标题"
)
private
String
typeName
;
// 科目编号
@ApiModelProperty
(
"科目编号"
)
private
String
subjectCode
;
// 小类编号
@ApiModelProperty
(
"小类编号"
)
private
String
kindNo
;
// 小类标题
@ApiModelProperty
(
"小类标题"
)
private
String
kindName
;
// 创建人 id
@ApiModelProperty
(
"创建人id"
)
private
Integer
createUserid
;
// 创建人编号
@ApiModelProperty
(
"创建人编号"
)
private
String
createUsercode
;
// 创建人名称
@ApiModelProperty
(
"创建人名称"
)
private
String
createUsername
;
// 费用单备注
@ApiModelProperty
(
"费用单备注"
)
private
String
costRemark
;
@ApiModelProperty
(
"创建时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createTime
;
// 关联子单
@ApiModelProperty
(
"关联子单"
)
@Deprecated
private
String
sonCostNo
;
@ApiModelProperty
(
"关联父单"
)
private
String
supCostNo
;
...
...
@@ -108,114 +95,96 @@ public class CostDomain implements Serializable {
@ApiModelProperty
(
"文件地址"
)
private
String
filePath
;
@ApiModelProperty
(
"补充材料地址"
)
private
String
morFilePath
;
// 费用总金额
@ApiModelProperty
(
"补充信息"
)
private
String
morRemark
;
@ApiModelProperty
(
"费用总金额"
)
private
BigDecimal
amount
;
// 二级物流供应商ID
@ApiModelProperty
(
"二级物流供应商ID"
)
private
Integer
subLogisticsSupplierId
;
// 一级物流供应商ID
@ApiModelProperty
(
"一级物流供应商ID"
)
private
Integer
logisticsSupplierId
;
// 收款银行(平台)
@ApiModelProperty
(
"收款银行(平台)"
)
private
String
bankName
;
// 收款账户
@ApiModelProperty
(
"收款账户"
)
private
String
bankCard
;
// 收款用户名
@ApiModelProperty
(
"收款用户名"
)
private
String
bankCardUser
;
// 收款/付款单位
@ApiModelProperty
(
"收款/付款单位"
)
private
String
bankCompany
;
// 补充信息
@ApiModelProperty
(
"补充信息"
)
private
String
morRemark
;
// 1 付款费用 2 收款费用 3 借支/借还
@ApiModelProperty
(
"1 付款费用 2 收款费用 3 借支/借还"
)
private
Integer
costForm
;
// 付款理由
@ApiModelProperty
(
"付款理由"
)
private
String
costReason
;
// 1 借支 2 借还
@ApiModelProperty
(
"1 借支 2 借还"
)
private
Integer
isLend
;
// 借支单已还金额
@ApiModelProperty
(
"1 未还 2 部分还款 3 待补差额 4 结清"
)
private
Integer
lendStatus
;
@ApiModelProperty
(
"付款理由"
)
private
String
costReason
;
@ApiModelProperty
(
"驳回原因"
)
private
String
rejectReason
;
@ApiModelProperty
(
"借支单已还金额"
)
private
BigDecimal
hadPay
;
// 借支单状态 1 未还 2 部分还款 3 结清
@ApiModelProperty
(
"借支单状态 1 未还 2 部分还款 3 结清"
)
private
Integer
lendStatus
;
// 借支单补偿金额
@ApiModelProperty
(
"借支单补偿金额"
)
private
BigDecimal
compensate
;
// 冲销金额
@ApiModelProperty
(
"冲销金额"
)
@ApiModelProperty
(
"冲销金额 (借支单币种)"
)
private
BigDecimal
counteract
;
// 借还单余额
@ApiModelProperty
(
"借还单余额"
)
@ApiModelProperty
(
"借还单余额 (借支单币种)"
)
private
BigDecimal
lendBalance
;
// 驳回原因
@ApiModelProperty
(
"驳回原因"
)
private
String
rejectReason
;
// 币种
@ApiModelProperty
(
"币种"
)
@ApiModelProperty
(
"对应借支单币种)"
)
private
String
dic
;
// 借还单冲销金额 ( 支付币种 )
@ApiModelProperty
(
"借还单冲销金额 ( 支付币种 )"
)
private
BigDecimal
payCounteract
;
// 借还单余额 ( 支付币种 )
@ApiModelProperty
(
"借还单余额 ( 支付币种 )"
)
private
BigDecimal
payLendBalance
;
// 计划金额 ( 支付币种 )
@ApiModelProperty
(
"计划金额 ( 支付币种 )"
)
private
BigDecimal
payPlanAmount
;
// 支付币种
@ApiModelProperty
(
"支付币种"
)
private
String
payDic
;
// 汇率
@ApiModelProperty
(
"汇率"
)
@ApiModelProperty
(
"借还单 借还支付币种 -> 借支币种汇率"
)
private
BigDecimal
payCur
;
// 0 不抵扣个税 1 抵扣个税
@ApiModelProperty
(
"0 不抵扣个税 1 抵扣个税"
)
private
Integer
isTax
;
// 出纳系统 detailKey
@ApiModelProperty
(
"出纳系统 detailKey"
)
private
String
detailKey
;
// 支付者用户ID
@ApiModelProperty
(
"支付者用户ID"
)
private
Integer
payUserId
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
// 支付时间
@ApiModelProperty
(
"支付时间"
)
private
Date
payTime
;
// 转人民币汇率
@ApiModelProperty
(
"转人民币汇率"
)
private
BigDecimal
toRmbRate
;
// 费用单人民币总金额
@ApiModelProperty
(
"费用单人民币总金额"
)
private
BigDecimal
amountRmb
;
// 公司主体value
@ApiModelProperty
(
"公司主体value"
)
private
Integer
companyValue
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
"财务审核时间"
)
private
Date
auditTime
;
//发票状态
@ApiModelProperty
(
"费用单发票状态编号"
)
private
Integer
hasInvoice
;
//驳回类型
@ApiModelProperty
(
"驳回类型"
)
private
Integer
rejectType
;
//财务驳回时间
@ApiModelProperty
(
"财务驳回时间"
)
private
Date
rejectTime
;
...
...
@@ -225,13 +194,12 @@ public class CostDomain implements Serializable {
@ApiModelProperty
(
""
)
private
String
cashierDownloadPath
;
//
@ApiModelProperty
(
"费用来源 1-默认 2-WMS 3-调拨系统"
)
private
String
sourceFrom
;
//项目
@ApiModelProperty
(
"项目"
)
private
String
projectType
;
//客户编号
@ApiModelProperty
(
"客户编号"
)
private
String
customerNum
;
...
...
@@ -251,8 +219,8 @@ public class CostDomain implements Serializable {
@TableField
(
exist
=
false
)
private
Boolean
canAudit
;
@
TableField
(
exist
=
false
)
private
String
checkUrl
;
@
ApiModelProperty
(
"借支单,还款申请金额,包括已还的和申请中 ,借支单币种。"
)
private
BigDecimal
repaymentAppliedAmount
;
public
CostDto
castToDto
()
{
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/CostService.java
View file @
be3599ce
...
...
@@ -134,4 +134,11 @@ public interface CostService {
* @param cashierCallbackUrlVo req
*/
void
cashierCallback
(
CashierCallbackUrlVo
cashierCallbackUrlVo
);
/**
* 审批拒绝handle
*
* @param costNo costNo
*/
void
reject
(
String
costNo
);
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/cost/AbstractCostService.java
View file @
be3599ce
...
...
@@ -291,6 +291,13 @@ public abstract class AbstractCostService implements CostService {
}
}
@Override
public
void
reject
(
String
costNo
)
{
CostDomain
costDomain
=
costDao
.
selectByCostNo
(
costNo
);
costDomain
.
setCostStatus
(
CostDomain
.
STATUS_REJECT
);
costDao
.
updateById
(
costDomain
);
}
@Resource
CostCashiercallbackService
costCashiercallbackService
;
...
...
@@ -340,7 +347,6 @@ public abstract class AbstractCostService implements CostService {
costDomain
.
setLendStatus
(
1
);
}
}
costDomain
.
setPayUserId
(
costCashiercallbackDomain
.
getPayuserid
());
costDomain
.
setPayTime
(
new
Date
());
costDomain
.
setAmountRmb
(
costCashiercallbackDomain
.
getCashierpaymoneyrmb
());
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/cost/Lend2PayCostServiceImpl.java
View file @
be3599ce
...
...
@@ -78,75 +78,57 @@ public class Lend2PayCostServiceImpl extends AbstractCostService implements Cost
}
@Override
public
void
reject
(
String
costNo
)
{
super
.
reject
(
costNo
);
//释放已申请的金额
CostDomain
costDomain
=
costDao
.
selectByCostNo
(
costNo
);
CostDomain
supCost
=
costDao
.
selectByCostNo
(
costDomain
.
getSupCostNo
());
supCost
.
setRepaymentAppliedAmount
(
supCost
.
getRepaymentAppliedAmount
().
subtract
(
costDomain
.
getAmount
()));
costDao
.
updateById
(
supCost
);
}
@Override
void
cashierCallbackPass
(
CostCashiercallbackDomain
costCashiercallbackDomain
)
{
// 付款成功,更改借还单信息,否则返回失败
CostDomain
costDomainByNo
=
this
.
getCostByCostNo
(
costCashiercallbackDomain
.
getCostNo
());
String
sonNo
=
costDomainByNo
.
getCostNo
().
toUpperCase
();
changeStatus
(
costCashiercallbackDomain
.
getCostNo
(),
4
,
costDomainByNo
.
getLendStatus
(),
costCashiercallbackDomain
.
getPayuserid
());
if
(
sonNo
.
contains
(
"S"
))
{
CostDomain
supCostDomain
=
this
.
getCostByCostNo
(
costDomainByNo
.
getSupCostNo
());
if
(
null
==
supCostDomain
.
getHadPay
())
supCostDomain
.
setHadPay
(
new
BigDecimal
(
0
));
if
(
null
==
supCostDomain
.
getCompensate
())
supCostDomain
.
setCompensate
(
new
BigDecimal
(
0
));
// supCostDomain.setCompensate(supCostDomain.getCompensate().add(costCashiercallbackDomain.getPayamount()));
supCostDomain
.
setCompensate
(
supCostDomain
.
getCompensate
().
subtract
(
costCashiercallbackDomain
.
getPayamount
()));
// supCostDomain.setHadPay(supCostDomain.getHadPay().add(costCashiercallbackDomain.getPayamount()));
// 借还单在出纳完成收付款后,不用直接获取返回的金额(使用费用系统中记录的提交金额,出纳系统结算的实时汇率和费用系统不一定一致)
supCostDomain
.
setHadPay
(
supCostDomain
.
getHadPay
().
add
(
costDomainByNo
.
getAmount
()));
// int i = supCostDomain.getAmount().compareTo(supCostDomain.getHadPay().subtract(supCostDomain.getCompensate()));
BigDecimal
zero
=
new
BigDecimal
(
0
);
if
(
supCostDomain
.
getCompensate
().
compareTo
(
zero
)
==
0
)
{
supCostDomain
.
setLendStatus
(
4
);
// 已补差额,但是仍有金额未到账
BigDecimal
allPayAmount
=
supCostDomain
.
getAmount
().
add
(
costCashiercallbackDomain
.
getPayamount
());
int
i
=
allPayAmount
.
compareTo
(
supCostDomain
.
getHadPay
());
if
(
0
<
i
)
{
supCostDomain
.
setLendStatus
(
2
);
}
}
CostDomain
costDomain
=
this
.
getCostByCostNo
(
costCashiercallbackDomain
.
getCostNo
());
String
sonNo
=
costDomain
.
getCostNo
().
toUpperCase
();
if
(
supCostDomain
.
getCompensate
().
compareTo
(
zero
)
==
1
)
{
supCostDomain
.
setLendStatus
(
3
);
}
this
.
updateCost
(
supCostDomain
);
}
if
(!
sonNo
.
contains
(
"S"
)
&&
null
!=
costDomainByNo
.
getSupCostNo
())
{
CostDomain
supCostDomain
=
this
.
getCostByCostNo
(
costDomainByNo
.
getSupCostNo
());
if
(
null
==
supCostDomain
.
getHadPay
())
{
supCostDomain
.
setHadPay
(
new
BigDecimal
(
0
));
}
// supCostDomain.setHadPay(supCostDomain.getHadPay().add(costCashiercallbackDomain.getCashierpaymoney()));
costDomain
.
setCostStatus
(
CostDomain
.
STATUS_PAYED
);
costDomain
.
setPayUserId
(
costCashiercallbackDomain
.
getPayuserid
());
costDomain
.
setPayTime
(
new
Date
());
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain
.
getDic
(),
"CNY"
);
costDomain
.
setToRmbRate
(
toRmbRate
);
costDomain
.
setAmountRmb
(
costDomain
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
costDomain
.
setAuditTime
(
new
Date
());
costDao
.
updateById
(
costDomain
);
//借还单
if
(!
sonNo
.
contains
(
"S"
))
{
//关联借支单
CostDomain
supCostDomain
=
this
.
getCostByCostNo
(
costDomain
.
getSupCostNo
());
// 借还单在出纳完成收付款后,不用直接获取返回的金额(使用费用系统中记录的提交金额,出纳系统结算的实时汇率和费用系统不一定一致)
supCostDomain
.
setHadPay
(
supCostDomain
.
getHadPay
().
add
(
costDomain
ByNo
.
getAmount
()));
supCostDomain
.
setHadPay
(
supCostDomain
.
getHadPay
().
add
(
costDomain
.
getAmount
()));
if
(
supCostDomain
.
getHadPay
().
compareTo
(
supCostDomain
.
getAmount
())
==
0
)
{
//结清
supCostDomain
.
setLendStatus
(
4
);
}
if
(
supCostDomain
.
getHadPay
().
compareTo
(
supCostDomain
.
getAmount
())
==
-
1
)
{
}
else
if
(
supCostDomain
.
getHadPay
().
compareTo
(
supCostDomain
.
getAmount
())
<
0
)
{
//部分结清
supCostDomain
.
setLendStatus
(
2
);
}
else
if
(
supCostDomain
.
getHadPay
().
compareTo
(
supCostDomain
.
getAmount
())
>
0
)
{
//todo 邮件通知
log
.
error
(
"金额异常 联系管理员,costNo:{}"
,
supCostDomain
.
getCostNo
());
}
if
(
supCostDomain
.
getHadPay
().
compareTo
(
supCostDomain
.
getAmount
())
==
1
)
{
supCostDomain
.
setLendStatus
(
3
);
supCostDomain
.
setCompensate
(
supCostDomain
.
getHadPay
().
subtract
(
supCostDomain
.
getAmount
()));
}
this
.
updateCost
(
supCostDomain
);
costDao
.
updateById
(
supCostDomain
);
}
costLogService
.
save
(
costCashiercallbackDomain
.
getCostNo
(),
costCashiercallbackDomain
.
getPayuserid
(),
"出纳收/付款成功:"
+
costCashiercallbackDomain
.
getPaynote
());
}
private
void
changeStatus
(
String
costNo
,
Integer
costStatus
,
Integer
lendStatus
,
Integer
updateUserId
)
{
costLogService
.
save
(
costDomain
.
getCostNo
(),
costDomain
.
getPayUserId
(),
"出纳收/付款成功:"
+
costCashiercallbackDomain
.
getPaynote
());
Date
now
=
new
Date
();
CostDomain
costDomain
=
this
.
getCostByCostNo
(
costNo
);
costDomain
.
setCostStatus
(
costStatus
);
costDomain
.
setCostNo
(
costNo
);
costDomain
.
setLendStatus
(
lendStatus
);
costDomain
.
setPayUserId
(
updateUserId
);
costDomain
.
setPayTime
(
now
);
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain
.
getDic
(),
"CNY"
);
costDomain
.
setToRmbRate
(
toRmbRate
);
costDomain
.
setAmountRmb
(
costDomain
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
costDomain
.
setAuditTime
(
now
);
this
.
updateCost
(
costDomain
);
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/costcheck/DepartmentCheckState.java
View file @
be3599ce
...
...
@@ -51,7 +51,7 @@ public class DepartmentCheckState extends CostState {
//流转状态
nextState
(
financialCheckState
);
costSubscribe
.
subscribe
(
costContext
);
costLogService
.
saveByManage
(
costDomain
.
getCostNo
(),
"部门审核自动通过"
,
CostLogDomain
.
DEPARTMENT_AUTO_PASS
);
costLogService
.
saveByManage
(
costDomain
.
getCostNo
(),
"部门审核自动通过"
,
CostLogDomain
.
DEPARTMENT_AUTO_PASS
);
return
;
}
...
...
@@ -110,10 +110,11 @@ public class DepartmentCheckState extends CostState {
throw
new
BizRuntimeException
(
"current user no authority"
);
}
costDomain
.
setCostStatus
(
CostDomain
.
STATUS_REJECT
);
costDao
.
updateById
(
costDomain
);
costLogService
.
save
(
costDomain
.
getCostNo
(),
currentUserId
,
"部门审核拒绝,理由:"
+
rejectReason
,
CostLogDomain
.
TYPE_UPDATE
);
//sd
costContext
.
costService
.
reject
(
costDomain
.
getCostNo
());
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/costcheck/FinalCheckState.java
View file @
be3599ce
...
...
@@ -122,8 +122,7 @@ public class FinalCheckState extends CostState {
throw
new
BizRuntimeException
(
"current user no authority"
);
}
costDomain
.
setCostStatus
(
CostDomain
.
STATUS_REJECT
);
costDao
.
updateById
(
costDomain
);
costContext
.
costService
.
resetCost
(
costDomain
.
getCostNo
());
costLogService
.
save
(
costDomain
.
getCostNo
(),
currentUserId
,
"最终审核拒绝,理由:"
+
rejectReason
,
CostLogDomain
.
TYPE_UPDATE
);
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/costcheck/FinancialCheckState.java
View file @
be3599ce
...
...
@@ -99,8 +99,7 @@ public class FinancialCheckState extends CostState {
throw
new
BizRuntimeException
(
"current user no authority"
);
}
costDomain
.
setCostStatus
(
CostDomain
.
STATUS_REJECT
);
costDao
.
updateById
(
costDomain
);
costContext
.
costService
.
resetCost
(
costDomain
.
getCostNo
());
costLogService
.
save
(
costDomain
.
getCostNo
(),
currentUserId
,
"财务审核拒绝,理由:"
+
rejectReason
,
CostLogDomain
.
TYPE_UPDATE
);
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/costplan/AbstractCostPlanService.java
View file @
be3599ce
...
...
@@ -96,6 +96,7 @@ public abstract class AbstractCostPlanService implements CostPlanService {
costPlanDomain
.
setCreateUserid
(
user
.
getUserid
());
costPlanDomain
.
setCreateUsername
(
user
.
getUsername
());
costPlanDomain
.
setCreateTime
(
new
Date
());
//借还单 借还币种 -> 借支币种汇率
costPlanDomain
.
setPayCur
(
costPlanDomain
.
getCur
());
}
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/costplan/CostPlanNewLend1ServiceImpl.java
View file @
be3599ce
...
...
@@ -73,18 +73,18 @@ public class CostPlanNewLend1ServiceImpl extends AbstractCostPlanService impleme
CostDomain
costDomain
=
planToCost
(
costPlanDomain
.
getCostPlanNo
());
String
costNo
=
getCostNo
();
costDomain
.
setCompensate
(
BigDecimal
.
ZERO
);
costDomain
.
setRepaymentAppliedAmount
(
BigDecimal
.
ZERO
);
costDomain
.
setCostNo
(
costNo
);
costDomain
.
setCostStatus
(
0
);
costDomain
.
setAmount
(
costPlanDomain
.
getPlanAmount
());
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain
.
getDic
(),
"CNY"
);
costDomain
.
setToRmbRate
(
toRmbRate
);
costDomain
.
setAmountRmb
(
costDomain
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
Integer
insert
=
costDao
.
insert
(
costDomain
);
if
(
null
==
insert
||
insert
<=
0
)
{
return
0
;
}
costLogService
.
save
(
costDomain
.
getCostNo
(),
costDomain
.
getCreateUserid
(),
"由费用计划:"
+
costDomain
.
getCostPlanNo
()
+
" 生成借支单"
);
int
insert
=
costDao
.
insert
(
costDomain
);
costLogService
.
save
(
costDomain
.
getCostNo
(),
costDomain
.
getCreateUserid
(),
"由费用计划:"
+
costDomain
.
getCostPlanNo
()
+
" 生成借支单"
);
return
insert
;
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/costplan/CostPlanNewLend2ServiceImpl.java
View file @
be3599ce
...
...
@@ -62,182 +62,181 @@ public class CostPlanNewLend2ServiceImpl extends AbstractCostPlanService impleme
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Integer
affirm
(
String
costPlanNo
)
{
CostPlanDomain
costPlanDomain
=
costPlanDao
.
selectByNo
(
costPlanNo
);
if
(
costPlanDomain
.
getCostPlanStatus
()
!=
0
)
{
throw
new
BizRuntimeException
(
"只能更新待确认的计划单"
);
}
affirmCounteract
(
costPlanNo
);
affirmLendBalance
(
costPlanNo
);
return
1
;
}
private
void
affirmCounteract
(
String
costPlanNo
)
{
CostPlanDomain
costPlanDomain
=
costPlanDao
.
selectByNo
(
costPlanNo
);
//已确认
costPlanDomain
.
setCostPlanStatus
(
1
);
costPlanDao
.
update
(
costPlanDomain
,
new
LambdaQueryWrapper
<
CostPlanDomain
>()
.
eq
(
CostPlanDomain:
:
getCostPlanNo
,
costPlanDomain
.
getCostPlanNo
()));
costPlanDao
.
updateById
(
costPlanDomain
);
// 借还单确认时,根据借支单金额、冲销金额、余额拆单
//关联的借支单
CostDomain
supCost
=
costDao
.
selectByCostNo
(
costPlanDomain
.
getSupCostNo
());
//借支还需要还的金额 (借支单币种) = 借支单金额 - 借支单已还金额
BigDecimal
subtract
=
supCost
.
getAmount
().
subtract
(
supCost
.
getRepaymentAppliedAmount
());
if
(
subtract
.
compareTo
(
BigDecimal
.
ZERO
)
<=
0
)
{
throw
new
BizRuntimeException
(
"待归还金额 = 0 无需再冲销"
);
}
//借支还需要还的金额 = 借支单金额 - 借支单已还金额
BigDecimal
subtract
=
supCost
.
getAmount
().
subtract
(
supCost
.
getHadPay
());
//借还单冲销金额
//借还单冲销金额 (借支单币种)
BigDecimal
counteract
=
costPlanDomain
.
getCounteract
();
//借还单余额
BigDecimal
lendBalance
=
costPlanDomain
.
getLendBalance
();
int
result
=
0
;
// 1、冲销金额等于 0,借还单余额大于0 : 生成一张收款的借还单。
if
(
counteract
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
&&
lendBalance
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
if
(
counteract
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
return
;
}
// 2.1、冲销刚好抵消差额 / 冲销小于差额 ===== 生成一张无需付款的借还单
if
(
counteract
.
compareTo
(
subtract
)
<=
0
)
{
CostDomain
costDomain
=
planToCost
(
costPlanDomain
.
getCostPlanNo
());
costDomain
.
setCostNo
(
getCostNo
());
//待提交
costDomain
.
setCostStatus
(
0
);
costDomain
.
setAmount
(
costPlanDomain
.
getPlanAmount
());
//费用单金额
costDomain
.
setAmount
(
counteract
);
//关联借支单币种 ->人民币 汇率
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain
.
getDic
(),
"CNY"
);
costDomain
.
setToRmbRate
(
toRmbRate
);
costDomain
.
setAmountRmb
(
costDomain
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
costDao
.
insert
(
costDomain
);
log
.
info
(
"1、冲销 0,还大于0 ==== 生成一张收款的借还单: "
+
costDomain
);
//更新借支单申请归还金额
supCost
.
setRepaymentAppliedAmount
(
supCost
.
getRepaymentAppliedAmount
().
add
(
counteract
));
costDao
.
updateById
(
supCost
);
log
.
info
(
"冲销刚好抵消差额 / 冲销小于差额 ===== 生成一张无需付款的借还单:"
+
costDomain
);
// 记录日志
costLogService
.
save
(
costDomain
.
getCostNo
(),
costDomain
.
getCreateUserid
(),
"由费用计划:"
+
costDomain
.
getCostPlanNo
()
+
" 生成收款借还单"
);
result
=
result
+
1
;
costLogService
.
save
(
costDomain
.
getCostNo
(),
costDomain
.
getCreateUserid
(),
"由费用计划:"
+
costDomain
.
getCostPlanNo
()
+
" 生成冲销单"
);
}
// 冲销大于差额 ===== 生成一张无需收款的借还单 + 一张付款单(出纳回调接口和财务审核接口改为借还出纳回调接口,费用单号以 “S” 打头)
else
{
log
.
info
(
"冲销大于差额 ===== 准备生成一张无需收款的借还单 + 一张付款单(出纳回调接口和财务审核接口改为借还出纳回调接口,费用单号以 “S” 打头)"
);
CostDomain
costDomain
=
planToCost
(
costPlanDomain
.
getCostPlanNo
());
costDomain
.
setCostNo
(
getCostNo
());
costDomain
.
setCostStatus
(
0
);
costDomain
.
setAmount
(
subtract
);
costDomain
.
setCounteract
(
subtract
);
//计算支付币种的金额
costDomain
.
setPayPlanAmount
(
subtract
.
divide
(
costPlanDomain
.
getPayCur
(),
4
));
costDomain
.
setPayCounteract
(
subtract
.
divide
(
costPlanDomain
.
getPayCur
(),
4
));
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain
.
getDic
(),
"CNY"
);
costDomain
.
setToRmbRate
(
toRmbRate
);
costDomain
.
setAmountRmb
(
costDomain
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
costDao
.
insert
(
costDomain
);
//更新借支单申请归还金额
supCost
.
setRepaymentAppliedAmount
(
supCost
.
getRepaymentAppliedAmount
().
add
(
costDomain
.
getCounteract
()));
costDao
.
updateById
(
supCost
);
log
.
info
(
"生成一张无需收款的借还单:"
+
costDomain
);
// 记录日志
costLogService
.
save
(
costDomain
.
getCostNo
(),
costDomain
.
getCreateUserid
(),
"由费用计划:"
+
costDomain
.
getCostPlanNo
()
+
" 生成冲销单"
);
/*
* 改为生成一张待提交的付款计划 且必须选择付款子项后才能确认(前端判断costTemps,后端判断是否有子项目)
* 差额计划单生成付款费用单时,费用单号保留 S 打头
* 差额计划单的总额、创建一个空的子项目,但是不选类型
* 前端 costForm = 1 isLend = 2 时,不可以删除自动生成的空的子项目,只能修改(后端删除子项目的环节同样需要判断)
*/
CostPlanDomain
payPlan
=
new
CostPlanDomain
();
BeanUtils
.
copyProperties
(
costPlanDomain
,
payPlan
);
//付款金额 (关联借支单币种)
BigDecimal
compensate
=
costPlanDomain
.
getCounteract
().
subtract
(
subtract
);
payPlan
.
setCostPlanNo
(
"S"
+
createNo
());
payPlan
.
setCostPlanStatus
(
0
);
//付款单
payPlan
.
setCostForm
(
1
);
//借还
payPlan
.
setIsLend
(
2
);
//计划金额(关联借支单金额)
payPlan
.
setPlanAmount
(
compensate
);
//付款金额(支付币种)
payPlan
.
setPayPlanAmount
(
compensate
.
divide
(
costPlanDomain
.
getPayCur
(),
4
));
payPlan
.
setCounteract
(
BigDecimal
.
ZERO
);
payPlan
.
setPayCounteract
(
BigDecimal
.
ZERO
);
payPlan
.
setIsTax
(
0
);
payPlan
.
setTypeNo
(
null
);
payPlan
.
setTypeName
(
null
);
payPlan
.
setKindName
(
null
);
payPlan
.
setKindNo
(
null
);
payPlan
.
setCostReason
(
"借支差额:"
+
payPlan
.
getSupCostNo
());
costPlanDao
.
insert
(
payPlan
);
log
.
info
(
"生成一张补差额的付款单计划:"
+
payPlan
);
// 生成空子类的子项目
CostPlanTempDomain
temp
=
new
CostPlanTempDomain
();
temp
.
setTempNo
(
costPlanTempService
.
createNo
());
temp
.
setCostPlanNo
(
payPlan
.
getCostPlanNo
());
temp
.
setCostReason
(
"借支差额:"
+
payPlan
.
getSupCostNo
());
temp
.
setAmount
(
payPlan
.
getPlanAmount
());
temp
.
setDic
(
payPlan
.
getDic
());
costPlanTempDao
.
insert
(
temp
);
log
.
info
(
"生成差额单子项目 "
+
temp
);
//更新借支单归还金额
supCost
.
setCompensate
(
supCost
.
getCompensate
().
add
(
payPlan
.
getPlanAmount
()));
costDao
.
updateById
(
supCost
);
}
// 2、冲销金额大于 0,借还单余额等于 0
else
if
(
counteract
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
&&
lendBalance
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
// 2.1、冲销刚好抵消差额 / 冲销小于差额 ===== 生成一张无需付款的借还单
if
(
counteract
.
compareTo
(
subtract
)
<=
0
)
{
CostDomain
costDomain
=
planToCost
(
costPlanDomain
.
getCostPlanNo
());
costDomain
.
setCostNo
(
getCostNo
());
costDomain
.
setCostStatus
(
0
);
costDomain
.
setAmount
(
costPlanDomain
.
getPlanAmount
());
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain
.
getDic
(),
"CNY"
);
costDomain
.
setToRmbRate
(
toRmbRate
);
costDomain
.
setAmountRmb
(
costDomain
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
int
insert
=
costDao
.
insert
(
costDomain
);
if
(
insert
==
1
)
{
log
.
info
(
"2.1、冲销刚好抵消差额 / 冲销小于差额 ===== 生成一张无需付款的借还单:"
+
costDomain
);
// 记录日志
costLogService
.
save
(
costDomain
.
getCostNo
(),
costDomain
.
getCreateUserid
(),
"由费用计划:"
+
costDomain
.
getCostPlanNo
()
+
" 生成冲销单"
);
result
=
1
;
}
else
{
log
.
info
(
"2.1、冲销刚好抵消差额 / 冲销小于差额 ===== 生成一张无需付款的借还单失败:"
+
costDomain
);
}
}
// 2.2、冲销大于差额 ===== 生成一张无需收款的借还单 + 一张付款单(出纳回调接口和财务审核接口改为借还出纳回调接口,费用单号以 “S” 打头)
else
{
log
.
info
(
"2.2、冲销大于差额 ===== 准备生成一张无需收款的借还单 + 一张付款单(出纳回调接口和财务审核接口改为借还出纳回调接口,费用单号以 “S” 打头)"
);
CostDomain
costDomain1
=
planToCost
(
costPlanDomain
.
getCostPlanNo
());
costDomain1
.
setCostNo
(
getCostNo
());
costDomain1
.
setCostStatus
(
0
);
costDomain1
.
setAmount
(
subtract
);
costDomain1
.
setCounteract
(
subtract
);
costDomain1
.
setPayPlanAmount
(
subtract
.
divide
(
costPlanDomain
.
getPayCur
(),
4
));
costDomain1
.
setPayCounteract
(
subtract
.
divide
(
costPlanDomain
.
getPayCur
(),
4
));
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain1
.
getDic
(),
"CNY"
);
costDomain1
.
setToRmbRate
(
toRmbRate
);
costDomain1
.
setAmountRmb
(
costDomain1
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
int
insert1
=
costDao
.
insert
(
costDomain1
);
log
.
info
(
"生成一张无需收款的借还单:"
+
costDomain1
);
// 记录日志
costLogService
.
save
(
costDomain1
.
getCostNo
(),
costDomain1
.
getCreateUserid
(),
"由费用计划:"
+
costDomain1
.
getCostPlanNo
()
+
" 生成冲销单"
);
result
=
result
+
insert1
;
/*
* 改为生成一张待提交的付款计划 且必须选择付款子项后才能确认(前端判断costTemps,后端判断是否有子项目)
* 差额计划单生成付款费用单时,费用单号保留 S 打头
* 差额计划单的总额、创建一个空的子项目,但是不选类型
* 前端 costForm = 1 isLend = 2 时,不可以删除自动生成的空的子项目,只能修改(后端删除子项目的环节同样需要判断)
*/
CostPlanDomain
payPlan
=
new
CostPlanDomain
();
BeanUtils
.
copyProperties
(
costPlanDomain
,
payPlan
);
//付款金额
BigDecimal
compensate
=
costPlanDomain
.
getCounteract
().
subtract
(
subtract
);
payPlan
.
setCostPlanNo
(
"S"
+
createNo
());
payPlan
.
setCostPlanStatus
(
0
);
//付款单
payPlan
.
setCostForm
(
1
);
payPlan
.
setIsLend
(
2
);
payPlan
.
setPlanAmount
(
compensate
);
payPlan
.
setPayPlanAmount
(
compensate
.
divide
(
costPlanDomain
.
getPayCur
(),
4
));
payPlan
.
setCounteract
(
new
BigDecimal
(
0
));
payPlan
.
setPayCounteract
(
new
BigDecimal
(
0
));
payPlan
.
setIsTax
(
0
);
payPlan
.
setTypeNo
(
null
);
payPlan
.
setTypeName
(
null
);
payPlan
.
setKindName
(
null
);
payPlan
.
setKindNo
(
null
);
payPlan
.
setCostReason
(
"借支差额:"
+
payPlan
.
getSupCostNo
());
int
insert2
=
costPlanDao
.
insert
(
payPlan
);
if
(
insert2
==
1
)
{
log
.
info
(
"生成一张补差额的付款单计划:"
+
payPlan
);
// 生成空子类的子项目
CostPlanTempDomain
temp
=
new
CostPlanTempDomain
();
temp
.
setTempNo
(
costPlanTempService
.
createNo
());
temp
.
setCostPlanNo
(
payPlan
.
getCostPlanNo
());
temp
.
setCostReason
(
"借支差额:"
+
payPlan
.
getSupCostNo
());
temp
.
setAmount
(
payPlan
.
getPlanAmount
());
temp
.
setDic
(
payPlan
.
getDic
());
Integer
insert
=
costPlanTempDao
.
insert
(
temp
);
if
(
null
!=
insert
&&
insert
==
1
)
{
log
.
info
(
"生成差额单子项目 "
+
temp
);
}
// 借支单的补差额添加金额
if
(
null
==
supCost
.
getCompensate
())
{
supCost
.
setCompensate
(
new
BigDecimal
(
0
));
}
supCost
.
setCompensate
(
supCost
.
getCompensate
().
add
(
payPlan
.
getPlanAmount
()));
costDao
.
update
(
supCost
,
new
LambdaQueryWrapper
<
CostDomain
>()
.
eq
(
CostDomain:
:
getCostNo
,
supCost
.
getCostNo
()));
}
else
{
log
.
info
(
"生成一张补差额的付款单失败:"
+
costDomain1
);
}
}
}
/**
* 确认归还余额
*
* @param costPlanNo costPlanNo
*/
private
void
affirmLendBalance
(
String
costPlanNo
)
{
CostPlanDomain
costPlanDomain
=
costPlanDao
.
selectByNo
(
costPlanNo
);
//已确认
costPlanDomain
.
setCostPlanStatus
(
1
);
costPlanDao
.
updateById
(
costPlanDomain
);
//关联的借支单
CostDomain
supCost
=
costDao
.
selectByCostNo
(
costPlanDomain
.
getSupCostNo
());
//借支还需要还的金额 = 借支单金额 - 借支单已还金额
BigDecimal
subtract
=
supCost
.
getAmount
().
subtract
(
supCost
.
getHadPay
());
//借还单余额
BigDecimal
lendBalance
=
costPlanDomain
.
getLendBalance
();
if
(
lendBalance
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
return
;
}
// 3、冲销 大于 0,还 大于0 生成一张无需付款的借还单,一张收款的借还单
else
if
(
counteract
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
&&
lendBalance
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
log
.
info
(
"3、冲销 大于 0,还 大于0 ,准备生成一张无需付款的借还单,一张收款的借还单"
);
CostDomain
costDomain1
=
planToCost
(
costPlanDomain
.
getCostPlanNo
());
costDomain1
.
setCostNo
(
getCostNo
());
costDomain1
.
setCostStatus
(
0
);
costDomain1
.
setAmount
(
costDomain1
.
getCounteract
());
costDomain1
.
setPayPlanAmount
(
costDomain1
.
getPayCounteract
());
costDomain1
.
setLendBalance
(
BigDecimal
.
ZERO
);
costDomain1
.
setPayLendBalance
(
BigDecimal
.
ZERO
);
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain1
.
getDic
(),
"CNY"
);
costDomain1
.
setToRmbRate
(
toRmbRate
);
costDomain1
.
setAmountRmb
(
costDomain1
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
int
insert1
=
costDao
.
insert
(
costDomain1
);
log
.
info
(
"生成一张无需付款的借还单:"
+
costDomain1
);
costLogService
.
save
(
costDomain1
.
getCostNo
(),
costDomain1
.
getCreateUserid
(),
"由费用计划:"
+
costDomain1
.
getCostPlanNo
()
+
" 生成冲销单"
);
result
=
result
+
insert1
;
CostDomain
costDomain2
=
planToCost
(
costPlanDomain
.
getCostPlanNo
());
costDomain2
.
setCostNo
(
getCostNo
());
costDomain2
.
setCostStatus
(
0
);
costDomain2
.
setAmount
(
costDomain2
.
getLendBalance
());
costDomain2
.
setPayPlanAmount
(
costDomain2
.
getPayLendBalance
());
costDomain2
.
setCounteract
(
new
BigDecimal
(
0
));
costDomain2
.
setPayCounteract
(
new
BigDecimal
(
0
));
BigDecimal
toRmbRate1
=
CurUtils
.
getCur
(
costDomain2
.
getDic
(),
"CNY"
);
costDomain2
.
setToRmbRate
(
toRmbRate1
);
costDomain2
.
setAmountRmb
(
costDomain2
.
getAmount
().
multiply
(
toRmbRate1
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
int
insert2
=
costDao
.
insert
(
costDomain2
);
log
.
info
(
"生成一张收款的借还单:"
+
costDomain2
);
costLogService
.
save
(
costDomain2
.
getCostNo
(),
costDomain2
.
getCreateUserid
(),
"由费用计划:"
+
costDomain2
.
getCostPlanNo
()
+
" 生成收款借还单"
);
result
=
result
+
insert2
;
if
(
lendBalance
.
compareTo
(
subtract
)
>
0
)
{
throw
new
BizRuntimeException
(
"冲销后归还金额 > 借支单待归还金额"
);
}
return
result
;
CostDomain
costDomain
=
planToCost
(
costPlanDomain
.
getCostPlanNo
());
costDomain
.
setCostNo
(
getCostNo
());
costDomain
.
setCostStatus
(
0
);
costDomain
.
setAmount
(
lendBalance
);
BigDecimal
toRmbRate
=
CurUtils
.
getCur
(
costDomain
.
getDic
(),
"CNY"
);
costDomain
.
setToRmbRate
(
toRmbRate
);
costDomain
.
setAmountRmb
(
costDomain
.
getAmount
().
multiply
(
toRmbRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
costDao
.
insert
(
costDomain
);
//更新借支单申请归还金额
supCost
.
setRepaymentAppliedAmount
(
supCost
.
getRepaymentAppliedAmount
().
add
(
lendBalance
));
costDao
.
updateById
(
supCost
);
log
.
info
(
"1、冲销 0,还大于0 ==== 生成一张收款的借还单: "
+
costDomain
);
// 记录日志
costLogService
.
save
(
costDomain
.
getCostNo
(),
costDomain
.
getCreateUserid
(),
"由费用计划:"
+
costDomain
.
getCostPlanNo
()
+
" 生成收款借还单"
);
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/utils/CostUtils.java
View file @
be3599ce
...
...
@@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import
com.blt.other.module.cost.dao.CostDao
;
import
com.blt.other.module.cost.model.CostDomain
;
import
javax.servlet.http.HttpServletRequest
;
import
java.math.BigDecimal
;
import
java.text.NumberFormat
;
/**
...
...
@@ -49,148 +47,4 @@ public class CostUtils {
}
return
"F"
+
result
;
}
/**
* 生成 CostDomain 实例
*
* @param request
* @return
*/
@Deprecated
public
static
CostDomain
createCostDomain
(
HttpServletRequest
request
,
String
costNo
)
{
String
companyNo
=
request
.
getParameter
(
"companyNo"
);
String
kindNo
=
request
.
getParameter
(
"kindNo"
);
String
amountRequest
=
request
.
getParameter
(
"amount"
);
BigDecimal
amount
=
null
;
if
(
null
!=
amountRequest
)
{
amount
=
new
BigDecimal
(
amountRequest
);
}
String
costRemark
=
request
.
getParameter
(
"costRemark"
);
String
createUsercode
=
request
.
getParameter
(
"createUsercode"
);
Integer
subLogisticsSupplierId
=
null
;
//二级物流供应商ID,非物流费用单为NULL
String
subLogisticsStr
=
request
.
getParameter
(
"subLogisticsSupplierId"
);
if
(
subLogisticsStr
!=
null
&&
!
""
.
equals
(
subLogisticsStr
)
&&
!
"null"
.
equals
(
subLogisticsStr
))
{
subLogisticsSupplierId
=
Integer
.
valueOf
(
subLogisticsStr
);
}
Integer
logisticsSupplierId
=
null
;
//一级物流供应商ID,非物流费用单为NULL
String
logisticsStr
=
request
.
getParameter
(
"logisticsSupplierId"
);
if
(
logisticsStr
!=
null
&&
!
""
.
equals
(
logisticsStr
)
&&
!
"null"
.
equals
(
logisticsStr
))
{
logisticsSupplierId
=
Integer
.
valueOf
(
logisticsStr
);
}
String
bankName
=
request
.
getParameter
(
"bankName"
);
String
bankCard
=
request
.
getParameter
(
"bankCard"
);
String
bankCardUser
=
request
.
getParameter
(
"bankCardUser"
);
String
bankCompany
=
request
.
getParameter
(
"bankCompany"
);
String
morRemark
=
request
.
getParameter
(
"morRemark"
);
String
costReason
=
request
.
getParameter
(
"costReason"
);
String
isLendStr
=
request
.
getParameter
(
"isLend"
);
String
dic
=
request
.
getParameter
(
"dic"
);
String
detailKey
=
request
.
getParameter
(
"detailKey"
);
Integer
isLend
=
null
;
if
(
null
!=
isLendStr
&&
!
"null"
.
equals
(
isLendStr
))
{
isLend
=
Integer
.
parseInt
(
isLendStr
);
}
String
costFormStr
=
request
.
getParameter
(
"costForm"
);
Integer
costForm
=
null
;
int
isTax
=
0
;
if
(
null
!=
costFormStr
&&
!
"null"
.
equals
(
costFormStr
))
{
costForm
=
Integer
.
parseInt
(
costFormStr
);
if
(
1
==
costForm
)
{
String
isTaxStr
=
request
.
getParameter
(
"isTax"
);
if
(
null
!=
isTaxStr
)
{
isTax
=
Integer
.
parseInt
(
isTaxStr
);
}
}
}
String
projectType
=
request
.
getParameter
(
"projectType"
);
String
customerNum
=
request
.
getParameter
(
"customerNum"
);
// 封装 CostDomain
CostDomain
costDomain
=
new
CostDomain
();
costDomain
.
setCostNo
(
costNo
);
costDomain
.
setDetailKey
(
detailKey
);
costDomain
.
setCompanyNo
(
companyNo
);
costDomain
.
setKindNo
(
kindNo
);
costDomain
.
setAmount
(
amount
);
costDomain
.
setCostRemark
(
costRemark
);
costDomain
.
setCreateUsercode
(
createUsercode
);
costDomain
.
setSubLogisticsSupplierId
(
subLogisticsSupplierId
);
costDomain
.
setLogisticsSupplierId
(
logisticsSupplierId
);
costDomain
.
setBankName
(
bankName
);
costDomain
.
setBankCard
(
bankCard
);
costDomain
.
setBankCardUser
(
bankCardUser
);
costDomain
.
setBankCompany
(
bankCompany
);
costDomain
.
setMorRemark
(
morRemark
);
costDomain
.
setCostForm
(
costForm
);
costDomain
.
setCostReason
(
costReason
);
costDomain
.
setIsLend
(
isLend
);
costDomain
.
setDic
(
dic
);
costDomain
.
setIsTax
(
isTax
);
costDomain
.
setProjectType
(
projectType
);
costDomain
.
setCustomerNum
(
customerNum
);
if
(
null
!=
costForm
&&
3
==
costForm
)
{
if
(
1
==
isLend
)
{
// 借支
costDomain
.
setTypeNo
(
null
);
costDomain
.
setKindNo
(
kindNo
);
String
hadPay
=
request
.
getParameter
(
"hadPay"
);
if
(
null
!=
hadPay
&&
!
"null"
.
equals
(
hadPay
))
{
costDomain
.
setHadPay
(
new
BigDecimal
(
hadPay
));
}
String
lendStatus
=
request
.
getParameter
(
"lendStatus"
);
if
(
null
!=
lendStatus
&&
!
"null"
.
equals
(
lendStatus
))
{
costDomain
.
setLendStatus
(
Integer
.
parseInt
(
lendStatus
));
}
String
compensate
=
request
.
getParameter
(
"compensate"
);
if
(
null
!=
compensate
&&
!
"null"
.
equals
(
compensate
))
{
costDomain
.
setCompensate
(
new
BigDecimal
(
compensate
));
}
String
counteract
=
request
.
getParameter
(
"counteract"
);
if
(
null
!=
counteract
&&
!
"null"
.
equals
(
counteract
))
{
costDomain
.
setCounteract
(
new
BigDecimal
(
counteract
));
}
String
lendBalance
=
request
.
getParameter
(
"lendBalance"
);
if
(
null
!=
lendBalance
&&
!
"null"
.
equals
(
lendBalance
))
{
costDomain
.
setLendBalance
(
new
BigDecimal
(
lendBalance
));
}
}
else
if
(
2
==
isLend
)
{
// 借还
String
supCostNo
=
request
.
getParameter
(
"supCostNo"
);
costDomain
.
setSupCostNo
(
supCostNo
);
costDomain
.
setTypeNo
(
null
);
costDomain
.
setKindNo
(
kindNo
);
String
counteract
=
request
.
getParameter
(
"counteract"
);
if
(
null
!=
counteract
&&
!
"null"
.
equals
(
counteract
))
{
costDomain
.
setCounteract
(
new
BigDecimal
(
counteract
));
}
String
lendBalance
=
request
.
getParameter
(
"lendBalance"
);
if
(
null
!=
lendBalance
&&
!
"null"
.
equals
(
lendBalance
))
{
costDomain
.
setLendBalance
(
new
BigDecimal
(
lendBalance
));
}
String
payDic
=
request
.
getParameter
(
"payDic"
);
if
(
null
!=
lendBalance
&&
!
"null"
.
equals
(
lendBalance
))
{
costDomain
.
setPayDic
(
payDic
);
}
String
payCounteract
=
request
.
getParameter
(
"payCounteract"
);
if
(
null
!=
payCounteract
&&
!
"null"
.
equals
(
payCounteract
))
{
costDomain
.
setPayCounteract
(
new
BigDecimal
(
payCounteract
));
}
String
payLendBalance
=
request
.
getParameter
(
"payLendBalance"
);
if
(
null
!=
payLendBalance
&&
!
"null"
.
equals
(
payLendBalance
))
{
costDomain
.
setPayLendBalance
(
new
BigDecimal
(
payLendBalance
));
}
String
payPlanAmount
=
request
.
getParameter
(
"payPlanAmount"
);
if
(
null
!=
payPlanAmount
&&
!
"null"
.
equals
(
payPlanAmount
))
{
costDomain
.
setPayPlanAmount
(
new
BigDecimal
(
payPlanAmount
));
}
String
cur
=
request
.
getParameter
(
"cur"
);
if
(
null
!=
cur
&&
!
"null"
.
equals
(
cur
))
{
costDomain
.
setPayCur
(
new
BigDecimal
(
cur
));
}
}
}
return
costDomain
;
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/database/model/CostPlanDomain.java
View file @
be3599ce
...
...
@@ -28,10 +28,14 @@ public class CostPlanDomain implements Serializable {
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
// 费用单表 id
@ApiModelProperty
(
"费用计划编号"
)
private
String
costPlanNo
;
// 费用计划编号
@ApiModelProperty
(
"0 不抵扣个税 1 抵扣个税"
)
private
Integer
isTax
;
@ApiModelProperty
(
"公司主体value"
)
private
Integer
companyValue
;
@ApiModelProperty
(
"主体编号"
)
private
String
companyNo
;
// 主体编号
@ApiModelProperty
(
"主体名称"
)
...
...
@@ -47,106 +51,105 @@ public class CostPlanDomain implements Serializable {
private
String
kindName
;
// 种类标题
@ApiModelProperty
(
"创建人id"
)
private
Integer
createUserid
;
// 创建人 id
private
Integer
createUserid
;
@ApiModelProperty
(
"创建人编号"
)
private
String
createUsercode
;
// 创建人编号
private
String
createUsercode
;
@ApiModelProperty
(
"创建人名称"
)
private
String
createUsername
;
// 创建人名称
private
String
createUsername
;
@ApiModelProperty
(
"付款理由"
)
private
String
costReason
;
// 付款理由
private
String
costReason
;
@ApiModelProperty
(
"费用单备注"
)
private
String
costRemark
;
// 费用单备注
private
String
costRemark
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
// 创建时间
private
Date
createTime
;
@ApiModelProperty
(
"关联子单"
)
@Deprecated
private
String
sonCostNo
;
// 关联子单
private
String
sonCostNo
;
@ApiModelProperty
(
"关联父单"
)
private
String
supCostNo
;
// 关联父单
private
String
supCostNo
;
@ApiModelProperty
(
"费用计划状态 0 待确认 1 已确认"
)
private
Integer
costPlanStatus
;
// 费用计划状态 0 待确认 1 已确认
private
Integer
costPlanStatus
;
@ApiModelProperty
(
"文件地址"
)
private
String
filePath
;
// 文件地址
private
String
filePath
;
@ApiModelProperty
(
"补充材料地址"
)
private
String
morFilePath
;
// 补充材料地址
private
String
morFilePath
;
@ApiModelProperty
(
"费用总金额"
)
private
BigDecimal
planAmount
;
// 费用总金额
private
BigDecimal
planAmount
;
@ApiModelProperty
(
"二级物流供应商ID"
)
private
Integer
subLogisticsSupplierId
;
// 二级物流供应商ID
private
Integer
subLogisticsSupplierId
;
@ApiModelProperty
(
"一级物流供应商ID"
)
private
Integer
logisticsSupplierId
;
// 一级物流供应商ID
private
Integer
logisticsSupplierId
;
@ApiModelProperty
(
"收款银行(平台)"
)
private
String
bankName
;
// 收款银行(平台)
private
String
bankName
;
@ApiModelProperty
(
"收款账户"
)
private
String
bankCard
;
// 收款账户
private
String
bankCard
;
@ApiModelProperty
(
"收款用户名"
)
private
String
bankCardUser
;
// 收款用户名
private
String
bankCardUser
;
@ApiModelProperty
(
"收款/付款单位"
)
private
String
bankCompany
;
// 收款/付款单位
private
String
bankCompany
;
@ApiModelProperty
(
"补充信息"
)
private
String
morRemark
;
// 补充信息
private
String
morRemark
;
@ApiModelProperty
(
"1 付款费用 2 收款费用 3 借支/借还"
)
private
Integer
costForm
;
// 1 付款费用 2 收款费用 3 借支/借还
private
Integer
costForm
;
@ApiModelProperty
(
"1 借支 2 借还"
)
private
Integer
isLend
;
// 1 借支 2 借还
private
Integer
isLend
;
@ApiModelProperty
(
"借支单已还金额"
)
private
BigDecimal
hadPay
;
// 借支单已还金额
private
BigDecimal
hadPay
;
@ApiModelProperty
(
"借支单状态 1 未还 2 部分还款 3 结清"
)
private
Integer
lendStatus
;
// 借支单状态 1 未还 2 部分还款 3 结清
@ApiModelProperty
(
"借支单补偿金额"
)
private
BigDecimal
compensate
;
// 借支单补偿金额
@ApiModelProperty
(
"冲销金额"
)
private
BigDecimal
counteract
;
// 冲销金额
@ApiModelProperty
(
"借还单余额"
)
private
BigDecimal
lendBalance
;
// 借还单余额
private
Integer
lendStatus
;
@ApiModelProperty
(
"驳回原因"
)
private
String
rejectReason
;
// 驳回原因
@ApiModelProperty
(
"币种"
)
private
String
dic
;
// 币种
private
String
rejectReason
;
/*借还单参数 start*/
@ApiModelProperty
(
"借支单补偿金额"
)
private
BigDecimal
compensate
;
@ApiModelProperty
(
"借还单冲销金额 (对应借支单币种)"
)
private
BigDecimal
counteract
;
@ApiModelProperty
(
"借还单归还金额 (对应借支单币种)"
)
private
BigDecimal
lendBalance
;
@ApiModelProperty
(
"对应借支单币种"
)
private
String
dic
;
@ApiModelProperty
(
"借还单冲销金额 ( 支付币种 )"
)
private
BigDecimal
payCounteract
;
// 借还单冲销金额 ( 支付币种 )
@ApiModelProperty
(
"借还单
余
额 ( 支付币种 )"
)
private
BigDecimal
payLendBalance
;
// 借还单余额 ( 支付币种 )
private
BigDecimal
payCounteract
;
@ApiModelProperty
(
"借还单
归还金
额 ( 支付币种 )"
)
private
BigDecimal
payLendBalance
;
@ApiModelProperty
(
"计划金额 ( 支付币种 )"
)
private
BigDecimal
payPlanAmount
;
// 计划金额 ( 支付币种 )
private
BigDecimal
payPlanAmount
;
@ApiModelProperty
(
"支付币种"
)
private
String
payDic
;
// 支付币种
@ApiModelProperty
(
"汇率"
)
private
BigDecimal
payCur
;
// 汇率
private
String
payDic
;
@ApiModelProperty
(
"借还单 借还支付币种 -> 借支币种汇率"
)
private
BigDecimal
payCur
;
@TableField
(
exist
=
false
)
@ApiModelProperty
(
"费用计划编汇率号"
)
private
BigDecimal
cur
;
// 汇率
@ApiModelProperty
(
"借还单 借还支付币种 -> 借支币种汇率"
)
private
BigDecimal
cur
;
/*借还单参数 end*/
@ApiModelProperty
(
"0 不抵扣个税 1 抵扣个税"
)
private
Integer
isTax
;
// 0 不抵扣个税 1 抵扣个税
@ApiModelProperty
(
"公司主体value"
)
private
Integer
companyValue
;
// 公司主体value
@TableField
(
value
=
"`attach`"
,
typeHandler
=
JacksonTypeHandler
.
class
)
@ApiModelProperty
(
"附加字段"
)
private
List
<
CostAttach
>
attach
;
@ApiModelProperty
(
"费用模版id"
)
private
Integer
costTemplateId
;
@TableField
(
exist
=
false
)
private
CostTemplate
costTemplate
;
public
CostPlanDto
castToDto
()
{
StatusMapper
statusMapper
=
SpringContextUtil
.
getBean
(
StatusMapper
.
class
);
...
...
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