Commit d8591742 authored by ysongq's avatar ysongq

commit

parent 644a8841
alter table t_data_goods add use_person varchar(64) DEFAULT '0' COMMENT '使用人数';
alter table t_mall_customer add head_portrait_url varchar(512) COMMENT '头像';
\ No newline at end of file
......@@ -7,6 +7,8 @@ import com.jz.common.utils.Result;
import com.jz.common.utils.SessionUtils;
import com.jz.common.utils.StatusCode;
import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto;
import com.jz.dm.mall.moduls.controller.customer.bean.req.CustomerRequest;
import com.jz.dm.mall.moduls.controller.customer.bean.req.LoginRequest;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.dm.mall.moduls.service.MallCustomerService;
import io.swagger.annotations.Api;
......@@ -43,14 +45,13 @@ public class LoginController {
/**
* 登录功能
*
* @param username 账号
* @param password 密码
* @return
*/
@PostMapping(value = "/login")
@ApiOperation(value = "登录功能", notes = "登录功能")
public Result<CustomerDto> login(@RequestParam(value = "username") String username,
@RequestParam(value = "password") String password, HttpServletRequest request) throws Exception {
public Result<CustomerDto> login(@RequestBody LoginRequest customer, HttpServletRequest request) throws Exception {
String username = customer.getUsername();
String password = customer.getPassword();
// 手机
String ph = "^[1][34578]\\d{9}$";
// 如果是手机验证
......@@ -59,7 +60,7 @@ public class LoginController {
request.getSession().getAttribute("mallCustomer");
if (mallCustomer != null) {
if (mallCustomer.getCustomerPhone().equals(username) && mallCustomer.getPassword().equals(password)) {
return new Result<>(true, "登录成功!", StatusCode.OK);
return new Result<>(true, "登录成功!", StatusCode.OK, mallCustomer);
}
return new Result<>(false, "用户名或密码错误!", StatusCode.ERROR);
}
......@@ -67,7 +68,7 @@ public class LoginController {
CustomerDto mallCustomer = mallCustomerService.selectByAccount(username, request);
if (mallCustomer != null) {
if (mallCustomer.getCustomerAccount().equals(username) && mallCustomer.getPassword().equals(password)) {
return new Result<>(true, "登录成功!", StatusCode.OK);
return new Result<>(true, "登录成功!", StatusCode.OK, mallCustomer);
}
}
......
......@@ -9,6 +9,7 @@ import com.jz.common.constant.ResultCode;
import com.jz.common.constant.ResultMsg;
import com.jz.common.utils.SessionUtils;
import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto;
import com.jz.dm.mall.moduls.controller.customer.bean.req.CustomerRequest;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode;
......@@ -47,32 +48,31 @@ public class MallCustomerController extends BaseController {
/**
* 添加用户
* @param paramMap
* @param customer
* @return
*/
@PostMapping("/saveCustomer")
@ApiOperation(value = "注册用户", notes = "添加用户")
public Result saveCustomer(@RequestParam(required = true) Map<String, String> paramMap, HttpServletRequest request) {
if (paramMap != null) {
String username = paramMap.get("username");
String telephone = paramMap.get("telephone");
public Result saveCustomer(@RequestBody CustomerRequest customer, HttpServletRequest request) {
if (!StringUtils.isEmpty(customer)) {
String ph = "^[1][34578]\\d{9}$";
String telephone= customer.getTelephone();
if (telephone.matches(ph)) {
MallCustomer mallCustomer = mallCustomerService.selectByPhone(telephone);
MallCustomer mallCustomer = mallCustomerService.selectByPhone(customer.getTelephone());
if (mallCustomer != null) {
if (mallCustomer.getCustomerPhone().equals(telephone)) {
if (mallCustomer.getCustomerPhone().equals(customer.getTelephone())) {
return new Result(false, "手机号相同", StatusCode.ERROR);
}
}
}
// 根据手机号查询用户信息
CustomerDto mallCustomer = mallCustomerService.selectByAccount(username, request);
CustomerDto mallCustomer = mallCustomerService.selectByAccount(customer.getUsername(), request);
if (mallCustomer != null) {
if (mallCustomer.getCustomerAccount().equals(username)) {
if (mallCustomer.getCustomerAccount().equals(customer.getUsername())) {
return new Result(false, "用户名相同", StatusCode.ERROR);
}
}
mallCustomerService.saveCustomer(paramMap);
mallCustomerService.saveCustomer(customer);
return new Result(true, "注册成功!", StatusCode.OK);
}
return new Result(false, "注册失败!", StatusCode.ERROR);
......@@ -84,7 +84,7 @@ public class MallCustomerController extends BaseController {
* @return
*/
@GetMapping("/getLoginUserName")
@ApiOperation(value = "获取用户信息")
@ApiOperation(value = "获取当前登录用户信息")
public Result getLoginUserName (HttpServletRequest request) {
// 从session中获取id
try {
......@@ -102,7 +102,7 @@ public class MallCustomerController extends BaseController {
@PostMapping(value = "/updatePassword")
@ApiOperation(value = "密码修改")
public Result updatePassword(@RequestParam(value = "oldPassWard") String oldPassword,
@RequestParam(value = "newPassword")String newPassword,HttpServletRequest request) throws Exception {
@RequestParam(value = "newPassword") String newPassword,HttpServletRequest request) throws Exception {
// 获取用户信息
MallCustomer mallCustomer = (MallCustomer) getLoginUserName(request).getData();
// 如果密码一致
......
......@@ -14,6 +14,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -40,7 +41,7 @@ public class ValidateCodeController {
*/
@PostMapping(value = "/sendForLogin")
@ApiOperation(value = "注册时发送的验证码")
public Result sendForLogin(String telephone) {
public Result sendForLogin(@RequestParam(value = "telephone") String telephone) {
String key = RedisMessageConstant.SENDTYPE_LOGIN + "_" + telephone;
// 通过手机号从redis获取验证码
String codeInRedis = (String) redisTemplate.opsForValue().get(key);
......@@ -71,7 +72,7 @@ public class ValidateCodeController {
*/
@PostMapping("/send4Code")
@ApiOperation(value = "修改密码发送验证码")
public Result send4Code(String telephone) {
public Result send4Code(@RequestParam(value = "telephone") String telephone) {
String key = RedisMessageConstant.SENDTYPE_LOGIN + "_" + telephone;
// 通过手机号从redis获取验证码
String codeInRedis = (String) redisTemplate.opsForValue().get(key);
......
package com.jz.dm.mall.moduls.controller.customer.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName: CustomerDto
......@@ -15,33 +16,51 @@ public class CustomerDto {
/**
* 用户id
*/
@ApiModelProperty(value = "账户id")
private Long customerId;
/**
* 企业id
*/
@ApiModelProperty(value = "企业id")
private Long departmentId;
/**
* 密码
*/
@ApiModelProperty(value = "密码")
private String password;
/**
* 账户
*/
@ApiModelProperty(value = "账户")
private String customerAccount;
/**
* 用户真实姓名
*/
@ApiModelProperty(value = "真实姓名")
private String customerName;
/**
* 联系电话
*/
@ApiModelProperty(value = "电话")
private String customerPhone;
/**
* 资产账户id
*/
@ApiModelProperty(value = "资产账户id")
private String assetsId;
@ApiModelProperty(value = "头像")
private String headPortraitUrl;
public String getHeadPortraitUrl() {
return headPortraitUrl;
}
public void setHeadPortraitUrl(String headPortraitUrl) {
this.headPortraitUrl = headPortraitUrl;
}
public Long getCustomerId() {
return customerId;
}
......
package com.jz.dm.mall.moduls.controller.customer.bean.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName:
* @Author: Carl
* @Date: 2020/12/17
* @Version:
*/
@ApiModel(value = "注册用户接受的参数")
public class CustomerRequest {
@ApiModelProperty(value = "用户名")
private String username;
@ApiModelProperty(value = "手机号")
private String telephone;
@ApiModelProperty(value = "验证码")
private String vailCode;
@ApiModelProperty(value = "密码")
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getVailCode() {
return vailCode;
}
public void setVailCode(String vailCode) {
this.vailCode = vailCode;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package com.jz.dm.mall.moduls.controller.customer.bean.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName:
* @Author: Carl
* @Date: 2020/12/17
* @Version:
*/
@ApiModel(value = "用户登录接受的参数")
public class LoginRequest {
@ApiModelProperty(value = "验证码")
private String vailCode;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "用户名")
private String username;
public String getVailCode() {
return vailCode;
}
public void setVailCode(String vailCode) {
this.vailCode = vailCode;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
package com.jz.dm.mall.moduls.service;
import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto;
import com.jz.dm.mall.moduls.controller.customer.bean.req.CustomerRequest;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import javax.servlet.http.HttpServletRequest;
......@@ -30,9 +31,9 @@ public interface MallCustomerService {
/**
* 注册账号
* @param paramMap
* @param customerRequest
*/
void saveCustomer(Map<String, String> paramMap);
void saveCustomer(CustomerRequest customerRequest);
/**
* 通过手机号查询是否已注册
......
......@@ -7,6 +7,7 @@ import com.jz.common.enums.UserTypeEnum;
import com.jz.common.utils.DateUtils;
import com.jz.common.utils.SessionUtils;
import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto;
import com.jz.dm.mall.moduls.controller.customer.bean.req.CustomerRequest;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.dm.mall.moduls.mapper.MallCustomerDao;
import com.jz.dm.mall.moduls.service.MallCustomerService;
......@@ -91,15 +92,15 @@ public class MallCustomerServiceImpl implements MallCustomerService {
/**
* 注册账号
*
* @param paramMap
* @param
*/
@Override
public void saveCustomer(Map<String, String> paramMap) {
public void saveCustomer(CustomerRequest customerRequest) {
MallCustomer mallCustomer = new MallCustomer();
// 获取验证码
String vailCode = paramMap.get("vailCode");
String username = paramMap.get("username");
String telephone = paramMap.get("telephone");
String vailCode = customerRequest.getVailCode();
String username = customerRequest.getUsername();
String telephone = customerRequest.getTelephone();
// 从redis获取验证码
// String key = RedisMessageConstant.SENDTYPE_LOGIN + "_" + telephone;
......@@ -108,7 +109,7 @@ public class MallCustomerServiceImpl implements MallCustomerService {
String codeInRedis = "147826";
if (codeInRedis.equals(vailCode)) {
mallCustomer.setCustomerAccount(username);
mallCustomer.setPassword(paramMap.get("password"));
mallCustomer.setPassword(customerRequest.getPassword());
mallCustomer.setCustomerPhone(telephone);
mallCustomer.setCreTime(DateUtils.getToday());
mallCustomer.setRegisterTime(DateUtils.getToday());
......
......@@ -173,6 +173,7 @@
t1.customer_account as customerAccount,
t1.customer_name as customerName,
t1.customer_phone as customerPhone,
t1.head_portrait_url as headPortraitUrl,
t3.assets_id as assetsId
from t_mall_customer t1
left join t_department t2 on t1.department_id=t2.department_id
......@@ -188,6 +189,7 @@
t1.customer_account as customerAccount,
t1.customer_name as customerName,
t1.customer_phone as customerPhone,
t1.head_portrait_url as headPortraitUrl,
t3.assets_id as assetsId
from t_mall_customer t1
left join t_department t2 on t1.department_id=t2.department_id
......
......@@ -63,7 +63,7 @@ public class DepartmentController extends BaseController {
* @param req
* @return
*/
@GetMapping(value = "/{id}")
@GetMapping(value = "/getDepartment/{id}")
@ApiOperation(value = "主键查询用户企业详情信息")
public Result<CompanyDetailsDto> selectById(@PathVariable(value = "id") Long id, HttpServletRequest req) {
if (id != null) {
......@@ -80,19 +80,26 @@ public class DepartmentController extends BaseController {
*/
@PostMapping(value = "/audit/{id}")
@ApiModelProperty(value = "企业审核")
public Result audit(@PathVariable(value = "id") Long id) {
public Result audit(@PathVariable(value = "id") Long id, HttpServletRequest req) {
if (id != null) {
departmentService.audit(id);
departmentService.audit(id, req);
return new Result<CompanyDetailsDto>(true, "企业审核成功!", StatusCode.OK);
}
return new Result<CompanyDetailsDto>(false, "企业审核失败!", StatusCode.ERROR);
}
/**
* 添加用户
* @param saveCustomerRequest
* @param req
* @return
* @throws Exception
*/
@PostMapping(value = "/add")
@ApiModelProperty(value = "添加用户")
public Result add(@RequestBody SaveCustomerRequest saveCustomerRequest, HttpServletRequest req) throws Exception {
if (saveCustomerRequest != null) {
Result result = departmentService.add(saveCustomerRequest);
Result result = departmentService.add(saveCustomerRequest, req);
result.getMessage();
result.getCode();
return result;
......
......@@ -37,11 +37,11 @@ public interface DepartmentService {
* 企业审核信息
* @param id
*/
void audit(Long id);
void audit(Long id, HttpServletRequest req);
/**
* 添加用户
* @param saveCustomerRequest
*/
Result add(SaveCustomerRequest saveCustomerRequest);
Result add(SaveCustomerRequest saveCustomerRequest, HttpServletRequest req);
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.jz.manage.moduls.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.common.bean.MallCustomerApiDto;
import com.jz.common.bean.PageInfoResponse;
import com.jz.common.constant.Constants;
import com.jz.common.constant.ResultCode;
......@@ -10,11 +11,13 @@ import com.jz.common.exception.ResponseException;
import com.jz.common.utils.DateUtils;
import com.jz.common.utils.Result;
import com.jz.common.utils.SessionUtils;
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;
import com.jz.manage.moduls.controller.customer.bean.request.SaveCustomerRequest;
import com.jz.manage.moduls.controller.sys.bean.SysUserDto;
import com.jz.manage.moduls.entity.Department;
import com.jz.manage.moduls.entity.FinanceCustomerAssets;
import com.jz.manage.moduls.entity.FinanceCustomerBalance;
......@@ -113,7 +116,7 @@ public class DepartmentServiceImpl implements DepartmentService {
*/
@Override
@Transactional
public void audit(Long id) {
public void audit(Long id ,HttpServletRequest req) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("department_id", id);
// 获取企业详细信息
......@@ -121,21 +124,21 @@ public class DepartmentServiceImpl implements DepartmentService {
// if (department.getAuditStatus().equals("02") ) {
// throw ResponseException.of(ResultCode.FAILURE, "已审核!不用在审核!");
// }
// 从session获取商城用户id
// 从session获取平台用户id
SysUserDto sysUser = (SysUserDto) SessionUtils.getUserCurrent(req, "sysUser");
// 更新信息: 将企业审核状态改为已审核,企业信息更新
department.setAuditStatus("02");
department.setAuditPerson("1");
department.setAuditPerson(sysUser.getUserId() + "");
department.setAuditTime(DateUtils.getToday());
department.setUptTime(DateUtils.getToday());
department.setUptPerson(department.getUptPerson());
department.setUptPerson(sysUser.getUserId()+ "");
tDepartmentDao.updateById(department);
// 新增企业客户资产
FinanceCustomerAssets financeCustomerAssets = new FinanceCustomerAssets();
financeCustomerAssets.setDepartmentId(department.getDepartmentId());
financeCustomerAssets.setCreTime(DateUtils.getToday());
financeCustomerAssets.setCrePerson("1");
financeCustomerAssets.setCrePerson(sysUser.getUserId() + "");
financeCustomerAssetsDao.insert(financeCustomerAssets);
}
......@@ -147,15 +150,16 @@ public class DepartmentServiceImpl implements DepartmentService {
*/
@Override
@Transactional()
public Result add(SaveCustomerRequest saveCustomerReq) {
public Result add(SaveCustomerRequest saveCustomerReq, HttpServletRequest req) {
// 校验信息
Result s = userCheck(saveCustomerReq);
boolean success = s.isSuccess();
if (!success) {
return Result.error("添加用户失败!");
}
SysUserDto sysUser = (SysUserDto) SessionUtils.getUserCurrent(req, "sysUser");
// 保存企业信息
Long departmentId = saveCompany(saveCustomerReq);
Long departmentId = saveCompany(saveCustomerReq, req);
if (departmentId != null) {
// 保存账号信息
MallCustomer mallCustomer = new MallCustomer();
......@@ -165,10 +169,9 @@ public class DepartmentServiceImpl implements DepartmentService {
mallCustomer.setPassword(saveCustomerReq.getPassword());
mallCustomer.setCreTime(DateUtils.getToday());
mallCustomer.setCustomerPoint(0L);
mallCustomer.setCrePerson("1");
mallCustomer.setCrePerson(sysUser.getUserId()+"");
mallCustomer.setDelFlag("N");
mallCustomerDao.insert(mallCustomer);
System.out.println(mallCustomer.getCustomerId());
// 如果充值金额不为空
if (saveCustomerReq.getBalanceMoney() != null) {
......@@ -214,10 +217,11 @@ public class DepartmentServiceImpl implements DepartmentService {
* 保存企业信息
* @param saveCustomerReq
*/
private Long saveCompany(SaveCustomerRequest saveCustomerReq) {
private Long saveCompany(SaveCustomerRequest saveCustomerReq, HttpServletRequest req) {
Department department = new Department();
SysUserDto sysUser = (SysUserDto) SessionUtils.getUserCurrent(req, "sysUser");
// 添加创建人/创建时间
department.setCrePerson("1");
department.setCrePerson(sysUser.getUserId() + "");
department.setCreTime(DateUtils.getToday());
// 基本信息
department.setDepartmentName(saveCustomerReq.getDepartmentName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment