|
package com.ekexiu.portal.service;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jfw.apt.annotation.Autowrie;
import org.jfw.apt.annotation.DefaultValue;
import org.jfw.apt.web.annotation.Path;
import org.jfw.apt.web.annotation.operate.Get;
import org.jfw.apt.web.annotation.operate.Post;
import org.jfw.apt.web.annotation.param.JdbcConn;
import org.jfw.util.StringUtil;
import org.jfw.util.exception.JfwBaseException;
import com.ekexiu.portal.dao.GrowthLogDao;
import com.ekexiu.portal.dao.ProfessorDao;
import com.ekexiu.portal.dao.UserDao;
import com.ekexiu.portal.po.GrowthLog;
import com.ekexiu.portal.po.Professor;
import com.ekexiu.portal.po.User;
import com.ekexiu.portal.pojo.InviteUserScore;
@Path("/growth")
public class GrowthLogService {
public static final String MAX_CREATE_TIME = "9";
private String dateFormat = "yyyyMMdd";
@Autowrie
private GrowthLogDao growthLogDao;
@Autowrie
private UserDao userDao;
@Autowrie
private ProfessorDao professorDao;
@Autowrie
private GrowthRuleService rule;
public String getDateFormat() {
return dateFormat;
}
public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
}
public GrowthLogDao getGrowthLogDao() {
return growthLogDao;
}
public void setGrowthLogDao(GrowthLogDao growthLogDao) {
this.growthLogDao = growthLogDao;
}
public UserDao getUserDao() {
return userDao;
}
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
public ProfessorDao getProfessorDao() {
return professorDao;
}
public void setProfessorDao(ProfessorDao professorDao) {
this.professorDao = professorDao;
}
public GrowthRuleService getRule() {
return rule;
}
public void setRule(GrowthRuleService rule) {
this.rule = rule;
}
@Get
@Path("/queryByPro")
public List<GrowthLog> queryByPro(@JdbcConn Connection con,String professorId,@DefaultValue("com.ekexiu.portal.service.GrowthLogService.MAX_CREATE_TIME") String createTime,@DefaultValue("20") int rows)throws SQLException{
return this.growthLogDao.queryList(con, professorId, createTime, rows);
}
@Get
@Path("/queryInvite")
public List<InviteUserScore> queryInvite(@JdbcConn Connection con,String professorId)throws SQLException{
return this.growthLogDao.queryInvite(con, professorId);
}
@Get
@Path("/queryScore")
public Map<String, Integer> queryScore(@JdbcConn Connection con,String professorId)throws SQLException{
int myScore = this.growthLogDao.queryMyScore(con, professorId);
int inviteScore= this.growthLogDao.queryInviteScore(con, professorId);
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("myScore", myScore);
map.put("inviteScore", inviteScore);
return map;
}
@Get
@Path("/inviteScore")
public int queryInviteScore(@JdbcConn Connection con,String professorId)throws SQLException{
return this.growthLogDao.queryInviteScore(con, professorId);
}
@Get
@Path("/qlInviter")
public List<String> queryInviterId(@JdbcConn Connection con,String professorId,@DefaultValue("com.ekexiu.portal.service.GrowthLogService.MAX_CREATE_TIME") String createTime,@DefaultValue("20") int rows)throws SQLException{
List<User> users = this.userDao.queryLimit(con, professorId, createTime, rows);
List<String> strings = new ArrayList<String>();
for (User user : users) {
strings.add(user.getId());
}
return strings;
}
@Get
@Path("/inviterCount")
public int queryInviterCount(@JdbcConn Connection con,String professorId)throws SQLException{
return this.userDao.queryInviter(con, professorId);
}
/**
* 分享专家
* @param con
* @param professorId 用户ID
* @return 分享成功并积分返回true,分享成功不积分返回false(每天分享前10次积分,之后不积分)
* @throws SQLException
*/
@Post
@Path("/sharePro")
public boolean sharePro(@JdbcConn(true) Connection con,String professorId)throws SQLException{
List<GrowthLog> logs = this.growthLogDao.queryShare(con, professorId, this.getDate()+"%");
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("2");
if(logs.size() < 10){
growthLog.setScore(this.rule.getShareProfessor());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
return true;
}else{
growthLog.setScore(0);
this.growthLogDao.insert(con, growthLog);
return false;
}
}
/**
* 分享文章
* @param con
* @param professorId 用户ID
* @return 分享成功并积分返回true,分享成功不积分返回false(每天分享前10次积分,之后不积分)
* @throws SQLException
*/
@Post
@Path("/shareArticle")
public boolean shareArticle(@JdbcConn(true) Connection con,String professorId)throws SQLException{
List<GrowthLog> logs = this.growthLogDao.queryShare(con, professorId, this.getDate()+"%");
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("3");
if(logs.size() < 10){
growthLog.setScore(this.rule.getShareArticle());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
return true;
}else{
growthLog.setScore(0);
this.growthLogDao.insert(con, growthLog);
return false;
}
}
/**
* 分享资源
* @param con
* @param professorId 用户ID
* @return 分享成功并积分返回true,分享成功不积分返回false(每天分享前10次积分,之后不积分)
* @throws SQLException
*/
@Post
@Path("/shareRes")
public boolean shareRes(@JdbcConn(true) Connection con,String professorId)throws SQLException{
List<GrowthLog> logs = this.growthLogDao.queryShare(con, professorId, this.getDate()+"%");
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("4");
if(logs.size() < 10){
growthLog.setScore(this.rule.getShareResource());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
return true;
}else{
growthLog.setScore(0);
this.growthLogDao.insert(con, growthLog);
return false;
}
}
/**
* 用户签到,第1天5分,连续2天6分,连续3天7分,连续4天8分,连续5天9分,连续5天以上10分
* @param con
* @param professorId 用户ID
* @throws SQLException
* @throws JfwBaseException -1:该用户今天已签到,不能再次签到
*/
@Post
@Path("/signIn")
public void signIn(@JdbcConn(true) Connection con,String professorId)throws SQLException, JfwBaseException{
//获取当天日期(年月日)
String today = this.getDate() + "%";
//获取前一天日期(年月日)
String lastDay = this.getLastDate() + "%";
GrowthLog log = this.growthLogDao.querySignIn(con, professorId, "5", today);
if(log != null){
throw new JfwBaseException(-1, "该用户今天已签到");
}
GrowthLog lastLog = this.growthLogDao.querySignIn(con, professorId, "5", lastDay);
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("5");
if(lastLog == null){
growthLog.setSignInDays(1);
growthLog.setScore(this.rule.getSignInOneDay());
}else{
int days = lastLog.getSignInDays();
growthLog.setSignInDays(days+1);
if(days > 5){
growthLog.setScore(this.rule.getSignInSixDays());
}else if(5 == days){
growthLog.setScore(this.rule.getSignInSixDays());
}else if(4 == days){
growthLog.setScore(this.rule.getSignInFiveDays());
}else if(3 == days){
growthLog.setScore(this.rule.getSignInFourDays());
}else if(2 == days){
growthLog.setScore(this.rule.getSignInThreeDays());
}else if(1 == days){
growthLog.setScore(this.rule.getSignInTwoDays());
}else{
growthLog.setScore(this.rule.getSignInOneDay());
}
}
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
}
/**
* 成功邀请一位好友注册科袖
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void invite(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("1");
growthLog.setScore(this.rule.getInviteProfessor());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("101");
log.setScore(this.rule.getInviteProfessorForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
@Post
@Path("/addResearchArea")
public void addResearchArea(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("6");
growthLog.setScore(this.rule.getAddResearchArea());
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
this.growthLogDao.insert(con, growthLog);
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("102");
log.setScore(this.rule.getAddResearchAreaForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
@Post
@Path("/researchAgree")
public void researchAgree(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("7");
growthLog.setScore(this.rule.getResearchAgree());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
}
@Post
@Path("/researchBeAgree")
public void researchBeAgree(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("8");
growthLog.setScore(this.rule.getResearchBeAgree());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
}
@Post
@Path("/addArticle")
public void addArticle(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("9");
growthLog.setScore(this.rule.getAddArticle());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("103");
log.setScore(this.rule.getAddArticleForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
@Post
@Path("/articleLeaveWord")
public void articleLeaveWord(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("10");
growthLog.setScore(this.rule.getArticleLeaveWord());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
}
@Post
@Path("/articleBeleaveWord")
public void articleBeleaveWord(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("11");
growthLog.setScore(this.rule.getArticleBeleaveWord());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
}
/**
* 发布资源
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void addResource(@JdbcConn(true) Connection con, String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("12");
growthLog.setScore(this.rule.getAddResource());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("104");
log.setScore(this.rule.getAddResourceForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 删除资源
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void deleteResource(@JdbcConn(true) Connection con, String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("-12");
growthLog.setScore(-this.rule.getAddResource());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("-104");
log.setScore(-this.rule.getAddResourceForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 通过实名认证
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void authRealName(@JdbcConn(true) Connection con,String professorId)throws SQLException{
List<GrowthLog> logs = this.growthLogDao.queryOperate(con, professorId, "13");
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("13");
if(logs.size() > 0){
growthLog.setScore(0);
this.growthLogDao.insert(con, growthLog);
}else{
growthLog.setScore(this.rule.getAuthRealName());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("105");
log.setScore(this.rule.getAuthRealNameForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
}
/**
* 通过专家认证
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void authExpert(@JdbcConn(true) Connection con,String professorId)throws SQLException{
List<GrowthLog> logs = this.growthLogDao.queryOperate(con, professorId, "14");
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("14");
if(logs.size() > 0){
growthLog.setScore(0);
this.growthLogDao.insert(con, growthLog);
}else{
growthLog.setScore(this.rule.getAuthExpert());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("106");
log.setScore(this.rule.getAuthExpertForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
}
/**
* 通过企业认证
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void authOrg(@JdbcConn(true) Connection con,String professorId)throws SQLException{
List<GrowthLog> logs = this.growthLogDao.queryOperate(con, professorId, "15");
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("15");
if(logs.size() > 0){
growthLog.setScore(0);
this.growthLogDao.insert(con, growthLog);
}else{
growthLog.setScore(this.rule.getAuthOrg());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("107");
log.setScore(this.rule.getAuthOrgForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
}
/**
* 接受咨询
* @param con
* @param professorId 用户(专家)ID
* @throws SQLException
*/
public void consultReceive(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("16");
growthLog.setScore(this.rule.getConsultReceive());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("108");
log.setScore(this.rule.getConsultReceiveForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 完成咨询
* @param con
* @param professorId 用户(咨询者)ID
* @throws SQLException
*/
public void consultFinish(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("17");
growthLog.setScore(this.rule.getConsultFinish());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("109");
log.setScore(this.rule.getConsultFinishForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 获得4星及以上评价
* @param con
* @param professorId 用户(专家)ID
* @throws SQLException
*/
public void receiveFourStar(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("18");
growthLog.setScore(this.rule.getReceiveFourStar());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("110");
log.setScore(this.rule.getReceiveFourStarForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 评价咨询
* @param con
* @param professorId 用户(咨询者)ID
* @throws SQLException
*/
public void consultAssess(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("19");
growthLog.setScore(this.rule.getConsultAssess());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("111");
log.setScore(this.rule.getConsultAssessForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 发布个人需求
* @param con
* @param professorId 用户(发布者)ID
* @throws SQLException
*/
public void addProDemand(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("20");
growthLog.setScore(this.rule.getAddProDemand());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("112");
log.setScore(this.rule.getAddProDemandForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 发布企业需求
* @param con
* @param professorId 用户(发布者)ID
* @throws SQLException
*/
public void addOrgDemand(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("21");
growthLog.setScore(this.rule.getAddOrgDemand());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("113");
log.setScore(this.rule.getAddOrgDemandForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 确认需求
* @param con
* @param professorId 用户(专家)ID
* @throws SQLException
*/
public void demandConfirm(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("22");
growthLog.setScore(this.rule.getDemandConfirm());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
User user = this.userDao.query(con, professorId);
if((user.getInviterId() != null) && (user.getInviterId().trim().length() == 32)){
Professor professor = this.professorDao.queryOne(con, user.getInviterId());
if(professor != null){
GrowthLog log = new GrowthLog();
log.setId(StringUtil.buildUUID());
log.setProfessorId(user.getInviterId());
log.setOperate("114");
log.setScore(this.rule.getDemandConfirmForInviter());
log.setInvitePro(professorId);
this.growthLogDao.insert(con, log);
this.professorDao.updateScoreValue(con, user.getInviterId(), log.getScore());
this.professorDao.updateGrowthValue(con, user.getInviterId(), log.getScore());
}
}
}
/**
* 绑定手机
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void bindMobile(@JdbcConn(true) Connection con,String professorId)throws SQLException{
List<GrowthLog> logs = this.growthLogDao.queryOperate(con, professorId, "23");
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("23");
if(logs.size() > 0){
growthLog.setScore(0);
this.growthLogDao.insert(con, growthLog);
}else{
growthLog.setScore(this.rule.getBindMobile());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
}
}
/**
* 首次绑定手机
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void firstBindMobile(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("23");
growthLog.setScore(this.rule.getBindMobile());
this.growthLogDao.insert(con, growthLog);
}
/**
* 绑定邮箱
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void bindEmail(@JdbcConn(true) Connection con,String professorId)throws SQLException{
List<GrowthLog> logs = this.growthLogDao.queryOperate(con, professorId, "24");
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("24");
if(logs.size() > 0){
growthLog.setScore(0);
this.growthLogDao.insert(con, growthLog);
}else{
growthLog.setScore(this.rule.getBindEmail());
this.growthLogDao.insert(con, growthLog);
this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
}
}
/**
* 首次绑定邮箱
* @param con
* @param professorId 用户ID
* @throws SQLException
*/
public void firstBindEmail(@JdbcConn(true) Connection con,String professorId)throws SQLException{
GrowthLog growthLog = new GrowthLog();
growthLog.setId(StringUtil.buildUUID());
growthLog.setProfessorId(professorId);
growthLog.setOperate("24");
growthLog.setScore(this.rule.getBindEmail());
this.growthLogDao.insert(con, growthLog);
}
private String getDate(){
SimpleDateFormat sdf = new SimpleDateFormat(this.dateFormat);
return sdf.format(new Date());
}
private String getLastDate(){
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH, -1);
SimpleDateFormat sdf = new SimpleDateFormat(this.dateFormat);
return sdf.format(calendar.getTime());
}
}
|