Exemple #1
0
        /// <summary>
        /// 获得团详情页分享Json
        /// </summary>
        /// <param name="URL"></param>
        /// <returns></returns>
        private JsonResult TeamJoinDetail(string URL)
        {
            string     TeamCodeStr  = "";
            string     OrderCodeStr = "";
            JsonResult json         = null;

            Uri    uri      = new Uri(URL);
            int    index    = uri.Query.IndexOf("?");
            string urlQuery = uri.Query.Substring(index + 1, uri.Query.Length - 1);

            string[] urlParams = urlQuery.Split('&');
            foreach (string param in urlParams)
            {
                string[] items = param.Split('=');
                if (items[0].Equals("TeamCode"))
                {
                    TeamCodeStr = items[1];
                }
                else if (items[0].Equals("OrderCode"))
                {
                    OrderCodeStr = items[1];
                }
            }
            //LogHelper.Info("------------Shared-----URL1:" + URL);

            IList <TeamDetailEntity> teamDetailList = null;

            if (!string.IsNullOrEmpty(TeamCodeStr))
            {
                /// 获取团详情信息
                teamDetailList = teamBll.GetTeamDetailList(TeamCodeStr);
                //LogHelper.Info("------------Shared-----teamDetailList:" + teamDetailList);
            }
            else if (!string.IsNullOrEmpty(OrderCodeStr))
            {
                TeamInfoEntity teamInfoEntity = teamBll.GetTeamInfoEntity(OrderCodeStr);
                //LogHelper.Info("------------Shared-----teamInfoEntity:" + teamInfoEntity);
                if (teamInfoEntity != null)
                {
                    TeamCodeStr = teamInfoEntity.TeamCode;
                    //LogHelper.Info("------------Shared-----TeamCodeStr:" + TeamCodeStr);

                    /// 获取团详情信息
                    teamDetailList = teamBll.GetTeamDetailList(TeamCodeStr);
                    //LogHelper.Info("------------Shared-----teamDetailList:" + teamDetailList);
                }
            }
            else
            {
                return(Json(new
                {
                    type = (int)ShareUtils.JsonType.typeFailed,
                    content = ShareUtils.JsonContent_TeamCodeIsNull
                }, JsonRequestBehavior.AllowGet));
            }

            /// 判断集合是否为空
            if (teamDetailList == null || teamDetailList.Count() == 0)
            {
                return(Json(new
                {
                    type = (int)ShareUtils.JsonType.typeFailed,
                    content = ShareUtils.JsonContent_TeamListIsNull
                }, JsonRequestBehavior.AllowGet));
            }

            //LogHelper.Info("------------Shared-----URL2:" + URL);
            //LogHelper.Info("------------Shared-----ImagePath:" + teamDetailList.First().ImagePath);

            // 获得商品净重、净含量信息,再重新装配数据集合
            List <TeamDetailEntity> teamDetailProductList = new List <TeamDetailEntity>();

            foreach (TeamDetailEntity product in teamDetailList)
            {
                string neight = commonBll.getProductDetailName(product.MainDicValue, product.SubDicValue, product.NetWeightUnit);
                product.NetWeightUnit = neight;
                teamDetailProductList.Add(product);
            }

            /// 获得团详情页分享对象
            TeamSharedModel teamSharedModel = GetTeamSharedInfo(teamDetailProductList);

            /// 获得微信配置信息
            JSSDKModel JsSdkModel = GetWechatParams(URL);

            if (JsSdkModel.type == (int)ShareUtils.JsonType.typeFailed)
            {
                return(Json(new
                {
                    type = JsSdkModel.type,
                    content = JsSdkModel.content
                }, JsonRequestBehavior.AllowGet));
            }

            //LogHelper.Info("------------Shared-------TeamCode:" + TeamCodeStr);

            // 获得团成员剩余数量
            int value = teamSharedModel.RestTeamMemberNum;

            /*LogHelper.Info("------------Shared----RestTeamMemberNum-----RestTeamMemberNum:" + value);
             * LogHelper.Info("------------Shared-----Title:" + teamSharedModel.Title);
             * LogHelper.Info("------------Shared-----ImagePath:" + teamSharedModel.ImagePath);
             * LogHelper.Info("------------Shared-----Description:" + teamSharedModel.Description);
             * LogHelper.Info("------------Shared-----URL3:" + teamSharedModel.Url);*/

            json = Json(new
            {
                type = JsSdkModel.type,
                data = new
                {
                    appId       = JsSdkModel.appId,
                    timestamp   = JsSdkModel.timestamp,
                    nonceStr    = JsSdkModel.nonceStr,
                    signature   = JsSdkModel.signature,
                    jsApiList   = JsSdkModel.jsApiList,
                    Title       = teamSharedModel.Title,
                    ImagePath   = teamSharedModel.ImagePath,
                    Description = teamSharedModel.Description,
                    Url         = URL
                }
            }, JsonRequestBehavior.AllowGet);

            return(json);
        }
Exemple #2
0
        /// <summary>
        /// 团详情页
        /// </summary>
        /// <param name="TeamCode"></param>
        /// <returns></returns>
        public ActionResult TeamDetail(string TeamCode, string OrderCode, int Flag)
        {
            try
            {
                string teamCodeStr = "";

                if (OrderCode != null)
                {
                    /// 获取订单所属的团信息
                    TeamInfoEntity teamInfoEntity = teamBll.GetTeamInfoEntity(OrderCode);
                    teamCodeStr = teamInfoEntity.TeamCode;

                    /// 获得团成员UserId
                    int TeamUserId = teamBll.GetTeamUserId(OrderCode, teamCodeStr);
                    ViewBag.TeamUserId       = TeamUserId; /// 团成员UserId
                    ViewBag.IsOrderCodeInput = 1;          /// OrderCode有值
                }
                else
                {
                    teamCodeStr = TeamCode;
                }

                if (string.IsNullOrEmpty(teamCodeStr))
                {
                    return(View("Error"));
                }

                /// 获取团详情信息
                var teamDetailListInfo = teamBll.GetTeamDetailList(teamCodeStr);
                List <TeamDetailEntity> teamDetailList = new List <TeamDetailEntity>();
                foreach (TeamDetailEntity product in teamDetailListInfo)
                {
                    string neight = commonBll.getProductDetailName(product.MainDicValue, product.SubDicValue, product.NetWeightUnit);
                    product.NetWeightUnit = neight;
                    teamDetailList.Add(product);
                }

                /// 登录用户ID
                int LoginUserId = 0;

                if (base.LoginUser != null)
                {
                    LoginUserId = base.LoginUser.UserID;
                }

                /// 倒计时秒数
                double sec = 0.0;

                DateTime dtStartTime = DateTime.Now;
                DateTime dtEndTime   = Convert.ToDateTime(teamDetailList.First().EndTime);
                sec = dtEndTime.Subtract(dtStartTime).TotalSeconds;

                /// 组团成功
                if (teamDetailList.First().TeamStatus == 3)
                {
                    ViewBag.TeamStatus = 3;
                }
                /// 参团中
                else if (teamDetailList.First().TeamStatus == 1)
                {
                    if (sec > 0)
                    {
                        ViewBag.restTime = sec;
                    }
                    else
                    {
                        ViewBag.restTime = 0;
                    }
                    ViewBag.TeamStatus = teamDetailList.First().TeamStatus;/// 组团状态
                }
                /// 参团失败
                else
                {
                    ViewBag.TeamStatus = teamDetailList.First().TeamStatus;/// 组团状态
                }

                /// 设置页面属性值
                ViewBag.LoginUserId  = LoginUserId;
                ViewBag.TeamHead     = teamDetailList.First().TeamHead;                                                          /// 团长
                ViewBag.TeamNumbers  = teamDetailList.First().TeamNumbers;                                                       /// 几人团
                ViewBag.ListLength   = teamDetailList.Count();                                                                   /// 团详情集合长度
                ViewBag.productPrice = (teamDetailList.First().DiscountPrice *base.ExchangeRate).ToNumberRoundStringWithPoint(); /// 拼团价格
                ViewBag.RestNumber   = teamDetailList.First().TeamNumbers - teamDetailList.Count();                              /// 组团剩余人数
                ViewBag.Flag         = Flag;
                ///ViewBag.restTime = restTime;
                return(View(teamDetailList));
            }
            catch (Exception ex)
            {
                return(HandleError(ex));
            }
        }