编辑用户(如果类型变更,更新用户钱包)
列表回显调整
This commit is contained in:
+8
@@ -104,4 +104,12 @@ public class CqBaseEmpVo extends CqBaseEmployee implements Serializable {
|
||||
|
||||
//直接部门ID
|
||||
private String departIds;
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String cardNo;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phoneNum;
|
||||
}
|
||||
|
||||
+12
@@ -127,6 +127,18 @@ public class CqBaseEmployeePayController extends JeecgController<CqBaseEmployee,
|
||||
return cqBaseEmployeeService.saveEmpSub(sysUserSub);
|
||||
}
|
||||
|
||||
@AutoLog(value = "主用户编辑")
|
||||
@Operation(summary = "主用户编辑", description = "主用户编辑")
|
||||
@PutMapping(value = "/updateMainUserSubInfo")
|
||||
public Result<?> updateMainUserSubInfo(@RequestBody SysUserSub sysUserSub){
|
||||
if(StringUtils.isBlank(sysUserSub.getId())){
|
||||
return Result.error("用户ID不能为空");
|
||||
}
|
||||
Result<?> result = cqBaseEmployeeService.updateMainUserSubInfo(sysUserSub);
|
||||
Map<String, Object> stringMap = new HashMap<>();
|
||||
stringMap.put("userId", sysUserSub.getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 非正式、家庭用户编辑
|
||||
|
||||
+39
-4
@@ -95,6 +95,7 @@
|
||||
NULL AS emp_sysno, -- 对应字段在 sys_user_sub 中不存在,填 NULL
|
||||
sus.birthday AS emp_birthday,
|
||||
CONCAT(LEFT(sus.card_no, 3), '*************', RIGHT(sus.card_no, 2)) AS emp_idcard,
|
||||
sus.card_no,
|
||||
NULL AS emp_job, -- 对应字段在 sys_user_sub 中不存在,填 NULL
|
||||
NULL AS emp_group,
|
||||
NULL AS emp_position,
|
||||
@@ -130,6 +131,7 @@
|
||||
sus.work_no,
|
||||
sus.sex,
|
||||
CONCAT(LEFT(sus.phone, 3), '****', RIGHT(sus.phone, 4)) AS phone,
|
||||
sus.phone phoneNum,
|
||||
sus.create_time,
|
||||
sus.user_type,
|
||||
sus.main_user_id,
|
||||
@@ -187,6 +189,7 @@
|
||||
NULL AS emp_sysno, -- 对应字段在 sys_user_sub 中不存在,填 NULL
|
||||
sus.birthday AS emp_birthday,
|
||||
CONCAT(LEFT(sus.card_no, 3), '*************', RIGHT(sus.card_no, 2)) AS emp_idcard,
|
||||
sus.card_no,
|
||||
NULL AS emp_job, -- 对应字段在 sys_user_sub 中不存在,填 NULL
|
||||
NULL AS emp_group,
|
||||
NULL AS emp_position,
|
||||
@@ -208,15 +211,20 @@
|
||||
NULL AS work_strength,
|
||||
sus.del_flag,
|
||||
sus.is_sync,
|
||||
NULL AS secondDepartName, -- 对应字段在 sys_user_sub 中不存在,填 NULL
|
||||
NULL AS thirdDepartName,
|
||||
NULL AS dep_id,
|
||||
NULL AS depart_name,
|
||||
parent_depart.depart_name AS secondDepartName,
|
||||
direct_depart.depart_name AS thirdDepartName,
|
||||
CONCAT(
|
||||
IFNULL(parent_depart.depart_name, ''),
|
||||
IF(parent_depart.depart_name IS NOT NULL AND direct_depart.depart_name IS NOT NULL, '->', ''),
|
||||
IFNULL(direct_depart.depart_name, '')
|
||||
) AS departNames,
|
||||
sus.depart_ids as departIds,
|
||||
sus.username,
|
||||
sus.realname,
|
||||
sus.avatar,
|
||||
sus.sex,
|
||||
CONCAT(LEFT(sus.phone, 3), '****', RIGHT(sus.phone, 4)) AS phone,
|
||||
sus.phone phoneNum,
|
||||
sus.create_time,
|
||||
sus.user_type,
|
||||
sus.main_user_id,
|
||||
@@ -225,6 +233,12 @@
|
||||
sus.status
|
||||
FROM
|
||||
sys_user_sub sus
|
||||
LEFT JOIN sys_pay_depart direct_depart
|
||||
ON sus.depart_ids = direct_depart.id
|
||||
AND direct_depart.del_flag = '0'
|
||||
LEFT JOIN sys_pay_depart parent_depart
|
||||
ON direct_depart.parent_id = parent_depart.id
|
||||
AND parent_depart.del_flag = '0'
|
||||
WHERE 1 = 1
|
||||
AND sus.user_identity = 6 -- 根据需求过滤条件
|
||||
AND sus.del_flag = 0
|
||||
@@ -274,6 +288,27 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 查询子用户 -->
|
||||
<select id="selectChildrenByParentId" resultMap="userTreeResultMap">
|
||||
SELECT *
|
||||
FROM sys_user_sub
|
||||
WHERE main_user_id = #{parentId}
|
||||
and del_flag = 0
|
||||
<if test="realname != null and realname != ''">
|
||||
AND realname LIKE CONCAT('%', #{realname}, '%')
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
AND phone LIKE CONCAT('%', #{phone}, '%')
|
||||
</if>
|
||||
<if test="mainUserRelation != null and mainUserRelation != ''">
|
||||
AND main_user_relation = #{mainUserRelation}
|
||||
</if>
|
||||
<if test="userType != null and userType != ''">
|
||||
AND user_type = #{userType}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="updateIsStatusByMemberId" parameterType="map">
|
||||
UPDATE st_client_member_balance
|
||||
<set>
|
||||
|
||||
+2
@@ -26,6 +26,8 @@ public interface ICqBaseEmployeeService extends IService<CqBaseEmployee> {
|
||||
|
||||
Page<CqBaseEmpVo> queryListV3(Page<CqBaseEmpVo> pageList, CqBaseEmpVo baseEmpVo);
|
||||
|
||||
Result<?> updateMainUserSubInfo(SysUserSub jsonObject);
|
||||
|
||||
Result<?> updateEmpSub(SysUserSub jsonObject);
|
||||
|
||||
Result<?> cancellationAndRecovery(SysUserSubVo sysUserSub);
|
||||
|
||||
+32
@@ -1,5 +1,6 @@
|
||||
package org.jeecg.emp.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -12,6 +13,8 @@ import org.jeecg.emp.mapper.CqBaseEmployeeMapper;
|
||||
import org.jeecg.emp.service.ICqBaseEmployeeService;
|
||||
import org.jeecg.emp.vo.CqBaseEmpVo;
|
||||
import org.jeecg.emp.vo.DepartVo;
|
||||
import org.jeecg.payment.entity.StClientMemberBalance;
|
||||
import org.jeecg.payment.service.IStClientMemberBalanceService;
|
||||
import org.jeecg.system.service.ISysPayDepartService;
|
||||
import org.jeecg.system.service.ISysUserService;
|
||||
import org.jeecg.system.service.ISysUserSubService;
|
||||
@@ -49,6 +52,8 @@ public class CqBaseEmployeeServiceImpl extends ServiceImpl<CqBaseEmployeeMapper,
|
||||
|
||||
@Resource
|
||||
private ISysPayDepartService iSysPayDepartService;
|
||||
@Resource
|
||||
private IStClientMemberBalanceService iStClientMemberBalanceService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -115,6 +120,33 @@ public class CqBaseEmployeeServiceImpl extends ServiceImpl<CqBaseEmployeeMapper,
|
||||
return page.setRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> updateMainUserSubInfo(SysUserSub jsonObject){
|
||||
Result<?> result = new Result<SysUserSub>();
|
||||
try {
|
||||
//更新用户表
|
||||
SysUserSub sysUser = sysUserSubService.getById(jsonObject.getId());
|
||||
//判断用户类型是否有更新 0: 正式员工 1:非正式员工,2:家庭用户
|
||||
if(!sysUser.getUserType().equals(jsonObject.getUserType())){
|
||||
if(2 != jsonObject.getUserType()){
|
||||
//更新用户钱包
|
||||
LambdaUpdateWrapper<StClientMemberBalance> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(StClientMemberBalance::getMemberId, sysUser.getId());
|
||||
updateWrapper.set(StClientMemberBalance::getUserInnerType, jsonObject.getUserType());
|
||||
iStClientMemberBalanceService.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
BeanUtils.copyProperties(jsonObject, sysUser);
|
||||
sysUser.setUpdateTime(new Date());//设置创建时间
|
||||
sysUserService.editUserSub(sysUser);
|
||||
result.success("编辑成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> updateEmpSub(SysUserSub jsonObject) {
|
||||
Result<?> result = new Result<SysUserSub>();
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public interface ISysUserSubService extends IService<SysUserSub> {
|
||||
* innerUser = true 表示内部用户
|
||||
* innerUser = false 表示外部用户
|
||||
*/
|
||||
public void initializeUserWallet(List<String> memberId,Boolean innerUser);
|
||||
public void initializeUserWallet(List<String> memberId,Integer userType);
|
||||
/**
|
||||
* 删除用户
|
||||
* @param userId
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
sysUserSubMapper.insert(user);
|
||||
if(2 != user.getUserType()){//只有正式员工、非正式员工才创建钱包
|
||||
//创建钱包
|
||||
iSysUserSubService.initializeUserWallet(Collections.singletonList(user.getId()),false);
|
||||
iSysUserSubService.initializeUserWallet(Collections.singletonList(user.getId()),user.getUserType());
|
||||
}
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
+2
-6
@@ -42,7 +42,7 @@ public class SysUserSubServiceImpl extends ServiceImpl<SysUserSubMapper, SysUser
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void initializeUserWallet(List<String> memberIds,Boolean innerUser) {
|
||||
public void initializeUserWallet(List<String> memberIds,Integer userType) {
|
||||
if(CollectionUtil.isNotEmpty(memberIds)){
|
||||
memberIds.forEach(memberId->{
|
||||
// 根据 memberId 查询用户数据
|
||||
@@ -61,11 +61,7 @@ public class SysUserSubServiceImpl extends ServiceImpl<SysUserSubMapper, SysUser
|
||||
newBalance.setLastConsumptionTime(null);
|
||||
newBalance.setFirstTopUpTime(null);
|
||||
newBalance.setInvoiceTotal(BigDecimal.ZERO);
|
||||
if(innerUser){
|
||||
newBalance.setUserInnerType(0); // 默认内部用户
|
||||
} else {
|
||||
newBalance.setUserInnerType(1); // 默认外部用户
|
||||
}
|
||||
newBalance.setUserInnerType(userType);
|
||||
newBalance.setIsDel(0); // 默认未删除
|
||||
newBalance.setIsStatus(0);
|
||||
newBalance.setCreateBy("system"); // 默认创建人
|
||||
|
||||
Reference in New Issue
Block a user