|
@@ -2,14 +2,17 @@
|
|
|
package person
|
|
|
|
|
|
import (
|
|
|
+ "app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ "context"
|
|
|
"database/sql"
|
|
|
. "entbase/src/config"
|
|
|
"fmt"
|
|
|
"log"
|
|
|
"regexp"
|
|
|
"strconv"
|
|
|
-
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
|
|
|
. "app.yhyue.com/moapp/jybase/api"
|
|
|
qutil "app.yhyue.com/moapp/jybase/common"
|
|
@@ -531,12 +534,65 @@ func (a *Action) Del() {
|
|
|
a.ServeJson(Result{Data: M{"status": status, "userList": leftRs}, Error_code: -1, Error_msg: "所删用户中存在数据包未使用完的"})
|
|
|
return
|
|
|
}
|
|
|
+ //回收pdf权益
|
|
|
+ entId := qutil.IntAll(a.GetSession("entId"))
|
|
|
+ PdfRecycle(id, entId)
|
|
|
if VarUser.Del(frameworkEntId, id) {
|
|
|
status = 1
|
|
|
}
|
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
|
}
|
|
|
|
|
|
+func PdfRecycle(ids string, entId int) {
|
|
|
+ log.Println("PdfRecycle===", ids, entId)
|
|
|
+ phones := Mysql.SelectBySql(`SELECT a.phone FROM entniche_user a WHERE a.id in (?)`, ids)
|
|
|
+ if phones != nil && len(*phones) > 0 {
|
|
|
+ var ps []string
|
|
|
+ for _, m := range *phones {
|
|
|
+ ps = append(ps, fmt.Sprintf(`"%s"`, qutil.InterfaceToStr(m["phone"])))
|
|
|
+ }
|
|
|
+ data := Base.SelectBySql("SELECT c.id AS positionId FROM base_user a INNER JOIN base_position c ON a.id = c.user_id WHERE c.ent_id = ? and a.phone in (?)", entId, strings.Join(ps, ","))
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ for _, m := range *data {
|
|
|
+ positionId := qutil.InterfaceToStr(m["positionId"])
|
|
|
+ res := Mysql.SelectBySql("SELECT b.s_name FROM bigmember_service_user a INNER JOIN bigmember_service b on (a.s_serviceid = b.id and b.s_name LIKE '%pdf下载%') WHERE a.s_userid = ? and a.i_status >= 0 and l_endtime >? ", positionId, time.Now().Format("2006-01-02 15:04:05"))
|
|
|
+ if res != nil {
|
|
|
+ for _, serverData := range *res {
|
|
|
+ var (
|
|
|
+ resourceType string
|
|
|
+ )
|
|
|
+ if strings.Contains(qutil.InterfaceToStr(serverData["s_name"]), "市场分析定制报告pdf下载") {
|
|
|
+ resourceType = "市场分析定制报告下载包"
|
|
|
+ } else if strings.Contains(qutil.InterfaceToStr(serverData["s_name"]), "业主采购分析报告pdf下载") {
|
|
|
+ resourceType = "业主采购分析报告下载包"
|
|
|
+ } else if strings.Contains(qutil.InterfaceToStr(serverData["s_name"]), "企业中标分析报告pdf下载") {
|
|
|
+ resourceType = "企业中标分析报告下载包"
|
|
|
+ }
|
|
|
+ if resourceType != "" {
|
|
|
+ if err := DelPdfPack(positionId, resourceType, int64(entId)); err != nil {
|
|
|
+ log.Println("DelPdfPack err ", err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// DelPdfPack 增加pdf下载包权限
|
|
|
+// resourceType "企业中标分析报告下载包","业主采购分析报告下载包","市场分析定制报告下载包"
|
|
|
+func DelPdfPack(userId, resourceType string, entId int64) error {
|
|
|
+ log.Println("DelPdfPack===", userId, resourceType, entId)
|
|
|
+ ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
|
|
|
+ _, err := ResourceCenterRpc.EntAccountRecovery(ctx, &resourcesCenterclient.EntOperateReq{
|
|
|
+ OperateAccountId: userId,
|
|
|
+ CompanyId: entId,
|
|
|
+ ResourceType: resourceType,
|
|
|
+ })
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
// 移动
|
|
|
func (a *Action) Move() {
|
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id", "did") {
|
|
@@ -675,8 +731,8 @@ func (a *Action) Update() {
|
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
|
}
|
|
|
|
|
|
-//入参 :1销售、2资讯分配、3资讯分配+销售
|
|
|
-//0:销售 1:企业资讯分配 2:部门资讯分配 3:企业资讯分配+销售 4:部门资讯分配+销售
|
|
|
+// 入参 :1销售、2资讯分配、3资讯分配+销售
|
|
|
+// 0:销售 1:企业资讯分配 2:部门资讯分配 3:企业资讯分配+销售 4:部门资讯分配+销售
|
|
|
func getNicheDis(pid, nicheDis int) int {
|
|
|
pId, _ := qutil.If(pid == 0, 0, 1).(int)
|
|
|
nicheDisMap := map[int]map[int]int{
|