wcj 5 năm trước cách đây
mục cha
commit
f9f298bc99

+ 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
 }
 
 //删除部门

+ 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"
@@ -56,16 +57,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
 				})
 			}
 		}