Răsfoiți Sursa

Merge branch 'dev2.9.0' of http://39.105.157.10:10080/qmx/jy into dev2.9.0

zhangxinlei1996 5 ani în urmă
părinte
comite
4f9854f8b9

+ 2 - 2
src/jfw/modules/entniche/src/entity/department.go

@@ -109,12 +109,12 @@ func (d *Department) GetChildrens(ent_id, dept_id int) *[]*Department {
 
 //新增的时候,判断部门是否存在
 func (d *Department) AddIsExists(name string, ent_id int) bool {
-	return Mysql.CountBySql(`select count(1) from entniche_department where name=? and ent_id=?`, name, ent_id) > 0
+	return Mysql.CountBySql(`select count(1) from entniche_department where name=? and ent_id=? and pid<>0`, name, ent_id) > 0
 }
 
 //修改的时候,判断部门是否存在
 func (d *Department) UpdateIsExists(name string, ent_id, dept_id int) bool {
-	return Mysql.CountBySql(`select count(1) from entniche_department where name=? and ent_id=? and id<>?`, name, ent_id, dept_id) > 0
+	return Mysql.CountBySql(`select count(1) from entniche_department where name=? and ent_id=? and id<>? and pid<>0`, name, ent_id, dept_id) > 0
 }
 
 //删除部门

+ 23 - 16
src/jfw/modules/entniche/src/entity/entity.go

@@ -86,25 +86,32 @@ func (c *CurrentUser) EntInfo(userId string, entId int) *CurrentUser {
 	if phone == "" {
 		return currentUser
 	}
-	//角色、权限
-	r := Mysql.SelectBySql(`SELECT b.role_id,c.dept_id,d.name as dept_name,d.subdis as dept_subdis from entniche_user a 
-		LEFT JOIN entniche_user_role b on (a.id=b.user_id) 
-		LEFT JOIN entniche_department_user c on (a.id=c.user_id) 
-		LEFT JOIN entniche_department d on (d.ent_id=? and c.dept_id=d.id) 
-		where a.ent_id=? and a.phone=? order by a.id desc`, entId, entId, phone)
-	if r != nil && len(*r) > 0 {
-		role_id := qutil.IntAll((*r)[0]["role_id"])
-		if role_id == Role_admin_department {
-			currentUser.Role_admin_department = true
-		}
-		currentUser.Dept.Id = qutil.IntAll((*r)[0]["dept_id"])
-		currentUser.Dept.Name = (*r)[0]["dept_name"].(string)
-		currentUser.Dept.Subdis = qutil.IntAll((*r)[0]["dept_subdis"])
-	}
-	//
 	currentUser.Ent = VarEntInfo.GetById(entId)
 	if currentUser.Ent.Phone == phone {
 		currentUser.Role_admin_system = true
+		r := Mysql.SelectBySql(`SELECT id,name,subdis from entniche_department where ent_id=? and pid=0`, entId)
+		if r != nil && len(*r) > 0 {
+			department := JsonUnmarshal((*r)[0], &Department{}).(*Department)
+			if department != nil {
+				currentUser.Dept = department
+			}
+		}
+	} else {
+		//角色、权限
+		r := Mysql.SelectBySql(`SELECT b.role_id,c.dept_id,d.name as dept_name,d.subdis as dept_subdis from entniche_user a 
+			LEFT JOIN entniche_user_role b on (a.id=b.user_id) 
+			LEFT JOIN entniche_department_user c on (a.id=c.user_id) 
+			LEFT JOIN entniche_department d on (d.ent_id=? and c.dept_id=d.id) 
+			where a.ent_id=? and a.phone=? order by a.id desc`, entId, entId, phone)
+		if r != nil && len(*r) > 0 {
+			role_id := qutil.IntAll((*r)[0]["role_id"])
+			if role_id == Role_admin_department {
+				currentUser.Role_admin_department = true
+			}
+			currentUser.Dept.Id = qutil.IntAll((*r)[0]["dept_id"])
+			currentUser.Dept.Name = (*r)[0]["dept_name"].(string)
+			currentUser.Dept.Subdis = qutil.IntAll((*r)[0]["dept_subdis"])
+		}
 	}
 	return currentUser
 }

+ 0 - 2
src/jfw/modules/entniche/src/filter/sessionfilter.go

@@ -18,8 +18,6 @@ type sessionfilter struct {
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	session := l.App.SessionManager.Session(req, w)
 	//session.Set("userId", "5d6e142a25ef871f08a72662")
-	//session.Set("entId", 4)
-	//session.Set("entName", "王公子测试企业")
 	if session.Get("userId") == nil {
 		content, _ := json.MarshalIndent(map[string]interface{}{
 			"error_code": Error_code_1001,

+ 3 - 1
src/jfw/modules/entniche/src/service/ent/ent.go

@@ -29,8 +29,9 @@ func (a *Action) Myents() {
 		return
 	}
 	ents := []M{}
-	list := Mysql.SelectBySql(`SELECT DISTINCT a.id,a.name,a.phone,a.startdate,a.enddate from entniche_info a 
+	list := Mysql.SelectBySql(`SELECT DISTINCT a.id,a.name,a.phone,a.startdate,a.enddate,c.id as dept_id from entniche_info a 
 				LEFT JOIN entniche_user b on (a.id=b.ent_id) 
+				LEFT JOIN entniche_department c on (a.id=c.ent_id and c.pid=0) 
 				where a.phone=? or b.phone=? 
 				order by convert(a.name using gbk) COLLATE gbk_chinese_ci asc`, phone, phone)
 	if list != nil {
@@ -42,6 +43,7 @@ func (a *Action) Myents() {
 			ents = append(ents, M{
 				"name":         v["name"],
 				"id":           v["id"],
+				"dept_id":      v["dept_id"],
 				"startdate":    v["startdate"],
 				"enddate":      v["enddate"],
 				"admin_system": admin_system,

+ 21 - 10
src/jfw/modules/subscribepay/src/entity/entniche.go

@@ -1,6 +1,7 @@
 package entity
 
 import (
+	"database/sql"
 	"encoding/json"
 	"log"
 	qutil "qfw/util"
@@ -57,16 +58,26 @@ func (e *entnicheStruct) PayCallBack(param *CallBackParam) bool {
 					})
 				}
 			} else {
-				filter_id = util.Mysql.Insert("entniche_info", map[string]interface{}{
-					"name":       entname,
-					"industry":   industry,
-					"phone":      phone,
-					"admin_name": adminname,
-					"quota":      qutil.IntAll(filter["personnum"]),
-					"status":     1,
-					"createtime": nowFormat,
-					"startdate":  now.Unix(),
-					"enddate":    enddate.Unix(),
+				util.Mysql.ExecTx("商机管理支付成功", func(tx *sql.Tx) bool {
+					filter_id = util.Mysql.InsertByTx(tx, "entniche_info", map[string]interface{}{
+						"name":       entname,
+						"industry":   industry,
+						"phone":      phone,
+						"admin_name": adminname,
+						"quota":      qutil.IntAll(filter["personnum"]),
+						"status":     1,
+						"createtime": nowFormat,
+						"startdate":  now.Unix(),
+						"enddate":    enddate.Unix(),
+					})
+					dept_id := util.Mysql.InsertByTx(tx, "entniche_department", map[string]interface{}{
+						"pid":        0,
+						"name":       entname,
+						"ent_id":     filter_id,
+						"createtime": nowFormat,
+						"timestamp":  nowFormat,
+					})
+					return filter_id > 0 && dept_id > 0
 				})
 			}
 		}