Commit 94440daf by Huang Linyu

后台 - 会服 - 绑定管理员 增加可以绑定第二个管理员

parent a9e91b5a
......@@ -30,10 +30,11 @@ public class CommuneAdmDao extends GenericHibernateDao<CommuneAdm, Integer>{
public PagedEntityBean<CommuneAdmBean> queryAdmBeanList(Object obj) {
CommuneAdmQuery query = (CommuneAdmQuery) obj;
StringBuffer sb = new StringBuffer();
sb.append("SELECT sql_calc_found_rows a.id,a.uid,a.id as communeExtId,a.drawer,a.mobilePhone,a.userName,a.birthday,c.vipGrade,c.communeAgainTime,d.nickName AS bindedAdm,b.bindTime,b.labels,a.customerRegion ,a.checkedRegion ");
sb.append("SELECT sql_calc_found_rows a.id,a.uid,a.id as communeExtId,a.drawer,a.mobilePhone,a.userName,a.birthday,c.vipGrade,c.communeAgainTime,d.nickName AS bindedAdm,b.bindTime,b.labels,a.customerRegion ,a.checkedRegion, e.nickName AS bindedAdm2,b.bindTime2 ");
sb.append(" FROM usr_commune_ext a LEFT JOIN usr_commune_adm b ON a.id = b.communeExtId");
sb.append(" LEFT JOIN bsc_userext c ON a.uid = c.uid");
sb.append(" LEFT JOIN adm_users d ON b.admUserId = d.id");
sb.append(" LEFT JOIN adm_users e ON b.admUserId2 = e.id");
sb.append(" WHERE 1=1");
if (StringUtils.isNotBlank(query.getUserName())) {
......@@ -55,6 +56,13 @@ public class CommuneAdmDao extends GenericHibernateDao<CommuneAdm, Integer>{
}else if (StringUtils.isNotBlank(query.getBindedAdm())) {
sb.append(" AND d.username LIKE '%"+query.getBindedAdm()+"%'");
}
if ("0".equals(query.getBindedAdm2())) {
sb.append(" AND e.username is null");
}else if ("1".equals(query.getBindedAdm2())) {
sb.append(" AND e.username is not null");
}else if (StringUtils.isNotBlank(query.getBindedAdm2())) {
sb.append(" AND e.username LIKE '%"+query.getBindedAdm2()+"%'");
}
if (query.getCheckedRegion() != null && query.getCheckedRegion() != 0) {
......@@ -147,8 +155,14 @@ public class CommuneAdmDao extends GenericHibernateDao<CommuneAdm, Integer>{
* @param communeExtId
* @return
*/
public int deleteByCommuneExtId(int communeExtId) {
String sql = " update usr_commune_adm set unbindFlag=1,admUserId=NULL WHERE communeExtId="+communeExtId;
public int deleteByCommuneExtId(int communeExtId, Integer rids) {
String sql ="";
if(rids == 1){
sql = " update usr_commune_adm set admUserId=NULL WHERE communeExtId="+communeExtId;
}
if(rids == 2){
sql = " update usr_commune_adm set admUserId2=NULL WHERE communeExtId="+communeExtId;
}
int rlt = this.getSession().createSQLQuery(sql).executeUpdate();
return rlt;
}
......@@ -156,7 +170,7 @@ public class CommuneAdmDao extends GenericHibernateDao<CommuneAdm, Integer>{
@SuppressWarnings("unchecked")
public CommuneAdm findByCommuneExtId(Integer communeExtId) {
String hql = " from CommuneAdm where communeExtId = "+communeExtId;
Query query = this.getSession().createQuery(hql);
Query query = this.getSession().createQuery(hql);
List<CommuneAdm> admList = query.list();
if(admList.size()>0){
return admList.get(0);
......@@ -169,6 +183,17 @@ public class CommuneAdmDao extends GenericHibernateDao<CommuneAdm, Integer>{
String sql = "update usr_commune_adm set admUserId = "+admUserId+",bindTime=now() where communeExtId = "+tmp_communeExtId ;
return this.getSession().createSQLQuery(sql).executeUpdate();
}
/**
* 重新绑定第二个会服
* @param tmp_communeExtId
* @param admUserId
* @return
*/
public int rebind2(Integer tmp_communeExtId, int admUserId) {
String sql = "update usr_commune_adm set admUserId2 = "+admUserId+",bindTime2=now() where communeExtId = "+tmp_communeExtId ;
return this.getSession().createSQLQuery(sql).executeUpdate();
}
public int updateLabelsByCommuneExtId(Integer communeExtId, String labels) {
String sql = "update usr_commune_adm set labels = '"+labels+"' where communeExtId = "+communeExtId ;
......
......@@ -64,6 +64,20 @@ public class CommuneAdm implements java.io.Serializable {
private Date bindTime;
/**
* 绑定的会服id
*/
@Column(name = "admUserId2")
private Integer admUserId2;
/**
* 绑定时间
*/
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "bindTime2", length = 20)
private Date bindTime2;
/**
* 微信备注
*/
@Column(name = "wechatRemark")
......@@ -159,6 +173,22 @@ public class CommuneAdm implements java.io.Serializable {
public void setUnbindFlag(Integer unbindFlag) {
this.unbindFlag = unbindFlag;
}
public Integer getAdmUserId2() {
return admUserId2;
}
public void setAdmUserId2(Integer admUserId2) {
this.admUserId2 = admUserId2;
}
public Date getBindTime2() {
return bindTime2;
}
public void setBindTime2(Date bindTime2) {
this.bindTime2 = bindTime2;
}
}
......@@ -102,17 +102,27 @@ public class CommuneAdmService {
@SuppressWarnings("unchecked")
public int batchBind(Map<String,Object> map){
List<Object> communeExtIds = (ArrayList<Object>) map.get("communeExtIds");
Integer rids = (Integer)map.get("rids");
int returnNum = 0;
for(Object communeExtId : communeExtIds){
Integer tmp_communeExtId = Integer.parseInt((String) communeExtId);
CommuneAdm communeAdmed = communeAdmDao.findByCommuneExtId(tmp_communeExtId);
if(communeAdmed!=null){
returnNum += communeAdmDao.rebind(tmp_communeExtId,(int) map.get("admUserId"));
if(rids == 1)
returnNum += communeAdmDao.rebind(tmp_communeExtId,(int) map.get("admUserId"));
else if(rids == 2)
returnNum += communeAdmDao.rebind2(tmp_communeExtId,(int) map.get("admUserId"));
}else{
CommuneAdm communeAdm = new CommuneAdm();
communeAdm.setCommuneExtId(tmp_communeExtId);
communeAdm.setBindTime(new Date());
communeAdm.setAdmUserId((int) map.get("admUserId"));
if(rids == 1){
communeAdm.setAdmUserId((int) map.get("admUserId"));
communeAdm.setBindTime(new Date());
}else if(rids == 2){
communeAdm.setAdmUserId2((int) map.get("admUserId"));
communeAdm.setBindTime2(new Date());
}
returnNum += communeAdmDao.save(communeAdm);
}
}
......@@ -130,9 +140,10 @@ public class CommuneAdmService {
@SuppressWarnings("unchecked")
public int batchUnbind(Map<String,Object> map){
List<Object> communeExtIds = (ArrayList<Object>) map.get("communeExtIds");
Integer rids = (Integer)map.get("rids");
int returnNum = 0;
for(Object communeExtId : communeExtIds){
returnNum += communeAdmDao.deleteByCommuneExtId(Integer.parseInt((String) communeExtId));
returnNum += communeAdmDao.deleteByCommuneExtId(Integer.parseInt((String) communeExtId), rids);
}
return returnNum;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment