diff --git a/B3WeChat/B3WeChat.csproj b/B3WeChat/B3WeChat.csproj index b9126cc..755d1b0 100644 --- a/B3WeChat/B3WeChat.csproj +++ b/B3WeChat/B3WeChat.csproj @@ -119,6 +119,7 @@ + diff --git a/B3WeChat/BO/ScanLoginRequest.cs b/B3WeChat/BO/ScanLoginRequest.cs new file mode 100644 index 0000000..bc19656 --- /dev/null +++ b/B3WeChat/BO/ScanLoginRequest.cs @@ -0,0 +1,30 @@ +using BWP.B3Frameworks.BO; +using Forks.EnterpriseServices.DataForm; +using Forks.EnterpriseServices.DomainObjects2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3WeChat.BO +{ + /// + /// 微信扫码登录 + /// + [BOClass] + [Serializable] + [DFClass] + public class ScanLoginRequest:Base + { + /// + /// 客户号 + /// + [DbColumn(AllowNull=false)] + public string CustomerCode { get; set; } + + public bool Confirmed { get; set; } + + public string CustomerUsername { get; set; } + } +} diff --git a/B3WeChat/Rpcs/ApproveMessageRpc.cs b/B3WeChat/Rpcs/ApproveMessageRpc.cs index d9b0383..13fc79e 100644 --- a/B3WeChat/Rpcs/ApproveMessageRpc.cs +++ b/B3WeChat/Rpcs/ApproveMessageRpc.cs @@ -19,6 +19,9 @@ using TSingSoft.WebPluginFramework; namespace BWP.B3WeChat.Rpcs { + /// + /// 客户服务器接口关于审批消息的部分 + /// [Rpc] public static class ApproveMessageRpc { diff --git a/B3WeChat/Rpcs/C3Rpc.cs b/B3WeChat/Rpcs/C3Rpc.cs index b3326f7..fdae456 100644 --- a/B3WeChat/Rpcs/C3Rpc.cs +++ b/B3WeChat/Rpcs/C3Rpc.cs @@ -9,9 +9,21 @@ using System.Text; namespace BWP.B3WeChat.Rpcs { + /// + /// 开发给C3系统的接口 + /// [Rpc] public static class C3Rpc { + /// + /// 向用户发送评价链接 + /// + /// + /// + /// + /// + /// + /// [Rpc] public static void SendAppraiseLinkMessage(string serviceNo,string username,string first,string billNo,string remark,string url) { diff --git a/B3WeChat/Rpcs/ClientRpc.cs b/B3WeChat/Rpcs/ClientRpc.cs index b8ece65..83e0772 100644 --- a/B3WeChat/Rpcs/ClientRpc.cs +++ b/B3WeChat/Rpcs/ClientRpc.cs @@ -2,6 +2,7 @@ using BWP.B3WeChat.BO; using BWP.B3WeChat.BO.NamedValueTemplate; using BWP.B3WeChat.Utils; +using Forks.EnterpriseServices.BusinessInterfaces; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; @@ -16,6 +17,10 @@ using TSingSoft.WebPluginFramework; namespace BWP.B3WeChat.Rpcs { + + /// + /// 客户服务器访问微信平台的接口 + /// [Rpc] public static class ClientRpc { @@ -117,5 +122,48 @@ namespace BWP.B3WeChat.Rpcs } + [Rpc] + public static long RequestScanLogin() + { + var request = new ScanLoginRequest(); + request.CustomerCode = CustomerUserContext.Current.CustomerCode; + + using (var context = new TransactionContext()) + { + context.Session.Insert(request); + context.Commit(); + } + return request.ID; + + } + + /// + /// 浏览器查询是否已扫码登录 + /// + /// + /// + [Rpc(RpcFlags.SkipAuth)] + public static bool ScanLoginIsConfirmed(long requestID) + { + var query = new DQueryDom(new JoinAlias(typeof(ScanLoginRequest))); + query.Range = SelectRange.Top(1); + query.Where.Conditions.Add(DQCondition.EQ("ID", requestID)); + query.Columns.Add(DQSelectColumn.Field("Confirmed")); + return query.EExecuteScalar() ?? false; + } + + [Rpc] + public static string QueryLoginResult(long requestID) + { + var query = new DQueryDom(new JoinAlias(typeof(ScanLoginRequest))); + query.Range = SelectRange.Top(1); + query.Where.Conditions.Add(DQCondition.EQ("ID", requestID)); + query.Where.Conditions.Add(DQCondition.EQ("Confirmed", true)); + query.Where.Conditions.Add(DQCondition.EQ("CustomerCode", CustomerUserContext.Current.CustomerCode)); + query.Columns.Add(DQSelectColumn.Field("CustomerUsername")); + return query.EExecuteScalar(); + } + + } } diff --git a/B3WeChat/Rpcs/WeChatUserRpc.cs b/B3WeChat/Rpcs/WeChatUserRpc.cs index f2bf983..9167329 100644 --- a/B3WeChat/Rpcs/WeChatUserRpc.cs +++ b/B3WeChat/Rpcs/WeChatUserRpc.cs @@ -2,6 +2,8 @@ using BWP.B3WeChat.BO; using BWP.B3WeChat.BO.NamedValueTemplate; using BWP.B3WeChat.Utils; +using BWP.Web.Utils; +using Forks.EnterpriseServices.BusinessInterfaces; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; @@ -14,6 +16,9 @@ using TSingSoft.WebPluginFramework; namespace BWP.B3WeChat.Rpcs { + /// + /// 微信公众号页面使用的接口 + /// [Rpc] public static class WeChatUserRpc { @@ -93,5 +98,41 @@ namespace BWP.B3WeChat.Rpcs { return InOutMessageUtil.GetJsApiSignature(noncestr, timestamp, url); } + + + [Rpc] + public static void ScanLoginConfirm(long requestID) + { + var request = WebBLUtil.GetSingleDmo(new Tuple("ID", requestID)); + if (request == null) + { + throw new Exception("不存在的扫码登录号"); + } + + if(request.Confirmed){ + throw new Exception("已经确认过了"); + } + + var queryUser = new DQueryDom(new JoinAlias(typeof(CustomerUser))); + queryUser.Where.Conditions.Add(DQCondition.EQ("CustomerCode", request.CustomerCode)); + queryUser.Where.Conditions.Add(DQCondition.EQ("OpenID", WeChatUserContext.Current.OpenID)); + queryUser.Range = SelectRange.Top(1); + queryUser.Columns.Add(DQSelectColumn.Field("CustomerUsername")); + var username = queryUser.EExecuteScalar(); + if (string.IsNullOrEmpty(username)) + { + throw new Exception("未能发现关联的用户"); + } + + request.Confirmed = true; + request.CustomerUsername = username; + + using (var context = new TransactionContext()) + { + context.Session.Update(request); + context.Commit(); + } + + } } }