Commit f0396d33 authored by zhangc's avatar zhangc

commit

parent 035c4ada
...@@ -2,6 +2,8 @@ package com.jz.dm.mall.moduls.mapper; ...@@ -2,6 +2,8 @@ package com.jz.dm.mall.moduls.mapper;
import com.jz.common.base.BaseMapper; import com.jz.common.base.BaseMapper;
import com.jz.common.entity.MallCustomer; import com.jz.common.entity.MallCustomer;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import java.util.Map; import java.util.Map;
...@@ -27,4 +29,12 @@ public interface MallCustomerDao extends BaseMapper<MallCustomer> { ...@@ -27,4 +29,12 @@ public interface MallCustomerDao extends BaseMapper<MallCustomer> {
*/ */
MallCustomer selectByPhone(String username); MallCustomer selectByPhone(String username);
/**
* 根据ID查询用户信息
* @param customerId
* @return
*/
@Select("select * from t_mall_customer where customer_id =#{customerId}")
@ResultType(MallCustomer.class)
MallCustomer findById(Long customerId);
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import com.jz.common.entity.Department; ...@@ -5,6 +5,7 @@ import com.jz.common.entity.Department;
import com.jz.common.entity.FinanceCustomerAssets; import com.jz.common.entity.FinanceCustomerAssets;
import com.jz.common.entity.MallCustomer; import com.jz.common.entity.MallCustomer;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.common.utils.UserContextUtil;
import com.jz.dm.mall.moduls.controller.company.bean.CompanyAddReq; import com.jz.dm.mall.moduls.controller.company.bean.CompanyAddReq;
import com.jz.dm.mall.moduls.mapper.DepartmentDao; import com.jz.dm.mall.moduls.mapper.DepartmentDao;
import com.jz.dm.mall.moduls.mapper.FinanceCustomerAssetsDao; import com.jz.dm.mall.moduls.mapper.FinanceCustomerAssetsDao;
...@@ -52,6 +53,18 @@ public class CompanyAuthServiceImpl implements CompanyAuthService { ...@@ -52,6 +53,18 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
public Result addCompanyData(CompanyAddReq req) { public Result addCompanyData(CompanyAddReq req) {
//TODO 获取当前用户ID判断当前用户是否已经关联企业 //TODO 获取当前用户ID判断当前用户是否已经关联企业
Long customerId = (Long) UserContextUtil.pop("customer_id");
if (null ==customerId){
return Result.error("获取用户信息失败");
}
MallCustomer mallCustomer = mallCustomerDao.findById(customerId);
if (null == mallCustomer){
return Result.error("用户信息不存在");
}
if (null != mallCustomer.getDepartmentId()){
return Result.error("用户已关联企业,请勿重复操作");
}
req.setCustomerId(mallCustomer.getCustomerId());
if (StringUtils.isNotBlank(req.getDepartmentName()) && if (StringUtils.isNotBlank(req.getDepartmentName()) &&
StringUtils.isNotBlank(req.getUnifiedCreditCode())) { //企业名称 && 营业执照 StringUtils.isNotBlank(req.getUnifiedCreditCode())) { //企业名称 && 营业执照
Department department = departmentDao.selectDepartmentData(req); Department department = departmentDao.selectDepartmentData(req);
...@@ -85,7 +98,7 @@ public class CompanyAuthServiceImpl implements CompanyAuthService { ...@@ -85,7 +98,7 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
Department departmentInset = new Department(); Department departmentInset = new Department();
departmentInset.setAuditStatus("01");//待审核 departmentInset.setAuditStatus("01");//待审核
departmentInset.setCreTime(new Date()); departmentInset.setCreTime(new Date());
departmentInset.setCrePerson(""); departmentInset.setCrePerson(req.getLoginName());
BeanUtils.copyProperties(req,departmentInset); BeanUtils.copyProperties(req,departmentInset);
if (departmentDao.insert(departmentInset) != 1){ if (departmentDao.insert(departmentInset) != 1){
throw new RuntimeException("保存企业信息失败"); throw new RuntimeException("保存企业信息失败");
...@@ -94,16 +107,16 @@ public class CompanyAuthServiceImpl implements CompanyAuthService { ...@@ -94,16 +107,16 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
FinanceCustomerAssets finance = new FinanceCustomerAssets(); FinanceCustomerAssets finance = new FinanceCustomerAssets();
finance.setDepartmentId(departmentInset.getDepartmentId());//企业ID finance.setDepartmentId(departmentInset.getDepartmentId());//企业ID
finance.setCreTime(new Date()); finance.setCreTime(new Date());
finance.setCrePerson(""); finance.setCrePerson(req.getLoginName());
if (financeCustomerAssetsDao.insert(finance) != 1){ if (financeCustomerAssetsDao.insert(finance) != 1){
throw new RuntimeException("初始化用户资产失败"); throw new RuntimeException("初始化用户资产失败");
} }
//更新用户企业信息 //更新用户企业信息
MallCustomer mallCustomer = new MallCustomer(); MallCustomer mallCustomer = new MallCustomer();
mallCustomer.setCustomerId(0L);//用户ID mallCustomer.setCustomerId(req.getCustomerId());//用户ID
mallCustomer.setDepartmentId(departmentInset.getDepartmentId()); mallCustomer.setDepartmentId(departmentInset.getDepartmentId());
mallCustomer.setUptTime(new Date()); mallCustomer.setUptTime(new Date());
mallCustomer.setUptPerson(""); mallCustomer.setUptPerson(req.getLoginName());
if (mallCustomerDao.updateById(mallCustomer) != 1){ if (mallCustomerDao.updateById(mallCustomer) != 1){
throw new RuntimeException("更新用户企业信息失败"); throw new RuntimeException("更新用户企业信息失败");
} }
......
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