Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
d518c25f
Commit
d518c25f
authored
Jul 12, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拥金功能
parent
eb5aeade
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
18 deletions
+138
-18
AppUserSellingWaterBiz.java
...ub/wxiaoqi/security/admin/biz/AppUserSellingWaterBiz.java
+35
-11
MyWaterBiz.java
...ava/com/github/wxiaoqi/security/admin/biz/MyWaterBiz.java
+51
-7
MyWalletMapper.java
.../github/wxiaoqi/security/admin/mapper/MyWalletMapper.java
+4
-0
MyWaterMapper.xml
...les/ace-admin/src/main/resources/mapper/MyWaterMapper.xml
+48
-0
No files found.
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserSellingWaterBiz.java
View file @
d518c25f
...
@@ -48,7 +48,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper,Ap
...
@@ -48,7 +48,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper,Ap
AppUserDetailBiz
detailBiz
;
AppUserDetailBiz
detailBiz
;
@Autowired
@Autowired
MyWalletDetailMapper
walletDetailMapper
;
MyWaterBiz
myWaterBiz
;
...
@@ -150,24 +150,48 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper,Ap
...
@@ -150,24 +150,48 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper,Ap
}
}
log
.
info
(
"订单完成计算用户拥金----finishOrderWater----orderId===="
+
orderId
+
"---amount=="
+
amount
);
log
.
info
(
"订单完成计算用户拥金----finishOrderWater----orderId===="
+
orderId
+
"---amount=="
+
amount
);
int
r
=
amount
.
compareTo
(
BigDecimal
.
ZERO
);
int
r
=
amount
.
compareTo
(
BigDecimal
.
ZERO
);
//更新钱包
if
(
r
==
1
&&
userId
>
0
){
if
(
r
==
1
&&
userId
>
0
){
MyWalletDetail
walletDetail
=
new
MyWalletDetail
();
myWaterBiz
.
updMyWater
(
userId
,
orderId
,
amount
);
walletDetail
.
setUserId
(
userId
);
walletDetail
.
setSource
(
1
);
walletDetail
.
setCono
(
orderId
);
walletDetail
.
setItype
(
1
);
walletDetail
.
setAmount
(
amount
);
walletDetailMapper
.
insertSelective
(
walletDetail
);
}
}
}
//订单退款计算用户拥金
public
void
refundOrderWater
(
OrderWaterDTO
orderWaterDTO
){
//订单id
Integer
orderId
=
orderWaterDTO
.
getOrderId
();
log
.
info
(
"订单完成计算用户拥金----refundOrderWater----orderId===="
+
orderId
);
if
(
orderId
==
null
||
orderId
==
0
){
return
;
}
List
<
AppUserSellingWater
>
list
=
getWaterList
(
orderId
);
BigDecimal
amount
=
new
BigDecimal
(
"0.00"
);
Integer
userId
=
0
;
if
(
list
.
size
()>
0
){
for
(
AppUserSellingWater
sellingWater:
list
){
Integer
id
=
sellingWater
.
getId
();
userId
=
sellingWater
.
getUserId
();
sellingWater
.
setWaiting
(
1
);
updateById
(
sellingWater
);
sellingWater
.
setId
(
null
);
sellingWater
.
setStatus
(
1
);
insertSelective
(
sellingWater
);
BigDecimal
commission
=
sellingWater
.
getCommission
();
log
.
info
(
"订单完成计算用户拥金----refundOrderWater----id===="
+
id
+
"---commission=="
+
commission
);
}
}
log
.
info
(
"订单完成计算用户拥金----refundOrderWater----orderId===="
+
orderId
+
"---amount=="
+
amount
);
int
r
=
amount
.
compareTo
(
BigDecimal
.
ZERO
);
//更新钱包
if
(
r
==
1
&&
userId
>
0
){
myWaterBiz
.
updMyWater
(
userId
,
orderId
,
amount
);
}
}
}
//获取拥金列表
//获取拥金列表
public
List
<
AppUserSellingWater
>
getWaterList
(
Integer
orderId
){
public
List
<
AppUserSellingWater
>
getWaterList
(
Integer
orderId
){
Example
example
=
new
Example
(
AppUserSellingWater
.
class
);
Example
example
=
new
Example
(
AppUserSellingWater
.
class
);
...
...
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/MyWaterBiz.java
View file @
d518c25f
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
biz
;
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
biz
;
import
cn.hutool.core.date.DateTime
;
import
com.github.wxiaoqi.security.admin.entity.MyWallet
;
import
com.github.wxiaoqi.security.admin.entity.MyWallet
;
import
com.github.wxiaoqi.security.admin.entity.MyWalletDetail
;
import
com.github.wxiaoqi.security.admin.entity.MyWalletDetail
;
import
com.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper
;
import
com.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper
;
...
@@ -10,6 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -10,6 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
/**
* 钱包
* 钱包
...
@@ -27,16 +31,15 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
...
@@ -27,16 +31,15 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
MyWalletDetailMapper
walletDetailMapper
;
MyWalletDetailMapper
walletDetailMapper
;
//
更新我的钱包
//
我的钱包入账
public
void
updMyWater
(
Integer
userId
,
Integer
orderId
,
BigDecimal
amount
){
public
void
updMyWater
(
Integer
userId
,
Integer
orderId
,
BigDecimal
amount
){
log
.
info
(
"---
更新我的钱包
----userId==="
+
userId
+
"----orderId===="
+
orderId
+
"----amount===="
+
amount
);
log
.
info
(
"---
我的钱包入账
----userId==="
+
userId
+
"----orderId===="
+
orderId
+
"----amount===="
+
amount
);
MyWallet
wallet
=
new
MyWallet
();
MyWallet
wallet
=
new
MyWallet
();
wallet
.
setUserId
(
userId
);
wallet
.
setUserId
(
userId
);
wallet
=
selectOne
(
wallet
);
wallet
=
selectOne
(
wallet
);
//进账之前余额
//进账之前余额
BigDecimal
oldBalance
=
new
BigDecimal
(
"0.00"
);
BigDecimal
balance
=
new
BigDecimal
(
"0.00"
);
BigDecimal
balance
=
new
BigDecimal
(
"0.00"
);
//已提现金额
BigDecimal
withdrawals
=
new
BigDecimal
(
"0.00"
);
//进账总额(元)
//进账总额(元)
BigDecimal
totalAmount
=
new
BigDecimal
(
"0.00"
);
BigDecimal
totalAmount
=
new
BigDecimal
(
"0.00"
);
//今日收益
//今日收益
...
@@ -49,19 +52,60 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
...
@@ -49,19 +52,60 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
wallet
.
setUserId
(
userId
);
wallet
.
setUserId
(
userId
);
totalAmount
=
amount
;
totalAmount
=
amount
;
todayAmount
=
amount
;
todayAmount
=
amount
;
balance
=
amount
;
}
else
{
}
else
{
id
=
wallet
.
getId
();
id
=
wallet
.
getId
();
balance
=
wallet
.
getBalance
();
oldBalance
=
wallet
.
getBalance
();
wallet
.
setBalance
(
balance
.
add
(
amount
));
balance
=
wallet
.
getBalance
().
add
(
amount
);
totalAmount
=
wallet
.
getTotalAmount
().
add
(
amount
);
Long
lastTime
=
wallet
.
getLastIntime
();
todayAmount
=
amount
;
if
(
lastTime
!=
null
&&
isToday
(
lastTime
)){
todayAmount
=
wallet
.
getTodayAmount
().
add
(
amount
);
}
unbooked
=
wallet
.
getUnbooked
().
subtract
(
unbooked
);
}
}
log
.
info
(
"---我的钱包入账----userId==="
+
userId
+
"----balance===="
+
balance
+
"----totalAmount===="
+
totalAmount
+
"---todayAmount==="
+
todayAmount
+
"---unbooked=="
+
unbooked
);
MyWalletDetail
walletDetail
=
new
MyWalletDetail
();
MyWalletDetail
walletDetail
=
new
MyWalletDetail
();
walletDetail
.
setUserId
(
userId
);
walletDetail
.
setUserId
(
userId
);
walletDetail
.
setSource
(
1
);
walletDetail
.
setSource
(
1
);
walletDetail
.
setCono
(
orderId
);
walletDetail
.
setCono
(
orderId
);
walletDetail
.
setItype
(
1
);
walletDetail
.
setItype
(
1
);
walletDetail
.
setAmount
(
amount
);
walletDetail
.
setAmount
(
amount
);
walletDetail
.
setBalance
(
b
alance
);
walletDetail
.
setBalance
(
oldB
alance
);
walletDetailMapper
.
insertSelective
(
walletDetail
);
walletDetailMapper
.
insertSelective
(
walletDetail
);
Long
time
=
System
.
currentTimeMillis
();
wallet
.
setBalance
(
balance
);
wallet
.
setTodayAmount
(
todayAmount
);
wallet
.
setTotalAmount
(
totalAmount
);
wallet
.
setUnbooked
(
unbooked
);
wallet
.
setLastIntime
(
time
);
wallet
.
setUpdTime
(
time
);
if
(
id
>
0
){
mapper
.
updMyWater
(
wallet
);
}
else
{
wallet
.
setCrtTime
(
time
);
insertSelective
(
wallet
);
}
log
.
info
(
"---我的钱包入账----userId==="
+
userId
+
"----成功"
);
}
}
// 这个时间戳是不是今天
public
boolean
isToday
(
long
time
)
{
boolean
isToday
=
false
;
Date
date
;
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
date
=
sdf
.
parse
(
sdf
.
format
(
new
Date
()));
if
(
time
<
date
.
getTime
()
&&
time
>
date
.
getTime
())
{
isToday
=
true
;
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
isToday
;
}
}
}
\ No newline at end of file
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/mapper/MyWalletMapper.java
View file @
d518c25f
...
@@ -12,4 +12,8 @@ import tk.mybatis.mapper.common.Mapper;
...
@@ -12,4 +12,8 @@ import tk.mybatis.mapper.common.Mapper;
*/
*/
public
interface
MyWalletMapper
extends
Mapper
<
MyWallet
>
{
public
interface
MyWalletMapper
extends
Mapper
<
MyWallet
>
{
public
void
updMyWater
(
MyWallet
myWallet
);
}
}
ace-modules/ace-admin/src/main/resources/mapper/MyWaterMapper.xml
0 → 100644
View file @
d518c25f
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.github.wxiaoqi.security.admin.mapper.MyWalletMapper"
>
<update
id=
"updMyWater"
parameterType=
"com.github.wxiaoqi.security.admin.entity.MyWallet"
>
update my_wallet
<set>
<if
test=
"userId!=null AND userId>0"
>
user_id=#{userId},
</if>
<if
test=
"balance!=null AND balance>0"
>
balance=#{balance},
</if>
<if
test=
"balance!=null AND balance>0"
>
withdrawals=#{withdrawals},
</if>
<if
test=
"totalAmount!=null AND totalAmount>0"
>
total_amount=#{totalAmount},
</if>
<if
test=
"todayAmount!=null AND todayAmount>0"
>
today_amount=#{todayAmount},
</if>
<if
test=
"unbooked!=null AND unbooked>0"
>
unbooked=#{unbooked},
</if>
<if
test=
"isFrozen!=null"
>
is_frozen=#{isFrozen},
</if>
<if
test=
"lastIntime!=null AND lastIntime>0"
>
last_intime=#{lastIntime},
</if>
<if
test=
"crtTime!=null AND crtTime>0"
>
crt_time=#{crtTime},
</if>
<if
test=
"updTime!=null AND updTime>0"
>
upd_time=#{updTime},
</if>
<if
test=
"version!=null "
>
version=version+1,
</if>
</set>
<where>
id=#{id} and version=#{version}
</where>
</update>
</mapper>
\ No newline at end of file
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