|
|
@ -1,4 +1,4 @@ |
|
|
using Bwp.MainSystem.BO; |
|
|
|
|
|
|
|
|
using Bwp.MainSystem.BO; |
|
|
using BWP.B3WeChat.BO; |
|
|
using BWP.B3WeChat.BO; |
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
@ -7,50 +7,62 @@ using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
|
|
|
using System.Web; |
|
|
using TSingSoft.WebPluginFramework; |
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
|
|
|
namespace BWP.B3WeChat |
|
|
namespace BWP.B3WeChat |
|
|
{ |
|
|
{ |
|
|
public class CustomerUserContext |
|
|
public class CustomerUserContext |
|
|
{ |
|
|
{ |
|
|
CustomerUser mUser; |
|
|
|
|
|
|
|
|
|
|
|
public CustomerUser User |
|
|
|
|
|
|
|
|
string mCustomerCode; |
|
|
|
|
|
public string CustomerCode |
|
|
{ |
|
|
{ |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
return mUser; |
|
|
|
|
|
|
|
|
return mCustomerCode; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ThreadStatic] |
|
|
|
|
|
static Lazy<CustomerUserContext> mCurrent = new Lazy<CustomerUserContext>(() => |
|
|
|
|
|
|
|
|
public string GetOpenID(string customerUsername) |
|
|
{ |
|
|
{ |
|
|
var user = BLContext.User; |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(DeviceAuthentication))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Ticket", user.UserTag.ToString("N"))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("DeviceNumber")); |
|
|
|
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(CustomerUser))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("CustomerCode", CustomerCode)); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("CustomerUsername", customerUsername)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("OpenID")); |
|
|
query.Range = SelectRange.Top(1); |
|
|
query.Range = SelectRange.Top(1); |
|
|
var deviceNumber = query.EExecuteScalar<string>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var context = new CustomerUserContext(); |
|
|
|
|
|
|
|
|
var result = query.EExecuteScalar<string>(); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var dmoQuery = new DmoQuery(typeof(CustomerUser)); |
|
|
|
|
|
dmoQuery.Where.Conditions.Add(DQCondition.EQ("CustomerCode", deviceNumber)); |
|
|
|
|
|
dmoQuery.Where.Conditions.Add(DQCondition.EQ("CustomerUsername", user.Name)); |
|
|
|
|
|
dmoQuery.Range = SelectRange.Top(1); |
|
|
|
|
|
context.mUser = dmoQuery.EExecuteScalar<CustomerUser>(); |
|
|
|
|
|
|
|
|
|
|
|
return context; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
public static CustomerUserContext Current |
|
|
public static CustomerUserContext Current |
|
|
{ |
|
|
{ |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
return mCurrent.Value; |
|
|
|
|
|
|
|
|
var httpContext = HttpContext.Current; |
|
|
|
|
|
var key = "CustomerUserContext"; |
|
|
|
|
|
if (httpContext != null && httpContext.Items.Contains(key)) |
|
|
|
|
|
{ |
|
|
|
|
|
return (CustomerUserContext)httpContext.Items[key]; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
var user = BLContext.User; |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(DeviceAuthentication))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Ticket", user.UserTag.ToString("N"))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("DeviceNumber")); |
|
|
|
|
|
query.Range = SelectRange.Top(1); |
|
|
|
|
|
var deviceNumber = query.EExecuteScalar<string>(); |
|
|
|
|
|
var context = new CustomerUserContext(); |
|
|
|
|
|
context.mCustomerCode = deviceNumber; |
|
|
|
|
|
if (httpContext != null) |
|
|
|
|
|
{ |
|
|
|
|
|
httpContext.Items[key] = context; |
|
|
|
|
|
} |
|
|
|
|
|
return context; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|