|
@@ -39,6 +39,10 @@ using System.Reactive;
|
|
|
using System.Security.Cryptography.Xml;
|
|
|
using ZhonTai.Common.Helpers;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
+using ZhonTai.Admin.Domain.Observe;
|
|
|
+using ZhonTai.Admin.Repositories.Observe;
|
|
|
+using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
|
|
|
namespace ZhonTai.Admin.Services.DiTuiAPI
|
|
|
{
|
|
@@ -55,6 +59,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
|
|
|
private ProjectStatRepository _projectStatRepository;
|
|
|
private ProjectConfigRepository _projectConfigRepository;
|
|
|
private KuaKeRepository _kuaKeRepository;
|
|
|
+ private ObserveRepository _observeRepository;
|
|
|
|
|
|
public ProjectsService(
|
|
|
ProjectLinkRepository projectLinkRepository,
|
|
@@ -62,7 +67,8 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
|
|
|
ProjectPriceRepository projectPriceRepository,
|
|
|
ProjectStatRepository projectStatRepository,
|
|
|
ProjectConfigRepository projectConfigRepository,
|
|
|
- KuaKeRepository kuaKeRepository
|
|
|
+ KuaKeRepository kuaKeRepository,
|
|
|
+ ObserveRepository observeRepository
|
|
|
)
|
|
|
{
|
|
|
_ProjectLinkRepository = projectLinkRepository;
|
|
@@ -71,6 +77,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
|
|
|
_projectStatRepository = projectStatRepository;
|
|
|
_projectConfigRepository = projectConfigRepository;
|
|
|
_kuaKeRepository = kuaKeRepository;
|
|
|
+ _observeRepository = observeRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -159,6 +166,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
|
|
|
if(priceConfig is null)
|
|
|
{
|
|
|
// 未单独设置佣金抽成 默认抽取 5% 取 一位小数
|
|
|
+ // 当前只 计算了公司抽成,尚未计算 平台抽成 实际显示金额 应为 结算价格=项目价格-公司默认抽成-平台默认或指定抽成
|
|
|
projectItem.Price = (Convert.ToDecimal(maxPrice.ProjectPrice) - ProjectPriceService.GetDrawAmount(Convert.ToDecimal(maxPrice.ProjectPrice),Convert.ToDecimal(5.00))).ToString();
|
|
|
}
|
|
|
else
|
|
@@ -727,32 +735,39 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
|
|
|
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
|
|
long timestamp = Convert.ToInt64(ts.TotalMilliseconds);
|
|
|
string salt = "e0u6fnlag06lc3pl";
|
|
|
+ string Base64Key = "XGAXicVG5GMBsx5bueOe4w==";
|
|
|
+ string DecodeBase64Key = Base64Decode(Base64Key);
|
|
|
ObservePostData postData = new ObservePostData();
|
|
|
|
|
|
- postData.imei = input.Imei;
|
|
|
- postData.requestId = input.ReqId;
|
|
|
- postData.mac = "";
|
|
|
- postData.clientIp = "";
|
|
|
- postData.timestamp = timestamp;
|
|
|
+ //postData.imei = AESEncryptedString(input.Imei, Base64Key,"");
|
|
|
+ postData.imei = AesEncrypt(input.Imei, Base64Key);
|
|
|
+ //postData.requestId = input.ReqId;
|
|
|
+ //postData.mac = "";
|
|
|
+ //postData.clientIp = "";
|
|
|
+ postData.timestamp = timestamp.ToString();
|
|
|
postData.pkg = input.Pkg;
|
|
|
- postData.dataType = 15;
|
|
|
- postData.payId = "";
|
|
|
+ postData.dataType = "15";
|
|
|
+ //postData.payId = "";
|
|
|
//postData.customType = "";
|
|
|
- postData.channel = 1;
|
|
|
- postData.type = 1;
|
|
|
- postData.appType = 1;
|
|
|
+ postData.channel = "1";
|
|
|
+ postData.type = "1";
|
|
|
+ postData.appType = "1";
|
|
|
//postData.payAmount = 100;
|
|
|
- postData.ascribeType = 1;
|
|
|
+ postData.ascribeType = "1";
|
|
|
postData.adId = input.AdId;
|
|
|
|
|
|
|
|
|
|
|
|
string contents = postData.ToJson() + timestamp + salt;
|
|
|
- string signature = this.GenerateMD5(contents);
|
|
|
+ string signature = this.GenerateMD5($"");
|
|
|
+ string sign2 = this.GenerateMD5("123456");
|
|
|
|
|
|
var resultJson = this.JsonPostUrl(postUrl, signature, timestamp, postData.ToJson());
|
|
|
//JsonReader reader = new JsonTextReader(new StringReader(resultJson));
|
|
|
-
|
|
|
+ ObserveEntity entity = new ObserveEntity();
|
|
|
+ entity.InputString = input.ToJson();
|
|
|
+ entity.OutputString = resultJson.ToString();
|
|
|
+ var res = _observeRepository.Insert(entity);
|
|
|
//JObject jo = JObject.Parse(resultJson);
|
|
|
//string[] values = jo.Properties().Select(item => item.Value.ToString()).ToArray();
|
|
|
//ObserveResult result = (ObserveResult)JsonHelper.Deserialize(resultJson);
|
|
@@ -760,6 +775,67 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
|
|
+ //private string AesEncrypt2(string encrypteStr, string key)
|
|
|
+ //{
|
|
|
+ // byte[] aesBytes = Encoding.UTF8.GetBytes(encrypteStr);
|
|
|
+ // byte[] aesKey = new byte[32];
|
|
|
+ // //直接转
|
|
|
+ // //Array.Copy(Convert.FromBase64String(key), aesKey, aesKey.Length);
|
|
|
+ // //当长度不够时,右侧添加空格
|
|
|
+ // Array.Copy(Encoding.UTF8.GetBytes(key.PadRight(aesKey.Length)), aesKey, aesKey.Length);
|
|
|
+
|
|
|
+ // using MemoryStream memoryStream = new();
|
|
|
+ // Rijndael Aes = Rijndael.Create();
|
|
|
+ // //或者采用下方生成Aes
|
|
|
+ // //RijndaelManaged Aes = new();
|
|
|
+
|
|
|
+ // Aes.Mode = CipherMode.ECB;
|
|
|
+ // Aes.Padding = PaddingMode.PKCS7;
|
|
|
+ // Aes.KeySize = 128;
|
|
|
+ // Aes.Key = aesKey;
|
|
|
+ // using CryptoStream cryptoStream = new(memoryStream, Aes.CreateEncryptor(), CryptoStreamMode.Write);
|
|
|
+ // cryptoStream.Write(aesBytes, 0, aesBytes.Length);
|
|
|
+ // cryptoStream.FlushFinalBlock();
|
|
|
+ // Aes.Clear();
|
|
|
+ // return Convert.ToBase64String(memoryStream.ToArray());
|
|
|
+ //}
|
|
|
+ public static string Base64Decode(string result)
|
|
|
+ {
|
|
|
+ return Base64Decode(Encoding.UTF8, result);
|
|
|
+ }
|
|
|
+ public static string Base64Decode(Encoding encodeType, string result)
|
|
|
+ {
|
|
|
+ string decode = string.Empty;
|
|
|
+ byte[] bytes = Convert.FromBase64String(result);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ decode = encodeType.GetString(bytes);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ decode = result;
|
|
|
+ }
|
|
|
+ return decode;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static string AesEncrypt(string str, string key)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(str)) return null;
|
|
|
+ Byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);
|
|
|
+
|
|
|
+ System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
|
|
|
+ {
|
|
|
+ Key = Encoding.UTF8.GetBytes(key),
|
|
|
+ Mode = System.Security.Cryptography.CipherMode.ECB,
|
|
|
+ Padding = System.Security.Cryptography.PaddingMode.PKCS7
|
|
|
+ };
|
|
|
+
|
|
|
+ System.Security.Cryptography.ICryptoTransform cTransform = rm.CreateEncryptor();
|
|
|
+ Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
|
|
|
+
|
|
|
+ return Convert.ToBase64String(resultArray, 0, resultArray.Length);
|
|
|
+ }
|
|
|
+
|
|
|
private string JsonPostUrl(string url, string signature, long timestamp, string postData)
|
|
|
{
|
|
|
string result = "";
|