Ejemplo n.º 1
0
        /// <summary>
        /// 从订单获取订单积分
        /// </summary>
        /// <param name="SupermarketOrderId"></param>
        /// <param name="Info"></param>
        /// <param name="cardno"></param>
        /// <param name="weixinID"></param>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public int GetScore(ref string SupermarketOrderId, MemberInfo Info, string cardno, string weixinID, string orderid)
        {
            MemberCard             MyCard       = MemberHelper.GetMemberCard(cardno, weixinID);
            MemberCardIntegralRule IntegralRule = MemberHelper.IntegralRule(Info, MyCard);

            var    dt    = SupermarketOrderDetailService.GetDataByOrderId(orderid);
            double money = 0;

            foreach (DataRow data in dt.Rows)
            {
                money += double.Parse(data["Price"].ToString()) * double.Parse(data["Total"].ToString());
            }

            string    sql1 = @"select top 1 id,Money from SupermarketOrder_Levi with (nolock) where OrderId=@OrderId";
            DataTable dt2  = SQLHelper.Get_DataTable(sql1, SQLHelper.GetCon(), new Dictionary <string, DBParam>()
            {
                { "OrderId", new HotelCloud.SqlServer.DBParam()
                  {
                      ParamValue = orderid
                  } }
            });

            //double money = double.Parse(dt.Rows[0]["Money"].ToString());
            SupermarketOrderId = dt2.Rows[0]["id"].ToString();

            var score = money;

            if (IntegralRule.equivalence > 0)
            {
                score = score * IntegralRule.equivalence;
            }
            if ((double)IntegralRule.GradePlus > 0)
            {
                score = score * (double)IntegralRule.GradePlus;
            }
            return((int)Math.Floor(Math.Round(score, 2)));
        }
Ejemplo n.º 2
0
        public ActionResult OrderDetails(string id)
        {
            string hotelId      = id;
            string key          = HotelCloud.Common.HCRequest.GetString("key");      //"酒店微信id@用户微信id"
            string weixinid     = HotelCloud.Common.HCRequest.GetString("weixinID"); //酒店微信id
            string userweixinid = "";

            if (!key.Equals("") && key.Contains("@"))
            {
                weixinid     = key.Split('@')[0];//酒店微信id
                userweixinid = key.Split('@')[1];
            }

            //计算订单总金额
            var     shoppingCarDataTable = cartService.GetDataByUserId(id, userweixinid);
            double  sum          = 0;
            decimal canCouponSum = 0;
            int     needPoints   = 0;
            int     canPoints    = 1;

            foreach (DataRow data in shoppingCarDataTable.Rows)
            {
                sum += double.Parse(data["Price"].ToString()) * int.Parse(data["Total"].ToString());
                if (int.Parse(data["CanCouPon"].ToString()) == 1)
                {
                    canCouponSum += decimal.Parse(data["Price"].ToString()) * int.Parse(data["Total"].ToString());
                }
                if (int.Parse(data["CanPurchase"].ToString()) == 0)
                {
                    canPoints = 0;
                }
                else
                {
                    needPoints += int.Parse(data["PurchasePoints"].ToString()) * int.Parse(data["Total"].ToString());
                }
            }
            ViewData["NoExpressAmount"] = sum;
            ViewData["canPoints"]       = canPoints;
            ViewData["needPoints"]      = needPoints;
            ViewData["myPoints"]        = 0;
            var userDt = orderService.GetScoreByUser(weixinid, userweixinid);

            if (userDt.Rows.Count > 0)
            {
                ViewData["myPoints"] = userDt.Rows[0]["Emoney"];
            }

            //获取收货地址
            List <OrderAddress> list    = DishOrderLogic.GetAddressList(userweixinid);
            OrderAddress        address = list.Find(a => a.isSelected == true);

            ViewData["ExpressFee"]    = 0;
            ViewData["hotelName"]     = DishOrderLogic.GetHotelName(hotelId);
            ViewData["addressRoomNo"] = "";
            if (address != null)
            {
                var hotelData = SupermarketController.GetHotelBySupermarket(int.Parse(id)).Rows[0];
                ViewData["ExpressFee2"] = hotelData["expressfee"];
                if (address.addressType == 1)
                {
                    ViewData["addressType"]   = "酒店";
                    ViewData["addressName"]   = address.Address + address.RoomNo;
                    ViewData["addressRoomNo"] = address.RoomNo;
                    ViewData["ExpressFee"]    = 0;
                }
                else
                {
                    ViewData["addressType"] = "快递";
                    ViewData["addressName"] = address.kuaidiAddress;
                    try
                    {
                        ViewData["ExpressFee"] = hotelData["expressfee"];
                        ViewData["hotelPhone"] = hotelData["tel"];
                        sum += double.Parse(hotelData["expressfee"].ToString());
                    }
                    catch (Exception e)
                    {
                        ViewData["ExpressFee"] = 0;
                        ViewData["hotelPhone"] = "";
                    }
                }
                ViewData["Address"]           = address;
                ViewData["OriginAddressType"] = address.addressType;
            }
            else
            {
                ViewData["Address"]           = new OrderAddress();
                ViewData["addressType"]       = "酒店";
                ViewData["hotelPhone"]        = "";
                ViewData["addressName"]       = ViewData["hotelName"];
                ViewData["OriginAddressType"] = 1;
            }


            //获取可用红包
            var couponDataTable = CouPon.GetUserCouPonDataTable(weixinid, userweixinid, "3");

            ViewData["couponDataTable"] = new DataTable();
            ViewData["canCouponSum"]    = canCouponSum;
            if (couponDataTable.Rows.Count > 0 && canCouponSum > 0)
            {
                ViewData["couponDataTable"] = couponDataTable;
                //var q1 = from dt1 in couponDataTable.AsEnumerable()//查询
                //         //orderby dt1.Field<int>("ID") descending//排序
                //         where dt1.Field<decimal>("amountlimit") <= canCouponSum//条件
                //         select dt1;
                //if (q1.Count() > 0)
                //{
                //    ViewData["couponDataTable"] = q1.CopyToDataTable<DataRow>();
                //}
            }

            //获取积分
            ViewData["orderScore"]  = 0;
            ViewData["equivalence"] = 1;
            ViewData["GradePlus"]   = 1;
            MemberInfo Info   = MemberHelper.GetMemberInfo(weixinid);
            string     cardno = MemberHelper.GetCardNo(userweixinid, weixinid);

            if (!string.IsNullOrEmpty(cardno))
            {
                MemberCard             MyCard       = MemberHelper.GetMemberCard(cardno, weixinid);
                MemberCardIntegralRule IntegralRule = MemberHelper.IntegralRule(Info, MyCard);
                var score = sum;
                if (IntegralRule.equivalence > 0)
                {
                    score = score * IntegralRule.equivalence;
                    ViewData["equivalence"] = IntegralRule.equivalence;
                }
                if ((double)IntegralRule.GradePlus > 0)
                {
                    score = score * (double)IntegralRule.GradePlus;
                    ViewData["GradePlus"] = IntegralRule.GradePlus;
                }

                ViewData["orderScore"] = Math.Floor(Math.Round(score, 2));
            }

            ViewData["shoppingCarDataTable"] = shoppingCarDataTable;
            ViewData["amount"]       = sum;
            ViewData["hotelId"]      = id;
            ViewData["weixinid"]     = weixinid;
            ViewData["userweixinid"] = userweixinid;
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult blue_OrderDetails2(string id)
        {
            string hotelId      = id;
            string orderId      = HotelCloud.Common.HCRequest.GetString("orderid");
            string key          = HotelCloud.Common.HCRequest.GetString("key");      //"酒店微信id@用户微信id"
            string weixinid     = HotelCloud.Common.HCRequest.GetString("weixinID"); //酒店微信id
            string userweixinid = "";

            if (!key.Equals("") && key.Contains("@"))
            {
                weixinid     = key.Split('@')[0];//酒店微信id
                userweixinid = key.Split('@')[1];
            }

            ViewData["list_ordersLog"]       = new DataTable();
            ViewData["PayStatus"]            = 0;
            ViewData["addressType"]          = "酒店";
            ViewData["shoppingCarDataTable"] = new DataTable();
            ViewData["amount"]             = 0;
            ViewData["refundfee"]          = 0;
            ViewData["ExpressCompany"]     = "";
            ViewData["ExpressNo"]          = "";
            ViewData["hotelId"]            = "";
            ViewData["ExpressFee"]         = 0;
            ViewData["remark"]             = "";
            ViewData["OrderStatus"]        = 0;
            ViewData["CreateTime"]         = new DateTime();
            ViewData["CanPurchase"]        = 0;
            ViewData["PurchasePoints"]     = 0;
            ViewData["PayMethod"]          = "";
            ViewData["isAllowDelayed"]     = false;
            ViewData["isShowAllowDelayed"] = true;
            ViewData["DelayedTake"]        = 0;
            ViewData["CouponId"]           = "";
            ViewData["CouponMoney"]        = 0;
            ViewData["express"]            = new ExpressData();
            ViewData["weixinid"]           = weixinid;
            ViewData["userweixinid"]       = userweixinid;
            ViewData["orderId"]            = orderId;
            ViewData["hotelId"]            = id;
            try
            {
                var    orderData = orderService.GetDataByOrderId(orderId).Rows[0];
                double refundfee = 0;
                try
                {
                    refundfee = double.Parse(orderData["Refundfee"].ToString()) + double.Parse(orderData["CardRefundfee"].ToString());
                }
                catch (Exception e) { }
                ViewData["refundfee"] = refundfee;

                //计算订单总金额
                double sum = 0;
                var    shoppingCarDataTable = SupermarketOrderDetailService.GetDataByOrderId(orderId);
                foreach (DataRow data in shoppingCarDataTable.Rows)
                {
                    sum += double.Parse(data["Price"].ToString()) * double.Parse(data["Total"].ToString());
                }

                //获取收货地址
                ViewData["hotelName"]  = DishOrderLogic.GetHotelName(orderData["HotelId"].ToString());
                ViewData["ExpressFee"] = 0;
                TimeSpan ts = new TimeSpan();    //用于计算是否可延迟收货
                if (!string.IsNullOrWhiteSpace(orderData["AddressType"].ToString()))
                {
                    if (orderData["AddressType"].ToString() == "1")
                    {
                        ViewData["addressType"] = "酒店";
                        ts = DateTime.Now - DateTime.Parse(orderData["CreateTime"].ToString()).AddDays(4);
                    }
                    else
                    {
                        ViewData["addressType"] = "快递";
                        ts   = DateTime.Now - DateTime.Parse(orderData["CreateTime"].ToString()).AddDays(12);
                        sum += double.Parse(orderData["ExpressFee"].ToString());
                    }
                    ViewData["addressName"] = orderData["Address"].ToString();
                }
                else
                {
                    ViewData["Address"]     = new OrderAddress();
                    ViewData["addressType"] = "酒店";
                    ViewData["addressName"] = ViewData["hotelName"];
                }
                ViewData["Linkman"]   = orderData["Linkman"].ToString();
                ViewData["LinkPhone"] = orderData["LinkPhone"].ToString();

                ViewData["isAllowDelayed"]     = false;
                ViewData["isShowAllowDelayed"] = true;
                ViewData["DelayedTake"]        = orderData["DelayedTake"];
                if (orderData["DelayedTake"].ToString() == "0")
                {
                    ViewData["isAllowDelayed"] = ts.Days >= 0 ? true : false;
                }
                else
                {
                    ViewData["isShowAllowDelayed"] = false;
                }


                //获取快递信息
                Express express = GetExpressData(orderData["ExpressNo"].ToString());
                try
                {
                    ViewData["express"] = express.data[0];
                }
                catch (Exception e)
                {
                    ViewData["express"] = new ExpressData();
                }

                try
                {
                    var hotelData = GetHotelBySupermarket(int.Parse(id)).Rows[0];
                    ViewData["hotelPhone"] = hotelData["tel"];
                }
                catch
                {
                    ViewData["hotelPhone"] = "";
                }

                //获取积分
                ViewData["orderScore"]  = 0;
                ViewData["equivalence"] = 1;
                ViewData["GradePlus"]   = 1;
                MemberInfo Info   = MemberHelper.GetMemberInfo(weixinid);
                string     cardno = MemberHelper.GetCardNo(userweixinid, weixinid);
                if (!string.IsNullOrEmpty(cardno))
                {
                    MemberCard             MyCard       = MemberHelper.GetMemberCard(cardno, weixinid);
                    MemberCardIntegralRule IntegralRule = MemberHelper.IntegralRule(Info, MyCard);
                    var score = sum;
                    if (IntegralRule.equivalence > 0)
                    {
                        score = score * IntegralRule.equivalence;
                        ViewData["equivalence"] = IntegralRule.equivalence;
                    }
                    if ((double)IntegralRule.GradePlus > 0)
                    {
                        score = score * (double)IntegralRule.GradePlus;
                        ViewData["GradePlus"] = IntegralRule.GradePlus;
                    }

                    ViewData["orderScore"] = Math.Floor(Math.Round(score, 2));;
                }
                var dbLog = orderService.GetOrderLogDataByOrderId(orderId);
                ViewData["list_ordersLog"] = dbLog;
                ViewData["PayStatus"]      = orderData["PayStatus"];

                ViewData["shoppingCarDataTable"] = shoppingCarDataTable;
                ViewData["amount"]         = orderData["Money"];
                ViewData["ExpressCompany"] = orderData["ExpressCompany"];
                ViewData["ExpressNo"]      = orderData["ExpressNo"];
                ViewData["hotelId"]        = orderData["HotelId"].ToString();
                ViewData["ExpressFee"]     = orderData["ExpressFee"];
                ViewData["remark"]         = orderData["Remark"].ToString();
                ViewData["OrderStatus"]    = orderData["OrderStatus"].ToString();
                ViewData["CreateTime"]     = orderData["CreateTime"];
                ViewData["CanPurchase"]    = orderData["CanPurchase"];
                ViewData["PurchasePoints"] = orderData["PurchasePoints"];
                ViewData["PayMethod"]      = orderData["PayMethod"];
                ViewData["CouponId"]       = orderData["CouponId"];
                ViewData["CouponMoney"]    = orderData["CouponMoney"];
                ViewData["weixinid"]       = weixinid;
                ViewData["userweixinid"]   = userweixinid;
                ViewData["orderId"]        = orderId;
            }
            catch (Exception e) { }
            return(View());
        }