Пример #1
0
 /// <summary>
 /// 支付选择页面
 /// </summary>
 public ActionResult GoPay()
 {
     using (EFDB db = new EFDB())
     {
         //当前项目
         int Project = LCookie.Project();
         ViewBag.Project = Project;
         Guid MemberGid = LCookie.GetMemberGid();
         if (MemberGid.ToString() != "00000000-0000-0000-0000-000000000000")
         {
             var b = db.Address.Where(l => l.MemberGid == MemberGid && l.Default == 2).FirstOrDefault();
             if (b != null)
             {
                 ViewBag.Addr          = b.Addr;
                 ViewBag.RealName      = b.RealName;
                 ViewBag.ContactNumber = b.ContactNumber;
             }
             else
             {
                 ViewBag.RealName = "请设置你的收货地址";
             }
             //获取用户积分
             ViewBag.Integral = db.Member.Where(l => l.Gid == MemberGid).FirstOrDefault().Integral;
             //获取最低合伙人金额
             //ViewBag.BuyAmount = db.Level.Where(l => l.LV == 6).FirstOrDefault().BuyAmount;
             return(View());
         }
         else
         {
             return(Helper.Redirect("失败", "/Home/Login", "请先登录!"));
         }
     }
 }
Пример #2
0
        public JsonResult SearchData()
        {
            string json = "";

            using (StreamReader sr = new StreamReader(Request.InputStream))
            {
                json = HttpUtility.UrlDecode(sr.ReadLine());
            }
            //解析参数
            JObject paramJson = JsonConvert.DeserializeObject(json) as JObject;
            string  Name      = paramJson["Name"].ToString();

            if (!string.IsNullOrEmpty(Name))
            {
                using (EFDB db = new EFDB())
                {
                    int Project = LCookie.Project();
                    var b       = db.Product.Where(l => l.Show == 1).GroupJoin(db.Classify,
                                                                               l => l.ClassifyGid,
                                                                               j => j.Gid,
                                                                               (l, j) => new
                    {
                        l.Gid,
                        l.Name,
                        l.Sort,
                        l.Picture,
                        l.Price,
                        l.Company,
                        l.Brand,
                        j.FirstOrDefault().Project
                    }).Where(l => l.Project == Project).AsQueryable();
                    if (!string.IsNullOrEmpty(Name))
                    {
                        b = b.Where(l => l.Name.Contains(Name));
                    }
                    int pageindex = Int32.Parse(paramJson["pageindex"].ToString());
                    int pagesize  = Int32.Parse(paramJson["pagesize"].ToString());
                    return(Json(new AjaxResult(new
                    {
                        other = "",
                        count = b.Count(),
                        pageindex,
                        list = b.OrderByDescending(l => l.Sort).Skip(pagesize * (pageindex - 1)).Take(pagesize).ToList()
                    })));
                }
            }
            else
            {
                return(Json(new AjaxResult(new
                {
                    other = "",
                    count = 0,
                    pageindex = 1,
                    list = new string[0]
                })));
            }
        }
Пример #3
0
 /// <summary>
 /// 产品详情
 /// </summary>
 /// <returns>返回调用结果</returns>
 /// <para name="result">200 是成功其他失败</para>
 /// <para name="data">结果提示</para>
 /// <remarks>
 /// 2016-06-30 林建生
 /// </remarks>
 public ActionResult Detail()
 {
     using (EFDB db = new EFDB())
     {
         Guid Gid = Guid.Parse(Request.QueryString["gid"]);
         var  b   = db.Product.Where(l => l.Gid == Gid).FirstOrDefault();
         if (b != null)
         {
             ViewBag.Gid     = b.Gid;
             ViewBag.Prefix  = b.Prefix;
             ViewBag.Name    = b.Name;
             ViewBag.Price   = b.Price;
             ViewBag.Company = b.Company;
             ViewBag.Picture = Help.Product + b.Picture;
             ViewBag.Brand   = b.Brand;
             ViewBag.Content = b.Content;
             b.Number        = b.Number + 1;
             db.SaveChanges();
         }
         ViewBag.RMB   = 0;
         ViewBag.Stock = "";
         if (LCookie.Project() == 2)
         {
             string ck = LCookie.GetCookie("linjiansheng");
             if (!string.IsNullOrEmpty(ck))
             {
                 Guid    MemberGid = LCookie.GetMemberGid();
                 var     m         = db.Member.Where(l => l.Gid == MemberGid).FirstOrDefault();
                 decimal BuyPrice  = 0;
                 if (m != null)
                 {
                     BuyPrice = m.BuyPrice;
                 }
                 if (string.IsNullOrEmpty(Request.QueryString["MPGid"]))
                 {
                     ViewBag.Stock = b.Stock;
                     //进货价是0就是产品价格X库存,有进货价的话就是进货价X库存
                     //ViewBag.Price = BuyPrice == 0 ? b.Price : BuyPrice * b.Stock;
                     //if (BuyPrice * b.Stock > b.Price)
                     //{
                     //    ViewBag.Price = b.Price;
                     //}
                     ViewBag.Price = ViewBag.RMB = b.Price;
                 }
                 else
                 {
                     //会员出售
                 }
             }
             else
             {
                 return(Helper.Redirect("请先登录", "/Home/Login", "登录查看你的购买价格!"));
             }
         }
     }
     return(View());
 }
Пример #4
0
 public JsonResult ClassifyList()
 {
     using (EFDB db = new EFDB())
     {
         int Project = LCookie.Project();
         return(Json(new AjaxResult(new
         {
             list = db.Classify.Where(l => l.Show == 1 && l.Project == Project).OrderByDescending(l => l.Sort).Select(l => new { l.Gid, l.Name, Count = db.Product.Where(p => p.ClassifyGid == l.Gid).Count() }).Where(l => l.Count != 0).ToList()
         })));
     }
 }
Пример #5
0
 /// <summary>
 /// 会员登录
 /// </summary>
 /// <param name="account">会员帐号</param>
 /// <param name="pwd">会员密码</param>
 /// <returns>返回调用结果</returns>
 /// <para name="result">200 是成功其他失败</para>
 /// <para name="data">结果提示</para>
 /// <remarks>
 /// 2016-06-30 林建生
 /// </remarks>
 public ActionResult Login(string account, string pwd)
 {
     ViewBag.OpenID = LCookie.GetCookie("openid");
     if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(pwd))
     {
         return(View());
     }
     else
     {
         if (account.Length == 11 && account.Substring(0, 1) == "1" && pwd.Length > 5)
         {
             using (EFDB db = new EFDB())
             {
                 string pwdMD5 = MD5.GetMD5ljsheng(pwd);
                 var    b      = db.Member.Where(l => l.Account == account && l.PWD == pwdMD5).OrderBy(l => l.AddTime).FirstOrDefault();
                 if (b != null)
                 {
                     //更新登录时间戳
                     b.LoginIdentifier = LCommon.TimeToUNIX(DateTime.Now);
                     db.SaveChanges();
                     Helper.MLogin(b.Gid);
                     string url = LCookie.Project() == 1 ? "Tea" : "Index";
                     return(new RedirectResult("/Home/" + url));
                 }
                 else
                 {
                     return(Helper.Redirect("登录失败!", "history.go(-1);", "帐号或密码错误!"));
                 }
             }
         }
         else
         {
             return(Helper.Redirect("登录失败!", "history.go(-1);", "必须是11位的手机号,密码最少需要6位!"));
         }
     }
 }
Пример #6
0
        public ActionResult Pay()
        {
            string RealName      = Request.Form["RealName"];
            string ContactNumber = Request.Form["ContactNumber"];
            string Address       = Request.Form["Addr"];
            string ProductList   = Request.Form["shopcart"];
            int    PayType       = int.Parse(Request.Form["PayType"]);
            string Remarks       = Request.Form["Remarks"];
            string OrderNo       = Request.Form["OrderNo"];
            //购买会员Gid
            Guid MemberGid = LCookie.GetMemberGid();
            //当前项目
            int Project = LCookie.Project();

            ViewBag.Project = Project;
            //订单信息
            string Order = "";

            //下单返回信息
            if (string.IsNullOrEmpty(OrderNo))
            {
                Order = Helper.CLOrder(4, 0, ProductList, MemberGid, Project, PayType, Remarks, Address, RealName, ContactNumber);
            }
            else
            {
                using (EFDB db = new EFDB())
                {
                    var b = db.Order.Where(l => l.OrderNo == OrderNo).FirstOrDefault();
                    if (b != null && b.PayStatus == 2 && b.ShopGid != MemberGid && b.ShopGid == b.MemberGid)
                    {
                        b.MemberGid = MemberGid;
                        if (db.SaveChanges() == 1)
                        {
                            Order = JsonConvert.SerializeObject(new { body = b.Product, b.Price, b.OrderNo, b.Gid });
                        }
                        else
                        {
                            return(Helper.Redirect("失败", "history.go(-1);", "获取订单失败!"));
                        }
                    }
                    else
                    {
                        return(Helper.Redirect("失败", "history.go(-1);", "下手慢了,被人抢了!"));
                    }
                }
            }
            if (!string.IsNullOrEmpty(Order))
            {
                JObject paramJson = JsonConvert.DeserializeObject(Order) as JObject;
                {
                    if (string.IsNullOrEmpty(paramJson["OrderNo"].ToString()))
                    {
                        return(Helper.Redirect(paramJson["Title"].ToString(), "history.go(-1);", paramJson["Error"].ToString()));
                    }
                    else
                    {
                        switch (PayType)
                        {
                        case 1:
                            return(Alipay(paramJson["OrderNo"].ToString(), paramJson["body"].ToString(), paramJson["TotalPrice"].ToString(), 1));

                        case 2:
                            if (!string.IsNullOrEmpty(LCookie.GetCookie("openid")))
                            {
                                string beizhu = "cl";    //备注
                                //开始微信统一下单
                                JObject j = WX.WXPay.Get_RequestHtml(LCookie.GetCookie("openid"), paramJson["OrderNo"].ToString(), "彩链订单", beizhu, paramJson["TotalPrice"].ToString());
                                return(Json(new AjaxResult(new
                                {
                                    OrderNo = paramJson["OrderNo"].ToString(),
                                    appId = j["appId"].ToString(),
                                    timeStamp = j["timeStamp"].ToString(),
                                    nonceStr = j["nonceStr"].ToString(),
                                    package = j["package"].ToString(),
                                    paySign = j["paySign"].ToString(),
                                    signType = j["signType"].ToString()
                                })));
                            }
                            else
                            {
                                return(Json(new AjaxResult(301, "微信支付,请在微信里打开重新登录进行支付")));
                            }

                        case 3:
                            return(new RedirectResult("/Home/Bank?Type=1&OrderNo=" + paramJson["OrderNo"].ToString() + "&Money=" + paramJson["TotalPrice"].ToString()));

                        default:
                            return(Helper.Redirect("失败", "history.go(-1);", "非法支付"));
                        }
                    }
                }
            }
            else
            {
                return(Helper.Redirect("失败", "history.go(-1);", "提交订单失败"));
            }
        }
Пример #7
0
        /// <summary>
        /// 项目跳转
        /// </summary>
        public new ActionResult Url()
        {
            string url = LCookie.Project() == 1 ? "Tea" : "Index";

            return(new RedirectResult("/Home/" + url));
        }