Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
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
licc
data-server
Commits
a2da5974
Commit
a2da5974
authored
Feb 23, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传返佣接口实现
parent
525ecf3c
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
167 additions
and
17 deletions
+167
-17
AccountMapper.java
...pper/src/main/java/cn/wisenergy/mapper/AccountMapper.java
+7
-0
RebateMapper.java
...apper/src/main/java/cn/wisenergy/mapper/RebateMapper.java
+7
-0
AccountInfoMapper.xml
...gy-mapper/src/main/resources/mapper/AccountInfoMapper.xml
+10
-0
RebateMapper.xml
wisenergy-mapper/src/main/resources/mapper/RebateMapper.xml
+10
-0
OrderInfo.java
...model/src/main/java/cn/wisenergy/model/app/OrderInfo.java
+1
-1
Rebate.java
...gy-model/src/main/java/cn/wisenergy/model/app/Rebate.java
+2
-1
TradeRecord.java
...del/src/main/java/cn/wisenergy/model/app/TradeRecord.java
+1
-1
AccountService.java
...rc/main/java/cn/wisenergy/service/app/AccountService.java
+7
-5
AccountServiceImpl.java
...ava/cn/wisenergy/service/app/impl/AccountServiceImpl.java
+55
-9
AccountManager.java
...main/java/cn/wisenergy/service/common/AccountManager.java
+67
-0
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/AccountMapper.java
View file @
a2da5974
...
...
@@ -35,4 +35,11 @@ public interface AccountMapper extends BaseMapper<AccountInfo> {
*/
int
delById
(
@Param
(
"id"
)
Integer
id
);
/**
* 通过userId获取账户信息
* @param userId 用户id
* @return 账户信息
*/
AccountInfo
getByUserId
(
@Param
(
"userId"
)
Integer
userId
);
}
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/RebateMapper.java
View file @
a2da5974
...
...
@@ -29,4 +29,11 @@ public interface RebateMapper extends BaseMapper<Rebate> {
*/
int
delById
(
@Param
(
"id"
)
Integer
id
);
/**
* 获取会员等级对应的返佣比例
* @param userLevel 会员等级
* @return 返佣比例
*/
Rebate
getByLevel
(
@Param
(
"userLevel"
)
Integer
userLevel
);
}
wisenergy-mapper/src/main/resources/mapper/AccountInfoMapper.xml
View file @
a2da5974
...
...
@@ -74,4 +74,14 @@
where id = #{id}
</delete>
<select
id=
"getByUserId"
resultType=
"cn.wisenergy.model.app.AccountInfo"
>
select
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
user_id=#{userId}
</where>
</select>
</mapper>
\ No newline at end of file
wisenergy-mapper/src/main/resources/mapper/RebateMapper.xml
View file @
a2da5974
...
...
@@ -67,4 +67,14 @@
where id = #{id}
</delete>
<select
id=
"getByLevel"
resultType=
"cn.wisenergy.model.app.Rebate"
>
select
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
user_level=#{userLevel}
</where>
</select>
</mapper>
wisenergy-model/src/main/java/cn/wisenergy/model/app/OrderInfo.java
View file @
a2da5974
...
...
@@ -109,7 +109,7 @@ public class OrderInfo {
* 返佣状态
*/
@ApiModelProperty
(
name
=
"rebateStatus"
,
value
=
"返佣状态"
)
private
int
rebateStatus
;
private
Integer
rebateStatus
;
/**
* 当月订单处理状态
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/app/Rebate.java
View file @
a2da5974
...
...
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
...
...
@@ -32,7 +33,7 @@ public class Rebate implements Serializable {
* 等级对应的返佣比例
*/
@ApiModelProperty
(
name
=
""
,
value
=
""
)
private
Integer
percent
;
private
BigDecimal
percent
;
/**
* 创建时间
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/app/TradeRecord.java
View file @
a2da5974
...
...
@@ -28,7 +28,7 @@ public class TradeRecord implements Serializable {
* 用户id
*/
@ApiModelProperty
(
name
=
"userId"
,
value
=
"用户id"
)
private
Integer
userId
;
private
String
userId
;
/**
* 交易类型 1:提现 2:订单返佣 3:订单下单 4:月度肥料 5:培育奖 6:工资
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/AccountService.java
View file @
a2da5974
...
...
@@ -2,17 +2,19 @@ package cn.wisenergy.service.app;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.model.app.AccountInfo
;
import
cn.wisenergy.model.app.OrderInfo
;
import
java.util.List
;
/**
* @author 86187
*/
public
interface
AccountService
{
R
<
AccountInfo
>
getById
(
Integer
userId
);
/**
* 返佣统计
* @return
* 订单返佣
* @param list 订单信息
* @return true or false
*/
R
<
Boolean
>
rebateCount
(
);
R
<
Boolean
>
orderRebate
(
List
<
OrderInfo
>
list
);
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
View file @
a2da5974
...
...
@@ -2,14 +2,22 @@ package cn.wisenergy.service.app.impl;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.mapper.AccountMapper
;
import
cn.wisenergy.mapper.RebateMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.AccountInfo
;
import
cn.wisenergy.model.app.OrderInfo
;
import
cn.wisenergy.model.app.Rebate
;
import
cn.wisenergy.model.app.User
;
import
cn.wisenergy.service.app.AccountService
;
import
cn.wisenergy.service.common.AccountManager
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
/**
...
...
@@ -17,17 +25,55 @@ import org.springframework.stereotype.Service;
*/
@Slf4j
@Service
public
class
AccountServiceImpl
extends
ServiceImpl
<
AccountMapper
,
AccountInfo
>
implements
AccountService
{
public
class
AccountServiceImpl
extends
ServiceImpl
<
AccountMapper
,
AccountInfo
>
implements
AccountService
{
@Autowired
private
UsersMapper
usersMapper
;
@Autowired
private
AccountMapper
accountMapper
;
@Autowired
private
RebateMapper
rebateMapper
;
@Autowired
private
AccountManager
accountManager
;
@Override
public
R
<
AccountInfo
>
getById
(
Integer
userId
)
{
return
null
;
public
R
<
Boolean
>
orderRebate
(
List
<
OrderInfo
>
list
)
{
log
.
info
(
"shop-mall[]AccountServiceImpl[]orderRebate[]input.param.list:{}"
,
list
.
size
());
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
R
.
ok
(
0
,
true
);
}
@Override
public
R
<
AccountInfo
>
rebateCount
()
{
log
.
info
(
"shop-mall[]AccountServiceImpl[]rebateCount"
);
return
null
;
//遍历订单,返佣
for
(
OrderInfo
orderInfo
:
list
)
{
//订单状态是未返佣,完成时间小于当前时间
long
successTime
=
orderInfo
.
getSuccessTime
().
getTime
();
long
time
=
System
.
currentTimeMillis
();
if
(
orderInfo
.
getRebateStatus
()
==
0
&&
successTime
<=
time
)
{
//获取用户信息
User
user
=
usersMapper
.
selectById
(
orderInfo
.
getBuyerId
());
if
(
null
==
user
)
{
continue
;
}
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
user
.
getUserId
());
if
(
null
==
accountInfo
)
{
continue
;
}
//获取返佣比例
Rebate
rebate
=
rebateMapper
.
getByLevel
(
user
.
getUserLevel
());
if
(
null
==
rebate
)
{
continue
;
}
//修改订单状态为已返佣,账户可用金额增加
accountManager
.
updateOrderAddMoney
(
orderInfo
,
accountInfo
,
rebate
);
}
}
return
R
.
ok
(
0
,
true
);
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/common/AccountManager.java
0 → 100644
View file @
a2da5974
package
cn
.
wisenergy
.
service
.
common
;
import
cn.wisenergy.mapper.AccountMapper
;
import
cn.wisenergy.mapper.OrderMapper
;
import
cn.wisenergy.mapper.TradeRecordMapper
;
import
cn.wisenergy.model.app.AccountInfo
;
import
cn.wisenergy.model.app.OrderInfo
;
import
cn.wisenergy.model.app.Rebate
;
import
cn.wisenergy.model.app.TradeRecord
;
import
io.undertow.security.idm.Account
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
/**
* @author 86187
* @ Description: 账户管理公共类
* @ Author : 86187
* @ Date : 2021/2/23 10:43
*/
@Component
@Slf4j
public
class
AccountManager
{
@Autowired
private
OrderMapper
orderMapper
;
@Autowired
private
AccountMapper
accountMapper
;
@Autowired
private
TradeRecordMapper
recordMapper
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
updateOrderAddMoney
(
OrderInfo
orderInfo
,
AccountInfo
accountInfo
,
Rebate
rebate
)
{
//1、计算返佣金额
BigDecimal
bigDecimal
=
orderInfo
.
getPayment
().
multiply
(
rebate
.
getPercent
());
BigDecimal
extractMoney
=
accountInfo
.
getExtractMoney
().
add
(
bigDecimal
);
accountInfo
.
setExtractMoney
(
extractMoney
);
//2、修改订单返佣状态:已返佣 1
orderInfo
.
setRebateStatus
(
1
);
int
count
=
orderMapper
.
updateById
(
orderInfo
);
if
(
count
==
0
)
{
return
false
;
}
//3、增加账户可用金额
int
sum
=
accountMapper
.
updateById
(
accountInfo
);
//4、添加交易流水记录
TradeRecord
tradeRecord
=
new
TradeRecord
();
tradeRecord
.
setUserId
(
orderInfo
.
getBuyerId
());
tradeRecord
.
setTradeType
(
2
);
tradeRecord
.
setTradeNo
(
orderInfo
.
getTid
());
int
number
=
recordMapper
.
add
(
tradeRecord
);
if
(
number
==
0
)
{
return
false
;
}
return
true
;
}
}
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