Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dm_project
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
姚本章
dm_project
Commits
b4522db4
Commit
b4522db4
authored
Dec 12, 2020
by
ysongq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 添加用户
parent
00cdbbef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
70 deletions
+99
-70
DepartmentController.java
...nage/moduls/controller/customer/DepartmentController.java
+5
-3
MallCustomer.java
...c/main/java/com/jz/manage/moduls/entity/MallCustomer.java
+3
-0
DepartmentService.java
.../java/com/jz/manage/moduls/service/DepartmentService.java
+2
-1
DepartmentServiceImpl.java
.../jz/manage/moduls/service/impl/DepartmentServiceImpl.java
+77
-57
MallCustomerDao.xml
...ge/src/main/resources/mapper/customer/MallCustomerDao.xml
+12
-9
No files found.
jz-dm-manage/src/main/java/com/jz/manage/moduls/controller/customer/DepartmentController.java
View file @
b4522db4
...
...
@@ -2,6 +2,7 @@ package com.jz.manage.moduls.controller.customer;
import
com.jz.common.bean.PageInfoResponse
;
import
com.jz.common.constant.Constants
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.manage.moduls.controller.BaseController
;
...
...
@@ -91,10 +92,11 @@ public class DepartmentController extends BaseController {
@ApiModelProperty
(
value
=
"添加用户"
)
public
Result
add
(
@RequestBody
SaveCustomerRequest
saveCustomerRequest
,
HttpServletRequest
req
)
throws
Exception
{
if
(
saveCustomerRequest
!=
null
)
{
departmentService
.
add
(
saveCustomerRequest
);
return
new
Result
<
CompanyDetailsDto
>(
true
,
"添加用户成功!"
,
StatusCode
.
OK
);
Result
result
=
departmentService
.
add
(
saveCustomerRequest
);
result
.
getMessage
();
result
.
getCode
();
return
result
;
}
return
new
Result
<
CompanyDetailsDto
>(
false
,
"添加用户失败!"
,
StatusCode
.
ERROR
);
}
}
\ No newline at end of file
jz-dm-manage/src/main/java/com/jz/manage/moduls/entity/MallCustomer.java
View file @
b4522db4
package
com
.
jz
.
manage
.
moduls
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
...
...
@@ -19,6 +21,7 @@ public class MallCustomer implements Serializable {
/**
* 用户id
*/
@TableId
(
value
=
"customer_id"
,
type
=
IdType
.
AUTO
)
private
Long
customerId
;
/**
* 企业id
...
...
jz-dm-manage/src/main/java/com/jz/manage/moduls/service/DepartmentService.java
View file @
b4522db4
package
com
.
jz
.
manage
.
moduls
.
service
;
import
com.jz.common.bean.PageInfoResponse
;
import
com.jz.common.utils.Result
;
import
com.jz.manage.moduls.controller.customer.bean.dto.CompanyDetailsDto
;
import
com.jz.manage.moduls.controller.customer.bean.dto.EnterpriseAuditDto
;
import
com.jz.manage.moduls.controller.customer.bean.request.EnterpriseAuditRequest
;
...
...
@@ -42,5 +43,5 @@ public interface DepartmentService {
* 添加用户
* @param saveCustomerRequest
*/
void
add
(
SaveCustomerRequest
saveCustomerRequest
);
Result
add
(
SaveCustomerRequest
saveCustomerRequest
);
}
\ No newline at end of file
jz-dm-manage/src/main/java/com/jz/manage/moduls/service/impl/DepartmentServiceImpl.java
View file @
b4522db4
...
...
@@ -9,8 +9,8 @@ import com.jz.common.constant.ResultCode;
import
com.jz.common.exception.ResponseException
;
import
com.jz.common.utils.DateUtils
;
import
com.jz.common.utils.Result
;
import
com.jz.manage.moduls.controller.customer.bean.dto.CompanyDetailsDto
;
import
com.jz.manage.moduls.controller.customer.bean.dto.CustomerDto
;
import
com.jz.manage.moduls.controller.customer.bean.dto.EnterpriseAuditDto
;
import
com.jz.manage.moduls.controller.customer.bean.request.EnterpriseAuditRequest
;
...
...
@@ -146,65 +146,75 @@ public class DepartmentServiceImpl implements DepartmentService {
* @param
*/
@Override
@Transactional
public
void
add
(
SaveCustomerRequest
saveCustomerReq
)
{
@Transactional
()
public
Result
add
(
SaveCustomerRequest
saveCustomerReq
)
{
// 校验信息
userCheck
(
saveCustomerReq
);
Result
s
=
userCheck
(
saveCustomerReq
);
boolean
success
=
s
.
isSuccess
();
if
(!
success
)
{
return
Result
.
error
(
"添加用户失败!"
);
}
// 保存企业信息
saveCompany
(
saveCustomerReq
);
// 保存账号信息
MallCustomer
mallCustomer
=
new
MallCustomer
();
mallCustomer
.
setCustomerAccount
(
saveCustomerReq
.
getCustomerAccount
());
mallCustomer
.
setCustomerPhone
(
saveCustomerReq
.
getCustomerPhone
());
mallCustomer
.
setPassword
(
saveCustomerReq
.
getPassword
());
mallCustomer
.
setCreTime
(
DateUtils
.
getToday
());
mallCustomer
.
setCrePerson
(
"1"
);
mallCustomer
.
setDelFlag
(
"N"
);
mallCustomerDao
.
insert
(
mallCustomer
);
// 如果充值金额不为空
if
(
saveCustomerReq
.
getBalanceMoney
()
!=
null
)
{
// 获取最新的企业id
Long
departmentId
=
saveCustomerReq
.
getDepartmentId
();
// 新增一条企业客户资产
FinanceCustomerAssets
assets
=
new
FinanceCustomerAssets
();
if
(
departmentId
!=
null
)
{
try
{
assets
.
setDepartmentId
(
departmentId
);
assets
.
setUseMoney
(
saveCustomerReq
.
getBalanceMoney
());
assets
.
setTotalMoney
(
saveCustomerReq
.
getBalanceMoney
());
assets
.
setCreTime
(
DateUtils
.
getToday
());
assets
.
setCrePerson
(
String
.
valueOf
(
mallCustomer
.
getCustomerId
()));
int
insert
=
financeCustomerAssetsDao
.
insert
(
assets
);
System
.
out
.
println
(
insert
);
}
catch
(
Exception
e
)
{
throw
ResponseException
.
of
(
ResultCode
.
FAILURE
,
"新增企业资产失败!"
);
Long
departmentId
=
saveCompany
(
saveCustomerReq
);
if
(
departmentId
!=
null
)
{
// 保存账号信息
MallCustomer
mallCustomer
=
new
MallCustomer
();
mallCustomer
.
setDepartmentId
(
departmentId
);
mallCustomer
.
setCustomerAccount
(
saveCustomerReq
.
getCustomerAccount
());
mallCustomer
.
setCustomerPhone
(
saveCustomerReq
.
getCustomerPhone
());
mallCustomer
.
setPassword
(
saveCustomerReq
.
getPassword
());
mallCustomer
.
setCreTime
(
DateUtils
.
getToday
());
mallCustomer
.
setCustomerPoint
(
0L
);
mallCustomer
.
setCrePerson
(
"1"
);
mallCustomer
.
setDelFlag
(
"N"
);
mallCustomerDao
.
insert
(
mallCustomer
);
System
.
out
.
println
(
mallCustomer
.
getCustomerId
());
// 如果充值金额不为空
if
(
saveCustomerReq
.
getBalanceMoney
()
!=
null
)
{
// 新增一条企业客户资产
FinanceCustomerAssets
assets
=
new
FinanceCustomerAssets
();
assets
.
setCrePerson
(
mallCustomer
.
getCustomerId
()
+
""
);
if
(
departmentId
!=
null
)
{
try
{
assets
.
setDepartmentId
(
departmentId
);
assets
.
setUseMoney
(
saveCustomerReq
.
getBalanceMoney
());
assets
.
setTotalMoney
(
saveCustomerReq
.
getBalanceMoney
());
assets
.
setCreTime
(
DateUtils
.
getToday
());
assets
.
setCrePerson
(
mallCustomer
.
getCustomerId
()
+
""
);
assets
.
setDelFlag
(
"N"
);
financeCustomerAssetsDao
.
insert
(
assets
);
}
catch
(
Exception
e
)
{
throw
ResponseException
.
of
(
ResultCode
.
FAILURE
,
"新增企业资产失败!"
);
}
}
}
// 新增一条充值记录表
// 获取最新的资产id
Long
assetsId
=
assets
.
getAssetsId
();
FinanceCustomerBalance
balance
=
new
FinanceCustomerBalance
();
if
(
assetsId
!=
null
)
{
try
{
balance
.
setAssetsId
(
assetsId
);
balance
.
setBalanceMoney
(
saveCustomerReq
.
getBalanceMoney
());
balance
.
setCrePerson
(
String
.
valueOf
(
mallCustomer
.
getCustomerId
()));
balance
.
setCreTime
(
DateUtils
.
getToday
());
balance
.
setAuditStatus
(
"02"
);
financeCustomerBalanceDao
.
insert
(
balance
);
}
catch
(
Exception
e
)
{
throw
ResponseException
.
of
(
ResultCode
.
FAILURE
,
"新增充值记录失败!"
);
// 新增一条充值记录表
// 获取最新的资产id
Long
assetsId
=
assets
.
getAssetsId
();
FinanceCustomerBalance
balance
=
new
FinanceCustomerBalance
();
if
(
assetsId
!=
null
)
{
try
{
balance
.
setAssetsId
(
assetsId
);
balance
.
setBalanceMoney
(
saveCustomerReq
.
getBalanceMoney
());
balance
.
setCrePerson
(
mallCustomer
.
getCustomerId
()
+
""
);
balance
.
setCreTime
(
DateUtils
.
getToday
());
balance
.
setAuditStatus
(
"02"
);
balance
.
setDelFlag
(
"N"
);
financeCustomerBalanceDao
.
insert
(
balance
);
}
catch
(
Exception
e
)
{
throw
ResponseException
.
of
(
ResultCode
.
FAILURE
,
"新增充值记录失败!"
);
}
}
}
}
return
Result
.
of_success
(
"添加用户成功!"
);
}
/**
* 保存企业信息
* @param saveCustomerReq
*/
private
void
saveCompany
(
SaveCustomerRequest
saveCustomerReq
)
{
private
Long
saveCompany
(
SaveCustomerRequest
saveCustomerReq
)
{
Department
department
=
new
Department
();
// 添加创建人/创建时间
department
.
setCrePerson
(
"1"
);
...
...
@@ -222,29 +232,39 @@ public class DepartmentServiceImpl implements DepartmentService {
department
.
setTelephone
(
saveCustomerReq
.
getTelephone
());
// 已审核
department
.
setAuditStatus
(
"02"
);
tDepartmentDao
.
insert
(
department
);
return
department
.
getDepartmentId
();
}
/**
* 校验企业/账号是否存在
* @param saveCustomerReq
*/
private
void
userCheck
(
SaveCustomerRequest
saveCustomerReq
)
{
private
Result
userCheck
(
SaveCustomerRequest
saveCustomerReq
)
{
// 校验公司是否已存在
QueryWrapper
queryWrapper
=
new
QueryWrapper
();
queryWrapper
.
eq
(
"unified_credit_code"
,
saveCustomerReq
.
getUnifiedCreditCode
());
Department
department
=
tDepartmentDao
.
selectOne
(
queryWrapper
);
// 如果
不
为空
// 如果为空
if
(
department
!=
null
)
{
throw
ResponseException
.
of
(
ResultCode
.
FAILURE
,
"公司已存在
"
);
return
Result
.
error
(
"企业已存在!
"
);
}
// 校验账号信息
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"customerAccount"
,
saveCustomerReq
.
getCustomerAccount
());
map
.
put
(
"customerPhone"
,
saveCustomerReq
.
getCustomerPhone
());
Map
<
String
,
Object
>
accountMap
=
new
HashMap
<>();
accountMap
.
put
(
"customerAccount"
,
saveCustomerReq
.
getCustomerAccount
());
// 查询用户是否存在
MallCustomer
accountUser
=
mallCustomerDao
.
selectByUser
(
accountMap
);
if
(
accountUser
!=
null
)
{
return
Result
.
error
(
"用户已存在!"
);
}
Map
<
String
,
Object
>
phoneMap
=
new
HashMap
<>();
phoneMap
.
put
(
"customerPhone"
,
saveCustomerReq
.
getCustomerPhone
());
// 查询用户是否存在
MallCustomer
mallCustomer
=
mallCustomerDao
.
selectByUser
(
m
ap
);
if
(
mallCustom
er
!=
null
)
{
throw
ResponseException
.
of
(
ResultCode
.
FAILURE
,
"用户已存在,请重新输入
!"
);
MallCustomer
phoneUser
=
mallCustomerDao
.
selectByUser
(
phoneM
ap
);
if
(
phoneUs
er
!=
null
)
{
return
Result
.
error
(
"用户已存在
!"
);
}
return
Result
.
ok
();
}
}
\ No newline at end of file
jz-dm-manage/src/main/resources/mapper/customer/MallCustomerDao.xml
View file @
b4522db4
...
...
@@ -91,11 +91,11 @@
</where>
</select>
<!--
新增所有列
-->
<
insert
id=
"insert"
keyProperty=
"customerId"
useGeneratedKeys=
"true"
>
insert into t_mall_customer(department_id, password, customer_account, customer_name, customer_phone, customer_email, customer_address, customer_point, register_time, customer_level, identity_card, cre_time, upt_time, del_flag)
values (#{departmentId}, #{password}, #{customerAccount}, #{customerName}, #{customerPhone}, #{customerEmail}, #{customerAddress}, #{customerPoint}, #{registerTime}, #{customerLevel}, #{identityCard}, #{creTime}, #{uptTime}, #{delFlag})
<
/insert
>
<!--
<!–新增所有列–>
-->
<
!--<insert id="insert" keyProperty="customerId" useGeneratedKeys="true">--
>
<!--insert into t_mall_customer(department_id, password, customer_account, customer_name, customer_phone, customer_email, customer_address, customer_point, register_time, customer_level, identity_card, cre_time, upt_time, del_flag)-->
<!--values (#{departmentId}, #{password}, #{customerAccount}, #{customerName}, #{customerPhone}, #{customerEmail}, #{customerAddress}, #{customerPoint}, #{registerTime}, #{customerLevel}, #{identityCard}, #{creTime}, #{uptTime}, #{delFlag})-->
<
!--</insert>--
>
<insert
id=
"insertBatch"
keyProperty=
"customerId"
useGeneratedKeys=
"true"
>
insert into t_mall_customer(department_id, password, customer_account, customer_name,
...
...
@@ -175,13 +175,16 @@
customer_phone
from t_mall_customer
where
1=1
and del_flag='N'
<if
test=
"customerPhone != null"
>
del_flag='N'
<if
test=
"customerPhone != null and customerPhone != ''"
>
and customer_phone = #{customerPhone}
</if>
<if
test=
"customerAccount != null"
>
<if
test=
"customerAccount != null and customerAccount != ''"
>
and customer_account = #{customerAccount}
</if>
<if
test=
"customerPhone != null and customerAccount != null"
>
and customer_account = #{customerAccount}
and customer_phone = #{customerPhone}
</if>
</select>
</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