/// <summary> /// 检查CcOrder集合 /// </summary> public Hashtable CheckCcOrders(IList <CcOrderContract> orders, string orderType) { Hashtable htError = new Hashtable(); if (orders == null || orders.Count == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据集合不能为空", true); return(htError); } foreach (var order in orders) { if (orderType == UploadCcOrderType.MOBILE.ToString()) // 手机端 { htError = CheckMobileCcOrder(order); } else { htError = CheckCcOrder(order); } if (!Convert.ToBoolean(htError["status"])) { return(htError); } } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查单据ID集合 /// </summary> public Hashtable CheckCcOrderIds(IList <CcOrderContract> orders) { Hashtable htError = new Hashtable(); if (orders == null || orders.Count == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据ID集合不能为空", true); return(htError); } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查Vip /// </summary> public Hashtable CheckVip(VipContract vip) { Hashtable htError = new Hashtable(); if (vip == null) { htError = ErrorService.OutputError(ErrorCode.A016, "会员信息不能为空", true); return(htError); } if (vip.id == null || vip.id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "会员ID不能为空", true); return(htError); } if (vip.no == null || vip.no.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "会员号码不能为空", true); return(htError); } //if (vip.order_type_id == null || vip.order_type_id.Trim().Length == 0) //{ // htError = ErrorService.OutputError(ErrorCode.A016, "会员类型1不能为空", true); // return htError; //} //if (vip.order_reason_id == null || vip.order_reason_id.Trim().Length == 0) //{ // htError = ErrorService.OutputError(ErrorCode.A016, "会员类型2不能为空", true); // return htError; //} //if (vip.red_flag == null || vip.red_flag.Trim().Length == 0) //{ // htError = ErrorService.OutputError(ErrorCode.A016, "会员红单标记不能为空", true); // return htError; //} //if (!(vip.red_flag == "1" || vip.red_flag == "-1")) //{ // htError = ErrorService.OutputError(ErrorCode.A019, "会员红单标记数据不合法", true); // return htError; //} //if (vip.order_date == null || vip.order_date.Trim().Length == 0) //{ // htError = ErrorService.OutputError(ErrorCode.A016, "会员日期不能为空", true); // return htError; //} //if (vip.create_unit_id == null || vip.create_unit_id.Trim().Length == 0) //{ // htError = ErrorService.OutputError(ErrorCode.A016, "会员创建单位不能为空", true); // return htError; //} htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查MonitorLog /// </summary> public Hashtable CheckMonitorLog(MonitorLogContract order) { Hashtable htError = new Hashtable(); if (order == null) { htError = ErrorService.OutputError(ErrorCode.A016, "信息不能为空", true); return(htError); } if (order.user_id == null || order.user_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "用户标识不能为空", true); return(htError); } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查Vip集合 /// </summary> public Hashtable CheckVips(IList <VipContract> vips) { Hashtable htError = new Hashtable(); if (vips == null || vips.Count == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "会员集合不能为空", true); return(htError); } foreach (var vip in vips) { htError = CheckVip(vip); if (!Convert.ToBoolean(htError["status"])) { return(htError); } } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查CustomerUnitApply集合 /// </summary> public Hashtable CheckApplyCustomerAndUnit(IList <CustomerUnitApply> orders, string type) { Hashtable htError = new Hashtable(); if (orders == null || orders.Count == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "集合不能为空", true); return(htError); } foreach (var order in orders) { htError = CheckApplyCustomerAndUnit(order, type); if (!Convert.ToBoolean(htError["status"])) { return(htError); } } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查Shift集合 /// </summary> public Hashtable CheckShifts(string orderType, IList <ShiftContract> orders) { Hashtable htError = new Hashtable(); if (orders == null || orders.Count == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "班次集合不能为空", true); return(htError); } foreach (var order in orders) { htError = CheckShift(orderType, order); if (!Convert.ToBoolean(htError["status"])) { return(htError); } } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查MonitorLog集合 /// </summary> public Hashtable CheckMonitorLogs(IList <MonitorLogContract> orders) { Hashtable htError = new Hashtable(); if (orders == null || orders.Count == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "集合不能为空", true); return(htError); } foreach (var order in orders) { htError = CheckMonitorLog(order); if (!Convert.ToBoolean(htError["status"])) { return(htError); } } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 获取日志接口 /// </summary> public GetLogContract GetLog(TransType transType, string userId, string userPwd, string logId) { string bizId = Utils.NewGuid(); string methodKey = "LogService.GetLog"; string ifCode = "C013"; var data = new GetLogContract(); Hashtable htLogExt = new Hashtable(); htLogExt["customer_code"] = null; htLogExt["customer_id"] = null; htLogExt["unit_code"] = null; htLogExt["unit_id"] = null; htLogExt["user_code"] = null; htLogExt["user_id"] = userId; htLogExt["if_code"] = ifCode; htLogExt["app_code"] = AppType.Client; try { Hashtable htParams = new Hashtable(); htParams.Add("trans_type", transType); htParams.Add("user_id", userId); htParams.Add("user_pwd", userPwd); htParams.Add("log_id", logId); LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt); bool statusFlag = true; Hashtable htError = null; CertInfo certInfo = null; // 检查参数 Hashtable htResult = new Hashtable(); bool paramCheckFlag = false; #region Check Length htResult = ErrorService.CheckLength("用户ID", userId, 1, 32, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogContract>(htResult)); } htResult = ErrorService.CheckLength("密码", userPwd, 1, 32, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogContract>(htResult)); } htResult = ErrorService.CheckLength("日志ID", logId, 1, 32, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogContract>(htResult)); } #endregion Dex.Services.AuthService authService = new Dex.Services.AuthService(); // 检查User Hashtable htUser = new Hashtable(); htUser.Add("UserId", userId); htUser.Add("CertPwd", userPwd); statusFlag = authService.Validate(htUser, ref certInfo); if (!statusFlag) { htError = ErrorService.OutputError(ErrorCode.A009, "用户ID与密码不匹配", true); data.status = Utils.GetStatus(false); data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } // 获取数据 Services.LogDBService logDBService = new Services.LogDBService(); LogInfo log = logDBService.GetLogById(logId); if (log != null) { LogContract logContract = new LogContract(); logContract.log_id = log.LogId; logContract.biz_id = log.BizId; logContract.biz_name = log.BizName; logContract.log_type_id = log.LogTypeId; logContract.log_type_code = log.LogTypeCode; logContract.log_code = log.LogCode; logContract.log_body = log.LogBody; logContract.create_time = log.CreateTime; logContract.create_user_id = log.CreateUserId; logContract.modify_time = log.ModifyTime; logContract.modify_user_id = log.ModifyUserId; logContract.customer_code = log.CustomerCode; logContract.customer_id = log.CustomerId; logContract.unit_code = log.UnitCode; logContract.unit_id = log.UnitId; logContract.user_code = log.UserCode; logContract.user_id = log.UserId; logContract.if_code = log.IfCode; logContract.app_code = log.AppCode; data.Log = logContract; } data.status = Utils.GetStatus(statusFlag); LogService.WriteTrace(bizId, methodKey, TraceLogType.Return.ToString(), data.ToString(), userId, htLogExt); } catch (Exception ex) { data.status = Utils.GetStatus(false); data.error_code = ErrorCode.A000.ToString(); data.error_full_desc = ex.ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); } return(data); }
/// <summary> /// 获取日志集合接口 /// </summary> public GetLogsContract GetLogs(TransType transType, string userId, string userPwd, long startRow, long rowsCount, LogQueryInfo queryInfo) { string bizId = Utils.NewGuid(); string methodKey = "LogService.GetLogs"; string ifCode = "C011"; var data = new GetLogsContract(); Hashtable htLogExt = new Hashtable(); htLogExt["customer_code"] = null; htLogExt["customer_id"] = null; htLogExt["unit_code"] = null; htLogExt["unit_id"] = null; htLogExt["user_code"] = null; htLogExt["user_id"] = userId; htLogExt["if_code"] = ifCode; htLogExt["app_code"] = AppType.Client; try { Hashtable htParams = new Hashtable(); htParams.Add("trans_type", transType); htParams.Add("user_id", userId); htParams.Add("user_pwd", userPwd); htParams.Add("start_row", startRow); htParams.Add("rows_count", rowsCount); htParams.Add("query_info", queryInfo); LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt); bool statusFlag = true; Hashtable htError = null; CertInfo certInfo = null; // 检查参数 Hashtable htResult = new Hashtable(); bool paramCheckFlag = false; #region Check Length htResult = ErrorService.CheckLength("用户ID", userId, 1, 32, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("密码", userPwd, 1, 32, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } // queryInfo htResult = ErrorService.CheckLength("日志ID", queryInfo.log_id, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("业务ID", queryInfo.biz_id, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("业务名称", queryInfo.biz_name, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("日志类型ID", queryInfo.log_type_id, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("日志类型代码", queryInfo.log_type_code, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("日志代码", queryInfo.log_code, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("日志内容", queryInfo.log_body, 0, 200, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("开始创建时间", queryInfo.create_time_begin, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("结束创建时间", queryInfo.create_time_end, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("创建人ID", queryInfo.create_user_id, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("开始修改时间", queryInfo.modify_time_begin, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("结束修改时间", queryInfo.modify_time_end, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("修改人ID", queryInfo.modify_user_id, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("客户代码", queryInfo.customer_code, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("客户ID", queryInfo.customer_id, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("门店代码", queryInfo.unit_code, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("门店ID", queryInfo.unit_id, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("用户代码", queryInfo.user_code, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("用户ID", queryInfo.user_id, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("接口代码", queryInfo.if_code, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } htResult = ErrorService.CheckLength("平台代码", queryInfo.app_code, 0, 50, true, true, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <GetLogsContract>(htResult)); } #endregion Hashtable htQueryInfo = new Hashtable(); htQueryInfo.Add("LogId", queryInfo.log_id); htQueryInfo.Add("BizId", queryInfo.biz_id); htQueryInfo.Add("BizName", queryInfo.biz_name); htQueryInfo.Add("LogTypeId", queryInfo.log_type_id); htQueryInfo.Add("LogTypeCode", queryInfo.log_type_code); htQueryInfo.Add("LogCode", queryInfo.log_code); htQueryInfo.Add("LogBody", queryInfo.log_body); htQueryInfo.Add("CreateTimeBegin", queryInfo.create_time_begin); htQueryInfo.Add("CreateTimeEnd", queryInfo.create_time_end); htQueryInfo.Add("CreateUserId", queryInfo.create_user_id); htQueryInfo.Add("ModifyTimeBegin", queryInfo.modify_time_begin); htQueryInfo.Add("ModifyTimeEnd", queryInfo.modify_time_end); htQueryInfo.Add("ModifyUserId", queryInfo.modify_user_id); htQueryInfo.Add("CustomerCode", queryInfo.customer_code); htQueryInfo.Add("CustomerId", queryInfo.customer_id); htQueryInfo.Add("UnitCode", queryInfo.unit_code); htQueryInfo.Add("UnitId", queryInfo.unit_id); htQueryInfo.Add("UserCode", queryInfo.user_code); htQueryInfo.Add("UserId", queryInfo.user_id); htQueryInfo.Add("IfCode", queryInfo.if_code); htQueryInfo.Add("AppCode", queryInfo.app_code); Dex.Services.AuthService authService = new Dex.Services.AuthService(); // 检查User Hashtable htUser = new Hashtable(); htUser.Add("UserId", userId); htUser.Add("CertPwd", userPwd); statusFlag = authService.Validate(htUser, ref certInfo); if (!statusFlag) { htError = ErrorService.OutputError(ErrorCode.A009, "用户ID与密码不匹配", true); data.status = Utils.GetStatus(false); data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } // 获取数据 Services.LogDBService logDBService = new Services.LogDBService(); IList <LogInfo> logs = logDBService.GetLogs(htQueryInfo, startRow, rowsCount); if (logs != null) { data.Logs = new List <LogContract>(); foreach (var log in logs) { LogContract logContract = new LogContract(); logContract.log_id = log.LogId; logContract.biz_id = log.BizId; logContract.biz_name = log.BizName; logContract.log_type_id = log.LogTypeId; logContract.log_type_code = log.LogTypeCode; logContract.log_code = log.LogCode; logContract.log_body = log.LogBody; logContract.create_time = log.CreateTime; logContract.create_user_id = log.CreateUserId; logContract.modify_time = log.ModifyTime; logContract.modify_user_id = log.ModifyUserId; logContract.customer_code = log.CustomerCode; logContract.customer_id = log.CustomerId; logContract.unit_code = log.UnitCode; logContract.unit_id = log.UnitId; logContract.user_code = log.UserCode; logContract.user_id = log.UserId; logContract.if_code = log.IfCode; logContract.app_code = log.AppCode; data.Logs.Add(logContract); } } data.status = Utils.GetStatus(statusFlag); LogService.WriteTrace(bizId, methodKey, TraceLogType.Return.ToString(), data.ToString(), userId, htLogExt); } catch (Exception ex) { data.status = Utils.GetStatus(false); data.error_code = ErrorCode.A000.ToString(); data.error_full_desc = ex.ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); } return(data); }
/// <summary> /// 用户凭证验证 /// </summary> public ValidateContract Validate(TransType transType, string userCode, string customerCode, string password, string type) { string bizId = Utils.NewGuid(); string methodKey = "AuthService.Validate"; string ifCode = "C003"; var data = new ValidateContract(); Hashtable htLogExt = new Hashtable(); htLogExt["customer_code"] = customerCode; htLogExt["customer_id"] = null; htLogExt["unit_code"] = null; htLogExt["unit_id"] = null; htLogExt["user_code"] = userCode; htLogExt["user_id"] = null; htLogExt["if_code"] = ifCode; htLogExt["app_code"] = AppType.Client; try { Hashtable htParams = new Hashtable(); htParams.Add("trans_type", transType); htParams.Add("user_code", userCode); htParams.Add("customer_code", customerCode); htParams.Add("password", password); htParams.Add("type", type); LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, null, htLogExt); bool statusFlag = false; Hashtable htError = null; string userId = string.Empty; string token = string.Empty; CertInfo certInfo = null; if (type == null || type == string.Empty) { type = CertType.POS.ToString(); } Dex.Services.AuthService authService = new Dex.Services.AuthService(); // 检查参数 Hashtable htResult = new Hashtable(); bool paramCheckFlag = false; #region Check Length htResult = ErrorService.CheckLength("用户代码", userCode, 1, 40, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <ValidateContract>(htResult)); } htResult = ErrorService.CheckLength("用户密码", password, 1, 40, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <ValidateContract>(htResult)); } if (type == CertType.POS.ToString()) { htResult = ErrorService.CheckLength("客户代码", customerCode, 1, 40, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <ValidateContract>(htResult)); } } else { htResult = ErrorService.CheckLength("客户代码", customerCode, 0, 40, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <ValidateContract>(htResult)); } } #endregion // 查询用户或客户是否存在 //certInfo = authService.GetCertByUserId(userId); //if (certInfo == null) //{ // htError = ErrorService.OutputError(ErrorCode.A006, "用户ID不存在", true); // data.status = Utils.GetStatus(false); // data.error_code = htError["error_code"].ToString(); // data.error_desc = htError["error_desc"].ToString(); // LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId); // return data; //} // 查询凭证 Hashtable htCert = new Hashtable(); htCert["UserCode"] = userCode; htCert["CustomerCode"] = customerCode; htCert["CertPwd"] = password; if (type == CertType.MOBILE.ToString()) { htCert["CustomerCode"] = null; htCert["CertTypeCode"] = type.ToLower(); } statusFlag = authService.Validate(htCert, ref certInfo); if (!statusFlag) { htError = ErrorService.OutputError(ErrorCode.A009, "用户代码与密码/用户代码与客户代码不匹配", true); if (type == CertType.MOBILE.ToString()) { htError = ErrorService.OutputError(ErrorCode.A009, "用户代码与密码不匹配", true); } data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); } else { userId = certInfo.UserId; // 获取令牌 var certTokenInfo = GetCertToken(certInfo.CertId, certInfo.UserId, true); token = certTokenInfo.CertToken; data.user_id = userId; data.token = token; htLogExt["user_id"] = userId; } data.status = Utils.GetStatus(statusFlag); LogService.WriteTrace(bizId, methodKey, TraceLogType.Return.ToString(), data.ToString(), userId, htLogExt); } catch (Exception ex) { data.status = Utils.GetStatus(false); data.error_code = ErrorCode.A000.ToString(); data.error_full_desc = ex.ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), null, htLogExt); } return(data); }
/// <summary> /// 修改用户密码接口 /// </summary> public BaseContract ChangePassword(TransType transType, string userId, string token, string unitId, string newPassword) { string bizId = Utils.NewGuid(); string methodKey = "AuthService.ChangePassword"; string ifCode = "C029"; var data = new BaseContract(); Hashtable htLogExt = new Hashtable(); htLogExt["customer_code"] = null; htLogExt["customer_id"] = null; htLogExt["unit_code"] = null; htLogExt["unit_id"] = unitId; htLogExt["user_code"] = null; htLogExt["user_id"] = userId; htLogExt["if_code"] = ifCode; htLogExt["app_code"] = AppType.Client; try { Hashtable htParams = new Hashtable(); htParams.Add("trans_type", transType); htParams.Add("user_id", userId); htParams.Add("token", token); htParams.Add("unit_id", unitId); htParams.Add("new_password", newPassword); LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, null, htLogExt); bool statusFlag = false; Hashtable htError = null; CertInfo certInfo = null; Dex.Services.AuthService authService = new Dex.Services.AuthService(); // 检查参数 Hashtable htResult = new Hashtable(); bool paramCheckFlag = false; #region Check Length htResult = ErrorService.CheckLength("用户ID", userId, 1, 32, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <BaseContract>(htResult)); } //htResult = ErrorService.CheckLength("令牌", token, 1, 32, true, false, ref paramCheckFlag); //if (!paramCheckFlag) return ErrorConvert.Export<BaseContract>(htResult); htResult = ErrorService.CheckLength("门店ID", unitId, 1, 32, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <BaseContract>(htResult)); } htResult = ErrorService.CheckLength("用户新密码", newPassword, 1, 40, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <BaseContract>(htResult)); } #endregion // 检查User和Customer certInfo = authService.GetCertByUserId(userId); if (certInfo == null) { htError = ErrorService.OutputError(ErrorCode.A006, "用户ID不存在", true); data.status = Utils.GetStatus(false); data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } statusFlag = true; // 检查Token是否不匹配或过期 //statusFlag = authService.CheckCertToken(token, certInfo.CertId, userId); //if (!statusFlag) //{ // htError = ErrorService.OutputError(ErrorCode.A005, "令牌不匹配或过期", true); // data.status = Utils.GetStatus(false); // data.error_code = htError["error_code"].ToString(); // data.error_full_desc = htError["error_desc"].ToString(); // LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); // return data; //} // 查询凭证 certInfo = authService.GetCertByUserId(userId); if (certInfo == null || certInfo.CustomerId == null || certInfo.CustomerId.Length == 0) { htError = ErrorService.OutputError(ErrorCode.A007, "获取后台数据(客户ID)失败", true); data.status = Utils.GetStatus(false); data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } string customerId = certInfo.CustomerId; htLogExt["customer_code"] = certInfo.CustomerCode; htLogExt["customer_id"] = certInfo.CustomerId; htLogExt["user_code"] = certInfo.UserCode; // 提交 var bsAuthService = new ServicesBs.AuthService(); bsAuthService.ChangePassword(customerId, unitId, userId, newPassword); authService.UpdateCertPwdByUserId(userId, newPassword); data.status = Utils.GetStatus(statusFlag); LogService.WriteTrace(bizId, methodKey, TraceLogType.Return.ToString(), data.ToString(), userId, htLogExt); } catch (Exception ex) { data.status = Utils.GetStatus(false); data.error_code = ErrorCode.A000.ToString(); data.error_full_desc = ex.ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), null, htLogExt); } return(data); }
/// <summary> /// 检查CustomerUnitApply /// </summary> public Hashtable CheckApplyCustomerAndUnit(CustomerUnitApply order, string type) { Hashtable htError = new Hashtable(); if (order == null) { htError = ErrorService.OutputError(ErrorCode.A016, "信息不能为空", true); return(htError); } if (order.customers != null) { foreach (var customerObj in order.customers) { if (customerObj == null) { continue; } if (customerObj.customer_id == null || customerObj.customer_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, customerObj.customer_name + ":客户标识不能为空", true); return(htError); } if (customerObj.customer_code == null || customerObj.customer_code.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, customerObj.customer_id + ":客户代码不能为空", true); return(htError); } if (customerObj.customer_name == null || customerObj.customer_name.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, customerObj.customer_id + ":客户名称不能为空", true); return(htError); } } } if (order.units != null) { foreach (var unitObj in order.units) { if (unitObj == null) { continue; } if (unitObj.unit_id == null || unitObj.unit_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, unitObj.unit_name + ":门店标识不能为空", true); return(htError); } if (unitObj.customer_id == null || unitObj.customer_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, unitObj.unit_id + ":门店的客户标识不能为空", true); return(htError); } if (unitObj.unit_code == null || unitObj.unit_code.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, unitObj.unit_id + ":门店代码不能为空", true); return(htError); } if (unitObj.unit_name == null || unitObj.unit_name.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, unitObj.unit_id + ":门店名称不能为空", true); return(htError); } } } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查Shift /// </summary> public Hashtable CheckShift(string orderType, ShiftContract order) { Hashtable htError = new Hashtable(); if (order == null) { htError = ErrorService.OutputError(ErrorCode.A016, "班次信息不能为空", true); return(htError); } if (order.shift_id == null || order.shift_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "班次ID不能为空", true); return(htError); } if (order.sales_user == null || order.sales_user.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "收营员不能为空", true); return(htError); } //if (order.pos_id == null || order.pos_id.Trim().Length == 0) //{ // htError = ErrorService.OutputError(ErrorCode.A016, "pos标识不能为空", true); // return htError; //} //if (order.parent_shift_id == null || order.parent_shift_id.Trim().Length == 0) //{ // htError = ErrorService.OutputError(ErrorCode.A016, "上一个班次标识不能为空", true); // return htError; //} if (order.unit_id == null || order.unit_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "门店标识不能为空", true); return(htError); } if (order.deposit_amount == null || order.deposit_amount.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "准备金不能为空", true); return(htError); } if (order.sale_amount == null || order.sale_amount.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "销售金额不能为空", true); return(htError); } if (order.return_amount == null || order.return_amount.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "退款金额不能为空", true); return(htError); } if (order.pos_date == null || order.pos_date.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "营业日期不能为空", true); return(htError); } if (order.sales_qty == null || order.sales_qty.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "销售笔数不能为空", true); return(htError); } if (order.sales_total_amount == null || order.sales_total_amount.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "销售总金额不能为空", true); return(htError); } if (order.open_time == null || order.open_time.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "开班时间不能为空", true); return(htError); } if (order.close_time == null || order.close_time.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "交班时间不能为空", true); return(htError); } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 检查手机端盘点单 /// </summary> public Hashtable CheckMobileCcOrder(CcOrderContract order) { Hashtable htError = new Hashtable(); if (order == null) { htError = ErrorService.OutputError(ErrorCode.A016, "单据信息不能为空", true); return(htError); } if (order.order_id == null || order.order_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据ID不能为空", true); return(htError); } if (order.order_no == null || order.order_no.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据号码不能为空", true); return(htError); } if (order.order_date == null || order.order_date.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据日期不能为空", true); return(htError); } if (order.unit_id == null || order.unit_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "门店标识不能为空", true); return(htError); } if (order.status == null || order.status.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "状态不能为空", true); return(htError); } if (order.create_user_id == null || order.create_user_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "创建人不能为空", true); return(htError); } if (order.create_time == null || order.create_time.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "创建时间不能为空", true); return(htError); } // details //if (order.details == null || order.details.Count == 0) //{ // htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "单据明细信息不能为空", true); // return htError; //} if (order.details != null && order.details.Count > 0) { foreach (var orderDetail in order.details) { if (orderDetail.order_detail_id == null || orderDetail.order_detail_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的ID不能为空", true); return(htError); } if (orderDetail.order_id == null || orderDetail.order_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的主单据ID不能为空", true); return(htError); } if (orderDetail.sku_id == null || orderDetail.sku_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的SKU不能为空", true); return(htError); } if (orderDetail.end_qty == null || orderDetail.end_qty.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的库存数量不能为空", true); return(htError); } if (orderDetail.item_name == null || orderDetail.item_name.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的商品名称不能为空", true); return(htError); } if (orderDetail.item_code == null || orderDetail.item_code.Trim().Length == 0) { orderDetail.item_code = orderDetail.item_name; htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的商品代码不能为空", true); return(htError); } if (orderDetail.barcode == null || orderDetail.barcode.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的商品条码不能为空", true); return(htError); } if (orderDetail.sku_prop_1_name == null || orderDetail.sku_prop_1_name.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的规格1名称不能为空", true); return(htError); } if (orderDetail.enter_price == null || orderDetail.enter_price.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的商品进价不能为空", true); return(htError); } if (orderDetail.sales_price == null || orderDetail.sales_price.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的商品售价不能为空", true); return(htError); } } } htError["status"] = Utils.GetStatus(true); return(htError); }
/// <summary> /// 上传 MonitorLog 信息接口 /// </summary> public UploadContract UploadMonitorLog(TransType transType, MonitorLogContract order, string userId, string token, string unitId) { string bizId = Utils.NewGuid(); string methodKey = "ComService.UploadMonitorLog"; string ifCode = "C001"; var data = new UploadContract(); Hashtable htLogExt = new Hashtable(); htLogExt["customer_code"] = null; htLogExt["customer_id"] = null; htLogExt["unit_code"] = null; htLogExt["unit_id"] = unitId; htLogExt["user_code"] = null; htLogExt["user_id"] = userId; htLogExt["if_code"] = ifCode; htLogExt["app_code"] = AppType.Client; try { Hashtable htParams = new Hashtable(); htParams.Add("trans_type", transType); htParams.Add("order", order); htParams.Add("user_id", userId); htParams.Add("token", token); htParams.Add("unit_id", unitId); LogService.WriteTrace(bizId, methodKey, TraceLogType.Params.ToString(), htParams, userId, htLogExt); bool statusFlag = false; Hashtable htError = null; CertInfo certInfo = null; #region 检查参数 Hashtable htResult = new Hashtable(); bool paramCheckFlag = false; htResult = ErrorService.CheckLength("用户ID", userId, 1, 32, true, false, ref paramCheckFlag); if (!paramCheckFlag) { return(ErrorConvert.Export <UploadContract>(htResult)); } //htResult = ErrorService.CheckLength("令牌", token, 1, 32, true, false, ref paramCheckFlag); //if (!paramCheckFlag) return ErrorConvert.Export<UploadContract>(htResult); //htResult = ErrorService.CheckLength("门店ID", unitId, 1, 32, true, false, ref paramCheckFlag); //if (!paramCheckFlag) return ErrorConvert.Export<UploadContract>(htResult); #endregion #region 检查权限 Dex.Services.AuthService authService = new Dex.Services.AuthService(); // 检查User和Customer certInfo = authService.GetCertByUserId(userId); if (certInfo == null) { htError = ErrorService.OutputError(ErrorCode.A006, "用户ID不存在", true); data.status = Utils.GetStatus(false); data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } statusFlag = true; //// 检查Token是否不匹配或过期 //statusFlag = authService.CheckCertToken(token, certInfo.CertId, userId); //if (!statusFlag) //{ // htError = ErrorService.OutputError(ErrorCode.A005, "令牌不匹配或过期", true); // data.status = Utils.GetStatus(false); // data.error_code = htError["error_code"].ToString(); // data.error_full_desc = htError["error_desc"].ToString(); // LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); // return data; //} // 查询凭证 certInfo = authService.GetCertByUserId(userId); if (certInfo == null || certInfo.CustomerId == null || certInfo.CustomerId.Length == 0) { htError = ErrorService.OutputError(ErrorCode.A007, "获取后台数据(客户ID)失败", true); data.status = Utils.GetStatus(false); data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } string customerId = certInfo.CustomerId; htLogExt["customer_code"] = certInfo.CustomerCode; htLogExt["customer_id"] = certInfo.CustomerId; htLogExt["user_code"] = certInfo.UserCode; #endregion #region 检查单据参数 Dex.ServicesBs.ComService orderService = new Dex.ServicesBs.ComService(); if (order.user_id == null || order.user_id.Trim().Length == 0) { order.user_id = userId; } htError = orderService.CheckMonitorLog(order); if (!Convert.ToBoolean(htError["status"])) { data.status = Utils.GetStatus(false); data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } #endregion // 保存 ConfigService cfgService = new ConfigService(); bool enableConnectPosBS = cfgService.GetEnableConnectPosBSCfg(); if (enableConnectPosBS) { try { orderService.SaveMonitorLog(order, customerId, unitId, userId); } catch (Exception ex) { data.status = Utils.GetStatus(false); data.error_code = ErrorCode.A018.ToString(); data.error_full_desc = ex.ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } } else { htError = ErrorService.OutputError(ErrorCode.A012, "连接业务平台数据通道已关闭", true); data.status = Utils.GetStatus(false); data.error_code = htError["error_code"].ToString(); data.error_full_desc = htError["error_desc"].ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); return(data); } data.status = Utils.GetStatus(statusFlag); LogService.WriteTrace(bizId, methodKey, TraceLogType.Return.ToString(), data.ToString(), userId, htLogExt); } catch (Exception ex) { data.status = Utils.GetStatus(false); data.error_code = ErrorCode.A000.ToString(); data.error_full_desc = ex.ToString(); LogService.WriteError(bizId, methodKey, data.error_code, data.ToString(), userId, htLogExt); } return(data); }
/// <summary> /// 检查CcOrder /// </summary> public Hashtable CheckCcOrder(CcOrderContract order) { Hashtable htError = new Hashtable(); if (order == null) { htError = ErrorService.OutputError(ErrorCode.A016, "单据信息不能为空", true); return(htError); } if (order.order_id == null || order.order_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据ID不能为空", true); return(htError); } if (order.order_no == null || order.order_no.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据号码不能为空", true); return(htError); } if (order.order_type_id == null || order.order_type_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据类型1不能为空", true); return(htError); } if (order.order_reason_id == null || order.order_reason_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据类型2不能为空", true); return(htError); } if (order.order_date == null || order.order_date.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "单据日期不能为空", true); return(htError); } if (order.warehouse_id == null || order.warehouse_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "仓库标识不能为空", true); return(htError); } if (order.create_user_id == null || order.create_user_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "创建人不能为空", true); return(htError); } if (order.create_time == null || order.create_time.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, "创建时间不能为空", true); return(htError); } // details if (order.details == null || order.details.Count == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "单据明细信息不能为空", true); return(htError); } foreach (var orderDetail in order.details) { if (orderDetail.order_detail_id == null || orderDetail.order_detail_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的ID不能为空", true); return(htError); } if (orderDetail.order_id == null || orderDetail.order_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的主单据ID不能为空", true); return(htError); } if (orderDetail.sku_id == null || orderDetail.sku_id.Trim().Length == 0) { htError = ErrorService.OutputError(ErrorCode.A016, order.order_no + "明细项的SKU不能为空", true); return(htError); } } htError["status"] = Utils.GetStatus(true); return(htError); }