Browse Source

数据包企业查询临时提交

wangkaiyue 4 years ago
parent
commit
c568c93e73
1 changed files with 42 additions and 5 deletions
  1. 42 5
      src/jfw/modules/subscribepay/src/entity/dataExportPackStruct.go

+ 42 - 5
src/jfw/modules/subscribepay/src/entity/dataExportPackStruct.go

@@ -6,6 +6,7 @@ import (
 	"github.com/go-xweb/httpsession"
 	"jfw/modules/common/src/qfw/util/dataexport"
 	"jfw/modules/common/src/qfw/util/jy"
+	"jfw/public"
 	qutil "qfw/util"
 	"strings"
 	"util"
@@ -73,17 +74,53 @@ func (this *dataExportPackStruct) GetAccountMsg(sess *httpsession.Session, userI
 		}
 	}
 	if phone != "" {
-		//查询所属企业及账户余额
-		//util.Mysql.Query("")
-
-		//util.Mysql.Find("entniche_user", map[string]interface{}{"phone": phone}, "id,ent_id", "", -1, -1)
 		//查询出企业列表
-		//根据企业列表获取所在企业余额
+		entList := util.Mysql.Query(`SELECT a.id AS uid,b.id AS eid,b.name AS eName,b.phone AS ePhone FROM entniche_user a INNER JOIN entniche_info b ON a.phone = ? AND a.power = 1 AND b.STATUS = 1 AND a.ent_id = b.id `, phone)
+		if entList != nil && len(*entList) > 0 {
+			entPack := make([]map[string]interface{}, 0, len(*entList))
+			//根据企业列表获取所在企业余额
+			for _, entMsg := range *entList {
+				user_entId, user_entId_ok := entMsg["uid"].(int)
+				ent_id, ent_id_ok := entMsg["eid"].(int)
+				ent_name, ent_name_ok := entMsg["eName"].(string)
+				ent_phone, ent_phone_ok := entMsg["ePhone"].(string)
+				if !ent_id_ok || !user_entId_ok || !ent_name_ok || !ent_phone_ok {
+					continue
+				}
+				entAllCount := GetCurrentCount(ent_name, ent_phone) //查询所属企业及账户余额
+
+				entPack = append(entPack, map[string]interface{}{
+					"entId":       ent_id,
+					"entName":     ent_name,
+					"entAllCount": entAllCount,
+				})
 
+			}
+			query := map[string]interface{}{"ent_id": entId, "user_id": entUserId}
+			data_limit, remain_nums, export_nums := 0, 0, 0
+			limit := public.Mysql.FindOne("entniche_export_limit", query, "data_limit,remain_nums,export_nums", "")
+			if limit != nil {
+				data_limit = util.IntAll((*limit)["data_limit"])
+				remain_nums = util.IntAll((*limit)["remain_nums"])
+				export_nums = util.IntAll((*limit)["export_nums"])
+			}
+		}
 	}
 	return packDetail, nil
 }
 
+func GetCurrentCount(entName, entPhone string) int {
+	current, ok := public.Mgo_Qyfw.FindOne("user", map[string]interface{}{"phone": entPhone, "username": entName})
+	if current == nil || !ok {
+		return 0
+	}
+	plan, plan_ok := (*current)["plan"].(map[string]interface{})
+	if !plan_ok {
+		return 0
+	}
+	return qutil.IntAll(plan["current"])
+}
+
 // GetPersonalAccount 中台交互-查询个人数据包账户信息
 func (this *dataExportPackStruct) GetPersonalAccount(userId string) (seniorNum, normal int, err error) {
 	//调用中台 查询