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
        /// <summary>
        /// 根据本地订单映射出驿氪订单
        /// </summary>
        /// <param name="orderSrc"></param>
        /// <returns></returns>
        public Entity.OrderInfo GeiMappingOrderInfo(ZentCloud.BLLJIMP.Model.WXMallOrderInfo orderSrc)
        {
            BLLMall bllMall = new BLLMall();

            Entity.OrderInfo order = new Entity.OrderInfo();

            order.ShopCode   = CurrEfastShopId.ToString();
            order.Code       = orderSrc.OrderID;
            order.OrderTime  = orderSrc.InsertDate.ToString();
            order.TotalQty   = orderSrc.ProductCount;
            order.TotalMoney = 0;// (double)orderSrc.TotalAmount;
            order.IsPayed    = orderSrc.PaymentStatus == 1;
            order.PayAmount  = (double)orderSrc.TotalAmount;

            var userInfo = new BLLUser().GetUserInfo(orderSrc.OrderUserID);

            order.BuyerCode = userInfo.Ex2;

            order.OrderStatus = GetOrderStatusCode(orderSrc.Status);
            order.StatusTime  = DateTime.Now.ToString();
            order.SellerId    = orderSrc.SellerId;
            order.DataOrigin  = 1;
            order.PayTime     = DateTime.Now.ToString();
            order.ExpressFee  = (double)orderSrc.Transport_Fee;

            order.RecvAddress   = orderSrc.Address;
            order.RecvCity      = orderSrc.ReceiverCity;
            order.RecvConsignee = orderSrc.Consignee;
            order.RecvCounty    = orderSrc.ReceiverDist;
            order.RecvMobile    = orderSrc.Phone;
            order.RecvProvince  = orderSrc.ReceiverProvince;

            List <ZentCloud.BLLJIMP.Model.WXMallOrderDetailsInfo> detailList = bllMall.GetOrderDetailsList(orderSrc.OrderID);
            List <Entity.OrderDetail> dtls = new List <Entity.OrderDetail>();

            int saleProdQty = 0;

            foreach (var item in detailList)
            {
                Entity.OrderDetail dtl = new Entity.OrderDetail();
                saleProdQty++;

                dtl.BarCode       = bllMall.GetEfastBarcode(item.SkuId.Value);
                dtl.PriceOriginal = (double)item.OrderPrice;
                dtl.PriceSell     = (double)item.OrderPrice;
                dtl.Quantity      = item.TotalCount;
                dtl.Amount        = dtl.PriceSell * dtl.Quantity;
                dtl.IsGift        = false;

                order.TotalMoney += dtl.Amount;

                dtls.Add(dtl);
            }

            order.Dtls = dtls;


            return(order);
        }
Beispiel #3
0
        public void ProcessRequest(HttpContext context)
        {
            string order_id = context.Request["order_id"];//订单状态 中文字符串
            WXMallOrderInfo orderInfo = bllMall.GetByKey<WXMallOrderInfo>("OrderID", order_id, true);
            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);
            apiResp.result = 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",
                use_score=orderInfo.UseScore,
                use_amount=orderInfo.UseAmount,
                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.status = true;
            apiResp.code = (int)APIErrCode.IsSuccess;
            bllMall.ContextResponse(context, apiResp);
        }
Beispiel #4
0
        /// <summary>
        /// 根据本地订单映射出efast订单
        /// </summary>
        /// <param name="orderSrc"></param>
        /// <returns></returns>
        public Open.EfastSDK.Entity.TradeNewAddInfo GetMappingOrderInfo(Model.WXMallOrderInfo orderSrc)
        {
            Open.EfastSDK.Entity.TradeNewAddInfo order = new Open.EfastSDK.Entity.TradeNewAddInfo();

            order.oid           = orderSrc.OrderID;
            order.sd_id         = CurrEfastShopId;
            order.user_name     = orderSrc.OrderUserID;
            order.shipping_name = "zto";
            order.pay_name      = "weixinpay"; //weixinpay
            order.consignee     = orderSrc.Consignee;
            order.address       = orderSrc.Address;
            order.zipcode       = string.IsNullOrWhiteSpace(orderSrc.ZipCode)? "000000": orderSrc.ZipCode;
            order.mobile        = orderSrc.Phone;
            order.tel           = "";
            order.email         = "";
            order.postscript    = "";
            order.to_buyer      = "";//商家备注
            order.goods_amount  = orderSrc.Product_Fee.ToString();
            order.goods_count   = orderSrc.ProductCount.ToString();
            order.total_amount  = orderSrc.TotalAmount.ToString();
            order.shipping_fee  = orderSrc.Transport_Fee.ToString();
            order.money_paid    = orderSrc.TotalAmount.ToString();
            order.order_amount  = orderSrc.TotalAmount.ToString();
            order.add_time      = DateTime.Now.ToString();
            order.province_name = orderSrc.ReceiverProvince;
            order.city_name     = orderSrc.ReceiverCity;
            order.district_name = orderSrc.ReceiverDist;

            if (!string.IsNullOrWhiteSpace(orderSrc.ReceiverDist))
            {
                order.address = orderSrc.ReceiverDist + "  " + order.address;
            }
            if (!string.IsNullOrWhiteSpace(orderSrc.ReceiverCity))
            {
                order.address = orderSrc.ReceiverCity + "  " + order.address;
            }
            if (!string.IsNullOrWhiteSpace(orderSrc.ReceiverProvince))
            {
                order.address = orderSrc.ReceiverProvince + "  " + order.address;
            }

            List <Model.WXMallOrderDetailsInfo> detailList         = bllMall.GetOrderDetailsList(orderSrc.OrderID);
            List <Open.EfastSDK.Entity.TradeNewAddOrdersInfo> dtls = new List <Open.EfastSDK.Entity.TradeNewAddOrdersInfo>();
            int totalCount  = 0;
            int saleProdQty = 0;

            foreach (var item in detailList)
            {
                Open.EfastSDK.Entity.TradeNewAddOrdersInfo dtl = new Open.EfastSDK.Entity.TradeNewAddOrdersInfo();
                saleProdQty++;
                totalCount += item.TotalCount;
                var sku = bllMall.GetProductSku(item.SkuId.Value);
                //var product = bllMall.GetProduct(item.PID);

                dtl.goods_name   = item.ProductName;
                dtl.goods_number = item.TotalCount;
                dtl.goods_price  = (double)item.OrderPrice;
                dtl.is_gift      = 0;
                dtl.outer_sku    = sku.OutBarCode;

                if (item.PaymentFt != null && item.PaymentFt != 0)
                {
                    dtl.payment_ft = (double)item.PaymentFt;
                }

                dtls.Add(dtl);
            }

            order.orders = dtls;

            return(order);
        }
Beispiel #5
0
        /// <summary>
        /// 计算订单可以返多少积分
        /// </summary>
        /// <param name="orderInfo"></param>
        /// <returns></returns>
        public decimal CalcOrderRebateScore(WXMallOrderInfo orderInfo)
        {
            BLLMall bllMall  = new BLLMall();
            decimal addScore = 0;

            //取出全部sku和数量,相加获取得到的总积分

            //判断当前是否只能全额支付才返积分
            //如果可以不全额,且实付跟应付不一致,则每个商品按照均摊价格去计算积分
            var websiteInfo = GetWebsiteInfoModelFromDataBase(orderInfo.WebsiteOwner);

            if (websiteInfo.IsRebateScoreMustAllCash == 1 && !orderInfo.IsAllCash)
            {
                //如果没有使用优惠券、积分、余额抵扣则为全额付款
                return(0);
            }

            var detalList = bllMall.GetOrderDetailsList(orderInfo.OrderID);

            var rebateRate = GetUserRebateScoreRate(orderInfo.OrderUserID, orderInfo.WebsiteOwner);

            if (rebateRate > 0 && orderInfo.TotalAmount > 0)
            {
                foreach (var item in detalList)
                {
                    decimal payRate = 1;//实付比例

                    if (!orderInfo.IsAllCash)
                    {
                        // 没有全额付款,计算返积分均摊价

                        // 均摊价=单个商品价格/所有商品价格*(实付-运费)- 已废弃
                        //item.OrderPrice = item.OrderPrice.Value / orderInfo.Product_Fee * (orderInfo.TotalAmount - orderInfo.Transport_Fee);

                        /* 积分均摊价
                         *
                         * 实付价格比例=商品实付/商品应付(不算邮费)
                         *
                         * 单个sku应算积分差价比例=单个sku积分差价(一件)/积分差价总和(总件数)
                         *
                         * 差价总额=每个sku的积分差价*数量 加起来
                         *
                         * 单个sku积分差价(无均摊)= 单个sku应算积分差价比例 * 差价总额
                         *
                         * 单个sku积分均摊价 = 实付价格比例 * 单个sku积分差价
                         *                   = 商品实付/商品应付(不算邮费) * 差价总额 * 单个sku应算积分差价比例
                         *
                         * --------------------------------------------------------------------------------------
                         *
                         *
                         * 单个sku积分均摊价 = 实付价格比例 * 单个sku积分差价
                         *
                         *
                         */

                        payRate = (orderInfo.TotalAmount - orderInfo.Transport_Fee) / orderInfo.Product_Fee;
                    }

                    addScore += CalcProductSkuRebateScore(item.SkuId.Value, rebateRate, payRate, item.TotalCount);
                }
            }

            addScore = RebateScoreGetInt(addScore);

            return(addScore);
        }
Beispiel #6
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);
        }