/// <summary>
        /// 产品首页
        /// </summary>
        /// <param name="code">微信的code</param>
        /// <param name="from">标志用户来源 如果微信公众号点击过来值为wx</param>
        /// <returns></returns>
        // GET: Product
        public ActionResult Index(String code, string from)
        {
            LogOpert.AddWeiXinMessage("开始进入到产品页面:code值为:" + code);

            ///// 获取用户信息
            ViewBag.Message = new ProductBus().GetWXUserInfoJesonByCode(code);
            LogOpert.AddWeiXinMessage("渲染产品页面:处理后的用户信息为:" + ViewBag.Message);
            return(View());
        }
        /// <summary>
        /// 分页获取订单数据信息
        /// </summary>
        /// <param name="pagIndex"></param>
        /// <param name="orderstats">订单状态 0:全部 4:待送货 7:派送中 8:完成</param>
        /// <returns></returns>
        public string GetOrderInfoPagList(string pagIndex, int orderState)
        {
            if (!this.CheckIsLogin())
            {
                return("-1");
            }

            int pageIndexI = 1;

            int.TryParse(pagIndex, out pageIndexI);
            LogOpert.AddWeiXinMessage("获取订单列表1:" + Session["loginuserId"]);

            return(new OrderBus().GetOrderInfoPagList(pageIndexI, Session["loginuserId"] + string.Empty, string.Empty, orderState > 0 ? orderState : -1, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 分页获取订单数据信息
        /// </summary>
        /// <param name="pagIndex"></param>
        /// <param name="userId"></param>
        /// <param name="orderState"></param>
        /// <param name="productname"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public string GetOrderInfoPagList(int pagIndex, string userId, string userName,
                                          int orderState, string productname, string startTime, string endTime, string groupOrderId, string orderId)
        {
            try
            {
                LogOpert.AddWeiXinMessage("获取订单列表:" + userId);

                //// 实现步骤
                //// 1、首先获取符号要求的数据总条数
                //// 2、根据获取到数据条数、每页数据量、页码。优化处理页面
                //// 3、获取具体的分页数据信息

                MPageListResult <Morder> pageListResult = new MPageListResult <Morder>();

                //// 每页获取20条数据
                int pagSize = 20;

                //// 1、首先获取符号要求的数据总条数
                OrderService orderService = new OrderService();
                if (!string.IsNullOrEmpty(endTime))
                {
                    endTime = Convert.ToDateTime(endTime).AddDays(1).ToString("yyyy-MM-dd");
                }
                pageListResult.totalNum = orderService.GetOrderInfoPagCount(userId, userName, orderState,
                                                                            productname, startTime, endTime, groupOrderId, orderId);
                if (pageListResult.totalNum > 0)
                {
                    //// 2、根据获取到数据条数、每页数据量、页码。优化处理页面
                    pageListResult.totalPage = (int)Math.Ceiling((double)pageListResult.totalNum / pagSize);
                    pagIndex = pagIndex > pageListResult.totalPage ? pageListResult.totalPage : pagIndex;

                    //// 3、获取具体的分页数据信息
                    pageListResult.dataList = orderService.GetOrderInfoPagList(pagIndex, pagSize, userId, userName, orderState,
                                                                               productname, startTime, endTime, groupOrderId, orderId);
                }

                pageListResult.pagIndex = pagIndex;
                pageListResult.pagSize  = pagSize;
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                };
                return(JsonConvert.SerializeObject(pageListResult, Formatting.Indented, timeConverter));
            }
            catch (Exception ex)
            {
                return(string.Empty);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据code获取用户信息jeson对象
        /// </summary>
        /// <param name="code"></param>
        public string GetWXUserInfoJesonByCode(string code)
        {
            LogOpert.AddWeiXinMessage("微信用户信息:" + code);
            try
            {
                if (!string.IsNullOrEmpty(code))
                {
                    MWXUserInfo userMdel = this.GetWXUserInfoByCode(code);
                    if (userMdel != null)
                    {
                        return(JsonHelper.GetJson <MWXUserInfo>(userMdel));
                    }
                }

                return(string.Empty);
            }
            catch (Exception ex)
            {
                LogOpert.AddWeiXinMessage("用户信息获取处理异常:" + ex.Message);
                return(string.Empty);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 加入到购物车
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string AddShopCart(MshoppingCart model)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                bool addResult = true;

                ShoppingCartService opert = new ShoppingCartService();
                //// 补全产品信息
                Mproduct product = new ProductBus().GetProductById(model.productId);
                if (product == null || string.IsNullOrEmpty(product.productid))
                {
                    addResult = false;
                }
                else
                {
                    string productformatunit = product.productformatunit == "0" ? "个" :
                                               product.productformatunit == "1" ? "袋" :
                                               product.productformatunit == "2" ? "斤" :
                                               product.productformatunit == "3" ? "瓶" :
                                               product.productformatunit == "4" ? "升" :
                                               product.productformatunit == "5" ? "听" :
                                               product.productformatunit == "4" ? "升" :
                                               product.productformatunit == "6" ? "件" :
                                               product.productformatunit == "7" ? "盒" :
                                               product.productformatunit == "8" ? "包" :
                                               product.productformatunit == "9" ? "提" : "双";
                    model.origPrice     = product.origprice;
                    model.productformat = $"{product.productformat}/{productformatunit}";
                    model.productname   = product.productname;
                    model.sellPrice     = product.sellprice;

                    //// 首先根据产id和用户 ID获取一次购物车信息
                    MshoppingCart shopCartModel = opert.GetShoppingCartListByUserIdAndProductId(model.userId, model.productId);

                    if (model.buyNum > 0)
                    {
                        ///// 加购物车
                        if (shopCartModel != null && !string.IsNullOrEmpty(shopCartModel.shoppingCartId))
                        {
                            /////  数量加1
                            addResult = opert.UpdatePriceAndNum(shopCartModel.shoppingCartId, model.userId,
                                                                model.origPrice, model.sellPrice, model.totalPrice + (model.sellPrice * model.buyNum), model.buyNum);
                        }
                        else
                        {
                            //// 新增
                            model.shoppingCartId = PublicTools.GetRandomNumberByTime();
                            addResult            = opert.Add(model);
                        }
                    }
                    else
                    {
                        //// 减购物车
                        if (shopCartModel != null && !string.IsNullOrEmpty(shopCartModel.shoppingCartId))
                        {
                            if (shopCartModel.buyNum <= (-model.buyNum))
                            {
                                //// 直接删除
                                addResult = opert.DeleteShoppingCartById(shopCartModel.shoppingCartId, shopCartModel.userId);
                            }
                            else
                            {
                                /////  数量减1
                                addResult = opert.UpdatePriceAndNum(shopCartModel.shoppingCartId, model.userId,
                                                                    model.origPrice, model.sellPrice, model.totalPrice + shopCartModel.totalPrice, model.buyNum);
                            }
                        }
                    }
                }


                if (addResult)
                {
                    mwxResult.errmsg  = "操作成功!";
                    mwxResult.errcode = 0;
                }
                else
                {
                    mwxResult.errmsg = "操作失败!";
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败!";
                LogOpert.AddWeiXinMessage("系统异常:" + ex.Message);
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }