示例#1
0
        public ActionResult Create([Bind(Include = "Id,Name,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                SystemLog.Add("01", "Tạo mới", db.Categories.ToList().Last().Id.ToString());
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Deleted")] Manufacturer manufacturer)
        {
            if (ModelState.IsValid)
            {
                db.Manufacturers.Add(manufacturer);
                db.SaveChanges();
                SystemLog.Add("02", "Tạo mới", db.Manufacturers.ToList().Last().Id.ToString());
                return(RedirectToAction("Index"));
            }

            return(View(manufacturer));
        }
示例#3
0
        // GET: Admin/Products/Delete/5
        public ActionResult Delete(string id)
        {
            Product product = db.Products.Find(id);

            //string fileName = product.Picture.Split('/')[6];
            //string filePath = Server.MapPath("~/Areas/Admin/Content/images/products/" + fileName);
            //if (System.IO.File.Exists(filePath))
            //    System.IO.File.Delete(filePath);
            product.Deleted = true;
            db.SaveChanges();
            SystemLog.Add("03", "Xóa", id.ToString());
            return(RedirectToAction("Index"));
        }
示例#4
0
        public ActionResult Delete(int id)
        {
            Category category = db.Categories.Find(id);

            if (db.Products.FirstOrDefault(x => x.CategoryId == category.Id) != null)
            {
                TempData["erorMessageAlert"] = "<script>alert('Không thể xóa mục này vì thông tin này đang được dùng ở một nơi khác')</script>";
                return(RedirectToAction("Index"));
            }
            category.Deleted = true;
            db.SaveChanges();
            SystemLog.Add("01", "Xóa", id.ToString());
            return(RedirectToAction("Index"));
        }
示例#5
0
 void Application_Start(object sender, EventArgs e)
 {
     try
     {
         // 在应用程序启动时运行的代码
         TimeWork tw = new TimeWork();//启动定时器
         tw.work_databackup_start();
         tw.work_email_start();
         Event.Initialization();
     }
     catch (Exception ex)
     {
         SystemLog.Add(ex.ToString());
     }
 }
示例#6
0
        /**
         * @Dictionary格式化成Json
         * @return json串数据
         */
        //public string ToJson()
        //{
        //    string jsonStr = JsonMapper.ToJson(m_values);
        //    return jsonStr;
        //}

        /**
         * @values格式化成能在Web页面上显示的结果(因为web页面上不能直接输出xml格式的字符串)
         */
        public string ToPrintStr()
        {
            string str = "";

            foreach (KeyValuePair <string, object> pair in m_values)
            {
                if (pair.Value == null)
                {
                    SystemLog.Add(this.GetType().ToString() + "WxPayData内部含有值为null的字段!");
                    throw new WxPayException("WxPayData内部含有值为null的字段!");
                }

                str += string.Format("{0}={1}<br>", pair.Key, pair.Value.ToString());
            }
            return(str);
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string RefId   = Request.Params["RefId"];
                string ResCode = Request.Params["ResCode"];
                SaleOrderId     = Convert.ToInt64(Request.Params["SaleOrderId"]);
                SaleReferenceId = Convert.ToInt64(Request.Params["SaleReferenceId"]);
                string     OrderID = Convert.ToString(SaleOrderId);
                Lebi_Order order   = B_Lebi_Order.GetModel("id=" + OrderID + "");
                if (order == null)
                {
                    Response.Write("416");
                    //Response.Write("系统错误");
                    Response.End();
                    return;
                }
                Lebi_OnlinePay pay = Shop.Bussiness.Money.GetOnlinePay(order.Code, "behpardakht");
                if (pay == null)
                {
                    Response.Write("系统错误");
                    Response.End();
                    return;
                }
                Lebi_Currency currendy = B_Lebi_Currency.GetModel(pay.Currency_id);

                string Content = "";
                Content += "OrderCode:" + order.Code + "<br>";
                Content += "ResCode:" + ResCode + "<br>";
                Content += "SaleReferenceId:" + SaleReferenceId + "<br>";
                if (yanzheng(pay) == 0)//验证成功
                {
                    Response.Write("0");
                    Order.OnlinePaySuccess(order.Code);
                }
                else
                {
                    Response.Write("416");
                    //SystemLog.Add("paypal验证失败");
                }
            }
            catch (Exception ex)
            {
                //Response.Write("False");
                SystemLog.Add("behpardakht验证异常" + ex.Message);
            }
        }
示例#8
0
 public IHttpActionResult ChangePassword(string password)
 {
     if (string.IsNullOrEmpty(password))
     {
         return(Failure("密码不为空"));
     }
     if (password?.Length <= 8)
     {
         return(Failure("密码必须是大于8位"));
     }
     if (!Regex.IsMatch(password[0].ToString(), @"^[A-Za-z]"))
     {
         return(Failure("密码必须字母开头"));
     }
     try
     {
         if (!UserController.LoginDictionary.ContainsKey(GetCookie("token")))
         {
             return(Logout());
         }
         UserInfo user = UserController.LoginDictionary[GetCookie("token")];
         if (user == null)
         {
             return(Logout());
         }
         var us = UserInfo.GetOne(user.ID);
         us.Password = AESAlgorithm.Encrypto(password);
         UserInfo.Update(us);
         SystemLog.Add(new SystemLog
         {
             Action       = "Logout",
             LogContent   = user.Name + "-更新密码",
             CreateTime   = DateTime.Now,
             UserID       = user.ID,
             RoleID       = user.RoleID,
             DepartmentID = user.DepartmentID,
             ClientIP     = GetIP(),
             UserName     = user.Name,
             RealName     = user.RealName
         });
         return(Success());
     }catch (Exception ex)
     {
         logger.Error(ex);
         return(Failure("修改失败"));
     }
 }
示例#9
0
        public IHttpActionResult AddDepartment(Department depart)
        {
            try
            {
                string valiate = ValiateDepartmentModel(depart);
                if (!string.IsNullOrEmpty(valiate))
                {
                    return(Failure(valiate));
                }

                if (Department.GetOne(depart.Name) != null)
                {
                    return(Failure("该部门已经存在"));
                }


                if (!UserController.LoginDictionary.ContainsKey(GetCookie("token")))
                {
                    return(Logout());
                }
                UserInfo userCookie = UserController.LoginDictionary[GetCookie("token")];
                if (userCookie == null)
                {
                    return(Logout());
                }
                SystemLog.Add(new SystemLog
                {
                    Action       = "AddDepartment",
                    LogContent   = userCookie.Name + "-新增部门-" + depart.Name,
                    CreateTime   = DateTime.Now,
                    UserID       = userCookie.ID,
                    RoleID       = userCookie.RoleID,
                    DepartmentID = userCookie.DepartmentID,
                    ClientIP     = GetIP(),
                    UserName     = userCookie.Name,
                    RealName     = userCookie.RealName
                });
                Department.Add(depart);
                return(Success(true));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(Failure("新增失败"));
            }
        }
示例#10
0
        public ActionResult Restore(int id)
        {
            Category category = db.Categories.Find(id);

            if (!category.Deleted)
            {
                TempData["erorMessageAlert"] = "<script>alert('Mục này chưa bị xóa')</script>";
                return(RedirectToAction("Details", new { id = id }));
            }
            else
            {
                category.Deleted = false;
                db.SaveChanges();
                SystemLog.Add("01", "Khôi phục", id.ToString());
                TempData["erorMessageAlert"] = "<script>alert('Khôi phục dữ liệu thành công')</script>";
                return(RedirectToAction("Details", new { id = id }));
            }
        }
示例#11
0
        public ActionResult Restore(string id)
        {
            Product product = db.Products.Find(id);

            if (!product.Deleted)
            {
                TempData["erorMessageAlert"] = "<script>alert('Mục này chưa bị xóa')</script>";
                return(RedirectToAction("Details", new { id = id }));
            }
            else
            {
                product.Deleted = false;
                db.SaveChanges();
                SystemLog.Add("03", "Khôi phục", id.ToString());
                TempData["erorMessageAlert"] = "<script>alert('Khôi phục dữ liệu thành công')</script>";
                return(RedirectToAction("Details", new { id = id }));
            }
        }
示例#12
0
        public ActionResult Edit(Product product, HttpPostedFileBase pictureFile)
        {
            if (pictureFile != null)
            {
                pictureFile.SaveAs(Server.MapPath("~/Areas/Admin/Content/images/products/" + product.Id + ".jpg"));
            }
            if (ModelState.IsValid)
            {
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                SystemLog.Add("03", "Sửa", product.Id.ToString());
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId     = new SelectList(db.Categories.Where(x => !x.Deleted), "Id", "Name");
            ViewBag.ManufacturerId = new SelectList(db.Manufacturers.Where(x => !x.Deleted), "Id", "Name");
            return(View(product));
        }
示例#13
0
 public ActionResult Edit(HttpPostedFileBase pictureFile, News news)
 {
     if (pictureFile != null)
     {
         pictureFile.SaveAs(Server.MapPath("~/Areas/Admin/Content/images/news/news-" + news.Id + ".jpg"));
     }
     if (ModelState.IsValid)
     {
         var uNews = db.News.Find(news.Id);
         uNews.Title   = news.Title;
         uNews.Content = news.Content;
         uNews.Brief   = news.Brief;
         db.SaveChanges();
         SystemLog.Add("04", "Sửa", news.Id.ToString());
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "Id", "Name", news.UserId);
     return(View(news));
 }
示例#14
0
        /**
         * @Dictionary格式转化成url参数格式
         * @ return url格式串, 该串不包含sign字段值
         */
        public string ToUrl()
        {
            string buff = "";

            foreach (KeyValuePair <string, object> pair in m_values)
            {
                if (pair.Value == null)
                {
                    SystemLog.Add(this.GetType().ToString() + "WxPayData内部含有值为null的字段!");
                    throw new WxPayException("WxPayData内部含有值为null的字段!");
                }

                if (pair.Key != "sign" && pair.Value.ToString() != "")
                {
                    buff += pair.Key + "=" + pair.Value + "&";
                }
            }
            buff = buff.Trim('&');
            return(buff);
        }
示例#15
0
 public IHttpActionResult DeleteCabinetByMac(string mac)
 {
     if (string.IsNullOrEmpty(mac))
     {
         return(Failure("未指定保险柜"));
     }
     try
     {
         if (!UserController.LoginDictionary.ContainsKey(GetCookie("token")))
         {
             return(Logout());
         }
         UserInfo userCookie = UserController.LoginDictionary[GetCookie("token")];
         if (userCookie == null)
         {
             return(Logout());
         }
         SystemLog.Add(new SystemLog
         {
             Action       = "DeleteCabinet",
             LogContent   = userCookie.Name + "-删除保险柜-" + mac,
             CreateTime   = DateTime.Now,
             UserID       = userCookie.ID,
             RoleID       = userCookie.RoleID,
             DepartmentID = userCookie.DepartmentID,
             ClientIP     = GetIP(),
             UserName     = userCookie.Name,
             RealName     = userCookie.RealName
         });
         if (Cabinet.Delete(mac))
         {
             return(Success(true));
         }
         return(Failure("删除失败"));
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         return(Failure("删除失败"));
     }
 }
示例#16
0
        /// <summary>
        /// 获得TOKEN
        /// https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx7374191e442b14ef&secret=c2f9f7d4a6985b2dd0194a86b2254d8c
        /// </summary>
        /// <returns></returns>
        public Model.weixin.token GetToken()
        {
            //if (EndTime > DateTime.Now)
            //    return tokenmodel;
            string               url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + appkey;
            StringBuilder        sb  = new StringBuilder();
            string               str = Get(url);
            JavaScriptSerializer jss = new JavaScriptSerializer();

            try
            {
                tokenmodel = jss.Deserialize <Model.weixin.token>(str);
                EndTime    = System.DateTime.Now.AddSeconds(tokenmodel.expires_in);
                return(tokenmodel);
            }
            catch (Exception ex)
            {
                SystemLog.Add("微信获得TOKEN异常:" + ex.ToString());
                return(new Model.weixin.token());
            }
        }
示例#17
0
        /// <summary>
        /// 接收从微信支付后台发送过来的数据并验证签名
        /// </summary>
        /// <returns>微信支付后台返回的数据</returns>
        public WxPayData GetNotifyData()
        {
            //接收从微信后台POST过来的数据
            System.IO.Stream s = page.Request.InputStream;
            int count          = 0;

            byte[]        buffer  = new byte[1024];
            StringBuilder builder = new StringBuilder();

            while ((count = s.Read(buffer, 0, 1024)) > 0)
            {
                builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
            }
            s.Flush();
            s.Close();
            s.Dispose();

            //Log.Info(this.GetType().ToString(), "Receive data from WeChat : " + builder.ToString());

            //转换数据格式并验证签名
            WxPayData data = new WxPayData();

            try
            {
                data.FromXml(builder.ToString());
            }
            catch (WxPayException ex)
            {
                //若签名错误,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", ex.Message);
                SystemLog.Add(this.GetType().ToString() + "Sign check error : " + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }

            //Log.Info(this.GetType().ToString(), "Check sign success");
            return(data);
        }
示例#18
0
        public ActionResult UpdateStatus(string id, bool disabled)
        {
            string eror = "";
            User   user = db.Users.Find(id);

            if (user == null)
            {
                eror = "Tài khoản không hợp lệ";
            }
            else if (user.Disabled == disabled)
            {
                eror = (disabled) ? "Tài khoản đang bị vô hiệu hóa":"Tài khoản đang được kích hoạt";
            }
            else
            {
                user.Disabled = disabled;
                db.SaveChanges();
                SystemLog.Add("07", disabled ? "Vô hiệu hóa" : "Kích hoạt", id);
                db.SaveChanges();
            }
            return(Content(eror));
        }
示例#19
0
        public IHttpActionResult DeleteUser(int UserID)
        {
            if (UserID == 0)
            {
                return(Failure("未指定用户"));
            }

            try
            {
                if (!UserController.LoginDictionary.ContainsKey(GetCookie("token")))
                {
                    return(Logout());
                }
                UserInfo userCookie = UserController.LoginDictionary[GetCookie("token")];
                if (userCookie == null)
                {
                    return(Logout());
                }
                SystemLog.Add(new SystemLog
                {
                    Action       = "DeleteUser",
                    LogContent   = userCookie.Name + "-删除用户-" + UserID,
                    CreateTime   = DateTime.Now,
                    UserID       = userCookie.ID,
                    RoleID       = userCookie.RoleID,
                    DepartmentID = userCookie.DepartmentID,
                    ClientIP     = GetIP(),
                    UserName     = userCookie.Name,
                    RealName     = userCookie.RealName
                });
                UserInfo.Delete(UserID);
                return(Success(true));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(Failure("删除失败"));
            }
        }
示例#20
0
        public void UpdateTable(string sql)
        {
            try
            {
                if (LB.DataAccess.DB.BaseUtilsInstance.DBType == "mysql")
                {
                    sql = sql.Replace("nvarchar", "varchar");
                    sql = sql.Replace("ntext", "text");
                    sql = sql.Replace("numeric", "decimal");
                    sql = sql.Replace("IDENTITY(1,1)", "AUTO_INCREMENT");
                    sql = sql.Replace("IDENTITY(1, 1) ", "AUTO_INCREMENT");

                    sql = sql.Replace("[", "`");
                    sql = sql.Replace("]", "`");
                    sql = sql.Replace("int ", "int(10) ");
                }

                Common.ExecuteSql(sql);
            }
            catch (Exception ex) {
                SystemLog.Add(ex.ToString() + "\r\n\r\n" + sql);
            }
        }
示例#21
0
        /**
         * 生成扫描支付模式一URL
         * @param productId 商品ID
         * @return 模式一URL
         */
        public static string GetPrePayUrl(string productId)
        {
            Lebi_Order order = B_Lebi_Order.GetModel("id = lbsql{" + productId + "}");

            if (order == null)
            {
                throw new WxPayException("订单不存在!");
                SystemLog.Add("weixinpay-NativePay" + "productId : " + productId);
            }
            WxPayConfig conf = new WxPayConfig(order);
            WxPayData   data = new WxPayData();

            data.SetValue("appid", conf.APPID);                     //公众帐号id
            data.SetValue("mch_id", conf.MCHID);                    //商户号
            data.SetValue("time_stamp", TenpayUtil.getTimestamp()); //时间戳
            data.SetValue("nonce_str", TenpayUtil.getNoncestr());   //随机字符串
            data.SetValue("product_id", productId);                 //商品ID
            data.SetValue("sign", data.MakeSign(order));            //签名
            string str = ToUrlParams(data.GetValues());             //转换为URL串
            string url = "weixin://wxpay/bizpayurl?" + str;

            return(url);
        }
示例#22
0
        /**
         * @将Dictionary转成xml
         * @return 经转换得到的xml串
         * @throws WxPayException
         **/
        public string ToXml()
        {
            //数据为空时不能转化为xml格式
            if (0 == m_values.Count)
            {
                //SystemLog.Add(this.GetType().ToString() = "WxPayData数据为空!");
                throw new WxPayException("WxPayData数据为空!");
            }

            string xml = "<xml>";

            foreach (KeyValuePair <string, object> pair in m_values)
            {
                //字段值不能为null,会影响后续流程
                if (pair.Value == null)
                {
                    SystemLog.Add(this.GetType().ToString() + "WxPayData内部含有值为null的字段!");
                    throw new WxPayException("WxPayData内部含有值为null的字段!");
                }

                if (pair.Value.GetType() == typeof(int))
                {
                    xml += "<" + pair.Key + ">" + pair.Value + "</" + pair.Key + ">";
                }
                else if (pair.Value.GetType() == typeof(string))
                {
                    xml += "<" + pair.Key + ">" + "<![CDATA[" + pair.Value + "]]></" + pair.Key + ">";
                }
                else//除了string和int类型不能含有其他数据类型
                {
                    //SystemLog.Add(this.GetType().ToString(), "WxPayData字段数据类型错误!");
                    throw new WxPayException("WxPayData字段数据类型错误!");
                }
            }
            xml += "</xml>";
            return(xml);
        }
示例#23
0
        /// <summary>
        /// 条形码
        /// </summary>
        public void ProductCode()
        {
            string lang = RequestTool.RequestSafeString("lang", "CN");
            string Code = RequestTool.RequestSafeString("Code");
            JavaScriptSerializer jss = new JavaScriptSerializer();
            LBAPI        api         = new LBAPI();
            Lebi_Product pro         = B_Lebi_Product.GetModel("Code=lbsql{'" + Code + "'}");

            if (pro != null)
            {
                api.data = Shop.Bussiness.ThemeUrl.GetURL("P_Product", pro.id.ToString(), "", lang);
                api.msg  = "OK";
                //Response.Write("{\"msg\":\"OK\",\"url\":\"" + Shop.Bussiness.ThemeUrl.GetURL("P_Product", pro.id.ToString(), "", lang) + "\"}");
            }
            else
            {
                api.msg = Tag("未找到商品");
                //Response.Write("{\"msg\":\"" + Tag("未找到商品") + "\"}");
            }
            string json = jss.Serialize(api);

            SystemLog.Add(json);
            Response.Write(json);
        }
示例#24
0
        /**
         *
         * 检测签名是否正确
         * 正确返回true,错误抛异常
         */
        public bool CheckSign()
        {
            string     Order_id = GetValue("product_id").ToString();
            Lebi_Order order    = B_Lebi_Order.GetModel("id = lbsql{" + Order_id + "}");

            if (order == null)
            {
                throw new WxPayException("订单不存在!");
            }
            //如果没有设置签名,则跳过检测
            if (!IsSet("sign"))
            {
                SystemLog.Add(this.GetType().ToString() + "WxPayData签名存在但不合法!");
                throw new WxPayException("WxPayData签名存在但不合法!");
            }
            //如果设置了签名但是签名为空,则抛异常
            else if (GetValue("sign") == null || GetValue("sign").ToString() == "")
            {
                SystemLog.Add(this.GetType().ToString() + "WxPayData签名存在但不合法!");
                throw new WxPayException("WxPayData签名存在但不合法!");
            }

            //获取接收到的签名
            string return_sign = GetValue("sign").ToString();

            //在本地计算新的签名
            string cal_sign = MakeSign(order);

            if (cal_sign == return_sign)
            {
                return(true);
            }

            SystemLog.Add(this.GetType().ToString() + "WxPayData签名验证错误!");
            throw new WxPayException("WxPayData签名验证错误!");
        }
示例#25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count == 0)
            {
                sPara = GetRequestGet();
            }
            //商户订单号
            string     out_trade_no = RequestTool.RequestString("out_trade_no");
            Lebi_Order order        = B_Lebi_Order.GetModel("Code=lbsql{'" + out_trade_no + "'}");

            if (order == null)
            {
                SystemLog.Add(out_trade_no + "系统错误");
                Response.Write("系统错误");
                Response.End();
                return;
            }
            if (sPara.Count > 0)//判断是否有带返回参数
            {
                Notify aliNotify    = new Notify(order);
                bool   verifyResult = aliNotify.Verify(sPara, RequestTool.RequestString("notify_id"), RequestTool.RequestString("sign"));

                if (verifyResult)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码


                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                    //支付宝交易号

                    string trade_no = RequestTool.RequestString("trade_no");

                    //交易状态
                    string trade_status = RequestTool.RequestString("trade_status");


                    if (trade_status == "TRADE_FINISHED")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序

                        //注意:
                        //该种交易状态只在两种情况下出现
                        //1、开通了普通即时到账,买家付款成功后。
                        //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。

                        Order.PaySuccess(out_trade_no, trade_no);
                        Response.Write("success");  //请不要修改或删除
                    }
                    else if (trade_status == "TRADE_SUCCESS")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序

                        //注意:
                        //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。
                        Order.PaySuccess(out_trade_no, trade_no);
                        Response.Write("success");  //请不要修改或删除
                    }
                    else
                    {
                        Response.Write("fail");
                        SystemLog.Add("单号付款" + trade_no + " | " + trade_status);
                    }
                    //Response.Write("success");
                    //Order.PaySuccess(out_trade_no, trade_no);
                }
                else//验证失败
                {
                    Response.Write("fail");
                    SystemLog.Add(out_trade_no + "验证fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
                SystemLog.Add(out_trade_no + "无通知参数");
            }
        }
示例#26
0
        protected int sid = 0;//结算供应商ID
        public void LoadPage()
        {
            sid    = RequestTool.RequestInt("sid", 0);
            basket = new Basket(sid);
            bool offlinepay = false;

            if (CurrentUser.Transport_Price_id == "")
            {
                CurrentUser.Transport_Price_id = "0";
            }
            List <Lebi_Transport_Price> prices = B_Lebi_Transport_Price.GetList("id in (" + CurrentUser.Transport_Price_id + ")", "");

            if (prices.Count == 0)
            {
                Response.Write(Tag("请先选择配送方式"));
                Response.End();
                return;
            }
            Lebi_Transport_Price currenttranprice = new Lebi_Transport_Price();
            Lebi_Transport       currenttran      = new Lebi_Transport();

            foreach (Lebi_Transport_Price price in prices)
            {
                currenttran = B_Lebi_Transport.GetModel(price.Transport_id);
                if (currenttran == null)
                {
                    Response.Write(Tag("请先选择配送方式"));
                    Response.End();
                    return;
                }
                if (basket.cashsupplierid == price.Supplier_id)//商城收款,供应商发货的情况必须用在线支付,所以下永远匹配不上。
                {
                    currenttranprice = price;
                }
            }
            string where = "IsUsed=1";
            //if (prices.Count > 1 || currenttranprice.Supplier_id > 0 || basket.cashsupplierid > 0)
            //{
            //    where += " and Code='OnlinePay'";
            //}
            //else
            //{
            if (currenttran.IsCanofflinePay == 1 && currenttranprice.IsCanofflinePay == 1)
            {
                offlinepay = true;
            }
            if (offlinepay == false)
            {
                where += " and Code!='OfflinePay'";
            }
            //}
            string onpaywhere = "IsUsed=1 and parentid=0 and ','+Language_ids+',' like '%," + CurrentLanguage.id + ",%'";

            //string useragent=Request.UserAgent.ToString().ToLower();
            //if (!useragent.Contains("micromessenger"))
            //{
            //    onpaywhere += " and Code!='weixinpay'";
            //}
            if (CurrentSite.IsMobile == 1)
            {
                onpaywhere += " and (showtype='' or showtype like '%wap%')";
            }
            else
            {
                onpaywhere += " and (showtype='' or showtype like '%web%')";
            }
            SystemLog.Add(onpaywhere);
            pays = B_Lebi_Pay.GetList(where, "Sort desc");
            if ((CurrentUser.Pay_id == 0 || pays.Count == 1) && pays.Count > 0)
            {
                CurrentUser.Pay_id = pays.FirstOrDefault().id;
            }
            onpays = B_Lebi_OnlinePay.GetList(onpaywhere, "Sort desc");
            if (onpays.Count == 0)
            {
                CurrentUser.OnlinePay_id = 0;
            }
            else
            {
                if (CurrentUser.OnlinePay_id == 0 || onpays.Count == 1)
                {
                    CurrentUser.OnlinePay_id = onpays.FirstOrDefault().id;
                }
                else
                {
                    bool flag = false;
                    foreach (Lebi_OnlinePay p in onpays)
                    {
                        if (p.id == CurrentUser.OnlinePay_id)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (flag == false)
                    {
                        CurrentUser.OnlinePay_id = onpays.FirstOrDefault().id;
                    }
                }
            }
        }
示例#27
0
        public IHttpActionResult EditCabinet(Cabinet cabinet)
        {
            try
            {
                string valiate = ValiateCabinetModel(cabinet);
                if (!string.IsNullOrEmpty(valiate))
                {
                    return(Failure(valiate));
                }
                if (!UserController.LoginDictionary.ContainsKey(GetCookie("token")))
                {
                    return(Logout());
                }
                UserInfo userCookie = UserController.LoginDictionary[GetCookie("token")];
                if (userCookie == null)
                {
                    return(Logout());
                }
                if (cabinet.ID == 0)
                {
                    return(Failure("未指定保险柜"));
                }
                var cab = Cabinet.GetOne(cabinet.ID);
                if (cab == null)
                {
                    return(Failure("未找到指定保险柜"));
                }
                var old = Cabinet.GetByName(cabinet.Name);
                if (old != null && old.ID != cabinet.ID)
                {
                    return(Failure("该名称已经被使用"));
                }

                old = Cabinet.GetByMac(cabinet.AndroidMac);
                if (old != null && old.ID != cabinet.ID)
                {
                    return(Failure("该硬件编码已经被使用"));
                }


                SystemLog.Add(new SystemLog
                {
                    Action       = "EditCabinet",
                    LogContent   = userCookie.Name + "-编辑保险柜-" + cabinet.ID,
                    CreateTime   = DateTime.Now,
                    UserID       = userCookie.ID,
                    RoleID       = userCookie.RoleID,
                    DepartmentID = userCookie.DepartmentID,
                    ClientIP     = GetIP(),
                    UserName     = userCookie.Name,
                    RealName     = userCookie.RealName
                });
                cab.Address              = cabinet.Address;
                cab.AndroidMac           = cabinet.AndroidMac;
                cab.Code                 = cabinet.Code;
                cab.DepartmentID         = cabinet.DepartmentID;
                cab.FirstContact         = cabinet.FirstContact;
                cab.FirstContactPassword = AESAlgorithm.Encrypto(cabinet.FirstContactPassword);
                cab.FirstContactPhone    = cabinet.FirstContactPhone;

                cab.IP            = cabinet.IP;
                cab.Name          = cabinet.Name;
                cab.NeedConfirm   = cabinet.NeedConfirm;
                cab.Remark        = cabinet.Remark;
                cab.SecondContact = cabinet.SecondContact;

                cab.SecondContactPassword = AESAlgorithm.Encrypto(cabinet.SecondContactPassword);
                cab.SecondContactPhone    = cabinet.SecondContactPhone;

                Cabinet.Update(cab);
                return(Success(true));
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                return(Failure("修改失败"));
            }
        }
示例#28
0
        /// <summary>
        /// 用户注册
        /// </summary>
        public void User_Reg()
        {
            string url = "";
            bool   Checkmobilephone = false;
            bool   Checkemail       = false;
            string MobilePhone      = RequestTool.RequestSafeString("MobilePhone");
            string Email            = RequestTool.RequestSafeString("Email");

            try
            {
                Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                if (defaultlevel == null)
                {
                    defaultlevel = new Lebi_UserLevel();
                }
                if (defaultlevel.RegisterType == 0) //关闭注册
                {
                    Response.Write("{\"msg\":\"" + Tag("会员注册已关闭") + "\"}");
                    return;
                }
                if (SYS.UserRegCheckedType.Contains("mobilephone"))
                {
                    Checkmobilephone = true;
                    string MobilePhone_checkcode = RequestTool.RequestSafeString("MobilePhone_checkcode");
                    try
                    {
                        string phonecheckcode = (string)Session["phonecheckcode"];//phonecheckcode
                        if (phonecheckcode != (MobilePhone + MobilePhone_checkcode))
                        {
                            Response.Write("{\"msg\":\"" + Tag("手机验证码错误") + phonecheckcode + "(" + MobilePhone + MobilePhone_checkcode + ")\"}");
                            return;
                        }
                        if (SYS.IsMobilePhoneMutiReg == "0")
                        {
                            int phonecount = B_Lebi_User.Counts("MobilePhone=lbsql{'" + MobilePhone + "'} and IsCheckedMobilePhone=1");
                            if (phonecount > 0)
                            {
                                Response.Write("{\"msg\":\"" + Tag("此手机号已经注册") + "\"}");
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write("{\"msg\":\"" + Tag("手机验证码错误") + "" + ex.ToString() + "\"}");
                        return;
                    }
                }
                if (SYS.UserRegCheckedType.Contains("email"))
                {
                    Checkemail = true;
                    string Email_checkcode = RequestTool.RequestSafeString("Email_checkcode");
                    try
                    {
                        string emailcheckcode = (string)Session["emailcheckcode"];
                        if (emailcheckcode != (Email + Email_checkcode))
                        {
                            Response.Write("{\"msg\":\"" + Tag("邮件验证码错误") + "\"}");
                            return;
                        }
                        int emailcount = B_Lebi_User.Counts("Email=lbsql{'" + Email + "'} and IsCheckedEmail=1");
                        if (emailcount > 0)
                        {
                            Response.Write("{\"msg\":\"" + Tag("此邮箱已经注册") + "\"}");
                            return;
                        }
                    }
                    catch
                    {
                        Response.Write("{\"msg\":\"" + Tag("邮件验证码错误") + "\"}");
                        return;
                    }
                }
                if (SYS.Verifycode_UserRegister == "1")
                {
                    if (Checkemail == false && Checkmobilephone == false)
                    {
                        string verifycode = RequestTool.RequestString("verifycode");
                        if (CurrentCheckCode != verifycode)
                        {
                            Response.Write("{\"msg\":\"" + Tag("验证码错误") + "\"}");
                            return;
                        }
                    }
                }
                string UserName = RequestTool.RequestSafeString("UserName");
                string PWD      = RequestTool.RequestSafeString("Password");
                string token    = RequestTool.RequestString("token");
                if (UserName == "")
                {
                    Response.Write("{\"msg\":\"" + Tag("请输入用户名") + "\"}");
                    return;
                }
                if (PWD == "")
                {
                    Response.Write("{\"msg\":\"" + Tag("请输入密码") + "\"}");
                    return;
                }
                //检查用户名存在
                int count = B_Lebi_User.Counts("UserName=lbsql{'" + UserName + "'}");
                if (count > 0)
                {
                    Response.Write("{\"msg\":\"" + Tag("用户名已注册") + "\"}");
                    return;
                }
                var nv           = CookieTool.GetCookie("parentuser");
                int parentuserid = 0;
                if (!string.IsNullOrEmpty(nv.Get("id")))
                {
                    string parentuserid_ = nv.Get("id");
                    int.TryParse(parentuserid_, out parentuserid);
                }
                if (parentuserid == 0)
                {
                    parentuserid = RequestTool.RequestInt("parentuserid", 0);
                }
                if (parentuserid != 0)
                {
                    Lebi_User puser = B_Lebi_User.GetModel("id=" + parentuserid + "");
                    if (puser != null)
                    {
                        if (defaultlevel.RegisterType == 2)  //邀请注册
                        {
                            Lebi_UserLevel userlevel = B_Lebi_UserLevel.GetModel(puser.UserLevel_id);
                            if (userlevel != null)
                            {
                                if (userlevel.RegisterType == 0) //关闭注册
                                {
                                    Response.Write("{\"msg\":\"" + Tag("会员注册已关闭") + "\"}");
                                    return;
                                }
                            }
                        }
                        if (SYS.IsUsedAgent == "1")
                        {
                            if (Shop.LebiAPI.Service.Instanse.Check("plugin_agent"))
                            {
                                parentuserid = puser.id;
                                puser.Count_sonuser++;
                                B_Lebi_User.Update(puser);
                            }
                        }
                    }
                }
                else
                {
                    if (defaultlevel.RegisterType == 2)  //邀请注册
                    {
                        Response.Write("{\"msg\":\"" + Tag("请输入邀请码") + "\"}");
                        return;
                    }
                }
                Lebi_User model = new Lebi_User();
                B_Lebi_User.SafeBindForm(model);
                model.NickName     = model.UserName;
                model.Password     = EX_User.MD5(PWD);
                model.UserLevel_id = defaultlevel.id;
                model.Time_Reg     = DateTime.Now;
                model.Time_This    = DateTime.Now;
                model.Time_Last    = DateTime.Now;
                model.Count_Login  = 1;
                model.IP_This      = RequestTool.GetClientIP();
                model.IP_Last      = RequestTool.GetClientIP();
                if (Checkemail)
                {
                    model.IsCheckedEmail = 1;
                }
                if (Checkmobilephone)
                {
                    model.IsCheckedMobilePhone = 1;
                }
                model.User_id_parent = parentuserid;
                if (CurrentSite != null)
                {
                    model.Site_id = CurrentSite.id;
                }
                if (CurrentLanguage != null)
                {
                    model.Language = CurrentLanguage.Code;
                }
                model.Area_id = RequestTool.RequestInt("Area_id", 0);
                int DefaultUserEndDays = 0;
                int.TryParse(SYS.DefaultUserEndDays, out DefaultUserEndDays);
                model.Time_End = System.DateTime.Now.AddDays(DefaultUserEndDays);
                Lebi_User user = EX_User.UserReg(model, PWD);
                try
                {
                    //发送邮件
                    if (ShopCache.GetBaseConfig().MailSign.ToLower().Contains("zhuce") || ShopCache.GetBaseConfig().AdminMailSign.ToLower().Contains("register"))
                    {
                        Shop.Bussiness.Email.SendEmail_newuser(user);
                    }
                    //发送短信
                    if (ShopCache.GetBaseConfig().SMS_sendmode.Contains("SMSTPL_newuser") || ShopCache.GetBaseConfig().SMS_sendmode.Contains("SMSTPL_Admin_newuser"))
                    {
                        SMS.SendSMS_newuser(user);
                    }
                }
                catch { }
                url = RequestTool.RequestString("url").Replace("<", "").Replace(">", "");
                if (EX_User.MD5(SYS.InstallCode + url) != token)
                {
                    url = URL("P_Index", "");
                }
                if (url.ToLower().IndexOf("http") > -1 || url.ToLower().IndexOf(URL("P_Register", "").ToLower()) > -1 || url.ToLower().IndexOf(URL("P_Login", "").ToLower()) > -1 || url == "")
                {
                    url = URL("P_Index", "");
                }
                Response.Write("{\"msg\":\"OK\",\"url\":\"" + url + "\"}");
            }
            catch (Exception e)
            {
                SystemLog.Add("User_Reg-" + e.ToString());
            }
        }
示例#29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //创建ResponseHandler实例
            ResponseHandler resHandler = new ResponseHandler(Context);

            //判断签名
            try
            {
                //string return_code = RequestTool.RequestString("return_code");//SUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查看 result_code 来判断
                //string return_msg = RequestTool.RequestString("return_msg");//返回信息,如非空,为错误原因/签名失败/参数格式校验错误
                //string appid = RequestTool.RequestString("appid");
                //string mch_id = RequestTool.RequestString("mch_id");
                //string nonce_str = RequestTool.RequestString("nonce_str");
                //string sign = RequestTool.RequestString("sign");
                //string result_code = RequestTool.RequestString("result_code");//业务结果SUCCESS/FAIL
                //string error_code = RequestTool.RequestString("error_code");
                //string error_code_des = RequestTool.RequestString("error_code_des");
                //string openid = RequestTool.RequestString("openid");
                //string trade_type = RequestTool.RequestString("trade_type");//交易类型
                //string bank_type = RequestTool.RequestString("bank_type");//out_trade_no
                //string total_fee = RequestTool.RequestString("total_fee");
                //string out_trade_no = RequestTool.RequestString("out_trade_no");
                //string attach = RequestTool.RequestString("attach");//商家数据包,原样返回
                //string time_end = RequestTool.RequestString("time_end");
                //string transaction_id = RequestTool.RequestString("transaction_id");//微信支付单号
                #region 协议参数=====================================
                //--------------协议参数--------------------------------------------------------
                //SUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查
                string return_code = resHandler.getParameter("return_code");
                //返回信息,如非空,为错误原因签名失败参数格式校验错误
                string return_msg = resHandler.getParameter("return_msg");
                //微信分配的公众账号 ID
                string appid = resHandler.getParameter("appid");

                //以下字段在 return_code 为 SUCCESS 的时候有返回--------------------------------
                //微信支付分配的商户号
                string mch_id = resHandler.getParameter("mch_id");
                //微信支付分配的终端设备号
                string device_info = resHandler.getParameter("device_info");
                //微信分配的公众账号 ID
                string nonce_str = resHandler.getParameter("nonce_str");
                //业务结果 SUCCESS/FAIL
                string result_code = resHandler.getParameter("result_code");
                //错误代码
                string err_code = resHandler.getParameter("err_code");
                //结果信息描述
                string err_code_des = resHandler.getParameter("err_code_des");

                //以下字段在 return_code 和 result_code 都为 SUCCESS 的时候有返回---------------
                //-------------业务参数---------------------------------------------------------
                //用户在商户 appid 下的唯一标识
                string openid = resHandler.getParameter("openid");
                //用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效
                string is_subscribe = resHandler.getParameter("is_subscribe");
                //JSAPI、NATIVE、MICROPAY、APP
                string trade_type = resHandler.getParameter("trade_type");
                //银行类型,采用字符串类型的银行标识
                string bank_type = resHandler.getParameter("bank_type");
                //订单总金额,单位为分
                string total_fee = resHandler.getParameter("total_fee");
                //货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
                string fee_type = resHandler.getParameter("fee_type");
                //微信支付订单号
                string transaction_id = resHandler.getParameter("transaction_id");
                //商户系统的订单号,与请求一致。
                string out_trade_no = resHandler.getParameter("out_trade_no");
                //商家数据包,原样返回
                string attach = resHandler.getParameter("attach");
                //支 付 完 成 时 间 , 格 式 为yyyyMMddhhmmss,如 2009 年12 月27日 9点 10分 10 秒表示为 20091227091010。时区为 GMT+8 beijing。该时间取自微信支付服务器
                string time_end = resHandler.getParameter("time_end");
                #endregion
                SystemLog.Add("JSAPI微信支付回调payNotifyUrl");
                Lebi_Order order = B_Lebi_Order.GetModel("Code=lbsql{'" + out_trade_no + "'}");
                if (order == null)
                {
                    Response.Write("系统错误");
                    SystemLog.Add("JSAPI微信支付-订单号" + out_trade_no + "不存在");
                    Response.End();
                    return;
                }
                TenpayUtil tu = new TenpayUtil(order);
                //SystemLog.Add(return_code + "|||" + result_code + "|||" + openid + "|||" + mch_id + "|||" + out_trade_no);

                if (return_code == "SUCCESS" && result_code == "SUCCESS")
                {
                    Lebi_User      user = B_Lebi_User.GetModel(order.User_id);
                    Lebi_OnlinePay pay  = B_Lebi_OnlinePay.GetModel("Code='weixinpay' and ','+Language_ids+',' like '%," + order.Language_id + ",%'");
                    if (pay == null)
                    {
                        Log.Add("在线支付接口 weixinpay 配置错误");
                        SystemLog.Add("JSAPI微信支付-接口配置错误");
                        return;
                    }
                    //if (user.bind_weixin_id == openid && pay.UserName == mch_id)
                    //{
                    Order.OnlinePaySuccess(out_trade_no, transaction_id, false);
                    Response.Write(paysuccess());
                    return;
                    //}
                }
                SystemLog.Add("JSAPI微信支付-签名失败");
                Response.Write(payerror("签名失败"));
            }
            catch (Exception ex)
            {
                SystemLog.Add("JSAPI微信支付-参数格式校验错误[" + ex.ToString() + "]");
                Response.Write(payerror("参数格式校验错误"));
            }
        }
示例#30
0
        public override void ProcessNotify()
        {
            WxPayData notifyData = GetNotifyData();

            //检查openid和product_id是否返回
            if (!notifyData.IsSet("openid") || !notifyData.IsSet("product_id"))
            {
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "回调数据异常");
                SystemLog.Add(this.GetType().ToString() + "The data WeChat post is error : " + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }

            //调统一下单接口,获得下单结果
            string     openid     = notifyData.GetValue("openid").ToString();
            string     product_id = notifyData.GetValue("product_id").ToString();
            string     Order_Code = notifyData.GetValue("out_trade_no").ToString();
            Lebi_Order order      = B_Lebi_Order.GetModel("Code = lbsql{'" + Order_Code + "'}");

            if (order == null)
            {
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL Order");
                res.SetValue("return_msg", "统一下单失败");
                SystemLog.Add(this.GetType().ToString() + "UnifiedOrder failure : " + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }
            WxPayData unifiedOrderResult = new WxPayData();

            try
            {
                unifiedOrderResult = UnifiedOrder(openid, product_id);
            }
            catch (Exception ex)//若在调统一下单接口时抛异常,立即返回结果给微信支付后台
            {
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "统一下单失败");
                SystemLog.Add(this.GetType().ToString() + "UnifiedOrder failure : " + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }

            //若下单失败,则立即返回结果给微信支付后台
            if (!unifiedOrderResult.IsSet("appid") || !unifiedOrderResult.IsSet("mch_id") || !unifiedOrderResult.IsSet("prepay_id"))
            {
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "统一下单失败");
                SystemLog.Add(this.GetType().ToString() + "UnifiedOrder failure : " + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }
            WxPayConfig conf = new WxPayConfig(order);
            //统一下单成功,则返回成功结果给微信支付后台
            WxPayData data = new WxPayData();

            data.SetValue("return_code", "SUCCESS");
            data.SetValue("return_msg", "OK");
            data.SetValue("appid", conf.APPID);
            data.SetValue("mch_id", conf.MCHID);
            data.SetValue("nonce_str", WxPayApi.GenerateNonceStr());
            data.SetValue("prepay_id", unifiedOrderResult.GetValue("prepay_id"));
            data.SetValue("result_code", "SUCCESS");
            data.SetValue("err_code_des", "OK");
            data.SetValue("sign", data.MakeSign(order));

            //SystemLog.Add(this.GetType().ToString() + "UnifiedOrder success , send data to WeChat : " + data.ToXml());
            page.Response.Write(data.ToXml());
            page.Response.End();
        }