Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
peizhen-java
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PeiZhen-Java
peizhen-java
Commits
1e117089
Commit
1e117089
authored
Sep 15, 2023
by
Wangmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改提现
parent
c3d65098
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
5 deletions
+87
-5
pz-merchant/src/main/java/com/pz/merchant/controller/applet/CompanyController.java
+12
-3
pz-system/src/main/java/com/pz/merchant/domain/Employees.java
+1
-1
pz-system/src/main/java/com/pz/merchant/service/ICompanyService.java
+9
-0
pz-system/src/main/java/com/pz/merchant/service/IEmployeesService.java
+10
-0
pz-system/src/main/java/com/pz/merchant/service/impl/CompanyServiceImpl.java
+26
-0
pz-system/src/main/java/com/pz/merchant/service/impl/EmployeesServiceImpl.java
+20
-0
pz-system/src/main/java/com/pz/system/domain/bo/WithdrawDepositBo.java
+9
-1
No files found.
pz-merchant/src/main/java/com/pz/merchant/controller/applet/CompanyController.java
View file @
1e117089
...
...
@@ -14,12 +14,14 @@ import com.pz.merchant.domain.vo.CompanyAppVo;
import
com.pz.merchant.domain.vo.CompanyBalanceVo
;
import
com.pz.merchant.domain.vo.FinanceStatisticVo
;
import
com.pz.merchant.service.ICompanyService
;
import
com.pz.merchant.service.IEmployeesService
;
import
com.pz.system.domain.bo.WithdrawDepositBo
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
/**
* 商户[小程序]
...
...
@@ -34,6 +36,7 @@ import javax.validation.constraints.NotNull;
public
class
CompanyController
extends
BaseController
{
private
final
ICompanyService
companyService
;
private
final
IEmployeesService
employeesService
;
/**
* 修改商户名称/头像
...
...
@@ -88,9 +91,15 @@ public class CompanyController extends BaseController {
* 提现
*/
@PutMapping
(
"/withdraw"
)
public
R
<
Boolean
>
withdrawDeposit
(
@RequestBody
WithdrawDepositBo
bo
)
{
// TODO: 2023/9/14 提现暂时搁置
return
R
.
ok
(
true
);
public
R
<
Boolean
>
withdrawDeposit
(
@RequestBody
@Validated
(
EditGroup
.
class
)
WithdrawDepositBo
bo
)
{
if
(
bo
.
getAmount
().
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
return
R
.
fail
(
"提现金额必须大于0"
);
}
if
(
bo
.
getIsMerchant
())
{
return
R
.
ok
(
companyService
.
withdrawDeposit
(
bo
));
}
else
{
return
R
.
ok
();
}
}
}
pz-system/src/main/java/com/pz/merchant/domain/Employees.java
View file @
1e117089
...
...
@@ -87,7 +87,7 @@ public class Employees extends BaseEntity {
/**
* 冻结余额
*/
private
Lo
ng
freezeBalance
;
private
Stri
ng
freezeBalance
;
/**
* 取消订单次数
*/
...
...
pz-system/src/main/java/com/pz/merchant/service/ICompanyService.java
View file @
1e117089
...
...
@@ -10,6 +10,7 @@ import com.pz.merchant.domain.vo.CompanyAppVo;
import
com.pz.merchant.domain.vo.CompanyBalanceVo
;
import
com.pz.merchant.domain.vo.CompanyVo
;
import
com.pz.merchant.domain.vo.FinanceStatisticVo
;
import
com.pz.system.domain.bo.WithdrawDepositBo
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -85,4 +86,12 @@ public interface ICompanyService {
* @return 商户余额及提现记录
*/
CompanyBalanceVo
queryCompanyBalance
(
CompanyBalanceBo
bo
,
PageQuery
page
);
/**
* 提现
*
* @param bo 提现数据
* @return 操作结果
*/
boolean
withdrawDeposit
(
WithdrawDepositBo
bo
);
}
pz-system/src/main/java/com/pz/merchant/service/IEmployeesService.java
View file @
1e117089
...
...
@@ -12,6 +12,7 @@ import com.pz.common.core.domain.PageQuery;
import
com.pz.merchant.domain.vo.OrderInfoVO
;
import
com.pz.merchant.domain.vo.TodayOrderListVo
;
import
com.pz.system.domain.bo.EmployeesCompanyBo
;
import
com.pz.system.domain.bo.WithdrawDepositBo
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -125,4 +126,13 @@ public interface IEmployeesService {
*/
EmployeesVo
queryByUserId
(
Long
userId
);
/**
* 提现
*
* @param bo 提现数据
* @return 操作结果
*/
boolean
withdrawDeposit
(
WithdrawDepositBo
bo
);
}
pz-system/src/main/java/com/pz/merchant/service/impl/CompanyServiceImpl.java
View file @
1e117089
...
...
@@ -10,6 +10,7 @@ import com.pz.common.core.domain.entity.SysUser;
import
com.pz.common.core.page.TableDataInfo
;
import
com.pz.common.core.domain.PageQuery
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.pz.common.exception.ServiceException
;
import
com.pz.common.utils.StringUtils
;
import
com.pz.merchant.domain.Company
;
import
com.pz.merchant.domain.bo.CompanyBalanceBo
;
...
...
@@ -20,6 +21,7 @@ import com.pz.merchant.mapper.CompanyMapper;
import
com.pz.merchant.service.ICompanyService
;
import
com.pz.merchant.service.ISonOrderService
;
import
com.pz.system.domain.Income
;
import
com.pz.system.domain.bo.WithdrawDepositBo
;
import
com.pz.system.mapper.CityMapper
;
import
com.pz.system.mapper.IncomeMapper
;
import
com.pz.system.mapper.SysUserMapper
;
...
...
@@ -229,4 +231,28 @@ public class CompanyServiceImpl implements ICompanyService {
result
.
setIncomes
(
incomePage
.
getRecords
());
return
result
;
}
/**
* 商户提现
*
* @param bo 提现数据
* @return 提现结果
*/
@Override
public
boolean
withdrawDeposit
(
WithdrawDepositBo
bo
)
{
Company
company
=
baseMapper
.
selectById
(
bo
.
getId
());
Objects
.
requireNonNull
(
company
,
"未检查到账户"
);
BigDecimal
money
=
new
BigDecimal
(
Optional
.
ofNullable
(
company
.
getBalance
()).
orElse
(
"0"
));
BigDecimal
balance
=
money
.
subtract
(
bo
.
getAmount
());
if
(
balance
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
throw
new
ServiceException
(
"可用余额不足"
);
}
BigDecimal
freeze
=
new
BigDecimal
(
Optional
.
ofNullable
(
company
.
getFreezeBalance
()).
orElse
(
"0"
));
freeze
=
freeze
.
add
(
bo
.
getAmount
());
LambdaUpdateWrapper
<
Company
>
wrapper
=
Wrappers
.
lambdaUpdate
();
wrapper
.
set
(
Company:
:
getBalance
,
balance
)
.
set
(
Company:
:
getFreezeBalance
,
freeze
)
.
eq
(
Company:
:
getId
,
company
.
getId
());
return
baseMapper
.
update
(
null
,
wrapper
)
>
0
;
}
}
pz-system/src/main/java/com/pz/merchant/service/impl/EmployeesServiceImpl.java
View file @
1e117089
...
...
@@ -23,6 +23,7 @@ import com.pz.merchant.service.ISonOrderService;
import
com.pz.system.domain.Business
;
import
com.pz.system.domain.TotalOrder
;
import
com.pz.system.domain.bo.EmployeesCompanyBo
;
import
com.pz.system.domain.bo.WithdrawDepositBo
;
import
com.pz.system.domain.vo.BusinessVo
;
import
com.pz.system.domain.vo.TotalOrderVo
;
import
com.pz.system.mapper.BusinessMapper
;
...
...
@@ -36,6 +37,7 @@ import com.pz.merchant.domain.Employees;
import
com.pz.merchant.mapper.EmployeesMapper
;
import
com.pz.merchant.service.IEmployeesService
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.util.*
;
...
...
@@ -302,6 +304,24 @@ public class EmployeesServiceImpl implements IEmployeesService {
return
baseMapper
.
selectVoOne
(
Wrappers
.<
Employees
>
lambdaQuery
().
eq
(
Employees:
:
getUid
,
userId
));
}
@Override
public
boolean
withdrawDeposit
(
WithdrawDepositBo
bo
)
{
Employees
employees
=
baseMapper
.
selectById
(
bo
.
getId
());
Objects
.
requireNonNull
(
employees
,
"未检查到账户"
);
BigDecimal
money
=
new
BigDecimal
(
Optional
.
ofNullable
(
employees
.
getBalance
()).
orElse
(
"0"
));
BigDecimal
balance
=
money
.
subtract
(
bo
.
getAmount
());
if
(
balance
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
throw
new
ServiceException
(
"可用余额不足"
);
}
BigDecimal
freeze
=
new
BigDecimal
(
Optional
.
ofNullable
(
employees
.
getFreezeBalance
()).
orElse
(
"0"
));
freeze
=
freeze
.
add
(
bo
.
getAmount
());
LambdaUpdateWrapper
<
Employees
>
wrapper
=
Wrappers
.
lambdaUpdate
();
wrapper
.
set
(
Employees:
:
getBalance
,
balance
)
.
set
(
Employees:
:
getFreezeBalance
,
freeze
)
.
eq
(
Employees:
:
getId
,
employees
.
getId
());
return
baseMapper
.
update
(
null
,
wrapper
)
>
0
;
}
/**
* 保存前的数据校验
*/
...
...
pz-system/src/main/java/com/pz/system/domain/bo/WithdrawDepositBo.java
View file @
1e117089
package
com
.
pz
.
system
.
domain
.
bo
;
import
com.pz.common.core.domain.BaseEntity
;
import
com.pz.common.core.validate.EditGroup
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
/**
* <p>created in 2023/9/14 17:41
*
...
...
@@ -17,16 +22,19 @@ public class WithdrawDepositBo extends BaseEntity {
/**
* 唯一标识ID
*/
@NotNull
(
groups
=
EditGroup
.
class
,
message
=
"唯一表示不能为空"
)
private
Integer
id
;
/**
* 是否是商户
*/
@NotNull
(
groups
=
EditGroup
.
class
,
message
=
"身份标识不能为空"
)
private
Boolean
isMerchant
;
/**
* 提现金额
*/
private
Float
amount
;
@Min
(
groups
=
EditGroup
.
class
,
value
=
0
,
message
=
"提现金额必须大于0"
)
private
BigDecimal
amount
;
}
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