添加项目文件。
This commit is contained in:
parent
da9e64ae85
commit
097b4a99c8
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.0.32112.339
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{1E0C7B53-1915-461F-99CA-3923BD35F849}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{1E0C7B53-1915-461F-99CA-3923BD35F849}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1E0C7B53-1915-461F-99CA-3923BD35F849}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1E0C7B53-1915-461F-99CA-3923BD35F849}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1E0C7B53-1915-461F-99CA-3923BD35F849}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {F76D52ED-3117-4046-8E8D-3790DC325982}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
</startup>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-8.0.28.0" newVersion="8.0.28.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-3.19.4.0" newVersion="3.19.4.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,261 @@
|
||||||
|
using Common.Models;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Microsoft.Owin.Hosting;
|
||||||
|
using Server.MyClass.Class;
|
||||||
|
using Server.Timers;
|
||||||
|
using Server.Winforms;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Common.DbExtends;
|
||||||
|
using Common.Requests.Lianmengs;
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using System.Threading;
|
||||||
|
using Common.Models.PubClass;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Server.MyClass.Caches;
|
||||||
|
using Server.Events;
|
||||||
|
using Server.Services.DataMigration;
|
||||||
|
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
internal class Client
|
||||||
|
{
|
||||||
|
public EventManager Events { get; private set; }
|
||||||
|
|
||||||
|
private static Client _client;
|
||||||
|
public static Client SingleClient { get { if (_client == null) _client = new Client(); return _client; } }
|
||||||
|
|
||||||
|
public string InternetIP { get; private set; }
|
||||||
|
public Config Config { get; private set; }
|
||||||
|
|
||||||
|
public OwinServer OwinServer { get; private set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
private SessionTimer DeviceSessionTimer = null;
|
||||||
|
private TbUpdateorderTimer TbUpdateorderTimer = null;
|
||||||
|
private TbSpecialTimer TbSpecialTimer = null;
|
||||||
|
private OldUserActivationTimer OldUserActivationTimer = null;
|
||||||
|
private FinishOrderTimer FinishOrderTimer = null;
|
||||||
|
private MtOrderTimer MtOrderTimer = null;
|
||||||
|
private JDOrderTimer JDOrderTimer = null;
|
||||||
|
private PDDOrderTimer PDDOrderTimer = null;
|
||||||
|
private TbUpdateRefundOrderTimer TbUpdateRefundOrderTimer = null;
|
||||||
|
private UpdateCookiesTimer UpdateCookiesTimer = null;
|
||||||
|
private WeiPinHuiTimer WeiPinHuiTimer = null;
|
||||||
|
private SystemTimer SystemTimer = null;
|
||||||
|
/// <summary>
|
||||||
|
/// 收到的消息
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, DeviceReplyMessage> ReplyMessages { get; set; }
|
||||||
|
private Client()
|
||||||
|
{
|
||||||
|
Config = new Config();
|
||||||
|
InternetIP = Util.QueryInternetIP();
|
||||||
|
}
|
||||||
|
public bool IsDebug { get; private set; }
|
||||||
|
|
||||||
|
public void InitSystem()
|
||||||
|
{
|
||||||
|
this.Db.SetDefaultConnection();
|
||||||
|
this.Db.InitTables();
|
||||||
|
this.Db.InitDefaultData();
|
||||||
|
this.Config.RuntimeCache = Db.GetMapValue<RuntimeCache>("系统缓存", () => new RuntimeCache());
|
||||||
|
this.Events = new EventManager(this);
|
||||||
|
OwinServer = new OwinServer();
|
||||||
|
//MtOrderTimer = MyTimer.NewTimer<MtOrderTimer>(60);
|
||||||
|
JDOrderTimer = MyTimer.NewTimer<JDOrderTimer>(60);
|
||||||
|
//PDDOrderTimer = MyTimer.NewTimer<PDDOrderTimer>(60);
|
||||||
|
//WeiPinHuiTimer = MyTimer.NewTimer<WeiPinHuiTimer>(60);
|
||||||
|
//OldUserActivationTimer = MyTimer.NewTimer<OldUserActivationTimer>(60 * 60);
|
||||||
|
ReplyMessages = new Dictionary<string, DeviceReplyMessage>();
|
||||||
|
//UpdateCookiesTimer = MyTimer.NewTimer<UpdateCookiesTimer>(60);
|
||||||
|
//TbUpdateRefundOrderTimer = MyTimer.NewTimer<TbUpdateRefundOrderTimer>(60 * 60);
|
||||||
|
//MyTimer.NewTimer<TbUpdateRefundOrderTimer>(1);
|
||||||
|
//MyTimer.NewTimer<SuningHuiTimer>(60);
|
||||||
|
//同步黑名单
|
||||||
|
//MyTimer.NewTimer<BlackTimer>(1);
|
||||||
|
//同步商品黑名单
|
||||||
|
//MyTimer.NewTimer<GoodsBlackTimer>(1);
|
||||||
|
//同步商店黑名单
|
||||||
|
//MyTimer.NewTimer<StoreBlackTimer>(60);
|
||||||
|
//同步抖音
|
||||||
|
//MyTimer.NewTimer<DyUpdateTimer>(60);
|
||||||
|
string baseAddress = $"http://*:{Config.Port}/";
|
||||||
|
|
||||||
|
WebApp.Start<OwinServer>(url: baseAddress);
|
||||||
|
|
||||||
|
var flag = false;
|
||||||
|
if (flag) //是否创建测试数据
|
||||||
|
{
|
||||||
|
Db.CreateTestData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//var u = Db.GetUser(1);
|
||||||
|
//if (u == null) u = new User() { Username = "test", UserType = Common.Models.Enums.UserType.微信用户, Headurl = String.Empty };
|
||||||
|
//Db.Save(u);
|
||||||
|
EO.WebBrowser.Runtime.AddLicense(
|
||||||
|
"N4SOscufWbPw+g7kp+rp9um7aOPt9BDtrNzpz7iJWZeksefgpePzCOmMQ5ek" +
|
||||||
|
"scufWZekzQzjnZf4ChvkdpnJ4NnCoenz/hChWe3pAx7oqOXBs92wZ6emsdq9" +
|
||||||
|
"RoGkscufdabl/RfusLWRm8ufWZfAAB3jnunN/xHuWdvlBRC8W6i2wNywaKm0" +
|
||||||
|
"w9uhWer58/D3qeD29h7ArbSmwt2uaqizw9uxapmkBxDxrODz/+iha6emsdq9" +
|
||||||
|
"RoGkscufdert+Bngrez29unLn9D7BR7Wb8T66/nCm6y40hu2b8zFzui7aOrt" +
|
||||||
|
"+Bngrez29umMQ7Oz/RTinuX39umMQ3Xj7fQQ7azcwp61n1mXpM0X6Jzc8gQQ" +
|
||||||
|
"yJ21uur5sXGqusrz0XCwtMTis4+zs/0U4p7l9/b043c=");
|
||||||
|
|
||||||
|
this.Url = $"http://{InternetIP}";
|
||||||
|
#if DEBUG
|
||||||
|
IsDebug = true;
|
||||||
|
Url = $"http://127.0.0.1";
|
||||||
|
#endif
|
||||||
|
if (Config.Port != 80) Url += ":" + Config.Port;
|
||||||
|
|
||||||
|
Events.OrderChange += Events_OrderChange;
|
||||||
|
//new Thread(() =>
|
||||||
|
//{
|
||||||
|
// DataMigrationManageSerivce.Instance.Test();
|
||||||
|
//}).Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Events_OrderChange(object sender, OrderChangeEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.UserId != 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var User = Db.GetUser(e.UserId);
|
||||||
|
if (User != null)
|
||||||
|
{
|
||||||
|
SendClientMsg(User.RobotId, DeviceMessageType.订单状态改变, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Db.OnLog("通知用户订单状态", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainForm Form { get; set; }
|
||||||
|
public HttpRuntimeCache Cache { get; set; } = new HttpRuntimeCache();
|
||||||
|
|
||||||
|
public SqlSugarClient Db
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = $"Data Source={Config.MysqlHost};Initial Catalog={Config.MysqlName};Persist Security Info=True;User ID={Config.MysqlUser};Password={Config.MysqlPass};Port={Config.MysqlPort};Min Pool Size = 3; Max Pool Size = 100;CharSet=utf8mb4;AllowLoadLocalInfile=true;Allow Zero Datetime=True;SslMode=none;Convert Zero Datetime=True;",//连接符字串
|
||||||
|
DbType = SqlSugar.DbType.MySql, //数据库类型
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
MoreSettings = new ConnMoreSettings()
|
||||||
|
{
|
||||||
|
IsAutoRemoveDataCache = true,
|
||||||
|
DefaultCacheDurationInSeconds = 86400,
|
||||||
|
},
|
||||||
|
ConfigureExternalServices = new ConfigureExternalServices()
|
||||||
|
{
|
||||||
|
DataInfoCacheService = Cache, //配置我们创建的缓存类,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
db.Aop.DataExecuting = (oldValue, entityInfo) =>
|
||||||
|
{
|
||||||
|
db.SetSplitTableService(entityInfo.EntityName);
|
||||||
|
};
|
||||||
|
|
||||||
|
db.Aop.OnError = (ex) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var temp = ex.Sql;
|
||||||
|
var time = db.Ado.SqlExecutionTime;
|
||||||
|
db.OnLog("SQL错误", $"{ex.Message},SQL => {ex.Sql}", Common.Models.Enums.LogType.错误);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
db.Aop.OnLogExecuted = (sql, pars) =>
|
||||||
|
{
|
||||||
|
if (db.Ado.SqlExecutionTime.TotalSeconds > 60)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var temp = sql;
|
||||||
|
|
||||||
|
var time = db.Ado.SqlExecutionTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IsDebug)
|
||||||
|
{
|
||||||
|
var temp = sql;
|
||||||
|
|
||||||
|
foreach (var item in pars) temp = temp.Replace(item.ParameterName, $"'{item.Value}'");
|
||||||
|
var time = db.Ado.SqlExecutionTime;
|
||||||
|
//Console.WriteLine($"SQL耗时:{time.TotalSeconds}、SQL => {sql}"); }
|
||||||
|
//WWW Console.WriteLine(sql,pars);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ConcurrentDictionary<string, DeviceSession> OnlineDevices { get { return Config.RuntimeCache.DeviceSessions; } }
|
||||||
|
public ConcurrentDictionary<int, UserSession> OnlineUsers { get { return Config.RuntimeCache.UserSessions; } }
|
||||||
|
public void SendAllClientMsg(DeviceMessageType Type, object Data)
|
||||||
|
{
|
||||||
|
var list = this.OnlineDevices.ToArray();
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
SendClientMsg(item.Key, Type, Data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceMessage SendClientMsg(int RobotId, DeviceMessageType Type, Object Data = null)
|
||||||
|
{
|
||||||
|
var deviceId = OnlineDevices.FirstOrDefault(f => f.Value.RobotId == RobotId).Key;
|
||||||
|
if (!string.IsNullOrEmpty(deviceId))
|
||||||
|
{
|
||||||
|
return SendClientMsg(deviceId, Type, Data);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public DeviceMessage SendClientMsg(string DeviceId, DeviceMessageType Type, Object Data = null)
|
||||||
|
{
|
||||||
|
if (OnlineDevices.ContainsKey(DeviceId))
|
||||||
|
{
|
||||||
|
var msg = new DeviceMessage() { Type = Type, Content = Data, Time = Util.GetTimespan(DateTime.Now) };
|
||||||
|
OnlineDevices[DeviceId].Messages.Enqueue(msg);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public Task<DeviceReplyMessage> GetClientMsg(string Msgid, int Timeout = 60)
|
||||||
|
{
|
||||||
|
return Task.Factory.StartNew<DeviceReplyMessage>(() =>
|
||||||
|
{
|
||||||
|
var ExpirationTime = DateTime.Now.AddSeconds(Timeout);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
if (ReplyMessages.ContainsKey(Msgid)) return ReplyMessages[Msgid];
|
||||||
|
} while (ExpirationTime > DateTime.Now);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
using CsharpHttpHelper;
|
||||||
|
using Server.Configs;
|
||||||
|
using Server.MyClass.Caches;
|
||||||
|
using Server.MyClass.Class;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
internal class Config
|
||||||
|
{
|
||||||
|
public int Port { get; set; }
|
||||||
|
public string Appsecret { get; set; }
|
||||||
|
|
||||||
|
public string MysqlName { get; set; }
|
||||||
|
public string MysqlUser { get; set; }
|
||||||
|
public string MysqlPass { get; set; }
|
||||||
|
public string MysqlHost { get; set; }
|
||||||
|
public int MysqlPort { get; set; }
|
||||||
|
|
||||||
|
public RuntimeCache RuntimeCache { get; set; }
|
||||||
|
|
||||||
|
public IniHelper Ini { get; private set; } = new IniHelper(HttpExtend.MapFile("配置.ini","Config"));
|
||||||
|
public Config()
|
||||||
|
{
|
||||||
|
|
||||||
|
Port = string.IsNullOrEmpty(Ini.GetValue("终端", "端口")) ? 80 : int.Parse(Ini.GetValue("终端", "端口"));
|
||||||
|
Appsecret = Ini.GetValue("终端", "密钥");
|
||||||
|
if (string.IsNullOrEmpty(Appsecret))
|
||||||
|
{
|
||||||
|
Appsecret = HttpExtend.GetMD5String(Guid.NewGuid().ToString());
|
||||||
|
Ini.SetValue("终端", "密钥", Appsecret);
|
||||||
|
Ini.SetValue("终端", "端口", Port.ToString());
|
||||||
|
}
|
||||||
|
MysqlName = Ini.GetValue("Mysql", "名称");
|
||||||
|
MysqlUser = Ini.GetValue("Mysql", "账号");
|
||||||
|
MysqlPass = Ini.GetValue("Mysql", "密码");
|
||||||
|
MysqlHost = Ini.GetValue("Mysql", "IP");
|
||||||
|
MysqlPort = string.IsNullOrEmpty(Ini.GetValue("Mysql", "端口")) ? 3306 : int.Parse(Ini.GetValue("Mysql", "端口"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,168 @@
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.DbExtends.Others;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Requests.Lianmengs;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.AccountManagement
|
||||||
|
{
|
||||||
|
public partial class LianmengController
|
||||||
|
{
|
||||||
|
#region 抖音代码
|
||||||
|
/// <summary>
|
||||||
|
/// 抖音- 查询
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetDouyinMedias()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pageSize = GetInt("PageSize", true);
|
||||||
|
var index = GetInt("PageIndex", true);
|
||||||
|
|
||||||
|
var LianmengId = GetInt("LianmengId");
|
||||||
|
|
||||||
|
var KeyWord = GetString("KeyWord");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<DyMedia>();
|
||||||
|
if (LianmengId > 0)
|
||||||
|
{
|
||||||
|
exp.And(f => f.LianmengId == LianmengId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(KeyWord))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Pid.Contains(KeyWord) || f.AdzoneName.Contains(KeyWord) || f.Remark.Contains(KeyWord));
|
||||||
|
}
|
||||||
|
|
||||||
|
exp.And(f => f.IsDelete == false);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<DyMedia>()
|
||||||
|
.LeftJoin<Lianmeng>((f, r) => f.LianmengId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((f, r) => new DyMediaShow
|
||||||
|
{
|
||||||
|
Id = f.Id,
|
||||||
|
LianmengId = f.LianmengId,
|
||||||
|
LianmengNick = r.Nickname,
|
||||||
|
Pid = f.Pid,
|
||||||
|
AdzoneName = f.AdzoneName,
|
||||||
|
MediaType = f.MediaType,
|
||||||
|
MediaName = f.MediaName,
|
||||||
|
Remark = f.Remark
|
||||||
|
|
||||||
|
})
|
||||||
|
.ToPageList(index, pageSize, ref tNumber);
|
||||||
|
|
||||||
|
//计算使用人数
|
||||||
|
foreach (var item in DataList)
|
||||||
|
{
|
||||||
|
item.UseCnt = Db.Queryable<Robot>().Count(p => p.TbMediaId1 == item.Id || p.TbMediaId2 == item.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData(new PageResult<DyMediaShow>(DataList, tNumber, pageSize, index));
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return PutData(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 抖音-新增
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddDouyinMedia()
|
||||||
|
{
|
||||||
|
var LianmengId = GetInt("LianmengId", true);
|
||||||
|
var AdzoneName = GetString("AdzoneName", true);
|
||||||
|
var MediaName = GetString("MediaName", true);
|
||||||
|
var MediaType = GetEnum<DouyinMediaType>("MediaType", true);
|
||||||
|
var Remark = GetString("Remark", false);
|
||||||
|
var lm = Db.GetLianmeng(LianmengId);
|
||||||
|
DouyinRequest req = new DouyinRequest(lm);
|
||||||
|
var Pid = req.CreateDouyinPidAdzone(AdzoneName, MediaName, MediaType, true);
|
||||||
|
var media = new DyMedia()
|
||||||
|
{
|
||||||
|
AdzoneName = AdzoneName,
|
||||||
|
MediaName = MediaName,
|
||||||
|
IsDelete = false,
|
||||||
|
LianmengId = LianmengId,
|
||||||
|
MediaType = MediaType,
|
||||||
|
Pid = Pid,
|
||||||
|
Remark = Remark,
|
||||||
|
UpdateTime = 0
|
||||||
|
};
|
||||||
|
Db.Save(media);
|
||||||
|
return PutData(media);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 抖音-修改推广位名称
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdDouyinAdzoneName()
|
||||||
|
{
|
||||||
|
var id = GetInt("MediaId", true);
|
||||||
|
var dyMedia = Db.GetDyMedia(id);
|
||||||
|
if (dyMedia == null) return PutData("编辑失败,未找到该推广位信息");
|
||||||
|
|
||||||
|
var dyLianmeng = Db.GetLianmeng(dyMedia.LianmengId);
|
||||||
|
if (dyLianmeng == null) return PutData("编辑失败,未找到该联盟信息");
|
||||||
|
|
||||||
|
|
||||||
|
var AdzoneName = GetString("AdzoneName", true);
|
||||||
|
|
||||||
|
DouyinRequest req = new DouyinRequest(dyLianmeng, dyMedia);
|
||||||
|
|
||||||
|
|
||||||
|
req.UpdateDouyinPidAdzone(dyMedia.Pid, AdzoneName, true);
|
||||||
|
|
||||||
|
dyMedia.AdzoneName = AdzoneName;
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
if (!string.IsNullOrEmpty(remark))
|
||||||
|
dyMedia.Remark = remark;
|
||||||
|
Db.Save(dyMedia);
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 抖音 - 删除推广位
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult DelDouyinMedia()
|
||||||
|
{
|
||||||
|
var lianmengId = GetInt("LianmengId", true);
|
||||||
|
var dyPids = GetStringList("DyPids", true);
|
||||||
|
if (dyPids != null && dyPids.Count > 0)
|
||||||
|
{
|
||||||
|
//去抖音API执行真实删除
|
||||||
|
var dyLianmeng = Db.GetLianmeng(lianmengId);
|
||||||
|
if (dyLianmeng != null)
|
||||||
|
{
|
||||||
|
var req = new DouyinRequest(dyLianmeng);
|
||||||
|
req.DeleteDouyinPidAdzone(dyPids.ToArray(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var rst =Db.Deleteable<DyMedia>().Where(f => dyPids.Contains(f.Pid) && f.LianmengId == lianmengId).ExecuteCommand();
|
||||||
|
DataCache.RemoveByPattern(@"cache_dymedia_[\d]+");
|
||||||
|
}
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,435 @@
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace Server.Controllers.AccountManagement
|
||||||
|
{
|
||||||
|
public class RobotController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查询机器人
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobots()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var TotalNumber = 0;
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword) || f.Username.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression()).ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var item in DataList)
|
||||||
|
{
|
||||||
|
var data = Client.SingleClient.OnlineDevices.FirstOrDefault(f => f.Value.RobotId == item.Id).Value;
|
||||||
|
item.IsOnlineRobot = data != null;
|
||||||
|
}
|
||||||
|
return PutData(new PageResult<Robot>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除机器人
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelRobot()
|
||||||
|
{
|
||||||
|
|
||||||
|
var Data = Db.GetRobot(GetInt("Id", true));
|
||||||
|
if (Data != null && Db.Delete(Data) > 0)
|
||||||
|
{
|
||||||
|
Client.SendClientMsg(Data.Id, DeviceMessageType.退出机器人, new { RobotId = Data.Id });
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
else return PutData("删除失败,机器人信息不存在!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录机器人
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult LoginRobot()
|
||||||
|
{
|
||||||
|
|
||||||
|
var Id = GetInt("RobotId", true);
|
||||||
|
var Robot = Db.Queryable<Robot>().Single(f => f.Id == Id);
|
||||||
|
if (Robot == null) return PutData("找不到该机器人数据!");
|
||||||
|
|
||||||
|
var device = Db.Queryable<Device>().Where(f => f.RobotId == Robot.Id).OrderBy(f => f.LoginTime, OrderByType.Desc).First();
|
||||||
|
if (device == null)
|
||||||
|
return PutData("登录失败,未发现该机器人上次登录的设备信息");
|
||||||
|
|
||||||
|
var Msg = Client.SendClientMsg(device.Id, DeviceMessageType.登录机器人, new { RobotId = Id });
|
||||||
|
if (Msg == null)
|
||||||
|
return PutData("登录失败,设备离线请检查软件状态");
|
||||||
|
|
||||||
|
var Rst = Client.GetClientMsg(Msg.Msgid).Result;
|
||||||
|
if (Rst == null) return PutData("登录失败,未获取到二维码信息请检查软件状态");
|
||||||
|
|
||||||
|
return PutData(new { Type = Robot.UserType, Qrcode = Rst.Content });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退出机器人
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult LogoutRobot()
|
||||||
|
{
|
||||||
|
var Id = GetInt("RobotId",true);
|
||||||
|
var Robot = Db.Queryable<Robot>().Single(f => f.Id == Id);
|
||||||
|
if (Robot == null) return PutData("找不到该机器人数据!");
|
||||||
|
Robot.LoginTime = DateTime.MinValue;
|
||||||
|
Db.Updateable<Robot>(Robot).ExecuteCommand();
|
||||||
|
Client.SendClientMsg(Robot.Id, DeviceMessageType.退出机器人, new { RobotId = Robot.Id });
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询机器人详细信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobot()
|
||||||
|
{
|
||||||
|
var Id = GetInt("RobotId",true);
|
||||||
|
var Robot = Db.Queryable<Robot>().Single(f => f.Id == Id);
|
||||||
|
if (Robot == null) return PutData("找不到该机器人数据!");
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("RobotId", true);
|
||||||
|
var Robot = Db.Queryable<Robot>().Single(f => f.Id == Id);
|
||||||
|
if (Robot == null) return PutData("查询失败,找不到该机器人信息!");
|
||||||
|
RobotSettingShow config = new RobotSettingShow();
|
||||||
|
|
||||||
|
var tbMedia1 = Robot.TbMediaId1 > 0 ? Db.GetTbMedia(Robot.TbMediaId1) : null;
|
||||||
|
var tbMedia2 = Robot.TbMediaId2 > 0 ? Db.GetTbMedia(Robot.TbMediaId2) : null;
|
||||||
|
var tbLianmeng1 = tbMedia1 != null ? Db.GetLianmeng(tbMedia1.LianmengId) : null;
|
||||||
|
var tbLianmeng2 = tbMedia2 != null ? Db.GetLianmeng(tbMedia2.LianmengId) : null;
|
||||||
|
config.TbLianmengId1 = tbLianmeng1 != null ? tbLianmeng1.Id : 0;
|
||||||
|
config.TbLianmengId2 = tbLianmeng2 != null ? tbLianmeng2.Id : 0;
|
||||||
|
config.TbLianmengNick1 = tbLianmeng1 != null ? tbLianmeng1.Showname : String.Empty;
|
||||||
|
config.TbLianmengNick2 = tbLianmeng2 != null ? tbLianmeng2.Showname : String.Empty;
|
||||||
|
config.TbMediaNick1 = tbMedia1 != null ? tbMedia1.AdzoneName : String.Empty;
|
||||||
|
config.TbMediaNick2 = tbMedia2!=null? tbMedia2.AdzoneName :String.Empty;
|
||||||
|
config.TbMediaId1 = tbMedia1!=null ? tbMedia1.Id : 0;
|
||||||
|
config.TbMediaId2 = tbMedia2!=null? tbMedia2.Id : 0;
|
||||||
|
|
||||||
|
|
||||||
|
var dyMedia1 = Robot.DyMediaId1 > 0 ? Db.GetDyMedia(Robot.DyMediaId1) : null;
|
||||||
|
var dyMedia2 = Robot.DyMediaId2 > 0 ? Db.GetDyMedia(Robot.DyMediaId2) : null;
|
||||||
|
var dyLianmeng1 = dyMedia1 != null ? Db.GetLianmeng(dyMedia1.LianmengId) : null;
|
||||||
|
var dyLianmeng2 = dyMedia2 != null ? Db.GetLianmeng(dyMedia2.LianmengId) : null;
|
||||||
|
config.DyLianmengId1 = dyLianmeng1 != null ? dyLianmeng1.Id : 0;
|
||||||
|
config.DyLianmengId2 = dyLianmeng2 != null ? dyLianmeng2.Id : 0;
|
||||||
|
config.DyLianmengNick1 = dyLianmeng1 != null ? dyLianmeng1.Showname : String.Empty;
|
||||||
|
config.DyLianmengNick2 = dyLianmeng2 != null ? dyLianmeng2.Showname : String.Empty;
|
||||||
|
config.DyMediaNick1 = dyMedia1 != null ? dyMedia1.AdzoneName : String.Empty;
|
||||||
|
config.DyMediaNick2 = dyMedia2 != null ? dyMedia2.AdzoneName : String.Empty;
|
||||||
|
config.DyMediaId1 = dyMedia1 != null ? dyMedia1.Id : 0;
|
||||||
|
config.DyMediaId2 = dyMedia2 != null ? dyMedia2.Id : 0;
|
||||||
|
|
||||||
|
|
||||||
|
var jdMedia1 = Robot.JdMediaId1 > 0 ? Db.GetJdMedia(Robot.JdMediaId1) : null;
|
||||||
|
var jdMedia2 = Robot.JdMediaId2 > 0 ? Db.GetJdMedia(Robot.JdMediaId2) : null;
|
||||||
|
var jdLianmeng1 = jdMedia1 != null ? Db.GetLianmeng(jdMedia1.LianmengId) : null;
|
||||||
|
var jdLianmeng2 = jdMedia2 != null ? Db.GetLianmeng(jdMedia2.LianmengId) : null;
|
||||||
|
config.JdLianmengId1 = jdLianmeng1 != null ? jdLianmeng1.Id : 0;
|
||||||
|
config.JdLianmengId2 = jdLianmeng2 != null ? jdLianmeng1.Id : 0;
|
||||||
|
config.JdLianmengNick1 = jdLianmeng1 != null ? jdLianmeng1.Showname : String.Empty;
|
||||||
|
config.JdLianmengNick2 = jdLianmeng2 != null ? jdLianmeng2.Showname : String.Empty;
|
||||||
|
config.JdMediaNick1 = jdMedia1 != null ? jdMedia1.AdzoneName : String.Empty;
|
||||||
|
config.JdMediaNick2 = jdMedia2 != null ? jdMedia2.AdzoneName : String.Empty;
|
||||||
|
config.JdMediaId1 = jdMedia1 != null ? jdMedia1.Id : 0;
|
||||||
|
config.JdMediaId2 = jdMedia2 != null ? jdMedia2.Id : 0;
|
||||||
|
|
||||||
|
|
||||||
|
var wphMedia1 = Robot.WphMediaId1 > 0 ? Db.GetWphMedia(Robot.WphMediaId1) : null;
|
||||||
|
var wphMedia2 = Robot.WphMediaId2 > 0 ? Db.GetWphMedia(Robot.WphMediaId2) : null;
|
||||||
|
var wphLianmeng1 = wphMedia1 != null ? Db.GetLianmeng(wphMedia1.LianmengId) : null;
|
||||||
|
var wphLianmeng2 = wphMedia1 != null ? Db.GetLianmeng(wphMedia2.LianmengId) : null;
|
||||||
|
config.WphLianmengId1 = wphLianmeng1 != null ? wphLianmeng1.Id : 0;
|
||||||
|
config.WphLianmengId2 = wphLianmeng2 != null ? wphLianmeng1.Id : 0;
|
||||||
|
config.WphLianmengNick1 = wphLianmeng1 != null ? wphLianmeng1.Showname : String.Empty;
|
||||||
|
config.WphLianmengNick2 = wphLianmeng2 != null ? wphLianmeng2.Showname : String.Empty;
|
||||||
|
config.WphMediaNick1 = wphMedia1 != null ? wphMedia1.AdzoneName : String.Empty;
|
||||||
|
config.WphMediaNick2 = wphMedia2 != null ? wphMedia2.AdzoneName : String.Empty;
|
||||||
|
config.WphMediaId1 = wphMedia1 != null ? wphMedia1.Id : 0;
|
||||||
|
config.WphMediaId2 = wphMedia2 != null ? wphMedia2.Id : 0;
|
||||||
|
|
||||||
|
|
||||||
|
var pddMedia1 = Robot.PddMediaId1 > 0 ? Db.GetPddMedia(Robot.PddMediaId1) : null;
|
||||||
|
var pddMedia2 = Robot.PddMediaId2 > 0 ? Db.GetPddMedia(Robot.PddMediaId2) : null;
|
||||||
|
var pddLianmeng1 = pddMedia1 != null ? Db.GetLianmeng(pddMedia1.LianmengId) : null;
|
||||||
|
var pddLianmeng2 = pddMedia2 != null ? Db.GetLianmeng(pddMedia2.LianmengId) : null;
|
||||||
|
config.PddLianmengId1 = pddLianmeng1 != null ? pddLianmeng1.Id : 0;
|
||||||
|
config.PddLianmengId2 = pddLianmeng2 != null ? pddLianmeng1.Id : 0;
|
||||||
|
config.PddLianmengNick1 = pddLianmeng1 != null ? pddLianmeng1.Showname : String.Empty;
|
||||||
|
config.PddLianmengNick2 = pddLianmeng2 != null ? pddLianmeng2.Showname : String.Empty;
|
||||||
|
config.PddMediaNick1 = pddMedia1 != null ? pddMedia1.AdzoneName : String.Empty;
|
||||||
|
config.PddMediaNick2 = pddMedia2 != null ? pddMedia2.AdzoneName : String.Empty;
|
||||||
|
config.PddMediaId1 = pddMedia1 != null ? pddMedia1.Id : 0;
|
||||||
|
config.PddMediaId2 = pddMedia2 != null ? pddMedia2.Id : 0;
|
||||||
|
|
||||||
|
|
||||||
|
var snLianmeng1 = Robot.SnLianmengId1 > 0 ? Db.GetLianmeng(Robot.SnLianmengId1) : null;
|
||||||
|
var snLianmeng2 = Robot.SnLianmengId2 > 0 ? Db.GetLianmeng(Robot.SnLianmengId2) : null;
|
||||||
|
config.SnLianmengId1 = snLianmeng1 != null ? snLianmeng1.Id : 0;
|
||||||
|
config.SnLianmengId2 = snLianmeng2 != null ? snLianmeng1.Id : 0;
|
||||||
|
config.SnLianmengNick1 = snLianmeng1 != null ? snLianmeng1.Showname : String.Empty;
|
||||||
|
config.SnLianmengNick2 = snLianmeng2 != null ? snLianmeng2.Showname : String.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var mtMedia1 = Robot.MtMediaId1 > 0 ? Db.GetMtMedia(Robot.MtMediaId1) : null;
|
||||||
|
var mtMedia2 = Robot.MtMediaId2 > 0 ? Db.GetMtMedia(Robot.MtMediaId2) : null;
|
||||||
|
var mtLianmeng1 = mtMedia1 != null ? Db.GetLianmeng(mtMedia1.LianmengId) : null;
|
||||||
|
var mtLianmeng2 = mtMedia2 != null ? Db.GetLianmeng(mtMedia2.LianmengId) : null;
|
||||||
|
config.MtLianmengId1 = mtLianmeng1 != null ? mtLianmeng1.Id : 0;
|
||||||
|
config.MtLianmengId2 = mtLianmeng2 != null ? mtLianmeng1.Id : 0;
|
||||||
|
config.MtLianmengNick1 = mtLianmeng1 != null ? mtLianmeng1.Showname : String.Empty;
|
||||||
|
config.MtLianmengNick2 = mtLianmeng2 != null ? mtLianmeng2.Showname : String.Empty;
|
||||||
|
config.MtMediaNick1 = mtMedia1 != null ? mtMedia1.AdzoneName : String.Empty;
|
||||||
|
config.MtMediaNick2 = mtMedia2 != null ? mtMedia2.AdzoneName : String.Empty;
|
||||||
|
config.MtMediaId1 = mtMedia1 != null ? mtMedia1.Id : 0;
|
||||||
|
config.MtMediaId2 = mtMedia2 != null ? mtMedia2.Id : 0;
|
||||||
|
|
||||||
|
|
||||||
|
config.ConfigRebateName = Robot.ConfigRebateId>0? Db.Queryable<ConfigData>().Where(f => f.Id == Robot.ConfigRebateId).Select(f=>f.Name).First():String.Empty;
|
||||||
|
config.ConfigReplyName = Robot.ConfigReplyId > 0 ? Db.Queryable<ConfigData>().Where(f => f.Id == Robot.ConfigReplyId).Select(f => f.Name).First() : String.Empty;
|
||||||
|
config.ConfibBaseName = Robot.ConfigBaseId > 0 ? Db.Queryable<ConfigData>().Where(f => f.Id == Robot.ConfigBaseId).Select(f => f.Name).First() : String.Empty;
|
||||||
|
config.ConfigBaseId = Robot.ConfigBaseId;
|
||||||
|
config.ConfigRebateId = Robot.ConfigRebateId;
|
||||||
|
config.ConfigReplyId = Robot.ConfigReplyId;
|
||||||
|
|
||||||
|
return PutData(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存配置
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult SetConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("RobotId", true);
|
||||||
|
var Robot = Db.Queryable<Robot>().Single(f => f.Id == Id);
|
||||||
|
if (Robot == null) return PutData("保存失败,找不到该机器人信息!");
|
||||||
|
|
||||||
|
Robot.ConfigBaseId = GetInt("ConfigBaseId",true);
|
||||||
|
Robot.ConfigRebateId = GetInt("ConfigRebateId", true);
|
||||||
|
Robot.ConfigReplyId = GetInt("ConfigReplyId", true);
|
||||||
|
Robot.TbMediaId1 = GetInt("TbMediaId1",true);
|
||||||
|
Robot.TbMediaId2 = GetInt("TbMediaId2", true);
|
||||||
|
Robot.DyMediaId1 = GetInt("DyMediaId1", true);
|
||||||
|
Robot.DyMediaId2 = GetInt("DyMediaId2", true);
|
||||||
|
Robot.JdMediaId1 = GetInt("JdMediaId1", true);
|
||||||
|
Robot.JdMediaId1 = GetInt("JdMediaId2", true);
|
||||||
|
Robot.MtMediaId1 = GetInt("MtMediaId1", true);
|
||||||
|
Robot.MtMediaId2 = GetInt("MtMediaId2", true);
|
||||||
|
Robot.WphMediaId1 = GetInt("WphMediaId1", true);
|
||||||
|
Robot.WphMediaId2 = GetInt("WphMediaId2", true);
|
||||||
|
Robot.PddMediaId1 = GetInt("PddMediaId1", true);
|
||||||
|
Robot.PddMediaId2 = GetInt("PddMediaId2", true);
|
||||||
|
Robot.SnLianmengId1 = GetInt("SnLianmengId1", true);
|
||||||
|
Robot.SnLianmengId2 = GetInt("SnLianmengId2", true);
|
||||||
|
Db.Save(Robot);
|
||||||
|
Client.SendClientMsg(Robot.Id, DeviceMessageType.机器人配置更新, new { RobotId = Robot.Id }); return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取联盟
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetLianmengs()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var LianmengType = GetEnum<LianmengType>("LianmengType",true);
|
||||||
|
var exp = Expressionable.Create<Lianmeng>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword) || f.Username.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
exp.And(f=>f.LianmengType == LianmengType);
|
||||||
|
var Lianmengs = Db.Queryable<Lianmeng>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(f => new NameShow { Id = f.Id, Name = f.Nickname })
|
||||||
|
.Take(20).
|
||||||
|
OrderBy(f => f.Id, OrderByType.Desc)
|
||||||
|
.ToList();
|
||||||
|
;
|
||||||
|
return PutData(Lianmengs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取联盟
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetMedias()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var LianmengId = GetInt("LianmengId",true);
|
||||||
|
var lianmeng = Db.GetLianmeng(LianmengId);
|
||||||
|
if (lianmeng == null) return PutData("查询失败,当前联盟账号不存在!");
|
||||||
|
switch (lianmeng.LianmengType)
|
||||||
|
{
|
||||||
|
case Common.Models.Enums.LianmengType.淘宝联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<TbMedia>();
|
||||||
|
exp.And(f => f.LianmengId == LianmengId);
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.AdzoneName.Contains(Keyword) || f.Pid.Contains(Keyword));
|
||||||
|
}
|
||||||
|
exp.And(f=>f.IsRemove == false);
|
||||||
|
var Results = Db.Queryable<TbMedia>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(f => new NameShow { Id = f.Id, Name = f.AdzoneName })
|
||||||
|
.Take(20)
|
||||||
|
.OrderBy(f => f.Id, OrderByType.Desc)
|
||||||
|
.ToList();
|
||||||
|
return PutData(Results);
|
||||||
|
}
|
||||||
|
case Common.Models.Enums.LianmengType.京东联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<JdMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.AdzoneName.Contains(Keyword));
|
||||||
|
}
|
||||||
|
exp.And(f => f.LianmengId == LianmengId);
|
||||||
|
var Results = Db.Queryable<JdMedia>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(f => new NameShow { Id = f.Id, Name = f.AdzoneName })
|
||||||
|
.Take(20)
|
||||||
|
.OrderBy(f => f.Id, OrderByType.Desc)
|
||||||
|
.ToList();
|
||||||
|
return PutData(Results);
|
||||||
|
}
|
||||||
|
|
||||||
|
case Common.Models.Enums.LianmengType.拼多多联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<PddMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.AdzoneName.Contains(Keyword));
|
||||||
|
}
|
||||||
|
exp.And(f => f.LianmengId == LianmengId);
|
||||||
|
var Results = Db.Queryable<PddMedia>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(f => new NameShow { Id = f.Id, Name = f.AdzoneName })
|
||||||
|
.Take(20)
|
||||||
|
.OrderBy(f => f.Id, OrderByType.Desc)
|
||||||
|
.ToList();
|
||||||
|
return PutData(Results);
|
||||||
|
}
|
||||||
|
case Common.Models.Enums.LianmengType.唯品会联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<WphMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.AdzoneName.Contains(Keyword));
|
||||||
|
}
|
||||||
|
exp.And(f => f.LianmengId == LianmengId);
|
||||||
|
var Results = Db.Queryable<WphMedia>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(f => new NameShow { Id = f.Id, Name = f.AdzoneName })
|
||||||
|
.Take(20)
|
||||||
|
.OrderBy(f => f.Id, OrderByType.Desc)
|
||||||
|
.ToList();
|
||||||
|
return PutData(Results);
|
||||||
|
}
|
||||||
|
|
||||||
|
case Common.Models.Enums.LianmengType.苏宁联盟:
|
||||||
|
return PutData("查询失败,苏宁无需设置推广位!");
|
||||||
|
|
||||||
|
case Common.Models.Enums.LianmengType.抖音联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<DyMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.AdzoneName.Contains(Keyword));
|
||||||
|
}
|
||||||
|
exp.And(f => f.LianmengId == LianmengId);
|
||||||
|
var Results = Db.Queryable<DyMedia>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(f => new NameShow { Id = f.Id, Name = f.AdzoneName })
|
||||||
|
.Take(20)
|
||||||
|
.OrderBy(f => f.Id, OrderByType.Desc)
|
||||||
|
.ToList();
|
||||||
|
return PutData(Results);
|
||||||
|
}
|
||||||
|
case LianmengType.美团联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<MtMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.AdzoneName.Contains(Keyword));
|
||||||
|
}
|
||||||
|
exp.And(f => f.LianmengId == LianmengId);
|
||||||
|
var Results = Db.Queryable<MtMedia>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(f => new NameShow { Id = f.Id, Name = f.AdzoneName })
|
||||||
|
.Take(20)
|
||||||
|
.OrderBy(f => f.Id, OrderByType.Desc)
|
||||||
|
.ToList();
|
||||||
|
return PutData(Results);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutError;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取配置表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetConfigNames()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var ConfigType = GetEnum<ConfigType>("ConfigType", true);
|
||||||
|
var exp = Expressionable.Create<ConfigData>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(Keyword));
|
||||||
|
}
|
||||||
|
exp.And(f=>f.Type == ConfigType);
|
||||||
|
var result = Db.Queryable<ConfigData>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(f=>new NameShow{ Id = f.Id,Name = f.Name })
|
||||||
|
.Take(20)
|
||||||
|
.OrderBy(f=>f.Id, OrderByType.Desc)
|
||||||
|
.ToList();
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,259 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.Controllers.AccountManagement
|
||||||
|
{
|
||||||
|
public class StaffController:DefaultController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询子账号
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetStaffs()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var TotalNumber = 0;
|
||||||
|
var exp = Expressionable.Create<Staff>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(a => a.Username.Contains(Keyword) || a.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<Staff>()
|
||||||
|
.LeftJoin<Role>((a,b)=>a.RoleId == b.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((a,b)=>new StaffShow() { Id = a.Id, CreateTime = a.CreateTime,IsCreator = a.IsCreator,Password = a.IsCreator?String.Empty:a.Password ,Remark = a.Remark ,RoleId = b.Id,RoleName = b.Name,Username = a.Username, IsEnable = a.IsEnable})
|
||||||
|
.ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
|
||||||
|
return PutData(new PageResult<StaffShow>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增子账号
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddStaff()
|
||||||
|
{
|
||||||
|
var Username = GetString("Username",true);
|
||||||
|
var Remark = GetString("Remark");
|
||||||
|
var Password = GetString("Password",true);
|
||||||
|
var RoleId = GetInt("RoleId",true);
|
||||||
|
|
||||||
|
var Role = Db.Queryable<Role>().Single(f => f.Id == RoleId);
|
||||||
|
if (Role == null) return PutData("对不起,该权限不存在!");
|
||||||
|
|
||||||
|
var Staff = Db.Queryable<Staff>().Where(f=>f.Username == Username).First();
|
||||||
|
if(Staff!=null) return PutData("对不起,该子账号名称已存在!");
|
||||||
|
var IsEnable = GetBoolean("IsEnable");
|
||||||
|
Staff = new Staff()
|
||||||
|
{
|
||||||
|
Username = Username,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
Password = Password,
|
||||||
|
Remark = Remark,
|
||||||
|
RoleId = RoleId,
|
||||||
|
IsEnable = IsEnable,
|
||||||
|
IsCreator = false
|
||||||
|
};
|
||||||
|
Staff.Id = (int)Db.Insertable<Staff>(Staff).ExecuteReturnBigIdentity();
|
||||||
|
return PutData(Staff);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用或禁用员工
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult EnableStaff()
|
||||||
|
{
|
||||||
|
var StaffId = GetInt("StaffId",true);
|
||||||
|
//var Remark = GetString("Remark");
|
||||||
|
//var Password = GetString("Password");
|
||||||
|
//var RoleId = GetInt("RoleId");
|
||||||
|
var IsEnable = GetBoolean("IsEnable",true);
|
||||||
|
|
||||||
|
//var Role = Db.Queryable<Role>().Single(f => f.Id == RoleId);
|
||||||
|
//if (Role == null) return PutData("对不起,该权限不存在!");
|
||||||
|
|
||||||
|
|
||||||
|
var Staff = Db.Queryable<Staff>().Single(f => f.Id == StaffId);
|
||||||
|
if (Staff == null) return PutData("对不起,该子账号不存在!");
|
||||||
|
else if (Staff.IsCreator) return PutData("操作失败,管理员账号禁止操作");
|
||||||
|
|
||||||
|
//Staff.Remark = Remark;
|
||||||
|
//Staff.Password = Password;
|
||||||
|
//Staff.RoleId = RoleId;
|
||||||
|
Staff.IsEnable = IsEnable;
|
||||||
|
Db.Updateable(Staff).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑子账号
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdStaff()
|
||||||
|
{
|
||||||
|
var StaffId = GetInt("StaffId",true);
|
||||||
|
var Remark = GetString("Remark");
|
||||||
|
var Password = GetString("Password");
|
||||||
|
var RoleId = GetInt("RoleId");
|
||||||
|
var IsEnable = GetBoolean("IsEnable");
|
||||||
|
|
||||||
|
var Role = Db.Queryable<Role>().Single(f => f.Id == RoleId);
|
||||||
|
if (Role == null) return PutData("对不起,该权限不存在!");
|
||||||
|
|
||||||
|
|
||||||
|
var Staff = Db.Queryable<Staff>().Single(f => f.Id == StaffId);
|
||||||
|
if (Staff == null) return PutData("对不起,该子账号不存在!");
|
||||||
|
else if (Staff.IsCreator) return PutData("操作失败,管理员账号禁止编辑");
|
||||||
|
|
||||||
|
|
||||||
|
Staff.Remark = Remark;
|
||||||
|
Staff.Password = String.IsNullOrEmpty(Password)?Staff.Password: Password;
|
||||||
|
Staff.RoleId = RoleId;
|
||||||
|
Staff.IsEnable = IsEnable;
|
||||||
|
Db.Updateable(Staff).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除子账号
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelStaff()
|
||||||
|
{
|
||||||
|
var Id = GetInt("StaffId");
|
||||||
|
var Rst = Db.Deleteable<Staff>().Where(f => f.Id == Id && f.IsCreator == false).ExecuteCommand();
|
||||||
|
if (Rst > 0) return PutSuccess;
|
||||||
|
else return PutData("删除失败,未找到数据!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static List<string> AllRoles = new List<string> { "Anlyze", "Data", "Tools", "Artificial", "Qunfa", "Social", "Account", "Lianmeng", "Robot", "Staff", "Member", "Grouping", "WechatUser", "Fans", "Blacklist", "Reminder", "Func", "Pub", "Base", "Rebate", "Feed", "Keywords", "Order", "TbOrder", "JdOrder", "DyOrder", "MtOrder", "SnOrder", "WphOrder", "PddOrder", "Financial", "CashList", "PayRecord", "IntegralRecord", "Help", "RunLog", "QA", "Guide", "About" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询权限
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRoles()
|
||||||
|
{
|
||||||
|
var List = Db.Queryable<Role>().OrderBy(f => f.Id, OrderByType.Desc).ToList();
|
||||||
|
var superRole = List.FirstOrDefault(f => f.Name == "超级管理员");
|
||||||
|
if (superRole != null)
|
||||||
|
{
|
||||||
|
superRole.ControllerNames = AllRoles;
|
||||||
|
}
|
||||||
|
return PutData(List);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据角色ID获取角色权限列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRole()
|
||||||
|
{
|
||||||
|
var RoleId = Session.RoleId;
|
||||||
|
|
||||||
|
var Role = Db.Queryable<Role>().Single(f => f.Id == RoleId);
|
||||||
|
if (Role == null) return PutData("对不起,该权限不存在!");
|
||||||
|
else if(Role.Name=="超级管理员") Role.ControllerNames = AllRoles;
|
||||||
|
return PutData(Role);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除权限
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelRole()
|
||||||
|
{
|
||||||
|
var Id = GetInt("RoleId",true);
|
||||||
|
|
||||||
|
|
||||||
|
var Role = Db.Queryable<Role>().Single(f=>f.Id ==Id);
|
||||||
|
if (Role != null && Role.Name == "超级管理员") return PutData("对不起,超级管理员权限禁止删除");
|
||||||
|
|
||||||
|
var Rst = Db.Deleteable<Role>().RemoveDataCache().Where(f => f.Id == Id).ExecuteCommand();
|
||||||
|
if (Rst > 0)
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
else return PutData("删除失败,未找到数据!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑权限
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdRole()
|
||||||
|
{
|
||||||
|
var RoleId = GetInt("RoleId",true);
|
||||||
|
|
||||||
|
var Name = GetString("Name",true);
|
||||||
|
var Roles = GetString("ControllerNames",true);
|
||||||
|
|
||||||
|
var Role = Db.Queryable<Role>().Single(f => f.Id == RoleId);
|
||||||
|
if (Role == null) return PutData("对不起,该权限不存在!");
|
||||||
|
else if (Role != null && Role.Name == "超级管理员") return PutData("对不起,超级管理员权限禁止修改");
|
||||||
|
|
||||||
|
Role.Name = Name;
|
||||||
|
Role.ControllerNames = Roles.Split(',').ToList();
|
||||||
|
|
||||||
|
Db.Updateable(Role).RemoveDataCache().ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增权限
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddRole()
|
||||||
|
{
|
||||||
|
|
||||||
|
var Name = GetString("Name");
|
||||||
|
var Roles = GetString("ControllerNames");
|
||||||
|
|
||||||
|
var Role = Db.Queryable<Role>().Where(f => f.Name == Name).First();
|
||||||
|
if (Role != null) return PutData("对不起,该权限已存在!");
|
||||||
|
Role = new Role()
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
ControllerNames = Roles.Split(',').ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
Role = Db.Insertable(Role).RemoveDataCache().ExecuteReturnEntity();
|
||||||
|
return PutData(Role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.Controllers.ClientManagement
|
||||||
|
{
|
||||||
|
public class ClientController:DefaultController
|
||||||
|
{
|
||||||
|
public WebResult Connection()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关闭
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult Close()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.DataOverviewController
|
||||||
|
{
|
||||||
|
public class DataViewController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 今日数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetData()
|
||||||
|
{
|
||||||
|
//var MaxTimeToday = DateTime.Now; //当前时间
|
||||||
|
//var MinTimeToday = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());//当天0点
|
||||||
|
|
||||||
|
//今日数据
|
||||||
|
var Today = DateTime.Now.Date;
|
||||||
|
var dataToday = Db.Queryable<DataOverview>().Where(f=>f.CreateTime.Date == Today).First();
|
||||||
|
|
||||||
|
if (dataToday == null)
|
||||||
|
dataToday = new DataOverview();
|
||||||
|
|
||||||
|
//var MinTimeYesterday = Convert.ToDateTime(DateTime.Now.ToString("D")).AddDays(-1);//昨天0点
|
||||||
|
//var MaxTimeYesterday = Convert.ToDateTime(DateTime.Now.ToString("D")).AddSeconds(-1);//昨天23点59分59秒
|
||||||
|
|
||||||
|
//昨日数据
|
||||||
|
var Yesterday = DateTime.Now.AddDays(-1).Date;
|
||||||
|
var dataYesterday = Db.Queryable<DataOverview>().Where(f => f.CreateTime.Date == Yesterday).First();
|
||||||
|
|
||||||
|
if (dataYesterday == null)
|
||||||
|
dataYesterday = new DataOverview();
|
||||||
|
|
||||||
|
return PutData(new {
|
||||||
|
Today = dataToday,
|
||||||
|
Yesterday = dataYesterday,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定范围时间数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetDataOverview()
|
||||||
|
{
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddMonths(-2);
|
||||||
|
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<DataOverview>();
|
||||||
|
|
||||||
|
exp.And(f => f.CreateTime >= MinTime && f.CreateTime <= MaxTime);
|
||||||
|
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSzie = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<DataOverview>().Where(exp.ToExpression())
|
||||||
|
.ToPageList(PageIndex, PageSzie, ref tNumber);
|
||||||
|
|
||||||
|
return PutData(new PageResult<DataOverview>(DataList, tNumber, PageSzie, PageIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.DataOverviewController
|
||||||
|
{
|
||||||
|
public class DataViewController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 今日数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetTodayData()
|
||||||
|
{
|
||||||
|
var MaxTime = DateTime.Now; //当前时间
|
||||||
|
var MinTime = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());//当天0点
|
||||||
|
|
||||||
|
var data = Db.Queryable<DataOverview>().Where(f => f.Date == DateTime.Now.Date)
|
||||||
|
.SplitTable(MinTime, MaxTime).First();
|
||||||
|
|
||||||
|
if (data == null) data = new DataOverview();
|
||||||
|
|
||||||
|
return PutData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 昨日数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetYesterdayData()
|
||||||
|
{
|
||||||
|
var data = Db.Queryable<DataOverview>().Where(f => f.Date == DateTime.Now.AddDays(-1)).First();
|
||||||
|
|
||||||
|
if (data == null)
|
||||||
|
data = new DataOverview();
|
||||||
|
|
||||||
|
|
||||||
|
return PutData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取昨日/今日数据对比
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetViewData()
|
||||||
|
{
|
||||||
|
var yestoday = Db.Queryable<DataOverview>().Where(f => f.Date == DateTime.Now.AddDays(-1)).First();
|
||||||
|
if (yestoday == null)
|
||||||
|
{
|
||||||
|
yestoday = new DataOverview();
|
||||||
|
}
|
||||||
|
var MaxTime = DateTime.Now;
|
||||||
|
var MinTime = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
|
||||||
|
|
||||||
|
var today = Db.Queryable<DataOverview>().Where(f => f.Date == DateTime.Now.Date)
|
||||||
|
.SplitTable(MinTime, MaxTime).First();
|
||||||
|
|
||||||
|
if (today == null) today = new DataOverview();
|
||||||
|
|
||||||
|
return PutData(new {today = today, yestoday = yestoday });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定范围时间数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetDataOverview()
|
||||||
|
{
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddMonths(-2);
|
||||||
|
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<DataOverview>();
|
||||||
|
|
||||||
|
exp.And(f => f.Date > MinTime && f.Date < MaxTime);
|
||||||
|
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSzie = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<DataOverview>().Where(exp.ToExpression())
|
||||||
|
.SplitTable(MinTime,MaxTime)
|
||||||
|
.ToPageList(PageIndex, PageSzie, ref tNumber);
|
||||||
|
|
||||||
|
if (DataList == null)
|
||||||
|
return PutData(new PageResult<DataOverview>(new List<DataOverview>(), tNumber, PageSzie, PageIndex));
|
||||||
|
|
||||||
|
return PutData(new PageResult<DataOverview>(DataList, tNumber, PageSzie, PageIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,364 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Server.MyClass.Class;
|
||||||
|
using Server.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using System.Web.Http.Controllers;
|
||||||
|
using System.Web.Http.Filters;
|
||||||
|
|
||||||
|
namespace Server.Controllers
|
||||||
|
{
|
||||||
|
public class PageResult<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 下一页
|
||||||
|
/// </summary>
|
||||||
|
public bool IsNext { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上一页
|
||||||
|
/// </summary>
|
||||||
|
public bool IsBack { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据
|
||||||
|
/// </summary>
|
||||||
|
public Object Datas { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总数量
|
||||||
|
/// </summary>
|
||||||
|
public int TotalNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每页显示条数
|
||||||
|
/// </summary>
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总页码
|
||||||
|
/// </summary>
|
||||||
|
public int PageNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前页码
|
||||||
|
/// </summary>
|
||||||
|
public int PageIndex { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public PageResult(List<T> Datas, int TotalNumber, int PageSize, int PageIndex)
|
||||||
|
{
|
||||||
|
if (PageIndex <= 0 || PageSize <= 0) throw new Exception("Index或PageSize 有问题,请检查");
|
||||||
|
if (PageSize > 100) throw new Exception("每页查询数量,不能超过100");
|
||||||
|
|
||||||
|
PageNumber = 1;
|
||||||
|
if (TotalNumber != 0 && PageSize > 0)
|
||||||
|
{
|
||||||
|
PageNumber = TotalNumber / PageSize;
|
||||||
|
if (TotalNumber % PageSize != 0) PageNumber++;
|
||||||
|
}
|
||||||
|
this.Datas = Datas;
|
||||||
|
this.TotalNumber = TotalNumber;
|
||||||
|
this.PageNumber = PageNumber;
|
||||||
|
this.PageSize = PageSize;
|
||||||
|
this.PageIndex = PageIndex;
|
||||||
|
this.IsBack = PageIndex > 1;
|
||||||
|
this.IsNext = PageIndex < PageNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class WebResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 请求是否成功
|
||||||
|
/// </summary>
|
||||||
|
public bool Ok { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回信息
|
||||||
|
/// </summary>
|
||||||
|
public object Data { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 消耗时长
|
||||||
|
/// </summary>
|
||||||
|
public double Time { get; set; }
|
||||||
|
}
|
||||||
|
internal class ErrorFilterAttribute : ExceptionFilterAttribute
|
||||||
|
{
|
||||||
|
private DateTime startTime = DateTime.Now;
|
||||||
|
public override void OnException(HttpActionExecutedContext actionExecutedContext)
|
||||||
|
{
|
||||||
|
var rst = new WebResult() { Ok = false, Data = actionExecutedContext.Exception.Message };
|
||||||
|
rst.Time = Math.Round((DateTime.Now - startTime).TotalSeconds, 5);
|
||||||
|
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(rst), Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||||
|
actionExecutedContext.Response = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DefaultController : ApiController
|
||||||
|
{
|
||||||
|
protected UserSession Session { get; set; }
|
||||||
|
public string ControllerName { get; private set; }
|
||||||
|
private const string WebAppsecret = "d3913942-3c9f-1340-2091-c384196b6111";
|
||||||
|
private static List<string> NotloginActions = new List<string>() { "login", "logintaobaoresult", "getcaptch", "checkcaptch", "upload", "getwebinfo" };
|
||||||
|
private static List<string> NotCheckAcions = new List<string>() { "logintaobaocallback", "pinduoduo", "vip" };
|
||||||
|
private static List<string> NotCheckRoleController = new List<string>() { "Com", "Resources" };
|
||||||
|
public override async Task<HttpResponseMessage> ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
验证逻辑:从header中提取type,如果是web表示正常浏览器请求用默认的appsecret验证签名,如果是api是免登录api验证
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var req = controllerContext.Request;
|
||||||
|
ControllerName = req.RequestUri.AbsolutePath.Split(new char[] { '/' }).FirstOrDefault(p => !string.IsNullOrEmpty(p)).ToLower();
|
||||||
|
var ActionName = req.RequestUri.Segments.LastOrDefault(p => !string.IsNullOrEmpty(p)).ToLower().Replace("/", "").Replace("&", "");
|
||||||
|
|
||||||
|
if (NotCheckAcions.Any(p => p.ToLower() == ActionName))
|
||||||
|
{
|
||||||
|
return await base.ExecuteAsync(controllerContext, cancellationToken);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!req.Headers.Contains("type"))
|
||||||
|
{
|
||||||
|
throw new Exception("Illegal request 1");
|
||||||
|
}
|
||||||
|
var type = req.Headers.GetValues("type").FirstOrDefault();
|
||||||
|
if (type != "api" && type != "web")
|
||||||
|
{
|
||||||
|
throw new Exception("Illegal request 2");
|
||||||
|
}
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
var contentType = req.Content.Headers.ContentType;
|
||||||
|
if (contentType.MediaType != "multipart/form-data")
|
||||||
|
{
|
||||||
|
//获取请求参数
|
||||||
|
Param = await req.Content.ReadAsFormDataAsync(cancellationToken);
|
||||||
|
foreach (var item in Param.AllKeys)
|
||||||
|
{
|
||||||
|
var v = Param.Get(item);
|
||||||
|
if (!string.IsNullOrEmpty(v))
|
||||||
|
{
|
||||||
|
param.Add(item, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Param = new NameValueCollection();
|
||||||
|
var paras = req.GetQueryNameValuePairs();
|
||||||
|
foreach (var item in paras)
|
||||||
|
{
|
||||||
|
param[item.Key] = item.Value;
|
||||||
|
Param[item.Key] = item.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var time = req.Headers.GetValues("time").FirstOrDefault();
|
||||||
|
//设置appsecret,如果是web需要增加token和uid的值纳入sign判断条件
|
||||||
|
string token = string.Empty;
|
||||||
|
int uid = 0;
|
||||||
|
var appsecret = string.Empty;
|
||||||
|
if (type == "web")
|
||||||
|
{
|
||||||
|
appsecret = WebAppsecret;
|
||||||
|
//如果是web请求一定会携带uid和token,但未登录可能是空字符串不参与sign验证
|
||||||
|
if (!req.Headers.Contains("u_token") || !req.Headers.Contains("u_id")) throw new Exception("Illegal request 3");
|
||||||
|
token = req.Headers.GetValues("u_token").FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(token)) param.Add("u_token", token);
|
||||||
|
var uidstr = req.Headers.GetValues("u_id").FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(uidstr))
|
||||||
|
{
|
||||||
|
uid = int.Parse(uidstr);
|
||||||
|
param.Add("u_id", uidstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == "api")
|
||||||
|
{
|
||||||
|
appsecret = Client.Config.Appsecret;
|
||||||
|
}
|
||||||
|
//验证sign
|
||||||
|
if (contentType.MediaType != "multipart/form-data")
|
||||||
|
{
|
||||||
|
var sign = Util.SignTopRequest(param, appsecret, time);
|
||||||
|
if (sign != req.Headers.GetValues("sign").FirstOrDefault())
|
||||||
|
{
|
||||||
|
throw new Exception("Sign Error!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//如果是web请求,需要验证是否登录
|
||||||
|
if (type == "web" && !NotloginActions.Any(p => p.ToLower() == ActionName))
|
||||||
|
{
|
||||||
|
if (Client.OnlineUsers.TryGetValue(uid, out var session) && session != null)
|
||||||
|
{
|
||||||
|
Session = session;
|
||||||
|
|
||||||
|
Session.RequestTime = DateTime.Now;
|
||||||
|
if (session.RoleId != 0 && session.RoleId != 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
//权限验证
|
||||||
|
if (!NotCheckRoleController.Contains(ControllerName))
|
||||||
|
{
|
||||||
|
var Role = Db.Queryable<Role>().Where(f => f.Id == session.RoleId).WithCache().First();
|
||||||
|
if (Role.Name != "超级管理员" && !Role.ControllerNames.Any(p => p.ToLower() == ControllerName))
|
||||||
|
{
|
||||||
|
throw new Exception("权限不足,暂时无法访问此接口!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("登录失效,请重新登录!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await base.ExecuteAsync(controllerContext, cancellationToken);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var rst = PutData(ex.Message);
|
||||||
|
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(rst), Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||||
|
return await Task.FromResult(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal Client Client { get { return Client.SingleClient; } }
|
||||||
|
internal SqlSugar.SqlSugarClient Db { get { return Client.Db; } }
|
||||||
|
|
||||||
|
|
||||||
|
protected NameValueCollection Param { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
protected string GetString(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
|
||||||
|
var v = Param?.Get(Name);
|
||||||
|
if (string.IsNullOrEmpty(v) && NotNull) throw new Exception("错误,缺少必要参数未输入!");
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
protected List<string> GetStringList(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
var v = Param?.Get(Name);
|
||||||
|
if (string.IsNullOrEmpty(v) && NotNull) throw new Exception("错误,缺少必要参数未输入!");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(v))
|
||||||
|
return new List<string>();
|
||||||
|
else
|
||||||
|
return JsonConvert.DeserializeObject<List<string>>(v);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<int> GetIntList(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
var v = Param?.Get(Name);
|
||||||
|
if (string.IsNullOrEmpty(v) && NotNull) throw new Exception("错误,缺少必要参数未输入!");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(v))
|
||||||
|
return new List<int>();
|
||||||
|
|
||||||
|
else
|
||||||
|
return JsonConvert.DeserializeObject<List<int>>(v);
|
||||||
|
}
|
||||||
|
protected DateTime GetTime(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
var time = DateTime.MinValue;
|
||||||
|
DateTime.TryParse(GetString(Name, NotNull), out time);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T GetEnum<T>(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
var v = GetString(Name, NotNull);
|
||||||
|
if (!string.IsNullOrEmpty(v))
|
||||||
|
return (T)Enum.Parse(typeof(T), v);
|
||||||
|
else
|
||||||
|
return (T)Enum.Parse(typeof(T), "0");
|
||||||
|
|
||||||
|
}
|
||||||
|
protected int GetInt(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
var rst = GetString(Name, NotNull);
|
||||||
|
int outRst = -1;
|
||||||
|
var flag = int.TryParse(rst, out outRst);
|
||||||
|
if (NotNull && !flag) throw new Exception("您输入的【" + rst + "】不是一个有效的Int类型!");
|
||||||
|
return outRst;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected double GetDouble(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
var rst = GetString(Name, NotNull);
|
||||||
|
double outRst = -1;
|
||||||
|
var flag = Double.TryParse(rst, out outRst);
|
||||||
|
if (NotNull && !flag) throw new Exception("您输入的【" + rst + "】不是一个有效的Double类型!");
|
||||||
|
return outRst;
|
||||||
|
}
|
||||||
|
protected long GetLong(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
var rst = GetString(Name, NotNull);
|
||||||
|
long outRst = 0;
|
||||||
|
var flag = long.TryParse(rst, out outRst);
|
||||||
|
if (NotNull && !flag) throw new Exception("您输入的【" + rst + "】不是一个有效的Long类型!");
|
||||||
|
return outRst;
|
||||||
|
}
|
||||||
|
protected bool GetBoolean(string Name, bool NotNull = false)
|
||||||
|
{
|
||||||
|
var rst = GetString(Name, NotNull);
|
||||||
|
bool outRst = false;
|
||||||
|
bool.TryParse(rst, out outRst);
|
||||||
|
return outRst;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DateTime startTime = DateTime.Now;
|
||||||
|
public WebResult PutData(object Data)
|
||||||
|
{
|
||||||
|
WebResult Ret = null;
|
||||||
|
if (Data == null)
|
||||||
|
{
|
||||||
|
Ret = new WebResult();
|
||||||
|
Ret.Ok = true;
|
||||||
|
Ret.Data = null;
|
||||||
|
}
|
||||||
|
else if (Data.GetType() == typeof(Exception))
|
||||||
|
{
|
||||||
|
Ret = new WebResult();
|
||||||
|
var e = Data as Exception;
|
||||||
|
Ret.Ok = false;
|
||||||
|
Ret.Data = e.Message;
|
||||||
|
}
|
||||||
|
else if (Data is string)
|
||||||
|
{
|
||||||
|
Ret = new WebResult();
|
||||||
|
Ret.Ok = false;
|
||||||
|
Ret.Data = Data;
|
||||||
|
}
|
||||||
|
else if (Data.GetType() == typeof(WebResult))
|
||||||
|
{
|
||||||
|
Ret = Data as WebResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Ret = new WebResult();
|
||||||
|
Ret.Ok = true;
|
||||||
|
Ret.Data = Data;
|
||||||
|
}
|
||||||
|
Ret.Time = Math.Round((DateTime.Now - startTime).TotalSeconds, 5);
|
||||||
|
return Ret;
|
||||||
|
}
|
||||||
|
public WebResult PutSuccess { get { return PutData(new WebResult() { Ok = true, Data = "操作成功" }); } }
|
||||||
|
public WebResult PutError { get { return PutData(new WebResult() { Ok = false, Data = "系统繁忙,请稍后重试" }); } }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,142 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FinancialManagement
|
||||||
|
{
|
||||||
|
public class CashListController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询提现记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetCashList()
|
||||||
|
{
|
||||||
|
var RobotId = GetInt("RobotId");//机器人Id:0:所有机器人 不为0:指定机器人
|
||||||
|
var MinTime = GetTime("MinTime");//起始时间
|
||||||
|
var MaxTime = GetTime("MaxTime");//结束时间
|
||||||
|
var VerifyStatus = GetEnum<VerifyStatus>("VerifyStatus");//审核状态:1: 未审核 2:已审核
|
||||||
|
/*
|
||||||
|
微信昵称 = 1, 微信ID = 2
|
||||||
|
*/
|
||||||
|
var KeywordType = GetInt("KeywordType");
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<TixianHist>();
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue)
|
||||||
|
MinTime = DateTime.Now.AddMonths(-6);
|
||||||
|
|
||||||
|
if (MaxTime == DateTime.MinValue)
|
||||||
|
MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
exp.And(a => a.ApplyTime > MinTime && a.ApplyTime < MaxTime);
|
||||||
|
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And(a => a.RobotId == RobotId);
|
||||||
|
|
||||||
|
|
||||||
|
if (VerifyStatus != 0)
|
||||||
|
exp.And(a => a.VerifyStatus == VerifyStatus);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
微信昵称 = 1, 微信ID = 2, 推荐人微信ID = 3,推荐人昵称 = 4
|
||||||
|
*/
|
||||||
|
if (KeywordType == 1)
|
||||||
|
{
|
||||||
|
var nickNames = Db.Queryable<User>().Where(f => f.NickName.Contains(Keyword))
|
||||||
|
.Select(f => f.Id).Take(20).ToList();
|
||||||
|
|
||||||
|
if (nickNames == null)
|
||||||
|
{
|
||||||
|
return PutData(new PageResult<CashListShow>(new List<CashListShow>(), tNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
exp.And(a => nickNames.Contains(a.UserId));
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (KeywordType == 2)
|
||||||
|
{
|
||||||
|
var user = Db.Queryable<User>().Where(f => f.Username == Keyword && f.UserType == Common.Models.Enums.UserType.微信用户).First();
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return PutData(new PageResult<CashListShow>(new List<CashListShow>(), tNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
exp.And(a => a.UserId == user.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<TixianHist>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
|
||||||
|
.LeftJoin<Robot>((a, b) => a.RobotId == b.Id)
|
||||||
|
.LeftJoin<User>((a, b, c) => a.UserId == c.Id)
|
||||||
|
.Select((a, b, c) => new CashListShow
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
UserId = c.Id,
|
||||||
|
NickName = c.NickName,
|
||||||
|
RobotId = b.Id,
|
||||||
|
RobotName = b.Nickname,
|
||||||
|
CashAmount = a.CashAmount,
|
||||||
|
TotalCash = a.TotalCash,
|
||||||
|
TotalConfirm = a.TotalConfirm,
|
||||||
|
TotalRefund = a.TotalRefund,
|
||||||
|
ApplyTime = a.ApplyTime,
|
||||||
|
VerifyStatus = a.VerifyStatus,
|
||||||
|
VerifyTime = a.VerifyTime,
|
||||||
|
Remark = a.Remark,
|
||||||
|
})
|
||||||
|
.SplitTable(MinTime, MaxTime)
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<CashListShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FinancialManagement
|
||||||
|
{
|
||||||
|
|
||||||
|
public class IntegralRecordController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询积分记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetIntegralRecord()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue)
|
||||||
|
MinTime = DateTime.Now.AddMonths(-6);
|
||||||
|
if (MaxTime == DateTime.MinValue)
|
||||||
|
MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<PointHist>();
|
||||||
|
|
||||||
|
exp.And(f => f.CreateTime > MinTime && f.CreateTime < MaxTime);
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
if (RobotId != 0)
|
||||||
|
exp.And(f => f.RobotId == RobotId);
|
||||||
|
|
||||||
|
var IntegralType = GetEnum<PointType>("IntegralType");
|
||||||
|
if (IntegralType != PointType.未知)
|
||||||
|
exp.And(f => f.PointType == IntegralType);
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
var KeywordType = GetInt("KeywordType");//搜索类型 1:微信账号 2:微信昵称
|
||||||
|
|
||||||
|
switch (KeywordType)
|
||||||
|
{
|
||||||
|
case 1://微信账号搜索
|
||||||
|
var user = Db.Queryable<User>().Where(u => u.Username == Keyword).First();
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
return PutData(new PageResult<PointHist>(new List<PointHist>(), tNumber, PageSize, PageIndex));
|
||||||
|
|
||||||
|
exp.And(f => user.Id == f.Id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2://微信昵称搜索
|
||||||
|
var Ids = Db.Queryable<User>().Where(u => u.NickName.Contains(Keyword)).Select(u => u.Id).Take(20).ToList();
|
||||||
|
|
||||||
|
exp.And(f => Ids.Contains(f.UserId));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<PointHist>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.SplitTable(MinTime, MaxTime)
|
||||||
|
.LeftJoin<Robot>((f, b) => f.RobotId == b.Id)
|
||||||
|
.LeftJoin<User>((f, b, u) => f.UserId == u.Id)
|
||||||
|
.Select((f, b, u) => new IntegralShow
|
||||||
|
{
|
||||||
|
Id = f.Id,
|
||||||
|
UserId = f.UserId,
|
||||||
|
NickName = u.NickName,
|
||||||
|
RobotName = b.Username,
|
||||||
|
BeforeModify = f.BeforeModify,
|
||||||
|
AfterModify = f.AfterModify,
|
||||||
|
ChangeAmount = f.ChangeAmount,
|
||||||
|
PointType = f.PointType,
|
||||||
|
CreateTime = f.CreateTime,
|
||||||
|
Remark = f.Remark
|
||||||
|
})
|
||||||
|
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<IntegralShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FinancialManagement
|
||||||
|
{
|
||||||
|
public class PayRecordController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询支付记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetPayRecord()
|
||||||
|
{
|
||||||
|
var RobotId = GetInt("RobotId");//机器人Id:0:所有机器人 不为0:指定机器人
|
||||||
|
var MinTime = GetTime("MinTime");//起始时间
|
||||||
|
var MaxTime = GetTime("MaxTime");//结束时间
|
||||||
|
var RecieveStatus = GetInt("RecieveStatus");//领取状态:1: 未领取 2:已领取
|
||||||
|
/*
|
||||||
|
微信昵称 = 1, 微信ID = 2
|
||||||
|
*/
|
||||||
|
var KeywordType = GetInt("KeywordType");
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize>100) PageSize = 100;
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<PayRecord>();
|
||||||
|
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And(a => a.RobotId == RobotId);
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue)
|
||||||
|
MinTime = DateTime.Now.AddMonths(-6);
|
||||||
|
|
||||||
|
if (MaxTime == DateTime.MinValue)
|
||||||
|
MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
exp.And(a=>a.PayTime>MinTime && a.PayTime < MaxTime);
|
||||||
|
|
||||||
|
if (RecieveStatus != 0)
|
||||||
|
exp.And(a => a.RecieveStatus == RecieveStatus);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
微信昵称 = 1, 微信ID = 2, 推荐人微信ID = 3,推荐人昵称 = 4
|
||||||
|
*/
|
||||||
|
if (KeywordType == 1)
|
||||||
|
{
|
||||||
|
var nickNames = Db.Queryable<User>().Where(f => f.NickName.Contains(Keyword))
|
||||||
|
.Select(f => f.Username).Take(20).ToList();
|
||||||
|
|
||||||
|
if (nickNames == null)
|
||||||
|
return PutData(new PageResult<PayRecordShow>(new List<PayRecordShow>(), tNumber, PageSize, PageIndex));
|
||||||
|
exp.And(a => nickNames.Contains(a.Wxid));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (KeywordType == 2)
|
||||||
|
exp.And(a => a.Wxid.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<PayRecord>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.LeftJoin<Robot>((a, b) => a.RobotId == b.Id)
|
||||||
|
.LeftJoin<User>((a, b, c) => a.Wxid == c.Username)
|
||||||
|
.Select((a, b, c) => new PayRecordShow
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Wxid = a.Wxid,
|
||||||
|
NickName = c.NickName,
|
||||||
|
RobotId = b.Id,
|
||||||
|
CashAmount = a.CashAmount,
|
||||||
|
RobotName = b.Nickname,
|
||||||
|
PayType = a.PayType,
|
||||||
|
PayTime = a.PayTime,
|
||||||
|
RecieveStatus = a.RecieveStatus,
|
||||||
|
Remark = a.Remark,
|
||||||
|
})
|
||||||
|
.SplitTable(MinTime, MaxTime)
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<PayRecordShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FinancialManagement
|
||||||
|
{
|
||||||
|
public class ShopController:DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商户信息信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetShops()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Shop>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Shop>().Where(exp.ToExpression())
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<Shop>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增商户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddShop()
|
||||||
|
{
|
||||||
|
var Remark = GetString("Remark");
|
||||||
|
var AppId = GetString("AppId", true);
|
||||||
|
var AppSecret = GetString("AppSecret", true);
|
||||||
|
var PartnerId = "";//GetString("PartnerId", true);
|
||||||
|
var PartnerKey = GetString("PartnerKey", true);
|
||||||
|
var FootTxt = GetString("FootTxt");
|
||||||
|
var CertPath = GetString("CertPath", true);
|
||||||
|
var shopType = GetEnum<ShopType>("ShopType", true);
|
||||||
|
bool isExist = false;
|
||||||
|
if (shopType == ShopType.微信商户)
|
||||||
|
{
|
||||||
|
PartnerId = GetString("PartnerId", true);
|
||||||
|
isExist = Db.Queryable<Shop>().Any(x => x.PartnerId == PartnerId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isExist = Db.Queryable<Shop>().Any(x => x.AppId == AppId);
|
||||||
|
}
|
||||||
|
if (isExist)
|
||||||
|
{
|
||||||
|
return PutData("当前商户ID已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
var shop = new Shop()
|
||||||
|
{
|
||||||
|
AppId = AppId,
|
||||||
|
AppSecret = AppSecret,
|
||||||
|
PartnerId = PartnerId,
|
||||||
|
PartnerKey = PartnerKey,
|
||||||
|
FootTxt = FootTxt,
|
||||||
|
CertPaths = CertPath,
|
||||||
|
Remark = Remark,
|
||||||
|
ShopType = shopType
|
||||||
|
};
|
||||||
|
Db.Insertable(shop).ExecuteCommand();
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑商户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SaveShop()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var Remark = GetString("Remark");
|
||||||
|
var AppId = GetString("AppId", true);
|
||||||
|
var AppSecret = GetString("AppSecret", true);
|
||||||
|
var PartnerKey = GetString("PartnerKey", true);
|
||||||
|
var FootTxt = GetString("FootTxt");
|
||||||
|
var CertPath = GetString("CertPath", true);
|
||||||
|
//var shopType = GetEnum<ShopType>("ShopType", true);
|
||||||
|
var shop = Db.Queryable<Shop>().First(x => x.Id == Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return PutData("目标商户ID不存在");
|
||||||
|
}
|
||||||
|
if (shop.ShopType == ShopType.微信商户)
|
||||||
|
{
|
||||||
|
shop.PartnerId = GetString("PartnerId", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
shop.AppId = AppId;
|
||||||
|
shop.AppSecret = AppSecret;
|
||||||
|
shop.PartnerKey = PartnerKey;
|
||||||
|
shop.FootTxt = FootTxt;
|
||||||
|
shop.CertPaths = CertPath;
|
||||||
|
shop.Remark = Remark;
|
||||||
|
Db.Saveable(shop).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除商户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelShop()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var shop = Db.Queryable<Shop>().First(x => x.Id == Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return PutData("目标商户ID不存在");
|
||||||
|
}
|
||||||
|
Db.Deleteable(shop).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,154 @@
|
||||||
|
using Common.DbExtends;
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.JsonModels;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Model.JsonModels;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using Server.Utils;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FunctionSetting
|
||||||
|
{
|
||||||
|
public class BaseController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取基础配置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var baseConfig = Db.GetBaseConfigById(Id);
|
||||||
|
if (baseConfig == null) baseConfig = new BaseConfig();
|
||||||
|
|
||||||
|
return PutData(baseConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增基础配置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddBaseConfig()
|
||||||
|
{
|
||||||
|
string Name = GetString("Name", true);
|
||||||
|
string Cfg = GetString("Cfg", true);
|
||||||
|
var config = Db.Queryable<ConfigData>().Where(f => f.Name == Name && f.Type == Common.Models.Enums.ConfigType.基础).First();
|
||||||
|
|
||||||
|
if (config != null)
|
||||||
|
return PutData("新增失败,此模板名称已存在");
|
||||||
|
config = new ConfigData();
|
||||||
|
config.Type = ConfigType.基础;
|
||||||
|
config.JsonContent = Cfg;
|
||||||
|
config.Name = Name;
|
||||||
|
Db.Save(config);
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑基础设置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdBaseConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
string Cfg = GetString("Cfg", true);
|
||||||
|
var config = Db.GetConfigData(Id);
|
||||||
|
|
||||||
|
if (config == null)
|
||||||
|
return PutData("编辑失败,没有此模板");
|
||||||
|
|
||||||
|
if (config.Type != Common.Models.Enums.ConfigType.基础)
|
||||||
|
{
|
||||||
|
return PutData("编辑失败,此模板类型不匹配");
|
||||||
|
}
|
||||||
|
|
||||||
|
config.JsonContent = Cfg;
|
||||||
|
Db.Save(config);
|
||||||
|
|
||||||
|
//通知应用了配置的机器人
|
||||||
|
var robots = Db.Queryable<Robot>().Where(f => f.ConfigBaseId == config.Id).ToList();
|
||||||
|
foreach (var robot in robots)
|
||||||
|
Client.SendClientMsg(robot.Id, DeviceMessageType.基础配置修改, new { ConfigId = config.Id });
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取基础设置模板的名称
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetBaseNames()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
|
||||||
|
var keyword = GetString("keyword");
|
||||||
|
var totalNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<ConfigData>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(keyword) && f.Type == Common.Models.Enums.ConfigType.基础);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exp.And(f => f.Type == Common.Models.Enums.ConfigType.基础);
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<ConfigData>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select(M => new BaseConfigShow
|
||||||
|
{
|
||||||
|
BaseConfigId = M.Id,
|
||||||
|
BaseConfigName = M.Name,
|
||||||
|
})
|
||||||
|
.ToPageList(PageIndex, PageSize, ref totalNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<BaseConfigShow>(DataList, totalNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除基础设置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelBaseConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var config = Db.Queryable<ConfigData>().Single(f => f.Id == Id);
|
||||||
|
|
||||||
|
if (config != null)
|
||||||
|
{
|
||||||
|
var res = Db.Delete(config);
|
||||||
|
|
||||||
|
if (res > 0) return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData("删除失败,此模板不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,170 @@
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FunctionSetting
|
||||||
|
{
|
||||||
|
public class KeywordsController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 回复关键字查询
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetKeyword()
|
||||||
|
{
|
||||||
|
var RobotId = GetInt("RobotId", true);
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Keyword>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword)) exp.And(f => f.KeyWord.Contains(Keyword));
|
||||||
|
if (RobotId >= 0) exp.And(f => f.RobotId == RobotId);
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<Keyword>()
|
||||||
|
.LeftJoin<Robot>((f, r) => f.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((f, r) => new KeywordShow
|
||||||
|
{
|
||||||
|
KeyWord = f.KeyWord,
|
||||||
|
RobotId = r.Id,
|
||||||
|
Content = f.Content,
|
||||||
|
Id = f.Id,
|
||||||
|
KeywordType = f.KeywordType,
|
||||||
|
RobotName = r.Nickname
|
||||||
|
})
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
var res = new PageResult<KeywordShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增关键词
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddKeyword()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword", true);
|
||||||
|
var KeywordType = GetEnum<KeywordType>("KeywordType", true);//2:模糊匹配 1:精准匹配
|
||||||
|
var RobotId = GetInt("RobotId");//支持的机器人Id:0为通用消息,其他则为某个机器人
|
||||||
|
var Content = GetString("Content");
|
||||||
|
|
||||||
|
var keywords = Db.Queryable<Keyword>().Where(f => f.KeyWord == Keyword && f.RobotId == RobotId).First();
|
||||||
|
|
||||||
|
if (keywords != null)
|
||||||
|
{
|
||||||
|
return PutData("添加失败,关键词已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RobotId != 0)
|
||||||
|
{
|
||||||
|
var robot = Db.Queryable<Robot>().Single(f => f.Id == RobotId);
|
||||||
|
|
||||||
|
if (robot == null) return PutData("没有此机器人ID");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
keywords = new Keyword()
|
||||||
|
{
|
||||||
|
KeyWord = Keyword,
|
||||||
|
KeywordType = KeywordType,
|
||||||
|
RobotId = RobotId,
|
||||||
|
Content = Content
|
||||||
|
};
|
||||||
|
|
||||||
|
Client.SendClientMsg(RobotId, DeviceMessageType.修改关键词回复, new { RobotId = RobotId });
|
||||||
|
|
||||||
|
Db.Insertable(keywords).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑关键字
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdKeyword()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var KeywordType = GetEnum<KeywordType>("KeywordType");//2:模糊匹配 1:精准匹配
|
||||||
|
var RobotId = GetInt("RobotId");//支持的机器人Id:0为通用消息,-1为所有机器人,其他则为某个机器人
|
||||||
|
var Content = GetString("Content");
|
||||||
|
|
||||||
|
var Keywords = Db.Queryable<Keyword>().Single(f => f.Id == Id);
|
||||||
|
|
||||||
|
if (Keywords == null)
|
||||||
|
{
|
||||||
|
return PutData("编辑失败,没有此关键词");
|
||||||
|
}
|
||||||
|
|
||||||
|
var keyword = Db.Queryable<Keyword>().Where(f => f.KeyWord == Keyword && f.RobotId == RobotId).First();
|
||||||
|
if (keyword != null) return PutData("此关键词已存在,请重新输入");
|
||||||
|
|
||||||
|
Keywords.KeyWord = Keyword;
|
||||||
|
Keywords.KeywordType = KeywordType;
|
||||||
|
Keywords.RobotId = RobotId;
|
||||||
|
Keywords.Content = Content;
|
||||||
|
|
||||||
|
Db.Updateable(Keywords).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除关键词
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelKeyowrd()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var res = Db.Deleteable<Keyword>().Where(f => f.Id == Id).ExecuteCommand();
|
||||||
|
|
||||||
|
if (res > 0)
|
||||||
|
{
|
||||||
|
Db.OnLog("服务端", "删除关键词");
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
else return PutData("删除失败,没有此关键词");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,487 @@
|
||||||
|
using Common.DbExtends;
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.JsonModels;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Server.Utils;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
namespace Server.Controllers.FunctionSetting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 全局设置
|
||||||
|
/// </summary>
|
||||||
|
public class PubController : DefaultController
|
||||||
|
{
|
||||||
|
#region 配置存储相关
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetConfig()
|
||||||
|
{
|
||||||
|
var pubConfig = Db.GetPubConfig();
|
||||||
|
if (pubConfig == null) pubConfig = new PublicConfig();
|
||||||
|
return PutData(pubConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SaveConfig()
|
||||||
|
{
|
||||||
|
//var pubConfig = Db.GetPubConfig();
|
||||||
|
|
||||||
|
//if (pubConfig == null) pubConfig = new PublicConfig();
|
||||||
|
|
||||||
|
//Util.CopyToObj(this.Param, pubConfig);
|
||||||
|
var ConfigStr = GetString("Cfg", true);
|
||||||
|
var PubConfig = JsonConvert.DeserializeObject<PublicConfig>(ConfigStr);
|
||||||
|
if (PubConfig == null) return PutData("保存失败,未能识别到您的数据");
|
||||||
|
if (PubConfig.CashNewPrevious < 0.3 || PubConfig.CashNewNext < 0.3) return PutData("保存失败,提现金额不能低于0.3元");
|
||||||
|
|
||||||
|
if (PubConfig.UserStatus == UserStatus.未知 || PubConfig.KeywordStatus == UserStatus.未知 || PubConfig.RefundStatus == UserStatus.未知 || PubConfig.SameSellStatus == UserStatus.未知)
|
||||||
|
return PutData("保存失败,用户状态未设置");
|
||||||
|
|
||||||
|
if (!PubConfig.ShDefault && PubConfig.ShId == 0) return PutData("保存失败,您尚未选择支付的商户号");
|
||||||
|
|
||||||
|
var config = Db.Queryable<ConfigData>().Where(f => f.Type == ConfigType.全局).First();
|
||||||
|
if (config == null) config = new ConfigData() { Type = ConfigType.全局, Name = "" };
|
||||||
|
|
||||||
|
config.JsonContent = ConfigStr;
|
||||||
|
Db.Save(config);
|
||||||
|
|
||||||
|
var RobotIds = Db.Queryable<Robot>().Select(f => f.Id).ToList();
|
||||||
|
if (RobotIds.Count == 0)
|
||||||
|
return PutData("添加失败,暂未发现有任何可用的机器人");
|
||||||
|
|
||||||
|
foreach (var RobotId in RobotIds)
|
||||||
|
Client.SendClientMsg(RobotId, DeviceMessageType.全局配置修改, new { });
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 通知API相关
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询机器人通知接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotNotify()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<RobotNotify>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<RobotNotify>().Where(exp.ToExpression())
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotNotify>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑通知接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdRobotNotify()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var notify = Db.Queryable<RobotNotify>()
|
||||||
|
.Single(f => f.Id == Id);
|
||||||
|
|
||||||
|
if (notify == null)
|
||||||
|
return PutData("编辑失败,此通知接口不存在");
|
||||||
|
|
||||||
|
var Name = GetString("Name", true);
|
||||||
|
if (notify.Name == Name)
|
||||||
|
return PutData("编辑失败,此名称已存在");
|
||||||
|
|
||||||
|
notify.Name = Name;
|
||||||
|
|
||||||
|
var ApiLocation = GetString("ApiLocation", true);
|
||||||
|
notify.ApiLocation = ApiLocation;
|
||||||
|
|
||||||
|
var Appsecret = GetString("Appsecret");
|
||||||
|
notify.Appsecret = Appsecret;
|
||||||
|
|
||||||
|
if (ApiLocation.Contains("weixin"))
|
||||||
|
notify.NoticeApiType = NoticeApiType.企业微信机器人API;
|
||||||
|
|
||||||
|
else if (ApiLocation.Contains("dingding"))
|
||||||
|
notify.NoticeApiType = NoticeApiType.企业钉钉机器人API;
|
||||||
|
|
||||||
|
else if (ApiLocation.Contains("feishu"))
|
||||||
|
notify.NoticeApiType = NoticeApiType.飞书机器人API;
|
||||||
|
|
||||||
|
else return PutData("编辑失败,无法识别链接类型");
|
||||||
|
|
||||||
|
var res = Db.Updateable(notify).ExecuteCommand();
|
||||||
|
|
||||||
|
if (res > 0)
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
else return PutError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除通知接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DeleteNotify()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var res = Db.Deleteable<RobotNotify>()
|
||||||
|
.Where(f => f.Id == Id).ExecuteCommand();
|
||||||
|
|
||||||
|
if (res > 0)
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
return PutData("删除失败,此通知接口不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增通知接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddNotify()
|
||||||
|
{
|
||||||
|
var Name = GetString("Name", true);
|
||||||
|
//var NoticeApiType = GetEnum<NoticeApiType>("NoticeApiType", true);//通知接口类型 : 企业钉钉机器人API =1, 企业微信机器人API = 2, 飞书机器人API = 3
|
||||||
|
|
||||||
|
var ApiLocation = GetString("ApiLocation", true);
|
||||||
|
|
||||||
|
var Appsecret = GetString("Appsecret");
|
||||||
|
|
||||||
|
var notify = Db.Queryable<RobotNotify>().Where(f => f.Name == Name).First();
|
||||||
|
|
||||||
|
if (notify != null)
|
||||||
|
return PutData("新增失败,此名称已存在");
|
||||||
|
|
||||||
|
notify = new RobotNotify()
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
Appsecret = Appsecret,
|
||||||
|
ApiLocation = ApiLocation
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ApiLocation.Contains("weixin"))
|
||||||
|
notify.NoticeApiType = NoticeApiType.企业微信机器人API;
|
||||||
|
|
||||||
|
else if (ApiLocation.Contains("dingding"))
|
||||||
|
notify.NoticeApiType = NoticeApiType.企业钉钉机器人API;
|
||||||
|
|
||||||
|
else if (ApiLocation.Contains("feishu"))
|
||||||
|
notify.NoticeApiType = NoticeApiType.飞书机器人API;
|
||||||
|
|
||||||
|
else return PutData("编辑失败,无法识别链接类型");
|
||||||
|
|
||||||
|
|
||||||
|
var res = Db.Insertable(notify).ExecuteCommand();
|
||||||
|
|
||||||
|
if (res > 0) return PutSuccess;
|
||||||
|
|
||||||
|
return PutError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 测试通知接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult TestNotify()
|
||||||
|
{
|
||||||
|
var Message = GetString("Message", true);
|
||||||
|
var ApiLocation = GetString("ApiLocation", true);
|
||||||
|
var Appsecret = GetString("Appsecret");
|
||||||
|
|
||||||
|
var noticeApiType = NoticeApiType.其他;
|
||||||
|
|
||||||
|
if (ApiLocation.Contains("weixin"))
|
||||||
|
noticeApiType = NoticeApiType.企业微信机器人API;
|
||||||
|
|
||||||
|
else if (ApiLocation.Contains("dingding"))
|
||||||
|
noticeApiType = NoticeApiType.企业钉钉机器人API;
|
||||||
|
|
||||||
|
else if (ApiLocation.Contains("feishu"))
|
||||||
|
noticeApiType = NoticeApiType.飞书机器人API;
|
||||||
|
|
||||||
|
else return PutData("编辑失败,无法识别链接类型");
|
||||||
|
|
||||||
|
var result = Util.RobotNotify(Message, ApiLocation, noticeApiType, Appsecret);
|
||||||
|
if (!string.IsNullOrEmpty(result))
|
||||||
|
return PutData(result);
|
||||||
|
|
||||||
|
else
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region 商户配置相关
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商户信息信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetShops()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Shop>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Shop>().Where(exp.ToExpression())
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<Shop>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增商户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddShop()
|
||||||
|
{
|
||||||
|
var Remark = GetString("Remark");
|
||||||
|
var AppId = GetString("AppId", true);
|
||||||
|
var AppSecret = GetString("AppSecret", true);
|
||||||
|
var PartnerId = "";//GetString("PartnerId", true);
|
||||||
|
var PartnerKey = GetString("PartnerKey", true);
|
||||||
|
var FootTxt = GetString("FootTxt");
|
||||||
|
var CertPath = GetString("CertPath", true);
|
||||||
|
var shopType = GetEnum<ShopType>("ShopType", true);
|
||||||
|
bool isExist = false;
|
||||||
|
if (shopType == ShopType.微信商户)
|
||||||
|
{
|
||||||
|
PartnerId = GetString("PartnerId", true);
|
||||||
|
isExist = Db.Queryable<Shop>().Any(x => x.PartnerId == PartnerId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isExist = Db.Queryable<Shop>().Any(x => x.AppId == AppId);
|
||||||
|
}
|
||||||
|
if (isExist)
|
||||||
|
{
|
||||||
|
return PutData("当前商户ID已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
var shop = new Shop()
|
||||||
|
{
|
||||||
|
AppId = AppId,
|
||||||
|
AppSecret = AppSecret,
|
||||||
|
PartnerId = PartnerId,
|
||||||
|
PartnerKey = PartnerKey,
|
||||||
|
FootTxt = FootTxt,
|
||||||
|
CertPaths = CertPath,
|
||||||
|
Remark = Remark,
|
||||||
|
ShopType = shopType
|
||||||
|
};
|
||||||
|
Db.Insertable(shop).ExecuteCommand();
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑商户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SaveShop()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var Remark = GetString("Remark");
|
||||||
|
var AppId = GetString("AppId", true);
|
||||||
|
var AppSecret = GetString("AppSecret", true);
|
||||||
|
//var PartnerId = GetString("PartnerId", true);
|
||||||
|
var PartnerKey = GetString("PartnerKey", true);
|
||||||
|
var FootTxt = GetString("FootTxt");
|
||||||
|
var CertPath = GetString("CertPath", true);
|
||||||
|
//var shopType = GetEnum<ShopType>("ShopType", true);
|
||||||
|
var shop = Db.Queryable<Shop>().First(x => x.Id == Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return PutData("目标商户ID不存在");
|
||||||
|
}
|
||||||
|
if (shop.ShopType == ShopType.微信商户)
|
||||||
|
{
|
||||||
|
shop.PartnerId = GetString("PartnerId", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
shop.AppId = AppId;
|
||||||
|
shop.AppSecret = AppSecret;
|
||||||
|
//shop.PartnerId = PartnerId;
|
||||||
|
shop.PartnerKey = PartnerKey;
|
||||||
|
shop.FootTxt = FootTxt;
|
||||||
|
shop.CertPaths = CertPath;
|
||||||
|
shop.Remark = Remark;
|
||||||
|
Db.Storageable(shop).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除商户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelShop()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var shop = Db.Queryable<Shop>().First(x => x.Id == Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return PutData("目标商户ID不存在");
|
||||||
|
}
|
||||||
|
Db.Deleteable(shop).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增全局变量
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddGlobalVariable()
|
||||||
|
{
|
||||||
|
var name = GetString("Name", true);
|
||||||
|
var value = GetString("Value", true);
|
||||||
|
var item = this.Db.Queryable<GlobalVariable>().Where(w => w.Name == name).First();
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
item = new GlobalVariable();
|
||||||
|
item.Name = name;
|
||||||
|
item.Value = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PutData("数据已经存在");
|
||||||
|
}
|
||||||
|
this.Db.Storageable(item).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑全局变量
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult EditGlobalVariable()
|
||||||
|
{
|
||||||
|
var id = GetInt("Id", true);
|
||||||
|
var name = GetString("Name", true);
|
||||||
|
var value = GetString("Value", true);
|
||||||
|
var item = this.Db.Queryable<GlobalVariable>().Where(w => w.Id == id).First();
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return PutData("数据不存在");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.Name = name;
|
||||||
|
item.Value = value;
|
||||||
|
}
|
||||||
|
this.Db.Storageable(item).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分页获取全局变量
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetGlobalVariableList()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var tNumber = 0;
|
||||||
|
var exp = Expressionable.Create<GlobalVariable>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<GlobalVariable>().Where(exp.ToExpression()).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
var res = new PageResult<GlobalVariable>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除全局变量
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult RemoveGlobalVariable()
|
||||||
|
{
|
||||||
|
var name = GetString("Name", true);
|
||||||
|
var item = this.Db.Queryable<GlobalVariable>().Where(w => w.Name == name).First();
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
this.Db.Deleteable(item).ExecuteCommand();
|
||||||
|
}
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置网站信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SetWebInfo()
|
||||||
|
{
|
||||||
|
//如果是网站上登录,但是不是创建者
|
||||||
|
if (this.Session != null && !this.Session.IsCreator)
|
||||||
|
{
|
||||||
|
return PutData("无权操作");
|
||||||
|
}
|
||||||
|
var logo = GetString("Logo", true);
|
||||||
|
var webColorType = GetString("WebColorType", true);
|
||||||
|
var webName = GetString("WebName", true);
|
||||||
|
var webNaviType = GetString("WebNaviType", true);
|
||||||
|
var webThemeColor = GetString("WebThemeColor");
|
||||||
|
var copyright = GetString("Copyright");
|
||||||
|
var data = new WebInfo()
|
||||||
|
{
|
||||||
|
Logo = logo,
|
||||||
|
WebColorType = webColorType,
|
||||||
|
WebName = webName,
|
||||||
|
WebNaviType = webNaviType,
|
||||||
|
WebThemeColor = webThemeColor,
|
||||||
|
Copyright = copyright
|
||||||
|
};
|
||||||
|
Db.Save(data);
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,350 @@
|
||||||
|
using Common.DbExtends;
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.JsonModels;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using Server.Utils;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FunctionSetting
|
||||||
|
{
|
||||||
|
public class RebateController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取返利配置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRebateConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var rebateConfig = Db.GetRebateConfigById(Id);
|
||||||
|
|
||||||
|
|
||||||
|
if (rebateConfig == null)
|
||||||
|
{
|
||||||
|
rebateConfig = new RebateConfig();
|
||||||
|
|
||||||
|
return PutData(new
|
||||||
|
{
|
||||||
|
Config = rebateConfig
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#region 返利比例ID
|
||||||
|
|
||||||
|
List<int> IdList = new List<int>();
|
||||||
|
|
||||||
|
if (!IdList.Contains(rebateConfig.TbRebateId)) IdList.Add(rebateConfig.TbRebateId);
|
||||||
|
if (!IdList.Contains(rebateConfig.SnRebateId)) IdList.Add(rebateConfig.SnRebateId);
|
||||||
|
if (!IdList.Contains(rebateConfig.PddRebateId)) IdList.Add(rebateConfig.PddRebateId);
|
||||||
|
if (!IdList.Contains(rebateConfig.JdRebateId)) IdList.Add(rebateConfig.JdRebateId);
|
||||||
|
if (!IdList.Contains(rebateConfig.DyRebateId)) IdList.Add(rebateConfig.DyRebateId);
|
||||||
|
if (!IdList.Contains(rebateConfig.WphRebateId)) IdList.Add(rebateConfig.WphRebateId);
|
||||||
|
if (!IdList.Contains(rebateConfig.MtRebateId)) IdList.Add(rebateConfig.MtRebateId);
|
||||||
|
if (!IdList.Contains(rebateConfig.PyqRebateId)) IdList.Add(rebateConfig.PyqRebateId);
|
||||||
|
|
||||||
|
if (IdList.Contains(0)) IdList.Remove(0);
|
||||||
|
|
||||||
|
var ResList = Db.Queryable<Rebate>().Where(f => IdList.Contains(f.Id))
|
||||||
|
.Select(f => new RebateIdsShow
|
||||||
|
{
|
||||||
|
Id = f.Id,
|
||||||
|
Name = f.Name,
|
||||||
|
|
||||||
|
}).ToList();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
return PutData(new
|
||||||
|
{
|
||||||
|
Config = rebateConfig,
|
||||||
|
RebateIds = ResList
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增返利设置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddRebateConfig()
|
||||||
|
{
|
||||||
|
var Name = GetString("Name", true);
|
||||||
|
var JsonContent = GetString("JsonContent", true);
|
||||||
|
|
||||||
|
var configData = Db.Queryable<ConfigData>().Where(f => f.Name == Name && f.Type == Common.Models.Enums.ConfigType.返利).First();
|
||||||
|
if (configData == null)
|
||||||
|
{
|
||||||
|
configData = new ConfigData()
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
Type = Common.Models.Enums.ConfigType.返利,
|
||||||
|
JsonContent = JsonContent
|
||||||
|
};
|
||||||
|
|
||||||
|
Db.Save(configData);
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PutData("添加失败,已存在该模板");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑返利设置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdRebateConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var configData = Db.GetConfigData(Id);
|
||||||
|
|
||||||
|
var JsonContent = GetString("JsonContent", true);
|
||||||
|
if (configData == null)
|
||||||
|
{
|
||||||
|
return PutData("编辑失败,此模板不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configData.Type != ConfigType.返利)
|
||||||
|
{
|
||||||
|
return PutData("编辑失败,此模板类型不匹配");
|
||||||
|
}
|
||||||
|
|
||||||
|
configData.JsonContent = JsonContent;
|
||||||
|
|
||||||
|
Db.Save(configData);
|
||||||
|
|
||||||
|
var Robots = Db.Queryable<Robot>().Where(f => f.ConfigRebateId == Id).Select(f => f.Id).ToList();
|
||||||
|
if (Robots.Count != 0)
|
||||||
|
{
|
||||||
|
foreach (var RobotId in Robots)
|
||||||
|
Client.SendClientMsg(RobotId, DeviceMessageType.返利配置修改, new { ConfigId = Id });
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取返利设置模板名称
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>返利设置模板名称</returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRebateInfos()
|
||||||
|
{
|
||||||
|
string KeyWord = GetString("KeyWord");
|
||||||
|
int PageIndex = GetInt("PageIndex", true);
|
||||||
|
int PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
|
||||||
|
int tNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<ConfigData>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(KeyWord))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(KeyWord) && f.Type == Common.Models.Enums.ConfigType.返利);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
exp.And(f => f.Type == Common.Models.Enums.ConfigType.返利);
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<ConfigData>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RebateConfigShow
|
||||||
|
{
|
||||||
|
Id = m.Id,
|
||||||
|
Name = m.Name,
|
||||||
|
}).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RebateConfigShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除返利设置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelRebateConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var config = Db.Queryable<ConfigData>().Single(f => f.Id == Id);
|
||||||
|
|
||||||
|
if (config != null)
|
||||||
|
{
|
||||||
|
var res = Db.Delete(config);
|
||||||
|
|
||||||
|
var Robots = Db.Queryable<Robot>().Where(f => f.ConfigRebateId == Id).Select(f => f.Id).ToList();
|
||||||
|
if (Robots.Count != 0)
|
||||||
|
{
|
||||||
|
foreach (var RobotId in Robots)
|
||||||
|
Client.SendClientMsg(RobotId, DeviceMessageType.返利配置修改, new { ConfigId = Id });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res > 0) return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData("删除失败,此模板不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询返利模式
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRebate()
|
||||||
|
{
|
||||||
|
//关键词
|
||||||
|
string KeyWord = GetString("KeyWord");
|
||||||
|
int pageIndex = GetInt("PageIndex", true);
|
||||||
|
int pageSize = GetInt("PageSize", true);
|
||||||
|
int tNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Rebate>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(KeyWord))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(KeyWord));
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<Rebate>().Where(exp.ToExpression())
|
||||||
|
.ToPageList(pageIndex, pageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<Rebate>(DataList, tNumber, pageSize, pageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回用户组ID和Name
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetUserGrouInfo()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<UserGroup>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
var usergroup = Db.Queryable<UserGroup>().Where(exp.ToExpression())
|
||||||
|
.Select(a => new UserGroupInfo
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Name = a.Name,
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
return PutData(usergroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增返利模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddRebate()
|
||||||
|
{
|
||||||
|
//CommissionSetting commissionSetting = new CommissionSetting();
|
||||||
|
var Name = GetString("Name");
|
||||||
|
var CommissionInfoStr = GetString("CommissionInfoStr", true);
|
||||||
|
|
||||||
|
var rebate = Db.Queryable<Rebate>().Where(f => f.Name == Name).First();
|
||||||
|
if (rebate != null)
|
||||||
|
{
|
||||||
|
return PutData("此模板已经存在,请重新输入");
|
||||||
|
}
|
||||||
|
|
||||||
|
rebate = new Rebate()
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
UpdateTime = DateTime.Now,
|
||||||
|
CommissionInfo = JsonConvert.DeserializeObject<List<CommissionGroup>>(CommissionInfoStr)
|
||||||
|
};
|
||||||
|
|
||||||
|
Db.Save(rebate);
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑返利模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdRebate()
|
||||||
|
{
|
||||||
|
int Id = GetInt("Id", true);
|
||||||
|
string Name = GetString("Name", true);
|
||||||
|
string CommissionInfoStr = GetString("CommissionInfoStr", true);
|
||||||
|
|
||||||
|
|
||||||
|
var model = Db.GetRebateById(Id);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return PutData("修改失败,此模板不存在,可能已被删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.CommissionInfo = JsonConvert.DeserializeObject<List<CommissionGroup>>(CommissionInfoStr);
|
||||||
|
model.UpdateTime = DateTime.Now;
|
||||||
|
model.Name = Name;
|
||||||
|
|
||||||
|
Db.Save(model);
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除返利模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelRebate()
|
||||||
|
{
|
||||||
|
int Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var rebate = Db.Deleteable<Rebate>().Where(x => x.Id == Id).ExecuteCommand();
|
||||||
|
|
||||||
|
if (rebate > 0)
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
return PutData("删除失败,没有此返利模板");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetRebateModels
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
public DateTime EditTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,211 @@
|
||||||
|
using Common.Models.JsonModels;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using SqlSugar;
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using System.Reflection;
|
||||||
|
using static Common.DbExtends.Extends.ReplyExtend;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Common.Utils;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FunctionSetting
|
||||||
|
{
|
||||||
|
public class ReplyController : DefaultController
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询变量
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetReply()
|
||||||
|
{
|
||||||
|
var Id = GetInt("ConfigId", true);
|
||||||
|
var Config = Db.GetReplyConfigById(Id);
|
||||||
|
var List = TranslationByObj(Config);
|
||||||
|
return PutData(List);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增基础配置模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddConfig()
|
||||||
|
{
|
||||||
|
string Name = GetString("Name", true);
|
||||||
|
var json = JObject.Parse(GetString("Cfg", true));
|
||||||
|
var config = Db.Queryable<ConfigData>().Where(f => f.Name == Name && f.Type == Common.Models.Enums.ConfigType.文案).First();
|
||||||
|
if (config != null) return PutData("新增失败,此模板名称已存在");
|
||||||
|
ReplyConfig wenan_config = new ReplyConfig();
|
||||||
|
Util.CopyToObj(json, wenan_config);
|
||||||
|
var Cfg = JsonConvert.SerializeObject(wenan_config);
|
||||||
|
|
||||||
|
config = new ConfigData();
|
||||||
|
config.Type = ConfigType.文案;
|
||||||
|
config.JsonContent = Cfg;
|
||||||
|
config.Name = Name;
|
||||||
|
Db.Save(config);
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑配置
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdConfig()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var jsondata = GetString("Cfg", true);
|
||||||
|
|
||||||
|
var config = Db.GetConfigData(Id);
|
||||||
|
if (config == null) return PutData("编辑失败,没有此模板");
|
||||||
|
if (config.Type != Common.Models.Enums.ConfigType.文案)
|
||||||
|
{
|
||||||
|
return PutData("编辑失败,此模板类型不匹配");
|
||||||
|
}
|
||||||
|
|
||||||
|
ReplyConfig wenan_config = TranslationByJson(jsondata);
|
||||||
|
|
||||||
|
var Cfg = JsonConvert.SerializeObject(wenan_config);
|
||||||
|
config.JsonContent = Cfg;
|
||||||
|
Db.Save(config);
|
||||||
|
|
||||||
|
|
||||||
|
var Robots = Db.Queryable<Robot>().Where(f => f.ConfigReplyId == Id).Select(f => f.Id).ToList();
|
||||||
|
if (Robots.Count != 0)
|
||||||
|
{
|
||||||
|
foreach (var RobotId in Robots)
|
||||||
|
Client.SendClientMsg(RobotId, DeviceMessageType.返利配置修改, new { ConfigId = Id });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ReplyConfig TranslationByJson(string json)
|
||||||
|
{
|
||||||
|
var jArray = JsonConvert.DeserializeObject<JArray>(json);
|
||||||
|
var replyConfig = new ReplyConfig();
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var item in jArray)
|
||||||
|
{
|
||||||
|
var pname = item["Name"].Value<string>();
|
||||||
|
var property = replyConfig.GetType().GetProperty(pname);
|
||||||
|
if (property != null)
|
||||||
|
{
|
||||||
|
var pobj = Activator.CreateInstance(property.PropertyType);
|
||||||
|
property.SetValue(replyConfig, pobj);
|
||||||
|
TranslationByJson(item, pobj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return replyConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TranslationByJson(JToken token, object obj)
|
||||||
|
{
|
||||||
|
var menuTokens = token["Menus"].ToArray();
|
||||||
|
if (!menuTokens.Any())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (var item in menuTokens)
|
||||||
|
{
|
||||||
|
var pname = item["Name"].Value<string>();
|
||||||
|
var context = item["Content"].Value<string>();
|
||||||
|
var property = obj.GetType().GetProperty(pname);
|
||||||
|
if (property == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (property.PropertyType == typeof(string))
|
||||||
|
{
|
||||||
|
property.SetValue(obj, context);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pobj = Activator.CreateInstance(property.PropertyType);
|
||||||
|
property.SetValue(obj, pobj);
|
||||||
|
TranslationByJson(item, pobj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//private ReplyConfig TranslationByJson(ReplyShowClass obj, ReplyConfig config)
|
||||||
|
//{
|
||||||
|
// PropertyInfo[] propertys = obj.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
|
||||||
|
// foreach (PropertyInfo item in propertys)
|
||||||
|
// {
|
||||||
|
// var value = item.GetValue(obj) as ReplyShowClass;
|
||||||
|
// if (value == null) continue;
|
||||||
|
|
||||||
|
// //有子菜单
|
||||||
|
// if (value.Menus != null && value.Menus.Count > 0)
|
||||||
|
// {
|
||||||
|
// TranslationByJson(obj, config);
|
||||||
|
// }
|
||||||
|
// //没有子菜单,到了跟类
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private List<ReplyShowClass> TranslationByObj(object obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return new List<ReplyShowClass>();
|
||||||
|
}
|
||||||
|
var replys = new List<ReplyShowClass>();
|
||||||
|
var stringType = typeof(string);
|
||||||
|
var atrType = typeof(ReplyAttribute);
|
||||||
|
PropertyInfo[] propertys = obj.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
|
||||||
|
foreach (var item in propertys)
|
||||||
|
{
|
||||||
|
if (item.IsDefined(atrType, true))
|
||||||
|
{
|
||||||
|
var curAttribute = item.GetCustomAttribute<ReplyAttribute>();
|
||||||
|
if (curAttribute == null)//防止异常
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var respose = new ReplyShowClass()
|
||||||
|
{
|
||||||
|
Name = item.Name,
|
||||||
|
Description = curAttribute.Describe
|
||||||
|
};
|
||||||
|
var propertyValue = item.GetValue(obj);
|
||||||
|
if (item.PropertyType == stringType)
|
||||||
|
{
|
||||||
|
respose.PrivateVariables = curAttribute.PrivateVariables;
|
||||||
|
respose.Content = propertyValue?.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respose.Menus = new List<ReplyShowClass>();
|
||||||
|
respose.Menus.AddRange(TranslationByObj(propertyValue));
|
||||||
|
}
|
||||||
|
replys.Add(respose);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return replys;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,184 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Common.Utils;
|
||||||
|
using Org.BouncyCastle.Asn1.Cms;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FunctionSetting
|
||||||
|
{
|
||||||
|
public class ResourcesController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 上传资源,迁移到ComControoller下面了
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取文件列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetList()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var fileType = GetEnum<ResourcesType>("FileType");
|
||||||
|
var fileUse = GetEnum<ResourcesUse>("FileUse");
|
||||||
|
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var tNumber = 0;
|
||||||
|
var exp = Expressionable.Create<Resources>();
|
||||||
|
if (fileType != ResourcesType.未知)
|
||||||
|
{
|
||||||
|
exp.And(w => w.FileType == fileType);
|
||||||
|
}
|
||||||
|
if (fileUse != ResourcesUse.未知)
|
||||||
|
{
|
||||||
|
exp.And(w => w.FileUse == fileUse);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Filename.Contains(Keyword) || f.Filename.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Resources>().Where(exp.ToExpression()).OrderBy(o => o.CreateTime, OrderByType.Desc).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
var res = new PageResult<Resources>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除文件
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Remove()
|
||||||
|
{
|
||||||
|
var ids = GetIntList("Ids");
|
||||||
|
var items = Db.Queryable<Resources>().In(ids).ToList();
|
||||||
|
if (items.Count==0)
|
||||||
|
{
|
||||||
|
return PutData("删除失败,未发现任何有关文件");
|
||||||
|
}
|
||||||
|
var db = Db;
|
||||||
|
|
||||||
|
bool isNotRemove = false;
|
||||||
|
db.UseTran(() =>
|
||||||
|
{
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (item.FileUse == ResourcesUse.凭证 )
|
||||||
|
{
|
||||||
|
//如果不是超级管理员
|
||||||
|
if (Session == null || !Session.IsCreator)
|
||||||
|
{
|
||||||
|
//这个不能被删除
|
||||||
|
isNotRemove = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db.Deleteable(item).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}, ex => throw ex);
|
||||||
|
|
||||||
|
|
||||||
|
if (isNotRemove)
|
||||||
|
{
|
||||||
|
return PutData("操作失败,凭证文件非管理员不允许删除");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//删除历史文件
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
Util.DeleteFile(Util.MapFile(item.FileId,defaultResourcesPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置文件名
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SetFilename()
|
||||||
|
{
|
||||||
|
var FileName = GetString("FileName");
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var item = Db.Queryable<Resources>().Where(w => w.Id == id).First();
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return PutData("设置失败,文件不存在");
|
||||||
|
}
|
||||||
|
item.Filename = FileName;
|
||||||
|
Db.Updateable(item).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
private const string defaultResourcesPath = "网站\\resources";
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult ReplaceFile()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id",true);
|
||||||
|
var resources = Db.Queryable<Resources>().Single(f=>f.Id == Id);
|
||||||
|
if (resources == null) return PutData("替换失败,该资源不存在或已被删除");
|
||||||
|
|
||||||
|
//替换只允许修改文件
|
||||||
|
var provider = new MultipartMemoryStreamProvider();
|
||||||
|
var r = Request.Content.ReadAsMultipartAsync(provider).Result;
|
||||||
|
System.Net.Http.StreamContent item = null;
|
||||||
|
foreach (var content in r.Contents)
|
||||||
|
{
|
||||||
|
switch (content.Headers.ContentDisposition.Name.Replace("\"", ""))
|
||||||
|
{
|
||||||
|
case "File":
|
||||||
|
item = content as System.Net.Http.StreamContent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
using (var ms = item.ReadAsStreamAsync().Result)
|
||||||
|
{
|
||||||
|
|
||||||
|
var oldFilename = Util.MapFile(resources.FileId, defaultResourcesPath);
|
||||||
|
|
||||||
|
//重新修改文件ID
|
||||||
|
resources.FileId = Guid.NewGuid().ToString("N");
|
||||||
|
resources.UpdateTime = DateTime.Now;
|
||||||
|
|
||||||
|
//以随机数为文件名,防止同名文件被覆盖
|
||||||
|
var fileName = Util.MapFile(resources.FileId, defaultResourcesPath);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var filems = File.OpenWrite(fileName))
|
||||||
|
{
|
||||||
|
ms.CopyTo(filems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//如果新增失败,删掉无效文件
|
||||||
|
Util.DeleteFile(fileName);
|
||||||
|
return PutData(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db.Updateable(resources).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
//更新成功,删掉老文件
|
||||||
|
Util.DeleteFile(oldFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData(resources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
using CsharpHttpHelper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.Controllers.FunctionSetting
|
||||||
|
{
|
||||||
|
public class nouse
|
||||||
|
{
|
||||||
|
public void nouse()
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var http = new HttpHelper();
|
||||||
|
var item = http.GetItem(_info.api_location);
|
||||||
|
item.Method = "post";
|
||||||
|
item.ContentType = "application/json;";//返回类型 可选项有默认值
|
||||||
|
switch (_info.notice_apitype)
|
||||||
|
{
|
||||||
|
case NoticeApiType.企业钉钉机器人API:
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(_info.token))
|
||||||
|
{
|
||||||
|
long dingTimestamp = (DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1, 0, 0, 0, 0).Ticks) / 10000;
|
||||||
|
string canonicalString = $"{dingTimestamp}\n{_info.token}";
|
||||||
|
string signature = Convert.ToBase64String(Sign(Encoding.UTF8.GetBytes(canonicalString), Encoding.UTF8.GetBytes(_info.token)));
|
||||||
|
item.URL = item.URL + $"×tamp={dingTimestamp}&sign={signature}";
|
||||||
|
}
|
||||||
|
item.PostDataType = CsharpHttpHelper.Enum.PostDataType.Byte;
|
||||||
|
item.PostdataByte = Encoding.UTF8.GetBytes(HttpHelper.ObjectToJson(new { msgtype = "text", text = new { content = _message } }));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NoticeApiType.企业微信机器人API:
|
||||||
|
{
|
||||||
|
item.PostDataType = CsharpHttpHelper.Enum.PostDataType.Byte;
|
||||||
|
item.PostdataByte = Encoding.UTF8.GetBytes(HttpHelper.ObjectToJson(new { msgtype = "text", text = new { content = _message } }));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NoticeApiType.飞书机器人API:
|
||||||
|
{
|
||||||
|
item.PostDataType = CsharpHttpHelper.Enum.PostDataType.Byte;
|
||||||
|
if (_info.api_location.Contains("bot/v2/hook"))
|
||||||
|
item.PostdataByte = Encoding.UTF8.GetBytes(HttpHelper.ObjectToJson(new { msg_type = "text", content = new { text = _message } }));
|
||||||
|
else
|
||||||
|
item.PostdataByte = Encoding.UTF8.GetBytes(HttpHelper.ObjectToJson(new { title = "", text = _message }));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: throw new Exception("无法识别的API类型!" + _info.notice_apitype.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = http.GetHtml(item).Html;
|
||||||
|
if (html.Contains("ok") || html.Contains("success"))
|
||||||
|
return;
|
||||||
|
throw new Exception(html);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (ex.Message.Contains("sign not match"))
|
||||||
|
{
|
||||||
|
Thread.Sleep(370);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
exception = ex;
|
||||||
|
EventClient.OnEvent(null, $"{_info.name}提醒失败:" + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.Help
|
||||||
|
{
|
||||||
|
public class RunLogController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询运行日志
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRunLog()
|
||||||
|
{
|
||||||
|
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddDays(-7);
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Log>();
|
||||||
|
exp.And(f => f.CreateTime > MinTime && f.CreateTime < MaxTime);
|
||||||
|
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
if (RobotId > 0) exp.And(f => f.RobotId == RobotId);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 日志类型:1:正常 2:错误 3:警告
|
||||||
|
*/
|
||||||
|
var LogType = GetEnum<LogType>("LogType");
|
||||||
|
if (LogType > 0) exp.And(f => f.LogType == LogType);
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Message.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<Log>()
|
||||||
|
.SplitTable(MinTime, MaxTime)
|
||||||
|
.LeftJoin<Robot>((f, r) => f.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((f, r) => new RunLogShow
|
||||||
|
{
|
||||||
|
Id = f.Id,
|
||||||
|
CreateTime = f.CreateTime,
|
||||||
|
LogType = f.LogType,
|
||||||
|
Message = f.Message,
|
||||||
|
RobotId = f.RobotId,
|
||||||
|
RobotName = r.Nickname,
|
||||||
|
Sender = f.Sender
|
||||||
|
})
|
||||||
|
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RunLogShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DeleteLog()
|
||||||
|
{
|
||||||
|
var Id = GetLong("Id", true);
|
||||||
|
var CreateTime = GetTime("CreateTime", true);
|
||||||
|
|
||||||
|
var tableName = Db.GetTableName<Log>(CreateTime);
|
||||||
|
|
||||||
|
var res = Db.Deleteable<Log>().Where(f=>f.Id == Id).SplitTable(i => i.InTableNames(tableName)).ExecuteCommand();
|
||||||
|
|
||||||
|
if (res > 0)
|
||||||
|
{
|
||||||
|
Db.OnLog("服务端", "删除日志");
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return PutData("删除失败,没有此日志");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,248 @@
|
||||||
|
using Common.DbExtends;
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Server.Controllers.Help;
|
||||||
|
using Server.Services;
|
||||||
|
using Server.Utils;
|
||||||
|
|
||||||
|
namespace Server.Controllers.MemberManagement
|
||||||
|
{
|
||||||
|
public class BlacklistController : DefaultController
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetBlacklist()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<UserBlack>();
|
||||||
|
exp.And(f => !f.IsDel);
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.NickName.Contains(Keyword) || f.Username.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<UserBlack>().Where(exp.ToExpression()).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
var res = new PageResult<UserBlack>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加白名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult AddWhite()
|
||||||
|
{
|
||||||
|
var Username = GetString("Username", true);
|
||||||
|
var userType = GetEnum<UserType>("UserType", true);
|
||||||
|
|
||||||
|
var user = Db.Queryable<User>().Where(f => f.Username == Username && f.UserType == userType).First();
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
user = new User()
|
||||||
|
{
|
||||||
|
Username = Username,
|
||||||
|
UserType = userType,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
};
|
||||||
|
|
||||||
|
Db.Save(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
var userData = Db.GetUserData(user.Id);
|
||||||
|
if (userData.UserStatus == UserStatus.白名单)
|
||||||
|
{
|
||||||
|
return PutData("该用户已在白名单中,请勿重复操作");
|
||||||
|
}
|
||||||
|
|
||||||
|
userData.UserStatus = UserStatus.白名单;
|
||||||
|
Db.Save(userData);
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除用户黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult RemoveBlack()
|
||||||
|
{
|
||||||
|
var username = GetString("Username", true);
|
||||||
|
var userType = GetEnum<UserType>("UserType", true);
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.RemoveUserBlack(username, userType, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加用户黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddBlack()
|
||||||
|
{
|
||||||
|
//加黑类型
|
||||||
|
var type = GetEnum<UserType>("Type", true);
|
||||||
|
var userId = GetString("UserName", true);
|
||||||
|
var nickName = GetString("NickName");
|
||||||
|
var blackType = GetEnum<BlackType>("BlackType", true);
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var avatar = GetString("Avatar");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.AddUserBlack(type, userId, nickName, blackType, avatar, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加商品黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddGoodsBlack()
|
||||||
|
{
|
||||||
|
//加黑类型
|
||||||
|
var goodsId = GetString("GoodsId", true);
|
||||||
|
var platform = GetEnum<LianmengType>("Platform", true);
|
||||||
|
var storeName = GetString("StoreName");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.AddGoodsBlack(goodsId, platform, storeName, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除商品黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult RemoveGoodsBlack()
|
||||||
|
{
|
||||||
|
//加黑类型
|
||||||
|
var goodsId = GetString("GoodsId", true);
|
||||||
|
var platform = GetEnum<LianmengType>("Platform", true);
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.RemoveGoodsBlack(goodsId, platform, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加店铺黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddStoreBlack()
|
||||||
|
{
|
||||||
|
//加黑类型
|
||||||
|
var platform = GetEnum<LianmengType>("Platform", true);
|
||||||
|
var storeId = GetString("StoreId", true);
|
||||||
|
var storeName = GetString("StoreName");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.AddStoreBlack(platform, storeId, storeName, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除商店黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult RemoveStoreBlack()
|
||||||
|
{
|
||||||
|
//加黑类型
|
||||||
|
var storeId = GetString("StoreId", true);
|
||||||
|
var platform = GetEnum<LianmengType>("Platform", true);
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.RemoveStoreBlack(storeId, platform, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商店黑名单列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetGoodsBlacklist()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var tNumber = 0;
|
||||||
|
var exp = Expressionable.Create<GoodsBlacklist>();
|
||||||
|
exp.And(f => !f.IsDel);
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.StoreName.Contains(Keyword) || f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<GoodsBlacklist>().Where(exp.ToExpression()).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
var res = new PageResult<GoodsBlacklist>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取店铺黑名单列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetStoreBlacklist()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var tNumber = 0;
|
||||||
|
var exp = Expressionable.Create<StoreBlacklist>();
|
||||||
|
exp.And(f => !f.IsDel);
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.StoreName.Contains(Keyword) || f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<StoreBlacklist>().Where(exp.ToExpression()).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
var res = new PageResult<StoreBlacklist>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,162 @@
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.MemberManagement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 进粉记录
|
||||||
|
/// </summary>
|
||||||
|
public class FansController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var robotInfos = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname }).Take(20).ToList();
|
||||||
|
|
||||||
|
return PutData(robotInfos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询进粉记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetFansRecord()
|
||||||
|
{
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<FansRecord>();
|
||||||
|
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And(f => f.RobotId == RobotId);
|
||||||
|
|
||||||
|
if (MinTime != DateTime.MinValue)
|
||||||
|
exp.And(f => f.CreateTime > MinTime);
|
||||||
|
|
||||||
|
if (MaxTime != DateTime.MinValue)
|
||||||
|
exp.And(f => f.CreateTime < MaxTime);
|
||||||
|
|
||||||
|
var list = Db.Queryable<FansRecord>()
|
||||||
|
.SplitTable(MinTime, MaxTime)
|
||||||
|
.LeftJoin<Robot>((f, b) => f.RobotId == b.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((f, b) => new FansRecordShow
|
||||||
|
{
|
||||||
|
Id = f.Id,
|
||||||
|
ApplyRemark = f.ApplyRemark,
|
||||||
|
CreateTime = f.CreateTime,
|
||||||
|
Nickname = f.Nickname,
|
||||||
|
Username = f.Username,
|
||||||
|
SourceNickname = f.SourceNickname,
|
||||||
|
SourceUsername = f.SourceUsername,
|
||||||
|
Type = f.Type,
|
||||||
|
RobotId = f.RobotId,
|
||||||
|
RobotName = b.Nickname,
|
||||||
|
Gender = f.Gender,
|
||||||
|
Operation = f.Operation,
|
||||||
|
}).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<FansRecordShow>(list, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置进粉状态
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddMoniData()
|
||||||
|
{
|
||||||
|
FansRecord f = new FansRecord()
|
||||||
|
{
|
||||||
|
ApplyRemark = "aa",
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
Gender = SexType.未知,
|
||||||
|
Nickname = GetString("Nickname", true),
|
||||||
|
Operation = OperationStatus.待审核,
|
||||||
|
RobotId = 1,
|
||||||
|
SourceNickname = "",
|
||||||
|
SourceUsername = "",
|
||||||
|
Type = UserType.微信用户,
|
||||||
|
Username = Guid.NewGuid().ToString("N"),
|
||||||
|
};
|
||||||
|
f.Id = Util.CreateID(f.CreateTime);//自己写的一个算法ID,可以根据时间计算出表名
|
||||||
|
Db.Insertable(f).SplitTable().ExecuteCommand();
|
||||||
|
return PutData(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置进粉状态
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SetRecordStatus()
|
||||||
|
{
|
||||||
|
|
||||||
|
//需要读long,否则越界
|
||||||
|
var Id = GetLong("Id", true);
|
||||||
|
//获取表名
|
||||||
|
var TableName = Db.GetTableNameById<FansRecord>(Id);
|
||||||
|
var record = Db.Queryable<FansRecord>().Where(f => f.Id == Id).SplitTable(tab => tab.InTableNames(TableName)).First();
|
||||||
|
|
||||||
|
if (record == null) return PutData("操作失败,当前数据不存在!");
|
||||||
|
|
||||||
|
//var MinTime = GetTime("MinTime", true);
|
||||||
|
//var MaxTime = GetTime("MaxTime", true);
|
||||||
|
//var record = Db.Queryable<FansRecord>().SplitTable(MinTime, MaxTime).Single(f => f.Id == Id);
|
||||||
|
//if (record == null)
|
||||||
|
//{
|
||||||
|
// return PutError;
|
||||||
|
//}
|
||||||
|
|
||||||
|
var op = GetEnum<OperationStatus>("State", true);
|
||||||
|
record.Operation = op;
|
||||||
|
Db.Updateable(record).SplitTable(tab => tab.InTableNames(TableName)).ExecuteCommand();
|
||||||
|
|
||||||
|
//if (op == record.Operation)
|
||||||
|
//{
|
||||||
|
// return PutError;
|
||||||
|
//}
|
||||||
|
|
||||||
|
////TODO 向机器人发送同步好友状态消息
|
||||||
|
//record.Operation = op;
|
||||||
|
////TODO 同步分表数据库
|
||||||
|
////Db.Updateable(record).SplitTable(MinTime, MaxTime).ExecuteCommand();
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,155 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.MemberManagement
|
||||||
|
{
|
||||||
|
|
||||||
|
public class GroupingController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查询用户分组
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetUserGroups()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<UserGroup>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
exp.And(f => f.Name.Contains(Keyword));
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<UserGroup>()
|
||||||
|
.LeftJoin<ConfigData>((f, g) => f.ReplyId == g.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((f, g) => new UserGroupView() {
|
||||||
|
AotuSort = f.AotuSort,
|
||||||
|
ConfigName = g.Name,
|
||||||
|
Describe = f.Describe,
|
||||||
|
Id = f.Id,
|
||||||
|
MaximumOrder = f.MaximumOrder,
|
||||||
|
Name = f.Name,
|
||||||
|
ReplyId = f.ReplyId
|
||||||
|
})
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<UserGroupView>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑用户分组
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdUserGroup()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var Name = GetString("Name",true);
|
||||||
|
var Describe = GetString("Describe");
|
||||||
|
var AotuSort = GetBoolean("AotuSort");
|
||||||
|
var MaximumOrder = GetInt("MinOrder");
|
||||||
|
var ReplyId = GetInt("ReplyId");
|
||||||
|
|
||||||
|
|
||||||
|
var user = Db.Queryable<UserGroup>().Single(f => f.Id == Id);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return PutData("编辑失败,此用户组不存在或已被删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
var cacheGroup = Db.Queryable<UserGroup>().Where(f=>f.Name == Name).First();
|
||||||
|
if (cacheGroup != null && cacheGroup.Id!=Id)
|
||||||
|
{
|
||||||
|
return PutData("此用户组名称已存在,请重新输入");
|
||||||
|
}
|
||||||
|
var temp = Db.Queryable<UserGroup>().Where(f => f.MaximumOrder == MaximumOrder).First();
|
||||||
|
if (temp != null && temp.Id!= Id) return PutData($"编辑失败,已存在订单要求为“{MaximumOrder}”的分组!");
|
||||||
|
user.Name = Name;
|
||||||
|
user.Describe = Describe;
|
||||||
|
user.AotuSort = AotuSort;
|
||||||
|
user.MaximumOrder = MaximumOrder;
|
||||||
|
user.ReplyId = ReplyId;
|
||||||
|
|
||||||
|
Db.Updateable(user).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增用户分组
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddUserGroup()
|
||||||
|
{
|
||||||
|
var Name = GetString("Name", true);
|
||||||
|
var Describe = GetString("Describe");
|
||||||
|
var AotuSort = GetBoolean("AotuSort");
|
||||||
|
var MaximumOrder = GetInt("MaximumOrder");
|
||||||
|
var ReplyId = GetInt("ReplyId");
|
||||||
|
var userGroup = Db.Queryable<UserGroup>().Where(f =>f.Name == Name).First();
|
||||||
|
|
||||||
|
if (userGroup != null)
|
||||||
|
{
|
||||||
|
return PutData("已存在此名称,请重新输入");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AotuSort)
|
||||||
|
{
|
||||||
|
var temp = Db.Queryable<UserGroup>().Where(f => f.MaximumOrder == MaximumOrder).First();
|
||||||
|
if (temp != null) return PutData($"添加失败,已存在订单要求为“{MaximumOrder}”的分组!");
|
||||||
|
}
|
||||||
|
Db.Queryable<UserGroup>();
|
||||||
|
|
||||||
|
userGroup = new UserGroup()
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
Describe = Describe,
|
||||||
|
AotuSort = AotuSort,
|
||||||
|
MaximumOrder = MaximumOrder,
|
||||||
|
ReplyId = ReplyId
|
||||||
|
};
|
||||||
|
|
||||||
|
Db.Insertable(userGroup).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除用户分组
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelUserGroup()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var user = Db.Queryable<UserGroup>().Single(f => f.Id == Id);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return PutData("删除失败,此用户组不存在或已被删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
Db.Deleteable(user).ExecuteCommand();
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.MemberManagement
|
||||||
|
{
|
||||||
|
public class ReminderController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var robotInfos = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname }).Take(20).ToList();
|
||||||
|
|
||||||
|
return PutData(robotInfos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询催单记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetReminder()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");//机器人Id
|
||||||
|
var ReminderStatus = GetEnum<ReminderStatus>("ReminderStatus");//催单状态分组ID 1:未催单 2:催单中 3:已催单 4:已下单
|
||||||
|
var KeywordType = GetInt("KeywordType");//昵称搜索方式ID :1.用户昵称, 2.用户名 3.用户ID
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Reminder, User, Robot>();
|
||||||
|
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And((a, u, r) => r.Id == RobotId);
|
||||||
|
|
||||||
|
if (ReminderStatus != 0)
|
||||||
|
exp.And((a, u, r) => a.RemindStatus == ReminderStatus);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
昵称搜索方式:1.用户昵称, 2.用户名 3.用户ID
|
||||||
|
*/
|
||||||
|
if (KeywordType == 1)
|
||||||
|
exp.And((a, u, r) => u.NickName.Contains(Keyword));
|
||||||
|
|
||||||
|
else if (KeywordType == 2)
|
||||||
|
{
|
||||||
|
exp.And((a, u, r) => u.Username.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (KeywordType == 3)
|
||||||
|
{
|
||||||
|
exp.And((a, u, r) => a.UserId == Convert.ToInt32(Keyword));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<Reminder>()
|
||||||
|
.LeftJoin<User>((a, u) => a.UserId == u.Id)
|
||||||
|
.LeftJoin<Robot>((a, u, r) => a.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((a, u, r) => new ReminderShow
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
UserId = a.UserId,
|
||||||
|
Username = u.Username,
|
||||||
|
Nickname = u.NickName,
|
||||||
|
RobotId = r.Id,
|
||||||
|
RobotName = r.Nickname,
|
||||||
|
ReminderType = a.ReminderType,
|
||||||
|
FirstRemind = a.FirstRemind,
|
||||||
|
SecRemind = a.SecRemind,
|
||||||
|
THirRemind = a.THirRemind,
|
||||||
|
RemindStatus = a.RemindStatus,
|
||||||
|
})
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<ReminderShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除催单记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelReminder()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var reminder = Db.Queryable<Reminder>().Single(r => r.Id == Id);
|
||||||
|
|
||||||
|
if (reminder == null)
|
||||||
|
return PutData("删除失败,没有此催单记录");
|
||||||
|
|
||||||
|
Db.Deleteable(reminder).ExecuteCommand();
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,400 @@
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.DbExtends.Others;
|
||||||
|
using Common.Models.SubCountTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Server.Services;
|
||||||
|
|
||||||
|
namespace Server.Controllers.MemberManagement
|
||||||
|
{
|
||||||
|
public class UserController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var robotInfos = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname, RobotType = m.UserType }).Take(20).ToList();
|
||||||
|
|
||||||
|
return PutData(robotInfos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户组信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetUserGrouInfo()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<UserGroup>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
var usergroup = Db.Queryable<UserGroup>().Where(exp.ToExpression())
|
||||||
|
.Select(a => new UserGroupInfo
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Name = a.Name,
|
||||||
|
}).Take(20).ToList();
|
||||||
|
|
||||||
|
return PutData(usergroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetData()
|
||||||
|
{
|
||||||
|
var db = Db;
|
||||||
|
db.CurrentConnectionConfig.ConfigureExternalServices.SplitTableService = new MySplitService(MySplitService.MySplitType.数量);
|
||||||
|
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");//机器人Id
|
||||||
|
var GroupId = GetInt("GroupId");//分组ID
|
||||||
|
|
||||||
|
var userExp = Expressionable.Create<User>();
|
||||||
|
var exp = Expressionable.Create<User, UserData, UserGroup, User, Robot>();
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
var KeywordType = GetInt("KeywordType");
|
||||||
|
|
||||||
|
switch (KeywordType)
|
||||||
|
{
|
||||||
|
case 1://昵称搜索
|
||||||
|
userExp.And(u => u.NickName.Contains(Keyword));
|
||||||
|
exp.And((u1, d, g, u2, r) => u1.NickName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2://账号搜索
|
||||||
|
userExp.And(u1 => u1.Username.Contains(Keyword));
|
||||||
|
exp.And((u1, d, g, u2, r) => u1.Username.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
|
||||||
|
//case 3://账号ID搜索
|
||||||
|
// exp.And((d, g, u1, u2, r) => d.UserId == Convert.ToInt32(Keyword));
|
||||||
|
// break;
|
||||||
|
|
||||||
|
//case 4://上级昵称搜索
|
||||||
|
// exp.And((d, g, u1, u2, r) => u2.NickName == Keyword);
|
||||||
|
// break;
|
||||||
|
|
||||||
|
//case 5://上级账号搜索
|
||||||
|
// exp.And((d, g, u1, u2, r) => u2.Username == Keyword);
|
||||||
|
// break;
|
||||||
|
|
||||||
|
//case 6://上级账号ID搜索
|
||||||
|
// exp.And((d, g, u1, u2, r) => u2.Id == Convert.ToInt32(Keyword));
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
return PutData("查询失败,暂不支持该搜索条件");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And((u1, d, g, u2, r) => r.Id == RobotId);
|
||||||
|
|
||||||
|
if (GroupId > 0)
|
||||||
|
exp.And((u1, d, g, u2, r) => g.Id == GroupId);
|
||||||
|
|
||||||
|
var ids = db.Queryable<User>()
|
||||||
|
.Where(userExp.ToExpression())
|
||||||
|
.OrderBy(o => o.Id)
|
||||||
|
.Select(s => s.Id)
|
||||||
|
.ToPageList(PageIndex, PageSize);
|
||||||
|
if (ids.Count <= 0)
|
||||||
|
{
|
||||||
|
return PutData(new PageResult<UserShow>(new List<UserShow>(), tNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
//var idmax = db.Queryable<User>()
|
||||||
|
// .Where(userExp.ToExpression())
|
||||||
|
// .OrderBy(o => o.Id)
|
||||||
|
// .Select(s => s.Id)
|
||||||
|
// .Skip(PageIndex)
|
||||||
|
// .Take(PageSize)
|
||||||
|
// .Max<int>("Id");
|
||||||
|
//根据最大ID,选择分页的表
|
||||||
|
var rightQuery = db.Queryable<UserData>().SplitTableById(ids.Max(s => s));
|
||||||
|
var dataList = db.Queryable<User>()
|
||||||
|
.LeftJoin<UserData>(rightQuery, (u1, d) => d.UserId == u1.Id)//获取分组
|
||||||
|
.LeftJoin<UserGroup>((u1, d, g) => d.GroupId == g.Id)//获取分组
|
||||||
|
.LeftJoin<User>((u1, d, g, u2) => d.RecommendId == u2.Id)//获取用户的邀请人信息
|
||||||
|
.LeftJoin<Robot>((u1, d, g, u2, r) => u1.RobotId == r.Id)//获取机器人信息
|
||||||
|
.LeftJoin<UserBlack>((u1,d,g,u2,r,black)=> u1.Username == black.Username && u1.UserType == black.UserType)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.OrderBy(u1 => u1.Id, OrderByType.Desc)
|
||||||
|
.Select((u1, d, g, u2, r, black) => new UserShow
|
||||||
|
{
|
||||||
|
Id = u1.Id,
|
||||||
|
UserId = d.UserId,
|
||||||
|
Nickname = u1.NickName,
|
||||||
|
Username = u1.Username,
|
||||||
|
RecommendId = d.RecommendId,
|
||||||
|
InviterNickname = u2.NickName,
|
||||||
|
InviterHeadurl = u2.Headurl,
|
||||||
|
InviterUsername = u2.Username,
|
||||||
|
InviterId = u2.Id,
|
||||||
|
RobotName = r.Username,
|
||||||
|
TixianAmount = d.TixianAmount,
|
||||||
|
CurPoint = d.CurPoint,
|
||||||
|
EstimateCoupon = d.EstimateCoupon,
|
||||||
|
EstimateRebate = d.EstimateRebate,
|
||||||
|
GroupId = d.GroupId,
|
||||||
|
GroupName = g.Name,
|
||||||
|
PayOrderCount = d.PayOrderCount,
|
||||||
|
QueryCount = d.QueryCount,
|
||||||
|
RecommendCount = d.RecommendCount,
|
||||||
|
TixianCount = d.TixianCount,
|
||||||
|
UserStatus = d.UserStatus,
|
||||||
|
BlackInfo = black,
|
||||||
|
Headurl = u1.Headurl,
|
||||||
|
UserType = u1.UserType
|
||||||
|
})
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
foreach (var item in dataList)
|
||||||
|
{
|
||||||
|
if (item.BlackInfo != null && item.BlackInfo.Id != 0)
|
||||||
|
{
|
||||||
|
if (!item.BlackInfo.IsDel)
|
||||||
|
{
|
||||||
|
if (item.BlackInfo.IsCloud)
|
||||||
|
item.UserStatus = UserStatus.云黑名单;
|
||||||
|
else
|
||||||
|
item.UserStatus = UserStatus.黑名单;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.BlackInfo = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var res = new PageResult<UserShow>(dataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 添加微信用户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//[HttpPost, ErrorFilter]
|
||||||
|
//public WebResult AddWechatUser()
|
||||||
|
//{
|
||||||
|
// var Wxid = GetString("Wxid");
|
||||||
|
|
||||||
|
// var user = Db.Queryable<User>().Where(f => f.Username == Wxid).First();
|
||||||
|
|
||||||
|
// if (user != null) return PutData("该微信用户已存在,请勿重复添加");
|
||||||
|
|
||||||
|
// user = new User();
|
||||||
|
|
||||||
|
// Util.CopyToObj(this.Param, user);
|
||||||
|
|
||||||
|
// Db.Insertable(user).ExecuteCommand();
|
||||||
|
|
||||||
|
// return PutSuccess;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑微信用户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UpdWechatUser()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var wechatuser = Db.Queryable<User>().Where(f => f.Id == Id).First();
|
||||||
|
|
||||||
|
if (wechatuser == null)
|
||||||
|
{
|
||||||
|
return PutData("编辑失败,没有此用户");
|
||||||
|
}
|
||||||
|
|
||||||
|
Util.CopyToObj(this.Param, wechatuser);
|
||||||
|
//TODO:
|
||||||
|
Db.Updateable(wechatuser)
|
||||||
|
.IgnoreColumns(it => new { it.Id, it.IsFriend, it.CreateTime, })
|
||||||
|
.ExecuteCommand();
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除微信用户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//[HttpPost, ErrorFilter]
|
||||||
|
//public WebResult DelWechatUser()
|
||||||
|
//{
|
||||||
|
// var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
// var wechatuser = Db.Queryable<WechatUser>().Where(f => f.Id == Id).First();
|
||||||
|
|
||||||
|
// if (wechatuser == null)
|
||||||
|
// {
|
||||||
|
// return PutData("删除失败,没有此微信用户");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Db.Deleteable(wechatuser).ExecuteCommand();
|
||||||
|
|
||||||
|
// return PutSuccess;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加用户黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddBlack()
|
||||||
|
{
|
||||||
|
//加黑类型
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var blackType = GetEnum<BlackType>("BlackType", true);
|
||||||
|
var remark = GetString("Remark", true);
|
||||||
|
var user = Db.Queryable<User>().Where(w => w.Id == id).First();
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return PutData("用户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
var userData = Db.GetUserData(user.Id);
|
||||||
|
//如果用户在白名单,需要恢复到正常名单
|
||||||
|
if (userData.UserStatus == UserStatus.白名单)
|
||||||
|
{
|
||||||
|
userData.UserStatus = UserStatus.正常;
|
||||||
|
Db.Save(userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.AddUserBlack(user.UserType, user.Username, user.NickName, blackType, user.Headurl, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除用户黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var user = Db.Queryable<User>().Where(w => w.Id == id).First();
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return PutData("删除失败,用户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.RemoveUserBlack(user.Username, user.UserType, true);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加白名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult AddWhite()
|
||||||
|
{
|
||||||
|
var Id = GetLong("Id",true);
|
||||||
|
|
||||||
|
var user = Db.Queryable<User>().Where(f => f.Id == Id).First();
|
||||||
|
if (user == null) return PutData("操作失败,用户数据不存在");
|
||||||
|
|
||||||
|
var userData = Db.GetUserData(user.Id);
|
||||||
|
if (userData.UserStatus == UserStatus.白名单) return PutData("操作失败,用户已在白名单中");
|
||||||
|
userData.UserStatus = UserStatus.白名单;
|
||||||
|
Db.Save(userData);
|
||||||
|
|
||||||
|
//尝试删除云端的黑名单,防止用户故意拉黑后,又把自己的用户变白名单
|
||||||
|
var blacklistService = new BlacklistService();
|
||||||
|
var result = blacklistService.RemoveUserBlack(user.Username, user.UserType, true);
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删白名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult DelWhite()
|
||||||
|
{
|
||||||
|
var Id = GetLong("Id", true);
|
||||||
|
|
||||||
|
var user = Db.Queryable<User>().Where(f => f.Id == Id).First();
|
||||||
|
if (user == null) return PutData("操作失败,用户数据不存在");
|
||||||
|
|
||||||
|
|
||||||
|
var userData = Db.GetUserData(user.Id);
|
||||||
|
if (userData.UserStatus != UserStatus.白名单) return PutData("操作失败,用户不在白名单中");
|
||||||
|
|
||||||
|
userData.UserStatus = UserStatus.正常;
|
||||||
|
Db.Save(userData);
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改用户积分
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult ChangeUserPoint()
|
||||||
|
{
|
||||||
|
var userid = GetInt("UserId", true);
|
||||||
|
var point = GetDouble("Point", true);
|
||||||
|
var remark = GetString("Remark", true);
|
||||||
|
var ResIds = GetIntList("ResIds");
|
||||||
|
|
||||||
|
//var voucherUrlArr = voucherUrls.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
Db.ChangePoint(userid, point, PointType.后台修改, remark, 0, Session==null?0:Session.Uid, ResIds.ToArray());
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,314 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Requests.Lianmengs;
|
||||||
|
using Common.Utils.CpsTurns;
|
||||||
|
using Common.Utils.CpsTurns.Entitys;
|
||||||
|
using Server.Timers;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OnlineTools
|
||||||
|
{
|
||||||
|
///TODO:只兼容了淘宝联盟,其他平台尚未兼容
|
||||||
|
public class ArtificialController : DefaultController
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询推广位
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetMedias()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var TotalNumber = 0;
|
||||||
|
|
||||||
|
var LianmengType = GetEnum<LianmengType>("LianmengType", true);
|
||||||
|
switch (LianmengType)
|
||||||
|
{
|
||||||
|
case Common.Models.Enums.LianmengType.淘宝联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<TbMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<TbMedia>().Where(exp.ToExpression()).OrderBy(f => f.Id, OrderByType.Desc).ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
return PutData(new PageResult<TbMedia>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
case Common.Models.Enums.LianmengType.京东联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<JdMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<JdMedia>().Where(exp.ToExpression()).OrderBy(f => f.Id, OrderByType.Desc).ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
return PutData(new PageResult<JdMedia>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
case Common.Models.Enums.LianmengType.拼多多联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<PddMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<PddMedia>().Where(exp.ToExpression()).OrderBy(f => f.Id, OrderByType.Desc).ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
return PutData(new PageResult<PddMedia>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
case Common.Models.Enums.LianmengType.唯品会联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<WphMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<WphMedia>().Where(exp.ToExpression()).OrderBy(f => f.Id, OrderByType.Desc).ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
return PutData(new PageResult<WphMedia>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
case Common.Models.Enums.LianmengType.苏宁联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<Lianmeng>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Lianmeng>().Where(exp.ToExpression()).OrderBy(f => f.Id, OrderByType.Desc).ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
return PutData(new PageResult<Lianmeng>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
case Common.Models.Enums.LianmengType.抖音联盟:
|
||||||
|
{
|
||||||
|
var exp = Expressionable.Create<DyMedia>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Remark.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<DyMedia>().Where(exp.ToExpression()).OrderBy(f => f.Id, OrderByType.Desc).ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
return PutData(new PageResult<DyMedia>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return PutData("暂不支持,该商品类型的推广位查询!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得字符串中开始和结束字符串中间得值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">字符串</param>
|
||||||
|
/// <param name="s">开始</param>
|
||||||
|
/// <param name="e">结束</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetValue(string str, string s, string e)
|
||||||
|
{
|
||||||
|
Regex rg = new Regex("(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))", RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
|
return rg.Match(str).Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解析宝贝
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult AnalysisItem()
|
||||||
|
{
|
||||||
|
var LianmengType = GetEnum<LianmengType>("LianmengType", true);
|
||||||
|
var Content = GetString("Content", true);
|
||||||
|
|
||||||
|
int DataId = 0;
|
||||||
|
|
||||||
|
switch (LianmengType)
|
||||||
|
{
|
||||||
|
case LianmengType.淘宝联盟:
|
||||||
|
case LianmengType.京东联盟:
|
||||||
|
case LianmengType.拼多多联盟:
|
||||||
|
case LianmengType.唯品会联盟:
|
||||||
|
case LianmengType.抖音联盟:
|
||||||
|
DataId = GetInt("MediaId", true);
|
||||||
|
break;
|
||||||
|
case LianmengType.苏宁联盟:
|
||||||
|
DataId = GetInt("LianmengId", true);
|
||||||
|
break;
|
||||||
|
case LianmengType.美团联盟:
|
||||||
|
break;
|
||||||
|
case LianmengType.无:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (LianmengType)
|
||||||
|
{
|
||||||
|
case LianmengType.淘宝联盟:
|
||||||
|
{
|
||||||
|
#region 老妖 xxx
|
||||||
|
//var tbMedia = Db.Queryable<TbMedia>().Single(f => f.Id == MediaId);
|
||||||
|
//if (tbMedia == null) return PutData("对不起,推广位信息不存在,请先添加!");
|
||||||
|
|
||||||
|
//var tbLianmeng = Db.Queryable<Lianmeng>().Single(f => f.Id == tbMedia.LianmengId);
|
||||||
|
//if (tbLianmeng == null) return PutData("对不起,找不到联盟数据!");
|
||||||
|
|
||||||
|
//if (tbLianmeng.ExpirationTime < DateTime.Now) return PutData($"对不起,该联盟账号已过期,请重新登录!{tbLianmeng.Nickname}({tbLianmeng.Username})");
|
||||||
|
|
||||||
|
//TaobaoRequest req = new TaobaoRequest(tbLianmeng, tbMedia);
|
||||||
|
//var ItemId = req.AnalysisItemid(Content);
|
||||||
|
//if (string.IsNullOrEmpty(ItemId))
|
||||||
|
//{
|
||||||
|
// ItemId = req.ConvertItemid(Content);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (!string.IsNullOrEmpty(ItemId))
|
||||||
|
//{
|
||||||
|
// var ItemInfo = req.FindItemInfoByItemId(ItemId);
|
||||||
|
// if (ItemInfo != null)
|
||||||
|
// {
|
||||||
|
// var counpInfo = req.CreateExtUrl(ItemId);
|
||||||
|
// if (!string.IsNullOrEmpty(counpInfo.coupon_click_url))
|
||||||
|
// {
|
||||||
|
// var r = GetValue(counpInfo.coupon_info, "减", "元");
|
||||||
|
// //var counpAmount = 1;
|
||||||
|
// var tkl = req.CreateTkl(counpInfo.coupon_click_url);
|
||||||
|
// var rtn = new { itemId = ItemId, title = ItemInfo.n_tbk_item.FirstOrDefault().title, oriPrice = ItemInfo.n_tbk_item.FirstOrDefault().zk_final_price, counpAmount = r, link = counpInfo.coupon_click_url, tkl = tkl.password_simple, imgSrc = ItemInfo.n_tbk_item.FirstOrDefault().pict_url, orderLink = counpInfo.coupon_click_url, middleLink = "" };
|
||||||
|
// return PutData(rtn);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return PutData(ItemInfo);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
////TODO 疑似 有文案处理
|
||||||
|
////TODO 中间页地址
|
||||||
|
//else return PutData("对不起,暂时无法识别您的“淘宝”文案信息!");
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 老道
|
||||||
|
var media = Db.Queryable<TbMedia>().Single(f => f.Id == DataId);
|
||||||
|
if (media == null) return PutData("对不起,推广位信息不存在,请先添加!");
|
||||||
|
|
||||||
|
var lianmeng = Db.Queryable<Lianmeng>().Single(f => f.Id == media.LianmengId);
|
||||||
|
if (lianmeng == null) return PutData("对不起,找不到联盟数据!");
|
||||||
|
|
||||||
|
if (lianmeng.ExpirationTime < DateTime.Now) return PutData($"对不起,该联盟账号已过期,请重新登录!{lianmeng.Nickname}({lianmeng.Username})");
|
||||||
|
|
||||||
|
TaobaoRequest req = new TaobaoRequest(lianmeng, media);
|
||||||
|
|
||||||
|
var itemInfo = new TbTurn().Invoke(req, new TurnParamInfo() { DB = Db, IsComputeCommission = false, IsCreatePromotionImage = true, ItemData = Content });
|
||||||
|
if (itemInfo != null)
|
||||||
|
return PutData(itemInfo as TbCpsInfo);
|
||||||
|
//TODO 疑似 有文案处理??这个不知道指的啥 - 需要问老妖
|
||||||
|
else
|
||||||
|
return PutData("对不起,暂时无法识别您的“淘宝”文案信息!");
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
case LianmengType.京东联盟:
|
||||||
|
{
|
||||||
|
var media = Db.Queryable<JdMedia>().Single(f => f.Id == DataId);
|
||||||
|
if (media == null) return PutData("对不起,推广位信息不存在,请先添加!");
|
||||||
|
|
||||||
|
var lianmeng = Db.Queryable<Lianmeng>().Single(f => f.Id == media.LianmengId);
|
||||||
|
if (lianmeng == null) return PutData("对不起,找不到联盟数据!");
|
||||||
|
|
||||||
|
if (lianmeng.ExpirationTime < DateTime.Now) return PutData($"对不起,该联盟账号已过期,请重新登录!{lianmeng.Nickname}({lianmeng.Username})");
|
||||||
|
|
||||||
|
JingdongRequest req = new JingdongRequest(lianmeng, media);
|
||||||
|
|
||||||
|
var itemInfo = new JdTurn().Invoke(req, new TurnParamInfo() { DB = Db, IsComputeCommission = false, IsCreatePromotionImage = true, ItemData = Content });
|
||||||
|
if (itemInfo != null)
|
||||||
|
return PutData(itemInfo as JdCpsInfo);
|
||||||
|
else
|
||||||
|
return PutData("对不起,暂时无法识别您的“京东”文案信息!");
|
||||||
|
}
|
||||||
|
case LianmengType.拼多多联盟:
|
||||||
|
{
|
||||||
|
var media = Db.Queryable<PddMedia>().Single(f => f.Id == DataId);
|
||||||
|
if (media == null) return PutData("对不起,推广位信息不存在,请先添加!");
|
||||||
|
|
||||||
|
var lianmeng = Db.Queryable<Lianmeng>().Single(f => f.Id == media.LianmengId);
|
||||||
|
if (lianmeng == null) return PutData("对不起,找不到联盟数据!");
|
||||||
|
|
||||||
|
if (lianmeng.ExpirationTime < DateTime.Now) return PutData($"对不起,该联盟账号已过期,请重新登录!{lianmeng.Nickname}({lianmeng.Username})");
|
||||||
|
|
||||||
|
PinduoRequest req = new PinduoRequest(lianmeng, media);
|
||||||
|
|
||||||
|
var itemInfo = new PddTurn().Invoke(req, new TurnParamInfo() { DB = Db, IsComputeCommission = false, IsCreatePromotionImage = true, ItemData = Content });
|
||||||
|
if (itemInfo != null)
|
||||||
|
return PutData(itemInfo as PddCpsInfo);
|
||||||
|
else
|
||||||
|
return PutData("对不起,暂时无法识别您的“拼多多”文案信息!");
|
||||||
|
}
|
||||||
|
case LianmengType.唯品会联盟:
|
||||||
|
{
|
||||||
|
var media = Db.Queryable<WphMedia>().Single(f => f.Id == DataId);
|
||||||
|
if (media == null) return PutData("对不起,推广位信息不存在,请先添加!");
|
||||||
|
|
||||||
|
var lianmeng = Db.Queryable<Lianmeng>().Single(f => f.Id == media.LianmengId);
|
||||||
|
if (lianmeng == null) return PutData("对不起,找不到联盟数据!");
|
||||||
|
|
||||||
|
if (lianmeng.ExpirationTime < DateTime.Now) return PutData($"对不起,该联盟账号已过期,请重新登录!{lianmeng.Nickname}({lianmeng.Username})");
|
||||||
|
|
||||||
|
WeipinhuiRequest req = new WeipinhuiRequest(lianmeng, media);
|
||||||
|
|
||||||
|
var itemInfo = new WphTurn().Invoke(req, new TurnParamInfo() { DB = Db, IsComputeCommission = false, IsCreatePromotionImage = true, ItemData = Content });
|
||||||
|
if (itemInfo != null)
|
||||||
|
return PutData(itemInfo as WphCpsInfo);
|
||||||
|
else
|
||||||
|
return PutData("对不起,暂时无法识别您的“唯品会”文案信息!");
|
||||||
|
}
|
||||||
|
case LianmengType.苏宁联盟:
|
||||||
|
{
|
||||||
|
//var media = Db.Queryable<SnMedia>().Single(f => f.Id == MediaId);
|
||||||
|
//if (media == null) return PutData("对不起,推广位信息不存在,请先添加!");
|
||||||
|
|
||||||
|
var lianmeng = Db.Queryable<Lianmeng>().Single(f => f.Id == DataId);
|
||||||
|
if (lianmeng == null) return PutData("对不起,找不到联盟数据!");
|
||||||
|
|
||||||
|
if (lianmeng.ExpirationTime < DateTime.Now) return PutData($"对不起,该联盟账号已过期,请重新登录!{lianmeng.Nickname}({lianmeng.Username})");
|
||||||
|
|
||||||
|
SuningRequest req = new SuningRequest(lianmeng);
|
||||||
|
|
||||||
|
var itemInfo = new SnTurn().Invoke(req, new TurnParamInfo() { DB = Db, IsComputeCommission = false, IsCreatePromotionImage = true, ItemData = Content });
|
||||||
|
if (itemInfo != null)
|
||||||
|
return PutData(itemInfo as SnCpsInfo);
|
||||||
|
else
|
||||||
|
return PutData("对不起,暂时无法识别您的“苏宁”文案信息!");
|
||||||
|
}
|
||||||
|
case LianmengType.抖音联盟:
|
||||||
|
{
|
||||||
|
var media = Db.Queryable<DyMedia>().Single(f => f.Id == DataId);
|
||||||
|
if (media == null) return PutData("对不起,推广位信息不存在,请先添加!");
|
||||||
|
|
||||||
|
var lianmeng = Db.Queryable<Lianmeng>().Single(f => f.Id == media.LianmengId);
|
||||||
|
if (lianmeng == null) return PutData("对不起,找不到联盟数据!");
|
||||||
|
|
||||||
|
if (lianmeng.ExpirationTime < DateTime.Now) return PutData($"对不起,该联盟账号已过期,请重新登录!{lianmeng.Nickname}({lianmeng.Username})");
|
||||||
|
|
||||||
|
DouyinRequest req = new DouyinRequest(lianmeng, media);
|
||||||
|
|
||||||
|
var itemInfo = new DyTurn().Invoke(req, new TurnParamInfo() { DB = Db, IsComputeCommission = false, IsCreatePromotionImage = true, ItemData = Content });
|
||||||
|
if (itemInfo != null)
|
||||||
|
return PutData(itemInfo as DyCpsInfo);
|
||||||
|
else
|
||||||
|
return PutData("对不起,暂时无法识别您的“抖音”文案信息!");
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData("对不起,暂时不支持该联盟操作!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
using Common.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OnlineTools
|
||||||
|
{
|
||||||
|
public class FileController : ApiController
|
||||||
|
{
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Upload()
|
||||||
|
{
|
||||||
|
WebResult result = new WebResult();
|
||||||
|
Console.WriteLine(Request);
|
||||||
|
|
||||||
|
var provider = new MultipartMemoryStreamProvider();
|
||||||
|
|
||||||
|
//读取文件数据
|
||||||
|
var r = Request.Content.ReadAsMultipartAsync(provider).Result;
|
||||||
|
var item = provider.Contents[0];
|
||||||
|
if (item.Headers.ContentDisposition.FileName != null)
|
||||||
|
{
|
||||||
|
var ms = item.ReadAsStreamAsync().Result;
|
||||||
|
using (var br = new BinaryReader(ms))
|
||||||
|
{
|
||||||
|
if (ms.Length <= 0)
|
||||||
|
{
|
||||||
|
result.Data = "文件长度为空";
|
||||||
|
}
|
||||||
|
byte[] data = br.ReadBytes((int)ms.Length);
|
||||||
|
|
||||||
|
var fileName = Guid.NewGuid().ToString("N") + Path.GetExtension(item.Headers.ContentDisposition.FileName.Replace("\"", ""));
|
||||||
|
var path = CsharpHttpHelper.HttpExtend.MapFile(fileName, "网站\\Cache\\Images");
|
||||||
|
|
||||||
|
File.WriteAllBytes(path, data);
|
||||||
|
result.Ok = true;
|
||||||
|
result.Data = $"http://{Util.QueryInternetIP()}/Cache/Images/{fileName}";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Data = "未知的上传内容";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,206 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.JsonModels;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OnlineTools
|
||||||
|
{
|
||||||
|
public class PyqController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 上传图片
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult UploadImgUrl()
|
||||||
|
{
|
||||||
|
var Img = GetString("Img", true);
|
||||||
|
var Name = GetString("Name", true);
|
||||||
|
var fileName = Guid.NewGuid().ToString("N") + Path.GetExtension(Name);
|
||||||
|
var path = CsharpHttpHelper.HttpExtend.MapFile(fileName, "网站\\Cache\\Images");
|
||||||
|
Img = Img.Replace("data:image/jpeg;base64,", "");
|
||||||
|
byte[] bytes = Convert.FromBase64String(Img);
|
||||||
|
File.WriteAllBytes(path, bytes);
|
||||||
|
return PutData(new { url = $"http://{Client.InternetIP}/Cache/Images/{fileName}" });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除图片
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DeleteImage()
|
||||||
|
{
|
||||||
|
var ImgUrl = GetString("ImgUrl", true);
|
||||||
|
|
||||||
|
ImgUrl = ImgUrl.Replace('/', '\\');
|
||||||
|
|
||||||
|
var reg = Regex.Match(ImgUrl, @"(Cache[\w\W]+)");
|
||||||
|
if (reg.Success)
|
||||||
|
{
|
||||||
|
var path = CsharpHttpHelper.HttpExtend.MapPath("网站\\") + reg.Groups[1].Value;
|
||||||
|
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
File.Delete(path);
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData("删除失败,此文件不存在或无法识别路径");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加到发布朋友圈
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult AddPyqPublish()
|
||||||
|
{
|
||||||
|
var Name = GetString("Name");
|
||||||
|
var ResIds = GetIntList("ResIds");
|
||||||
|
|
||||||
|
var Copywriting = GetString("Copywriting");
|
||||||
|
var Comment = GetString("Comment");
|
||||||
|
var SendTime = GetTime("SendTime");
|
||||||
|
var RobotIds = GetIntList("RobotIds");
|
||||||
|
var IsSendAll = GetBoolean("IsSendAll");
|
||||||
|
|
||||||
|
if (SendTime == DateTime.MinValue)
|
||||||
|
SendTime = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
|
if (IsSendAll)
|
||||||
|
{
|
||||||
|
RobotIds.Clear();
|
||||||
|
RobotIds = Db.Queryable<Robot>().Select(f => f.Id).ToList();
|
||||||
|
}
|
||||||
|
else if (RobotIds.Count <= 0) return PutData("添加失败,至少需要选择一个机器人");
|
||||||
|
|
||||||
|
if (RobotIds.Count == 0)
|
||||||
|
{
|
||||||
|
return PutData("添加失败,暂未发现有任何可用的机器人");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var RobotId in RobotIds)
|
||||||
|
{
|
||||||
|
var publish = new PyqPublish()
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
SendTime = SendTime,
|
||||||
|
Comment = Comment,
|
||||||
|
Copywriting = Copywriting,
|
||||||
|
ResIds = ResIds.ToArray(),
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
RobotId = RobotId
|
||||||
|
};
|
||||||
|
publish.Id = Db.Insertable(publish).ExecuteReturnIdentity();
|
||||||
|
|
||||||
|
Client.SendClientMsg(RobotId, DeviceMessageType.添加定时发送朋友圈, new { Id = publish.Id });
|
||||||
|
}
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除朋友圈任务
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult DelSendRecord()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
|
||||||
|
var pyqPublish = Db.Queryable<PyqPublish>().First(p => p.Id == Id);
|
||||||
|
if (pyqPublish != null)
|
||||||
|
{
|
||||||
|
Client.SendClientMsg(pyqPublish.RobotId, DeviceMessageType.删除定时发送朋友圈, new { Id = Id });
|
||||||
|
|
||||||
|
return Db.Deleteable(pyqPublish).ExecuteCommandHasChange() ? PutSuccess : PutError;
|
||||||
|
}
|
||||||
|
return PutError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询发送记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetSendRecord()
|
||||||
|
{
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<PyqPublish>();
|
||||||
|
//var pp = Db.Queryable<PyqPublish>().First();
|
||||||
|
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And(f => f.RobotId == RobotId);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
exp.And(f => f.Name.Contains(Keyword));
|
||||||
|
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<PyqPublish>()
|
||||||
|
.LeftJoin<Robot>((f, r) => f.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((f, r) => new PyqPublishShow
|
||||||
|
{
|
||||||
|
Id = f.Id,
|
||||||
|
Name = f.Name,
|
||||||
|
RobotId = f.RobotId,
|
||||||
|
RobotNickname = r.Nickname,
|
||||||
|
SendTime = f.SendTime,
|
||||||
|
IsSend = f.IsSend,
|
||||||
|
RobotUserName = r.Username,
|
||||||
|
UserType = r.UserType,
|
||||||
|
ResIds = f.ResIds,
|
||||||
|
Comment = f.Comment,
|
||||||
|
Copywriting = f.Copywriting
|
||||||
|
})
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<PyqPublishShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,232 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OnlineTools
|
||||||
|
{
|
||||||
|
public class QunfaController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 上传图片
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WebResult UploadImgUrl()
|
||||||
|
{
|
||||||
|
var Img = GetString("Img", true);
|
||||||
|
var Name = GetString("Name", true);
|
||||||
|
var fileName = Guid.NewGuid().ToString("N") + Path.GetExtension(Name);
|
||||||
|
var path = CsharpHttpHelper.HttpExtend.MapFile(fileName, "网站\\Cache\\Images");
|
||||||
|
Img = Img.Replace("data:image/jpeg;base64,", "");
|
||||||
|
byte[] bytes = Convert.FromBase64String(Img);
|
||||||
|
File.WriteAllBytes(path, bytes);
|
||||||
|
return PutData(new { url = $"http://{Client.InternetIP}/Cache/Images/{fileName}" });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除图片
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult DeleteImage()
|
||||||
|
{
|
||||||
|
var ImgUrl = GetString("ImgUrl", true);
|
||||||
|
|
||||||
|
ImgUrl = ImgUrl.Replace('/', '\\');
|
||||||
|
|
||||||
|
var reg = Regex.Match(ImgUrl, @"(Cache[\w\W]+)");
|
||||||
|
if (reg.Success)
|
||||||
|
{
|
||||||
|
var path = CsharpHttpHelper.HttpExtend.MapPath("网站\\") + reg.Groups[1].Value;
|
||||||
|
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
File.Delete(path);
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData("删除失败,此文件不存在或无法识别路径");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询群发任务
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetQunfas()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
if (PageSize > 100) PageSize = 100;
|
||||||
|
var TotalNumber = 0;
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Qunfa, Robot>();
|
||||||
|
|
||||||
|
if (RobotId != 0)
|
||||||
|
{
|
||||||
|
exp.And((q, r) => q.RobotId == RobotId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And((q, r) => q.Name.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<Qunfa>()
|
||||||
|
.LeftJoin<Robot>((q, r) => q.Id == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((q, r) => new QunfaShow()
|
||||||
|
{
|
||||||
|
Id = q.Id,
|
||||||
|
BuyOrderDay = q.BuyOrderDay,
|
||||||
|
Content = q.Content,
|
||||||
|
CreateTime = q.CreateTime,
|
||||||
|
FinishTime = q.FinishTime,
|
||||||
|
GroupId = q.GroupId,
|
||||||
|
Name = q.Name,
|
||||||
|
NotBuy = q.NotBuy,
|
||||||
|
NotInvitation = q.NotInvitation,
|
||||||
|
RobotId = RobotId,
|
||||||
|
RobotNick = r.Nickname,
|
||||||
|
SendMaxSleepInterval = q.SendMaxSleepInterval,
|
||||||
|
SendMinSleepInterval = q.SendMinSleepInterval,
|
||||||
|
SendNumberInterval = q.SendNumberInterval,
|
||||||
|
StartTime = q.StartTime,
|
||||||
|
Status = q.Status,
|
||||||
|
TodayMaxNumber = q.TodayMaxNumber,
|
||||||
|
Type = q.Type,
|
||||||
|
RobotUserName = r.Username,
|
||||||
|
UserType = r.UserType
|
||||||
|
})
|
||||||
|
.ToPageList(PageIndex, PageSize, ref TotalNumber);
|
||||||
|
return PutData(new PageResult<QunfaShow>(DataList, TotalNumber, PageSize, PageIndex));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增群发
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddQunfa()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Qunfa qunfa = new Qunfa();
|
||||||
|
qunfa.Name = GetString("Name", true);
|
||||||
|
qunfa.StartTime = GetTime("StartTime", true);
|
||||||
|
qunfa.SendNumberInterval = GetInt("SendNumberInterval", true);
|
||||||
|
qunfa.SendMinSleepInterval = GetInt("SendMinSleepInterval", true);
|
||||||
|
qunfa.SendMaxSleepInterval = GetInt("SendMaxSleepInterval", true);
|
||||||
|
qunfa.TodayMaxNumber = GetInt("TodayMaxNumber", true);
|
||||||
|
qunfa.Type = GetEnum<QunfaType>("Type", true);
|
||||||
|
switch (qunfa.Type)
|
||||||
|
{
|
||||||
|
case QunfaType.全部好友:
|
||||||
|
break;
|
||||||
|
case QunfaType.分组好友:
|
||||||
|
qunfa.GroupId = GetIntList("GroupId", true);
|
||||||
|
break;
|
||||||
|
case QunfaType.长时间未下单:
|
||||||
|
qunfa.BuyOrderDay = GetInt("BuyOrderDay", true);
|
||||||
|
break;
|
||||||
|
case QunfaType.满足指定条件:
|
||||||
|
qunfa.NotBuy = GetBoolean("NotBuy", true);
|
||||||
|
qunfa.NotInvitation = GetBoolean("NotInvitation", true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qunfa.Content = GetString("Content", true);
|
||||||
|
|
||||||
|
List<int> RobotIds = null;
|
||||||
|
if (qunfa.Type == QunfaType.全部好友)
|
||||||
|
{
|
||||||
|
RobotIds = Db.Queryable<Robot>().Select(f => f.Id).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RobotIds = GetIntList("RobotIds");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RobotIds != null && RobotIds.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var RobotId in RobotIds)
|
||||||
|
{
|
||||||
|
var qf = qunfa.CopyQunfa(RobotId);//克隆一个自己
|
||||||
|
if (qf.GroupId == null)
|
||||||
|
{
|
||||||
|
qf.GroupId = new List<int>();
|
||||||
|
}
|
||||||
|
qf.Id = Db.Insertable(qf).ExecuteReturnIdentity();
|
||||||
|
Client.SendClientMsg(RobotId, DeviceMessageType.添加群发任务, new { Id = qf.Id });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else return PutData("暂未发现,可用的机器人!");
|
||||||
|
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return PutData(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置群发任务状态
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult SetQunfaStatus()
|
||||||
|
{
|
||||||
|
var QunfaId = GetInt("QunfaId", true);
|
||||||
|
var Qunfa = Db.Queryable<Qunfa>().Single(f => f.Id == QunfaId);
|
||||||
|
if (Qunfa == null) return PutData("对不起,任务不存在!");
|
||||||
|
if (Qunfa.Status == QunfaStatus.完成) return PutData("该任务已完成,无法修改!");
|
||||||
|
|
||||||
|
var Status = GetEnum<QunfaStatus>("QunfaStatus");
|
||||||
|
Qunfa.Status = Status;
|
||||||
|
if (Qunfa.Status == QunfaStatus.完成) Qunfa.FinishTime = DateTime.Now;
|
||||||
|
|
||||||
|
Db.Updateable(Qunfa).UpdateColumns(f => new { f.Status, f.FinishTime }).ExecuteCommand();
|
||||||
|
|
||||||
|
Client.SendClientMsg(Qunfa.RobotId, DeviceMessageType.修改群发任务状态, new { Id = QunfaId });
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除群发任务
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[System.Web.Http.HttpPost, ErrorFilter]
|
||||||
|
public WebResult DelQunfa()
|
||||||
|
{
|
||||||
|
var Id = GetInt("Id", true);
|
||||||
|
var Qunfa = Db.Queryable<Qunfa>().Single(f => f.Id == Id);
|
||||||
|
if (Qunfa == null) return PutData("删除失败,未找到数据!");
|
||||||
|
|
||||||
|
Client.SendClientMsg(Qunfa.RobotId, DeviceMessageType.删除群发任务, new { Id = Id });
|
||||||
|
|
||||||
|
Db.Deleteable<Qunfa>().Where(f => f.Id == Id).ExecuteCommand();
|
||||||
|
var TableName = Db.SplitHelper<QunfaHist>().GetTableName(Qunfa.CreateTime);//根据时间获取表名;
|
||||||
|
Db.Deleteable<QunfaHist>().Where(f => f.QunfaId == Qunfa.Id).SplitTable(tas => tas.InTableNames(TableName)).ExecuteCommand();
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,240 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Common.Utils;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OpenManagement
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ComController:DefaultController
|
||||||
|
{
|
||||||
|
private const int DefaultMaxNumber = 20;
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索机器人
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SerchRobots()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword) || f.Username.Contains(Keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
var RobotType = GetInt("RobotType");
|
||||||
|
if (RobotType != 0)
|
||||||
|
{
|
||||||
|
exp.And(f => f.UserType == (UserType)RobotType);
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<Robot>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.OrderBy(f=>f.Id, OrderByType.Desc)
|
||||||
|
.Select(m => new { Id = m.Id, Nickname = m.Nickname, Username = m.Username })
|
||||||
|
.Take(DefaultMaxNumber)
|
||||||
|
.ToList();
|
||||||
|
return PutData(DataList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索配置模板
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SerchConfigs()
|
||||||
|
{
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
var exp = Expressionable.Create<ConfigData>();
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Name.Contains(Keyword) );
|
||||||
|
}
|
||||||
|
|
||||||
|
var RobotType = GetInt("ConfigType",true);
|
||||||
|
if (RobotType != 0)
|
||||||
|
{
|
||||||
|
exp.And(f => f.Type == (ConfigType)RobotType);
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<ConfigData>()
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.OrderBy(f => f.Id, OrderByType.Desc)
|
||||||
|
.Select(m => new { Id = m.Id, Name = m.Name})
|
||||||
|
.Take(DefaultMaxNumber)
|
||||||
|
.ToList();
|
||||||
|
return PutData(DataList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region 之前的代码
|
||||||
|
///// <summary>
|
||||||
|
///// 上传资源
|
||||||
|
///// </summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//[HttpPost, ErrorFilter]
|
||||||
|
//public WebResult Upload()
|
||||||
|
//{
|
||||||
|
// //Tabale 填充这个数据,Resources
|
||||||
|
// ResourcesType fileType = ResourcesType.未知;
|
||||||
|
// ResourcesUse fileUse = ResourcesUse.未知;
|
||||||
|
// var remark = GetString("Remark", false);
|
||||||
|
// var id = GetLong("Id", false);
|
||||||
|
|
||||||
|
|
||||||
|
// var provider = new MultipartMemoryStreamProvider();
|
||||||
|
// //读取文件数据
|
||||||
|
// var r = Request.Content.ReadAsMultipartAsync(provider).Result;
|
||||||
|
// System.Net.Http.StreamContent item = null;
|
||||||
|
// foreach (var content in r.Contents)
|
||||||
|
// {
|
||||||
|
// switch (content.Headers.ContentDisposition.Name.Replace("\"", ""))
|
||||||
|
// {
|
||||||
|
// case "FileType":
|
||||||
|
// fileType = (ResourcesType)Enum.Parse(typeof(ResourcesType), content.ReadAsStringAsync().Result);
|
||||||
|
// break;
|
||||||
|
// case "FileUse":
|
||||||
|
// fileUse = (ResourcesUse)Enum.Parse(typeof(ResourcesUse), content.ReadAsStringAsync().Result);
|
||||||
|
// break;
|
||||||
|
// case "Remark":
|
||||||
|
// remark = content.ReadAsStringAsync().Result;
|
||||||
|
// break;
|
||||||
|
// case "File":
|
||||||
|
// item = content as System.Net.Http.StreamContent;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //var item = provider.Contents[0];
|
||||||
|
// if (string.IsNullOrWhiteSpace(item.Headers.ContentDisposition.FileName))
|
||||||
|
// {
|
||||||
|
// return PutData("文件名不存在");
|
||||||
|
// }
|
||||||
|
// string upfileName = item.Headers.ContentDisposition.FileName.Replace("\"", "");
|
||||||
|
// var resources = this.Db.Queryable<Resources>().Where(w => w.Id == id).First();
|
||||||
|
// if (id == 0)
|
||||||
|
// {
|
||||||
|
// resources = new Resources();
|
||||||
|
// resources.Remark = remark;
|
||||||
|
// resources.CreateTime = DateTime.Now;
|
||||||
|
// resources.FileType = fileType;
|
||||||
|
// resources.FileUse = fileUse;
|
||||||
|
// resources.Filename = upfileName;
|
||||||
|
// resources.UpdateTime = DateTime.Now;
|
||||||
|
// resources.FileId = Guid.NewGuid().ToString("N");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if (resources == null)
|
||||||
|
// {
|
||||||
|
// return PutData("更新失败,数据不存在。");
|
||||||
|
// }
|
||||||
|
// resources.Remark = remark;
|
||||||
|
// resources.FileType = fileType;
|
||||||
|
// resources.FileUse = fileUse;
|
||||||
|
// resources.Filename = upfileName;
|
||||||
|
// resources.UpdateTime = DateTime.Now;
|
||||||
|
// resources.FileId = Guid.NewGuid().ToString("N");
|
||||||
|
// }
|
||||||
|
// using (var ms = item.ReadAsStreamAsync().Result)
|
||||||
|
// {
|
||||||
|
// if (ms.Length <= 0)
|
||||||
|
// {
|
||||||
|
// return PutData("文件长度为空");
|
||||||
|
// }
|
||||||
|
// if (resources.Id == 0)
|
||||||
|
// {
|
||||||
|
// this.Db.Insertable(resources).ExecuteReturnEntity();
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// this.Db.Updateable(resources).ExecuteCommand();
|
||||||
|
// //删除老文件
|
||||||
|
// //var oldfileName = resources.FileId + Path.GetExtension(resources.Filename);
|
||||||
|
// var oldfileName = resources.Filename;
|
||||||
|
// var oldpath = CsharpHttpHelper.HttpExtend.MapFile(oldfileName, "网站\\resources");
|
||||||
|
// if (File.Exists(oldpath))
|
||||||
|
// {
|
||||||
|
// File.Delete(oldpath);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //var fileName = resources.FileId + Path.GetExtension(upfileName);
|
||||||
|
// var fileName = resources.Filename;
|
||||||
|
// var path = CsharpHttpHelper.HttpExtend.MapFile(fileName, "网站\\resources");
|
||||||
|
// using (var filems = File.OpenWrite(path))
|
||||||
|
// {
|
||||||
|
// ms.CopyTo(filems);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return new WebResult()
|
||||||
|
// {
|
||||||
|
// Ok = true,
|
||||||
|
// Data = resources
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
private const string defaultResourcesPath = "网站\\resources";
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult UploadFile()
|
||||||
|
{
|
||||||
|
Resources resources = new Resources();
|
||||||
|
|
||||||
|
//读取文件数据
|
||||||
|
var provider = new MultipartMemoryStreamProvider();
|
||||||
|
var r = Request.Content.ReadAsMultipartAsync(provider).Result;
|
||||||
|
System.Net.Http.StreamContent item = null;
|
||||||
|
foreach (var content in r.Contents)
|
||||||
|
{
|
||||||
|
switch (content.Headers.ContentDisposition.Name.Replace("\"", ""))
|
||||||
|
{
|
||||||
|
case "FileType":
|
||||||
|
resources.FileType = (ResourcesType)Enum.Parse(typeof(ResourcesType), content.ReadAsStringAsync().Result);
|
||||||
|
break;
|
||||||
|
case "FileUse":
|
||||||
|
resources.FileUse = (ResourcesUse)Enum.Parse(typeof(ResourcesUse), content.ReadAsStringAsync().Result);
|
||||||
|
break;
|
||||||
|
case "File":
|
||||||
|
item = content as System.Net.Http.StreamContent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var ms = item.ReadAsStreamAsync().Result)
|
||||||
|
{
|
||||||
|
resources.FileId = Guid.NewGuid().ToString("N");
|
||||||
|
resources.UpdateTime = DateTime.Now;
|
||||||
|
resources.CreateTime = DateTime.Now;
|
||||||
|
resources.Filename = item.Headers.ContentDisposition.FileName.Replace("\"", "");
|
||||||
|
|
||||||
|
//以随机数为文件名,防止同名文件被覆盖
|
||||||
|
var fileName = Util.MapFile(resources.FileId, defaultResourcesPath);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var filems = File.OpenWrite(fileName))
|
||||||
|
{
|
||||||
|
ms.CopyTo(filems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//写入失败,删除无效文件
|
||||||
|
Util.DeleteFile(fileName);
|
||||||
|
return PutData(ex);
|
||||||
|
}
|
||||||
|
resources.Id = Db.Insertable(resources).ExecuteReturnIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData(resources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Common.Utils;
|
||||||
|
using Server.Services.DataMigration;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OpenManagement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据迁移Api
|
||||||
|
/// </summary>
|
||||||
|
public class DataMigrationController : DefaultController
|
||||||
|
{
|
||||||
|
private const string defaultTempPath = "Temp";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上传数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Upload()
|
||||||
|
{
|
||||||
|
//替换只允许修改文件
|
||||||
|
var provider = new MultipartMemoryStreamProvider();
|
||||||
|
var r = Request.Content.ReadAsMultipartAsync(provider).Result;
|
||||||
|
System.Net.Http.StreamContent item = null;
|
||||||
|
foreach (var content in r.Contents)
|
||||||
|
{
|
||||||
|
switch (content.Headers.ContentDisposition.Name.Replace("\"", ""))
|
||||||
|
{
|
||||||
|
case "File":
|
||||||
|
item = content as System.Net.Http.StreamContent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var fileName = Util.MapFile("datamigration.zip", defaultTempPath);
|
||||||
|
//删除旧数据
|
||||||
|
Util.DeleteFile(fileName);
|
||||||
|
using (var ms = item.ReadAsStreamAsync().Result)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var filems = File.OpenWrite(fileName))
|
||||||
|
{
|
||||||
|
ms.CopyTo(filems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//如果新增失败,删掉无效文件
|
||||||
|
Util.DeleteFile(fileName);
|
||||||
|
return PutData(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 检查上传的数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Check()
|
||||||
|
{
|
||||||
|
var fileName = Util.MapFile("datamigration.zip", defaultTempPath);
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
{
|
||||||
|
return PutData("请先上传数据。");
|
||||||
|
}
|
||||||
|
var err = DataMigrationManageSerivce.Instance.Check(fileName);
|
||||||
|
if (string.IsNullOrWhiteSpace(err))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(err);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 开始导入
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult OpenImport()
|
||||||
|
{
|
||||||
|
var state = DataMigrationProgressService.Instance.GetState();
|
||||||
|
if (state != null && state.State == 1)
|
||||||
|
{
|
||||||
|
return PutData("后台已经正在处理中,请不要重复操作。");
|
||||||
|
}
|
||||||
|
var fileName = Util.MapFile("datamigration.zip", defaultTempPath);
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
{
|
||||||
|
return PutData("请先上传数据。");
|
||||||
|
}
|
||||||
|
var err = DataMigrationManageSerivce.Instance.Start(fileName);
|
||||||
|
if (string.IsNullOrWhiteSpace(err))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(err);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取进度
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetProgress()
|
||||||
|
{
|
||||||
|
var state = DataMigrationProgressService.Instance.GetState();
|
||||||
|
if (state == null)
|
||||||
|
{
|
||||||
|
return PutData("当前还未开始");
|
||||||
|
}
|
||||||
|
return PutData(new
|
||||||
|
{
|
||||||
|
StartDateTime = state.StartDateTime,
|
||||||
|
EndDateTime = state.EndDateTime,
|
||||||
|
Logs = state.Logs.ToArray(),
|
||||||
|
State = state.State,
|
||||||
|
ElapsedTime = state.ElapsedTime.ToString("0.00")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
using Common.Models.PubClass;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Class;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OpenManagement
|
||||||
|
{
|
||||||
|
public class DeviceController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 连接客户端
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Connection()
|
||||||
|
{
|
||||||
|
var Id = GetString("Id", true);
|
||||||
|
var InternetIP = GetString("InternetIP", true);
|
||||||
|
var ClientVersion = GetString("ClientVersion", true);
|
||||||
|
Version v = null;
|
||||||
|
if (Id.Length != 32) return PutData("Id 建议生成32位的唯一数,保证设备的准确性!");
|
||||||
|
if (!Regex.Match(InternetIP, @"(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})").Success) return PutData("IP信息不准确,请务必查询真实外网IP!");
|
||||||
|
if (!Version.TryParse(ClientVersion, out v)) return PutData("您的版本信息有误,请输入一个正确的版本信息!");
|
||||||
|
|
||||||
|
Device Device = Db.Queryable<Device>().Single(f => f.Id == Id);
|
||||||
|
if (Device == null)
|
||||||
|
{
|
||||||
|
Device = new Device()
|
||||||
|
{
|
||||||
|
Id = Id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Device.Version = ClientVersion;
|
||||||
|
Device.InternetIP = InternetIP;
|
||||||
|
Device.Token = System.Guid.NewGuid().ToString();
|
||||||
|
Device.LoginTime = DateTime.Now;
|
||||||
|
Db.Storageable(Device).ExecuteCommand();
|
||||||
|
|
||||||
|
if (Client.OnlineDevices.ContainsKey(Id))
|
||||||
|
{
|
||||||
|
Client.OnlineDevices[Id] = new MyClass.Class.DeviceSession();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!Client.OnlineDevices.TryAdd(Id, new MyClass.Class.DeviceSession())) return PutError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData(new
|
||||||
|
{
|
||||||
|
Token = Device.Token,
|
||||||
|
MysqlName = Client.Config.MysqlName,
|
||||||
|
MysqlHost = Client.Config.MysqlHost,
|
||||||
|
MysqlPort = Client.Config.MysqlPort,
|
||||||
|
MysqlPass = Client.Config.MysqlPass,
|
||||||
|
MysqlUser = Client.Config.MysqlUser
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Reading()
|
||||||
|
{
|
||||||
|
|
||||||
|
var session = CheckLoginDevice();
|
||||||
|
if (session == null) return PutData("机器人登录失效,请重新登录");
|
||||||
|
|
||||||
|
//如果服务端重启了,有可能就找不到,所以这里需要自动添加
|
||||||
|
try
|
||||||
|
{
|
||||||
|
session.IsReading = true;
|
||||||
|
session.ReadTime = DateTime.Now;
|
||||||
|
List<DeviceMessage> ResposeMsgs = new List<DeviceMessage>();
|
||||||
|
var time = DateTime.Now.AddSeconds(180);
|
||||||
|
while (time > DateTime.Now)
|
||||||
|
{
|
||||||
|
if (session.Messages.Count > 0)
|
||||||
|
{
|
||||||
|
var Msg = session.Messages.Dequeue();
|
||||||
|
if (Msg != null) ResposeMsgs.Add(Msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ResposeMsgs.Count > 0) break;
|
||||||
|
Thread.Sleep(100);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData(ResposeMsgs);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
session.IsReading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Reply()
|
||||||
|
{
|
||||||
|
var device = CheckLoginDevice();
|
||||||
|
if (device == null) return PutData("机器人登录失效,请重新登录");
|
||||||
|
|
||||||
|
//要回复的ID
|
||||||
|
var Replyid = GetString("Msgid", true);
|
||||||
|
var Content = GetString("Content", true);
|
||||||
|
Client.ReplyMessages.Add(Replyid, new DeviceReplyMessage() { Replyid = Replyid, Content = Content, CreateTime = DateTime.Now });
|
||||||
|
return PutSuccess;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult SetRobotId()
|
||||||
|
{
|
||||||
|
var session = CheckLoginDevice();
|
||||||
|
if (session == null) return PutData("机器人登录失效,请重新登录");
|
||||||
|
|
||||||
|
var robotId = GetInt("RobotId", true);
|
||||||
|
if (robotId == 0) return PutData("设置失败,机器人的编号不能为0");
|
||||||
|
if (robotId != device.RobotId)
|
||||||
|
{
|
||||||
|
var oldRobots = Client.OnlineDevices.Where(x => x.Value.RobotId == robotId && x.Key != device.Id).ToList();
|
||||||
|
foreach (var item in oldRobots)
|
||||||
|
{
|
||||||
|
Client.OnlineDevices.TryRemove(item.Key, out _);
|
||||||
|
}
|
||||||
|
session.RobotId = robotId;
|
||||||
|
device.RobotId = robotId;
|
||||||
|
session.RobotId = robotId;
|
||||||
|
Db.Storageable(device).ExecuteCommand();
|
||||||
|
}
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Device device;
|
||||||
|
private DeviceSession CheckLoginDevice()
|
||||||
|
{
|
||||||
|
var Id = GetString("Id", true);
|
||||||
|
var Token = GetString("Token", true);
|
||||||
|
device = Db.Queryable<Device>().WithCache().Single(f => f.Id == Id);
|
||||||
|
if (Client.OnlineDevices.ContainsKey(Id) && device != null && device.Token == Token)
|
||||||
|
{
|
||||||
|
return Client.OnlineDevices[Id];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using CsharpHttpHelper;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Server.MyClass.Class;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.JsonModels;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OpenManagement
|
||||||
|
{
|
||||||
|
public class OpenController:DefaultController
|
||||||
|
{
|
||||||
|
|
||||||
|
public class Slider
|
||||||
|
{
|
||||||
|
public bool sliderSuccessed { get; set; }
|
||||||
|
|
||||||
|
public int y { get; set; }
|
||||||
|
|
||||||
|
public string src { get; set; }
|
||||||
|
|
||||||
|
public bool sliderVisible { get; set; }
|
||||||
|
|
||||||
|
public int sliderMx { get; set; }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 登录接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Login()
|
||||||
|
{
|
||||||
|
var Username = GetString("Username",true);
|
||||||
|
var Password = GetString("Password",true);
|
||||||
|
var user = Db.Queryable<Staff>().Where(f=>f.Username == Username).First();
|
||||||
|
if (user == null || Password != user.Password)
|
||||||
|
{
|
||||||
|
return PutData("登录失败,用户名或密码错误!");
|
||||||
|
}
|
||||||
|
if (Client.OnlineUsers.ContainsKey(user.Id))
|
||||||
|
{
|
||||||
|
if (!Client.OnlineUsers.TryRemove(user.Id, out var oldUser))
|
||||||
|
{
|
||||||
|
return PutError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var session = new UserSession(user);
|
||||||
|
session.IsCreator = user.IsCreator;
|
||||||
|
if (!Client.OnlineUsers.TryAdd(user.Id, session))
|
||||||
|
{
|
||||||
|
return PutError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PutData(session);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 背景图
|
||||||
|
/// </summary>
|
||||||
|
private static readonly List<string> bgs = new List<string>() { "/imgs/clouds.jpg", "/imgs/leafs.jpg", "/imgs/moon.jpg", "/imgs/mountains.jpg", "/imgs/rocks.jpg" };
|
||||||
|
/// <summary>
|
||||||
|
/// 登录接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetCaptch()
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
var slider = new Slider()
|
||||||
|
{
|
||||||
|
sliderSuccessed = false,
|
||||||
|
sliderMx = random.Next(130, 230),
|
||||||
|
y = random.Next(10,99),
|
||||||
|
sliderVisible = true,
|
||||||
|
src = bgs[random.Next(0,bgs.Count - 1)]
|
||||||
|
};
|
||||||
|
var base64Str = HttpExtend.StringToBase64String(JsonConvert.SerializeObject(slider));
|
||||||
|
var Id = Guid.NewGuid().ToString("N");
|
||||||
|
Client.Cache.Add(Id, slider, 60*2);
|
||||||
|
return PutData(new {Id = Id, Data = base64Str });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult CheckCaptch()
|
||||||
|
{
|
||||||
|
var Id = GetString("Id", true);
|
||||||
|
var time = GetDouble("Time", true);
|
||||||
|
var X = GetInt("X", true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var target = Client.Cache.Get<Slider>(Id);
|
||||||
|
var min = target.sliderMx - 10;
|
||||||
|
var max = target.sliderMx + 10;
|
||||||
|
time = time / 1000;
|
||||||
|
if (X > min && X < max)
|
||||||
|
{
|
||||||
|
if (time < 0.5)
|
||||||
|
{
|
||||||
|
return PutData("哎呀,手速太快啦");
|
||||||
|
}
|
||||||
|
else if (time > 5)
|
||||||
|
{
|
||||||
|
return PutData("哎呀,手速太慢啦");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PutData("出现错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception )
|
||||||
|
{
|
||||||
|
return PutError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退出登录
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult Logout()
|
||||||
|
{
|
||||||
|
if (Session != null)
|
||||||
|
{
|
||||||
|
if (!Client.OnlineUsers.TryRemove(Session.Uid, out _))
|
||||||
|
{
|
||||||
|
|
||||||
|
return PutError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取网站信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetWebInfo()
|
||||||
|
{
|
||||||
|
return PutData(Db.GetMapValue<WebInfo>("WebInfo", () => null));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OrderManagement
|
||||||
|
{
|
||||||
|
public class DyOrderController:DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询京东订单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetDyOrders()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<DyOrder, User, Robot>();
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddMonths(-3);
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
exp.And((o, u, r) => o.pay_success_time > MinTime && o.pay_success_time < MaxTime);
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And((o, u, r) => r.Id == RobotId);
|
||||||
|
|
||||||
|
var OrderStatus = GetEnum<SystemOrderStatus>("OrderStatus");
|
||||||
|
|
||||||
|
if (OrderStatus != SystemOrderStatus.未知)
|
||||||
|
exp.And((o, u, r) => o.SystemOrderStatus == OrderStatus);
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
var KeywordType = GetInt("KeywordType", true);
|
||||||
|
|
||||||
|
switch (KeywordType)
|
||||||
|
{
|
||||||
|
case 1://用户账号查询
|
||||||
|
exp.And((o, u, r) => u.Username.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 2://用户昵称查询
|
||||||
|
exp.And((o, u, r) => u.NickName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 3://订单编号查询
|
||||||
|
exp.And((o, u, r) => o.order_id.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 4://商品编号查询
|
||||||
|
exp.And((o, u, r) => o.item_num.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 5://商品名称
|
||||||
|
exp.And((o, u, r) => o.product_name.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<DyOrder>()
|
||||||
|
.SplitTable(it => it.Take(6))
|
||||||
|
.LeftJoin<User>((o, u) => o.UserId == u.Id)
|
||||||
|
.LeftJoin<Robot>((o, u, r) => u.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((o, u, r) => new DyOrderShow
|
||||||
|
{
|
||||||
|
//ItemCount = Convert.ToInt32(o.), //?
|
||||||
|
//Itemid = o.item_num.ToString(),
|
||||||
|
//ItemTitle = o.product_name,
|
||||||
|
//OrderStatus = o.SystemOrderStatus,
|
||||||
|
//PayPrice = o.settled_tech_service_fee,
|
||||||
|
//UserHeadurl = u.Headurl,
|
||||||
|
//UserId = o.UserId,
|
||||||
|
//UsOrderNumber = o.orderId.ToString(),
|
||||||
|
//UserNickname = u.NickName,
|
||||||
|
//RobotName = r.Nickname,
|
||||||
|
//PartnerPoint = 0.00, //?
|
||||||
|
//RebatePoint = o.subSideRate, //?
|
||||||
|
//TkOrderNumber = null, // 联盟订单编号 ?
|
||||||
|
//RecommendPoint = 0.00, //?
|
||||||
|
//Commission = o.commissionRate,//?
|
||||||
|
//GrossProfit = o.estimateCosPrice, //?
|
||||||
|
}).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
|
||||||
|
var res = new PageResult<DyOrderShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Server.Services;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OrderManagement
|
||||||
|
{
|
||||||
|
public class JdOrderController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询京东订单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetJdOrders()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<JdOrder, User, Robot>();
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddMonths(-3);
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
exp.And((o, u, r) => o.orderTime > MinTime && o.orderTime < MaxTime);
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And((o, u, r) => r.Id == RobotId);
|
||||||
|
|
||||||
|
var OrderStatus = GetEnum<SystemOrderStatus>("OrderStatus");
|
||||||
|
|
||||||
|
if (OrderStatus != SystemOrderStatus.未知)
|
||||||
|
exp.And((o, u, r) => o.SystemOrderStatus == OrderStatus);
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
var KeywordType = GetInt("KeywordType", true);
|
||||||
|
|
||||||
|
switch (KeywordType)
|
||||||
|
{
|
||||||
|
case 1://用户账号查询
|
||||||
|
exp.And((o, u, r) => u.Username.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 2://用户昵称查询
|
||||||
|
exp.And((o, u, r) => u.NickName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 3://订单编号查询
|
||||||
|
exp.And((o, u, r) => o.orderId.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 4://商品编号查询
|
||||||
|
exp.And((o, u, r) => o.skuId.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 5://商品名称
|
||||||
|
exp.And((o, u, r) => o.skuName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<JdOrder>()
|
||||||
|
.SplitTable(it => it.Take(6))
|
||||||
|
.LeftJoin<User>((o, u) => o.UserId == u.Id)
|
||||||
|
.LeftJoin<Robot>((o, u, r) => u.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((o, u, r) => new JdOrderShow
|
||||||
|
{
|
||||||
|
ItemCount = Convert.ToInt32(o.skuNum), //?
|
||||||
|
Itemid = o.skuId.ToString(),
|
||||||
|
ItemTitle = o.skuName,
|
||||||
|
OrderStatus = o.SystemOrderStatus,
|
||||||
|
PayPrice = o.price,
|
||||||
|
UserHeadurl = u.Headurl,
|
||||||
|
UserId = o.UserId,
|
||||||
|
UsOrderNumber = o.orderId.ToString(),
|
||||||
|
UserNickname = u.NickName,
|
||||||
|
RobotName = r.Nickname,
|
||||||
|
PartnerPoint = 0.00, //?
|
||||||
|
RebatePoint = o.subSideRate, //?
|
||||||
|
TkOrderNumber = null, // 联盟订单编号 ?
|
||||||
|
RecommendPoint = 0.00, //?
|
||||||
|
Commission = o.commissionRate,//?
|
||||||
|
GrossProfit = o.estimateCosPrice, //?
|
||||||
|
}).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
|
||||||
|
var res = new PageResult<JdOrderShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加京东商店黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddGoodsBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<JdOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddGoodsBlack(order.skuId, LianmengType.京东联盟, order.skuName, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加京东店铺黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddStoreBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<JdOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddStoreBlack(LianmengType.京东联盟, order.popId + "", "", remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,175 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Server.Services;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OrderManagement
|
||||||
|
{
|
||||||
|
public class PddOrderController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetPddOrders()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<PddOrder, User, Robot>();
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddMonths(-3);
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
exp.And((o, u, r) => o.order_create_time > MinTime && o.order_create_time < MaxTime);
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And((o, u, r) => r.Id == RobotId);
|
||||||
|
|
||||||
|
var OrderStatus = GetEnum<SystemOrderStatus>("OrderStatus");
|
||||||
|
|
||||||
|
if (OrderStatus != SystemOrderStatus.未知)
|
||||||
|
exp.And((o, u, r) => o.SystemOrderStatus == OrderStatus);
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
var KeywordType = GetInt("KeywordType", true);
|
||||||
|
|
||||||
|
switch (KeywordType)
|
||||||
|
{
|
||||||
|
case 1://用户账号查询
|
||||||
|
exp.And((o, u, r) => u.Username.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 2://用户昵称查询
|
||||||
|
exp.And((o, u, r) => u.NickName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 3://订单编号查询
|
||||||
|
exp.And((o, u, r) => o.order_sn.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 4://商品编号查询
|
||||||
|
exp.And((o, u, r) => o.goods_id.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 5://商品名称
|
||||||
|
exp.And((o, u, r) => o.goods_name.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<PddOrder>()
|
||||||
|
.SplitTable(it => it.Take(6))
|
||||||
|
.LeftJoin<User>((o, u) => o.UserId == u.Id)
|
||||||
|
.LeftJoin<Robot>((o, u, r) => u.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((o, u, r) => new PddOrderShow
|
||||||
|
{
|
||||||
|
ItemCount = o.goods_quantity, //?
|
||||||
|
Itemid = o.goods_id.ToString(),
|
||||||
|
ItemTitle = o.goods_name,
|
||||||
|
OrderStatus = o.SystemOrderStatus,
|
||||||
|
PayPrice = o.order_amount,
|
||||||
|
UserHeadurl = u.Headurl,
|
||||||
|
UserId = o.UserId,
|
||||||
|
UsOrderNumber = o.order_sn.ToString(),
|
||||||
|
UserNickname = u.NickName,
|
||||||
|
RobotName = r.Nickname,
|
||||||
|
PartnerPoint = 0.00, //?
|
||||||
|
RebatePoint = o.promotion_amount, //?
|
||||||
|
TkOrderNumber = null, // 联盟订单编号 ?
|
||||||
|
RecommendPoint = 0.00, //?
|
||||||
|
Commission = o.promotion_amount,//?
|
||||||
|
GrossProfit = o.promotion_rate, //?
|
||||||
|
}).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
|
||||||
|
var res = new PageResult<PddOrderShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加拼多多商店黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddGoodsBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<PddOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddGoodsBlack(order.goods_id + "", LianmengType.拼多多联盟, order.goods_name, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加拼多多店铺黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddStoreBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<PddOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddStoreBlack(LianmengType.拼多多联盟, order.mall_id + "", "", remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,177 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Server.Services;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OrderManagement
|
||||||
|
{
|
||||||
|
public class SnOrderController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetSnOrders()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<SnOrder, User, Robot>();
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddMonths(-3);
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
exp.And((o, u, r) => o.orderSubmitTime > MinTime && o.orderSubmitTime < MaxTime);
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And((o, u, r) => r.Id == RobotId);
|
||||||
|
|
||||||
|
var OrderStatus = GetEnum<SystemOrderStatus>("OrderStatus");
|
||||||
|
|
||||||
|
if (OrderStatus != SystemOrderStatus.未知)
|
||||||
|
exp.And((o, u, r) => o.SystemOrderStatus == OrderStatus);
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
var KeywordType = GetInt("KeywordType", true);
|
||||||
|
|
||||||
|
switch (KeywordType)
|
||||||
|
{
|
||||||
|
case 1://用户账号查询
|
||||||
|
exp.And((o, u, r) => u.Username.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 2://用户昵称查询
|
||||||
|
exp.And((o, u, r) => u.NickName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 3://订单编号查询
|
||||||
|
exp.And((o, u, r) => o.orderCode.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 4://商品编号查询
|
||||||
|
exp.And((o, u, r) => o.goodsNum.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 5://商品名称
|
||||||
|
exp.And((o, u, r) => o.productName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<SnOrder>()
|
||||||
|
.SplitTable(it => it.Take(6))
|
||||||
|
.LeftJoin<User>((o, u) => o.UserId == u.Id)
|
||||||
|
.LeftJoin<Robot>((o, u, r) => u.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((o, u, r) => new SnOrderShow
|
||||||
|
{
|
||||||
|
ItemCount = Convert.ToInt32(o.saleNum), //?
|
||||||
|
Itemid = o.goodsNum.ToString(),
|
||||||
|
ItemTitle = o.productName,
|
||||||
|
OrderStatus = o.SystemOrderStatus,
|
||||||
|
PayPrice = double.Parse(o.payAmount),
|
||||||
|
UserHeadurl = u.Headurl,
|
||||||
|
UserId = o.UserId,
|
||||||
|
UsOrderNumber = o.orderCode.ToString(),
|
||||||
|
UserNickname = u.NickName,
|
||||||
|
RobotName = r.Nickname,
|
||||||
|
PartnerPoint = 0.00, //?
|
||||||
|
RebatePoint = 0.00, //?
|
||||||
|
TkOrderNumber = null, // 联盟订单编号 ?
|
||||||
|
RecommendPoint = 0.00, //?
|
||||||
|
Commission = double.Parse(o.prePayCommission),//?
|
||||||
|
GrossProfit = double.Parse(o.commissionRatio), //?
|
||||||
|
}).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
|
||||||
|
var res = new PageResult<SnOrderShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加苏宁商店黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddGoodsBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<SnOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddGoodsBlack(order.goodsNum + "", LianmengType.苏宁联盟, order.productName, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加苏宁店铺黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddStoreBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<SnOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddStoreBlack(LianmengType.苏宁联盟, order.mallId + "", order.sellName, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,179 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Server.Services;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OrderManagement
|
||||||
|
{
|
||||||
|
public class TbOrderController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询淘宝订单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetTbOrders()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<TbOrder, User, Robot>();
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddMonths(-3);
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
exp.And((o, u, r) => o.tk_create_time > MinTime && o.tk_create_time < MaxTime);
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And((o, u, r) => r.Id == RobotId);
|
||||||
|
|
||||||
|
var OrderStatus = GetEnum<SystemOrderStatus>("OrderStatus");
|
||||||
|
|
||||||
|
if (OrderStatus != SystemOrderStatus.未知)
|
||||||
|
exp.And((o, u, r) => o.SystemOrderStatus == OrderStatus);
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
var KeywordType = GetInt("KeywordType", true);
|
||||||
|
|
||||||
|
switch (KeywordType)
|
||||||
|
{
|
||||||
|
case 1://用户账号查询
|
||||||
|
exp.And((o, u, r) => u.Username.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 2://用户昵称查询
|
||||||
|
exp.And((o, u, r) => u.NickName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 3://订单编号查询
|
||||||
|
exp.And((o, u, r) => o.trade_id.Contains(Keyword) || o.trade_parent_id.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 4://商品编号查询
|
||||||
|
exp.And((o, u, r) => o.item_id.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 5://商品名称
|
||||||
|
exp.And((o, u, r) => o.item_title.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<TbOrder>()
|
||||||
|
.SplitTable(it=>it.Take(6))
|
||||||
|
.LeftJoin<User>((o, u) => o.UserId == u.Id)
|
||||||
|
.LeftJoin<Robot>((o, u, r) => u.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((o, u, r) => new TboderShow
|
||||||
|
{
|
||||||
|
ItemCount = o.item_num,
|
||||||
|
Itemid = o.item_id,
|
||||||
|
ItemTitle = o.item_title,
|
||||||
|
OrderStatus = o.SystemOrderStatus,
|
||||||
|
PayPrice = double.Parse(o.pay_price),
|
||||||
|
UserHeadurl = u.Headurl,
|
||||||
|
UserId = o.UserId,
|
||||||
|
UsOrderNumber = o.trade_id,
|
||||||
|
UserNickname = u.NickName,
|
||||||
|
RobotName = r.Nickname,
|
||||||
|
PartnerPoint = 0.00, //?
|
||||||
|
RebatePoint = double.Parse(o.pub_share_fee), //?
|
||||||
|
TkOrderNumber = null, // 联盟订单编号 ?
|
||||||
|
RecommendPoint = 0.00, //?
|
||||||
|
Commission = double.Parse(o.pub_share_fee),//?
|
||||||
|
GrossProfit = o.pub_share_pre_fee, //?
|
||||||
|
}).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
|
||||||
|
var res = new PageResult<TboderShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加淘宝商店黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddGoodsBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<TbOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddGoodsBlack(order.item_id + "", LianmengType.淘宝联盟, order.item_title, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加淘宝店铺黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddStoreBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<TbOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddStoreBlack(LianmengType.淘宝联盟, order.shop_id + "", order.seller_shop_title, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,176 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Server.MyClass.Views;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Server.Services;
|
||||||
|
|
||||||
|
namespace Server.Controllers.OrderManagement
|
||||||
|
{
|
||||||
|
public class WphOrderController : DefaultController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取机器人信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetRobotInfo()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex");
|
||||||
|
var PageSize = GetInt("PageSize");
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<Robot>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
exp.And(f => f.Nickname.Contains(Keyword));
|
||||||
|
}
|
||||||
|
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
|
||||||
|
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
|
||||||
|
.ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult GetWphOrders()
|
||||||
|
{
|
||||||
|
var PageIndex = GetInt("PageIndex", true);
|
||||||
|
var PageSize = GetInt("PageSize", true);
|
||||||
|
var tNumber = 0;
|
||||||
|
|
||||||
|
var MinTime = GetTime("MinTime");
|
||||||
|
var MaxTime = GetTime("MaxTime");
|
||||||
|
|
||||||
|
var exp = Expressionable.Create<WphOrder, User, Robot>();
|
||||||
|
|
||||||
|
if (MinTime == DateTime.MinValue) MinTime = DateTime.Now.AddMonths(-3);
|
||||||
|
if (MaxTime == DateTime.MinValue) MaxTime = DateTime.Now;
|
||||||
|
|
||||||
|
exp.And((o, u, r) => o.orderTime > MinTime && o.orderTime < MaxTime);
|
||||||
|
|
||||||
|
var RobotId = GetInt("RobotId");
|
||||||
|
if (RobotId > 0)
|
||||||
|
exp.And((o, u, r) => r.Id == RobotId);
|
||||||
|
|
||||||
|
var OrderStatus = GetEnum<SystemOrderStatus>("OrderStatus");
|
||||||
|
|
||||||
|
if (OrderStatus != SystemOrderStatus.未知)
|
||||||
|
exp.And((o, u, r) => o.SystemOrderStatus == OrderStatus);
|
||||||
|
|
||||||
|
var Keyword = GetString("Keyword");
|
||||||
|
if (!string.IsNullOrEmpty(Keyword))
|
||||||
|
{
|
||||||
|
var KeywordType = GetInt("KeywordType", true);
|
||||||
|
|
||||||
|
switch (KeywordType)
|
||||||
|
{
|
||||||
|
case 1://用户账号查询
|
||||||
|
exp.And((o, u, r) => u.Username.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 2://用户昵称查询
|
||||||
|
exp.And((o, u, r) => u.NickName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 3://订单编号查询
|
||||||
|
exp.And((o, u, r) => o.orderSn.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 4://商品编号查询
|
||||||
|
exp.And((o, u, r) => o.goodsId.ToString().Contains(Keyword));
|
||||||
|
break;
|
||||||
|
case 5://商品名称
|
||||||
|
exp.And((o, u, r) => o.goodsName.Contains(Keyword));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var DataList = Db.Queryable<WphOrder>()
|
||||||
|
.SplitTable(it => it.Take(6))
|
||||||
|
.LeftJoin<User>((o, u) => o.UserId == u.Id)
|
||||||
|
.LeftJoin<Robot>((o, u, r) => u.RobotId == r.Id)
|
||||||
|
.Where(exp.ToExpression())
|
||||||
|
.Select((o, u, r) => new WphOrderShow
|
||||||
|
{
|
||||||
|
ItemCount = o.goodsCount,
|
||||||
|
Itemid = o.goodsId.ToString(),
|
||||||
|
ItemTitle = o.goodsName,
|
||||||
|
OrderStatus = o.SystemOrderStatus,
|
||||||
|
PayPrice = o.goodsFinalPrice,
|
||||||
|
UserHeadurl = u.Headurl,
|
||||||
|
UserId = o.UserId,
|
||||||
|
UsOrderNumber = o.orderSn.ToString(),
|
||||||
|
UserNickname = u.NickName,
|
||||||
|
RobotName = r.Nickname,
|
||||||
|
PartnerPoint = 0.00, //?
|
||||||
|
RebatePoint = o.commission, //?
|
||||||
|
TkOrderNumber = null, // 联盟订单编号 ?
|
||||||
|
RecommendPoint = 0.00, //?
|
||||||
|
Commission = o.commission,//?
|
||||||
|
GrossProfit = o.commissionRate, //?
|
||||||
|
}).ToPageList(PageIndex, PageSize, ref tNumber);
|
||||||
|
|
||||||
|
|
||||||
|
var res = new PageResult<WphOrderShow>(DataList, tNumber, PageSize, PageIndex);
|
||||||
|
|
||||||
|
return PutData(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加唯品会商店黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddGoodsBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<WphOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddGoodsBlack(order.goodsId + "", LianmengType.唯品会联盟, order.goodsName, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加唯品会店铺黑名单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ErrorFilter]
|
||||||
|
public WebResult AddStoreBlack()
|
||||||
|
{
|
||||||
|
var id = GetLong("Id");
|
||||||
|
var isCloud = GetBoolean("IsCloud");
|
||||||
|
var remark = GetString("Remark");
|
||||||
|
var order = Db.Queryable<WphOrder>().SplitTable(it => it.Take(6)).Where(w => w.Id == id).First();
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return PutData("订单不存在");
|
||||||
|
}
|
||||||
|
var ser = new BlacklistService();
|
||||||
|
var result = ser.AddStoreBlack(LianmengType.唯品会联盟, order.mallId + "", order.brandStoreName, remark, isCloud);
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
return PutSuccess;
|
||||||
|
}
|
||||||
|
return PutData(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,45 @@
|
||||||
|
using Common.DbExtends.Extends;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Server.Events;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
internal class EventManager
|
||||||
|
{
|
||||||
|
private Client client;
|
||||||
|
internal EventManager(Client client) { this.client = client; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关闭程序
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<EventArgs> ExitWinform;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单发生改变
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<OrderChangeEventArgs> OrderChange;
|
||||||
|
|
||||||
|
public void OnExitWinform(object sender)
|
||||||
|
{
|
||||||
|
ExitWinform?.Invoke(sender, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单改变
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">调用的类</param>
|
||||||
|
/// <param name="e">订单相关信息</param>
|
||||||
|
public void OnOrderChange(object sender, OrderChangeEventArgs e)
|
||||||
|
{
|
||||||
|
OrderChange?.BeginInvoke(sender, e, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.Events
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 订单状态发生改变
|
||||||
|
/// </summary>
|
||||||
|
public class OrderChangeEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 联盟类型
|
||||||
|
/// </summary>
|
||||||
|
public LianmengType LianmengType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单编号(注意,是数据库内的ID)
|
||||||
|
/// </summary>
|
||||||
|
public long OrderId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户编号
|
||||||
|
/// </summary>
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 老状态
|
||||||
|
/// </summary>
|
||||||
|
public SystemOrderStatus OldStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最新状态
|
||||||
|
/// </summary>
|
||||||
|
public SystemOrderStatus NewStatus { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,867 @@
|
||||||
|
using CsharpHttpHelper;
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.HttpRequests
|
||||||
|
{
|
||||||
|
public class TaobaoRequest
|
||||||
|
{
|
||||||
|
public delegate bool OrderChange(TaobaoRequest Req, JToken Order);
|
||||||
|
public static event OrderChange OrderChangeEvent;
|
||||||
|
|
||||||
|
#region 阿里妈妈请求类
|
||||||
|
public TaobaoRequest() { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Lianmeng Lianmeng { get; private set; }
|
||||||
|
|
||||||
|
public string Token { get { return Lianmeng.Token; } }
|
||||||
|
|
||||||
|
public TaobaoRequest(Lianmeng Lianmeng)
|
||||||
|
{
|
||||||
|
if (Lianmeng.LianmengType != LianmengType.淘宝联盟) throw new Exception($"当前账号{Lianmeng.LianmengType},不支持!");
|
||||||
|
this.Lianmeng = Lianmeng;
|
||||||
|
}
|
||||||
|
|
||||||
|
TbMedia Meadia;
|
||||||
|
public TaobaoRequest(Lianmeng Lianmeng, TbMedia Media)
|
||||||
|
{
|
||||||
|
if (Lianmeng.LianmengType != LianmengType.淘宝联盟) throw new Exception($"当前账号{Lianmeng.LianmengType},不支持!");
|
||||||
|
this.Lianmeng = Lianmeng;
|
||||||
|
this.Meadia = Media;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private string Appid { get; set; } = "27754179";
|
||||||
|
private string Appsecret { get; set; } = "2ee7beffe4752708564bf110971c262f";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private const string SIGN_METHOD_MD5 = "md5";
|
||||||
|
private const string SIGN_METHOD_HMAC = "hmac";
|
||||||
|
private string SignTopRequest(Dictionary<string, string> parameters, string secret, string signMethod = "hmac")
|
||||||
|
{
|
||||||
|
// 第一步:把字典按Key的字母顺序排序
|
||||||
|
IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters, StringComparer.Ordinal);
|
||||||
|
|
||||||
|
// 第二步:把所有参数名和参数值串在一起
|
||||||
|
StringBuilder query = new StringBuilder();
|
||||||
|
if (SIGN_METHOD_MD5.Equals(signMethod))
|
||||||
|
{
|
||||||
|
query.Append(secret);
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<string, string> kv in sortedParams)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(kv.Key) && !string.IsNullOrEmpty(kv.Value) && kv.Key != "sign")
|
||||||
|
{
|
||||||
|
query.Append(kv.Key).Append(kv.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// 第三步:把请求主体拼接在参数后面
|
||||||
|
//if (!string.IsNullOrEmpty(body))
|
||||||
|
//{
|
||||||
|
// query.Append(body);
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 第四步:使用MD5/HMAC加密
|
||||||
|
byte[] bytes;
|
||||||
|
if (SIGN_METHOD_HMAC.Equals(signMethod))
|
||||||
|
{
|
||||||
|
HMACMD5 hmac = new HMACMD5(Encoding.UTF8.GetBytes(secret));
|
||||||
|
bytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(query.ToString()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
query.Append(secret);
|
||||||
|
MD5 md5 = MD5.Create();
|
||||||
|
bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(query.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第五步:把二进制转化为大写的十六进制
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (int i = 0; i < bytes.Length; i++)
|
||||||
|
{
|
||||||
|
result.Append(bytes[i].ToString("X2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计算签名,返回请求阿里妈妈服务器的参数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_api">api名称</param>
|
||||||
|
/// <param name="_data">参数</param>
|
||||||
|
/// <param name="appkey">appkey</param>
|
||||||
|
/// <param name="appsecret">appsecret</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private string GetAlimamaRequestData(string _api, object _data, string appkey = "", string appsecret = "", string token = "")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = _data;
|
||||||
|
var api = _api;
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
var type = data.GetType().GetProperties();
|
||||||
|
|
||||||
|
foreach (var item in type)
|
||||||
|
{
|
||||||
|
var _value = item.GetValue(data).ToString();
|
||||||
|
param[item.Name] = _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
param["method"] = api;
|
||||||
|
param["app_key"] = appkey;
|
||||||
|
param["session"] = token;
|
||||||
|
param["timestamp"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
param["format"] = "json";
|
||||||
|
param["v"] = "2.0";
|
||||||
|
param["sign_method"] = "md5";
|
||||||
|
|
||||||
|
//计算签名
|
||||||
|
string sign = SignTopRequest(param, appsecret, param["sign_method"]);
|
||||||
|
param["sign"] = sign;
|
||||||
|
return HttpExtend.BuildQuery(param);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求淘宝服务器端
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ApiName">api名称</param>
|
||||||
|
/// <param name="Data">参数</param>
|
||||||
|
/// <param name="ThrowException">异常是否抛出</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public JToken GetJSON(string ApiName, object Data, bool ThrowException = false)
|
||||||
|
{
|
||||||
|
var query = GetAlimamaRequestData(ApiName, Data, Appid, Appsecret, Token);
|
||||||
|
var html = string.Empty;
|
||||||
|
string _url = string.Empty;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpHelper http = new HttpHelper();
|
||||||
|
|
||||||
|
_url = "http://gw.api.taobao.com/router/rest?" + query;
|
||||||
|
HttpItem item = new HttpItem()
|
||||||
|
{
|
||||||
|
URL = _url,//URL 必需项
|
||||||
|
Method = "GET",//URL 可选项 默认为Get
|
||||||
|
Timeout = 5000,//连接超时时间 可选项默认为100000
|
||||||
|
ReadWriteTimeout = 5000,//写入Post数据超时时间
|
||||||
|
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
|
||||||
|
ContentType = "application/json",//返回类型 可选项有默认值
|
||||||
|
};
|
||||||
|
var result = http.GetHtml(item);
|
||||||
|
//{"tbk_dg_vegas_tlj_create_response":{"result":{"model":{"rights_id":"XvLXNwkX8HBQ8VZ2WS4DlNtN7m9cS4TU","send_url":"https:\/\/uland.taobao.com\/taolijin\/edetail?eh=5L6pfx5vldOZuQF0XRz0iAXoB%2BDaBK5LQS0Flu%2FfbSp4QsdWMikAalrisGmre1Id0BFAqRODu1004PvI5lqUzYTPq7zN5TtBXU4J7X2wljh7PW2ShemY2x1IRRpXndAncj8tXpgtxXzbOKxKSviYxsuv0da8KKt7WubOUkoI2Oa3HR2hP0JFSmjppH3xlrrJg8pBHJnzzOjd2vZvO6fEydXbwx4naJ6dk%2FBu2lJxZtMc7BMk%2FDH7wY2fDQKPuN9qcxwaWpDoQwfi%2B9ZUBfurmaewy3GJqMoK4342DlvX1ZVNOJlvqrE2h6J7%2BkHL3AEW&union_lens=lensId%3A0b14fbf4_0b3d_16f65a622fd_31b4%3Btraffic_flag%3Dlm","vegas_code":"N4HHV6HV"},"success":true},"request_id":"no8k8bbwsct2"}}
|
||||||
|
|
||||||
|
if (result != null && result.StatusCode != System.Net.HttpStatusCode.OK) throw new Exception(result.Html);
|
||||||
|
html = result.Html;
|
||||||
|
|
||||||
|
var JsonResult = JObject.Parse(html);
|
||||||
|
if (JsonResult == null) throw new Exception(html);
|
||||||
|
if (JsonResult["error_response"] != null)
|
||||||
|
throw new Exception(html);
|
||||||
|
//tbk_sc_order_details_get_response
|
||||||
|
//tbk_sc_order_details_get_response
|
||||||
|
var key = ApiName.Replace("taobao.", "").Replace(".", "_") + "_response";
|
||||||
|
if (JsonResult[key] == null) throw new Exception($"key = {key},html = {html}");
|
||||||
|
var ResultToken = JsonResult[key];
|
||||||
|
if (ResultToken["result"] != null) return ResultToken["result"];
|
||||||
|
if (ResultToken["results"] != null) return ResultToken["results"];
|
||||||
|
if (ResultToken["data"] != null) return ResultToken["data"];
|
||||||
|
return ResultToken;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (ex.Message.Contains("过期"))
|
||||||
|
{
|
||||||
|
Lianmeng.ExpirationTime = DateTime.Now;
|
||||||
|
//Client.SigleClient.Db.Updateable(Lianmeng).UpdateColumns(f => new { f.ExpirationTime }).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Client.SigleClient.Event.OnLog($"请求API:{ApiName}发生错误,{ex.Message}", "系统", ex, true);
|
||||||
|
if (ThrowException) throw ex;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="StartTime">开始时间</param>
|
||||||
|
/// <param name="EndTime">结束时间</param>
|
||||||
|
/// <param name="orderScene">同步的订单类型</param>
|
||||||
|
/// <returns>返回错误原因</returns>
|
||||||
|
public Task<string> UpdateOrder(DateTime StartTime, DateTime EndTime, TBOrderScene orderScene = TBOrderScene.常规订单)
|
||||||
|
{
|
||||||
|
return Task.Factory.StartNew<string>(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (StartTime < DateTime.Now.AddMonths(-5)) StartTime = DateTime.Now.AddMonths(-5);
|
||||||
|
var time = StartTime;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
逻辑:从结束的时间,倒序更新
|
||||||
|
*/
|
||||||
|
var sTime = time;
|
||||||
|
var eTime = time.AddHours(3);
|
||||||
|
//if (eTime > EndTime) eTime = StartTime;
|
||||||
|
|
||||||
|
time = eTime;
|
||||||
|
|
||||||
|
//是否还有下一页
|
||||||
|
var page_on = 0;
|
||||||
|
var has_next = false;
|
||||||
|
var position_index = string.Empty;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
page_on++;
|
||||||
|
var postData = new
|
||||||
|
{
|
||||||
|
query_type = 4,//查询时间类型,1:按照订单淘客创建时间查询,2:按照订单淘客付款时间查询,3:按照订单淘客结算时间查询,4:按照订单更新时间;
|
||||||
|
page_size = 100,//页大小
|
||||||
|
start_time = sTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
|
end_time = eTime.ToString("yyyy-MM-dd HH:mm:ss"),//这里是对应前面同步间隔的19分钟 //【订单查询结束时间,订单开始时间至订单结束时间,中间时间段日常要求不超过3个小时,但如618、双11、年货节等大促期间预估时间段不可超过20分钟,超过会提示错误,调用时请务必注意时间段的选择,以保证亲能正常调用!】
|
||||||
|
page_no = page_on,
|
||||||
|
position_index = position_index,
|
||||||
|
order_scene = (int)orderScene,
|
||||||
|
};
|
||||||
|
var Json = GetJSON("taobao.tbk.sc.order.details.get", postData);
|
||||||
|
if (Json != null && Json["data"] != null)
|
||||||
|
{
|
||||||
|
var Data = Json["data"];
|
||||||
|
has_next = (bool)Data["has_next"];
|
||||||
|
position_index = Data["position_index"].ToString();
|
||||||
|
var orders = Data["results"]["publisher_order_dto"];
|
||||||
|
if (orders == null) break;
|
||||||
|
|
||||||
|
foreach (var item in orders)
|
||||||
|
{
|
||||||
|
item["LianmengId"] = Lianmeng.Id;
|
||||||
|
OrderChangeEvent?.Invoke(this, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has_next)
|
||||||
|
{
|
||||||
|
Lianmeng.ModifiedTime = sTime;
|
||||||
|
//Client.SigleClient.Db.SaveCache(Lianmeng);
|
||||||
|
//Client.SigleClient.Db.Updateable(Lianmeng).UpdateColumns(f => new { f.ModifiedTime }).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
} while (has_next);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} while (time < EndTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//Client.SigleClient.Event.OnLog(ex.Message, "淘宝", ex);
|
||||||
|
return ex.Message;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 淘口令解析并转链 返回商品ID 【淘宝客-服务商-淘口令解析&转链】
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public JToken TpwdConvert(string Content, string SiteId, string AdzoneId)
|
||||||
|
{
|
||||||
|
return GetJSON("taobao.tbk.sc.tpwd.convert", new { password_content = Content, adzone_id = AdzoneId, site_id = SiteId });
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 正则获取Url链接
|
||||||
|
/// </summary>
|
||||||
|
public const string RegexGetUrl = @"(?<链接>(?:(?:ht|f)tps?):\/\/[\w\-]+(?:\.[\w\-]+)+(?:[\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?)";
|
||||||
|
public JToken TbUrlAnalysis(string Content)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var regs = Regex.Matches(Content, RegexGetUrl);
|
||||||
|
if (regs.Count == 0) return null;
|
||||||
|
foreach (Match reg in regs)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = reg.Groups["链接"].Value;
|
||||||
|
var jToken = GetJSON("taobao.tbk.item.click.extract", new { click_url = url });
|
||||||
|
if (jToken != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//Client.SigleClient.Event.OnLog($"解析内容中的url异常", Exception: ex, IsDebug: true);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解析宝贝地址
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string AnalysisItemid(string Content)
|
||||||
|
{
|
||||||
|
var itemid = AnalysisItemidByUrl(Content);
|
||||||
|
if (!string.IsNullOrWhiteSpace(itemid))
|
||||||
|
return itemid;
|
||||||
|
|
||||||
|
if (Meadia == null) throw new Exception("推广位信息不能为空!");
|
||||||
|
var convertRst = TpwdConvert(Content, Meadia.SiteId, Meadia.AdzoneId);
|
||||||
|
if (convertRst != null)
|
||||||
|
{
|
||||||
|
return convertRst["num_iid"].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断是否为淘宝的相关域名,后续有新的在这个位置添加
|
||||||
|
/// </summary>
|
||||||
|
private static string RegDomainMatch = @"((?:m.tb.cn))";
|
||||||
|
|
||||||
|
private string AnalysisItemidByUrl(string Content)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//判断是否为淘宝的相关域名
|
||||||
|
if (!Regex.IsMatch(Content, RegDomainMatch, RegexOptions.IgnoreCase))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
var regs = Regex.Matches(Content, RegexGetUrl);
|
||||||
|
if (regs.Count == 0)
|
||||||
|
return String.Empty;
|
||||||
|
|
||||||
|
foreach (Match regTmp in regs)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = regTmp.Groups["链接"].Value;
|
||||||
|
var result = new HttpHelper().GetHtml(url);
|
||||||
|
if (result != null && result.StatusCode != System.Net.HttpStatusCode.OK) throw new Exception(result.Html);
|
||||||
|
var html = result.Html;
|
||||||
|
|
||||||
|
var itemid = string.Empty;
|
||||||
|
var reg = Regex.Match(html, @"var url = '(?<url>.+?)';", RegexOptions.IgnoreCase);
|
||||||
|
if (reg.Success)
|
||||||
|
{
|
||||||
|
itemid = GetItemIdByContent(html);
|
||||||
|
if (!string.IsNullOrWhiteSpace(itemid))
|
||||||
|
return itemid;
|
||||||
|
itemid = GetItemIdByCoupon(reg.Groups["url"].Value);
|
||||||
|
if (!string.IsNullOrWhiteSpace(itemid))
|
||||||
|
return itemid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找宝贝Id的正则表达式
|
||||||
|
/// 注:追加为最后一个括号前加|(?:新的正则)
|
||||||
|
/// </summary>
|
||||||
|
private static string RegItemId = @"((?:item[Ii]d=(?<itemid>\d{5,}))|(?:item_id=(?<itemid>\d{5,}))|(?:\?id=(?<itemid>\d{5,}))|(?:&id=(?<itemid>\d{5,}))|(?:/i(?<itemid>\d{5,}))|(?:num[Ii]id=(?<itemid>\d{5,})))";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 正则表达式匹配商品Id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Content">查找的内容</param>
|
||||||
|
/// <returns>查找到的宝贝id</returns>
|
||||||
|
public string GetItemIdByContent(string Content)
|
||||||
|
{
|
||||||
|
var reg = Regex.Match(Content, RegItemId);
|
||||||
|
if (reg.Success)
|
||||||
|
return reg.Groups["itemid"].Value;
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过优惠券链接获取淘宝宝贝的id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
public string GetItemIdByCoupon(string url)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var urlTmp = url.ToLower();
|
||||||
|
if (urlTmp.Contains(@"uland.taobao.com/coupon"))//这是针对淘宝联盟有优惠券的接口.//https://uland.taobao.com/coupon/edetail
|
||||||
|
{
|
||||||
|
var coupon = CheckCoupon(url);//将返利接口转成淘宝宝贝接口
|
||||||
|
if (coupon != null) return coupon.itemId;
|
||||||
|
}
|
||||||
|
else if (url.Contains(@"s.click.taobao.com"))//这是针对淘宝联盟没有的接口.//https://s.click.taobao.com/t?e=m
|
||||||
|
{
|
||||||
|
var html = string.Empty;
|
||||||
|
|
||||||
|
string locUrl = HttpExtend.GetLocationUrl(url);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(locUrl) && locUrl.StartsWith("https://s.click.taobao.com/t?e=", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var locUrlTmp = HttpExtend.GetLocationUrl(locUrl);
|
||||||
|
if (!string.IsNullOrEmpty(locUrlTmp)) locUrl = locUrlTmp;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(locUrl))//跳转地址存在
|
||||||
|
{
|
||||||
|
if (locUrl.ToLower().Contains("uland.taobao.com/coupon/edetail?"))
|
||||||
|
{
|
||||||
|
|
||||||
|
var reg = Regex.Match(locUrl, @"(?:&|\?)itemId=(\d+)", RegexOptions.IgnoreCase);
|
||||||
|
if (reg.Success)
|
||||||
|
return reg.Groups[1].Value;
|
||||||
|
|
||||||
|
html = HttpHelper.URLDecode(new HttpHelper().GetHtml(locUrl).Html);
|
||||||
|
var reqUrl = Regex.Match(html, "&req_url=([^\"]+)", RegexOptions.IgnoreCase);
|
||||||
|
if (reqUrl.Success)
|
||||||
|
{
|
||||||
|
var param_e = Regex.Match(reqUrl.Groups[1].Value, "e=([^&]+)");
|
||||||
|
if (!param_e.Success)
|
||||||
|
return string.Empty;
|
||||||
|
var coupon = CheckCoupon(reqUrl.Groups[1].Value);
|
||||||
|
if (coupon != null)
|
||||||
|
return coupon.itemId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (locUrl.Contains("uland.taobao.com"))
|
||||||
|
{
|
||||||
|
var _reg = Regex.Match(locUrl, "itemId=(\\d+)", RegexOptions.IgnoreCase);
|
||||||
|
if (_reg.Success)
|
||||||
|
return _reg.Groups[1].Value;
|
||||||
|
}
|
||||||
|
else if (locUrl.Contains("tu="))
|
||||||
|
{
|
||||||
|
//获得二次访问地址
|
||||||
|
string next = HttpHelper.URLDecode(locUrl.Replace("http://s.click.taobao.com/t_js?tu=", "").Replace("https://s.click.taobao.com/t_js?tu=", ""));
|
||||||
|
html = HttpHelper.URLDecode(new HttpHelper().GetHtml(next, referer: locUrl).Html);
|
||||||
|
var reg = Regex.Match(html, @"(?:&|\?)itemId=(\d+)", RegexOptions.IgnoreCase);
|
||||||
|
if (reg.Success)
|
||||||
|
return reg.Groups[1].Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return GetItemIdByContent(new HttpHelper().GetHtml(locUrl).Html);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region
|
||||||
|
if (string.IsNullOrWhiteSpace(locUrl))
|
||||||
|
{
|
||||||
|
html = new HttpHelper().GetHtml(url).Html;
|
||||||
|
var reg = Regex.Match(html, "real_jump_address = '(?<真正的跳转地址>[^']+)");
|
||||||
|
if (reg.Success)
|
||||||
|
{
|
||||||
|
var address = reg.Groups["真正的跳转地址"].Value;
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
html = new HttpHelper().GetHtml(address.Replace("&", "&"), referer: url).Html;
|
||||||
|
var itemid = GetItemIdByContent(html);
|
||||||
|
if (!string.IsNullOrWhiteSpace(itemid))
|
||||||
|
return itemid;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//访问频繁,休息重试3次
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static DateTime NextTime = DateTime.MinValue;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 淘宝优惠券
|
||||||
|
/// </summary>
|
||||||
|
public class TaobaoCoupon
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券状态,!=0表示优惠券失效或没有优惠券
|
||||||
|
/// </summary>
|
||||||
|
public int retStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用条件
|
||||||
|
/// </summary>
|
||||||
|
public string startFee { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用金额
|
||||||
|
/// </summary>
|
||||||
|
public string amount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 店铺Logo
|
||||||
|
/// </summary>
|
||||||
|
public string shopLogo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 店铺名称
|
||||||
|
/// </summary>
|
||||||
|
public string shopName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime effectiveStartTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 活动截止时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime effectiveEndTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 点击下单
|
||||||
|
/// </summary>
|
||||||
|
public string clickUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分享地址
|
||||||
|
/// </summary>
|
||||||
|
public string shareUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 软件标题
|
||||||
|
/// </summary>
|
||||||
|
public string title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原价
|
||||||
|
/// </summary>
|
||||||
|
public string reservePrice { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 折扣价格
|
||||||
|
/// </summary>
|
||||||
|
public string discountPrice { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 30天销量
|
||||||
|
/// </summary>
|
||||||
|
public int biz30Day { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是天猫 ,1(是)
|
||||||
|
/// </summary>
|
||||||
|
public string tmall { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 未知参数
|
||||||
|
/// </summary>
|
||||||
|
public int postFree { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 宝贝ID
|
||||||
|
/// </summary>
|
||||||
|
public string itemId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 未知参数
|
||||||
|
/// </summary>
|
||||||
|
public string couponFlowLimit { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测淘宝优惠券
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="coupon_click_url">优惠券地址</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public TaobaoCoupon CheckCoupon(string coupon_click_url)
|
||||||
|
{
|
||||||
|
string html = string.Empty;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (coupon_click_url.Contains("coupon/details") || coupon_click_url.Contains("coupon/edetail"))
|
||||||
|
{
|
||||||
|
TaobaoCoupon c = new TaobaoCoupon();
|
||||||
|
coupon_click_url = coupon_click_url.Replace("coupon/details", "cp/coupon/").Replace("coupon/edetail", "cp/coupon/");
|
||||||
|
var http = new HttpHelper();
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (NextTime > DateTime.Now)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var item = http.GetItem(coupon_click_url);
|
||||||
|
item.Timeout = 30000;
|
||||||
|
item.ReadWriteTimeout = 20000;
|
||||||
|
item.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0";
|
||||||
|
item.ContentType = "application/x-www-form-urlencoded";
|
||||||
|
item.SetProxyipCDN();
|
||||||
|
html = http.GetHtml(item).Html.Replace("\\", "");
|
||||||
|
if (html.Contains("亲,小二正忙,滑动一下马上回来") || html.Contains("操作超时") || html == @"{""success"": false}")
|
||||||
|
{
|
||||||
|
if (i == 3)
|
||||||
|
{
|
||||||
|
NextTime = DateTime.Now.AddMinutes(2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Thread.Sleep(500);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _obj = HttpExtend.JsonToDictionary(html);//转成字典
|
||||||
|
if (_obj != null)
|
||||||
|
{
|
||||||
|
_obj = _obj["result"] as Dictionary<string, object>;
|
||||||
|
_obj.ConvertToObj(c);
|
||||||
|
if (c.retStatus == 1) continue;
|
||||||
|
_obj = _obj["item"] as Dictionary<string, object>;
|
||||||
|
if (_obj["clickUrl"] != null) _obj["clickUrl"] = "http:" + _obj["clickUrl"].ToString();
|
||||||
|
if (_obj["shareUrl"] != null) _obj["shareUrl"] = "http:" + _obj["shareUrl"].ToString();
|
||||||
|
_obj.ConvertToObj(c);
|
||||||
|
|
||||||
|
if (c.retStatus == 2 || c.retStatus == 0 || c.retStatus == 4) return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Client.SigleClient.Event.OnLog($@"检查淘宝优惠券异常", Exception: ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class TaobaoIteminfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券剩余量
|
||||||
|
/// </summary>
|
||||||
|
public int coupon_remain_count { get; set; }
|
||||||
|
//coupon_remain_count Number 6859 优惠券剩余量
|
||||||
|
|
||||||
|
//优惠券总量
|
||||||
|
public int coupon_total_count { get; set; }
|
||||||
|
//coupon_total_count Number 8000 优惠券总量
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券面额
|
||||||
|
/// </summary>
|
||||||
|
public string coupon_info { get; set; }
|
||||||
|
//coupon_info String 满16元减10元 优惠券面额
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券结束时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime coupon_end_time { get; set; }
|
||||||
|
// coupon_end_time String 2016-09-26 优惠券结束时间
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券开始时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime coupon_start_time { get; set; }
|
||||||
|
// coupon_start_time String 2016-09-25 优惠券开始时间
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券(商品优惠券推广链接中的券)类型,1 公开券,2 私有券,3 妈妈券
|
||||||
|
/// </summary>
|
||||||
|
public int coupon_type { get; set; }
|
||||||
|
//coupon_type Number 1 优惠券(商品优惠券推广链接中的券)类型,1 公开券,2 私有券,3 妈妈券
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品优惠券推广链接
|
||||||
|
/// </summary>
|
||||||
|
public string coupon_click_url { get; set; }
|
||||||
|
//coupon_click_url String https://uland.taobao.com/coupon/edetail?e=nqUNB1NOF3Bt3vqbdXnGloankzPYmeEFkgNrw6YHQf9pZTj41Orn8MwBAs06HAOzqQomYNedOiHDYPmqkFXqLR0HgBdG%2FDDL%2F1M%2FBw7Sf%2FesGXLf%2BqX4cbeC%2F2cR0p0NlWH0%2BknxpnCJJP%2FQkZSsyo1HvKjXo4uz&pid=mm_26381042_12970066_52864659&af=1 商品优惠券推广链接
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 后台一级类目
|
||||||
|
/// </summary>
|
||||||
|
public int category_id { get; set; }
|
||||||
|
//category_id Number 1 后台一级类目
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 展示常规佣金率
|
||||||
|
/// </summary>
|
||||||
|
public double max_commission_rate { get; set; }
|
||||||
|
//max_commission_rate String 20.3 当不入参special_id、relation_id、external_id时,展示常规佣金率(%)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品id
|
||||||
|
/// </summary>
|
||||||
|
public string item_id { get; set; }
|
||||||
|
//item_id Number 524136796550 商品id
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品地址
|
||||||
|
/// </summary>
|
||||||
|
public string item_url { get; set; }
|
||||||
|
//item_url String https://s.click.taobao.com/t?spm=a2e2e.10720394/c.90202110.1.4399704cUUhhH0&e=m%3D2%26s%3D0NJS731SUEdw4vFB6t2Z2ueEDrYVVa64LKpWJ%2Bin0XLjf2vlNIV67uIA4kDYDopEpOjgxi0uT208hw4H8GMUew7uoRPWrIBwR7CIpaNCoiKr9WTFywb%2BCtGNFs53xi4QGSKqJrqeJvt5ArodCWjzv9fsai3uVirbXH%2BQH9e66Y4%3D 商品淘客链接
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预售有礼-推广链接
|
||||||
|
/// </summary>
|
||||||
|
public string ysyl_click_url { get; set; }
|
||||||
|
//ysyl_click_url String https://uland.taobao.com/coupon/edetail?e=nqUNB1NOF3Bt3vqbdXnGloankzPYmeEFkgNrw6YHQf9pZTj41Orn8MwBAs06HAOzqQomYNedOiHDYPmqkFXqLR0HgBdG%2FDDL%2F1M%2FBw7Sf%2FesGXLf%2BqX4cbeC%2F2cR0p0NlWH0%2BknxpnCJJP%2FQkZSsyo1HvKjXo4uz&pid=mm_26381042_12970066_52864659&af=1 预售有礼-推广链接
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预售有礼-预估淘礼金(元)
|
||||||
|
/// </summary>
|
||||||
|
public string ysyl_tlj_face { get; set; }
|
||||||
|
//ysyl_tlj_face String 0.6 预售有礼-预估淘礼金(元)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预售有礼-淘礼金发放时间
|
||||||
|
/// </summary>
|
||||||
|
public string ysyl_tlj_send_time { get; set; }
|
||||||
|
//ysyl_tlj_send_time String 2019-11-10 21:59:59 预售有礼-淘礼金发放时间
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预售有礼-淘礼金使用开始时间
|
||||||
|
/// </summary>
|
||||||
|
public string ysyl_tlj_use_start_time { get; set; }
|
||||||
|
//ysyl_tlj_use_start_time String 2019-11-10 21:59:59 预售有礼-淘礼金使用开始时间
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预售有礼-佣金比例
|
||||||
|
/// </summary>
|
||||||
|
public string ysyl_commission_rate { get; set; }
|
||||||
|
//ysyl_commission_rate String 20.3 预售有礼-佣金比例(%)( 预售有礼活动享受的推广佣金比例,注:推广该活动有特殊分成规则,请详见:https://tbk.bbs.taobao.com/detail.html?appId=45301&postId=9334376 )
|
||||||
|
|
||||||
|
public string ysyl_tlj_use_end_time { get; set; }
|
||||||
|
//ysyl_tlj_use_end_time String 2019-11-10 21:59:59 预售有礼-淘礼金使用结束时间
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预估最低佣金率
|
||||||
|
/// </summary>
|
||||||
|
public double min_commission_rate { get; set; }
|
||||||
|
//min_commission_rate String 20.3 当入参special_id、relation_id、external_id时,该字段展示预估最低佣金率(%)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 比价场景专用
|
||||||
|
/// </summary>
|
||||||
|
public int reward_info { get; set; }
|
||||||
|
//reward_info Number 1 比价场景专用,当系统检测到入参消费者ID购买当前商品会获得《天天开彩蛋》玩法的彩蛋时,该字段显示1,否则为0
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单品券高效转链
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ItemId">需要转链的产品ID</param>
|
||||||
|
/// <param name="SpecialId">会员运营ID</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public TaobaoIteminfo ConvertItemid(string ItemId, long? SpecialId = null)
|
||||||
|
{
|
||||||
|
object transportData;
|
||||||
|
if (SpecialId != null)
|
||||||
|
{
|
||||||
|
transportData = new { adzone_id = this.Meadia.AdzoneId, site_id = this.Meadia.SiteId, item_id = ItemId, special_id = SpecialId };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transportData = new { adzone_id = this.Meadia.AdzoneId, site_id = this.Meadia.SiteId, item_id = ItemId };
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = GetJSON("taobao.tbk.privilege.get", transportData);
|
||||||
|
TaobaoIteminfo obj = new TaobaoIteminfo();
|
||||||
|
Utils.Util.CopyToObj(data,obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取会员绑定的specialId
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ExternalId">通常情况下为wxid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public long GetSpecialId(string ExternalId)
|
||||||
|
{
|
||||||
|
var data = GetJSON("taobao.tbk.sc.publisher.info.get", new { info_type = 2, relation_app = "common", external_id = ExternalId, external_type = 1 });
|
||||||
|
if (data["inviter_list"]["map_data"].Count() > 0)
|
||||||
|
{
|
||||||
|
return (long)data["inviter_list"]["map_data"].First["special_id"];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取私域标记链接
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="WxId"></param>
|
||||||
|
/// <param name="RedirectUrl"></param>
|
||||||
|
/// <param name="ExternalType"></param>
|
||||||
|
/// <param name="UcRowdId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetRelationLink(string WxId, string RedirectUrl, int ExternalType = 1, int? UcRowdId = null)
|
||||||
|
{
|
||||||
|
object transportData;
|
||||||
|
if (UcRowdId != null)
|
||||||
|
{
|
||||||
|
transportData = new { external_id = WxId, external_type = ExternalType, op_type = 2, redirect_url = RedirectUrl, ucrowd_id = UcRowdId };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transportData = new { external_id = WxId, external_type = ExternalType, op_type = 2, redirect_url = RedirectUrl };
|
||||||
|
}
|
||||||
|
var data = GetJSON("taobao.tbk.sc.relation.record", transportData);
|
||||||
|
return data["url"].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using ProtoBuf;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Caches
|
||||||
|
{
|
||||||
|
[ProtoContract]
|
||||||
|
public class DouyinUpdateCache
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最后更新时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public DateTime UpdateTime1 { get; set; } = DateTime.Now.AddDays(-30);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
using ProtoBuf;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Caches
|
||||||
|
{
|
||||||
|
|
||||||
|
[ProtoContract]
|
||||||
|
public class JDUpdateOrderItemCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public string Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 上次时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
|
public DateTime LastDateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
using ProtoBuf;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Caches
|
||||||
|
{
|
||||||
|
[ProtoContract]
|
||||||
|
public class MtUpdateOrderItemCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public string Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 上次时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
|
public DateTime LastDateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProtoBuf;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Caches
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 拼多多
|
||||||
|
/// </summary>
|
||||||
|
[ProtoContract]
|
||||||
|
public class PDDUpdateOrderItemCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public string Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 上次时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
|
public DateTime LastDateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
using ProtoBuf;
|
||||||
|
using Server.Configs;
|
||||||
|
using Server.MyClass.Class;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Caches
|
||||||
|
{
|
||||||
|
[ProtoContract]
|
||||||
|
public class RuntimeCache
|
||||||
|
{
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public List<TaobaoUpdateCacheInfo> TbDatas { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 抖音同步相关信息
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
|
public List<DouyinUpdateCache> DyDatas { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[global::ProtoBuf.ProtoMember(3)]
|
||||||
|
public List<MtUpdateOrderItemCache> MtDatas { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 京东
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(4)]
|
||||||
|
public List<JDUpdateOrderItemCache> JDDatas { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 拼多多
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(5)]
|
||||||
|
public List<PDDUpdateOrderItemCache> PDDDatas { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 唯品会
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(6)]
|
||||||
|
public List<WeiPinHuiUpdateOrderItemCache> WeiPinHuiDatas { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 苏宁
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(7)]
|
||||||
|
public List<SuningUpdateOrderItemCache> SuningDatas { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 公共数据缓存配置
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(8)]
|
||||||
|
public Dictionary<string, string> PublicCacheDic { get; set; }
|
||||||
|
|
||||||
|
[global::ProtoBuf.ProtoMember(9)]
|
||||||
|
public ConcurrentDictionary<string, DeviceSession> DeviceSessions { get; set; }
|
||||||
|
public ConcurrentDictionary<int, UserSession> UserSessions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用来缓存存储公共配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool SetPublicValue<T>(string key, T value)
|
||||||
|
{
|
||||||
|
PublicCacheDic[key] = Newtonsoft.Json.JsonConvert.SerializeObject(value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取 用来缓存存储公共配置
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T GetPublicValue<T>(string key, Func<T> def = null)
|
||||||
|
{
|
||||||
|
if (PublicCacheDic.ContainsKey(key))
|
||||||
|
{
|
||||||
|
var val = PublicCacheDic[key];
|
||||||
|
var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(val);
|
||||||
|
return (T)Convert.ChangeType(obj, typeof(T));
|
||||||
|
}
|
||||||
|
if (def == null)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
return def();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public RuntimeCache()
|
||||||
|
{
|
||||||
|
PublicCacheDic = new Dictionary<string, string>();
|
||||||
|
TbDatas = new List<TaobaoUpdateCacheInfo>();
|
||||||
|
DyDatas = new List<DouyinUpdateCache>();
|
||||||
|
MtDatas = new List<MtUpdateOrderItemCache>();
|
||||||
|
JDDatas = new List<JDUpdateOrderItemCache>();
|
||||||
|
PDDDatas = new List<PDDUpdateOrderItemCache>();
|
||||||
|
WeiPinHuiDatas = new List<WeiPinHuiUpdateOrderItemCache>();
|
||||||
|
SuningDatas = new List<SuningUpdateOrderItemCache>();
|
||||||
|
DeviceSessions = new ConcurrentDictionary<string, DeviceSession>();
|
||||||
|
UserSessions = new ConcurrentDictionary<int, UserSession>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProtoBuf;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Caches
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 苏宁
|
||||||
|
/// </summary>
|
||||||
|
[ProtoContract]
|
||||||
|
public class SuningUpdateOrderItemCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public string Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 上次时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
|
public DateTime LastDateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
using ProtoBuf;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.Configs
|
||||||
|
{
|
||||||
|
[ProtoContract]
|
||||||
|
public class TaobaoUpdateCacheInfo
|
||||||
|
{
|
||||||
|
public TaobaoUpdateCacheInfo()
|
||||||
|
{
|
||||||
|
this.UpdateTime1 = DateTime.Now.AddMonths(-3);
|
||||||
|
this.UpdateTime3 = DateTime.Now.AddMonths(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 常规订单更新时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public DateTime UpdateTime1 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 渠道订单更新时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
|
public DateTime UpdateTime2 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 会员运营ID更新时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(3)]
|
||||||
|
public DateTime UpdateTime3 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 渠道退款时间更新时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(4)]
|
||||||
|
public DateTime UpdateTime4 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 会员运营更新时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(5)]
|
||||||
|
public DateTime UpdateTime5 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新处罚订单时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(6)]
|
||||||
|
public DateTime UpdateTime6 { get; set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最后一次更新时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(7)]
|
||||||
|
public DateTime UpdateTimer7 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[global::ProtoBuf.ProtoMember(8)]
|
||||||
|
public int LianmengId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProtoBuf;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Caches
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 唯品会
|
||||||
|
/// </summary>
|
||||||
|
[ProtoContract]
|
||||||
|
public class WeiPinHuiUpdateOrderItemCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public string Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 上次时间
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
|
public DateTime LastDateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
using Common.Models.PubClass;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Class
|
||||||
|
{
|
||||||
|
[ProtoBuf.ProtoContract]
|
||||||
|
public class DeviceSession
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否正在读取消息
|
||||||
|
/// </summary>
|
||||||
|
[ProtoBuf.ProtoMember(1)]
|
||||||
|
public bool IsReading { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取消息时间
|
||||||
|
/// </summary>
|
||||||
|
[ProtoBuf.ProtoMember(2)]
|
||||||
|
public DateTime ReadTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录的机器人
|
||||||
|
/// </summary>
|
||||||
|
[ProtoBuf.ProtoMember(3)]
|
||||||
|
public int RobotId { get; set; }
|
||||||
|
|
||||||
|
public DeviceSession()
|
||||||
|
{
|
||||||
|
Messages = new Queue<DeviceMessage>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发送的消息列表
|
||||||
|
/// </summary>
|
||||||
|
public Queue<DeviceMessage> Messages { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
using ProtoBuf;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 记录初始化表数据
|
||||||
|
/// </summary>
|
||||||
|
[ProtoContract]
|
||||||
|
public class InitDbData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 上次计算的MD5
|
||||||
|
/// </summary>
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public string LastMd5 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 压缩包信息
|
||||||
|
/// </summary>
|
||||||
|
public class PackInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 类型
|
||||||
|
/// </summary>
|
||||||
|
public string TypeName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime AddDateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using ProtoBuf;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Class
|
||||||
|
{
|
||||||
|
[ProtoContract]
|
||||||
|
public class UserSession
|
||||||
|
{
|
||||||
|
public UserSession(Staff User)
|
||||||
|
{
|
||||||
|
this.Uid = User.Id;
|
||||||
|
this.Token = Guid.NewGuid().ToString();
|
||||||
|
this.LoginTime = DateTime.Now;
|
||||||
|
this.RoleId = User.RoleId;
|
||||||
|
this.UserName = User.Username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserSession()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RoleId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是超级管理员
|
||||||
|
/// </summary>
|
||||||
|
public bool IsCreator { get; set; }
|
||||||
|
|
||||||
|
public int Uid { get; set; }
|
||||||
|
|
||||||
|
public string UserName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime LoginTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 请求时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime RequestTime { get; set; }
|
||||||
|
|
||||||
|
public string Token { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class BaseConfigShow
|
||||||
|
{
|
||||||
|
public int BaseConfigId { get; set; }
|
||||||
|
|
||||||
|
public string BaseConfigName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class CashListShow:TixianHist
|
||||||
|
{
|
||||||
|
public string NickName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string RobotName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
internal class CommonMediaShow
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class DyMediaShow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int LianmengId { get; set; }
|
||||||
|
public string LianmengNick { get; set; }
|
||||||
|
|
||||||
|
public string Remark { get; set; }
|
||||||
|
public string MediaName { get; set; }
|
||||||
|
public DouyinMediaType MediaType { get; set; }
|
||||||
|
public string AdzoneName { get; set; }
|
||||||
|
public string Pid { get; set; }
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class DyOrderShow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品编号
|
||||||
|
/// </summary>
|
||||||
|
public string Itemid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品标题
|
||||||
|
/// </summary>
|
||||||
|
public string ItemTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户头像地址
|
||||||
|
/// </summary>
|
||||||
|
public string UserHeadurl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户昵称
|
||||||
|
/// </summary>
|
||||||
|
public string UserNickname { get; set; }
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单状态
|
||||||
|
/// </summary>
|
||||||
|
public SystemOrderStatus OrderStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联盟订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string TkOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 京东订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string UsOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品预估佣金
|
||||||
|
/// </summary>
|
||||||
|
public double Commission { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买数量
|
||||||
|
/// </summary>
|
||||||
|
public int ItemCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返利金额
|
||||||
|
/// </summary>
|
||||||
|
public double RebatePoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推荐人提成
|
||||||
|
/// </summary>
|
||||||
|
public double RecommendPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 合伙人分红
|
||||||
|
/// </summary>
|
||||||
|
public double PartnerPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 毛利率
|
||||||
|
/// </summary>
|
||||||
|
public double GrossProfit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付款金额
|
||||||
|
/// </summary>
|
||||||
|
public double PayPrice { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class FansRecordShow:FansRecord
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 机器人名称
|
||||||
|
/// </summary>
|
||||||
|
public string RobotName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class IntegralShow:PointHist
|
||||||
|
{
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
public string NickName { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
internal class JdOrderShow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品编号
|
||||||
|
/// </summary>
|
||||||
|
public string Itemid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品标题
|
||||||
|
/// </summary>
|
||||||
|
public string ItemTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户头像地址
|
||||||
|
/// </summary>
|
||||||
|
public string UserHeadurl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户昵称
|
||||||
|
/// </summary>
|
||||||
|
public string UserNickname { get; set; }
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单状态
|
||||||
|
/// </summary>
|
||||||
|
public SystemOrderStatus OrderStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联盟订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string TkOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 京东订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string UsOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品预估佣金
|
||||||
|
/// </summary>
|
||||||
|
public double Commission { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买数量
|
||||||
|
/// </summary>
|
||||||
|
public int ItemCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返利金额
|
||||||
|
/// </summary>
|
||||||
|
public double RebatePoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推荐人提成
|
||||||
|
/// </summary>
|
||||||
|
public double RecommendPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 合伙人分红
|
||||||
|
/// </summary>
|
||||||
|
public double PartnerPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 毛利率
|
||||||
|
/// </summary>
|
||||||
|
public double GrossProfit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付款金额
|
||||||
|
/// </summary>
|
||||||
|
public double PayPrice { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class KeywordShow: Keyword
|
||||||
|
{
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public enum LoginQRCodeStatus :int
|
||||||
|
{
|
||||||
|
正在获取二维码 = 1,
|
||||||
|
获取二维码失败 = 2,
|
||||||
|
二维码已过期 = 3,
|
||||||
|
等待扫码 = 4,
|
||||||
|
等待确认登录 = 5,
|
||||||
|
正在授权 = 6,
|
||||||
|
登录并授权成功 = 7,
|
||||||
|
|
||||||
|
登录失败 = 97,
|
||||||
|
操作超时 = 99
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 返回给前端的美团推广位信息
|
||||||
|
/// </summary>
|
||||||
|
public class MTMediaShow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 淘宝联盟的ID
|
||||||
|
/// </summary>
|
||||||
|
public int LianmengId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// PID
|
||||||
|
/// </summary>
|
||||||
|
public string AdzoneId { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 推广位名称
|
||||||
|
/// </summary>
|
||||||
|
public string AdzoneName { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string Remark { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 媒体类型
|
||||||
|
/// </summary>
|
||||||
|
public MTMediaType MediaType { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 媒体ID
|
||||||
|
/// </summary>
|
||||||
|
public string MediaPId { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 媒体名称
|
||||||
|
/// </summary>
|
||||||
|
public string MediaName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class NameShow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class PayRecordShow:PayRecord
|
||||||
|
{
|
||||||
|
public string NickName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string RobotName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class PddOrderShow
|
||||||
|
{ /// <summary>
|
||||||
|
/// 商品编号
|
||||||
|
/// </summary>
|
||||||
|
public string Itemid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品标题
|
||||||
|
/// </summary>
|
||||||
|
public string ItemTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户头像地址
|
||||||
|
/// </summary>
|
||||||
|
public string UserHeadurl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户昵称
|
||||||
|
/// </summary>
|
||||||
|
public string UserNickname { get; set; }
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单状态
|
||||||
|
/// </summary>
|
||||||
|
public SystemOrderStatus OrderStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联盟订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string TkOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拼多多订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string UsOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品预估佣金
|
||||||
|
/// </summary>
|
||||||
|
public double Commission { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买数量
|
||||||
|
/// </summary>
|
||||||
|
public int ItemCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返利金额
|
||||||
|
/// </summary>
|
||||||
|
public double RebatePoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推荐人提成
|
||||||
|
/// </summary>
|
||||||
|
public double RecommendPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 合伙人分红
|
||||||
|
/// </summary>
|
||||||
|
public double PartnerPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 毛利率
|
||||||
|
/// </summary>
|
||||||
|
public double GrossProfit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付款金额
|
||||||
|
/// </summary>
|
||||||
|
public double PayPrice { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class PyqPublishShow:PyqPublish
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn()]
|
||||||
|
public string RobotNickname { get; set; }
|
||||||
|
|
||||||
|
public string RobotUserName { get; set; }
|
||||||
|
|
||||||
|
public UserType UserType { get; set; }
|
||||||
|
|
||||||
|
public List<string> Imgs { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class QunfaShow:Qunfa
|
||||||
|
{
|
||||||
|
public string RobotNick { get; set; }
|
||||||
|
|
||||||
|
public string RobotUserName { get; set; }
|
||||||
|
|
||||||
|
public UserType UserType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class RebateConfigShow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class RebateIdsShow
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class ReminderShow:Reminder
|
||||||
|
{
|
||||||
|
public string Nickname { get; set; }
|
||||||
|
public string Username { get; set; }
|
||||||
|
public string RobotName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class ReplyShow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 字段名
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述信息
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内容
|
||||||
|
/// </summary>
|
||||||
|
public string Content { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支持的变量
|
||||||
|
/// </summary>
|
||||||
|
public string[] SpecialVariables { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class ReplyShowClass
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public List<ReplyShowClass> Menus { get; set; }
|
||||||
|
public string[] PrivateVariables { get; set; }
|
||||||
|
public string Content { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 机器人ID和name显示类
|
||||||
|
/// </summary>
|
||||||
|
public class RobotInfo
|
||||||
|
{
|
||||||
|
public int RobotId { get; set; }
|
||||||
|
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
|
||||||
|
public UserType RobotType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class RobotSettingShow:Robot
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 基础设置名称
|
||||||
|
/// </summary>
|
||||||
|
public string ConfibBaseName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返利设置名称
|
||||||
|
/// </summary>
|
||||||
|
public string ConfigRebateName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 回复提示名称
|
||||||
|
/// </summary>
|
||||||
|
public string ConfigReplyName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public int TbLianmengId1 { get; set; }
|
||||||
|
public string TbLianmengNick1 { get; set; }
|
||||||
|
public string TbMediaNick1 { get; set; }
|
||||||
|
public int TbLianmengId2 { get; set; }
|
||||||
|
public string TbLianmengNick2 { get; set; }
|
||||||
|
public string TbMediaNick2 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public int DyLianmengId1 { get; set; }
|
||||||
|
public string DyLianmengNick1 { get; set; }
|
||||||
|
public int DyLianmengId2 { get; set; }
|
||||||
|
public string DyLianmengNick2 { get; set; }
|
||||||
|
public string DyMediaNick1 { get; set; }
|
||||||
|
public string DyMediaNick2 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public string SnLianmengNick1 { get; set; }
|
||||||
|
|
||||||
|
public string SnLianmengNick2 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public int JdLianmengId1 { get; set; }
|
||||||
|
public string JdLianmengNick1 { get; set; }
|
||||||
|
public int JdLianmengId2 { get; set; }
|
||||||
|
public string JdLianmengNick2 { get; set; }
|
||||||
|
public string JdMediaNick1 { get; set; }
|
||||||
|
public string JdMediaNick2 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public int MtLianmengId1 { get; set; }
|
||||||
|
public string MtLianmengNick1 { get; set; }
|
||||||
|
public int MtLianmengId2 { get; set; }
|
||||||
|
public string MtLianmengNick2 { get; set; }
|
||||||
|
public string MtMediaNick1 { get; set; }
|
||||||
|
public string MtMediaNick2 { get; set; }
|
||||||
|
|
||||||
|
public int WphLianmengId1 { get; set; }
|
||||||
|
public string WphLianmengNick1 { get; set; }
|
||||||
|
public int WphLianmengId2 { get; set; }
|
||||||
|
public string WphLianmengNick2 { get; set; }
|
||||||
|
public string WphMediaNick1 { get; set; }
|
||||||
|
public string WphMediaNick2 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public int PddLianmengId1 { get; set; }
|
||||||
|
public string PddLianmengNick1 { get; set; }
|
||||||
|
public int PddLianmengId2 { get; set; }
|
||||||
|
public string PddLianmengNick2 { get; set; }
|
||||||
|
public string PddMediaNick1 { get; set; }
|
||||||
|
public string PddMediaNick2 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class RunLogShow:Log
|
||||||
|
{
|
||||||
|
public string RobotName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class ShopInfo
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
internal class SnOrderShow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品编号
|
||||||
|
/// </summary>
|
||||||
|
public string Itemid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品标题
|
||||||
|
/// </summary>
|
||||||
|
public string ItemTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户头像地址
|
||||||
|
/// </summary>
|
||||||
|
public string UserHeadurl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户昵称
|
||||||
|
/// </summary>
|
||||||
|
public string UserNickname { get; set; }
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单状态
|
||||||
|
/// </summary>
|
||||||
|
public SystemOrderStatus OrderStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联盟订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string TkOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string UsOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品预估佣金
|
||||||
|
/// </summary>
|
||||||
|
public double Commission { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买数量
|
||||||
|
/// </summary>
|
||||||
|
public int ItemCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返利金额
|
||||||
|
/// </summary>
|
||||||
|
public double RebatePoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推荐人提成
|
||||||
|
/// </summary>
|
||||||
|
public double RecommendPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 合伙人分红
|
||||||
|
/// </summary>
|
||||||
|
public double PartnerPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 毛利率
|
||||||
|
/// </summary>
|
||||||
|
public double GrossProfit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付款金额
|
||||||
|
/// </summary>
|
||||||
|
public double PayPrice { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class StaffShow: Staff
|
||||||
|
{
|
||||||
|
public string RoleName { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class TboderShow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品编号
|
||||||
|
/// </summary>
|
||||||
|
public string Itemid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品标题
|
||||||
|
/// </summary>
|
||||||
|
public string ItemTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户头像地址
|
||||||
|
/// </summary>
|
||||||
|
public string UserHeadurl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户昵称
|
||||||
|
/// </summary>
|
||||||
|
public string UserNickname { get; set; }
|
||||||
|
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单状态
|
||||||
|
/// </summary>
|
||||||
|
public SystemOrderStatus OrderStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联盟订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string TkOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 淘宝订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string UsOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品预估佣金
|
||||||
|
/// </summary>
|
||||||
|
public double Commission { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买数量
|
||||||
|
/// </summary>
|
||||||
|
public int ItemCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返利金额
|
||||||
|
/// </summary>
|
||||||
|
public double RebatePoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推荐人提成
|
||||||
|
/// </summary>
|
||||||
|
public double RecommendPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 合伙人分红
|
||||||
|
/// </summary>
|
||||||
|
public double PartnerPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 毛利率
|
||||||
|
/// </summary>
|
||||||
|
public double GrossProfit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付款金额
|
||||||
|
/// </summary>
|
||||||
|
public double PayPrice { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户组显示类
|
||||||
|
/// </summary>
|
||||||
|
public class UserGroupInfo
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class UserGroupView: UserGroup
|
||||||
|
{
|
||||||
|
public string ConfigName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
using Common.Models.SubCountTables;
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
public class UserShow : UserData
|
||||||
|
{
|
||||||
|
public string Nickname { get; set; }
|
||||||
|
public string Username { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 推荐人昵称
|
||||||
|
/// </summary>
|
||||||
|
public string InviterNickname { get; set; } = string.Empty;
|
||||||
|
public string InviterUsername { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 邀请人
|
||||||
|
/// </summary>
|
||||||
|
public int InviterId { get; set; }
|
||||||
|
public string InviterHeadurl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 机器人名称
|
||||||
|
/// </summary>
|
||||||
|
public string RobotName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string GroupName { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 头像
|
||||||
|
/// </summary>
|
||||||
|
public string Headurl { get; set; }
|
||||||
|
public UserBlack BlackInfo { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
using Common.Models.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views
|
||||||
|
{
|
||||||
|
internal class WphOrderShow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品编号
|
||||||
|
/// </summary>
|
||||||
|
public string Itemid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品标题
|
||||||
|
/// </summary>
|
||||||
|
public string ItemTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户头像地址
|
||||||
|
/// </summary>
|
||||||
|
public string UserHeadurl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户昵称
|
||||||
|
/// </summary>
|
||||||
|
public string UserNickname { get; set; }
|
||||||
|
public string RobotName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单状态
|
||||||
|
/// </summary>
|
||||||
|
public SystemOrderStatus OrderStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联盟订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string TkOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单编号
|
||||||
|
/// </summary>
|
||||||
|
public string UsOrderNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品预估佣金
|
||||||
|
/// </summary>
|
||||||
|
public double Commission { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买数量
|
||||||
|
/// </summary>
|
||||||
|
public int ItemCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返利金额
|
||||||
|
/// </summary>
|
||||||
|
public double RebatePoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推荐人提成
|
||||||
|
/// </summary>
|
||||||
|
public double RecommendPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 合伙人分红
|
||||||
|
/// </summary>
|
||||||
|
public double PartnerPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 毛利率
|
||||||
|
/// </summary>
|
||||||
|
public double GrossProfit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付款金额
|
||||||
|
/// </summary>
|
||||||
|
public double PayPrice { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views.medias
|
||||||
|
{
|
||||||
|
internal class DyMediaShow:DyMedia
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前正在使用此推广位的机器人数量
|
||||||
|
/// </summary>
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views.medias
|
||||||
|
{
|
||||||
|
internal class JdMediaShow:JdMedia
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前正在使用此推广位的机器人数量
|
||||||
|
/// </summary>
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views.medias
|
||||||
|
{
|
||||||
|
internal class MtMediaShow:MtMedia
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前正在使用此推广位的机器人数量
|
||||||
|
/// </summary>
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views.medias
|
||||||
|
{
|
||||||
|
internal class PddMediaShow:MtMedia
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前正在使用此推广位的机器人数量
|
||||||
|
/// </summary>
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views.medias
|
||||||
|
{
|
||||||
|
internal class SnMediaShow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前正在使用此推广位的机器人数量
|
||||||
|
/// </summary>
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views.medias
|
||||||
|
{
|
||||||
|
public class TbMediaShow : TbMedia
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前正在使用此推广位的机器人数量
|
||||||
|
/// </summary>
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前推广位归属的联盟名称
|
||||||
|
/// </summary>
|
||||||
|
public string LmName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联盟账号
|
||||||
|
/// </summary>
|
||||||
|
public string LmAcc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否支持淘礼金
|
||||||
|
/// </summary>
|
||||||
|
public bool IsTlj { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Common.Models.UnqTables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Server.MyClass.Views.medias
|
||||||
|
{
|
||||||
|
internal class VipMediaShow:WphMedia
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前正在使用此推广位的机器人数量
|
||||||
|
/// </summary>
|
||||||
|
public int UseCnt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,236 @@
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.Owin;
|
||||||
|
using Microsoft.Owin.Cors;
|
||||||
|
using Microsoft.Owin.FileSystems;
|
||||||
|
using Microsoft.Owin.Hosting;
|
||||||
|
using Microsoft.Owin.StaticFiles;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Owin;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Http;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
internal class OwinServer
|
||||||
|
{
|
||||||
|
|
||||||
|
public static string RootDir = CsharpHttpHelper.HttpExtend.MapPath("网站");// Directory.GetCurrentDirectory() + "\\网站";
|
||||||
|
/// <summary>
|
||||||
|
/// 查找本地数据,无数据 返回index
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="relPath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetFilePath(string relPath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(relPath) || relPath == "/")
|
||||||
|
{
|
||||||
|
relPath = "index.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
return Path.Combine(
|
||||||
|
AppDomain.CurrentDomain.BaseDirectory
|
||||||
|
, RootDir
|
||||||
|
, relPath.TrimStart('/').Replace('/', '\\'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置返回contenttype 并返回数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task SetResponse(IOwinContext context, string path)
|
||||||
|
{
|
||||||
|
var perfix = Path.GetExtension(path);
|
||||||
|
switch (perfix)
|
||||||
|
{
|
||||||
|
case ".html":
|
||||||
|
context.Response.ContentType = "text/html; charset=utf-8";
|
||||||
|
break;
|
||||||
|
case ".js":
|
||||||
|
context.Response.ContentType = "application/x-javascript";
|
||||||
|
break;
|
||||||
|
case ".css":
|
||||||
|
context.Response.ContentType = "text/css";
|
||||||
|
break;
|
||||||
|
case ".jpg":
|
||||||
|
case ".jpeg":
|
||||||
|
context.Response.ContentType = "image/jpeg";
|
||||||
|
break;
|
||||||
|
case ".png":
|
||||||
|
context.Response.ContentType = "application/x-png";
|
||||||
|
break;
|
||||||
|
case ".mp4":
|
||||||
|
context.Response.ContentType = "video/mpeg4";
|
||||||
|
break;
|
||||||
|
case ".webp":
|
||||||
|
context.Response.ContentType = "image/webp";
|
||||||
|
break;
|
||||||
|
case ".gif":
|
||||||
|
context.Response.ContentType = "image/gif";
|
||||||
|
break;
|
||||||
|
case ".woff2":
|
||||||
|
context.Response.ContentType = "application/x-font-woff";
|
||||||
|
break;
|
||||||
|
case ".ico":
|
||||||
|
context.Response.ContentType = "image/x-icon";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return context.Response.WriteAsync(File.ReadAllText(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行API
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="next"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private Task TodoApi(IOwinContext context, Func<Task> next)
|
||||||
|
{
|
||||||
|
//var response = new WebResult();
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// var query = context.Request.Query.ToString();
|
||||||
|
|
||||||
|
// //Dictionary<string, string> Param = new Dictionary<string, string>();
|
||||||
|
// //var contentType = context.Request.ContentType;
|
||||||
|
// //if (context.Request.Method.ToLower() == "post")
|
||||||
|
// //{
|
||||||
|
// // if (contentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase))
|
||||||
|
// // {
|
||||||
|
// // string body = new StreamReader(context.Request.Body, Encoding.UTF8).ReadToEnd();
|
||||||
|
// // var postdata =new NameValueCollection(StringComparer.OrdinalIgnoreCase);
|
||||||
|
// // ///Util.GetQueryString(body, Encoding.UTF8);
|
||||||
|
// // if (postdata != null)
|
||||||
|
// // {
|
||||||
|
// // foreach (var item in postdata.AllKeys)
|
||||||
|
// // {
|
||||||
|
// // Param[item] = HttpUtility.UrlEncode(postdata[item]);
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
|
||||||
|
// //if (context.Request.Query != null && context.Request.Query.Count() > 0)
|
||||||
|
// //{
|
||||||
|
// // foreach (var item in context.Request.Query)
|
||||||
|
// // {
|
||||||
|
// // if (item.Value != null && item.Value.Length > 0) Param[item.Key] = HttpUtility.UrlDecode(item.Value[0]);
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
|
||||||
|
// //if (EventClient.StopParsing) return next();
|
||||||
|
// //var plugins = PluginClient.Plugins.ToArray();
|
||||||
|
// //var events = new WebRequestEvents(context, Param, response);
|
||||||
|
// ////正常事件解析
|
||||||
|
// //foreach (var plugin in plugins)
|
||||||
|
// //{
|
||||||
|
// // if (!plugin.IsRun) continue;//未运行
|
||||||
|
// // if (events.Cancel) break;//已取消传递
|
||||||
|
// // plugin.SDK.OnEvent(context, events);
|
||||||
|
// //}
|
||||||
|
//}
|
||||||
|
//catch (Exception ex)
|
||||||
|
//{
|
||||||
|
// response.code = -1;
|
||||||
|
// response.errMsg = ex.Message;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (string.IsNullOrEmpty(response.))
|
||||||
|
//{
|
||||||
|
// response.ok = false;
|
||||||
|
// response.errMsg = $"请求成功,但未响应结果!{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}";
|
||||||
|
//}
|
||||||
|
|
||||||
|
//var msg = JsonConvert.SerializeObject(response);
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
return context.Response.WriteAsync("无响应结果");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 挂载数据 分流静态文件及接口请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="next"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task RequestHandler(IOwinContext context, Func<Task> next)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var path = GetFilePath(context.Request.Path.Value);
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
await SetResponse(context, path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await TodoApi(context, next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
await next();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Configuration(Owin.IAppBuilder appBuilder)
|
||||||
|
{
|
||||||
|
appBuilder.UseCors(CorsOptions.AllowAll);
|
||||||
|
|
||||||
|
var config = new HttpConfiguration();
|
||||||
|
config.MapHttpAttributeRoutes();
|
||||||
|
|
||||||
|
// config.Routes.MapHttpRoute(
|
||||||
|
// name: "DefaultApi",
|
||||||
|
// routeTemplate: "api/{controller}/{id}"
|
||||||
|
//);
|
||||||
|
|
||||||
|
config.Routes.MapHttpRoute(
|
||||||
|
name: "Default",
|
||||||
|
|
||||||
|
routeTemplate: "{controller}/{action}/{id}",
|
||||||
|
defaults: new { controller = "abbb", action = "Index", id = UrlParameter.Optional }
|
||||||
|
);
|
||||||
|
|
||||||
|
///@".\wwwroot"
|
||||||
|
var physicalFileSystem = new PhysicalFileSystem(RootDir);
|
||||||
|
var options = new FileServerOptions
|
||||||
|
{
|
||||||
|
EnableDefaultFiles = true,
|
||||||
|
FileSystem = physicalFileSystem
|
||||||
|
};
|
||||||
|
|
||||||
|
options.StaticFileOptions.FileSystem = physicalFileSystem;
|
||||||
|
options.StaticFileOptions.ServeUnknownFileTypes = true;
|
||||||
|
options.DefaultFilesOptions.DefaultFileNames = new[] { "Index.html" };
|
||||||
|
appBuilder.UseFileServer(options);
|
||||||
|
appBuilder.UseWebApi(config);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapRazorPages();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
using Common.Models.JsonModels;
|
||||||
|
using Common.Models.SubTables;
|
||||||
|
using Common.Requests.Lianmengs;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Server.Configs;
|
||||||
|
using Server.Winforms;
|
||||||
|
using Server.Winforms.LoginForms;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 应用程序的主入口点。
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Client.SingleClient.Config.MysqlHost))
|
||||||
|
{
|
||||||
|
if (new InitMysqlForm(Client.SingleClient).ShowDialog() != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//线程池
|
||||||
|
ThreadPool.SetMinThreads(10, 10);
|
||||||
|
ThreadPool.SetMaxThreads(150, 150);
|
||||||
|
//显示启动窗口
|
||||||
|
var startForm = new StartForm();
|
||||||
|
//Application.Run(new StartForm());
|
||||||
|
var th = new Thread(() =>
|
||||||
|
{
|
||||||
|
var mainForm = new MainForm();
|
||||||
|
mainForm.InitCompleteAction = () =>
|
||||||
|
{
|
||||||
|
startForm?.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
startForm.DialogResult = DialogResult.OK;
|
||||||
|
startForm.Close();
|
||||||
|
startForm = null;
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
mainForm.Show();
|
||||||
|
mainForm.Activate();
|
||||||
|
Application.Run(mainForm);
|
||||||
|
//强制退出程序,防止意外驻留进程
|
||||||
|
Environment.Exit(0);
|
||||||
|
});
|
||||||
|
th.SetApartmentState(ApartmentState.STA);
|
||||||
|
th.Start();
|
||||||
|
if (startForm.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
Application.Run();
|
||||||
|
}
|
||||||
|
//强制退出程序,防止意外驻留进程
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Test()
|
||||||
|
{
|
||||||
|
var json = @"{'data':{'data':{'cursor':'4737996432465788974','orders':[{'ads_estimated_commission':'100','ads_promotion_rate':'10','ads_real_commission':'100','ads_split_rate':'0','app':'抖音','author_account':'我的昵称','author_buyin_id':'123467','author_openid':'f190e172-5fd8-4b7b-babb-f32323e60f7b','author_short_id':'kodofo','buyer_openid':'f190e172-5fd8-4b7b-babb-f32323e60f7b','commission_rate':'2000','estimated_commission':'165','estimated_tech_service_fee':'12','estimated_total_commission':'2','flow_point':'PAY_SUCC','item_num':'2','media_type':'shop_list','order_id':'4737996432465788974','pay_goods_amount':'1100','pay_success_time':'2006-01-02 15:04:05','pick_source_client_key':'jifji32rnu3jit43','pid_info':{'external_info':'1222_2333','media_type_name':'Live','pid':'dy_1234_33_455'},'product_id':'3450632721376902816','product_img':'https://tosv.boe.byted.org/obj/temai/7e92a281163e33cedef99d8735d1e90bwww828-708','product_name':'测试商品','real_commission':'165','refund_time':'2006-01-02 15:04:05','settle_time':'2006-01-02 15:04:05','settled_goods_amount':'0','settled_tech_service_fee':'12','shop_estimated_commission':'12','shop_id':'1234','shop_name':'我的店铺','shop_real_commission':'12','total_pay_amount':'2100','update_time':'2006-01-02 15:04:05'}]}},'err_no':0,'message':'success','code':10000,'msg':'success','sub_code':'','sub_msg':''}";
|
||||||
|
var rest = JObject.Parse(json)["data"]["data"]["orders"];
|
||||||
|
foreach (var item in rest)
|
||||||
|
{
|
||||||
|
var order = new DyOrder();
|
||||||
|
Common.Utils.Util.CopyToObj(item, order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue