zj
2024-06-03 287ac389edd047696d956afafdb855a93830bc0c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package com.nq.service.impl;
 
 
import com.github.pagehelper.PageHelper;
 
import com.github.pagehelper.PageInfo;
 
import com.nq.common.ServerResponse;
 
import com.nq.dao.AgentUserMapper;
 
import com.nq.dao.UserCashDetailMapper;
 
import com.nq.pojo.AgentUser;
 
import com.nq.pojo.User;
 
import com.nq.pojo.UserCashDetail;
 
import com.nq.service.IAgentUserService;
 
import com.nq.service.IUserCashDetailService;
 
import com.nq.service.IUserService;
 
 
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
 
import org.springframework.stereotype.Service;
 
 @Service("iUserCashDetailService")
 public class UserCashDetailServiceImpl implements IUserCashDetailService {
 
   @Autowired
   UserCashDetailMapper userCashDetailMapper;
 
   @Autowired
   IUserService iUserService;
 
   @Autowired
   IAgentUserService iAgentUserService;
 
   @Autowired
   AgentUserMapper agentUserMapper;
 
 
 
   public ServerResponse<PageInfo> findUserCashDetailList(Integer positionId, HttpServletRequest request, int pageNum, int pageSize) {
 
     PageHelper.startPage(pageNum, pageSize);
 
 
 
     User user = this.iUserService.getCurrentUser(request);
     if (user == null ){
       return ServerResponse.createBySuccessMsg("Please log in first");
     }
 
 
     List<UserCashDetail> userCashDetails = this.userCashDetailMapper.findUserCashDetailList(user.getId(), positionId);
 
 
 
     PageInfo pageInfo = new PageInfo(userCashDetails);
 
 
 
     return ServerResponse.createBySuccess(pageInfo);
 
   }
 
   public ServerResponse<PageInfo> listByAgent(Integer userId, String userName, Integer agentId, Integer positionId, HttpServletRequest request, int pageNum, int pageSize) {
 
     AgentUser currentAgent = this.iAgentUserService.getCurrentAgent(request);
     if (currentAgent ==null){
       return    ServerResponse.createByError("Please log in first",null);
     }
 
 
     if (agentId != null) {
 
       AgentUser agentUser = this.agentUserMapper.selectByPrimaryKey(agentId);
 
       if (agentUser.getParentId() != currentAgent.getId()) {
 
         return ServerResponse.createByErrorMsg("Positions held by non-subordinate agent users cannot be queried");
 
       }
 
     }
 
     Integer searchId = null;
 
     if (agentId == null) {
 
       searchId = currentAgent.getId();
 
     } else {
 
       searchId = agentId;
 
     }
 
     PageHelper.startPage(pageNum, pageSize);
 
     List<UserCashDetail> cashDetails = this.userCashDetailMapper.listByAgent(userId, userName, searchId, positionId);
 
     PageInfo pageInfo = new PageInfo(cashDetails);
 
     return ServerResponse.createBySuccess(pageInfo);
 
   }
 
   public ServerResponse<PageInfo> listByAdmin(Integer userId, String userName, Integer agentId, Integer positionId, int pageNum, int pageSize) {
 
     PageHelper.startPage(pageNum, pageSize);
 
     List<UserCashDetail> cashDetails = this.userCashDetailMapper.listByAdmin(userId, userName, agentId, positionId);
 
     PageInfo pageInfo = new PageInfo(cashDetails);
 
     return ServerResponse.createBySuccess(pageInfo);
 
   }
 
 
   public int deleteByUserId(Integer userId) { return this.userCashDetailMapper.deleteByUserId(userId); }
 
   public ServerResponse delCash(Integer cashId) {
     if (cashId == null) {
       return ServerResponse.createByErrorMsg("The delete id cannot be empty");
     }
     int updateCount = this.userCashDetailMapper.deleteByPrimaryKey(cashId);
     if (updateCount > 0) {
       return ServerResponse.createBySuccessMsg("Successfully deleted");
     }
     return ServerResponse.createByErrorMsg("Deletion failure");
   }
 
 }