Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gogirl-miniapp-backend
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
gogirl-miniapp-backend
Commits
75f9ae1d
Commit
75f9ae1d
authored
Nov 03, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agent user default value
parent
37ce4302
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
2 deletions
+68
-2
AgentUserServiceImpl.java
.../gogirl/application/common/impl/AgentUserServiceImpl.java
+12
-2
AgentUserMapperTest.java
...irl/infrastructure/mapper/common/AgentUserMapperTest.java
+56
-0
No files found.
src/main/java/com/gogirl/application/common/impl/AgentUserServiceImpl.java
View file @
75f9ae1d
...
...
@@ -32,6 +32,7 @@ import java.net.InetAddress;
import
java.net.UnknownHostException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
/**
...
...
@@ -99,20 +100,29 @@ public class AgentUserServiceImpl extends ServiceImpl<AgentUserMapper, AgentUser
AgentUser
agentUser
=
this
.
selectByPhone
(
customer
.
getPhone
());
AgentConfig
agentConfig
=
agentConfigMapper
.
selectOne
(
new
LambdaQueryWrapper
<
AgentConfig
>()
.
eq
(
AgentConfig:
:
getRechargeAmount
,
amount
));
//首次充值
if
(
agentUser
==
null
)
{
agentUser
=
new
AgentUser
();
agentUser
.
setPhone
(
customer
.
getPhone
());
agentUser
.
setName
(
customer
.
getNickname
());
agentUser
.
setNo
(
IdWorker
.
getIdStr
().
substring
(
8
));
//todo
agentUser
.
setLevel
(
agentConfig
.
getId
());
agentUser
.
setDiscount
(
agentConfig
.
getDiscount
());
agentUser
.
setCurrentStartTime
(
LocalDateTime
.
now
());
agentUser
.
setDueDate
(
LocalDateTime
.
now
().
plusYears
(
1
));
agentUser
.
setCreateUser
(
customer
.
getNickname
());
agentUserMapper
.
insert
(
agentUser
);
AgentUserLog
agentUserLog
=
new
AgentUserLog
();
agentUserLog
.
setAgentUserId
(
agentUser
.
getId
());
AgentConfig
agentConfig
=
agentConfigMapper
.
selectOne
(
new
LambdaQueryWrapper
<
AgentConfig
>()
.
eq
(
AgentConfig:
:
getRechargeAmount
,
amount
));
agentUserLog
.
setItem
(
String
.
format
(
" 首次签约,签约时间 %s, 代理级别 %s , 代理折扣 %s "
,
LocalDate
.
now
(),
agentConfig
.
getTitle
(),
agentConfig
.
getDiscount
()));
agentUserLogMapper
.
insert
(
agentUserLog
);
...
...
src/test/java/com/gogirl/infrastructure/mapper/common/AgentUserMapperTest.java
0 → 100644
View file @
75f9ae1d
package
com
.
gogirl
.
infrastructure
.
mapper
.
common
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.gogirl.domain.common.AgentUser
;
import
com.gogirl.domain.user.customer.Customer
;
import
com.gogirl.infrastructure.mapper.user.customer.CustomerMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/11/3 9:38 上午
*/
@ActiveProfiles
(
"pre"
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@Slf4j
public
class
AgentUserMapperTest
{
@Resource
AgentUserMapper
agentUserMapper
;
@Resource
CustomerMapper
customerMapper
;
@Test
public
void
insert
()
{
Customer
customer
=
customerMapper
.
selectByPhone
(
"13272036791"
);
AgentUser
agentUser
=
new
AgentUser
();
agentUser
.
setPhone
(
customer
.
getPhone
());
agentUser
.
setName
(
customer
.
getNickname
());
agentUser
.
setNo
(
IdWorker
.
getIdStr
().
substring
(
8
));
//todo
agentUser
.
setLevel
(
1
);
agentUser
.
setDiscount
(
BigDecimal
.
ONE
);
agentUser
.
setCurrentStartTime
(
LocalDateTime
.
now
());
agentUser
.
setDueDate
(
LocalDateTime
.
now
().
plusYears
(
1
));
agentUser
.
setCreateUser
(
customer
.
getNickname
());
agentUserMapper
.
insert
(
agentUser
);
}
}
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