Esempio n. 1
0
        public string getTotalJiF(ShopOrder model)
        {
            if (model == null)
            {
                return(string.Empty);
            }
            StringBuilder sb         = new StringBuilder();
            Xml_Shop      shopConfig = DB.XmlConfig.XmlShop;

            //sb.AppendFormat("{0}", model.RealShopping);
            sb.AppendFormat("积分:{0}   ", model.RealScore);
            return(sb.ToString());
        }
Esempio n. 2
0
        public void RefreshConfigShop()
        {
            XMLHelp xmlhelp = new Common.XMLHelp("/XmlConfig/shop.config");

            xmlshop = new Xml_Shop();
            #region 通过反射来取各个字段
            var type = typeof(Xml_Shop);
            var ps   = type.GetProperties();
            foreach (var item in ps)
            {
                var name  = item.Name;
                var value = WebTools.ChangeType(xmlhelp.GetNodeValue(name), item.PropertyType);
                if (value != null && !string.IsNullOrEmpty(value.ToString()))
                {
                    item.SetValue(xmlshop, value);
                }
            }
            #endregion
        }
Esempio n. 3
0
        public void SaveShop(Xml_Shop entity)
        {
            XMLHelp xmlhelp = new Common.XMLHelp("/XmlConfig/shop.config");

            #region 通过反射来取各个字段
            var type = typeof(DataBase.Xml_Shop);
            var ps   = type.GetProperties();
            foreach (var item in ps)
            {
                var name  = item.Name;
                var value = item.GetValue(entity);
                if (value != null)
                {
                    xmlhelp.SetXmlNodeValue("//" + item.Name, value.ToString());
                }
            }
            #endregion
            xmlhelp.SavexmlDocument();
            RefreshConfigShop();
        }
Esempio n. 4
0
        public string GetPostStr(Xml_Shop shopConfig, bool isBao)
        {
            //爆款不参与订单满减
            //if (this.ShopOrderProducts != null)
            //{
            //    ShopProduct first = this.ShopOrderProducts.Select(q => q.ShopProduct).FirstOrDefault();
            //    if (first != null && first.IsBaoKuan())
            //    {
            //        return this.RealCongXiao + "元";
            //    }
            //}

            if (isBao)
            {
                return(this.RealCongXiao + "元");
            }
            if (this.RealShopping >= shopConfig.BaoYouAmount)
            {
                return("免运费");
            }
            return(this.RealCongXiao + "元");
        }
Esempio n. 5
0
        /// <summary>
        /// 购物结算处理
        /// </summary>
        /// <param name="AddressID"></param>
        /// <param name="remark"></param>
        /// <returns></returns>
        public bool Calcute(Member_Info curUser, string orderid, string payPwd)
        {
            using (var tran = BeginTransaction)
            {
                try
                {
                    if (curUser.Pwd2 != Common.CryptHelper.DESCrypt.Encrypt(payPwd))
                    {
                        throw new Exception("支付密码不正确");
                    }
                    Xml_Shop shopConfig = DB.XmlConfig.XmlShop;
                    int      state      = ShopEnum.OrderState.Submit.GetHashCode();
                    var      query      = DB.ShopOrder.Where(q => q.MemberID == curUser.MemberId && q.State == state);
                    if (string.IsNullOrEmpty(orderid) == false)
                    {
                        query = query.Where(q => q.GUID == orderid);
                    }
                    List <ShopOrder> orderList = query.ToList();
                    foreach (var order in orderList)
                    {
                        if (order.State != 1)
                        {
                            throw new Exception("订单不是待支付订单不可支付");
                        }
                        Fin_LiuShui _liushui = new Fin_LiuShui();
                        //1.修改订单状态
                        order.PayState = ShopEnum.OrderPayState.Pay.GetHashCode();
                        order.PayTime  = DateTime.Now;
                        order.State    = ShopEnum.OrderState.Pay.GetHashCode();
                        if (DB.ShopOrder.Update(order) == false)
                        {
                            throw new Exception("修改订单失败");
                        }


                        decimal zong = (order.RealAmount + order.Postage.Value);

                        if (curUser.Commission < zong)
                        {
                            throw new Exception("余额不足");
                        }
                        curUser.Commission = Convert.ToDecimal(curUser.Commission - zong);
                        DB.Fin_LiuShui.AddLS(curUser.MemberId, -zong, "商城下单");


                        if (DB.Member_Info.Update(curUser) == false)
                        {
                            throw new Exception("修改会员信息失败");
                        }


                        DB.Jiang.GiveJiang(DB.Member_Info.FindEntity(order.MemberID), order);
                    }
                    tran.Complete();
                    return(true);
                }
                catch (Exception ex)
                {
                    DB.Rollback();
                    throw ex;
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 确认付款操作
        /// </summary>
        /// <returns></returns>
        public ActionResult DoPay(int addressid, string paytype, string remark, bool isziti, string payPwd)
        {
            JsonHelp json = new JsonHelp(true);

            try
            {
                Xml_Site    config     = DB.XmlConfig.XmlSite;
                Xml_Shop    shopConfig = DB.XmlConfig.XmlShop;
                Member_Info curUser    = User_Shop.GetMember_Info();
                //获取订单信息
                string        orderlist = CookieHelper.GetCookieValue("orderlist");
                List <string> orderList = orderlist.JsonDeserializer <List <string> >();
                if (orderList == null)
                {
                    throw new Exception("订单支付异常");
                }
                if (orderList.Count <= 0)
                {
                    throw new Exception("获取订单信息失败");
                }
                var orderid = orderList.First();
                var query   = DB.ShopOrder.Where(q => q.GUID == orderid).FirstOrDefault();
                if (query.State != 1)
                {
                    throw new Exception("订单不是待支付订单不可支付");
                }

                DB.ShopOrder.UpdateOrderInfo(orderList, addressid, remark, isziti, paytype);

                if (paytype == "余额")
                {
                    //计算处理
                    DB.ShopOrder.Calcute(curUser, orderList.First(), payPwd);
                    CookieHelper.ClearCookie("orderlist");
                }
                else if (paytype == "支付宝")
                {
                    json.ReUrl = "/Member_Mall/Pay/Pay?OrderId=" + orderList.First();//http://tjyy.fabeisha.cn
                    //r.ReUrl = "http://tjyy.fabeisha.cn/Member_Mall/Pay/Pay?BillId=" + r.BillId;//http://www.738600.cn
                }
                else if (paytype == "微信")
                {
                    var    orderModel = DB.ShopOrder.FindEntity(orderList.First());
                    H5Pay  h5Pay      = new H5Pay();
                    var    wxConfig   = WxPayConfig.GetConfig();
                    string clientIP   = wxConfig.GetIp();                                                                                           //获取客户端真实IP
                    var    url        = h5Pay.GetPayUrl(clientIP, orderModel.OrderCode, (orderModel.RealAmount + orderModel.Postage.Value) * 100M); //通过统一下单接口进行H5支付
                                                                                                                                                    //Response.Redirect(url);//跳转到微信支付中间页
                    json.ReUrl = url;
                    //json.ReUrl = "/Member_Mall/Pay/WXPay?OrderId=" + orderList.First();//http://tjyy.fabeisha.cn
                    //r.ReUrl = "/Member_Mall/Pay/WXPay?BillId=" + r.BillId;//http://tjyy.fabeisha.cn
                }

                //3.清空cookie
                CookieHelper.ClearCookie("cart");
                CookieHelper.ClearCookie("total");

                CookieHelper.ClearCookie("traceno");
            }
            catch (Exception ex)
            {
                StringBuilder str   = new StringBuilder();
                Exception     inner = ex;
                while (inner != null)
                {
                    str.AppendLine(inner.Message);
                    inner = inner.InnerException;
                }
                json.IsSuccess = false;
                json.Msg       = str.ToString();

                str.AppendLine("跟踪:" + ex.StackTrace);
                LogHelper.Debug(str.ToString());
            }

            return(Json(json));
        }