Exemple #1
0
        private void GetLoginOn(HttpContext context)
        {
            UsersBLL    bll         = new UsersBLL();
            ReturnModel ReturnModel = new ReturnModel();
            //int IsManager = 0;

            int result = 0;

            try
            {
                string LoginName = context.Request.Params["LoginName"];
                string Password  = context.Request.Params["Password"];
                string CardID    = context.Request.Params["CardID"];
                //string IsRemember = context.Request.Params["IsRemember"];

                if (!string.IsNullOrEmpty(LoginName) && !string.IsNullOrEmpty(Password) && !string.IsNullOrEmpty(CardID))
                {
                    Users  users  = new Users();
                    string PwdKey = LinkFun.getPwdKey();
                    Password    = DESEncrypt.Encrypt(PwdKey, Password);//旧密码加密
                    ReturnModel = bll.VerificationPassword(LoginName, Password, CardID);
                    if (ReturnModel.IsSuccess)
                    {
                        int UserID = (int)ReturnModel.Data;
                        result = UserID;

                        MerchantFrontCookieBLL.SetMerchantFrontCookie(UserID, LoginName);

                        #region 改造前端登录方法存储到缓存
                        UsersBLL bllUsers = new UsersBLL();
                        Users    model    = bllUsers.GetModel(UserID);
                        if (model != null)
                        {
                            string key = ComPage.memberModelCacheDependency + model.UserID;
                            ComPage.SetBWJSCache(key, Guid.NewGuid(), null, DateTime.Now.AddMinutes(ComPage.SafeToDouble(LinkFun.ConfigString("FrontEndCookieExpires", "120"))), TimeSpan.Zero);

                            HttpCookie cookie = new HttpCookie(LinkFun.ConfigString("FrontEndCookieName", "BWJSFrontEnd20180108"));
                            cookie.Expires = DateTime.Now.AddMinutes(ComPage.SafeToDouble(LinkFun.ConfigString("FrontEndCookieExpires", "120")));
                            cookie.Values.Add("Id", HttpContext.Current.Server.UrlEncode(model.UserID.ToString()));

                            System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                            System.Web.HttpContext.Current.Response.AppendCookie(cookie);

                            model.LastAccessIP     = HttpContext.Current.Request.UserHostAddress;
                            model.LoginTimes       = ComPage.SafeToInt(model.LoginTimes) + 1;
                            model.RecordUpdateTime = DateTime.Now;
                            model.IsLogined        = 1;
                            bllUsers.Update(model);
                        }
                        #endregion
                    }
                }
                context.Response.Write(ObjectToJson(ReturnModel));
            }
            catch (Exception ex)
            {
                context.Response.Write(ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// 查询可结算订单列表
        /// </summary>
        static public Object QueryOrderList()
        {
            string result = string.Empty;

            try
            {
                string sEcho         = JsonRequest.GetJsonKeyVal(jsonText, "sEcho");
                int    displayStart  = ComPage.SafeToInt(JsonRequest.GetJsonKeyVal(jsonText, "iDisplayStart"));
                int    displayLength = ComPage.SafeToInt(JsonRequest.GetJsonKeyVal(jsonText, "iDisplayLength"));
                int    pageIndex     = (displayStart / displayLength) + 1;
                int    pageSize      = displayLength;

                #region 获取列表
                StringBuilder where = new StringBuilder();
                where.Append("b.ProductId=0");
                #region 查询条件

                #region 商家
                string UserId = DNTRequest.GetString("UserId");
                if (string.IsNullOrEmpty(UserId))
                {
                    UserId = JsonRequest.GetJsonKeyVal(jsonText, "UserId");
                }
                if (!string.IsNullOrEmpty(UserId))
                {
                    where.AppendFormat(" and a.UserId={0}", UserId);
                }
                #endregion

                #region  道
                string CompanyId = DNTRequest.GetString("CompanyId");
                if (string.IsNullOrEmpty(CompanyId))
                {
                    CompanyId = JsonRequest.GetJsonKeyVal(jsonText, "CompanyId");
                }
                if (!string.IsNullOrEmpty(CompanyId))
                {
                    where.AppendFormat(" and a.CompanyId={0}", CompanyId);
                }
                #endregion

                #region 结算周期
                string StartDate = DNTRequest.GetString("StartDate");
                if (string.IsNullOrEmpty(StartDate))
                {
                    StartDate = JsonRequest.GetJsonKeyVal(jsonText, "StartDate");
                }

                string EndDate = DNTRequest.GetString("EndDate");
                if (string.IsNullOrEmpty(EndDate))
                {
                    EndDate = JsonRequest.GetJsonKeyVal(jsonText, "EndDate");
                }

                if (!string.IsNullOrEmpty(StartDate) && !string.IsNullOrEmpty(EndDate))
                {
                    where.AppendFormat(" and a.CreateDate between '{0} 00:00:00' and '{1} 23:59:59'", StartDate, EndDate);
                }
                else if (string.IsNullOrEmpty(StartDate) && !string.IsNullOrEmpty(EndDate))
                {
                    where.AppendFormat(" and a.CreateDate<='{0} 23:59:59'", EndDate);
                }
                else if (!string.IsNullOrEmpty(StartDate) && string.IsNullOrEmpty(EndDate))
                {
                    where.AppendFormat(" and a.CreateDate>='{0} 00:00:00'", StartDate);
                }
                #endregion

                #endregion

                #region 固定的查询条件
                where.Append(" and a.IsDeleted=0 and a.PayStatus=1 and a.IsSettled=0 and a.IsCancel=0");
                #endregion

                #region 执行sql
                OrderRebateBLL op = new OrderRebateBLL();
                DataTable      dt = op.QueryOrderList(where.ToString());
                #endregion

                #region 结果处理
                double sumOrderMoney    = 0;
                double sumMerchantMoney = 0;
                double sumAgentMoney    = 0;
                double sumHQMoney       = 0;
                double sumNetProfit     = 0;
                double sumApplyMoney    = 0;
                int    totalCount       = 0;
                if (dt != null && dt.Rows.Count > 0)
                {
                    totalCount = dt.Rows.Count;
                    foreach (DataRow dr in dt.Rows)
                    {
                        sumOrderMoney    += Math.Round(ComPage.SafeToDouble(dr["sumOrderMoney"]), 2, MidpointRounding.AwayFromZero);
                        sumMerchantMoney += Math.Round(ComPage.SafeToDouble(dr["sumMerchantMoney"]), 2, MidpointRounding.AwayFromZero);
                        sumAgentMoney    += Math.Round(ComPage.SafeToDouble(dr["sumAgentMoney"]), 2, MidpointRounding.AwayFromZero);
                        sumHQMoney       += Math.Round(ComPage.SafeToDouble(dr["sumHQMoney"]), 2, MidpointRounding.AwayFromZero);
                        sumNetProfit     += Math.Round(ComPage.SafeToDouble(dr["sumNetProfit"]), 2, MidpointRounding.AwayFromZero);
                        int    settlementMethod = ComPage.SafeToInt(dr["SettlementMethod"]);
                        double salesPercentage  = ComPage.SafeToDouble(dr["SalesPercentage"]);
                        int    userType         = ComPage.SafeToInt(dr["UserType"]);
                        switch (settlementMethod)
                        {
                        case 1:
                            #region 销售额百分比分成
                            double salesPercentageMoney = (sumOrderMoney * salesPercentage) / 100;
                            sumApplyMoney += Math.Round(salesPercentageMoney, 2, MidpointRounding.AwayFromZero);
                            #endregion
                            break;

                        case 2:
                            #region 单笔结算分成
                            switch (userType)
                            {
                            case 2:        //经销商
                                sumApplyMoney += Math.Round(sumMerchantMoney, 2, MidpointRounding.AwayFromZero);
                                break;

                            case 3:        //代理商
                                sumApplyMoney += Math.Round(sumAgentMoney, 2, MidpointRounding.AwayFromZero);
                                break;
                            }
                            #endregion
                            break;
                        }
                    }
                }
                #endregion

                #region 拼装返回结果
                var obj = new
                {
                    result           = true,
                    code             = "",
                    msg              = "",
                    sumOrderMoney    = sumOrderMoney,
                    sumMerchantMoney = sumMerchantMoney,
                    sumAgentMoney    = sumAgentMoney,
                    sumHQMoney       = sumHQMoney,
                    sumNetProfit     = sumNetProfit,
                    sumApplyMoney    = sumApplyMoney,
                    recordsTotal     = totalCount,
                    recordsFiltered  = totalCount,
                    data             = ((dt == null) ? (new DataTable()) : (dt)),
                    sEcho            = sEcho
                };
                #endregion

                result = Newtonsoft.Json.JsonConvert.SerializeObject(obj);

                #endregion
            }
            catch (Exception ex)
            {
                result = DNTRequest.GetResultJson(false, "获取结算申请信息异常,", ex.Message);
                ExceptionLogBLL.WriteExceptionLogToDB(ex.ToString());
            }
            return(result);
        }