Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            int    page          = !string.IsNullOrEmpty(context.Request["page"]) ? int.Parse(context.Request["page"]) : 1;
            int    rows          = !string.IsNullOrEmpty(context.Request["rows"]) ? int.Parse(context.Request["rows"]) : 10;
            string status        = context.Request["order_status"];//订单状态 中文字符串
            string orderFromTime = context.Request["order_from_time"];
            string orderToTime   = context.Request["order_to_time"];
            string orderType     = context.Request["order_type"];      //订单类型 0 普通订单 1礼品订单
            string giftOrderType = context.Request["gift_order_type"]; //礼品订单类型 0收到的礼品订单 1 发出的礼品订单
            string type          = context.Request["type"];            //订单大类型 空普通订单 MeetingRoom会议室预订 BookingTutor导师预约

            int totalCount = 0;
            var orderList  = bllMall.GetOrderList(rows, page, "", out totalCount, status, CurrentUserInfo.UserID, orderFromTime, orderToTime,
                                                  orderType, giftOrderType, null, null, null, null, null, type);
            List <dynamic> list = new List <dynamic>();

            foreach (var orderInfo in orderList)
            {
                var orderDetailList      = bllMall.GetOrderDetailsList(orderInfo.OrderID);
                var orderMainDetailList  = orderDetailList.Where(p => p.ArticleCategoryType == orderInfo.ArticleCategoryType).ToList();
                var orderAddedDetailList = orderDetailList.Where(p => p.ArticleCategoryType != orderInfo.ArticleCategoryType).ToList();
                var mainProduct          = bllMall.GetByKey <WXMallProductInfo>("PID", orderMainDetailList[0].PID, true);
                list.Add(new
                {
                    order_id      = orderInfo.OrderID,
                    order_time    = orderInfo.InsertDate.ToString("yyyy-MM-dd HH:mm:ss"),
                    product_name  = orderMainDetailList[0].ProductName,
                    price         = orderMainDetailList[0].OrderPrice,
                    unit          = orderMainDetailList[0].Unit,
                    img           = mainProduct.RecommendImg,
                    show_imgs     = mainProduct.ShowImage,
                    total_amount  = orderInfo.TotalAmount,
                    order_status  = orderInfo.Status,
                    is_pay        = orderInfo.PaymentStatus,
                    pay_type      = orderInfo.PaymentType == 2 ? "WEIXIN" : "ALIPAY",
                    order_details = from p in orderMainDetailList
                                    select new
                    {
                        start_date = p.StartDate.ToString("yyyy-MM-dd HH:mm:ss"),
                        end_date   = p.EndDate.ToString("yyyy-MM-dd HH:mm:ss")
                    },
                    added_details = from p in orderAddedDetailList
                                    select new
                    {
                        product_name = p.ProductName,
                        price        = p.OrderPrice,
                        count        = p.TotalCount,
                        unit         = p.Unit
                    }
                });
            }
            apiResp.result = new
            {
                totalcount = totalCount,
                list       = list
            };
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bllMall.ContextResponse(context, apiResp);
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            int    page          = !string.IsNullOrEmpty(context.Request["page"]) ? int.Parse(context.Request["page"]) : 1;
            int    rows          = !string.IsNullOrEmpty(context.Request["rows"]) ? int.Parse(context.Request["rows"]) : 10;
            string status        = context.Request["order_status"];//订单状态 中文字符串
            string orderFromTime = context.Request["order_from_time"];
            string orderToTime   = context.Request["order_to_time"];
            string orderType     = context.Request["order_type"];      //订单类型 0 普通订单 1礼品订单
            string giftOrderType = context.Request["gift_order_type"]; //礼品订单类型 0收到的礼品订单 1 发出的礼品订单
            string type          = context.Request["type"];            //订单大类型 空普通订单 MeetingRoom会议室预订 BookingTutor导师预约
            string keyword       = context.Request["keyword"];

            int totalCount = 0;
            var orderList  = bllMall.GetOrderList(rows, page, keyword, out totalCount, status, null, orderFromTime, orderToTime,
                                                  orderType, giftOrderType, null, null, null, null, null, type);
            List <WXMallOrderDetailsInfo> orderAllMainDetailList  = new List <WXMallOrderDetailsInfo>();
            List <WXMallOrderDetailsInfo> orderAllAddedDetailList = new List <WXMallOrderDetailsInfo>();
            List <WXMallProductInfo>      orderAllProductList     = new List <WXMallProductInfo>();

            if (orderList.Count > 0)
            {
                string orderIds = ZentCloud.Common.MyStringHelper.ListToStr(orderList.Select(p => p.OrderID).Distinct().ToList(), "'", ",");
                List <WXMallOrderDetailsInfo> orderAllDetailList = bllMall.GetMultListByKey <WXMallOrderDetailsInfo>("OrderID", orderIds);
                orderAllMainDetailList  = orderAllDetailList.Where(p => p.ArticleCategoryType == type).ToList();
                orderAllAddedDetailList = orderAllDetailList.Where(p => p.ArticleCategoryType != type).ToList();
                if (orderAllMainDetailList.Count > 0)
                {
                    string productIds = ZentCloud.Common.MyStringHelper.ListToStr(orderAllMainDetailList.Select(p => p.PID).Distinct().ToList(), "", ",");
                    orderAllProductList = bllMall.GetMultListByKey <WXMallProductInfo>("PID", productIds);
                }
            }
            List <dynamic> list = new List <dynamic>();

            foreach (var orderInfo in orderList)
            {
                var orderMainDetailList  = orderAllMainDetailList.Where(p => p.OrderID == orderInfo.OrderID).ToList();
                var orderAddedDetailList = orderAllAddedDetailList.Where(p => p.OrderID == orderInfo.OrderID).ToList();
                var mainProduct          = orderAllProductList.FirstOrDefault(p => p.PID == orderMainDetailList[0].PID);
                list.Add(new
                {
                    order_id         = orderInfo.OrderID,
                    order_time       = orderInfo.InsertDate.ToString("yyyy-MM-dd HH:mm:ss"),
                    product_name     = orderMainDetailList[0].ProductName,
                    price            = orderMainDetailList[0].OrderPrice,
                    unit             = orderMainDetailList[0].Unit,
                    img              = mainProduct.RecommendImg,
                    show_imgs        = mainProduct.ShowImage,
                    use_score        = orderInfo.UseScore,                                                  //使用积分
                    use_score_amount = orderInfo.Product_Fee - orderInfo.TotalAmount - orderInfo.UseAmount, //使用积分抵扣金额
                    use_amount       = orderInfo.UseAmount,                                                 //使用余额
                    total_amount     = orderInfo.TotalAmount,                                               //实付金额
                    order_status     = orderInfo.Status,
                    is_pay           = orderInfo.PaymentStatus,
                    pay_type         = orderInfo.PaymentType == 2 ? "WEIXIN" : "ALIPAY",
                    order_details    = from p in orderMainDetailList
                                       select new
                    {
                        start_date = p.StartDate.ToString("yyyy-MM-dd HH:mm:ss"),
                        end_date   = p.EndDate.ToString("yyyy-MM-dd HH:mm:ss")
                    },
                    added_details = from p in orderAddedDetailList
                                    select new
                    {
                        product_name = p.ProductName,
                        price        = p.OrderPrice,
                        count        = p.TotalCount,
                        unit         = p.Unit
                    },
                    user_id   = orderInfo.OrderUserID,
                    true_name = orderInfo.Consignee,
                    phone     = orderInfo.Phone
                });
            }
            apiResp.result = new
            {
                totalcount = totalCount,
                list       = list
            };
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bllMall.ContextResponse(context, apiResp);
        }
Beispiel #3
0
        public void ProcessRequest(HttpContext context)
        {
            string ids          = context.Request["ids"];
            string order_status = context.Request["order_status"];
            bool   actionStatus = false;

            if (order_status == "预约成功")
            {
                List <string> successIds  = new List <string>();
                List <string> failIds     = new List <string>();
                List <string> orderIds    = ids.Split(',').ToList();
                string        hasOrderIDs = "";
                int           maxCount    = 1;
                foreach (string orderId in orderIds)
                {
                    //已有订单详情
                    WXMallOrderInfo tOrder = bllMall.GetByKey <WXMallOrderInfo>("OrderID", orderId);
                    List <WXMallOrderDetailsInfo> tDetailList  = bllMall.GetOrderDetailsList(orderId, null, tOrder.ArticleCategoryType, null, null);
                    List <WXMallOrderDetailsInfo> oDetailList  = bllMall.GetOrderDetailsList(null, tDetailList[0].PID, tOrder.ArticleCategoryType, tDetailList.Min(p => p.StartDate), tDetailList.Max(p => p.EndDate));
                    WXMallProductInfo             tProductInfo = bllMall.GetByKey <WXMallProductInfo>("PID", tDetailList[0].PID);
                    maxCount = tProductInfo.Stock;

                    List <string> hasOrderID_List = new List <string>();
                    foreach (var item in tDetailList)
                    {
                        List <WXMallOrderDetailsInfo> hasOrderDetailList = oDetailList.Where(p => !((item.StartDate >= p.EndDate && item.EndDate > p.EndDate) || (item.StartDate < p.StartDate && item.EndDate <= p.StartDate))).ToList();
                        if (hasOrderDetailList.Count > 0)
                        {
                            hasOrderID_List.AddRange(hasOrderDetailList.Select(p => p.OrderID).Distinct());
                        }
                    }
                    hasOrderID_List = hasOrderID_List.Where(p => !p.Contains(orderId)).ToList();
                    if (hasOrderID_List.Count > 0)
                    {
                        hasOrderID_List = hasOrderID_List.Distinct().ToList();
                        hasOrderIDs     = MyStringHelper.ListToStr(hasOrderID_List, "'", ",");
                        int tempCount = 0;
                        List <WXMallOrderInfo> tempList = bllMall.GetOrderList(0, 1, "", out tempCount, "预约成功", null, null, null,
                                                                               null, null, null, null, null, null, null, tOrder.ArticleCategoryType, hasOrderIDs);
                        if (tempCount >= maxCount)
                        {
                            failIds.Add(orderId);
                            continue;
                        }

                        if (string.IsNullOrWhiteSpace(hasOrderIDs))
                        {
                            hasOrderIDs = "'0'";
                        }
                        if (bllMall.Update(new WXMallOrderInfo(),
                                           string.Format("PaymentStatus={0},PayTime=GetDate(),Status='{1}'", 1, "预约成功"),
                                           string.Format("OrderID={0} AND WebsiteOwner='{4}' and (select count(1) from [ZCJ_WXMallOrderInfo] where Status='{3}' and WebsiteOwner='{4}' and  OrderID IN({1}))<{2}",
                                                         tOrder.OrderID, hasOrderIDs, maxCount, "预约成功", bllMall.WebsiteOwner)
                                           ) > 0)
                        {
                            hasOrderIDs = string.Format("{0},'{1}'", hasOrderIDs, tOrder.OrderID);
                            successIds.Add(orderId);
                            #region 修改其他预约订单为预约失败
                            bllMall.Update(new WXMallOrderInfo(),
                                           string.Format("Status='{0}'", "预约失败"),
                                           string.Format("OrderID In ({0}) AND Status Not In ({1}) and WebsiteOwner='{4}' AND (select count(1) from [ZCJ_WXMallOrderInfo] where Status='{5}' and OrderID IN({2}) and WebsiteOwner='{4}' )>={3}",
                                                         hasOrderIDs, "'预约失败','预约成功','已取消'", hasOrderIDs, maxCount, bllMall.WebsiteOwner, "预约成功"));
                            #endregion
                        }
                        else
                        {
                            failIds.Add(orderId);
                        }
                    }
                    else
                    {
                        tOrder.Status = order_status;
                        if (bllMall.Update(tOrder))
                        {
                            successIds.Add(orderId);
                        }
                        else
                        {
                            failIds.Add(orderId);
                        }
                    }
                }
                if (orderIds.Count == 0)
                {
                    apiResp.msg = "修改完成";
                }
                else
                {
                    if (failIds.Count == 0)
                    {
                        apiResp.msg = "全部修改成功";
                    }
                    else if (successIds.Count == 0)
                    {
                        apiResp.msg = "全部订单所选时间已有预约成功的订单";
                    }
                    else
                    {
                        apiResp.msg = "订单[" + MyStringHelper.ListToStr(successIds, "", ",") + "]修改成功,订单[" + MyStringHelper.ListToStr(failIds, "", ",") + "]所选时间已有预约成功的订单";
                    }
                }
                apiResp.status = true;
                apiResp.code   = (int)APIErrCode.IsSuccess;
                bllMall.ContextResponse(context, apiResp);
            }
            else
            {
                List <string> orderIds = ids.Split(',').ToList();
                ids = MyStringHelper.ListToStr(orderIds, "'", ",");
                if (bllMall.UpdateMultByKey <WXMallOrderInfo>("OrderID", ids, "Status", order_status, null, true) > 0)
                {
                    apiResp.status = true;
                    apiResp.msg    = "修改完成";
                    apiResp.code   = (int)APIErrCode.IsSuccess;
                }
                else
                {
                    apiResp.msg  = "修改失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                }
            }
            bllMall.ContextResponse(context, apiResp);
        }