Esempio n. 1
0
 /// <summary>
 /// 判断是否发起砍价人
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 protected string ShowLeader(object id)
 {
     if (id == null)
     {
         return(string.Empty);
     }
     else
     {
         int _id = 0;
         int.TryParse(id.ToString(), out _id);
         if (!string.IsNullOrWhiteSpace(BargainOrder.SelectedValue))
         {
             _bargainOrder = BargainOrderBLL.ReadBargainOrder(int.Parse(BargainOrder.SelectedValue));
             CheckStatus(_bargainOrder.Id);
         }
         if (_id > 0 && _bargainOrder.UserId == _id)
         {
             string result = "<span class=\"red\">【发起砍价】</span>";
             return(result);
         }
         else
         {
             return(string.Empty);
         }
     }
 }
Esempio n. 2
0
 private void BindData()
 {
     if (string.IsNullOrWhiteSpace(BargainOrder.SelectedValue))
     {
         // 默认查看此砍价所有的砍记录
         if (b_orderids.Count > 0)
         {
             string inBOrderId = string.Join(",", b_orderids);
             recordingList = RecordingBLL.SearchRecordingList(new RecordingSearch()
             {
                 InBOrderId = inBOrderId
             });
         }
         else
         {
             //recordingList = RecordingBLL.SearchRecordingList(new RecordingSearch() { });
         }
     }
     else
     {
         recordingList = RecordingBLL.SearchRecordingList(new RecordingSearch()
         {
             BOrderId = int.Parse(BargainOrder.SelectedValue)
         });
     }
     recordingList = recordingList.Where(k => k.UserId > 0).ToList();
     recordingList.ForEach(k => k.UserName = System.Web.HttpUtility.UrlDecode(k.UserName, System.Text.Encoding.UTF8));
     recordingList = recordingList.OrderBy(k => k.AddDate).ToList();
     BindControl(recordingList, RecordList);
     if (!string.IsNullOrWhiteSpace(BargainOrder.SelectedValue))
     {
         _bargainOrder = BargainOrderBLL.ReadBargainOrder(int.Parse(BargainOrder.SelectedValue));
         CheckStatus(_bargainOrder.Id);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 页面加载方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CheckAdminPower("ReadRecording", PowerCheckType.Single);

                //var bargain = BargainOrderBLL.ReadBargainOrder(RequestHelper.GetQueryString<int>("ID"));
                bargain = BargainBLL.ReadBargain(RequestHelper.GetQueryString <int>("ID"));
                var BargainDetailList = BargainDetailsBLL.ReadByBargainId(bargain.Id);
                foreach (var item in BargainDetailList)
                {
                    var product = ProductBLL.Read(item.ProductID);
                    if (product.Id > 0 && product.IsDelete == 0)
                    {
                        BargainDetail.Items.Add(new ListItem(product.Name, item.Id.ToString()));
                    }
                }
                BargainDetail.Items.Insert(0, new ListItem {
                    Text = "请选择", Value = ""
                });
                //BargainDetail.SelectedIndexChanged += new System.EventHandler(BargainDetail_SelectedIndexChanged);
                if (!string.IsNullOrEmpty(BargainDetail.SelectedValue))
                {
                    foreach (var item in BargainOrderBLL.SearchBargainOrderList(new BargainOrderSearch()
                    {
                        BargainDetailsId = int.Parse(BargainDetail.SelectedValue)
                    }))
                    {
                        var user = UserBLL.Read(item.UserId);
                        user.UserName = System.Web.HttpUtility.UrlDecode(user.UserName, System.Text.Encoding.UTF8);
                        BargainOrder.Items.Add(new ListItem(user.UserName, item.Id.ToString()));
                    }
                }
                BargainOrder.Items.Insert(0, new ListItem {
                    Text = "请选择", Value = ""
                });
                #region MyRegion
                var bargainDetails = BargainDetailsBLL.ReadByBargainId(bargain.Id);
                foreach (var bdt in bargainDetails)
                {
                    var bargain_orders = BargainOrderBLL.SearchBargainOrderList(new BargainOrderSearch {
                        BargainDetailsId = bdt.Id
                    });
                    b_orderids = b_orderids.Concat(bargain_orders.Select(k => k.Id)).ToList();
                }
                #endregion
                BindData();
            }
        }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         CheckAdminPower("ReadBargain", PowerCheckType.Single);
         string Action = RequestHelper.GetQueryString <string>("Action");
         if (Action == "Delete")
         {
             Delete();
         }
         if (Action == "ShutDown")
         {
             ShutDown();
         }
         List <BargainInfo> dataList = BargainBLL.SearchBargainList(CurrentPage, PageSize, new BargainSearch(), ref Count);
         foreach (var bargain in dataList)
         {
             int total_bargain = 0;
             //到期,将状态置为“已结束”
             if (DateTime.Now > bargain.EndDate && bargain.Status != (int)Bargain_Status.End)
             {
                 //异步 改变“砍价活动状态”
                 TimeExpire(bargain.Id);
             }
             var bargainDetails = BargainDetailsBLL.ReadByBargainId(bargain.Id);
             foreach (var bdt in bargainDetails)
             {
                 var bargain_orders = BargainOrderBLL.SearchBargainOrderList(new BargainOrderSearch {
                     BargainDetailsId = bdt.Id
                 });
                 foreach (var bo in bargain_orders)
                 {
                     total_bargain += RecordingBLL.SearchRecordingList(new RecordingSearch {
                         BOrderId = bo.Id
                     }).Where(k => k.UserId > 0).Count();
                 }
             }
             //本次砍价总砍次数
             bargain.Bargain_Records_Total = total_bargain;
         }
         BindControl(dataList, RecordList, MyPager);
     }
 }
Esempio n. 5
0
        protected void BargainDetail_SelectedIndexChanged(object sender, EventArgs e)
        {
            BargainOrder.Items.Clear();
            if (!string.IsNullOrWhiteSpace(BargainDetail.SelectedValue))
            {
                foreach (var item in BargainOrderBLL.SearchBargainOrderList(new BargainOrderSearch()
                {
                    BargainDetailsId = int.Parse(BargainDetail.SelectedValue)
                }))
                {
                    var user = UserBLL.Read(item.UserId);
                    user.UserName = System.Web.HttpUtility.UrlDecode(user.UserName, System.Text.Encoding.UTF8);
                    BargainOrder.Items.Add(new ListItem(user.UserName, item.Id.ToString()));
                }

                #region MyRegion

                var bargain_orders = BargainOrderBLL.SearchBargainOrderList(new BargainOrderSearch {
                    BargainDetailsId = int.Parse(BargainDetail.SelectedValue)
                });
                b_orderids = b_orderids.Concat(bargain_orders.Select(k => k.Id)).ToList();

                #endregion
            }
            else
            {
                #region MyRegion
                var bargainDetails = BargainDetailsBLL.ReadByBargainId(RequestHelper.GetQueryString <int>("ID"));
                foreach (var bdt in bargainDetails)
                {
                    var bargain_orders = BargainOrderBLL.SearchBargainOrderList(new BargainOrderSearch {
                        BargainDetailsId = bdt.Id
                    });
                    b_orderids = b_orderids.Concat(bargain_orders.Select(k => k.Id)).ToList();
                }
                #endregion
            }
            BargainOrder.Items.Insert(0, new ListItem {
                Text = "请选择", Value = ""
            });
            BindData();
        }
Esempio n. 6
0
        /// <summary>
        /// 检查砍价订单状态
        /// </summary>
        /// <param name="bargainOrderId"></param>
        /// <returns></returns>
        private void CheckStatus(int bargainOrderId)
        {
            //new TxtLog(Server.MapPath("/apilog/")).Write("-----bargainOrderId:"+ bargainOrderId+"----");
            var bargainOrder = BargainOrderBLL.ReadBargainOrder(bargainOrderId);

            //new TxtLog(Server.MapPath("/apilog/")).Write("-----BargainOrderType:" + bargainOrder.Status + "----");
            if (bargainOrder.Id > 0 && bargainOrder.Status == (int)BargainOrderType.进行中)
            {
                var bargainDetail = BargainDetailsBLL.ReadBargainDetails(bargainOrder.BargainDetailsId);
                var bargain       = BargainBLL.ReadBargain(bargainDetail.BargainId);
                if (DateTime.Now >= bargain.EndDate)
                {//已经结束,砍价失败
                    bargainOrder.Status = (int)BargainOrderType.价失败;
                    BargainOrderBLL.UpdateBargainOrder(bargainOrder);
                }
                var product = ProductBLL.Read(bargainDetail.ProductID);
                if (product.MarketPrice - bargainOrder.BargainPrice == bargainDetail.ReservePrice && bargainOrder.Status != (int)BargainOrderType.价成功)
                {
                    bargainOrder.Status = (int)BargainOrderType.价成功;
                    //BargainOrderBLL.UpdateBargainOrder(bargainOrder);
                    if (BargainOrderBLL.UpdateBargainOrder(bargainOrder))
                    {
                        //发送砍价成功模板消息
                        //SendBargainMessage(bargainOrder);
                        //new TxtLog(Server.MapPath("/apilog/")).Write("-----发送砍价成功模板消息:End----");
                    }
                }
                else if (DateTime.Now >= bargain.EndDate && bargainOrder.Status != (int)BargainOrderType.价失败)
                {
                    bargainOrder.Status = (int)BargainOrderType.价失败;
                    BargainOrderBLL.UpdateBargainOrder(bargainOrder);
                }
                else
                {//进行中
                }
            }
        }
Esempio n. 7
0
        public override void ProcessNotify()
        {
            WxPayData notifyData = GetNotifyData();


            //检查支付结果中transaction_id是否存在
            if (!notifyData.IsSet("transaction_id"))
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "支付结果中微信订单号不存在");
                Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
                //page.Response.Write(res.ToXml());
                //page.Response.End();
            }
            else
            {
                string transaction_id = notifyData.GetValue("transaction_id").ToString();

                //查询订单,判断订单真实性
                if (!QueryOrder(transaction_id))
                ////沙箱测试只能用out_trade_no
                //if (notifyData.IsSet("out_trade_no") && !QueryOrderByout_trade_no(notifyData.GetValue("out_trade_no").ToString()))
                {
                    //若订单查询失败,则立即返回结果给微信支付后台
                    WxPayData res = new WxPayData();
                    res.SetValue("return_code", "FAIL");
                    res.SetValue("return_msg", "订单查询失败");
                    Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
                    //page.Response.Write(res.ToXml());
                    //page.Response.End();
                }
                //查询订单成功
                else
                {
                    Log.Debug(this.GetType().ToString(), "订单查询成功 ");
                    /************在这里加入商户自己的逻辑***********************************************************/

                    //attach:以逗号分开的订单Id字符串,与支付时提交的数据一致
                    if (notifyData.IsSet("attach"))
                    {
                        string attach = notifyData.GetValue("attach").ToString();

                        string[] orderIds = attach.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string orderId in orderIds)
                        {
                            var order = OrderBLL.Read(int.Parse(orderId));
                            if (order.Id > 0)
                            {
                                #region 正常流程 待付款--》待审核
                                if (order.OrderStatus == (int)OrderStatus.WaitPay)
                                {
                                    order.PayKey  = "WxPay";
                                    order.PayName = "微信支付";

                                    order.WxPayTradeNo = transaction_id;
                                    //沙箱测试用out_trade_no
                                    //order.WxPayTradeNo = notifyData.GetValue("out_trade_no").ToString();

                                    order.OrderStatus = (int)OrderStatus.WaitCheck;
                                    order.PayDate     = RequestHelper.DateNow;
                                    OrderBLL.Update(order);
                                    #region 拼团订单付款:团长付款--开团+增加参团记录;成员付款--增加参团记录
                                    if (order.IsActivity == (int)OrderKind.GroupBuy)
                                    {
                                        var orderDetail = OrderDetailBLL.ReadList(order.Id).FirstOrDefault() ?? new OrderDetailInfo();
                                        if (orderDetail.Id > 0)
                                        {
                                            var product = ProductBLL.Read(orderDetail.ProductId);
                                            //团长付款
                                            if (order.FavorableActivityId <= 0)
                                            {
                                                //开团
                                                int groupId = GroupBuyBLL.Add(new GroupBuyInfo
                                                {
                                                    Leader    = order.UserId,
                                                    ProductId = product.Id,
                                                    StartTime = DateTime.Now,
                                                    EndTime   = DateTime.Now.AddDays(ShopConfig.ReadConfigInfo().GroupBuyDays),
                                                    Quantity  = product.GroupQuantity,
                                                    //团购订单支付成功之后计数加1
                                                    SignCount = 1
                                                });
                                                //订单绑定团购Id
                                                Dictionary <string, object> dict = new Dictionary <string, object>();
                                                dict.Add("[FavorableActivityId]", groupId);
                                                OrderBLL.UpdatePart("[Order]", dict, order.Id);
                                                //增加参团记录
                                                GroupSignBLL.Add(new GroupSignInfo
                                                {
                                                    GroupId  = groupId,
                                                    UserId   = order.UserId,
                                                    OrderId  = order.Id,
                                                    SignTime = DateTime.Now
                                                });
                                            }
                                            else//参团者付款--放到参团者checkout
                                            {
                                                ////增加参团记录
                                                //GroupSignBLL.Add(new GroupSignInfo
                                                //{
                                                //    GroupId = order.FavorableActivityId,
                                                //    UserId = order.UserId,
                                                //    OrderId = order.Id,
                                                //    SignTime = DateTime.Now
                                                //});
                                                ////开团表signcount加1
                                                //GroupBuyBLL.PlusSignCount(order.FavorableActivityId);
                                            }
                                        }
                                    }
                                    #endregion
                                    #region 自提订单 生成提货码
                                    //避免重复数据,一个订单对应一个提货码,提货码没有有效期,使用过后失效
                                    if (order.SelfPick == 1 && PickUpCodeBLL.ReadByOrderId(order.Id).Id <= 0)
                                    {
                                        PickUpCodeInfo pkCode = new PickUpCodeInfo();
                                        pkCode.OrderId  = order.Id;
                                        pkCode.Status   = 0;
                                        pkCode.PickCode = PickUpCodeBLL.CreatePickUpCode();
                                        int pickCodeId = PickUpCodeBLL.Add(pkCode);
                                    }
                                    #endregion
                                    #region  价订单
                                    if (order.IsActivity == (int)OrderKind.Bargain)
                                    {
                                        BargainOrderBLL.HandleBargainOrderPay(order.FavorableActivityId);
                                    }
                                    #endregion
                                    //发送订单支付成功通知
                                    SendPayOrderMsg(order);
                                    //增加操作记录
                                    OrderActionInfo orderAction = new OrderActionInfo();
                                    orderAction.OrderId          = order.Id;
                                    orderAction.OrderOperate     = (int)OrderOperate.Pay;
                                    orderAction.StartOrderStatus = (int)OrderStatus.WaitPay;
                                    orderAction.EndOrderStatus   = (int)OrderStatus.WaitCheck;
                                    orderAction.Note             = "客户微信在线支付";
                                    orderAction.IP        = ClientHelper.IP;
                                    orderAction.Date      = RequestHelper.DateNow;
                                    orderAction.AdminID   = 0;
                                    orderAction.AdminName = string.Empty;
                                    OrderActionBLL.Add(orderAction);
                                }
                                #endregion
                                #region 非正常流程 待付款超时已失效(未退款)--》待审核
                                if (order.OrderStatus == (int)OrderStatus.NoEffect && order.IsRefund == 0)
                                {
                                    order.PayKey       = "WxPay";
                                    order.PayName      = "微信支付";
                                    order.WxPayTradeNo = transaction_id;
                                    order.OrderStatus  = (int)OrderStatus.WaitCheck;
                                    order.PayDate      = RequestHelper.DateNow;
                                    OrderBLL.Update(order);
                                    #region 拼团订单付款:团长付款--开团+增加参团记录;成员付款--增加参团记录
                                    if (order.IsActivity == (int)OrderKind.GroupBuy)
                                    {
                                        var orderDetail = OrderDetailBLL.ReadList(order.Id).FirstOrDefault() ?? new OrderDetailInfo();
                                        if (orderDetail.Id > 0)
                                        {
                                            var product = ProductBLL.Read(orderDetail.ProductId);
                                            //团长付款
                                            if (order.FavorableActivityId <= 0)
                                            {
                                                //开团
                                                int groupId = GroupBuyBLL.Add(new GroupBuyInfo
                                                {
                                                    Leader    = order.UserId,
                                                    ProductId = product.Id,
                                                    StartTime = DateTime.Now,
                                                    EndTime   = DateTime.Now.AddDays(ShopConfig.ReadConfigInfo().GroupBuyDays),
                                                    Quantity  = product.GroupQuantity,
                                                    //团购订单支付成功之后计数加1
                                                    SignCount = 1
                                                });
                                                //订单绑定团购Id
                                                Dictionary <string, object> dict = new Dictionary <string, object>();
                                                dict.Add("[FavorableActivityId]", groupId);
                                                OrderBLL.UpdatePart("[Order]", dict, order.Id);
                                                //增加参团记录
                                                GroupSignBLL.Add(new GroupSignInfo
                                                {
                                                    GroupId  = groupId,
                                                    UserId   = order.UserId,
                                                    OrderId  = order.Id,
                                                    SignTime = DateTime.Now
                                                });
                                            }
                                            else//参团者付款--放到参团者checkout
                                            {
                                                ////增加参团记录
                                                //GroupSignBLL.Add(new GroupSignInfo
                                                //{
                                                //    GroupId = order.FavorableActivityId,
                                                //    UserId = order.UserId,
                                                //    OrderId = order.Id,
                                                //    SignTime = DateTime.Now
                                                //});
                                                ////开团表signcount加1
                                                //GroupBuyBLL.PlusSignCount(order.FavorableActivityId);
                                            }
                                        }
                                    }
                                    #endregion
                                    #region 自提订单 生成提货码
                                    //避免重复数据,一个订单对应一个提货码,提货码没有有效期,使用过后失效
                                    if (order.SelfPick == 1 && PickUpCodeBLL.ReadByOrderId(order.Id).Id <= 0)
                                    {
                                        PickUpCodeInfo pkCode = new PickUpCodeInfo();
                                        pkCode.OrderId  = order.Id;
                                        pkCode.Status   = 0;
                                        pkCode.PickCode = PickUpCodeBLL.CreatePickUpCode();
                                        int pickCodeId = PickUpCodeBLL.Add(pkCode);
                                    }
                                    #endregion
                                    #region  价订单
                                    if (order.IsActivity == (int)OrderKind.Bargain)
                                    {
                                        BargainOrderBLL.HandleBargainOrderPay(order.FavorableActivityId);
                                    }
                                    #endregion
                                    #region 扣除支付积分
                                    if (order.Point > 0)
                                    {
                                        //减少积分
                                        UserAccountRecordInfo uarInfo = new UserAccountRecordInfo();
                                        uarInfo.RecordType = (int)AccountRecordType.Point;
                                        uarInfo.UserId     = order.UserId;
                                        uarInfo.UserName   = order.UserName;
                                        uarInfo.Note       = "支付订单:" + order.OrderNumber;
                                        uarInfo.Point      = -order.Point;
                                        uarInfo.Money      = 0;
                                        uarInfo.Date       = DateTime.Now;
                                        uarInfo.IP         = ClientHelper.IP;
                                        UserAccountRecordBLL.Add(uarInfo);
                                    }
                                    #endregion
                                    #region 减少商品库存
                                    ProductBLL.ChangeOrderCountByOrder(order.Id, ChangeAction.Plus);
                                    #endregion
                                    //发送订单支付成功通知
                                    SendPayOrderMsg(order);
                                    //增加操作记录
                                    OrderActionInfo orderAction = new OrderActionInfo();
                                    orderAction.OrderId          = order.Id;
                                    orderAction.OrderOperate     = (int)OrderOperate.Pay;
                                    orderAction.StartOrderStatus = (int)OrderStatus.WaitPay;
                                    orderAction.EndOrderStatus   = (int)OrderStatus.WaitCheck;
                                    orderAction.Note             = "客户微信在线支付";
                                    orderAction.IP        = ClientHelper.IP;
                                    orderAction.Date      = RequestHelper.DateNow;
                                    orderAction.AdminID   = 0;
                                    orderAction.AdminName = string.Empty;
                                    OrderActionBLL.Add(orderAction);
                                }
                                #endregion
                                //记录微信支付交易单号
                                if (order.OrderStatus == (int)OrderStatus.WaitCheck && string.IsNullOrEmpty(order.WxPayTradeNo))
                                {
                                    order.WxPayTradeNo = transaction_id;
                                    OrderBLL.Update(order);
                                }
                                notifyResult = true;
                            }
                        }
                    }

                    /************在这里加入商户自己的逻辑***********************************************************/

                    WxPayData res = new WxPayData();
                    res.SetValue("return_code", "SUCCESS");
                    res.SetValue("return_msg", "OK");
                    Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
                    //page.Response.Write(res.ToXml());
                    //page.Response.End();
                }
            }
        }