Browse Source

添加积分成长

zzy.zhiyuan.foxmail 8 years ago
parent
commit
9507737293

+ 20 - 0
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

45
	@Update
45
	@Update
46
	public abstract int update(Connection con, Professor professor) throws SQLException;
46
	public abstract int update(Connection con, Professor professor) throws SQLException;
47
	
47
	
48
	public int updateScoreValue(Connection con,String id,Integer scoreValue)throws SQLException{
49
		String sql = "UPDATE PROFESSOR SET SCORE_VALUE = SCORE_VALUE + " + scoreValue + " WHERE ID = '" + id + "'";
50
		PreparedStatement ps = con.prepareStatement(sql);
51
		try{
52
			return ps.executeUpdate();
53
		}finally{
54
			try{ps.close();}catch(Exception e){}
55
		}
56
	}
57
	
58
	public int updateGrowthValue(Connection con,String id,Integer growthValue)throws SQLException{
59
		String sql = "UPDATE PROFESSOR SET GROWTH_VALUE = GROWTH_VALUE + " + growthValue + " WHERE ID = '" + id + "'";
60
		PreparedStatement ps = con.prepareStatement(sql);
61
		try{
62
			return ps.executeUpdate();
63
		}finally{
64
			try{ps.close();}catch(Exception e){}
65
		}
66
	}
67
	
48
	@UpdateWith
68
	@UpdateWith
49
	@From(Professor.class)
69
	@From(Professor.class)
50
	public abstract int updatePhone(Connection con, String id, @Set String phone) throws SQLException;
70
	public abstract int updatePhone(Connection con, String id, @Set String phone) throws SQLException;

+ 21 - 1
src/main/java/com/ekexiu/portal/po/Professor.java

51
	private String phone;
51
	private String phone;
52
	private String email;
52
	private String email;
53
	private Integer sortFirst;
53
	private Integer sortFirst;
54
	private Integer scoreValue;
55
	private Integer growthValue;
54
	
56
	
55
	private Organization organization;
57
	private Organization organization;
56
	private List<Resource> resources;
58
	private List<Resource> resources;
294
		this.email = email;
296
		this.email = email;
295
	}
297
	}
296
298
297
	@Column(handlerClass=WIntHandler.class,dbType="INT",insertable=false,nullable=false,renewable=false,queryable=true)
299
	@Column(handlerClass=WIntHandler.class,dbType="INT",insertable=false,renewable=false)
298
	public Integer getSortFirst() {
300
	public Integer getSortFirst() {
299
		return sortFirst;
301
		return sortFirst;
300
	}
302
	}
303
		this.sortFirst = sortFirst;
305
		this.sortFirst = sortFirst;
304
	}
306
	}
305
307
308
	@Column(handlerClass=WIntHandler.class,dbType="INT",nullable=true,renewable=false)
309
	public Integer getScoreValue() {
310
		return scoreValue;
311
	}
312
313
	public void setScoreValue(Integer scoreValue) {
314
		this.scoreValue = scoreValue;
315
	}
316
317
	@Column(handlerClass=WIntHandler.class,dbType="INT",nullable=true,renewable=false)
318
	public Integer getGrowthValue() {
319
		return growthValue;
320
	}
321
322
	public void setGrowthValue(Integer growthValue) {
323
		this.growthValue = growthValue;
324
	}
325
306
}
326
}

+ 16 - 0
src/main/java/com/ekexiu/portal/service/AuthApplyService.java

29
	private ProfessorDao professorDao;
29
	private ProfessorDao professorDao;
30
	@Autowrie
30
	@Autowrie
31
	private OrgDao orgDao;
31
	private OrgDao orgDao;
32
	@Autowrie
33
	private GrowthLogService growthLogService;
32

34

33
	public AuthApplyDao getAuthApplyDao() {
35
	public AuthApplyDao getAuthApplyDao() {
34
		return authApplyDao;
36
		return authApplyDao;
62
		this.orgDao = orgDao;
64
		this.orgDao = orgDao;
63
	}
65
	}
64

66

67
	public GrowthLogService getGrowthLogService() {
68
		return growthLogService;
69
	}
70

71
	public void setGrowthLogService(GrowthLogService growthLogService) {
72
		this.growthLogService = growthLogService;
73
	}
74

65
	@Post
75
	@Post
66
	@Path("/realName")
76
	@Path("/realName")
67
	public void realNameAuth(@JdbcConn(true) Connection con,AuthApply authApply,String[] fns) throws SQLException, IOException{
77
	public void realNameAuth(@JdbcConn(true) Connection con,AuthApply authApply,String[] fns) throws SQLException, IOException{
110
		this.authApplyDao.updateSolveStatus(con,state,id);
120
		this.authApplyDao.updateSolveStatus(con,state,id);
111
		if(auth==1){
121
		if(auth==1){
112
			this.professorDao.updateAuthStatus(con, professorId, state);
122
			this.professorDao.updateAuthStatus(con, professorId, state);
123
			//通过实名认证给用户增加积分
124
			if(state==3){
125
				this.growthLogService.authRealName(con, professorId);
126
			}
113
		}else if(auth==2){
127
		}else if(auth==2){
114
			this.professorDao.updateAuthStatusExpert(con, professorId, state);
128
			this.professorDao.updateAuthStatusExpert(con, professorId, state);
115
			if(state==3){
129
			if(state==3){
116
				this.professorDao.updateAuthType(con, professorId, 1);
130
				this.professorDao.updateAuthType(con, professorId, 1);
131
				//通过专家认证给用户增加积分
132
				this.growthLogService.authExpert(con, professorId);
117
			}
133
			}
118
		}else if(auth==3){
134
		}else if(auth==3){
119
			this.orgDao.updateAuthStatus(con, professorId, state+"");
135
			this.orgDao.updateAuthStatus(con, professorId, state+"");

+ 23 - 0
src/main/java/com/ekexiu/portal/service/ConsultService.java

38
	private TidingsDao tidingsDao;
38
	private TidingsDao tidingsDao;
39
	@Autowrie
39
	@Autowrie
40
	private ConsultRejectDao consultRejectDao;
40
	private ConsultRejectDao consultRejectDao;
41
	@Autowrie
42
	private GrowthLogService growthLogService;
41
	
43
	
42
	public ConsultDao getConsultDao() {
44
	public ConsultDao getConsultDao() {
43
		return consultDao;
45
		return consultDao;
69
	public void setConsultRejectDao(ConsultRejectDao consultRejectDao) {
71
	public void setConsultRejectDao(ConsultRejectDao consultRejectDao) {
70
		this.consultRejectDao = consultRejectDao;
72
		this.consultRejectDao = consultRejectDao;
71
	}
73
	}
74
	public GrowthLogService getGrowthLogService() {
75
		return growthLogService;
76
	}
77
	public void setGrowthLogService(GrowthLogService growthLogService) {
78
		this.growthLogService = growthLogService;
79
	}
72
	
80
	
73
	@Post
81
	@Post
74
	@Path
82
	@Path
92
		tidings.setTidingsContant(consult.getConsultContant());
100
		tidings.setTidingsContant(consult.getConsultContant());
93
		tidings.setReadStatus(1);
101
		tidings.setReadStatus(1);
94
		this.tidingsDao.insert(con, tidings);
102
		this.tidingsDao.insert(con, tidings);
103
		//需求确认给专家增加积分
104
		if(consult.getDemandId() != null){
105
			this.growthLogService.demandConfirm(con, consult.getProfessorId());
106
		}
95
		return consultId;
107
		return consultId;
96
	}
108
	}
97
	
109
	
104
	@Post
116
	@Post
105
	@Path("/agree")
117
	@Path("/agree")
106
	public void agreeConsult(@JdbcConn(true) Connection con,String consultId)throws SQLException{
118
	public void agreeConsult(@JdbcConn(true) Connection con,String consultId)throws SQLException{
119
		Consult consult = this.consultDao.query(con, consultId);
107
		//点击确认接受咨询,更新咨询状态为进行中
120
		//点击确认接受咨询,更新咨询状态为进行中
108
		this.consultDao.updateConsultStatus(con, consultId, 0);
121
		this.consultDao.updateConsultStatus(con, consultId, 0);
122
		//接受咨询给专家增加积分
123
		this.growthLogService.consultReceive(con, consult.getProfessorId());
109
	}
124
	}
110
	
125
	
111
	@Post
126
	@Post
136
			this.consultDao.updateFinishTime(con, consultId,consultStatus);
151
			this.consultDao.updateFinishTime(con, consultId,consultStatus);
137
			int finishConsult = this.consultDao.queryReceiveConsult(con, consult.getProfessorId());
152
			int finishConsult = this.consultDao.queryReceiveConsult(con, consult.getProfessorId());
138
			this.professorDao.updateConsultCount(con, consult.getProfessorId(), finishConsult);
153
			this.professorDao.updateConsultCount(con, consult.getProfessorId(), finishConsult);
154
			//咨询完成给咨询者增加积分
155
			this.growthLogService.consultFinish(con, consult.getConsultantId());
139
			return true;
156
			return true;
140
		}
157
		}
141
		return false;
158
		return false;
150
			this.consultDao.updateAssess(con, consultId, assessStatus, assessStar, assessContant);
167
			this.consultDao.updateAssess(con, consultId, assessStatus, assessStar, assessContant);
151
			BigDecimal avgStar = this.consultDao.queryStarLevel(con, consult.getProfessorId());
168
			BigDecimal avgStar = this.consultDao.queryStarLevel(con, consult.getProfessorId());
152
			this.professorDao.updateStarLevel(con, consult.getProfessorId(), avgStar);
169
			this.professorDao.updateStarLevel(con, consult.getProfessorId(), avgStar);
170
			//评价一次咨询给咨询者增加积分
171
			this.growthLogService.consultAssess(con, consult.getConsultantId());
172
			//获得4星及以上评价给专家增加积分
173
			if(assessStar > 3){
174
				this.growthLogService.receiveFourStar(con, consult.getProfessorId());
175
			}
153
			return true;
176
			return true;
154
		}
177
		}
155
		return false;
178
		return false;

+ 15 - 0
src/main/java/com/ekexiu/portal/service/DemandService.java

38
	private ImageService imageService;
38
	private ImageService imageService;
39
	@Autowrie
39
	@Autowrie
40
	private OrgService orgService;
40
	private OrgService orgService;
41
	@Autowrie
42
	private GrowthLogService growthLogService;
41
	
43
	
42
	public DemandDao getDemandDao() {
44
	public DemandDao getDemandDao() {
43
		return demandDao;
45
		return demandDao;
69
	public void setOrgService(OrgService orgService) {
71
	public void setOrgService(OrgService orgService) {
70
		this.orgService = orgService;
72
		this.orgService = orgService;
71
	}
73
	}
74
	public GrowthLogService getGrowthLogService() {
75
		return growthLogService;
76
	}
77
	public void setGrowthLogService(GrowthLogService growthLogService) {
78
		this.growthLogService = growthLogService;
79
	}
72
	
80
	
73
	@Post
81
	@Post
74
	@Path
82
	@Path
88
				this.demandSubOrIndusDao.insert(con, subOrIndus);
96
				this.demandSubOrIndusDao.insert(con, subOrIndus);
89
			}
97
			}
90
		}
98
		}
99
		if("1".equals(demand.getDemandType())){
100
			//发布个人需求给发布者增加积分
101
			this.growthLogService.addProDemand(con, demand.getDemander());
102
		}else if("2".equals(demand.getDemandType())){
103
			//发布企业需求给发布者增加积分
104
			this.growthLogService.addOrgDemand(con, demand.getDemander());
105
		}
91
	}
106
	}
92
	
107
	
93
	@Post
108
	@Post

+ 22 - 0
src/main/java/com/ekexiu/portal/service/InitUserService.java

27
	private UserDao userDao;
27
	private UserDao userDao;
28
	@Autowrie
28
	@Autowrie
29
	private ProfessorDao professorDao;
29
	private ProfessorDao professorDao;
30
	@Autowrie
31
	private GrowthLogService growthLogService;
30
	
32
	
31
	
33
	
32
	public UserDao getUserDao() {
34
	public UserDao getUserDao() {
45
		this.professorDao = professorDao;
47
		this.professorDao = professorDao;
46
	}
48
	}
47
49
50
	public GrowthLogService getGrowthLogService() {
51
		return growthLogService;
52
	}
53
54
	public void setGrowthLogService(GrowthLogService growthLogService) {
55
		this.growthLogService = growthLogService;
56
	}
57
48
	@Get
58
	@Get
49
	@Path("/user/{id}")
59
	@Path("/user/{id}")
50
	public User getUser(@JdbcConn Connection con,@PathVar String id) throws SQLException{
60
	public User getUser(@JdbcConn Connection con,@PathVar String id) throws SQLException{
72
		user.setUserType("0");
82
		user.setUserType("0");
73
		user.setInviteCode(inviteCode);
83
		user.setInviteCode(inviteCode);
74
		this.userDao.insert(con, user);
84
		this.userDao.insert(con, user);
85
		if(mobilePhone != null && mobilePhone.trim().length() == 11){
86
			this.growthLogService.bindMobile(con, id);
87
		}
88
		if(email != null && !"".equals(email)){
89
			this.growthLogService.bindEmail(con, id);
90
		}
75
		Professor professor = this.professorDao.queryOne(con, id);
91
		Professor professor = this.professorDao.queryOne(con, id);
76
		if(mobilePhone != null && (professor.getPhone() == null || professor.getPhone().isEmpty())){
92
		if(mobilePhone != null && (professor.getPhone() == null || professor.getPhone().isEmpty())){
77
			this.professorDao.updatePhone(con, id, mobilePhone);
93
			this.professorDao.updatePhone(con, id, mobilePhone);
85
	public void modifyMobilePhone(@JdbcConn(true) Connection con ,@RequestBody User user)throws SQLException{
101
	public void modifyMobilePhone(@JdbcConn(true) Connection con ,@RequestBody User user)throws SQLException{
86
		this.userDao.updateMobilePhone(con, user.getMobilePhone(), user.getId());
102
		this.userDao.updateMobilePhone(con, user.getMobilePhone(), user.getId());
87
		this.userDao.updateEmail(con, user.getEmail(), user.getId());
103
		this.userDao.updateEmail(con, user.getEmail(), user.getId());
104
		if(user.getMobilePhone() != null && user.getMobilePhone().trim().length() == 11){
105
			this.growthLogService.bindMobile(con, user.getId());
106
		}
107
		if(user.getEmail() != null && !"".equals(user.getEmail())){
108
			this.growthLogService.bindEmail(con, user.getId());
109
		}
88
		Professor professor = this.professorDao.queryOne(con, user.getId());
110
		Professor professor = this.professorDao.queryOne(con, user.getId());
89
		if(user.getMobilePhone() != null && (professor.getPhone() == null || professor.getPhone().isEmpty())){
111
		if(user.getMobilePhone() != null && (professor.getPhone() == null || professor.getPhone().isEmpty())){
90
			this.professorDao.updatePhone(con, user.getId(), user.getMobilePhone());
112
			this.professorDao.updatePhone(con, user.getId(), user.getMobilePhone());

+ 38 - 3
src/main/java/com/ekexiu/portal/service/ProfessorService.java

47

47

48
@Path("/professor")
48
@Path("/professor")
49
public class ProfessorService {
49
public class ProfessorService {
50
	@Autowrie
51
	private GrowthLogService growthLogService;
52
	@Autowrie
53
	private GrowthRuleService rule;
50
	@Autowrie
54
	@Autowrie
51
	private ArticleDao articleDao;
55
	private ArticleDao articleDao;
52
	@Autowrie
56
	@Autowrie
84
	@Autowrie
88
	@Autowrie
85
	private ProjectDao projectDao;
89
	private ProjectDao projectDao;
86

90

87
	
91
	public GrowthLogService getGrowthLogService() {
92
		return growthLogService;
93
	}
94

95
	public void setGrowthLogService(GrowthLogService growthLogService) {
96
		this.growthLogService = growthLogService;
97
	}
98

99
	public GrowthRuleService getRule() {
100
		return rule;
101
	}
102

103
	public void setRule(GrowthRuleService rule) {
104
		this.rule = rule;
105
	}
106

88
	public ArticleDao getArticleDao() {
107
	public ArticleDao getArticleDao() {
89
		return articleDao;
108
		return articleDao;
90
	}
109
	}
249
		}
268
		}
250
		User user = this.userDao.query(con, professor.getId());
269
		User user = this.userDao.query(con, professor.getId());
251
		if(user != null){
270
		if(user != null){
252
			professor.setPhone(user.getMobilePhone());
253
			professor.setEmail(user.getEmail());
271
			int value = 0;
272
			if(user.getMobilePhone() != null && user.getMobilePhone().trim().length() == 11){
273
				professor.setPhone(user.getMobilePhone());
274
				value = value + this.rule.getBindMobile();
275
				this.growthLogService.firstBindMobile(con, professor.getId());
276
			}
277
			if(user.getEmail() != null && !"".equals(user.getEmail())){
278
				professor.setEmail(user.getEmail());
279
				value = value + this.rule.getBindEmail();
280
				this.growthLogService.firstBindEmail(con, professor.getId());
281
			}
282
			professor.setScoreValue(value);
283
			professor.setGrowthValue(value);
284
		}else{
285
			professor.setScoreValue(0);
286
			professor.setGrowthValue(0);
254
		}
287
		}
255
		this.professorDao.insert(con, professor);
288
		this.professorDao.insert(con, professor);
256
		return professor.getId();
289
		return professor.getId();
437
	@Path("/passOrgAuth")
470
	@Path("/passOrgAuth")
438
	public void passOrgAuth(@JdbcConn(true) Connection con,String id)throws SQLException{
471
	public void passOrgAuth(@JdbcConn(true) Connection con,String id)throws SQLException{
439
		this.professorDao.updateOrgAuth(con, id, "1");
472
		this.professorDao.updateOrgAuth(con, id, "1");
473
		//通过企业认证给用户增加积分
474
		this.growthLogService.authOrg(con, id);
440
	}
475
	}
441
	
476
	
442
	@Post
477
	@Post

+ 14 - 0
src/main/java/com/ekexiu/portal/service/ResourceService.java

43
	private ImageService imageService;
43
	private ImageService imageService;
44
	@Autowrie
44
	@Autowrie
45
	private OperationDao operationDao;
45
	private OperationDao operationDao;
46
	@Autowrie
47
	private GrowthLogService growthLogService;
46

48

47
	public ProfessorDao getProfessorDao() {
49
	public ProfessorDao getProfessorDao() {
48
		return professorDao;
50
		return professorDao;
100
		this.imagesService = imagesService;
102
		this.imagesService = imagesService;
101
	}
103
	}
102

104

105
	public GrowthLogService getGrowthLogService() {
106
		return growthLogService;
107
	}
108

109
	public void setGrowthLogService(GrowthLogService growthLogService) {
110
		this.growthLogService = growthLogService;
111
	}
112

103
	@Post
113
	@Post
104
	@Path
114
	@Path
105
	public String insert(@JdbcConn(true) Connection con, Resource resource, @Nullable String fn) 
115
	public String insert(@JdbcConn(true) Connection con, Resource resource, @Nullable String fn) 
110
		}
120
		}
111
		resource.setResourceId(resourceId);
121
		resource.setResourceId(resourceId);
112
		this.resourceDao.insert(con, resource);
122
		this.resourceDao.insert(con, resource);
123
		this.growthLogService.addResource(con, resource.getProfessorId());
113
		return resourceId;
124
		return resourceId;
114
	}
125
	}
115
	
126
	
123
		}
134
		}
124
		resource.setResourceId(resourceId);
135
		resource.setResourceId(resourceId);
125
		this.resourceDao.insert(con, resource);
136
		this.resourceDao.insert(con, resource);
137
		this.growthLogService.addResource(con, resource.getProfessorId());
126
		return resourceId;
138
		return resourceId;
127
	}
139
	}
128

140

227
	public boolean delete(@JdbcConn(true) Connection con, @PathVar String resourceId) throws SQLException {
239
	public boolean delete(@JdbcConn(true) Connection con, @PathVar String resourceId) throws SQLException {
228
		List<Operation> operations = this.operationDao.queryResourceId(con, resourceId);
240
		List<Operation> operations = this.operationDao.queryResourceId(con, resourceId);
229
		if(operations.isEmpty()){
241
		if(operations.isEmpty()){
242
			Resource resource = this.resourceDao.queryInfo(con, resourceId);
230
			this.imageDao.deleteRes(con, resourceId);
243
			this.imageDao.deleteRes(con, resourceId);
231
			this.resourceDao.delete(con, resourceId);
244
			this.resourceDao.delete(con, resourceId);
232
			this.watchDao.deleteWatch(con, resourceId);
245
			this.watchDao.deleteWatch(con, resourceId);
246
			this.growthLogService.deleteResource(con, resource.getProfessorId());
233
			return true;
247
			return true;
234
		}else{
248
		}else{
235
			return false;
249
			return false;

+ 22 - 2
src/main/java/com/ekexiu/portal/service/SysService.java

59
	private MailService mailservice;
59
	private MailService mailservice;
60
	@Autowrie
60
	@Autowrie
61
	private MobilePhoneService mobilePhoneServcie;
61
	private MobilePhoneService mobilePhoneServcie;
62
	@Autowrie
63
	private GrowthLogService growthLogService;
62
64
63
	private String bindMailSubject;
65
	private String bindMailSubject;
64
66
179
		this.mobilePhoneServcie = mobilePhoneServcie;
181
		this.mobilePhoneServcie = mobilePhoneServcie;
180
	}
182
	}
181
183
184
	public GrowthLogService getGrowthLogService() {
185
		return growthLogService;
186
	}
187
188
	public void setGrowthLogService(GrowthLogService growthLogService) {
189
		this.growthLogService = growthLogService;
190
	}
191
182
	public String getPhoneRetrievePasswordReplaceKey() {
192
	public String getPhoneRetrievePasswordReplaceKey() {
183
		return phoneRetrievePasswordReplaceKey;
193
		return phoneRetrievePasswordReplaceKey;
184
	}
194
	}
619
	        user.setInviterId(inviterId);
629
	        user.setInviterId(inviterId);
620
	        user.setActiveTime(DATE.format(new Date()));
630
	        user.setActiveTime(DATE.format(new Date()));
621
			this.userDao.insert(con, user);
631
			this.userDao.insert(con, user);
632
			if(inviterId != null){
633
				this.growthLogService.invite(con, inviterId);
634
			}
622
			return user.getId();
635
			return user.getId();
623
		} finally {
636
		} finally {
624
			JfwAppContext.removeCachedObject(state);
637
			JfwAppContext.removeCachedObject(state);
655
			user.setActiveTime(DATE.format(new Date()));
668
			user.setActiveTime(DATE.format(new Date()));
656
			this.userDao.insert(con, user);
669
			this.userDao.insert(con, user);
657
			con.commit();
670
			con.commit();
671
			if(sc.getValue() != null){
672
				this.growthLogService.invite(con, sc.getValue());
673
			}
658
		} catch (SQLException e) {
674
		} catch (SQLException e) {
659
			try {
675
			try {
660
				con.rollback();
676
				con.rollback();
1083
			if (professor.getPhone() == null || professor.getPhone().isEmpty()) {
1099
			if (professor.getPhone() == null || professor.getPhone().isEmpty()) {
1084
				this.professorDao.updateEmail(con, sc.getKey(), sc.getValue());
1100
				this.professorDao.updateEmail(con, sc.getKey(), sc.getValue());
1085
			}
1101
			}
1086
			return this.userDao.updateEmail(con, sc.getValue(), sc.getKey()) > 0;
1102
			this.userDao.updateEmail(con, sc.getValue(), sc.getKey());
1103
			this.growthLogService.bindEmail(con, sc.getKey());
1104
			return true;
1087
		} finally {
1105
		} finally {
1088
			JfwAppContext.removeCachedObject(key);
1106
			JfwAppContext.removeCachedObject(key);
1089
		}
1107
		}
1241
			if (professor.getPhone() == null || professor.getPhone().isEmpty()) {
1259
			if (professor.getPhone() == null || professor.getPhone().isEmpty()) {
1242
				this.professorDao.updatePhone(con, userid, mobilePhone);
1260
				this.professorDao.updatePhone(con, userid, mobilePhone);
1243
			}
1261
			}
1244
			return this.userDao.updateMobilePhone(con, mobilePhone, userid) > 0;
1262
			this.userDao.updateMobilePhone(con, mobilePhone, userid);
1263
			this.growthLogService.bindMobile(con, userid);
1264
			return true;
1245
		} finally {
1265
		} finally {
1246
			JfwAppContext.removeCachedObject(state);
1266
			JfwAppContext.removeCachedObject(state);
1247
		}
1267
		}