Browse Source

监测 + 分成比例 类型修改 int -> decimal

lifa 1 year ago
parent
commit
20da78e88b

+ 1 - 1
src/platform/ZhonTai.Admin/Domain/Platform/PlatformUserEntity.cs

@@ -61,7 +61,7 @@ namespace ZhonTai.Admin.Domain.Platform
         /// <summary>
         /// 抽成比例
         /// </summary>
-        public int CommissionRatio { get; set; }
+        public decimal CommissionRatio { get; set; }
 
 
         /// 通过手机号和上级ID 来判断唯一(一个手机号可注册多个不同上级的账号)

+ 86 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Dto/ObserveDto/ObserveInput.cs

@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto
+{
+    public class ObserveInput
+    {
+        /// <summary>
+        /// 操作系统
+        /// </summary>
+        public string Os { get; set; }
+        /// <summary>
+        /// OS 版本
+        /// </summary>
+        public string OsVersion { get; set; }
+        /// <summary>
+        /// 机型
+        /// </summary>
+        public string Model { get; set; }
+        /// <summary>
+        /// 语言
+        /// </summary>
+        public string Lang { get; set; }
+        /// <summary>
+        /// 国家
+        /// </summary>
+        public string Country { get; set; }
+        /// <summary>
+        /// 屏幕宽(像素)
+        /// </summary>
+        public string Width { get; set; }
+        /// <summary>
+        /// 屏幕高(像素)
+        /// </summary>
+        public string Height { get; set; }
+        /// <summary>
+        /// 广告所在apk包名
+        /// </summary>
+        public string Pkg { get; set; }
+        /// <summary>
+        /// 应用版本
+        /// </summary>
+        public string AppVersion { get; set; }
+
+        public string Useragent { get; set; }
+        public string Referer { get; set; }
+        // 2-客户端参数
+        /// <summary>
+        /// 网络类型
+        /// </summary>
+        public string NetType { get; set; }
+        /// <summary>
+        /// 运营商
+        /// </summary>
+        public string Carrier { get; set; }
+        /// <summary>
+        /// 播放进度,单位为毫秒,视频广告时有效
+        /// </summary>
+        public string Progress { get; set; }
+        // 3-服务端参数
+        /// <summary>
+        /// IMEI
+        /// </summary>
+        public string Imei { get; set; }
+        /// <summary>
+        /// OAID 原值
+        /// </summary>
+        public string OAID { get; set; }
+        // 5-服务端参数
+        /// <summary>
+        /// 广告ID
+        /// </summary>
+        public long AdId { get; set; }
+        /// <summary>
+        /// 广告名称,需要urlencode
+        /// </summary>
+        public string AdName { get; set; }
+        /// <summary>
+        /// 请求ID
+        /// </summary>
+        public string ReqId { get; set; }
+    }
+}

+ 46 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Dto/ObserveDto/ObservePostData.cs

@@ -0,0 +1,46 @@
+using Qiniu.Util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto
+{
+    public class ObservePostData
+    {
+        public string imei { get; set; }
+        /// <summary>
+        /// ouId 就是 oaid
+        /// 二选一,但优先用 imei,然后考虑 ouId,ouId 就是oaid;
+        /// </summary>
+        //public string ouId { get; set; }
+
+        public string requestId { get; set; }
+        public string mac { get; set; }
+        public string clientIp { get; set; }
+        public long timestamp { get; set; }
+        public string pkg { get; set; }
+        public int dataType { get; set; }
+        public string payId { get; set; }
+        public int? customType { get; set; }
+        public int channel { get; set; }
+        public int type { get; set; }
+        public int appType { get; set; }
+        public long? payAmount { get; set; }
+        public int ascribeType { get; set; }
+        public long adId { get; set; }
+    }
+
+    public class ObserveResult
+    {
+        /// <summary>
+        /// 消息
+        /// </summary>
+        public string msg { get; set; }
+        /// <summary>
+        /// 编号
+        /// </summary>
+        public int ret { get; set; }
+    }
+}

+ 166 - 1
src/platform/ZhonTai.Admin/Services/DiTuiAPI/ProjectsService.cs

@@ -1,10 +1,19 @@
-using Microsoft.AspNetCore.Http.Metadata;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http.Metadata;
 using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
 using Qiniu.Util;
+using StackExchange.Profiling.Internal;
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Linq.Expressions;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Security.Cryptography;
 using System.Text;
 using System.Threading.Tasks;
 using ZhonTai.Admin.Core.Attributes;
@@ -19,12 +28,17 @@ using ZhonTai.Admin.Repositories.KuaKe;
 using ZhonTai.Admin.Repositories.Project;
 using ZhonTai.Admin.Repositories.ProjectLink;
 using ZhonTai.Admin.Services.DiTuiAPI.Dto;
+using ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto;
 using ZhonTai.Admin.Services.Notice.Dto;
 using ZhonTai.Admin.Services.Project;
 using ZhonTai.Admin.Services.ProjectLink.Dto;
 using ZhonTai.Admin.Services.ProjectStat.Dto;
 using ZhonTai.DynamicApi;
 using ZhonTai.DynamicApi.Attributes;
+using System.Reactive;
+using System.Security.Cryptography.Xml;
+using ZhonTai.Common.Helpers;
+using NPOI.SS.Formula.Functions;
 
 namespace ZhonTai.Admin.Services.DiTuiAPI
 {
@@ -699,6 +713,157 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
             return data;
         }
 
+        /// <summary>
+        /// 监测
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [AllowAnonymous]
+        [NoOprationLog]
+        public string  Observe(ObserveInput input)
+        {
+            string postUrl = "https://api.ads.heytapmobi.com/api/uploadActiveData";
+            
+            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+            long timestamp = Convert.ToInt64(ts.TotalMilliseconds);
+            string salt = "e0u6fnlag06lc3pl";
+            ObservePostData postData = new ObservePostData();
+
+            postData.imei = input.Imei;
+            postData.requestId = input.ReqId;
+            postData.mac = "";
+            postData.clientIp = "";
+            postData.timestamp = timestamp;
+            postData.pkg = input.Pkg;
+            postData.dataType = 15;
+            postData.payId = "";
+            //postData.customType = "";
+            postData.channel = 1;
+            postData.type = 1;
+            postData.appType = 1;
+            //postData.payAmount = 100;
+            postData.ascribeType = 1;
+            postData.adId = input.AdId;
+
+            
+
+            string contents = postData.ToJson() + timestamp + salt;
+            string signature = this.GenerateMD5(contents);
+
+            var resultJson = this.JsonPostUrl(postUrl, signature, timestamp, postData.ToJson());
+            //JsonReader reader = new JsonTextReader(new StringReader(resultJson));
+
+            //JObject jo = JObject.Parse(resultJson);
+            //string[] values = jo.Properties().Select(item => item.Value.ToString()).ToArray();
+            //ObserveResult result = (ObserveResult)JsonHelper.Deserialize(resultJson);
+            //string reutrn = "123";
+            return resultJson;
+        }
+
+        private string JsonPostUrl(string url, string signature, long timestamp, string postData)
+        {
+            string result = "";
+            
+            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
+
+            req.Method = "POST";
+
+            // req.TimeOut = "800";//设置请求超时时间,单位为毫秒
+            req.Headers.Add("signature", signature);
+            req.Headers.Add("timestamp", timestamp.ToString());
+            req.ContentType = "application/json";
+
+            byte[] data = Encoding.UTF8.GetBytes(postData);
+
+            req.ContentLength = data.Length;
+
+            using (Stream reqStream = req.GetRequestStream())
+            {
+                reqStream.Write(data, 0, data.Length);
+
+                reqStream.Close();
+            }
+
+            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
+
+            Stream stream = resp.GetResponseStream();
+
+            //获取响应内容
+            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
+            {
+                result = reader.ReadToEnd();
+            }
+
+            return result;
+           
+        }
+
+        private string HttpPost(string url,string signature, long timestamp, string content)
+        {
+            string getAccessToken = "";
+            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
+            req.Headers.Add("signature",signature);
+            req.Headers.Add("timestamp", timestamp.ToString());
+            req.Method = "POST";
+            req.ContentType = "application/json";
+
+            //#region 添加Post 参数
+            byte[] data = Encoding.UTF8.GetBytes(content);
+            req.ContentLength = data.Length;
+            using (Stream reqStream = req.GetRequestStream())
+            {
+                reqStream.Write(data, 0, data.Length);
+                reqStream.Close();
+            }
+            //#endregion
+
+            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
+            Stream stream = resp.GetResponseStream();
+            //获取响应内容
+            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
+            {
+                getAccessToken = reader.ReadToEnd();
+                reader.Close();
+            }
+            JObject getToken = (JObject)JsonConvert.DeserializeObject(getAccessToken);
+
+            // 同样根据接口规则去取得返回Token
+            string getTheToken = getToken["{access_token}"].ToString();
+            return "";
+            // 后续操作参上GET
+        }
+
+
+        private string GenerateMD5(string txt)
+
+        {
+
+            using (MD5 mi = MD5.Create())
+
+            {
+
+                byte[] buffer = Encoding.Default.GetBytes(txt);
+
+                //开始加密
+
+                byte[] newBuffer = mi.ComputeHash(buffer);
+
+                StringBuilder sb = new StringBuilder();
+
+                for (int i = 0; i < newBuffer.Length; i++)
+
+                {
+
+                    sb.Append(newBuffer[i].ToString("x2"));
+
+                }
+
+                return sb.ToString();
+
+            }
+
+        }
+
         /// <summary>
         /// 判断字符串是否是手机号
         /// </summary>

+ 1 - 1
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Team/Dto/TeamIndexOutput.cs

@@ -31,7 +31,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI.Team.Dto
         /// <summary>
         /// 默认抽成比例
         /// </summary>
-        public int CommissionRatio { get; set; }
+        public decimal CommissionRatio { get; set; }
 
         /// <summary>
         /// 团队概况

+ 107 - 0
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -6068,6 +6068,107 @@
             ID
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Os">
+            <summary>
+            操作系统
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.OsVersion">
+            <summary>
+            OS 版本
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Model">
+            <summary>
+            机型
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Lang">
+            <summary>
+            语言
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Country">
+            <summary>
+            国家
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Width">
+            <summary>
+            屏幕宽(像素)
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Height">
+            <summary>
+            屏幕高(像素)
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Pkg">
+            <summary>
+            广告所在apk包名
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.AppVersion">
+            <summary>
+            应用版本
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.NetType">
+            <summary>
+            网络类型
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Carrier">
+            <summary>
+            运营商
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Progress">
+            <summary>
+            播放进度,单位为毫秒,视频广告时有效
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.Imei">
+            <summary>
+            IMEI
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.OAID">
+            <summary>
+            OAID 原值
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.AdId">
+            <summary>
+            广告ID
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.AdName">
+            <summary>
+            广告名称,需要urlencode
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput.ReqId">
+            <summary>
+            请求ID
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObservePostData.requestId">
+            <summary>
+            ouId 就是 oaid
+            二选一,但优先用 imei,然后考虑 ouId,ouId 就是oaid;
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveResult.msg">
+            <summary>
+            消息
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveResult.ret">
+            <summary>
+            编号
+            </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.PersonReportFormInput.StartDate">
             <summary>
             开始时间
@@ -6643,6 +6744,12 @@
             <param name="input"></param>
             <returns></returns>
         </member>
+        <member name="M:ZhonTai.Admin.Services.DiTuiAPI.ProjectsService.Observe(ZhonTai.Admin.Services.DiTuiAPI.Dto.ObserveDto.ObserveInput)">
+            <summary>
+            监测
+            </summary>
+            <returns></returns>
+        </member>
         <member name="M:ZhonTai.Admin.Services.DiTuiAPI.ProjectsService.IsPhoneNumber(System.String)">
             <summary>
             判断字符串是否是手机号