Commit 557ba91c authored by ysongq's avatar ysongq

用户添加接口

parent b6f48fa5
...@@ -8,10 +8,12 @@ import com.jz.manage.moduls.controller.BaseController; ...@@ -8,10 +8,12 @@ import com.jz.manage.moduls.controller.BaseController;
import com.jz.manage.moduls.controller.customer.bean.dto.CompanyDetailsDto; 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.dto.EnterpriseAuditDto;
import com.jz.manage.moduls.controller.customer.bean.request.EnterpriseAuditRequest; 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.service.DepartmentService; import com.jz.manage.moduls.service.DepartmentService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -70,13 +72,29 @@ public class DepartmentController extends BaseController { ...@@ -70,13 +72,29 @@ public class DepartmentController extends BaseController {
return new Result<CompanyDetailsDto>(false, "查询企业详情失败!", StatusCode.ERROR); return new Result<CompanyDetailsDto>(false, "查询企业详情失败!", StatusCode.ERROR);
} }
@PostMapping(value = "audit/{id}") /**
* 企业审核接口
* @param id
* @return
*/
@PostMapping(value = "/audit/{id}")
@ApiModelProperty(value = "企业审核") @ApiModelProperty(value = "企业审核")
public Result audit(@PathVariable(value = "id") Long id) { public Result audit(@PathVariable(value = "id") Long id) {
if (id != null) { if (id != null) {
departmentService.audit(id); departmentService.audit(id);
return new Result<CompanyDetailsDto>(true, "企业审核成功!", StatusCode.ERROR); return new Result<CompanyDetailsDto>(true, "企业审核成功!", StatusCode.OK);
} }
return new Result<CompanyDetailsDto>(false, "企业审核失败!", StatusCode.ERROR); return new Result<CompanyDetailsDto>(false, "企业审核失败!", StatusCode.ERROR);
} }
@PostMapping(value = "/add")
@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);
}
return new Result<CompanyDetailsDto>(false, "添加用户失败!", StatusCode.ERROR);
}
} }
\ No newline at end of file
package com.jz.manage.moduls.controller.customer.bean.dto;
import io.swagger.annotations.ApiModel;
/**
* @ClassName: CustomerDto
* @Description: 商城用户返回对象参数
* @Author Bellamy
* @Date 2020/12/9
* @Version 1.0
*/
@ApiModel(value = "商城用户--返回参数对象", description = "返回参数对象")
public class CustomerDto {
/**
* 用户id
*/
private Long customerId;
/**
* 企业id
*/
private Long departmentId;
/**
* 密码
*/
private String password;
/**
* 账户
*/
private String customerAccount;
/**
* 用户真实姓名
*/
private String customerName;
/**
* 联系电话
*/
private String customerPhone;
/**
* 资产账户id
*/
private String assetsId;
public Long getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
public Long getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Long departmentId) {
this.departmentId = departmentId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getCustomerAccount() {
return customerAccount;
}
public void setCustomerAccount(String customerAccount) {
this.customerAccount = customerAccount;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getCustomerPhone() {
return customerPhone;
}
public void setCustomerPhone(String customerPhone) {
this.customerPhone = customerPhone;
}
public String getAssetsId() {
return assetsId;
}
public void setAssetsId(String assetsId) {
this.assetsId = assetsId;
}
}
package com.jz.manage.moduls.controller.customer.bean.request;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
/**
* @ClassName:
* @Author: Carl
* @Date: 2020/12/10
* @Version:
*/
@Api(tags = "用户添加信息请求参数封装")
public class SaveCustomerRequest extends BasePageBean {
@ApiModelProperty(value = "企业id")
@TableId(value = "department_id",type = IdType.AUTO)
private Long departmentId;
@ApiModelProperty(value = "企业名称")
private String departmentName;
@ApiModelProperty(value = "企业地址")
private String registeredAddress;
@ApiModelProperty(value = "营业执照")
private String businessLicense;
@ApiModelProperty(value = "统一社会信用代码")
private String unifiedCreditCode;
@ApiModelProperty(value = "银行卡号")
private String bankCardNumber;
@ApiModelProperty(value = "开户行地址")
private String bankAddress;
@ApiModelProperty(value = "联系人姓名")
private String linkman;
@ApiModelProperty(value = "联系人电话")
private String telephone;
@ApiModelProperty(value = "账号名")
private String customerAccount;
@ApiModelProperty(value = "账号手机号")
private String customerPhone;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "充值金额")
private BigDecimal balanceMoney;
public Long getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Long departmentId) {
this.departmentId = departmentId;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public String getRegisteredAddress() {
return registeredAddress;
}
public void setRegisteredAddress(String registeredAddress) {
this.registeredAddress = registeredAddress;
}
public String getBusinessLicense() {
return businessLicense;
}
public void setBusinessLicense(String businessLicense) {
this.businessLicense = businessLicense;
}
public String getUnifiedCreditCode() {
return unifiedCreditCode;
}
public void setUnifiedCreditCode(String unifiedCreditCode) {
this.unifiedCreditCode = unifiedCreditCode;
}
public String getBankCardNumber() {
return bankCardNumber;
}
public void setBankCardNumber(String bankCardNumber) {
this.bankCardNumber = bankCardNumber;
}
public String getLinkman() {
return linkman;
}
public void setLinkman(String linkman) {
this.linkman = linkman;
}
public String getBankAddress() {
return bankAddress;
}
public void setBankAddress(String bankAddress) {
this.bankAddress = bankAddress;
}
public String getCustomerPhone() {
return customerPhone;
}
public void setCustomerPhone(String customerPhone) {
this.customerPhone = customerPhone;
}
public String getCustomerAccount() {
return customerAccount;
}
public void setCustomerAccount(String customerAccount) {
this.customerAccount = customerAccount;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public BigDecimal getBalanceMoney() {
return balanceMoney;
}
public void setBalanceMoney(BigDecimal balanceMoney) {
this.balanceMoney = balanceMoney;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
}
...@@ -44,6 +44,10 @@ public class Department implements Serializable { ...@@ -44,6 +44,10 @@ public class Department implements Serializable {
* 行业 * 行业
*/ */
private String industry; private String industry;
/**
* 联系人
*/
private String linkman;
/** /**
* 联系电话 * 联系电话
*/ */
...@@ -370,4 +374,11 @@ public class Department implements Serializable { ...@@ -370,4 +374,11 @@ public class Department implements Serializable {
this.delFlag = delFlag; this.delFlag = delFlag;
} }
public String getLinkman() {
return linkman;
}
public void setLinkman(String linkman) {
this.linkman = linkman;
}
} }
\ No newline at end of file
...@@ -68,6 +68,10 @@ public class MallCustomer implements Serializable { ...@@ -68,6 +68,10 @@ public class MallCustomer implements Serializable {
* 创建时间 * 创建时间
*/ */
private Date creTime; private Date creTime;
/**
* 创建人
*/
private String crePerson;
/** /**
* 更新时间 * 更新时间
*/ */
...@@ -198,4 +202,11 @@ public class MallCustomer implements Serializable { ...@@ -198,4 +202,11 @@ public class MallCustomer implements Serializable {
this.delFlag = delFlag; this.delFlag = delFlag;
} }
public String getCrePerson() {
return crePerson;
}
public void setCrePerson(String crePerson) {
this.crePerson = crePerson;
}
} }
\ No newline at end of file
package com.jz.manage.moduls.mapper; package com.jz.manage.moduls.mapper;
import com.jz.common.base.BaseMapper; import com.jz.common.base.BaseMapper;
import com.jz.common.entity.MallCustomer; import com.jz.manage.moduls.entity.MallCustomer;
import java.util.Map;
/** /**
* 商城用户(TMallCustomer)表数据库访问层 * 商城用户(TMallCustomer)表数据库访问层
...@@ -12,4 +16,5 @@ import com.jz.common.entity.MallCustomer; ...@@ -12,4 +16,5 @@ import com.jz.common.entity.MallCustomer;
public interface MallCustomerDao extends BaseMapper<MallCustomer> { public interface MallCustomerDao extends BaseMapper<MallCustomer> {
MallCustomer selectByUser(Map map);
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import com.jz.common.bean.PageInfoResponse; ...@@ -4,6 +4,7 @@ import com.jz.common.bean.PageInfoResponse;
import com.jz.manage.moduls.controller.customer.bean.dto.CompanyDetailsDto; 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.dto.EnterpriseAuditDto;
import com.jz.manage.moduls.controller.customer.bean.request.EnterpriseAuditRequest; import com.jz.manage.moduls.controller.customer.bean.request.EnterpriseAuditRequest;
import com.jz.manage.moduls.controller.customer.bean.request.SaveCustomerRequest;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -36,4 +37,10 @@ public interface DepartmentService { ...@@ -36,4 +37,10 @@ public interface DepartmentService {
* @param id * @param id
*/ */
void audit(Long id); void audit(Long id);
/**
* 添加用户
* @param saveCustomerRequest
*/
void add(SaveCustomerRequest saveCustomerRequest);
} }
\ No newline at end of file
...@@ -10,16 +10,23 @@ import com.jz.common.exception.ResponseException; ...@@ -10,16 +10,23 @@ import com.jz.common.exception.ResponseException;
import com.jz.common.utils.DateUtils; import com.jz.common.utils.DateUtils;
import com.jz.manage.moduls.controller.customer.bean.dto.CompanyDetailsDto; 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.dto.EnterpriseAuditDto;
import com.jz.manage.moduls.controller.customer.bean.request.EnterpriseAuditRequest; 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.entity.Department; import com.jz.manage.moduls.entity.Department;
import com.jz.manage.moduls.entity.FinanceCustomerAssets; import com.jz.manage.moduls.entity.FinanceCustomerAssets;
import com.jz.manage.moduls.entity.FinanceCustomerBalance;
import com.jz.manage.moduls.entity.MallCustomer;
import com.jz.manage.moduls.mapper.DepartmentDao; import com.jz.manage.moduls.mapper.DepartmentDao;
import com.jz.manage.moduls.mapper.FinanceCustomerAssetsDao; import com.jz.manage.moduls.mapper.FinanceCustomerAssetsDao;
import com.jz.manage.moduls.mapper.FinanceCustomerBalanceDao;
import com.jz.manage.moduls.mapper.MallCustomerDao;
import com.jz.manage.moduls.service.DepartmentService; import com.jz.manage.moduls.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -40,6 +47,13 @@ public class DepartmentServiceImpl implements DepartmentService { ...@@ -40,6 +47,13 @@ public class DepartmentServiceImpl implements DepartmentService {
@Autowired @Autowired
private FinanceCustomerAssetsDao financeCustomerAssetsDao; private FinanceCustomerAssetsDao financeCustomerAssetsDao;
@Autowired
private MallCustomerDao mallCustomerDao;
@Autowired
private FinanceCustomerBalanceDao financeCustomerBalanceDao;
/** /**
* 条件查询企业审核信息列表 * 条件查询企业审核信息列表
* *
...@@ -98,6 +112,7 @@ public class DepartmentServiceImpl implements DepartmentService { ...@@ -98,6 +112,7 @@ public class DepartmentServiceImpl implements DepartmentService {
* @param id * @param id
*/ */
@Override @Override
@Transactional
public void audit(Long id) { public void audit(Long id) {
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("department_id", id); queryWrapper.eq("department_id", id);
...@@ -124,4 +139,112 @@ public class DepartmentServiceImpl implements DepartmentService { ...@@ -124,4 +139,112 @@ public class DepartmentServiceImpl implements DepartmentService {
financeCustomerAssetsDao.insert(financeCustomerAssets); financeCustomerAssetsDao.insert(financeCustomerAssets);
} }
/**
* 添加用户
*
* @param
*/
@Override
@Transactional
public void add(SaveCustomerRequest saveCustomerReq) {
// 校验信息
userCheck(saveCustomerReq);
// 保存企业信息
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, "新增企业资产失败!");
}
}
// 新增一条充值记录表
// 获取最新的资产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, "新增充值记录失败!");
}
}
}
}
/**
* 保存企业信息
* @param saveCustomerReq
*/
private void saveCompany(SaveCustomerRequest saveCustomerReq) {
Department department = new Department();
// 添加创建人/创建时间
department.setCrePerson("1");
department.setCreTime(DateUtils.getToday());
// 基本信息
department.setDepartmentName(saveCustomerReq.getDepartmentName());
department.setRegisteredAddress(saveCustomerReq.getRegisteredAddress());
// 企业信息
department.setUnifiedCreditCode(saveCustomerReq.getUnifiedCreditCode());
department.setBusinessLicense(saveCustomerReq.getBusinessLicense());
department.setBankAddress(saveCustomerReq.getBankAddress());
department.setBankCardNumber(saveCustomerReq.getBankCardNumber());
// 联系人信息
department.setLinkman(saveCustomerReq.getLinkman());
department.setTelephone(saveCustomerReq.getTelephone());
// 已审核
department.setAuditStatus("02");
}
/**
* 校验企业/账号是否存在
* @param saveCustomerReq
*/
private void 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, "公司已存在");
}
// 校验账号信息
Map<String, Object> map = new HashMap<>();
map.put("customerAccount", saveCustomerReq.getCustomerAccount());
map.put("customerPhone", saveCustomerReq.getCustomerPhone());
// 查询用户是否存在
MallCustomer mallCustomer = mallCustomerDao.selectByUser(map);
if (mallCustomer != null) {
throw ResponseException.of(ResultCode.FAILURE, "用户已存在,请重新输入!");
}
}
} }
\ No newline at end of file
...@@ -150,10 +150,10 @@ ...@@ -150,10 +150,10 @@
</select> </select>
<!--新增所有列--> <!--新增所有列-->
<insert id="insert" keyProperty="departmentId" useGeneratedKeys="true"> <!--<insert id="insert" keyProperty="departmentId" useGeneratedKeys="true">
insert into t_department(department_name, legal_representative, province, city, industry, telephone, registered_address, zone_code, depart_picture, business_license, tax_registration, depart_picture_time, business_license_time, tax_registration_time, unified_credit_code, bank_name, bank_card_number, bank_address, bank_no, audit_status, reject_reason, audit_person, audit_time, cre_time, cre_person, upt_time, upt_person, del_flag) insert into t_department(department_name, legal_representative, province, city, industry, telephone, registered_address, zone_code, depart_picture, business_license, tax_registration, depart_picture_time, business_license_time, tax_registration_time, unified_credit_code, bank_name, bank_card_number, bank_address, bank_no, audit_status, reject_reason, audit_person, audit_time, cre_time, cre_person, upt_time, upt_person, del_flag)
values (#{departmentName}, #{legalRepresentative}, #{province}, #{city}, #{industry}, #{telephone}, #{registeredAddress}, #{zoneCode}, #{departPicture}, #{businessLicense}, #{taxRegistration}, #{departPictureTime}, #{businessLicenseTime}, #{taxRegistrationTime}, #{unifiedCreditCode}, #{bankName}, #{bankCardNumber}, #{bankAddress}, #{bankNo}, #{auditStatus}, #{rejectReason}, #{auditPerson}, #{auditTime}, #{creTime}, #{crePerson}, #{uptTime}, #{uptPerson}, #{delFlag}) values (#{departmentName}, #{legalRepresentative}, #{province}, #{city}, #{industry}, #{telephone}, #{registeredAddress}, #{zoneCode}, #{departPicture}, #{businessLicense}, #{taxRegistration}, #{departPictureTime}, #{businessLicenseTime}, #{taxRegistrationTime}, #{unifiedCreditCode}, #{bankName}, #{bankCardNumber}, #{bankAddress}, #{bankNo}, #{auditStatus}, #{rejectReason}, #{auditPerson}, #{auditTime}, #{creTime}, #{crePerson}, #{uptTime}, #{uptPerson}, #{delFlag})
</insert> </insert>-->
<insert id="insertOrUpdateBatch" keyProperty="departmentId" useGeneratedKeys="true"> <insert id="insertOrUpdateBatch" keyProperty="departmentId" useGeneratedKeys="true">
insert into t_department(department_name, legal_representative, province, city, industry, insert into t_department(department_name, legal_representative, province, city, industry,
......
...@@ -165,4 +165,23 @@ ...@@ -165,4 +165,23 @@
delete from t_mall_customer where customer_id = #{customerId} delete from t_mall_customer where customer_id = #{customerId}
</delete> </delete>
<select id="selectByUser" resultType="com.jz.manage.moduls.entity.MallCustomer" parameterType="map">
select
customer_id,
department_id,
password,
customer_account,
customer_name,
customer_phone
from t_mall_customer
where
1=1
and del_flag='N'
<if test="customerPhone != null">
and customer_phone = #{customerPhone}
</if>
<if test="customerAccount != null">
and customer_account = #{customerAccount}
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
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