Пример #1
0
        public ActionResult Delete(string OrderNo)
        {
            if (string.IsNullOrEmpty(OrderNo))
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }
            Order order = _orderBLL.GetOrderByOrderNo(OrderNo);

            if (order == null)
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }

            order.IsDeleted   = true;
            order.DeletedTime = DateTime.Now;

            if (_orderBLL.Update(order))
            {
                // 删除一条订单时  异步删除订单下的订单详情
                DeleteOrderDetailDel del = new DeleteOrderDetailDel(DeleteOrderDetail);
                IAsyncResult         ar  = del.BeginInvoke(order.OrderNo, Callback, null);

                return(Json("True", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        public ActionResult Completed(string condition)
        {
            List <OrderModel> orderModelList = new List <OrderModel>();
            List <Order>      orderList      = new List <Order>();

            // 偷懒 只按订单号查询
            orderList.Add(_orderBLL.GetOrderByOrderNo(condition));

            foreach (var item in orderList)
            {
                OrderModel om     = new OrderModel(item);
                Member     member = _memberBLL.GetMemberById(item.MemberId);
                om.MemberName = member.NickeName;

                Address address = _addressBLL.GetAddressById(om.AddressId);
                om.Phone     = address.Phone;
                om.Address   = address.Province + "," + address.City + "," + address.County + "," + address.Detail;
                om.Consignee = address.Consignee;

                // 添加配送地址
                om.LogisticalStatus = _orderStatusBLL.GetOrderStatusByOrderId(om.Id).Status;

                orderModelList.Add(om);
            }
            ViewData["CompletedOrderList"] = orderModelList;

            return(View());
        }
Пример #3
0
        public void WxPayResult()
        {
            //接收从微信后台POST过来的数据
            System.IO.Stream s = Request.InputStream;
            int count          = 0;

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

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


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

            try
            {
                data.FromXml(builder.ToString());
                Order order = _orderBLL.GetOrderByOrderNo(data.GetValue("out_trade_no").ToString());
                order.Status  = 1;
                order.PayTime = DateTime.Now;

                Member member = _memberBLL.GetMemberByOpenId(data.GetValue("openid").ToString());

                if (_orderBLL.Update(order))
                {
                    // 添加交易记录
                    Transaction trans = new Transaction();
                    trans.Amount      = order.TotalPrice;
                    trans.CreatedTime = DateTime.Now;
                    trans.DeletedTime = DateTime.MinValue.AddHours(8);
                    trans.Id          = Guid.NewGuid();
                    trans.IsDeleted   = false;
                    trans.MemberId    = member.Id;
                    trans.OrderId     = order.Id;
                    trans.PayWay      = 0;

                    _transactionBLL.Add(trans);

                    if (AddConsumeCredit(member, order.TotalPrice))
                    {
                        // 异步判断是否有足够的积分进行升级
                        UpGradeDel   del    = new UpGradeDel(UpGradeVIP);
                        IAsyncResult result = del.BeginInvoke(member.Id, CallBackMethod, null);

                        // 异步找到此订单所有的服务  并添加
                        AddMyServiceDel msDel = new AddMyServiceDel(AddMyService);
                        IAsyncResult    ra    = msDel.BeginInvoke(member.Id, order.OrderNo, MyServiceCallBackMethod, null);
                    }
                }
                else
                {
                    LogHelper.Log.Write("支付失败");
                }
            }
            catch (WxPayException ex)
            {
                //若签名错误,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", ex.Message);
                Log.Error(this.GetType().ToString(), "Sign check error : " + res.ToXml());

                Response.Write(res.ToXml());
                Response.End();
            }

            Log.Info(this.GetType().ToString(), "Check sign success");
            WxPayData successData = new WxPayData();

            successData.SetValue("return_code", "SUCCESS");
            successData.SetValue("return_msg", "OK");

            Response.Write(successData.ToXml());
            Response.End();
            //return Content(successData.ToXml());
        }