瀏覽代碼

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

CrazyIter_Bin 1 年之前
父節點
當前提交
774a14b39c

+ 197 - 8
TEAMModelBI/Controllers/BITmid/TmidController.cs

@@ -81,9 +81,9 @@ namespace TEAMModelBI.Controllers.BITmid
                             string id = doc.GetProperty("id").GetString();
                             string id = doc.GetProperty("id").GetString();
                             //基本資料
                             //基本資料
                             TmidStics tmidStics = (tmidDic.ContainsKey(id)) ? tmidDic[id] : new() { id = id };
                             TmidStics tmidStics = (tmidDic.ContainsKey(id)) ? tmidDic[id] : new() { id = id };
-                            tmidStics.name = doc.GetProperty("name").GetString();
-                            tmidStics.mobile = doc.GetProperty("mobile").GetString();
-                            tmidStics.mail = doc.GetProperty("mail").GetString();
+                            string tmidName = doc.GetProperty("name").GetString();
+                            string tmidMobile = GenDataMask(doc.GetProperty("mobile").GetString(), "mobile");
+                            string tmidMail = GenDataMask(doc.GetProperty("mail").GetString(), "mail");
 
 
                             //票券
                             //票券
                             var usersCoupons = tableCouponClient.Get<DynamicTableEntity>(id);
                             var usersCoupons = tableCouponClient.Get<DynamicTableEntity>(id);
@@ -136,8 +136,8 @@ namespace TEAMModelBI.Controllers.BITmid
                             string id = doc.GetProperty("id").GetString();
                             string id = doc.GetProperty("id").GetString();
                             TmidStics tmidStics = (tmidDic.ContainsKey(id)) ? tmidDic[id] : new() { id = id };
                             TmidStics tmidStics = (tmidDic.ContainsKey(id)) ? tmidDic[id] : new() { id = id };
                             if (string.IsNullOrWhiteSpace(tmidStics.name)) tmidStics.name = doc.GetProperty("name").GetString();
                             if (string.IsNullOrWhiteSpace(tmidStics.name)) tmidStics.name = doc.GetProperty("name").GetString();
-                            if (string.IsNullOrWhiteSpace(tmidStics.mobile)) tmidStics.mobile = doc.GetProperty("mobile").GetString();
-                            if (string.IsNullOrWhiteSpace(tmidStics.mail)) tmidStics.mail = doc.GetProperty("mail").GetString();
+                            if (string.IsNullOrWhiteSpace(tmidStics.mobile)) tmidStics.mobile = GenDataMask(doc.GetProperty("mobile").GetString(), "mobile");
+                            if (string.IsNullOrWhiteSpace(tmidStics.mail)) tmidStics.mail = GenDataMask(doc.GetProperty("mail").GetString(), "mail");
                             tmidStics.country = doc.GetProperty("country").GetString();
                             tmidStics.country = doc.GetProperty("country").GetString();
                             tmidStics.province = doc.GetProperty("province").GetString();
                             tmidStics.province = doc.GetProperty("province").GetString();
                             tmidStics.city = doc.GetProperty("city").GetString();
                             tmidStics.city = doc.GetProperty("city").GetString();
@@ -178,7 +178,7 @@ namespace TEAMModelBI.Controllers.BITmid
                 }
                 }
 
 
                 //IES5
                 //IES5
-                //個人空間使用狀況
+                ///個人空間使用狀況
                 foreach (KeyValuePair<string, TmidStics> dicItem in tmidDic)
                 foreach (KeyValuePair<string, TmidStics> dicItem in tmidDic)
                 {
                 {
                     string tmidNow = dicItem.Key;
                     string tmidNow = dicItem.Key;
@@ -189,7 +189,6 @@ namespace TEAMModelBI.Controllers.BITmid
                     tmidDic[tmidNow].ies5.surplusSize = surplus;
                     tmidDic[tmidNow].ies5.surplusSize = surplus;
                 }
                 }
 
 
-
                 //輸出
                 //輸出
                 List<object> data = new();
                 List<object> data = new();
                 foreach (KeyValuePair<string, TmidStics> dicItem in tmidDic)
                 foreach (KeyValuePair<string, TmidStics> dicItem in tmidDic)
@@ -200,11 +199,129 @@ namespace TEAMModelBI.Controllers.BITmid
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                await _dingDing.SendBotMsg($"BI,{_option.Location} /tmid/get-tmidstics \n {ex.Message}\n{ex.StackTrace}", GroupNames.台北開發測試群組);
+                //await _dingDing.SendBotMsg($"BI,{_option.Location} /tmid/get-tmidstics \n {ex.Message}\n{ex.StackTrace}", GroupNames.台北開發測試群組);
                 return BadRequest();
                 return BadRequest();
             }
             }
         }
         }
 
 
+        //取得TMID服務授權週期
+        public async Task<List<object>> getTMIDAuthService(CosmosClient cosmosClientCsv2, string tmid, string prodCode, bool validFlg)
+        {
+            long now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
+            var qryOption = new QueryRequestOptions() { PartitionKey = new PartitionKey("servicePeriod") };
+            string whereSql = $"c.saleClient.tmid = '{tmid}'";
+            if (!string.IsNullOrWhiteSpace(prodCode)) whereSql += $" AND c.prodCode = '{prodCode}'";
+            if (validFlg) whereSql += $" AND c.startDate <= {now} AND {now} <= c.endDate";
+            string sql = $"SELECT c.id, c.prodCode, c.type, c.startDate, c.endDate, c.number, c.unit, c.aprule FROM c WHERE {whereSql}";
+            var client = cosmosClientCsv2.GetContainer("Habb", "Auth");
+            var result = new List<object>();
+            await foreach (var item in client.GetItemQueryStreamIterator(queryText: sql, requestOptions: qryOption))
+            {
+                var json = await JsonDocument.ParseAsync(item.ContentStream);
+                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                {
+                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                    {
+                        result.Add(
+                        new
+                        {
+                            id = obj.GetProperty("id").GetString(),
+                            prodCode = obj.GetProperty("prodCode").GetString(),
+                            type = obj.GetProperty("type").GetInt32(),
+                            startDate = obj.GetProperty("startDate").GetInt64(),
+                            endDate = obj.GetProperty("endDate").GetInt64(),
+                            number = obj.GetProperty("number").GetInt32(),
+                            unit = obj.GetProperty("unit").GetString(),
+                            aprule = obj.GetProperty("aprule")
+                        });
+                    }
+                }
+            }
+            return result;
+        }
+
+        //取得TMID購買紀錄
+        public async Task<List<Ies5OrderHis>> getTMIDAuthOrder(CosmosClient cosmosClientCsv2, string tmid, string prodCode)
+        {
+            SortedDictionary<string, Ies5OrderHis> OrderDic = new SortedDictionary<string, Ies5OrderHis>();
+            var qryOption = new QueryRequestOptions() { PartitionKey = new PartitionKey("order") };
+            //服務 ※序號、硬體 不列入購買紀錄
+            string strQueryV = $"SELECT * FROM c WHERE IS_DEFINED(c.saleClient.tmid) AND c.saleClient.tmid = '{tmid}' AND c.prodType = 'service'";
+            if (!string.IsNullOrWhiteSpace(prodCode))
+            {
+                strQueryV += $" AND c.prodCode = '{prodCode}'";
+            }
+            await foreach (OrderHisService orderService in cosmosClientCsv2.GetContainer("Habb", "Auth").GetItemQueryIterator<OrderHisService>(strQueryV, null, qryOption))
+            {
+                Ies5OrderHisService ies5OrderVRow = new Ies5OrderHisService();
+                ies5OrderVRow.prodCode = orderService.prodCode;
+                ies5OrderVRow.type = (orderService.contract.Equals(1)) ? "C" : (orderService.contract.Equals(2)) ? "G" : "N"; //授權方式 [FROM]contract契約型態 0:新約 1:續約 2:變更 [TO]type N:新約 C:續約 G:變更
+                ies5OrderVRow.sdate = orderService.startDate;
+                ies5OrderVRow.edate = orderService.endDate;
+                ies5OrderVRow.number = orderService.number;
+                ies5OrderVRow.unit = orderService.unit;
+                //加入Order字典
+                string OrderID = orderService.orderinfo.orderid.ToString();
+                long OrderDate = orderService.orderinfo.createDate;
+                if (OrderDic.ContainsKey(OrderID))
+                {
+                    OrderDic[OrderID].service.Add(ies5OrderVRow);
+                }
+                else
+                {
+                    Ies5OrderHis ies5OrderHisNew = new Ies5OrderHis();
+                    ies5OrderHisNew.id = OrderID;
+                    ies5OrderHisNew.date = OrderDate;
+                    ies5OrderHisNew.service.Add(ies5OrderVRow);
+                    OrderDic.Add(OrderID, ies5OrderHisNew);
+                }
+            }
+
+            //輸出項
+            List<Ies5OrderHis> Result = new List<Ies5OrderHis>();
+            foreach (KeyValuePair<string, Ies5OrderHis> item in OrderDic)
+            {
+                Result.Add(item.Value);
+            }
+            return Result;
+        }
+
+        //Tool
+        //資料遮罩
+        ///規則:
+        ///1.手機、電話:隱藏後4碼
+        ///2.Mail:隱藏@前資料
+        ///3.姓名:只顯示第一個字元
+        ///4.身分證、護照:隱藏後4碼
+        public string GenDataMask(string data, string type)
+        {
+            int length = 0;
+            string subString = string.Empty;
+            if (!string.IsNullOrWhiteSpace(data))
+            {
+                switch (type)
+                {
+                    case "mobile":
+                    case "id":
+                        length = 4;
+                        subString = data.Substring(data.Length - length, length);
+                        data = data.Replace(subString, "****");
+                        break;
+                    case "mail":
+                        string[] dataList = data.Split("@");
+                        subString = dataList.First();
+                        data = data.Replace(subString, "****");
+                        break;
+                    case "name":
+                        length = 2;
+                        subString = data.Substring(data.Length - length, length);
+                        data = data.Replace(subString, "〇〇");
+                        break;
+                }
+            }
+            return data;
+        }
+
         //Model
         //Model
 
 
         //TMID統計 基本資訊
         //TMID統計 基本資訊
@@ -260,6 +377,78 @@ namespace TEAMModelBI.Controllers.BITmid
             public string learning_duration { get; set; }
             public string learning_duration { get; set; }
         }
         }
 
 
+        //[API輸出] 訂單履歷 
+        public class Ies5OrderHis
+        {
+            public Ies5OrderHis()
+            {
+                service = new List<Ies5OrderHisService>();
+            }
+            public string id { get; set; }
+            public long date { get; set; }
+            public List<Ies5OrderHisService> service { get; set; } = new ();
+        }
+        //[API輸出] 訂單履歷.服務型產品
+        public class Ies5OrderHisService
+        {
+            public string prodCode { get; set; } //產品代碼
+            public string type { get; set; } //授權方式 N:新約 C:續約
+            public long sdate { get; set; } //授權起始時間
+            public long edate { get; set; } //授權終止時間
+            public int number { get; set; } //購買數量
+            public string unit { get; set; } //購買單位 無單位者為null
+        }
+
+        //[承接DB] DB: Habb.Auth
+        //[承接DB] 訂單履歷基本Class
+        public class OrderHisBase
+        {
+            public string id { get; set; } //OPID
+            public OrderHisOrderInfo orderinfo { get; set; } //訂單資訊
+            public string prodCode { get; set; } //產品代碼
+            public SerialSaleClient saleClient { get; set; } = null; //銷售終端
+            public string prodType { get; set; } //產品類型 serial:序號 service:服務 hard:硬體
+            public string dataType { get; set; } //資料類型
+            public long operationTime { get; set; } //最新資料變更時間戳記
+            public int ttl { get; set; } = -1; //過期刪除秒數
+
+        }
+        //[承接DB] 訂單履歷基本Class.銷售終端
+        public class SerialSaleClient
+        {
+            public string name { get; set; } //[String]銷售終端姓名
+            public string schoolCode { get; set; } = null; //[String]銷售終端學校代碼
+            public string clientId { get; set; } = null; //[String]銷售終端客戶ID
+            public string tmid { get; set; } = null; //[String]TMID
+            public string type { get; set; } //[String]銷售終端資料類型  school:學校 client:經銷商客戶
+            public string countryId { get; set; } //[String]國家代碼
+            public string provinceId { get; set; } //[String]省代碼
+            public string cityId { get; set; } //[String]市代碼
+            public string schoolShortCode { get; set; } //[String]學校簡碼
+            public string districtId { get; set; } //[String]區代碼
+            public string dataCenter { get; set; } //[String]數據中心
+        }
+
+        //[承接DB] 訂單履歷基本Class.訂單資訊
+        public class OrderHisOrderInfo
+        {
+            public string orderid { get; set; } //[String]訂單編號
+            public int orderAudit { get; set; } //[Int]訂單審核狀態 0:待審, 1:通過, 2:否決, 3:問題
+            public int orderProperty { get; set; } //[Int]訂單類型 0:銷售,1:展示申請 2:內部申請
+            public long createDate { get; set; } //訂單創建時間
+        }
+        //[承接DB] 訂單履歷 服務類
+        public class OrderHisService : OrderHisBase
+        {
+            public int type { get; set; } //[Int]授權類型 0:銷售 1:試用
+            public int contract { get; set; } //[Int]契約型態 0:新約 1:續約
+            public long startDate { get; set; } //[long]授權起始日期 Timestamp(UTC)
+            public long endDate { get; set; } //[long]授權終止日期 Timestamp(UTC)
+            public int number { get; set; } //[Int]數量
+            public string unit { get; set; } //[String]單位 (無者為空)
+        }
+
+        //雲端服務ClientId列表
         private readonly Dictionary<string, string> _dicClientIds = new()
         private readonly Dictionary<string, string> _dicClientIds = new()
         {
         {
             { "917d02f2-5b91-404e-a71d-7bdd926ddd81", "HiTeach" },
             { "917d02f2-5b91-404e-a71d-7bdd926ddd81", "HiTeach" },

+ 23 - 8
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -1648,17 +1648,32 @@ namespace TEAMModelOS.FunctionV4
                     //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
                     //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
                     string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
                     string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
                     string urlAction = string.Empty;
                     string urlAction = string.Empty;
-                    if (location.Contains("China") || location.Contains("China-Dep") || location.Contains("China-Test"))
+                    string accessKey = string.Empty;
+                    if (location.Contains("China"))
                     {
                     {
-                        urlAction = "https://malearnfunction.chinacloudsites.cn";
+                        if(location.Equals("China")) //大陸正式站
+                        {
+                            urlAction = "https://malearn.teammodel.cn";
+                            accessKey = "QUzQqbqbnLsTDTeaJy4Br6wUuqPoAlKpzRK2S6PGImRHAzFuySGAeA==";
+                        }
+                        else if(location.Equals("China-Dep") || location.Equals("China-Test")) //大陸測試站
+                        {
+                            urlAction = "https://malearn-rc.teammodel.cn";
+                            accessKey = "hESc0g7Q60FTEss4ZnVXPB61S1a8WlAXIq5ULl3T3oTxAzFunpLDwA==";
+                        }                        
                     }
                     }
                     else if (location.Contains("Global"))
                     else if (location.Contains("Global"))
                     {
                     {
-                        urlAction = "https://malearnfunction.azurewebsites.net";
-                    }
-                    else if (location.Contains("Global-Test"))
-                    {
-                        urlAction = "https://malearn-test.azurewebsites.net";
+                        if(location.Equals("Global")) //國際正式站
+                        {
+                            urlAction = "https://malearn.teammodel.net";
+                            accessKey = "I-2lTcdggJkZWSBwOXQIm4oHx-huwX3d0wLe-9pgojThAzFuq_KNFg==";
+                        }
+                        else if(location.Equals("Global-Test")) //國際測試站
+                        {
+                            urlAction = "https://malearn-rc.teammodel.net";
+                            accessKey = "_l4Cb_tHIRBw_iv3ZuwVqjkMwjg4_HtDaxhAmZ8OwJraAzFu_DAY8A==";
+                        }
                     }
                     }
                     string connect = $"{urlAction}/api/crtmabank";
                     string connect = $"{urlAction}/api/crtmabank";
                     var htc = _httpClient.CreateClient();
                     var htc = _httpClient.CreateClient();
@@ -1666,7 +1681,7 @@ namespace TEAMModelOS.FunctionV4
                     {
                     {
                         htc.DefaultRequestHeaders.Remove("x-functions-key");
                         htc.DefaultRequestHeaders.Remove("x-functions-key");
                     }
                     }
-                    htc.DefaultRequestHeaders.Add("x-functions-key", "QUzQqbqbnLsTDTeaJy4Br6wUuqPoAlKpzRK2S6PGImRHAzFuySGAeA==");
+                    htc.DefaultRequestHeaders.Add("x-functions-key", accessKey);
                     string paramJson = JsonConvert.SerializeObject(errors);
                     string paramJson = JsonConvert.SerializeObject(errors);
                     var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
                     var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
                     await htc.PostAsync(connect, content);
                     await htc.PostAsync(connect, content);

+ 1 - 1
TEAMModelOS/ClientApp/src/components/student-web/WrongQusetion/QuesList.vue

@@ -281,7 +281,7 @@ export default {
                 stuId: this.userInfo.sub,
                 stuId: this.userInfo.sub,
                 // code: this.courseNow.school,
                 // code: this.courseNow.school,
                 subjectId: this.courseNow.subject.id ? this.courseNow.subject.id : this.courseNow.id,
                 subjectId: this.courseNow.subject.id ? this.courseNow.subject.id : this.courseNow.id,
-                count: 1,
+                count: 10,
                 // token: '',
                 // token: '',
             }
             }
             if(this.userInfo.scope === 'student') {
             if(this.userInfo.scope === 'student') {

+ 1 - 1
TEAMModelOS/ClientApp/src/components/student-web/WrongQusetion/mobile/WrongQues.vue

@@ -350,7 +350,7 @@ export default {
                 stuId: this.userInfo.sub,
                 stuId: this.userInfo.sub,
                 // code: this.courseNow.school,
                 // code: this.courseNow.school,
                 subjectId: this.courseNow.subject.id ? this.courseNow.subject.id : this.courseNow.id,
                 subjectId: this.courseNow.subject.id ? this.courseNow.subject.id : this.courseNow.id,
-                count: 1,
+                count: 10,
                 // token: '',
                 // token: '',
             }
             }
             if(this.userInfo.scope === 'student') {
             if(this.userInfo.scope === 'student') {