KuaishouTransferAccountServiceImpl.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package com.ruixuan.jinniu.service.impl;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.ruixuan.common.core.domain.entity.SysUser;
  4. import com.ruixuan.common.utils.DateUtils;
  5. import com.ruixuan.common.utils.PageUtils;
  6. import com.ruixuan.jinniu.entity.KuaishouAccount;
  7. import com.ruixuan.jinniu.entity.KuaishouTransferAccount;
  8. import com.ruixuan.jinniu.mapper.KuaishouAccountMapper;
  9. import com.ruixuan.jinniu.mapper.KuaishouTransferAccountMapper;
  10. import com.ruixuan.jinniu.service.IKuaishouProjectMemberService;
  11. import com.ruixuan.jinniu.service.IKuaishouTransferAccountService;
  12. import com.ruixuan.system.service.ISysDeptService;
  13. import com.ruixuan.system.service.ISysUserService;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.stereotype.Service;
  16. import java.util.Arrays;
  17. import java.util.Collections;
  18. import java.util.List;
  19. /**
  20. * 账户转让记录Service业务层处理
  21. *
  22. * @author ruoyi
  23. * @date 2023-03-16
  24. */
  25. @Service
  26. public class KuaishouTransferAccountServiceImpl implements IKuaishouTransferAccountService {
  27. @Autowired
  28. private KuaishouTransferAccountMapper kuaishouTransferAccountMapper;
  29. @Autowired
  30. private KuaishouAccountMapper kuaishouAccountMapper;
  31. @Autowired
  32. private ISysUserService sysUserService;
  33. @Autowired
  34. private ISysDeptService deptService;
  35. @Autowired
  36. private IKuaishouProjectMemberService kuaishouProjectMemberService;
  37. /**
  38. * 查询账户转让记录
  39. *
  40. * @param id 账户转让记录主键
  41. * @return 账户转让记录
  42. */
  43. @Override
  44. public KuaishouTransferAccount selectKuaishouTransferAccountById(Long id) {
  45. return kuaishouTransferAccountMapper.selectKuaishouTransferAccountById(id);
  46. }
  47. /**
  48. * 查询账户转让记录列表
  49. *
  50. * @param kuaishouTransferAccount 账户转让记录
  51. * @return 账户转让记录
  52. */
  53. @Override
  54. public List<JSONObject> selectKuaishouTransferAccountList(Long userId) {
  55. String roleKey = sysUserService.getRoleKeyByUserId(userId);
  56. List<Long> userList;
  57. if ("operationsManager".equals(roleKey)) {
  58. //运营经理 可以看自己部门所有人
  59. Long deptId = deptService.getDeptIdByUserId(userId);
  60. userList = deptService.getDeptUserListByDeptId(deptId);
  61. } else if ("admin".equals(roleKey) || "directorOperations".equals(roleKey)) {
  62. userList = null;
  63. } else {
  64. return Collections.emptyList();
  65. }
  66. PageUtils.startPage();
  67. return kuaishouTransferAccountMapper.selectKuaishouTransferAccountList(userList);
  68. }
  69. /**
  70. * 新增账户转让记录
  71. *
  72. * @param kuaishouTransferAccount 账户转让记录
  73. * @return 结果
  74. */
  75. @Override
  76. public int insertKuaishouTransferAccount(KuaishouTransferAccount kuaishouTransferAccount) {
  77. return kuaishouTransferAccountMapper.insertKuaishouTransferAccount(kuaishouTransferAccount);
  78. }
  79. /**
  80. * 修改账户转让记录
  81. */
  82. @Override
  83. public int updateKuaishouTransferAccount(KuaishouTransferAccount kuaishouTransferAccount) {
  84. KuaishouTransferAccount transferAccount = kuaishouTransferAccountMapper.selectKuaishouTransferAccountById(kuaishouTransferAccount.getId());
  85. transferAccount.setStatus(kuaishouTransferAccount.getStatus());
  86. transferAccount.setAuditor(kuaishouTransferAccount.getAuditor());
  87. transferAccount.setRemarks(DateUtils.getDate());
  88. int i = kuaishouTransferAccountMapper.updateKuaishouTransferAccount(transferAccount);
  89. if (i > 0 && kuaishouTransferAccount.getStatus() == 1) {
  90. // 通过转让审核,账户运营人变为受让人
  91. SysUser sysUser = sysUserService.selectUserById(transferAccount.getAssignee());
  92. KuaishouAccount kuaishouAccount = new KuaishouAccount();
  93. kuaishouAccount.setAccountId(transferAccount.getAccountId());
  94. kuaishouAccount.setOperatorId(sysUser.getUserId());
  95. kuaishouAccount.setOperatorName(sysUser.getNickName());
  96. kuaishouAccountMapper.updateKuaishouAccountByAccountId(kuaishouAccount);
  97. //添加 参与项目人员
  98. JSONObject mem = new JSONObject();
  99. mem.put("projectId", transferAccount.getProjectId());
  100. mem.put("userIds", Arrays.asList(sysUser.getUserId()));
  101. kuaishouProjectMemberService.addProjectUsers(mem);
  102. }
  103. return i;
  104. }
  105. /**
  106. * 删除账户转让记录信息
  107. *
  108. * @param id 账户转让记录主键
  109. * @return 结果
  110. */
  111. @Override
  112. public int deleteKuaishouTransferAccountById(Long id) {
  113. return kuaishouTransferAccountMapper.deleteKuaishouTransferAccountById(id);
  114. }
  115. }