|
|
|
@ -1,4 +1,6 @@ |
|
|
|
using BWP.B3WeChat.BO; |
|
|
|
using BWP.B3Frameworks.Utils; |
|
|
|
using BWP.B3WeChat.BO; |
|
|
|
using BWP.B3WeChat.Utils; |
|
|
|
using Forks.EnterpriseServices.BusinessInterfaces; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
using Forks.Utils; |
|
|
|
@ -20,24 +22,49 @@ namespace BWP.B3WeChat.BL |
|
|
|
|
|
|
|
public class CustomerUserBL : BusinessClass, ICustomerUserBL |
|
|
|
{ |
|
|
|
|
|
|
|
static Lazy<ICustomerUserBL> mInstance = new Lazy<ICustomerUserBL>(() => |
|
|
|
{ |
|
|
|
return BIFactory.Create<ICustomerUserBL>(); |
|
|
|
}); |
|
|
|
|
|
|
|
public static ICustomerUserBL Instance |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
return mInstance.Value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Follow(string customerCode, string customerUsername, string openID) |
|
|
|
{ |
|
|
|
var del = new DQDeleteDom(typeof(CustomerUser)); |
|
|
|
del.Where.Conditions.Add(DQCondition.EQ("CustomerCode", customerCode)); |
|
|
|
del.Where.Conditions.Add(DQCondition.EQ("CustomerUsername", customerUsername)); |
|
|
|
var user = InnerBLUtil.GetSingleDmo<CustomerUser>(Session, new Tuple<string, object>("CustomerCode", "customerCode"), |
|
|
|
new Tuple<string, object>("CustomerUsername", customerUsername)); |
|
|
|
|
|
|
|
var customerUser = new CustomerUser() |
|
|
|
if (user != null) |
|
|
|
{ |
|
|
|
CustomerCode = customerCode, |
|
|
|
CustomerUsername = customerUsername, |
|
|
|
OpenID = openID |
|
|
|
}; |
|
|
|
Session.Insert(customerUser); |
|
|
|
|
|
|
|
var userBL = BIFactory.Create<IUserBL>(this); |
|
|
|
if (userBL.Exist(openID)) |
|
|
|
if (user.OpenID != openID) |
|
|
|
{ |
|
|
|
var oldOpenID = user.OpenID; |
|
|
|
user.OpenID = openID; |
|
|
|
Session.Update(user); |
|
|
|
var update = new DQUpdateDom(typeof(ApproveMessage)); |
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("CustomerCode", user.CustomerCode)); |
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("CustomerUsername", user.CustomerUsername)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("OpenID", openID)); |
|
|
|
Session.ExecuteNonQuery(update); |
|
|
|
|
|
|
|
SendMessageUtil.SendOverwriteNotice(user.OpenID, customerUsername); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
userBL.Create(openID, StringUtil.CreateRandomString(30), "wechat", customerCode + "/" + customerUsername); |
|
|
|
user = new CustomerUser(); |
|
|
|
user.CustomerCode = customerCode; |
|
|
|
user.CustomerUsername = customerUsername; |
|
|
|
user.OpenID = openID; |
|
|
|
Session.Insert(user); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|