Просмотр исходного кода

Merge branch 'master' into hotfix/v1.0.0.2

lianbingjie 2 лет назад
Родитель
Сommit
20c4dc148f
1 измененных файлов с 17 добавлено и 6 удалено
  1. 17 6
      service/service.go

+ 17 - 6
service/service.go

@@ -48,12 +48,20 @@ func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplicat
 				data := JyMysql.FindOne(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, "", "")
 				if data != nil && len(*data) > 0 {
 					dataStatus := common.IntAll((*data)["status"])
+					wait_empower_id := common.Int64All((*data)["wait_empower_id"])
 					if dataStatus == -1 {
 						ok = JyMysql.Update(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, map[string]interface{}{"wait_empower_id": this.WaitEmpowerId, "status": 1, "update_time": timeStr})
 					} else {
-						msg = "人员已经拥有权限,请先删除原有权限"
-						code = int64(-1)
-						break
+						resdata := JyMysql.FindOne(EntnicheWaitEmpower, map[string]interface{}{"id": wait_empower_id}, "", "")
+						end_time := common.ObjToString((*resdata)["end_time"])
+						res, _ := time.ParseInLocation("2006-01-02 15:04:05", end_time, time.Local)
+						if res.Unix() > time.Now().Unix() {
+							msg = "人员已经拥有权限,请先删除原有权限"
+							code = int64(-1)
+							break
+						} else {
+							ok = JyMysql.Update(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, map[string]interface{}{"wait_empower_id": this.WaitEmpowerId, "status": 1, "update_time": timeStr})
+						}
 					}
 				} else {
 					id = JyMysql.Insert(EntnichePower, map[string]interface{}{
@@ -97,14 +105,16 @@ func DelUsePerson(this *entmanageapplication.DelUsePersonReq) *entmanageapplicat
 }
 
 func UsePersonList(this *entmanageapplication.UsePersonListReq) *entmanageapplication.UsePersonListResp {
+	nowTime := time.Now().Format("2006-01-02 15:04:05")
 	data := JyMysql.SelectBySql(`select a.id,a.wait_empower_id,c.name,c.phone,c.mail,g.name as department,e.name as role from entniche_power a 
 		INNER JOIN entniche_user c on (a.ent_user_id=c.id and a.ent_id = c.ent_id) 
 		LEFT JOIN entniche_user_role d on (c.id=d.user_id) 
 		LEFT JOIN entniche_role e on (d.role_id=e.id) 
 		LEFT JOIN entniche_department_user f on (a.ent_user_id=f.user_id) 
 		LEFT JOIN entniche_department g on (g.id=f.dept_id) 
-		where a.status = 1 and a.ent_id = ?
-		order by a.update_time desc`, this.EntId)
+		LEFT JOIN entniche_wait_empower h on (h.id=a.wait_empower_id) 
+		where a.status = 1 and a.ent_id = ? and end_time >= ? 
+		order by a.update_time desc`, this.EntId, nowTime)
 	arr := []*entmanageapplication.UsePersonList{}
 	if data != nil && len(*data) > 0 {
 		for _, v := range *data {
@@ -141,7 +151,8 @@ func UsePersonList(this *entmanageapplication.UsePersonListReq) *entmanageapplic
 }
 
 func BuyProductList(this *entmanageapplication.BuyProductListReq) *entmanageapplication.BuyProductListResp {
-	data := JyMysql.Find(EntnicheWaitEmpower, map[string]interface{}{"ent_id": this.EntId}, "", "create_time desc", 0, 0)
+	nowTime := time.Now().Format("2006-01-02 15:04:05")
+	data := JyMysql.SelectBySql(`select * from `+EntnicheWaitEmpower+` where ent_id = ? and end_time >= ? order by create_time desc`, this.EntId, nowTime)
 	arr := []*entmanageapplication.BuyProductList{}
 	if data != nil && len(*data) > 0 {
 		for _, v := range *data {