using Operater.DbModel;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using CommonUtil;
|
using Operater.DAL;
|
using AlibabaSDK.Domain;
|
using AlibabaSDK.Api;
|
using AlibabaSDK.Request;
|
using Operater.DTO.TopMessage;
|
|
namespace TradeInterflow.Handle
|
{
|
public class CommonHandle
|
{
|
public static TopTokenInfo _topToken = new TopTokenInfo();
|
|
public static AuthPointTaskSet _authPointTaskSet = new AuthPointTaskSet();
|
/// <summary>
|
/// 记录通知消息
|
/// </summary>
|
/// <param name="msg"></param>
|
public static void RecorderMessage(MessageNotify msg)
|
{
|
msg.Id = Guid.NewGuid().ToString();
|
msg.CreateTime = DateTime.Now;
|
msg.IsSolve = 0;
|
new MessageNotifyDAL().Insert(msg);
|
}
|
|
#region 获取1688token信息
|
public static string GetAliToken()
|
{
|
if (_topToken.IsNull() || _topToken.aliToken.IsNullOrEmpty() || _topToken.aliExpreTime < DateTime.Now)
|
{
|
var appSet = new AppsetDAL().ListGet(t => t.Id != null)[0];
|
_topToken.aliToken = appSet.AlibabaToken;
|
_topToken.aliExpreTime = DateTime.Now.AddHours(1);
|
return appSet.AlibabaToken;
|
}
|
return _topToken.aliToken;
|
}
|
#endregion
|
|
#region 获取有赞token信息
|
public static string GetYzToken()
|
{
|
if (_topToken.IsNull() || _topToken.yzToken.IsNullOrEmpty() || _topToken.yzExpreTime < DateTime.Now)
|
{
|
var appSet = new AppsetDAL().ListGet(t => t.Id != null)[0];
|
_topToken.yzToken = appSet.YzToken;
|
_topToken.yzExpreTime = DateTime.Now.AddHours(1);
|
return appSet.YzToken;
|
}
|
return _topToken.yzToken;
|
}
|
#endregion
|
|
public static TopTokenInfo GetSetInfo()
|
{
|
if (_topToken.IsNull() || _topToken.yzToken.IsNullOrEmpty() || _topToken.yzExpreTime > DateTime.Now)
|
{
|
var appSet = new AppsetDAL().ListGet(t => t.Id != null)[0];
|
_topToken.yzToken = appSet.YzToken;
|
_topToken.yzExpreTime = DateTime.Now.AddHours(1);
|
_topToken.aliToken = appSet.AlibabaToken;
|
_topToken.YzShopId = appSet.YzShopid;
|
}
|
return _topToken;
|
}
|
|
#region 接口获取1688订单详情
|
public static AlibabaTradeDetailDomain GetAliTradeDetail(string tid)
|
{
|
try
|
{
|
AlibabaTradeDeatilGetRequest request = new AlibabaTradeDeatilGetRequest()
|
{
|
orderId = tid,
|
webSite = "1688"
|
};
|
var response = AliabaClient.Execute(request, CommonHandle.GetAliToken());
|
if (response.IsNull() || !response.Success || response.result.IsNull())
|
{//接口请求失败
|
LogUtil.Info("接口获取1688订单详情error:" + (response.IsNull() ? "null" : response.ErrorMsg), "1688订单详情eror");
|
return null;
|
}
|
return response.result;
|
}
|
catch (Exception e)
|
{
|
LogUtil.Info("接口获取1688订单详情error:" + e.ToString(), "1688订单详情eror");
|
Console.WriteLine("接口获取1688订单详情error:" + e.ToString());
|
}
|
return null;
|
}
|
|
#endregion
|
|
|
#region 获取授权送积分设置
|
public static AuthPointTaskSet GetAuthPointSet()
|
{
|
if (_authPointTaskSet.IsSet == 0 || _authPointTaskSet.ExpressTime < DateTime.Now)
|
{//从数据库获取
|
var set = new PointTaskDAL().ListGet(t => t.TaskType == 0 && t.IsRun == 1 && t.IsDel == 0);
|
if (set.IsNull() || set.Count == 0)
|
{
|
_authPointTaskSet.ExpressTime = DateTime.Now.AddMinutes(10);
|
_authPointTaskSet.IsSet = -1;
|
return null;
|
}
|
_authPointTaskSet.ExpressTime = DateTime.Now.AddMinutes(10);
|
_authPointTaskSet.PointTaskSet = set[0];
|
_authPointTaskSet.IsSet = 1;
|
}
|
return _authPointTaskSet;
|
}
|
|
#endregion
|
|
public class TopTokenInfo
|
{
|
public string aliToken { get; set; }
|
|
public DateTime aliExpreTime { get; set; }
|
|
public string yzToken { get; set; }
|
|
public DateTime yzExpreTime { get; set; }
|
|
public string YzShopId { get; set; }
|
}
|
}
|
}
|