/// <summary> /// 读取IC卡信息 /// </summary> /// <param name="msg"></param> /// <param name="sessionPool"></param> /// <param name="sendIP"></param> public static void GetICCard(string msg, Dictionary <string, Session> sessionPool, string sendIP) { string receiveIP = string.Empty; string dogId = string.Empty; string answerMsgType = Convert.ToInt32(TCPMessageType.读取IC卡).ToString(); string cardMsg = string.Empty; string storePassword = string.Empty; string icCardId = string.Empty; string repeatCode = string.Empty; string memberRepeatCode = string.Empty; string errMsg = string.Empty; //解析消息对象 SocketDataModel <UserSendObject> socketDataModel = Utils.DataContractJsonDeserializer <SocketDataModel <UserSendObject> >(msg); UserSendObject sendObj = socketDataModel.SendObject; //接受信息方是否存在 if (!GetIP(sessionPool, sendObj.UserToken, out receiveIP)) { SendFailData(answerMsgType, sessionPool, sendIP, "用户未注册"); return; } //获取店密码接口 string userToken = sendObj.UserToken; if (!StoreBusiness.GetStorePassword(userToken, out storePassword, out errMsg)) { SendFailData(answerMsgType, sessionPool, sendIP, "获取门店信息出错"); return; } object result_data = null; //读取IC卡信息 if (ICCardUtility.GetICCardID(storePassword, out icCardId, out repeatCode, out errMsg)) { if (MemberBusiness.GetMember(userToken, sendObj.StoreId, icCardId, ref result_data, out errMsg)) { SendSuccessData(answerMsgType, sessionPool, sendIP, "读取会员信息成功", result_data); } else { SendFailData(answerMsgType, sessionPool, sendIP, errMsg); } } else { SendFailData(answerMsgType, sessionPool, sendIP, errMsg); } }
public static void ExitICCard(string msg, Dictionary <string, Session> sessionPool, string sendIP) { string receiveIP = string.Empty; string dogId = string.Empty; string storePassword = string.Empty; string newICCardId = string.Empty; string errMsg = string.Empty; string answerMsgType = Convert.ToInt32(TCPMessageType.退卡).ToString(); //解析消息对象 SocketDataModel <UserSendObject> socketDataModel = Utils.DataContractJsonDeserializer <SocketDataModel <UserSendObject> >(msg); UserSendObject sendObj = socketDataModel.SendObject; //接受信息方是否存在 if (!GetIP(sessionPool, sendObj.UserToken, out receiveIP)) { SendFailData(answerMsgType, sessionPool, sendIP, "用户未注册"); return; } //获取店密码接口 string userToken = sendObj.UserToken; if (!StoreBusiness.GetStorePassword(userToken, out storePassword, out errMsg)) { SendFailData(answerMsgType, sessionPool, sendIP, "获取门店信息出错"); return; } //清理卡片 if (!ICCardUtility.RecoveryICCard(storePassword, out errMsg)) { SendFailData(answerMsgType, sessionPool, sendIP, errMsg); return; } else { SendSuccessData(answerMsgType, sessionPool, sendIP, "会员卡回收成功", null); } }
public static void CreateICCard(string msg, Dictionary <string, Session> sessionPool, string sendIP) { string sRepeatCode = (new Random()).Next(0, 255).ToString(); string receiveIP = string.Empty; string dogId = string.Empty; string storePassword = string.Empty; string newICCardId = string.Empty; string errMsg = string.Empty; string answerMsgType = Convert.ToInt32(TCPMessageType.办理新IC卡).ToString(); //解析消息对象 SocketDataModel <UserSendObject, MemberRegisterModel> socketDataModel = Utils.DataContractJsonDeserializer <SocketDataModel <UserSendObject, MemberRegisterModel> >(msg); UserSendObject sendObj = socketDataModel.SendObject; MemberRegisterModel memberRegisterModel = (MemberRegisterModel)(socketDataModel.Data); newICCardId = memberRegisterModel.ICCardId; //接受信息方是否存在 if (!GetIP(sessionPool, sendObj.UserToken, out receiveIP)) { SendFailData(answerMsgType, sessionPool, sendIP, "用户未注册"); return; } //获取店密码接口 string userToken = sendObj.UserToken; if (!StoreBusiness.GetStorePassword(userToken, out storePassword, out errMsg)) { SendFailData(answerMsgType, sessionPool, sendIP, "获取门店信息出错"); return; } //验证是否可以办卡 if (ICCardUtility.CheckNullCard(storePassword)) { if (MemberBusiness.CheckMemberCanRegister(userToken, memberRegisterModel.StoreId, memberRegisterModel.Mobile, out errMsg)) { //办理新卡 if (ICCardUtility.CreateICCard(newICCardId, sRepeatCode, storePassword, out errMsg, true)) { memberRegisterModel.RepeatCode = sRepeatCode; object result_data = null; int repeatCode = 0; if (MemberBusiness.MemberRegister(memberRegisterModel, out repeatCode, out errMsg, ref result_data)) { SendSuccessData(answerMsgType, sessionPool, sendIP, "会员卡开通成功", result_data); } else { SendFailData(answerMsgType, sessionPool, sendIP, errMsg); } } else { SendFailData(answerMsgType, sessionPool, sendIP, errMsg); } } else { SendFailData(answerMsgType, sessionPool, sendIP, errMsg); } } else { SendFailData(answerMsgType, sessionPool, sendIP, "本卡已使用,请插入空卡"); } }