Ejemplo n.º 1
0
        public ActionResult CommodityRichText(string id)
        {
            string hotelId      = id;
            string key          = HotelCloud.Common.HCRequest.GetString("key");         //"酒店微信id@用户微信id"
            string weixinid     = HotelCloud.Common.HCRequest.GetString("weixinID");    //酒店微信id
            string commodityId  = HotelCloud.Common.HCRequest.GetString("CommodityID"); //酒店微信id
            string userweixinid = "";

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

            var hotelData = GetHotelBySupermarket(int.Parse(id)).Rows[0];

            ViewData["myPoints"] = 0;
            var userDt = orderService.GetScoreByUser(weixinid, userweixinid);

            if (userDt.Rows.Count > 0)
            {
                ViewData["myPoints"] = userDt.Rows[0]["Emoney"];
            }
            ViewData["Address"]        = hotelData["address"];
            ViewData["soldCount"]      = SupermarketOrderDetailService.GetSoldCount(commodityId).Rows[0][0];
            ViewData["hotelName"]      = DishOrderLogic.GetHotelName(hotelId);
            ViewData["commodityTable"] = DataTable;
            ViewData["hotelId"]        = id;
            ViewData["weixinid"]       = weixinid;
            ViewData["userweixinid"]   = userweixinid;
            ViewData["CommodityID"]    = commodityId;
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Logistics(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];
            }

            var orderData = orderService.GetDataByOrderId(orderId).Rows[0];
            //获取快递信息
            Express express = GetExpressData(orderData["ExpressNo"].ToString());

            ViewData["expressCompany"] = orderData["ExpressCompany"];
            ViewData["expressOrder"]   = orderData["ExpressNo"];
            ViewData["express"]        = express;

            var dtCommodity = SupermarketOrderDetailService.GetDataByOrderId(orderId).Rows;

            ViewData["imagePath"]      = dtCommodity[0]["ImageList"].ToString().Split(',')[0];
            ViewData["CommodityCount"] = dtCommodity.Count;

            ViewData["isAllowDelayed"]     = false;
            ViewData["isShowAllowDelayed"] = true;
            if (orderData["DelayedTake"].ToString() == "0")
            {
                TimeSpan ts = DateTime.Now - DateTime.Parse(orderData["CreateTime"].ToString()).AddDays(7);
                ViewData["isAllowDelayed"] = ts.Days >= 0 ? true : false;
            }
            else
            {
                ViewData["isShowAllowDelayed"] = false;
            }

            ViewData["hotelId"]      = orderData["HotelId"].ToString();
            ViewData["OrderStatus"]  = orderData["OrderStatus"].ToString();
            ViewData["orderId"]      = orderId;
            ViewData["weixinid"]     = weixinid;
            ViewData["userweixinid"] = userweixinid;
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult CreateOrderAlone(string id)
        {
            string key          = HotelCloud.Common.HCRequest.GetString("key");//"酒店微信id@用户微信id"
            string weixinID     = HotelCloud.Common.HCRequest.GetString("weixinID");
            string userweixinID = HotelCloud.Common.HCRequest.GetString("userweixinID");
            string remark       = HotelCloud.Common.HCRequest.GetString("remark");
            string LinkMan      = HotelCloud.Common.HCRequest.GetString("LinkMan");
            string LinkPhone    = HotelCloud.Common.HCRequest.GetString("LinkPhone");
            string Address      = HotelCloud.Common.HCRequest.GetString("Address");
            string AddressType  = HotelCloud.Common.HCRequest.GetString("AddressType");
            string ExpressFee   = HotelCloud.Common.HCRequest.GetString("ExpressFee");
            string useScorePay  = HotelCloud.Common.HCRequest.GetString("useScorePay");
            string commodityId  = HotelCloud.Common.HCRequest.GetString("commodityId");
            string commodityNum = HotelCloud.Common.HCRequest.GetString("commodityNum");
            string CouponId     = HotelCloud.Common.HCRequest.GetString("CouponId");
            string CouponMoney  = HotelCloud.Common.HCRequest.GetString("CouponMoney");
            //string CanPurchase = HotelCloud.Common.HCRequest.GetString("CanPurchase");
            //string PurchasePoints = HotelCloud.Common.HCRequest.GetString("PurchasePoints");
            string orderId     = "";
            string OrderSource = "微官网";

            if (!string.IsNullOrWhiteSpace(HotelCloud.Common.HCRequest.GetString("OrderSource")))
            {
                OrderSource = HotelCloud.Common.HCRequest.GetString("OrderSource");
            }


            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    //检查红包是否可用
                    if (!string.IsNullOrWhiteSpace(CouponId))
                    {
                        bool couponCanUse = WeiXin.Models.Home.CouPonContent.IsCouPonContentEnable(weixinID, userweixinID, int.Parse(CouponId));
                        if (!couponCanUse)
                        {
                            throw new Exception();
                        }
                    }
                    //创建订单
                    orderId = orderService.InsertOrderAlone(weixinID, userweixinID, id, remark, LinkMan, LinkPhone, AddressType, Address, ExpressFee, CouponId, CouponMoney, commodityId, commodityNum, OrderSource);
                    if (!string.IsNullOrWhiteSpace(orderId))
                    {
                        orderService.InsertOrderLog(orderId, "创建订单", 1, "系统");
                    }
                    else
                    {
                        throw new Exception();
                    }

                    if (useScorePay == "1")
                    {
                        //获取用户积分
                        var myPoints = 0;
                        var userDt   = orderService.GetScoreByUser(weixinID, userweixinID);
                        if (userDt.Rows.Count > 0)
                        {
                            myPoints = int.Parse(userDt.Rows[0]["Emoney"].ToString());
                        }
                        //var shoppingCarDataTable = cartService.GetDataByUserId(id, userweixinID);
                        var shoppingCarDataTable = SupermarketOrderDetailService.GetDataByOrderId(orderId);
                        //获取订单所需积分
                        int needPoints = 0;
                        foreach (DataRow data in shoppingCarDataTable.Rows)
                        {
                            needPoints += int.Parse(data["PurchasePoints"].ToString()) * int.Parse(data["Total"].ToString());
                        }
                        if (myPoints - needPoints < 0 || shoppingCarDataTable.Rows.Count == 0)
                        {
                            return(Json(new
                            {
                                orderId = orderId,
                                error = 2,
                                message = "无法使用积分支付,请使用其他支付方式"
                            }));
                        }
                        //用户扣除积分支付订单
                        int result2 = orderService.DeductionPoints(weixinID, userweixinID, needPoints);
                        int result1 = orderService.CreateUseScoreLog(weixinID, userweixinID, orderId);
                        int result  = orderService.PayOrder(orderId, "积分支付");
                        if (result2 == 0 || result1 == 0 || result == 0)
                        {
                            return(Json(new
                            {
                                orderId = orderId,
                                error = 2,
                                message = "无法使用积分支付,请使用其他支付方式"
                            }));
                        }
                    }

                    ts.Complete();
                }
                catch (Exception e)
                {
                    //ts.Dispose();
                    return(Json(new
                    {
                        orderId = "",
                        error = 1,
                        message = "订单创建失败,请重新选购商品"
                    }));
                }
            }

            return(Json(new
            {
                orderId = orderId,
                error = 0,
                message = "创建成功"
            }));

            //orderId = orderService.InsertOrder(weixinID, userweixinID, id, remark, LinkMan, LinkPhone, AddressType, Address, ExpressFee);
            //if (!string.IsNullOrWhiteSpace(orderId))
            //    orderService.InsertOrderLog(orderId,"创建订单",1,"系统");
            //return Json(new
            //{
            //    orderId = orderId,
            //    message = "数据操作错误,请联系管理人员"
            //});
        }
Ejemplo n.º 4
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());
        }