Commit 63f350f9 authored by zuoyh's avatar zuoyh

Merge branch 'saff_update_feature' into dev

parents 880f2272 f8cb21d7
...@@ -65,6 +65,7 @@ public class AppShareholderDetailDTO { ...@@ -65,6 +65,7 @@ public class AppShareholderDetailDTO {
* 操作指令 * 操作指令
* 1:信息修改 * 1:信息修改
* 2:股权变动 * 2:股权变动
* 3:再次购买此前抛售的股权
*/ */
private Integer changeState; private Integer changeState;
......
...@@ -17,6 +17,7 @@ import com.google.common.collect.Lists; ...@@ -17,6 +17,7 @@ import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -95,14 +96,14 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper, ...@@ -95,14 +96,14 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
Integer companyId = Integer.valueOf(company); Integer companyId = Integer.valueOf(company);
if (!(companyId != null && companyId > 0)) if (!(companyId != null && companyId > 0))
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "分公司不存在"); return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "分公司不存在");
RestResponse<BranchCompany> branchCompany = vehicleFeign.get(companyId); CompanyDetail branchCompany = vehicleFeign.getCompanyDetail(companyId).getData();
if (branchCompany.getData() == null) { if (branchCompany == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "分公司不存在"); return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "分公司不存在");
} }
appShareholderDetailDTO.setCompanyId(companyId); appShareholderDetailDTO.setCompanyId(companyId);
appShareholderDetailDTO.setCompanyName(branchCompany.getData().getName()); appShareholderDetailDTO.setCompanyName(branchCompany.getName());
Integer positionId = branchCompany.getData().getId().equals(1) ? HEADQUARTERS_SHAREHOLDER : BRANCH_HEADQUARTERS_SHAREHOLDER; Integer positionId = branchCompany.getId().equals(1) ? HEADQUARTERS_SHAREHOLDER : BRANCH_HEADQUARTERS_SHAREHOLDER;
//用户表更改其身份 //用户表更改其身份
Integer userId = 0; Integer userId = 0;
//登陆表查询用户手机号 //登陆表查询用户手机号
...@@ -129,7 +130,7 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper, ...@@ -129,7 +130,7 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
Integer id = appShareholderDetailDTO.getId() == null ? 0 : appShareholderDetailDTO.getId(); Integer id = appShareholderDetailDTO.getId() == null ? 0 : appShareholderDetailDTO.getId();
BeanUtils.copyProperties(appShareholderDetailDTO, appShareholderDetail); BeanUtils.copyProperties(appShareholderDetailDTO, appShareholderDetail);
appShareholderDetail.setPositionId(positionId); appShareholderDetail.setPositionId(positionId);
appShareholderDetailDTO.setUserId(userId); appShareholderDetail.setUserId(userId);
// insertSelective(appShareholderDetail); // insertSelective(appShareholderDetail);
addUserFindId(appShareholderDetail); addUserFindId(appShareholderDetail);
//插入记录表 //插入记录表
...@@ -163,8 +164,19 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper, ...@@ -163,8 +164,19 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
BeanUtils.copyProperties(appShareholderDetailDTO, appShareholderDetail); BeanUtils.copyProperties(appShareholderDetailDTO, appShareholderDetail);
//信息修改 //信息修改
if (appShareholderDetailDTO.getChangeState().equals(1)) { if (appShareholderDetailDTO.getChangeState().equals(1)) {
updateSelectiveById(appShareholderDetail); if (appShareholderDetailDTO.getCompanyList() == null) {
// updateById(appShareholderDetail); for (String company : appShareholderDetailDTO.getCompanyList()) {
Integer companyId = Integer.valueOf(company);
appShareholderDetail.setCompanyId(companyId);
CompanyDetail branchCompany = vehicleFeign.getCompanyDetail(companyId).getData();
String companyName = branchCompany.getName();
appShareholderDetail.setCompanyName(companyName);
updateSelectiveById(appShareholderDetail);
}
} else {
updateSelectiveById(appShareholderDetail);
}
//退股操作
} else if (appShareholderDetailDTO.getChangeState().equals(2)) { } else if (appShareholderDetailDTO.getChangeState().equals(2)) {
if (appShareholderDetailDTO.getCompanyList() == null) { if (appShareholderDetailDTO.getCompanyList() == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "请传入需要退股的公司"); return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "请传入需要退股的公司");
...@@ -177,20 +189,70 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper, ...@@ -177,20 +189,70 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
} }
for (String company : appShareholderDetailDTO.getCompanyList()) { for (String company : appShareholderDetailDTO.getCompanyList()) {
Integer companyId = Integer.valueOf(company); Integer companyId = Integer.valueOf(company);
appShareholderDetail.setIsQuit(SHAREHOLDERDE_IS_FALSE); //更新股东表 持股状态改为已退股
updateSelectiveById(appShareholderDetail); mapper.updShareHolderIsQuit(appShareholderDetailDTO.getPhone(), companyId);
AppShareholderDetail updAppShareholderDetail = selectById(appShareholderDetail); AppShareholderDetail updAppShareholderDetail = selectById(appShareholderDetailDTO);
RestResponse<BranchCompany> branchCompany = vehicleFeign.get(companyId); //查询股东表,是否为总部股东
String companyName = branchCompany.getData().getName(); Integer oldPositionId = null;
oldPositionId = mapper.selectShareHolderByUserIdOrPhone(updAppShareholderDetail.getUserId(), updAppShareholderDetail.getPhone());
CompanyDetail branchCompany = vehicleFeign.getCompanyDetail(companyId).getData();
String companyName = branchCompany.getName();
updAppShareholderDetail.setCompanyName(companyName); updAppShareholderDetail.setCompanyName(companyName);
//用户表更改其身份
Integer userId = 0;
//登陆表查询用户手机号
AppUserLogin userLogin = loginBiz.checkeUserLogin(appShareholderDetailDTO.getPhone());
if (userLogin != null) {
userId = userLogin.getId();
//离职更新用户表身份
if (oldPositionId == null) {
detailBiz.updateUserPositionByUserId(userId, 6);
} else {
detailBiz.updateUserPositionByUserId(userId, oldPositionId);
}
}
//插入记录表 //插入记录表
appShareholderDetailChangeRecordBiz.addAppShareholderDetailChangeRecord(updAppShareholderDetail, updUserId, SHAREHOLDERDE_IS_FALSE); appShareholderDetailChangeRecordBiz.addAppShareholderDetailChangeRecord(updAppShareholderDetail, updUserId, SHAREHOLDERDE_IS_FALSE);
} }
//复股操作
} else if (appShareholderDetailDTO.getChangeState().equals(3)) {
if (appShareholderDetailDTO.getPhone() == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "请输入股东号码");
}
if (appShareholderDetailDTO.getCompanyList() == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "请输入复股公司");
}
for (String company : appShareholderDetailDTO.getCompanyList()) {
AppShareholderDetail updAppShareholderDetail = selectById(appShareholderDetail);
//查询股东表,是否为总部股东
Integer oldPositionId = mapper.selectShareHolderByUserIdOrPhone(updAppShareholderDetail.getUserId(), updAppShareholderDetail.getPhone());
//用户表更改其身份
Integer userId = 0;
//登陆表查询用户手机号
AppUserLogin userLogin = loginBiz.checkeUserLogin(appShareholderDetailDTO.getPhone());
if (userLogin != null) {
userId = userLogin.getId();
//关联查询detail表 获取身份
AppUserDetail appUserDetail = detailBiz.checkeIsAppUser(userId);
if (oldPositionId == null) {
detailBiz.updateUserPositionByUserId(userId, appShareholderDetail.getPositionId());
} else {
if (!(appUserDetail.getPositionId().equals(1))) {
detailBiz.updateUserPositionByUserId(userId, appShareholderDetail.getPositionId());
}
}
}
appShareholderDetail.setIsQuit(SHAREHOLDERDE_IS_TRUE);
//修改
Integer companyId = Integer.valueOf(company);
updateSelectiveById(appShareholderDetail);
appShareholderDetailChangeRecordBiz.addAppShareholderDetailChangeRecord(updAppShareholderDetail, updUserId, SHAREHOLDERDE_IS_TRUE);
}
} }
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -373,7 +435,7 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper, ...@@ -373,7 +435,7 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
Integer id = appShareholderDetailDTO.getId() == null ? 0 : appShareholderDetailDTO.getId(); Integer id = appShareholderDetailDTO.getId() == null ? 0 : appShareholderDetailDTO.getId();
BeanUtils.copyProperties(appShareholderDetailDTO, appShareholderDetail); BeanUtils.copyProperties(appShareholderDetailDTO, appShareholderDetail);
appShareholderDetail.setPositionId(positionId); appShareholderDetail.setPositionId(positionId);
appShareholderDetailDTO.setUserId(userId); appShareholderDetail.setUserId(userId);
addUserFindId(appShareholderDetail); addUserFindId(appShareholderDetail);
//插入记录表 //插入记录表
appShareholderDetailChangeRecordBiz.addAppShareholderDetailChangeRecord(appShareholderDetail, operatorId, SHAREHOLDERDE_IS_TRUE); appShareholderDetailChangeRecordBiz.addAppShareholderDetailChangeRecord(appShareholderDetail, operatorId, SHAREHOLDERDE_IS_TRUE);
......
...@@ -23,4 +23,10 @@ public interface AppShareholderDetailMapper extends Mapper<AppShareholderDetail> ...@@ -23,4 +23,10 @@ public interface AppShareholderDetailMapper extends Mapper<AppShareholderDetail>
@Param("positionId") Integer positionId, @Param("positionId") Integer positionId,
@Param("companyId") Integer companyId); @Param("companyId") Integer companyId);
void updShareHolderIsQuit(@Param("phone") String phone, @Param("companyId") Integer companyId);
Integer selectMaxShareHolderByUserIdOrPhone(
@Param("phone") String phone,
@Param("userId") Integer userId);
} }
...@@ -14,6 +14,38 @@ ...@@ -14,6 +14,38 @@
<result property="positionId" column="position_id"/> <result property="positionId" column="position_id"/>
</resultMap> </resultMap>
<select id="selectMaxShareHolderByUserIdOrPhone" resultType="java.lang.Integer">
select max(`position_id`) from `app_shareholder_detail` where `is_quit`=0
<choose>
<when test="userId != null and (phone == null or phone != '')">
and `user_id`=#{userId}
</when>
<when test="phone != null and phone != '' and userId == null">
and `phone`=#{phone}
</when>
<otherwise>
and `user_id`=#{userId}
</otherwise>
</choose>
</select>
<select id="updShareHolderIsQuit" resultType="com.github.wxiaoqi.security.admin.entity.AppShareholderDetail">
UPDATE `app_shareholder_detail`
SET
<if test="phone!=null">
`is_quit`=#{phone}
</if>
WHERE
1 = 1
<if test="phone!=null">
and `phone`=#{phone}
</if>
<if test="companyId!=null">
and `company_id`=#{companyId}
</if>
</select>
<select id="selectShareHolderByUserIdOrPhone" resultType="java.lang.Integer"> <select id="selectShareHolderByUserIdOrPhone" resultType="java.lang.Integer">
select min(`position_id`) from `app_shareholder_detail` where `is_quit`=0 select min(`position_id`) from `app_shareholder_detail` where `is_quit`=0
<choose> <choose>
...@@ -71,7 +103,7 @@ ...@@ -71,7 +103,7 @@
<if test="companyId!=null"> <if test="companyId!=null">
and find_in_set(#{companyId}, a.companyIdArray) and find_in_set(#{companyId}, a.companyIdArray)
</if> </if>
</select> </select>
<resultMap id="detail" type="com.github.wxiaoqi.security.admin.entity.AppShareholderDetail"> <resultMap id="detail" type="com.github.wxiaoqi.security.admin.entity.AppShareholderDetail">
<result property="id" column="id"/> <result property="id" column="id"/>
......
...@@ -211,6 +211,6 @@ public interface VehicleFeign { ...@@ -211,6 +211,6 @@ public interface VehicleFeign {
@GetMapping("/branchCompany/company_info") @GetMapping("/branchCompany/company_info")
Map<Integer, String> findCompanyMap(); Map<Integer, String> findCompanyMap();
@RequestMapping(value ="/branchCompany/{id}",method = RequestMethod.GET) /* @RequestMapping(value ="/branchCompany/{id}",method = RequestMethod.GET)
RestResponse<BranchCompany> get(@PathVariable Integer id); RestResponse<BranchCompany> get(@PathVariable Integer id);*/
} }
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