Browse Source

添加积分成长

zzy.zhiyuan.foxmail 8 years ago
parent
commit
9507737293

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

@ -45,6 +45,26 @@ public abstract class ProfessorDao {
45 45
	@Update
46 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 68
	@UpdateWith
49 69
	@From(Professor.class)
50 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,6 +51,8 @@ public class Professor implements CreateTimeSupported, ModifyTimeSupported{
51 51
	private String phone;
52 52
	private String email;
53 53
	private Integer sortFirst;
54
	private Integer scoreValue;
55
	private Integer growthValue;
54 56
	
55 57
	private Organization organization;
56 58
	private List<Resource> resources;
@ -294,7 +296,7 @@ public class Professor implements CreateTimeSupported, ModifyTimeSupported{
294 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 300
	public Integer getSortFirst() {
299 301
		return sortFirst;
300 302
	}
@ -303,4 +305,22 @@ public class Professor implements CreateTimeSupported, ModifyTimeSupported{
303 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,6 +29,8 @@ public class AuthApplyService {
29 29
	private ProfessorDao professorDao;
30 30
	@Autowrie
31 31
	private OrgDao orgDao;
32
	@Autowrie
33
	private GrowthLogService growthLogService;
32 34

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

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

@ -38,6 +38,8 @@ public class ConsultService {
38 38
	private TidingsDao tidingsDao;
39 39
	@Autowrie
40 40
	private ConsultRejectDao consultRejectDao;
41
	@Autowrie
42
	private GrowthLogService growthLogService;
41 43
	
42 44
	public ConsultDao getConsultDao() {
43 45
		return consultDao;
@ -69,6 +71,12 @@ public class ConsultService {
69 71
	public void setConsultRejectDao(ConsultRejectDao consultRejectDao) {
70 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 81
	@Post
74 82
	@Path
@ -92,6 +100,10 @@ public class ConsultService {
92 100
		tidings.setTidingsContant(consult.getConsultContant());
93 101
		tidings.setReadStatus(1);
94 102
		this.tidingsDao.insert(con, tidings);
103
		//需求确认给专家增加积分
104
		if(consult.getDemandId() != null){
105
			this.growthLogService.demandConfirm(con, consult.getProfessorId());
106
		}
95 107
		return consultId;
96 108
	}
97 109
	
@ -104,8 +116,11 @@ public class ConsultService {
104 116
	@Post
105 117
	@Path("/agree")
106 118
	public void agreeConsult(@JdbcConn(true) Connection con,String consultId)throws SQLException{
119
		Consult consult = this.consultDao.query(con, consultId);
107 120
		//点击确认接受咨询,更新咨询状态为进行中
108 121
		this.consultDao.updateConsultStatus(con, consultId, 0);
122
		//接受咨询给专家增加积分
123
		this.growthLogService.consultReceive(con, consult.getProfessorId());
109 124
	}
110 125
	
111 126
	@Post
@ -136,6 +151,8 @@ public class ConsultService {
136 151
			this.consultDao.updateFinishTime(con, consultId,consultStatus);
137 152
			int finishConsult = this.consultDao.queryReceiveConsult(con, consult.getProfessorId());
138 153
			this.professorDao.updateConsultCount(con, consult.getProfessorId(), finishConsult);
154
			//咨询完成给咨询者增加积分
155
			this.growthLogService.consultFinish(con, consult.getConsultantId());
139 156
			return true;
140 157
		}
141 158
		return false;
@ -150,6 +167,12 @@ public class ConsultService {
150 167
			this.consultDao.updateAssess(con, consultId, assessStatus, assessStar, assessContant);
151 168
			BigDecimal avgStar = this.consultDao.queryStarLevel(con, consult.getProfessorId());
152 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 176
			return true;
154 177
		}
155 178
		return false;

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

@ -38,6 +38,8 @@ public class DemandService {
38 38
	private ImageService imageService;
39 39
	@Autowrie
40 40
	private OrgService orgService;
41
	@Autowrie
42
	private GrowthLogService growthLogService;
41 43
	
42 44
	public DemandDao getDemandDao() {
43 45
		return demandDao;
@ -69,6 +71,12 @@ public class DemandService {
69 71
	public void setOrgService(OrgService orgService) {
70 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 81
	@Post
74 82
	@Path
@ -88,6 +96,13 @@ public class DemandService {
88 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 108
	@Post

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

@ -27,6 +27,8 @@ public class InitUserService {
27 27
	private UserDao userDao;
28 28
	@Autowrie
29 29
	private ProfessorDao professorDao;
30
	@Autowrie
31
	private GrowthLogService growthLogService;
30 32
	
31 33
	
32 34
	public UserDao getUserDao() {
@ -45,6 +47,14 @@ public class InitUserService {
45 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 58
	@Get
49 59
	@Path("/user/{id}")
50 60
	public User getUser(@JdbcConn Connection con,@PathVar String id) throws SQLException{
@ -72,6 +82,12 @@ public class InitUserService {
72 82
		user.setUserType("0");
73 83
		user.setInviteCode(inviteCode);
74 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 91
		Professor professor = this.professorDao.queryOne(con, id);
76 92
		if(mobilePhone != null && (professor.getPhone() == null || professor.getPhone().isEmpty())){
77 93
			this.professorDao.updatePhone(con, id, mobilePhone);
@ -85,6 +101,12 @@ public class InitUserService {
85 101
	public void modifyMobilePhone(@JdbcConn(true) Connection con ,@RequestBody User user)throws SQLException{
86 102
		this.userDao.updateMobilePhone(con, user.getMobilePhone(), user.getId());
87 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 110
		Professor professor = this.professorDao.queryOne(con, user.getId());
89 111
		if(user.getMobilePhone() != null && (professor.getPhone() == null || professor.getPhone().isEmpty())){
90 112
			this.professorDao.updatePhone(con, user.getId(), user.getMobilePhone());

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

@ -47,6 +47,10 @@ import com.ekexiu.portal.util.Calculate;
47 47

48 48
@Path("/professor")
49 49
public class ProfessorService {
50
	@Autowrie
51
	private GrowthLogService growthLogService;
52
	@Autowrie
53
	private GrowthRuleService rule;
50 54
	@Autowrie
51 55
	private ArticleDao articleDao;
52 56
	@Autowrie
@ -84,7 +88,22 @@ public class ProfessorService {
84 88
	@Autowrie
85 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 107
	public ArticleDao getArticleDao() {
89 108
		return articleDao;
90 109
	}
@ -249,8 +268,22 @@ public class ProfessorService {
249 268
		}
250 269
		User user = this.userDao.query(con, professor.getId());
251 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 288
		this.professorDao.insert(con, professor);
256 289
		return professor.getId();
@ -437,6 +470,8 @@ public class ProfessorService {
437 470
	@Path("/passOrgAuth")
438 471
	public void passOrgAuth(@JdbcConn(true) Connection con,String id)throws SQLException{
439 472
		this.professorDao.updateOrgAuth(con, id, "1");
473
		//通过企业认证给用户增加积分
474
		this.growthLogService.authOrg(con, id);
440 475
	}
441 476
	
442 477
	@Post

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

@ -43,6 +43,8 @@ public class ResourceService {
43 43
	private ImageService imageService;
44 44
	@Autowrie
45 45
	private OperationDao operationDao;
46
	@Autowrie
47
	private GrowthLogService growthLogService;
46 48

47 49
	public ProfessorDao getProfessorDao() {
48 50
		return professorDao;
@ -100,6 +102,14 @@ public class ResourceService {
100 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 113
	@Post
104 114
	@Path
105 115
	public String insert(@JdbcConn(true) Connection con, Resource resource, @Nullable String fn) 
@ -110,6 +120,7 @@ public class ResourceService {
110 120
		}
111 121
		resource.setResourceId(resourceId);
112 122
		this.resourceDao.insert(con, resource);
123
		this.growthLogService.addResource(con, resource.getProfessorId());
113 124
		return resourceId;
114 125
	}
115 126
	
@ -123,6 +134,7 @@ public class ResourceService {
123 134
		}
124 135
		resource.setResourceId(resourceId);
125 136
		this.resourceDao.insert(con, resource);
137
		this.growthLogService.addResource(con, resource.getProfessorId());
126 138
		return resourceId;
127 139
	}
128 140

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

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

@ -59,6 +59,8 @@ public class SysService {
59 59
	private MailService mailservice;
60 60
	@Autowrie
61 61
	private MobilePhoneService mobilePhoneServcie;
62
	@Autowrie
63
	private GrowthLogService growthLogService;
62 64
63 65
	private String bindMailSubject;
64 66
@ -179,6 +181,14 @@ public class SysService {
179 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 192
	public String getPhoneRetrievePasswordReplaceKey() {
183 193
		return phoneRetrievePasswordReplaceKey;
184 194
	}
@ -619,6 +629,9 @@ public class SysService {
619 629
	        user.setInviterId(inviterId);
620 630
	        user.setActiveTime(DATE.format(new Date()));
621 631
			this.userDao.insert(con, user);
632
			if(inviterId != null){
633
				this.growthLogService.invite(con, inviterId);
634
			}
622 635
			return user.getId();
623 636
		} finally {
624 637
			JfwAppContext.removeCachedObject(state);
@ -655,6 +668,9 @@ public class SysService {
655 668
			user.setActiveTime(DATE.format(new Date()));
656 669
			this.userDao.insert(con, user);
657 670
			con.commit();
671
			if(sc.getValue() != null){
672
				this.growthLogService.invite(con, sc.getValue());
673
			}
658 674
		} catch (SQLException e) {
659 675
			try {
660 676
				con.rollback();
@ -1083,7 +1099,9 @@ public class SysService {
1083 1099
			if (professor.getPhone() == null || professor.getPhone().isEmpty()) {
1084 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 1105
		} finally {
1088 1106
			JfwAppContext.removeCachedObject(key);
1089 1107
		}
@ -1241,7 +1259,9 @@ public class SysService {
1241 1259
			if (professor.getPhone() == null || professor.getPhone().isEmpty()) {
1242 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 1265
		} finally {
1246 1266
			JfwAppContext.removeCachedObject(state);
1247 1267
		}