示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //读取站点配置信息
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(DTKeys.FILE_SITE_XML_CONFING);

            string order_type = DTRequest.GetFormString("pay_order_type"); //订单类型
            string order_no = DTRequest.GetFormString("pay_order_no");
            decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0);
            string subject = DTRequest.GetFormString("pay_subject");
            if (order_no == "" || order_amount == 0 )
            {
                Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"));
                return;
            }
            //检查是否已登录
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel == null)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "login")); //尚未登录
                return;
            }
            if (userModel.amount < order_amount)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "recharge")); //账户的余额不足
                return;
            }

            if (order_type.ToLower() == DTEnums.AmountTypeEnum.BuyGoods.ToString().ToLower()) //购买商品
            {
                BLL.orders bll = new BLL.orders();
                Model.orders model = bll.GetModel(order_no);
                if (model == null)
                {
                    Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,商品订单号不存在!"));
                    return;
                }
                //执行扣取账户金额
                int result = new BLL.amount_log().Add(userModel.id, userModel.user_name, DTEnums.AmountTypeEnum.BuyGoods.ToString(), order_no, model.payment_id, -1 * order_amount, subject, 1);
                if (result > 0)
                {
                    //更改订单状态
                    bool result1 = bll.UpdateField(order_no, "payment_status=2,payment_time='" + DateTime.Now + "'");
                    if (!result1)
                    {
                        Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error"));
                        return;
                    }
                    //扣除积分
                    if (model.point < 0)
                    {
                        new BLL.point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no);
                    }
                    //支付成功
                    Response.Redirect(new Web.UI.BasePage().linkurl("payment1", "succeed", order_type, order_no));
                    return;
                }
            }
            Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,找不到需要支付的订单类型!"));
            return;
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string order_no = DTRequest.GetString("order_no");

            if (order_no.StartsWith("R")) //充值订单
            {
                Model.user_recharge model = new BLL.user_recharge().GetModel(order_no);
                if (model != null && model.status == 1)
                {
                    string resurl = new Web.UI.BasePage().linkurl("payment", "?action=succeed&order_no=" + order_no);
                    Response.Write("{\"status\": 1, \"url\": \"" + resurl + "\"}");
                    return;
                }
            }
            else if (order_no.StartsWith("B")) //商品订单
            {
                Model.orders model = new BLL.orders().GetModel(order_no);
                if (model != null && model.payment_status == 2)
                {
                    string resurl = new Web.UI.BasePage().linkurl("payment", "?action=succeed&order_no=" + order_no);
                    Response.Write("{\"status\": 1, \"url\": \"" + resurl + "\"}");
                    return;
                }
            }
            Response.Write("{\"status\": 0, \"msg\": \"订单未支付成功!\"}");
            return;
        }
示例#3
0
        protected void Getstr()
        {
            int tolcount = 0;
            List <Model.shop_log> list = new List <Model.shop_log>();

            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                //  int state = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidState")).Value);

                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    Model.shop_log shop      = new Model.shop_log();
                    Model.users    userModel = new Web.UI.BasePage().GetUserInfo();
                    shop.user_id = userModel.id;

                    int count;
                    if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtQuantity")).Text.Trim(), out count))
                    {
                        count = 0;
                    }
                    shop.quantity = count;
                    shop.goods_id = this.id;
                    shop.shop_id  = id;
                    list.Add(shop);
                    tolcount = tolcount + count;
                }
            }
            string message = "";

            if (quantity == tolcount)
            {
                BLL.shop_log shop = new BLL.shop_log();
                shop.AddList(list);
                message = "true";
            }
            else
            {
                message = "错误:请与加入购物车数量保持一致";
                ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + message + "');</script>");
                return;
            }
            ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>setData(" + message + "," + quantity + "," + quantity * price + "," + this.id + ");</script>");//后台调用前台JS
        }
示例#4
0
        protected string CombSqlTxt(int _channel_id, int _category_id, string _keywords, string _property)
        {
            StringBuilder strTemp = new StringBuilder();

            Model.manager managerModel = new Web.UI.BasePage().GetManagerInfo();
            //筛选当前旅行社数据  超级管理员与普通管理员不需要筛选
            if (managerModel != null && managerModel.role_type ==3)
            {
                strTemp.Append(" and manager_id=" + managerModel.id);
            }
            //status
            strTemp.Append(" and status=1");
            if (_channel_id > 0)
            {
                strTemp.Append(" and channel_id=" + channel_id);
            }
            if (_category_id > 0)
            {
                strTemp.Append(" and category_id in(select id from dt_category where id=" + _category_id + " and class_list like '%," + _category_id + ",%')");
            }
            _keywords = _keywords.Replace("'", "");
            if (!string.IsNullOrEmpty(_keywords))
            {
                strTemp.Append(" and title like '%" + _keywords + "%'");
            }
            if (!string.IsNullOrEmpty(_property))
            {
                switch (_property)
                {
                    case "isLock":
                        strTemp.Append(" and is_lock=1");
                        break;
                    case "unIsLock":
                        strTemp.Append(" and is_lock=0");
                        break;
                    case "isTop":
                        strTemp.Append(" and is_top=1");
                        break;
                    case "isRed":
                        strTemp.Append(" and is_red=1");
                        break;
                }
            }
            return strTemp.ToString();
        }
示例#5
0
        private bool DoAdd()
        {
            bool result = false;

            Model.shop  model     = new Model.shop();
            BLL.shop    bll       = new BLL.shop();
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            model.address   = txtAddress.Text.Trim();;
            model.user_id   = userModel.id;
            model.shop_name = txtShopName.Text.Trim();
            model.telphone  = txtTelphone.Text.Trim();
            model.city      = txtCity.Text.Trim();
            model.linkman   = txtLinkman.Text.Trim();
            if (bll.Add(model) > 0)
            {
                result = true;
            }
            return(result);
        }
示例#6
0
        private bool DoAdd()
        {
            bool result = false;

            Model.user_address model     = new Model.user_address();
            BLL.user_address   bll       = new BLL.user_address();
            Model.users        userModel = new Web.UI.BasePage().GetUserInfo();
            model.address   = txtAddress.Text;
            model.is_check  = 0;
            model.mobile    = txtMobile.Text.Trim();
            model.telphone  = txtTelphone.Text.Trim();
            model.user_name = userModel.user_name;
            model.nick_name = txtNickName.Text.Trim();
            model.city      = txtCity.Text.Trim();
            model.post_code = txtPost.Text.Trim();
            if (bll.Add(model) > 0)
            {
                result = true;
            }
            return(result);
        }
示例#7
0
        protected string CombSqlTxt(int _channel_id,string _keywords, string _property)
        {
            StringBuilder strTemp = new StringBuilder();

            Model.manager managerModel = new Web.UI.BasePage().GetManagerInfo();
            //筛选当前旅行社数据  超级管理员不需要筛选
            if (managerModel != null && managerModel.role_type != 1)
            {
                strTemp.Append(" and manager_id=" + managerModel.id);
            }

            if (_channel_id > 0)
            {
                strTemp.Append(" and channel_id=" + channel_id);
            }

            _keywords = _keywords.Replace("'", "");
            if (!string.IsNullOrEmpty(_keywords))
            {
                strTemp.Append(" and title like '%" + _keywords + "%'");
            }
            if (!string.IsNullOrEmpty(_property))
            {
                switch (_property)
                {

                    case "isTop":
                        strTemp.Append(" and is_top=1");
                        break;
                    case "isRed":
                        strTemp.Append(" and is_red=1");
                        break;
                }
            }
            return strTemp.ToString();
        }
示例#8
0
 public void ProcessRequest(HttpContext context)
 {
     string sitepath = DTRequest.GetQueryString("site");
     int id = DTRequest.GetQueryInt("id");
     if (string.IsNullOrEmpty(sitepath))
     {
         context.Response.Write("出错了,站点传输参数不正确!");
         return;
     }
     //获得下载ID
     if (id < 1)
     {
         context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
             new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,文件参数传值不正确!"))));
         return;
     }
     //检查下载记录是否存在
     BLL.article_attach bll = new BLL.article_attach();
     if (!bll.Exists(id))
     {
         context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
             new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
         return;
     }
     Model.article_attach model = bll.GetModel(id);
     //检查积分是否足够
     if (model.point > 0)
     {
         //检查用户是否登录
         Model.users userModel = new Web.UI.BasePage().GetUserInfo();
         if (userModel == null)
         {
             //自动跳转URL
             HttpContext.Current.Response.Redirect(new Web.UI.BasePage().getlink(sitepath, new Web.UI.BasePage().linkurl("login")));
         }
         //如果该用户未曾下载过该附件
         if (!bll.ExistsLog(model.id, userModel.id))
         {
             //检查积分
             if (model.point > userModel.point)
             {
                 context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                     new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您的积分不足支付本次下载!"))));
                 return;
             }
             //扣取积分
             int result = new BLL.user_point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下载附件:“" + model.file_name + "”,扣减积分", false);
             //添加下载记录
             if (result > 0)
             {
                 bll.AddLog(userModel.id, userModel.user_name, model.id, model.file_name);
             }
         }
     }
     //下载次数+1
     bll.UpdateField(id, "down_num=down_num+1");
     //检查文件本地还是远程
     if (model.file_path.ToLower().StartsWith("http://"))
     {
         context.Response.Redirect(model.file_path);
         return;
     }
     else
     {
         //取得文件物理路径
         string fullFileName = Utils.GetMapPath(model.file_path);
         if (!File.Exists(fullFileName))
         {
             context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                 new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
             return;
         }
         FileInfo file = new FileInfo(fullFileName);//路径
         context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
         context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
         context.Response.AddHeader("Content-length", file.Length.ToString());
         context.Response.ContentType = "application/pdf";
         context.Response.WriteFile(file.FullName);
         context.Response.End();
     }
 }
示例#9
0
        private void order_save(HttpContext context)
        {
            //获取传参信息===================================
            string hideGoodsJson = Utils.GetCookie(DTKeys.COOKIE_SHOPPING_BUY); //获取商品JSON数据
            string sitepath = DTRequest.GetQueryString("site"); //站点目录
            int book_id = DTRequest.GetFormInt("book_id", 1);
            int payment_id = DTRequest.GetFormInt("payment_id");
            int express_id = DTRequest.GetFormInt("express_id");
            int is_invoice = DTRequest.GetFormInt("is_invoice", 0);
            string accept_name = Utils.ToHtml(DTRequest.GetFormString("accept_name"));
            string province = Utils.ToHtml(DTRequest.GetFormString("province"));
            string city = Utils.ToHtml(DTRequest.GetFormString("city"));
            string area = Utils.ToHtml(DTRequest.GetFormString("area"));
            string address = Utils.ToHtml(DTRequest.GetFormString("address"));
            string telphone = Utils.ToHtml(DTRequest.GetFormString("telphone"));
            string mobile = Utils.ToHtml(DTRequest.GetFormString("mobile"));
            string email = Utils.ToHtml(DTRequest.GetFormString("email"));
            string post_code = Utils.ToHtml(DTRequest.GetFormString("post_code"));
            string message = Utils.ToHtml(DTRequest.GetFormString("message"));
            string invoice_title = Utils.ToHtml(DTRequest.GetFormString("invoice_title"));
            Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); //获取订单配置

            //检查传参信息===================================
            if (string.IsNullOrEmpty(hideGoodsJson))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,无法获取商品信息!\"}");
                return;
            }
            //检查站点目录
            if (string.IsNullOrEmpty(sitepath))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:站点传输参数不正确!\"}");
                return;
            }
            if (express_id == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择配送方式!\"}");
                return;
            }
            if (payment_id == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择支付方式!\"}");
                return;
            }
            Model.express expModel = new BLL.express().GetModel(express_id);
            if (expModel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,配送方式不存在或已删除!\"}");
                return;
            }
            //检查支付方式
            Model.payment payModel = new BLL.payment().GetModel(payment_id);
            if (payModel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,支付方式不存在或已删除!\"}");
                return;
            }
            //检查收货人
            if (string.IsNullOrEmpty(accept_name))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入收货人姓名!\"}");
                return;
            }
            //检查手机和电话
            if (string.IsNullOrEmpty(telphone) && string.IsNullOrEmpty(mobile))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入收货人联系电话或手机!\"}");
                return;
            }
            //检查地区
            if (string.IsNullOrEmpty(province) && string.IsNullOrEmpty(city))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择您所在的省市区!\"}");
                return;
            }
            //检查地址
            if (string.IsNullOrEmpty(address))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入详细的收货地址!\"}");
                return;
            }
            //如果开启匿名购物则不检查会员是否登录
            int user_id = 0;
            int user_group_id = 0;
            string user_name = string.Empty;
            //检查用户是否登录
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel != null)
            {
                user_id = userModel.id;
                user_group_id = userModel.group_id;
                user_name = userModel.user_name;
                //检查是否需要添加会员地址
                if (book_id == 0)
                {
                    Model.user_addr_book addrModel = new Model.user_addr_book();
                    addrModel.user_id=userModel.id;
                    addrModel.user_name=userModel.user_name;
                    addrModel.accept_name = accept_name;
                    addrModel.area = province + "," + city + "," + area;
                    addrModel.address = address;
                    addrModel.mobile = mobile;
                    addrModel.telphone = telphone;
                    addrModel.email = email;
                    addrModel.post_code = post_code;
                    new BLL.user_addr_book().Add(addrModel);
                }
            }
            if (orderConfig.anonymous == 0 && userModel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户尚未登录或已超时!\"}");
                return;
            }
            //获取商品信息==================================
            List<Model.cart_keys> iList = (List<Model.cart_keys>)JsonHelper.JSONToObject<List<Model.cart_keys>>(hideGoodsJson);
            List<Model.cart_items> goodsList = ShopCart.ToList(iList, user_group_id); //商品列表
            Model.cart_total goodsTotal = ShopCart.GetTotal(goodsList); //商品统计
            if (goodsList == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,商品为空,无法结算!\"}");
                return;
            }
            //保存订单=======================================
            Model.orders model = new Model.orders();
            model.order_no = "B" + Utils.GetOrderNumber(); //订单号B开头为商品订单
            model.user_id = user_id;
            model.user_name = user_name;
            model.payment_id = payment_id;
            model.express_id = express_id;
            model.accept_name = accept_name;
            model.area = province + "," + city + "," + area; //省市区以逗号相隔
            model.address = address;
            model.telphone = telphone;
            model.mobile = mobile;
            model.message = message;
            model.email = email;
            model.post_code = post_code;
            model.is_invoice = is_invoice;
            model.payable_amount = goodsTotal.payable_amount;
            model.real_amount = goodsTotal.real_amount;
            model.express_status = 1;
            model.express_fee = expModel.express_fee; //物流费用
            //是否先款后货
            if (payModel.type == 1)
            {
                model.payment_status = 1; //标记未付款
                if (payModel.poundage_type == 1 && payModel.poundage_amount > 0) //百分比
                {
                    model.payment_fee = model.real_amount * payModel.poundage_amount / 100;
                }
                else //固定金额
                {
                    model.payment_fee = payModel.poundage_amount;
                }
            }
            //是否开具发票
            if (model.is_invoice == 1)
            {
                model.invoice_title = invoice_title;
                if (orderConfig.taxtype == 1 && orderConfig.taxamount > 0) //百分比
                {
                    model.invoice_taxes = model.real_amount * orderConfig.taxamount / 100;
                }
                else //固定金额
                {
                    model.invoice_taxes = orderConfig.taxamount;
                }
            }
            //订单总金额=实付商品金额+运费+支付手续费+税金
            model.order_amount = model.real_amount + model.express_fee + model.payment_fee + model.invoice_taxes;
            //购物积分,可为负数
            model.point = goodsTotal.total_point;
            model.add_time = DateTime.Now;
            //商品详细列表
            List<Model.order_goods> gls = new List<Model.order_goods>();
            foreach (Model.cart_items item in goodsList)
            {
                gls.Add(new Model.order_goods { article_id = item.article_id, goods_id = item.goods_id, goods_no = item.goods_no, goods_title = item.title, 
                    img_url = item.img_url, spec_text = item.spec_text, goods_price = item.sell_price, real_price = item.user_price, quantity = item.quantity, point = item.point });
            }
            model.order_goods = gls;
            int result = new BLL.orders().Add(model);
            if (result < 1)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"订单保存发生错误,请联系管理员!\"}");
                return;
            }
            //扣除积分
            if (model.point < 0)
            {
                new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "积分换购,订单号:" + model.order_no, false);
            }
            //删除购物车对应的商品
            Web.UI.ShopCart.Clear(iList);
            //清空结账清单
            Utils.WriteCookie(DTKeys.COOKIE_SHOPPING_BUY, "");
            //提交成功,返回URL
            context.Response.Write("{\"status\":1, \"url\":\""
                + new Web.UI.BasePage().getlink(sitepath, new Web.UI.BasePage().linkurl("payment", "?action=confirm&order_no=" + model.order_no)) + "\", \"msg\":\"恭喜您,订单已成功提交!\"}");
            return;
        }
示例#10
0
 private void cart_goods_add(HttpContext context)
 {
     int article_id = DTRequest.GetFormInt("article_id", 0);
     int goods_id = DTRequest.GetFormInt("goods_id", 0);
     int quantity = DTRequest.GetFormInt("quantity", 1);
     if (article_id == 0)
     {
         context.Response.Write("{\"status\":0, \"msg\":\"您提交的商品参数有误!\"}");
         return;
     }
     //检查商品是否正确
     if (goods_id > 0 && !new BLL.article_goods().Exists(article_id, goods_id))
     {
         context.Response.Write("{\"status\":0, \"msg\":\"您提交的商品参数有误!\"}");
         return;
     }
     //查找会员组
     int group_id = 0;
     Model.users groupModel = new Web.UI.BasePage().GetUserInfo();
     if (groupModel != null)
     {
         group_id = groupModel.group_id;
     }
     //统计购物车
     Web.UI.ShopCart.Add(article_id, goods_id, quantity);
     Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id);
     context.Response.Write("{\"status\":1, \"msg\":\"商品已成功添加到购物车!\", \"quantity\":" + cartModel.total_quantity + ", \"amount\":" + cartModel.real_amount + "}");
     return;
 }
示例#11
0
 private void get_article_goods_info(HttpContext context)
 {
     int article_id = DTRequest.GetInt("article_id", 0);
     string spec_ids = DTRequest.GetString("ids");
     if (article_id == 0)
     {
         context.Response.Write("{\"status\": 0, \"msg\": \"对不起,传输参数不正确!\"}");
         return;
     }
     if (string.IsNullOrEmpty(spec_ids))
     {
         context.Response.Write("{\"status\": 0, \"msg\": \"对不起,传输参数不正确!\"}");
         return;
     }
     //查询商品信息
     Model.article_goods goodsModel = new BLL.article_goods().GetModel(article_id, spec_ids);
     if (goodsModel == null)
     {
         context.Response.Write("{\"status\": 0, \"msg\": \"对不起,暂无查到商品信息!\"}");
         return;
     }
     //查询是否登录,有则查询会员价格
     Model.users userModel = new Web.UI.BasePage().GetUserInfo();
     if (userModel != null)
     {
         //查询会员组价格
         Model.user_group_price userPriceModel = new BLL.user_group_price().GetModel(goodsModel.id, userModel.group_id);
         if (userPriceModel != null)
         {
             goodsModel.sell_price = userPriceModel.price;
         }
         else
         {
             //查询会员组折扣
             Model.user_groups groupModel = new BLL.user_groups().GetModel(userModel.group_id);
             if (groupModel != null)
             {
                 goodsModel.sell_price = goodsModel.sell_price * groupModel.discount / 100;
             }
         }
     }
     //以JSON格式输出商品信息
     context.Response.Write("{\"status\": \"1\", \"id\": \"" + goodsModel.id + "\", \"article_id\": \"" + goodsModel.article_id + "\", \"goods_id\": \"" + goodsModel.id
         + "\", \"goods_no\": \"" + goodsModel.goods_no + "\", \"spec_ids\": \"" + goodsModel.spec_ids + "\", \"spec_text\": \"" + goodsModel.spec_text
         + "\", \"stock_quantity\": \"" + goodsModel.stock_quantity + "\", \"market_price\": \"" + goodsModel.market_price + "\", \"sell_price\": \"" + goodsModel.sell_price + "\"}");
 }
示例#12
0
        Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); //系统配置
        public void ProcessRequest(HttpContext context)
        {
            string sitepath = DTRequest.GetQueryString("site");
            int    id       = DTRequest.GetQueryInt("id");

            if (string.IsNullOrEmpty(sitepath))
            {
                context.Response.Write("出错了,站点传输参数不正确!");
                return;
            }
            //获得下载ID
            if (id == 0)
            {
                context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                        new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,文件参数传值不正确!"))));
                return;
            }
            //检查下载记录是否存在
            BLL.article_attach bll = new BLL.article_attach();
            if (!bll.Exists(id))
            {
                context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                        new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
                return;
            }
            Model.article_attach model = bll.GetModel(id);
            //检查积分是否足够
            if (model.point > 0)
            {
                //检查用户是否登录
                Model.users userModel = new Web.UI.BasePage().GetUserInfo();
                if (userModel == null)
                {
                    //自动跳转URL
                    HttpContext.Current.Response.Redirect(new Web.UI.BasePage().getlink(sitepath, new Web.UI.BasePage().linkurl("login")));
                }
                //如果该用户未曾下载过该附件
                if (!bll.ExistsLog(model.id, userModel.id))
                {
                    //检查积分
                    if (model.point > userModel.point)
                    {
                        context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                                new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您的积分不足支付本次下载!"))));
                        return;
                    }
                    //扣取积分
                    int result = new BLL.user_point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下载附件:“" + model.file_name + "”,扣减积分", false);
                    //添加下载记录
                    if (result > 0)
                    {
                        bll.AddLog(userModel.id, userModel.user_name, model.id, model.file_name);
                    }
                }
            }
            //下载次数+1
            bll.UpdateField(id, "down_num=down_num+1");
            //检查文件本地还是远程
            if (model.file_path.ToLower().StartsWith("http://") || model.file_path.ToLower().StartsWith("https://"))
            {
                var request = System.Net.HttpWebRequest.Create(model.file_path) as System.Net.HttpWebRequest;
                using (var response = request.GetResponse() as System.Net.HttpWebResponse)
                {
                    if (response.StatusCode != System.Net.HttpStatusCode.OK)
                    {
                        context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                                new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
                        return;
                    }
                    byte[] byteData = FileHelper.ConvertStreamToByteBuffer(response.GetResponseStream());
                    context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                        //解决中文乱码
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
                    context.Response.AddHeader("Content-length", byteData.Length.ToString());
                    context.Response.ContentType = "application/octet-stream";
                    context.Response.BinaryWrite(byteData);
                    context.Response.Flush();
                    context.Response.End();
                }
                return;
            }
            else
            {
                //取得文件物理路径
                string fullFileName = Utils.GetMapPath(model.file_path);
                if (!File.Exists(fullFileName))
                {
                    context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                            new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
                    return;
                }
                FileInfo file = new FileInfo(fullFileName);                                                                          //路径
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                        //解决中文乱码
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
                context.Response.AddHeader("Content-length", file.Length.ToString());
                context.Response.ContentType = "application/octet-stream";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }
示例#13
0
 private void cart_goods_add(HttpContext context)
 {
     string goods_id = DTRequest.GetFormString("goods_id");
     int goods_quantity = DTRequest.GetFormInt("goods_quantity", 1);
     if (goods_id == "")
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"您提交的商品参数有误!\"}");
         return;
     }
     //查找会员组
     int group_id = 0;
     Model.users groupModel = new Web.UI.BasePage().GetUserInfo();
     if (groupModel != null)
     {
         group_id = groupModel.group_id;
     }
     //统计购物车
     Web.UI.ShopCart.Add(goods_id, goods_quantity);
     Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id);
     context.Response.Write("{\"msg\":1, \"msgbox\":\"商品已成功添加到购物车!\", \"quantity\":" + cartModel.total_quantity + ", \"amount\":" + cartModel.real_amount + "}");
     return;
 }
示例#14
0
        public void ProcessRequest(HttpContext context)
        {
            int id = DTRequest.GetQueryInt("id");

            //獲得下載ID
            if (id < 1)
            {
                context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出錯啦,參數傳值不正確!"));
                return;
            }
            //檢查下載記錄是否存在
            BLL.download_attach bll = new BLL.download_attach();
            if (!bll.Exists(id))
            {
                context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出錯啦,您要下載的文件不存在或已被刪除!"));
                return;
            }
            Model.download_attach model = bll.GetModel(id);
            //檢查積分是否足夠
            if (model.point > 0)
            {
                //檢查用戶是否登錄
                Model.users userModel = new Web.UI.BasePage().GetUserInfo();
                if (userModel == null)
                {
                    //自動跳轉URL
                    HttpContext.Current.Response.Redirect(new Web.UI.BasePage().linkurl("login"));
                }
                //防止重複扣積分
                string cookie = Utils.GetCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString());
                if (cookie != model.id.ToString())
                {
                    //檢查積分
                    if (model.point > userModel.point)
                    {
                        context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出錯啦,您的積分不足支付本次下載!"));
                        return;
                    }
                    //扣取積分
                    new BLL.point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下載附件:“" + model.title + "”,扣除積分");
                    //寫入Cookie
                    Utils.WriteCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString(), model.id.ToString(), 8640);
                }
            }
            //下載次數+1
            bll.UpdateField(id, "down_num=down_num+1");
            //檢查檔本地還是遠端
            if (model.file_path.ToLower().StartsWith("http://"))
            {
                context.Response.Redirect(model.file_path);
                return;
            }
            else
            {
                //取得檔物理路徑
                string fullFileName = Utils.GetMapPath(model.file_path);
                if (!File.Exists(fullFileName))
                {
                    context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出錯啦,您要下載的文件不存在或已被刪除!"));
                    return;
                }
                FileInfo file = new FileInfo(fullFileName);                                                                      //路徑
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                    //解決中文亂碼
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.title)); //解決中文檔案名亂碼
                context.Response.AddHeader("Content-length", file.Length.ToString());
                context.Response.ContentType = "application/pdf";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }
示例#15
0
        public void ProcessRequest(HttpContext context)
        {
            int id = DTRequest.GetQueryInt("id");

            //获得下载ID
            if (id < 1)
            {
                context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,参数传值不正确哦!"));
                return;
            }
            //检查下载记录是否存在
            BLL.download_attach bll = new BLL.download_attach();
            if (!bll.Exists(id))
            {
                context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
                return;
            }
            Model.download_attach model = bll.GetModel(id);
            //检查积分是否足够
            if (model.point > 0)
            {
                //检查用户是否登录
                Model.users userModel = new Web.UI.BasePage().GetUserInfo();
                if (userModel == null)
                {
                    //自动跳转URL
                    HttpContext.Current.Response.Redirect(new Web.UI.BasePage().linkurl("login"));
                }
                //防止重复扣积分
                string cookie = Utils.GetCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString());
                if (cookie != model.id.ToString())
                {
                    //检查积分
                    if (model.point > userModel.point)
                    {
                        context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您的积分不足支付本次下载!"));
                        return;
                    }
                    //扣取积分
                    new BLL.point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下载附件:“" + model.title + "”,扣减积分");
                    //写入Cookie
                    Utils.WriteCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString(), model.id.ToString(), 8640);
                }
            }
            //下载次数+1
            bll.UpdateField(id, "down_num=down_num+1");
            //检查文件本地还是远程
            if (model.file_path.ToLower().StartsWith("http://"))
            {
                context.Response.Redirect(model.file_path);
                return;
            }
            else
            {
                //取得文件物理路径
                string fullFileName = Utils.GetMapPath(model.file_path);
                if (!File.Exists(fullFileName))
                {
                    context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
                    return;
                }
                FileInfo file = new FileInfo(fullFileName);                                                                      //路径
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                    //解决中文乱码
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.title)); //解决中文文件名乱码
                context.Response.AddHeader("Content-length", file.Length.ToString());
                context.Response.ContentType = "application/pdf";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }
示例#16
0
        private void add_car(HttpContext context)
        {
            int goods_id = DTRequest.GetQueryInt("goods_id");
            int goods_quantity = DTRequest.GetQueryInt("goods_quantity", 1);
            string standard = DTRequest.GetQueryString("standard");
            decimal unit_id = DTRequest.GetQueryDecimal("unit_id", 0);
            if (goods_id <= 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"您提交的商品参数有误!\"}");
                return;
            }
            //查找会员组
            int group_id = 0;
            Model.users groupModel = new Web.UI.BasePage().GetUserInfo();
            if (groupModel != null)
            {
                group_id = groupModel.group_id;
            }
            //规格ID|规格值ID,规格ID|规格值ID
            BLL.standard_price bll_standard_price = new BLL.standard_price();
            string standard_value_ids = "";
            if (!string.IsNullOrEmpty(standard))
            {
                string[] arr_standard = standard.Split(',');
                foreach (string str in arr_standard)
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        if (str.Split('|').Length == 2)
                        {
                            standard_value_ids += str.Split('|')[1] + ",";
                        }
                    }
                }
            }

            int total_quantity = goods_quantity;

            BLL.unit bll_unit = new BLL.unit();
            Model.unit model_unit = bll_unit.GetModel(unit_id);
            if (model_unit != null)
            {
                total_quantity = total_quantity * model_unit.quantity;
            }

            BLL.article bll_article = new BLL.article();
            Model.article model_article = bll_article.GetModel(goods_id);
            if (model_article != null)
            {
                if (model_article.fields["stock_quantity"] != null && model_article.fields["stock_quantity"].ToString() != "")
                {
                    if (Convert.ToInt32(model_article.fields["stock_quantity"]) < total_quantity)
                    {
                        context.Response.Write("{\"status\":0, \"msg\":\"对不起,该商品库存不足,购买失败!\"}");
                        return;
                    }
                }
                else
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该商品库存不足,购买失败!\"}");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(standard_value_ids))
            {
                standard_value_ids = standard_value_ids.Substring(0, standard_value_ids.Length - 1);
                DataTable dt_standard_price = bll_standard_price.GetList("standard_value_ids='" + standard_value_ids + "' and good_id=" + goods_id).Tables[0];
                if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
                {
                    if (Convert.ToInt32(dt_standard_price.Rows[0]["stock_quantity"]) < total_quantity)
                    {
                        context.Response.Write("{\"status\":0, \"msg\":\"对不起,该商品库存不足,购买失败!\"}");
                        return;
                    }
                }
                else
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该商品库存不足,购买失败!\"}");
                    return;
                }
            }

            //统计购物车
            Web.UI.ShopCart.Add(goods_id + "-" + standard + "-" + unit_id, goods_quantity);
            Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id);
            context.Response.Write("{\"status\":1, \"msg\":\"商品已成功添加到购物车!\", \"quantity\":" + cartModel.total_quantity + ", \"amount\":" + cartModel.real_amount + "}");
            return;
        }
示例#17
0
        private void meal_into_shopping(HttpContext context)
        {
            int meal_id = DTRequest.GetQueryInt("meal_id");
            BLL.meal bll_meal = new BLL.meal();
            Model.meal model_meal = bll_meal.GetModel(meal_id);
            if (model_meal == null)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"该套餐不存在或已删除!\"}");
                return;
            }
            List<string> shopping_key = new List<string>();
            bool quantity_ture = true;
            bool good_true = true;

            //查找会员组

            decimal unit_id = 0;

            int group_id = 0;
            Model.users user_model = new Web.UI.BasePage().GetUserInfo();
            if (user_model != null)
            {
                group_id = user_model.group_id;
            }
            string str_standard_good_price_ids = ",";
            DataTable dt_meal_good = new BLL.meal_good().GetList("meal_id=" + meal_id).Tables[0];
            foreach (DataRow dr_meal_good in dt_meal_good.Rows)
            {
                if (str_standard_good_price_ids.IndexOf("," + (Convert.ToInt32(dr_meal_good["meal_id"]) + "-" + Convert.ToInt32(dr_meal_good["good_id"]) + "-" + Convert.ToDecimal(dr_meal_good["standard_price_id"]) + "-" + Convert.ToDecimal(dr_meal_good["unit_id"])) + ",") > -1)
                {
                    continue;
                }
                str_standard_good_price_ids += Convert.ToInt32(dr_meal_good["meal_id"]) + "-" + Convert.ToInt32(dr_meal_good["good_id"]) + "-" + Convert.ToDecimal(dr_meal_good["standard_price_id"]) + "-" + Convert.ToDecimal(dr_meal_good["unit_id"]) + ",";

                int goods_id = Convert.ToInt32(dr_meal_good["good_id"]);
                Model.article model_good = new BLL.article().GetModel(goods_id);
                if (model_good != null)
                {

                    //商品ID-规格ID|规格值ID,规格ID|规格值ID-单位ID
                    string standard = "";
                    DataTable dt_standard_price = new BLL.standard_price().GetList("id=" + Convert.ToDecimal(dr_meal_good["standard_price_id"])).Tables[0];
                    foreach (DataRow dr_standard_price in dt_standard_price.Rows)
                    {
                        if (!string.IsNullOrEmpty(dr_standard_price["standard_ids"].ToString()))
                        {
                            string[] arr_standard = dr_standard_price["standard_ids"].ToString().Split(',');
                            string[] arr_standard_value = dr_standard_price["standard_value_ids"].ToString().Split(',');
                            for (int i = 0; i < arr_standard.Length; i++)
                            {
                                if (!string.IsNullOrEmpty(arr_standard[i]))
                                {
                                    standard += arr_standard[i] + "|" + ((i < arr_standard_value.Length) ? arr_standard_value[i] : "0");
                                }
                            }
                        }
                    }
                    int goods_quantity = Convert.ToInt32(dr_meal_good["quantity"]);
                    Model.unit model_unit = new BLL.unit().GetModel(Convert.ToInt32(dr_meal_good["unit_id"]));
                    if (model_unit != null)
                    {
                        unit_id = model_unit.id;
                        goods_quantity = goods_quantity * model_unit.quantity;
                    }

                    //统计购物车
                    shopping_key.Add(goods_id + "-" + standard + "-" + unit_id + "&" + goods_quantity);
                }
                else
                {
                    quantity_ture = false;
                    good_true = false;
                }
            }
            if (!quantity_ture || !good_true)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"库存不足,添加购物车失败\"}");
                return;
            }
            foreach (string str in shopping_key)
            {
                if (!string.IsNullOrEmpty(str))
                {
                    Web.UI.ShopCart.Add(str.Split('&')[0], Convert.ToInt32(str.Split('&')[1]));
                }

            }

            Model.cart_total cartModel = Web.UI.ShopCart.GetTotal(group_id);

            context.Response.Write("{\"status\":1, \"msg\":\"商品已成功添加到购物车!\", \"quantity\":" + cartModel.total_quantity + ", \"amount\":" + cartModel.real_amount + "}");
            return;
        }
示例#18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //读取站点配置信息
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(DTKeys.FILE_SITE_XML_CONFING);

            string  order_type   = DTRequest.GetFormString("pay_order_type"); //订单类型
            string  order_no     = DTRequest.GetFormString("pay_order_no");
            decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0);
            string  subject      = DTRequest.GetFormString("pay_subject");

            if (order_no == "" || order_amount == 0)
            {
                Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"));
                return;
            }
            //检查是否已登录
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel == null)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "login")); //尚未登录
                return;
            }
            if (userModel.amount < order_amount)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "recharge")); //账户的余额不足
                return;
            }

            if (order_type.ToLower() == DTEnums.AmountTypeEnum.BuyGoods.ToString().ToLower()) //购买商品
            {
                BLL.orders   bll   = new BLL.orders();
                Model.orders model = bll.GetModel(order_no);
                if (model == null)
                {
                    Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,商品订单号不存在!"));
                    return;
                }
                //执行扣取账户金额
                int result = new BLL.amount_log().Add(userModel.id, userModel.user_name, DTEnums.AmountTypeEnum.BuyGoods.ToString(), order_no, model.payment_id, -1 * order_amount, subject, 1);
                if (result > 0)
                {
                    //更改订单状态
                    bool result1 = bll.UpdateField(order_no, "payment_status=2,payment_time='" + DateTime.Now + "'");
                    if (!result1)
                    {
                        Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error"));
                        return;
                    }
                    //扣除积分
                    if (model.point < 0)
                    {
                        new BLL.point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no);
                    }
                    //支付成功
                    Response.Redirect(new Web.UI.BasePage().linkurl("payment1", "succeed", order_type, order_no));
                    return;
                }
            }
            Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,找不到需要支付的订单类型!"));
            return;
        }
示例#19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //读取站点配置信息
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig();
            string order_no = DTRequest.GetFormString("pay_order_no").ToUpper();
            BLL.orders objorders = new BLL.orders();
            Model.orders modelorders = objorders.GetModel(order_no);
            if (modelorders == null)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,订单详情获取出错,请重试!")));
                return;
            }
            decimal order_amount = modelorders.order_amount;
            string subject = DTRequest.GetFormString("pay_subject");
            if (order_no == "" || order_amount == 0 )
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!")));
                return;
            }
            //检查是否已登录
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel == null)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=login")); //尚未登录
                return;
            }
            if (userModel.amount < order_amount)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=recharge")); //账户的余额不足
                return;
            }

            if (order_no.StartsWith("B")) //B开头为商品订单
            {
                BLL.orders bll = new BLL.orders();
                Model.orders model = bll.GetModel(order_no);
                if (model == null)
                {
                    Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,商品订单号不存在!")));
                    return;
                }
                if (model.payment_status == 1)
                {
                    //执行扣取账户金额
                    int result = new BLL.user_amount_log().Add(userModel.id, userModel.user_name, -1 * order_amount, subject);
                    if (result > 0)
                    {
                        //更改订单状态
                        bool result1 = bll.UpdateField(order_no, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                        if (!result1)
                        {
                            Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=error"));
                            return;
                        }
                        //扣除积分
                        if (model.point < 0)
                        {
                            new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false);
                        }
                    }
                    else
                    {
                        Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=error"));
                        return;
                    }
                }
                //支付成功
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=succeed&order_no=" + order_no));
                return;
            }
            Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,找不到需要支付的订单类型!")));
            return;
        }
示例#20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //读取站点配置信息
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig();
            string           order_no   = MXRequest.GetFormString("pay_order_no").ToUpper();

            BLL.orders   objorders   = new BLL.orders();
            Model.orders modelorders = objorders.GetModel(order_no);
            if (modelorders == null)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,订单详情获取出错,请重试!")));
                return;
            }
            decimal order_amount = modelorders.payable_amount;
            string  subject      = MXRequest.GetFormString("pay_subject");

            if (order_no == "" || order_amount == 0)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!")));
                return;
            }
            //检查是否已登录
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel == null)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "login")); //尚未登录
                return;
            }
            if (userModel.amount < order_amount)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "recharge")); //账户的余额不足
                return;
            }

            if (order_no.StartsWith("B")) //B开头为商品订单
            {
                BLL.orders   bll   = new BLL.orders();
                Model.orders model = bll.GetModel(order_no);
                if (model == null)
                {
                    Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,商品订单号不存在!")));
                    return;
                }
                if (model.payment_status == 1)
                {
                    //执行扣取账户金额
                    int result = new BLL.user_amount_log().Add(userModel.id, userModel.user_name, MXEnums.AmountTypeEnum.BuyGoods.ToString(), order_no, model.payment_id, -1 * order_amount, subject, 1);
                    if (result > 0)
                    {
                        //更改订单状态
                        bool result1 = bll.UpdateField(order_no, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                        if (!result1)
                        {
                            Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error"));
                            return;
                        }
                        //扣除积分
                        if (model.point < 0)
                        {
                            new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false);
                        }
                    }
                    else
                    {
                        Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error"));
                        return;
                    }
                }
                //支付成功
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "succeed", order_no));
                return;
            }
            Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,找不到需要支付的订单类型!")));
            return;
        }
示例#21
0
 public void ProcessRequest(HttpContext context)
 {
     int id = DTRequest.GetQueryInt("id");
     //获得下载ID
     if (id < 1)
     {
         context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,参数传值不正确哦!"));
         return;
     }
     //检查下载记录是否存在
     BLL.article_attach bll = new BLL.article_attach();
     if (!bll.Exists(id))
     {
         context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
         return;
     }
     Model.article_attach model = bll.GetModel(id);
     //检查积分是否足够
     if (model.point > 0)
     {
         //检查用户是否登录
         Model.users userModel = new Web.UI.BasePage().GetUserInfo();
         if (userModel == null)
         {
             //自动跳转URL
             HttpContext.Current.Response.Redirect(new Web.UI.BasePage().linkurl("login"));
         }
         //防止重复扣积分
         string cookie = Utils.GetCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString());
         if (cookie != model.id.ToString())
         {
             //检查积分
             if (model.point > userModel.point)
             {
                 context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您的积分不足支付本次下载!"));
                 return;
             }
             //扣取积分
             new BLL.user_point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下载附件:“" + model.file_name + "”,扣减积分", false);
             //写入Cookie
             Utils.WriteCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString(), model.id.ToString(), 8640);
         }
     }
     //下载次数+1
     bll.UpdateField(id, "down_num=down_num+1");
     //检查文件本地还是远程
     if (model.file_path.ToLower().StartsWith("http://"))
     {
         context.Response.Redirect(model.file_path);
         return;
     }
     else
     {
         //取得文件物理路径
         string fullFileName = Utils.GetMapPath(model.file_path);
         if (!File.Exists(fullFileName))
         {
             context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
             return;
         }
         FileInfo file = new FileInfo(fullFileName);//路径
         context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
         context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
         context.Response.AddHeader("Content-length", file.Length.ToString());
         context.Response.ContentType = "application/pdf";
         context.Response.WriteFile(file.FullName);
         context.Response.End();
     }
 }
示例#22
0
        private void comment_add(HttpContext context)
        {
            StringBuilder strTxt = new StringBuilder();
            BLL.article_comment bll = new BLL.article_comment();
            Model.article_comment model = new Model.article_comment();

            string code = DTRequest.GetFormString("txtCode");
            int article_id = DTRequest.GetQueryInt("article_id");
            string _content = DTRequest.GetFormString("txtContent");
            //校检验证码
            string result =verify_code(context, code);
            if (result != "success")
            {
                context.Response.Write(result);
                return;
            }
            if (article_id == 0)
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,参数传输有误!\"}");
                return;
            }
            if (string.IsNullOrEmpty(_content))
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,请输入评论的内容!\"}");
                return;
            }
            //检查用户是否登录
            int user_id = 0;
            string user_name = "匿名用户";
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel != null)
            {
                user_id = userModel.id;
                user_name = userModel.user_name;
            }
            model.article_id = article_id;
            model.content = Utils.ToHtml(_content);
            model.user_id = user_id;
            model.user_name = user_name;
            model.user_ip = DTRequest.GetIP();
            model.is_lock = siteConfig.commentstatus; //审核开关
            model.add_time = DateTime.Now;
            model.is_reply = 0;
            if (bll.Add(model) > 0)
            {
                context.Response.Write("{\"msg\": 1, \"msgbox\": \"恭喜您,留言提交成功啦!\"}");
                return;
            }
            context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,保存过程中发生错误!\"}");
            return;
        }
示例#23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //讀取網站配置資料
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(DTKeys.FILE_SITE_XML_CONFING);

            string  order_type   = DTRequest.GetFormString("pay_order_type"); //訂單類型
            string  order_no     = DTRequest.GetFormString("pay_order_no");
            decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0);
            string  subject      = DTRequest.GetFormString("pay_subject");

            if (order_no == "" || order_amount == 0)
            {
                Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("對不起,您送出的參數有誤!"));
                return;
            }
            //檢查是否已登入
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel == null)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "login")); //尚未登入
                return;
            }
            if (userModel.amount < order_amount)
            {
                Response.Redirect(new Web.UI.BasePage().linkurl("payment", "recharge")); //帳戶的餘額不足
                return;
            }

            if (order_type.ToLower() == DTEnums.AmountTypeEnum.BuyGoods.ToString().ToLower()) //購買商品
            {
                BLL.orders   bll   = new BLL.orders();
                Model.orders model = bll.GetModel(order_no);
                if (model == null)
                {
                    Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("對不起,商品訂單號不存在!"));
                    return;
                }
                if (model.payment_status == 1)
                {
                    //執行扣取帳戶金額
                    int result = new BLL.amount_log().Add(userModel.id, userModel.user_name, DTEnums.AmountTypeEnum.BuyGoods.ToString(), order_no, model.payment_id, -1 * order_amount, subject, 1);
                    if (result > 0)
                    {
                        //更改訂單狀態
                        bool result1 = bll.UpdateField(order_no, "payment_status=2,payment_time='" + DateTime.Now + "'");
                        if (!result1)
                        {
                            Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error"));
                            return;
                        }
                        //扣除積分
                        if (model.point < 0)
                        {
                            new BLL.point_log().Add(model.user_id, model.user_name, model.point, "換購扣除積分,訂單號:" + model.order_no);
                        }
                    }
                    else
                    {
                        Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error"));
                        return;
                    }
                }
                //付款成功
                Response.Redirect(new Web.UI.BasePage().linkurl("payment1", "succeed", order_type, order_no));
                return;
            }
            Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("對不起,找不到需要付款的訂單類型!"));
            return;
        }