Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            BLLJIMP.BLLDistributionOffLine bll = new BLLJIMP.BLLDistributionOffLine();
            BLLJIMP.BLLUser bllUser            = new BLLJIMP.BLLUser();

            int pageIndex  = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1; //页码
            int pageSize   = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 10;  //页数
            int totalCount = 0;
            var sourceList = bll.QueryWithdrawCashList(pageIndex, pageSize, CurrentUserInfo.UserID, out totalCount, "", context.Request["type"]);
            var list       = from p in sourceList
                             select new
            {
                id     = p.AutoID,                       //申请编号
                amount = p.Amount,                       //金额
                status = ConvertStatus(p.Status),        //状态
                time   = bll.GetTimeStamp(p.InsertDate), //时间
                score  = p.Score
            };
            var data = new
            {
                totalcount = totalCount,
                list       = list
            };

            apiResp.status = true;
            apiResp.msg    = "ok";
            apiResp.result = data;
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     BLLJIMP.BLLUser bllUser = new BLLJIMP.BLLUser("");
     BLLPermission.BLLMenuPermission bll = new BLLPermission.BLLMenuPermission("");
     string curUserID = bllUser.GetCurrUserID();
     canTeamExport = bll.CheckUserAndPmsKey(curUserID, BLLPermission.Enums.PermissionSysKey.TeamExport);
 }
Exemple #3
0
        public int SendSms(string userName, string userPwd, string mobile, string content, string pipeID, string attime = "")
        {
            try
            {
                //用户名密码不能为空
                if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(userPwd))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_LoginError);
                }

                BLLJIMP.BLLUser userBll = new BLLJIMP.BLLUser(userName);

                //用户登录
                if (!userBll.Login(userName, userPwd))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_LoginError);
                }

                //通道不能为空
                if (string.IsNullOrWhiteSpace(pipeID))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_PipeError);
                }

                //手机号码不能为空
                if (string.IsNullOrWhiteSpace(mobile))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_MobileEmpty);
                }

                //发送内容不能为空
                if (string.IsNullOrWhiteSpace(content))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_ContentEmpty);
                }

                pipeID = pipeID.ToLower().Trim();

                BLLJIMP.BLLSMS smsBll = new BLLJIMP.BLLSMS(userName);

                if (pipeID.Equals("membermission"))
                {
                    return((int)smsBll.SubmitSMSMission(pipeID, mobile, content, userName));
                }
                else
                {
                    return((int)smsBll.SubmitSMS(pipeID, mobile, content));
                }
            }
            catch
            {
                //SMS_Exception
                return((int)BLLJIMP.ReturnCode.SMS_Exception);
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string orderid = null;

            orderid = Request["oid"];
            if (string.IsNullOrEmpty(orderid))
            {
                Response.End();
            }

            if (bll.IsLogin)
            {
                userInfo  = bll.GetCurrentUserInfo();
                OrderInfo = bll.GetOrderInfo(orderid);
                if (OrderInfo == null)
                {
                    Response.End();
                }

                bool CanAccess = false;
                if (!OrderInfo.OrderUserID.Equals(userInfo.UserID))
                {
                    try
                    {
                        if (bll.GetWebsiteInfoModel().IsDistributionMall.Equals(1))
                        {
                            //检查是否是上下级关系
                            BLLJIMP.BLLDistribution bllDis  = new BLLJIMP.BLLDistribution();
                            BLLJIMP.BLLUser         bllUser = new BLLJIMP.BLLUser("");
                            if (bllDis.GetUserBetweenLevel(userInfo, bllUser.GetUserInfo(OrderInfo.OrderUserID)) > 0)
                            {
                                CanAccess = true;
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    CanAccess = true;
                }
                if (!CanAccess)
                {
                    Response.End();
                }
            }
            else
            {
                Response.Redirect("/App/Cation/Wap/Login.aspx?redirecturl=/App/Cation/Wap/Mall/Index.aspx");
            }
        }
Exemple #5
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            ZentCloud.BLLJIMP.Model.UserInfo user = Comm.DataLoadTool.GetCurrUserModel();
            user.Password = this.txtPwd.Text.Trim();

            BLLJIMP.BLLUser userBll = new BLLJIMP.BLLUser(user.UserID);

            if (userBll.Update(user))
            {
                Tool.AjaxMessgeBox.ShowMessgeBoxForAjax(this.UpdatePanel1, this.GetType(), "更新成功,稍后请重新登录!", Common.ConfigHelper.GetConfigString("logoutUrl"));
            }
            else
            {
                Tool.AjaxMessgeBox.ShowMessgeBoxForAjax(this.UpdatePanel1, this.GetType(), "更新失败!");
            }
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            user = Comm.DataLoadTool.GetCurrUserModel();

            userBll   = new BLLJIMP.BLLUser(user.UserID);
            weixinBll = new BLLJIMP.BLLWeixin(user.UserID);

            if (!IsPostBack)
            {
                SystemSet systemset = weixinBll.Get <SystemSet>("");
                //this.lbURL.Text = user.WeixinAPIUrl;
                this.txtToken.Text             = user.WeixinToken;
                this.txtWeinxinPublicName.Text = user.WeixinPublicName;
                this.lbURL.Text = string.Format("{0}/Weixin/OAuthPage.aspx?u={1}", systemset.weiXinAdDomain, Common.Base64Change.EncodeBase64ByUTF8(user.UserID));
                ZentCloud.BLLJIMP.Model.WeixinReplyRuleInfo menuModel = weixinBll.Get <ZentCloud.BLLJIMP.Model.WeixinReplyRuleInfo>(string.Format(" UserID = '{0}' and RuleType = 4 ", user.UserID));
                if (menuModel != null)
                {
                    this.txtMenuContent.Text = menuModel.ReplyContent;
                }
                txtAppId.Text     = user.WeixinAppId;
                txtAppSecret.Text = user.WeixinAppSecret;

                this.rblIsWeixinVerify.SelectedValue = user.IsWeixinVerify.ToString();

                if (user.WeixinIsEnableMenu != null)
                {
                    if (user.WeixinIsEnableMenu == 1)
                    {
                        rblEnableMenu.SelectedIndex = 0;
                    }
                    else
                    {
                        rblEnableMenu.SelectedIndex = 1;
                    }
                }
                else
                {
                    rblEnableMenu.SelectedIndex = 1;
                }
            }
        }
Exemple #7
0
        public void ProcessRequest(HttpContext context)
        {
            BLLJIMP.BLLUser bllUser     = new BLLJIMP.BLLUser();
            var             websiteInfo = bllUser.GetWebsiteInfoModelFromDataBase();

            if (!string.IsNullOrWhiteSpace(CurrentUserInfo.IMToken))
            {
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                apiResp.msg    = "获取用户成功";
                apiResp.status = true;
                apiResp.result = new {
                    appkey = websiteInfo.NIMAppKey,
                    accid  = CurrentUserInfo.AutoID,
                    token  = CurrentUserInfo.IMToken
                };
                new BLLJIMP.BLL().ContextResponse(context, apiResp);
                return;
            }
            BLLJIMP.BLLIM bllIM = new BLLJIMP.BLLIM(websiteInfo.NIMAppKey, websiteInfo.NIMAppSecret);
            string        token = "";

            if (CurrentUserInfo.UserType != 6)
            {
                token = bllIM.RefreshToken(CurrentUserInfo.AutoID.ToString());
                if (string.IsNullOrWhiteSpace(token))
                {
                    token = bllIM.CreateUser(CurrentUserInfo.AutoID.ToString(), bllUser.GetUserDispalyName(CurrentUserInfo), "", bllUser.GetUserDispalyAvatar(CurrentUserInfo));
                }
                bllUser.UpdateByKey <BLLJIMP.Model.UserInfo>("AutoID", CurrentUserInfo.AutoID.ToString(), "IMToken", token);
            }
            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
            apiResp.msg    = "获取用户成功";
            apiResp.status = true;
            apiResp.result = new
            {
                appkey = websiteInfo.NIMAppKey,
                accid  = CurrentUserInfo.AutoID,
                token  = token
            };
            new BLLJIMP.BLL().ContextResponse(context, apiResp);
        }
Exemple #8
0
        public void ProcessRequest(HttpContext context)
        {
            BLLJIMP.BLLDistributionOffLine bll = new BLLJIMP.BLLDistributionOffLine();
            BLLJIMP.BLLUser bllUser            = new BLLJIMP.BLLUser();

            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 userId       = "";
            string keyword      = context.Request["keyword"];
            string websiteowner = bllUser.WebsiteOwner;

            if (!string.IsNullOrWhiteSpace(keyword))
            {
                BLLJIMP.Model.UserInfo u = bllUser.GetUserInfo(keyword, websiteowner);
                if (u != null)
                {
                    userId = u.UserID;
                }
                if (string.IsNullOrWhiteSpace(userId))
                {
                    u = bllUser.GetUserInfoByPhone(keyword, websiteowner);
                    if (u != null)
                    {
                        userId = u.UserID;
                    }
                }
                if (string.IsNullOrWhiteSpace(userId))
                {
                    List <BLLJIMP.Model.UserInfo> ul = bllUser.GetUsersByLikeName(keyword, websiteowner);
                    if (ul.Count > 1)
                    {
                        userId = ZentCloud.Common.MyStringHelper.ListToStr(ul.Select(p => p.UserID).ToList(), "'", ",");
                    }
                    else if (ul.Count == 1)
                    {
                        userId = ul[0].UserID;
                    }
                }

                if (string.IsNullOrWhiteSpace(userId))
                {
                    userId = "-999";
                }
            }
            int            total      = 0;
            var            sourceList = bll.QueryWithdrawCashList(page, rows, userId, out total, context.Request["status"], context.Request["type"]);
            List <dynamic> list       = new List <dynamic>();

            if (sourceList.Count > 0)
            {
                foreach (var p in sourceList)
                {
                    BLLJIMP.Model.UserInfo u = bllUser.GetUserInfo(p.UserId, websiteowner);
                    list.Add(new
                    {
                        id       = p.AutoID,
                        amount   = p.Amount,                       //金额
                        status   = ConvertStatus(p.Status),        //状态
                        time     = bll.GetTimeStamp(p.InsertDate), //时间
                        score    = p.Score,
                        username = u == null ? p.UserId : bllUser.GetUserDispalyName(u)
                    });
                }
            }
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.msg    = "ok";
            apiResp.result = new{
                totalcount = total,
                list       = list
            };

            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Exemple #9
0
        public void ProcessRequest(HttpContext context)
        {
            /// <summary>
            /// 卡券BLL
            /// </summary>
            BLLJIMP.BLLCardCoupon bllCardCoupon = new BLLJIMP.BLLCardCoupon();
            /// <summary>
            /// 商城BLL
            /// </summary>
            BLLJIMP.BLLMall bllMall = new BLLJIMP.BLLMall();
            /// <summary>
            /// 用户BLL
            /// </summary>
            BLLJIMP.BLLUser bllUser = new BLLJIMP.BLLUser();
            /// <summary>
            /// 微信BLL
            /// </summary>
            BLLJIMP.BLLWeixin bllWeixin = new BLLJIMP.BLLWeixin();
            /// <summary>
            ///
            /// </summary>
            BLLJIMP.BLLStoredValueCard bllStoredValue = new BLLJIMP.BLLStoredValueCard();
            /// <summary>
            ///
            /// </summary>
            BLLJIMP.BLLWeixinCard bllWeixinCard = new BLLJIMP.BLLWeixinCard();

            string cardCouponId   = context.Request["cardcoupon_id"];    //主卡券ID
            string myCardCouponId = context.Request["my_cardcoupon_id"]; //我的卡券ID

            if (string.IsNullOrEmpty(cardCouponId))
            {
                resp.status = false;
                resp.msg    = "cardcoupon_id 参数必传";
                context.Response.Write(JsonConvert.SerializeObject(resp));
                return;
            }
            CardCoupons cardCoupon = bllCardCoupon.GetCardCouponByWXCardId(cardCouponId);

            if (cardCoupon == null)
            {
                cardCoupon = bllCardCoupon.GetCardCoupon(int.Parse(cardCouponId));
                if (cardCoupon == null)
                {
                    resp.status = false;
                    resp.msg    = "cardcoupon_id 不存在";
                    context.Response.Write(JsonConvert.SerializeObject(resp));
                    return;
                }
            }
            cardCoupon = bllCardCoupon.ConvertExpireTime(cardCoupon);

            MainCardModel model = new MainCardModel();

            model.cardcoupon_id      = cardCoupon.CardId;
            model.cardcoupon_name    = cardCoupon.Name;
            model.cardcoupon_type    = ConvertCardCouponType(cardCoupon.CardCouponType);
            model.valid_from         = cardCoupon.ValidFrom.ToString();
            model.valid_to           = cardCoupon.ValidTo.ToString();
            model.img_url            = bllMall.GetImgUrl(cardCoupon.Logo);
            model.discount           = string.IsNullOrEmpty(cardCoupon.Ex1) ? 0 : double.Parse(cardCoupon.Ex1);
            model.product_id         = string.IsNullOrEmpty(cardCoupon.Ex2) ? 0 : double.Parse(cardCoupon.Ex2);
            model.deductible_amount  = string.IsNullOrEmpty(cardCoupon.Ex3) ? 0 : double.Parse(cardCoupon.Ex3);
            model.freefreight_amount = string.IsNullOrEmpty(cardCoupon.Ex4) ? 0 : double.Parse(cardCoupon.Ex4);
            model.buckle_amount      = string.IsNullOrEmpty(cardCoupon.Ex5) ? 0 : double.Parse(cardCoupon.Ex5);
            model.buckle_sub_amount  = string.IsNullOrEmpty(cardCoupon.Ex6) ? 0 : double.Parse(cardCoupon.Ex6);
            model.max_count          = cardCoupon.MaxCount;
            model.send_count         = cardCoupon.SendCount;
            model.un_send_count      = cardCoupon.UnSendCount;
            //model.is_recivece = bllCardCoupon.IsReciveCoupon(cardCoupon.CardId, CurrentUserInfo.UserID);
            model.valid_to_timestamp  = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
            model.limit_type          = cardCoupon.Ex7;
            model.product_tags        = cardCoupon.Ex8;
            model.user_get_limit_type = cardCoupon.GetLimitType;
            model.is_can_use_shop     = cardCoupon.IsCanUseShop;
            model.is_can_use_groupbuy = cardCoupon.IsCanUseGroupbuy;
            model.expire_time_type    = cardCoupon.ExpireTimeType;
            model.expire_day          = cardCoupon.ExpireDay;
            model.weixin_card_id      = cardCoupon.WeixinCardId == null ? "" : cardCoupon.WeixinCardId;
            if (!string.IsNullOrEmpty(myCardCouponId))
            {
                MyCardCoupons myCardCoupon = bllCardCoupon.GetMyCardCoupon(int.Parse(myCardCouponId));
                if (myCardCoupon != null)
                {
                    UserInfo fromUserInfo = bllUser.GetUserInfo(myCardCoupon.UserId);

                    if (fromUserInfo != null)
                    {
                        model.from_user_info = new UserInfoModel();
                        model.from_user_info.head_img_url = bllUser.GetUserDispalyAvatar(fromUserInfo);
                        model.from_user_info.nick_name    = bllUser.GetUserDispalyName(fromUserInfo);
                    }

                    if (!string.IsNullOrEmpty(myCardCoupon.ToUserId))
                    {
                        model.is_donation = true;
                    }
                }
            }

            resp.status = true;
            resp.result = model;

            context.Response.Write(JsonConvert.SerializeObject(resp));
        }
Exemple #10
0
        public int SendSms(string userName, string userPwd, string mobile, string content, string pipeID, string attime)
        {
            try
            {
                //用户名密码不能为空
                if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(userPwd))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_LoginError);
                }

                BLLJIMP.BLLUser userBll = new BLLJIMP.BLLUser(userName);

                //用户登录
                if (!userBll.Login(userName, userPwd))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_LoginError);
                }

                //通道不能为空
                if (string.IsNullOrWhiteSpace(pipeID))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_PipeError);
                }

                //手机号码不能为空
                if (string.IsNullOrWhiteSpace(mobile))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_MobileEmpty);
                }

                //发送内容不能为空
                if (string.IsNullOrWhiteSpace(content))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_ContentEmpty);
                }

                pipeID = pipeID.ToLower().Trim();

                BLLJIMP.BLLSMS smsBll = new BLLJIMP.BLLSMS(userName);

                DateTime planTime = DateTime.Now;
                if (attime != null)
                {
                    if (!DateTime.TryParse(attime, out planTime))
                    {
                        return((int)BLLJIMP.ReturnCode.SMS_AddSMSPlanTimeError);
                    }
                    else
                    {
                        return((int)smsBll.SubmitSMSMission(pipeID, mobile, content, userName, planTime));
                    }
                }
                else
                {
                    return((int)smsBll.SubmitSMSMission(pipeID, mobile, content, userName));
                }
            }
            catch
            {
                //SMS_Exception
                return((int)BLLJIMP.ReturnCode.SMS_Exception);
            }
        }
Exemple #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BLLJIMP.BllOrder            bllOrder = new BLLJIMP.BllOrder();
            BLLJIMP.BLLUser             bllUser  = new BLLJIMP.BLLUser("");
            Dictionary <string, string> dicAll   = bllOrder.GetRequestParameter();

            if (dicAll.Count > 0)//判断是否有带返回参数
            {
                Notify notify       = new Notify();
                bool   verifyResult = notify.VerifyNotify(dicAll, dicAll["sign"]);
                if (verifyResult)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码

                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                    //解密(如果是RSA签名需要解密,如果是MD5签名则下面一行清注释掉)
                    //sPara = aliNotify.Decrypt(sPara);

                    //XML解析notify_data数据
                    try
                    {
                        XmlDocument xmlDoc = new XmlDocument();
                        xmlDoc.LoadXml(dicAll["notify_data"]);
                        xmlDoc.Save(string.Format("C:\\Alipay\\notify{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));
                        //商户订单号
                        string outTradeNo = xmlDoc.SelectSingleNode("/notify/out_trade_no").InnerText;
                        //支付宝交易号
                        string tradeNo = xmlDoc.SelectSingleNode("/notify/trade_no").InnerText;
                        //交易状态
                        string tradeStatus = xmlDoc.SelectSingleNode("/notify/trade_status").InnerText;
                        var    orderPay    = bllOrder.GetOrderPay(outTradeNo);
                        if (tradeStatus == "TRADE_FINISHED")
                        {
                            //判断该笔订单是否在商户网站中已经做过处理
                            //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                            //如果有做过处理,不执行商户的业务程序

                            //注意:
                            //该种交易状态只在两种情况下出现
                            //1、开通了普通即时到账,买家付款成功后。
                            //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。

                            if (orderPay.Status.Equals(0))     //只有未付款状态
                            {
                                if (orderPay.Type.Equals("1")) //投票充值
                                {
                                    ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
                                    try
                                    {
                                        UserInfo userInfo = bllUser.GetUserInfo(orderPay.UserId);
                                        if (userInfo.AvailableVoteCount == null)
                                        {
                                            userInfo.AvailableVoteCount = 0;
                                        }
                                        userInfo.AvailableVoteCount += int.Parse(orderPay.Ex1);
                                        orderPay.Status              = 1;
                                        orderPay.Trade_No            = tradeNo;
                                        if (!bllOrder.Update(orderPay, tran))
                                        {
                                            tran.Rollback();
                                            Response.Write("fail");
                                        }
                                        if (bllUser.Update(userInfo, string.Format(" AvailableVoteCount={0}", userInfo.AvailableVoteCount), string.Format(" AutoID={0}", userInfo.AutoID), tran) < 1)
                                        {
                                            tran.Rollback();
                                            Response.Write("fail");
                                        }
                                        tran.Commit();
                                        Response.Write("success");  //请不要修改或删除
                                    }
                                    catch (Exception ex)
                                    {
                                        tran.Rollback();
                                        Response.Write("fail");
                                    }
                                }
                                else
                                {
                                }
                            }


                            Response.Write("success");  //请不要修改或删除
                        }
                        else if (tradeStatus == "TRADE_SUCCESS")
                        {
                            //判断该笔订单是否在商户网站中已经做过处理
                            //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                            //如果有做过处理,不执行商户的业务程序

                            //注意:
                            //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。
                            if (orderPay.Status.Equals(0))   //只有未付款状态
                            {
                                if (orderPay.Type.Equals(1)) //投票充值
                                {
                                    ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
                                    try
                                    {
                                        UserInfo userInfo = bllUser.GetUserInfo(orderPay.UserId);
                                        if (userInfo.AvailableVoteCount == null)
                                        {
                                            userInfo.AvailableVoteCount = 0;
                                        }
                                        userInfo.AvailableVoteCount += int.Parse(orderPay.Ex1);
                                        orderPay.Status              = 1;
                                        orderPay.Trade_No            = tradeNo;
                                        if (!bllOrder.Update(orderPay, tran))
                                        {
                                            tran.Rollback();
                                            Response.Write("fail");
                                        }
                                        if (bllUser.Update(userInfo, string.Format(" AvailableVoteCount={0}", userInfo.AvailableVoteCount), string.Format(" AutoID={0}", userInfo.AutoID), tran) < 1)
                                        {
                                            tran.Rollback();
                                            Response.Write("fail");
                                        }
                                        tran.Commit();
                                        Response.Write("success");  //请不要修改或删除
                                    }
                                    catch (Exception Ex)
                                    {
                                        tran.Rollback();
                                        Response.Write("fail");
                                    }
                                }
                                else
                                {
                                }
                            }

                            Response.Write("success");  //请不要修改或删除
                        }
                        else
                        {
                            Response.Write(tradeStatus);
                        }
                    }
                    catch (Exception Ex)
                    {
                        Response.Write("fail");
                    }



                    //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
Exemple #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BLLJIMP.BllOrder            bllOrder = new BLLJIMP.BllOrder();
            BLLJIMP.BLLUser             bllUser  = new BLLJIMP.BLLUser("");
            Dictionary <string, string> dicAll   = GetRequestGet();

            if (dicAll.Count > 0)//判断是否有带返回参数
            {
                Notify notify       = new Notify();
                bool   verifyResult = notify.VerifyReturn(dicAll, Request.QueryString["sign"]);
                if (verifyResult)//验证成功
                {
                    try
                    {
                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        //请在这里加上商户的业务逻辑程序代码



                        //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                        //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表

                        //商户订单号
                        string outTrade_no = Request.QueryString["out_trade_no"];

                        //支付宝交易号
                        string tradeNo = Request.QueryString["trade_no"];

                        //交易状态
                        string result   = Request.QueryString["result"];
                        var    orderPay = bllOrder.GetOrderPay(outTrade_no);
                        if (orderPay.Status.Equals(0))     //只有未付款状态
                        {
                            if (orderPay.Type.Equals("1")) //投票充值
                            {
                                ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
                                try
                                {
                                    UserInfo userInfo = bllUser.GetUserInfo(orderPay.UserId);
                                    if (userInfo.AvailableVoteCount == null)
                                    {
                                        userInfo.AvailableVoteCount = 0;
                                    }
                                    userInfo.AvailableVoteCount += int.Parse(orderPay.Ex1);
                                    orderPay.Status              = 1;
                                    orderPay.Trade_No            = tradeNo;
                                    if (!bllOrder.Update(orderPay, tran))
                                    {
                                        tran.Rollback();
                                        Hmsg.InnerHtml = "更新订单失败";
                                    }
                                    if (bllUser.Update(userInfo, string.Format(" AvailableVoteCount={0}", userInfo.AvailableVoteCount), string.Format(" AutoID={0}", userInfo.AutoID), tran) < 1)
                                    {
                                        tran.Rollback();
                                        Hmsg.InnerHtml = "更新用户信息失败";
                                    }
                                    tran.Commit();
                                    Hmsg.InnerHtml = "交易成功!";
                                }
                                catch (Exception ex)
                                {
                                    Log(DateTime.Now.ToString() + ex.ToString());
                                    tran.Rollback();
                                    Hmsg.InnerHtml = ex.ToString();
                                }
                            }
                            else
                            {
                            }
                        }
                        if (orderPay.Status.Equals(1))
                        {
                            Hmsg.InnerHtml = "交易成功!";
                        }



                        //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    }
                    catch (Exception ex)
                    {
                        Log(DateTime.Now.ToString() + ex.ToString());
                        Hmsg.InnerHtml = ex.ToString();
                    }
                }
                else//验证失败
                {
                    Hmsg.InnerHtml = "验证失败";
                }
            }
            else
            {
                Hmsg.InnerHtml = "无返回参数";
            }
        }
Exemple #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (bll.IsLogin)
            {
                currentUserInfo = bll.GetCurrentUserInfo();
            }
            string activityId = context.Request["activity_id"];

            if (string.IsNullOrEmpty(activityId))
            {
                resp.errcode = 1;
                resp.errmsg  = "activity_id 为必填项,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            JuActivityInfo juInfo = bll.GetJuActivity(int.Parse(activityId), true);

            if (juInfo == null)
            {
                resp.errcode = 4;
                resp.errmsg  = "活动不存在!";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            #region 是否可以报名
            if (juInfo.ActivityStatus.Equals(1))
            {
                resp.errcode = 2;
                resp.errmsg  = "活动已停止";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (juInfo.MaxSignUpTotalCount > 0)//检查报名人数
            {
                if (juInfo.SignUpTotalCount > (juInfo.MaxSignUpTotalCount - 1))
                {
                    resp.errcode = 3;
                    resp.errmsg  = "报名人数已满";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
            }
            if (juInfo.ActivityIntegral > 0)
            {
                if (currentUserInfo.TotalScore < juInfo.ActivityIntegral)
                {
                    resp.errcode = 4;
                    resp.errmsg  = "您的积分不足";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
            }
            if (juInfo.GuaranteeCreditAcount > 0)
            {
                if (currentUserInfo.CreditAcount < juInfo.GuaranteeCreditAcount)
                {
                    resp.errcode = 6;
                    resp.errmsg  = "您的信用金不足";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
            }
            #endregion
            dicPar = bll.GetRequestParameter();
            //string weixinOpenID = null;
            string activityIdBySignUp = juInfo.SignUpActivityID;
            string spreadUserId       = null;
            dicPar.TryGetValue("SpreadUserID", out spreadUserId);
            string strDistinctKeys = null;//检查重复的字段,多个字段用,分隔, //没有此参数默认用手机检查
            dicPar.TryGetValue("DistinctKeys", out strDistinctKeys);
            string monitorPlanID = null;
            dicPar.TryGetValue("MonitorPlanID", out monitorPlanID);
            string name = null;
            dicPar.TryGetValue("Name", out name);
            string phone = null;
            dicPar.TryGetValue("Phone", out phone);
            ActivityInfo activity = bll.Get <ActivityInfo>(string.Format("ActivityID='{0}'", activityIdBySignUp));

            #region IP限制
            //获取用户IP;
            string userHostAddress = context.Request.UserHostAddress;
            var    count           = DataCache.GetCache(userHostAddress);
            if (count != null)
            {
                int newCount = int.Parse(count.ToString()) + 1;
                DataCache.SetCache(userHostAddress, newCount);
                int limitCount = 1000;
                if (activity != null)
                {
                    limitCount = activity.LimitCount;
                }
                if (newCount >= limitCount)
                {
                    resp.errcode = 5;
                    resp.errmsg  = "您的提交过于频繁,请稍后再试";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
            }
            else
            {
                DataCache.SetCache(userHostAddress, 1, DateTime.MaxValue, new TimeSpan(4, 0, 0));
            }

            #endregion

            #region 活动权限验证
            if (juInfo == null)
            {
                resp.errcode = 6;
                resp.errmsg  = "活动不存在!";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (juInfo.ActivityStatus.Equals(1))
            {
                resp.errcode = 7;
                resp.errmsg  = "活动已关闭!";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }

            if (activity.IsDelete.Equals(1))
            {
                resp.errcode = 8;
                resp.errmsg  = "活动已删除!";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            #endregion

            #region 判断必填项
            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(phone))
            {
                resp.errcode = 9;
                resp.errmsg  = "姓名和手机不能为空!";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }

            if ((!phone.StartsWith("1")) || (!phone.Length.Equals(11)))
            {
                resp.errcode = 10;
                resp.errmsg  = "手机号码无效!";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }

            #endregion

            #region 检查自定义必填项
            List <ActivityFieldMappingInfo> listRequiredField = bll.GetList <ActivityFieldMappingInfo>(string.Format("ActivityID='{0}' And FieldIsNull=1", activity.ActivityID));
            if (listRequiredField.Count > 0)
            {
                foreach (var requiredField in listRequiredField)
                {
                    if (string.IsNullOrEmpty(dicPar.SingleOrDefault(p => p.Key.Equals(string.Format("K{0}", requiredField.ExFieldIndex))).Value))
                    {
                        resp.errcode = 11;
                        resp.errmsg  = string.Format(" {0} 必填", requiredField.MappingName);
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
            }
            #endregion

            #region 检查数据格式
            //检查数据格式
            List <ActivityFieldMappingInfo> activityFieldMapping = bll.GetList <ActivityFieldMappingInfo>(string.Format("ActivityID='{0}'", activity.ActivityID));
            foreach (var item in activityFieldMapping)
            {
                string value = dicPar.SingleOrDefault(p => p.Key.Equals(string.Format("K{0}", item.ExFieldIndex))).Value;

                if (string.IsNullOrWhiteSpace(value))
                {
                    continue;
                }

                //检查数据格式
                if (item.FormatValiFunc == "email")//email检查
                {
                    if (!ZentCloud.Common.ValidatorHelper.EmailLogicJudge(value))
                    {
                        resp.errcode = 12;
                        resp.errmsg  = string.Format("{0}格式不正确", item.MappingName);
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
                if (item.FormatValiFunc == "url")                                                                                                             //url检查
                {
                    System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址
                    System.Text.RegularExpressions.Match m      = regUrl.Match(value);
                    if (!m.Success)
                    {
                        resp.errcode = 13;
                        resp.errmsg  = string.Format("{0}格式不正确", item.MappingName);
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
            }
            #endregion

            #region 检查是否已经报名
            if (!string.IsNullOrEmpty(strDistinctKeys))
            {
                if (!strDistinctKeys.Equals("none"))//自定义检查重复
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder("1=1 ");
                    string[] distinctKeys        = strDistinctKeys.Split(',');
                    foreach (var item in distinctKeys)
                    {
                        sb.AppendFormat("And {0}='{1}' ", item, dicPar.Single(p => p.Key.Equals(item)).Value);
                    }
                    sb.Append("  and IsDelete = 0  ");
                    if (bll.GetCount <ActivityDataInfo>(sb.ToString()) > 0)
                    {
                        resp.errcode = 14;
                        resp.errmsg  = "重复的报名!";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
                else//不检查重复
                {
                }
            }
            else//默认检查
            {
                if (bll.GetCount <ActivityDataInfo>(string.Format("ActivityID='{0}' And Phone='{1}' and IsDelete = 0 ", activityIdBySignUp, phone)) > 0)
                {
                    resp.errcode = 15;
                    resp.errmsg  = "已经报过名了!";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
            }



            #endregion


            var newActivityUID       = 1001;
            var lastActivityDataInfo = bll.Get <ActivityDataInfo>(string.Format("ActivityID='{0}' order by UID DESC", activityIdBySignUp));
            if (lastActivityDataInfo != null)
            {
                newActivityUID = lastActivityDataInfo.UID + 1;
            }
            ActivityDataInfo model = bll.ConvertRequestToModel <ActivityDataInfo>(new ActivityDataInfo());
            model.UID          = newActivityUID;
            model.SpreadUserID = spreadUserId;
            model.ActivityID   = activityIdBySignUp;
            if (juInfo.GuaranteeCreditAcount > 0)
            {
                if (model.GuaranteeCreditAcount < juInfo.GuaranteeCreditAcount)
                {
                    resp.errcode = 18;
                    resp.errmsg  = string.Format("担保信用金不能少于{0}!", Convert.ToDouble(juInfo.GuaranteeCreditAcount));
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
            }
            if (!string.IsNullOrEmpty(monitorPlanID))
            {
                model.MonitorPlanID = int.Parse(monitorPlanID);
            }
            model.WebsiteOwner = bll.WebsiteOwner;
            if (bll.IsLogin)
            {
                UserInfo curUser = bll.GetCurrentUserInfo();
                model.UserId       = curUser.UserID;
                model.WeixinOpenID = curUser.WXOpenId;
                if (context.Request["limit_userid_signupcount"] == "1")//限制每个登录账号只能报名一次
                {
                    if (bll.GetCount <ActivityDataInfo>(string.Format(" UserId='{0}' AND ActivityID={1} AND IsDelete=0 "
                                                                      , model.UserId, juInfo.SignUpActivityID)) > 0)
                    {
                        resp.errcode = 14;
                        resp.errmsg  = "重复的报名!";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
                if (context.Request["limit_wxopenid_signupcount"] == "1")//限制每个微信只能报名一次
                {
                    if (bll.GetCount <ActivityDataInfo>(string.Format(" UserId='{0}' AND ActivityID={1} AND IsDelete=0 "
                                                                      , model.WeixinOpenID, juInfo.SignUpActivityID)) > 0)
                    {
                        resp.errcode = 14;
                        resp.errmsg  = "重复的报名!";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
            }

            if (bll.Add(model))
            {
                bll.PlusNumericalCol("SignUpCount", juInfo.JuActivityID);//报名数+1

                resp.errmsg    = "ok";
                resp.errcode   = 0;
                resp.isSuccess = true;
                #region 当ActivityIntegral>0   扣积分
                if (juInfo.ActivityIntegral > 0)//扣积分
                {
                    currentUserInfo.TotalScore -= juInfo.ActivityIntegral;
                    if (bll.Update(currentUserInfo, string.Format("TotalScore={0}", currentUserInfo.TotalScore), string.Format(" AutoID={0}", currentUserInfo.AutoID)) <= 0)
                    {
                        resp.errcode = 16;
                        resp.errmsg  = "扣除用户积分失败";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                    else
                    {
                        //
                        BLLJIMP.Model.WBHScoreRecord scoreRecord = new BLLJIMP.Model.WBHScoreRecord();
                        scoreRecord.Nums         = "b55";
                        scoreRecord.InsertDate   = DateTime.Now;
                        scoreRecord.WebsiteOwner = bll.WebsiteOwner;
                        scoreRecord.UserId       = currentUserInfo.UserID;
                        scoreRecord.RecordType   = "2";
                        scoreRecord.NameStr      = "参加活动:" + juInfo.ActivityName;
                        scoreRecord.ScoreNum     = string.Format("-{0}", juInfo.ActivityIntegral);
                        if (!bll.Add(scoreRecord))
                        {
                            resp.errcode = 17;
                            resp.errmsg  = "插入积分记录失败";
                            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                            return;
                        }
                    }
                }
                #endregion

                #region 当ActivityIntegral>0   扣信用金
                if (juInfo.GuaranteeCreditAcount > 0)//扣积分
                {
                    BLLJIMP.BLLUser bllUser = new BLLJIMP.BLLUser();
                    bllUser.AddUserCreditAcountDetails(currentUserInfo.UserID, "ApplyCost", bllUser.WebsiteOwner, 0 - model.GuaranteeCreditAcount
                                                       , string.Format("报名【{0}】消耗{1}信用金", juInfo.ActivityName, Convert.ToDouble(model.GuaranteeCreditAcount)));
                }
                #endregion
            }
            else
            {
                resp.errcode = 1;
                resp.errmsg  = "报名失败,请重试或联系管理员!";
            }
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }
Exemple #14
0
        public void ProcessRequest(HttpContext context)
        {
            /// <summary>
            /// 卡券BLL
            /// </summary>
            BLLJIMP.BLLCardCoupon bllCardCoupon = new BLLJIMP.BLLCardCoupon();
            /// <summary>
            /// 商城BLL
            /// </summary>
            BLLJIMP.BLLMall bllMall = new BLLJIMP.BLLMall();
            /// <summary>
            /// 用户BLL
            /// </summary>
            BLLJIMP.BLLUser bllUser = new BLLJIMP.BLLUser();
            /// <summary>
            /// 微信BLL
            /// </summary>
            BLLJIMP.BLLWeixin bllWeixin = new BLLJIMP.BLLWeixin();
            /// <summary>
            ///
            /// </summary>
            BLLJIMP.BLLStoredValueCard bllStoredValue = new BLLJIMP.BLLStoredValueCard();
            /// <summary>
            ///
            /// </summary>
            BLLJIMP.BLLWeixinCard bllWeixinCard = new BLLJIMP.BLLWeixinCard();


            int pageIndex = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1;
            int pageSize  = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 20;

            pageSize = int.MaxValue;
            string cardcouponStatus    = context.Request["cardcoupon_status"];
            string isCanUse            = "0";                                      // context.Request["is_can_use"];//可以正常使用的标识
            string amount              = context.Request["amount"];                //订单金额
            string isNotShowStoreValue = context.Request["is_notshow_storevalue"]; //是否不显示储值卡

            string openId = context.Request["open_id"];

            bool   isSuccess  = false;
            string msg        = "";
            string couponName = "";
            int    totalCount = 0;

            var currUser = bllUser.GetUserInfoByOpenId(openId);

            if (currUser == null)
            {
                resp.status = false;
                resp.msg    = "openid找不到用户";
                context.Response.Write(JsonConvert.SerializeObject(resp));
                return;
            }

            List <MyCardModel> list = new List <MyCardModel>();

            #region 优惠券
            var sourceData = bllCardCoupon.GetMyCardCoupons(currUser.UserID, pageIndex, pageSize, out totalCount, cardcouponStatus);
            foreach (var item in sourceData)
            {
                BLLJIMP.Model.CardCoupons cardCoupon = bllCardCoupon.GetCardCoupon(item.CardId);
                cardCoupon = bllCardCoupon.ConvertExpireTime(cardCoupon, item);
                MyCardModel model = new MyCardModel();
                model.cardcoupon_id        = item.AutoId;
                model.main_cardcoupon_id   = item.CardId;
                model.cardcoupon_name      = cardCoupon.Name;
                model.cardcoupon_type      = ConvertCardCouponType(cardCoupon.CardCouponType);
                model.valid_from           = cardCoupon.ValidFrom.ToString();
                model.valid_to             = cardCoupon.ValidTo.ToString();
                model.img_url              = bllMall.GetImgUrl(cardCoupon.Logo);
                model.cardcoupon_status    = item.Status;
                model.cardcoupon_gettime   = bllCardCoupon.GetTimeStamp(item.InsertDate);
                model.product_id           = cardCoupon.Ex2;
                model.valid_from_timestamp = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidFrom);
                model.valid_to_timestamp   = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
                model.discount             = cardCoupon.Ex1;
                model.deductible_amount    = cardCoupon.Ex3;
                model.freefreight_amount   = cardCoupon.Ex4;
                model.buckle_amount        = cardCoupon.Ex5;
                model.buckle_sub_amount    = cardCoupon.Ex6;
                model.limit_type           = cardCoupon.Ex7;
                model.product_tags         = cardCoupon.Ex8;
                model.hexiao_channel       = item.HexiaoChannel;
                model.is_can_use_shop      = cardCoupon.IsCanUseShop;
                model.is_can_use_groupbuy  = cardCoupon.IsCanUseGroupbuy;
                model.weixin_card_id       = cardCoupon.WeixinCardId;

                if (model.cardcoupon_type == 4)//满减券直接转成现金券
                {
                    model.buckle_amount     = "";
                    model.buckle_sub_amount = "";
                    model.cardcoupon_type   = 1;
                    model.deductible_amount = cardCoupon.Ex6;
                }

                #region 转赠信息
                model.is_can_give = bllCardCoupon.IsCanGiveCoupon(item, out msg);
                if (!string.IsNullOrEmpty(item.FromUserId))//赠送人信息
                {
                    model.from_user_info = new UserInfoModel();
                    UserInfo fromUserInfo = bllUser.GetUserInfo(item.FromUserId);
                    if (fromUserInfo != null)
                    {
                        model.from_user_info.head_img_url = bllUser.GetUserDispalyAvatar(fromUserInfo);
                        model.from_user_info.nick_name    = bllUser.GetUserDispalyName(fromUserInfo);
                    }
                }
                if (!string.IsNullOrEmpty(item.ToUserId))//被赠送人信息
                {
                    model.to_user_info = new UserInfoModel();
                    UserInfo toUserInfo = bllUser.GetUserInfo(item.ToUserId);
                    if (toUserInfo != null)
                    {
                        model.to_user_info.head_img_url = bllUser.GetUserDispalyAvatar(toUserInfo);
                        model.to_user_info.nick_name    = bllUser.GetUserDispalyName(toUserInfo);
                    }
                }
                #endregion

                if (isCanUse == "1")//可以使用
                {
                    if (model.cardcoupon_status == 0)
                    {
                        if (cardCoupon.ValidFrom != null && cardCoupon.ValidTo != null)
                        {
                            DateTime dtNow = DateTime.Now;
                            if (dtNow >= (DateTime)(cardCoupon.ValidFrom) && (dtNow <= (DateTime)(cardCoupon.ValidTo)))
                            {
                                list.Add(model);
                                //if (!string.IsNullOrEmpty(amount))
                                //{
                                //    if (bllMall.CalcDiscountAmount(item.AutoId.ToString(), decimal.Parse(amount), currUser.UserID, out isSuccess, out msg, out couponName) > 0)
                                //    {
                                //        list.Add(model);
                                //    }
                                //}
                                //else
                                //{
                                //    list.Add(model);
                                //}
                            }
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(amount))
                    {
                        if (bllMall.CalcDiscountAmount(item.AutoId.ToString(), decimal.Parse(amount), currUser.UserID, out isSuccess, out msg, out couponName) > 0)
                        {
                            list.Add(model);
                        }
                    }
                    else
                    {
                        list.Add(model);
                    }
                }
            }
            #endregion

            #region 储值卡转换成现金券
            if (string.IsNullOrEmpty(isNotShowStoreValue))
            {
                var storeValueCardList = bllStoredValue.GetCanUseStoredValueCardList(currUser.UserID);
                foreach (var item in storeValueCardList)
                {
                    try
                    {
                        BLLJIMP.Model.StoredValueCard cardCoupon = bllStoredValue.Get <StoredValueCard>(string.Format(" AutoId={0}", item.CardId));
                        MyCardModel model = new MyCardModel();
                        model.cardcoupon_id      = item.AutoId;
                        model.main_cardcoupon_id = item.CardId;
                        model.cardcoupon_name    = string.Format("{0}(储值卡余额{1}元)", cardCoupon.Name, bllMall.GetStoreValueCardCanUseAmount(item.AutoId.ToString(), item.UserId));
                        model.valid_from         = DateTime.Now.ToString();
                        model.valid_to           = cardCoupon.ValidTo.ToString();
                        // model.img_url = bllMall.GetImgUrl(cardCoupon.Logo);
                        model.cardcoupon_status = 0;
                        //model.cardcoupon_gettime = bllCardCoupon.GetTimeStamp(item.InsertDate);
                        //model.product_id = cardCoupon.Ex2;
                        model.valid_from_timestamp = bllCardCoupon.GetTimeStamp(DateTime.Now);
                        model.valid_to_timestamp   = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
                        model.discount             = "";
                        //model.deductible_amount = cardCoupon.Ex3;
                        model.freefreight_amount = "";
                        model.buckle_amount      = "";
                        model.buckle_sub_amount  = "";
                        model.limit_type         = "";
                        model.product_tags       = "";
                        //model.hexiao_channel = item.HexiaoChannel;
                        model.is_can_use_shop     = 1;
                        model.is_can_use_groupbuy = 1;
                        model.product_id          = "";
                        model.buckle_amount       = "";
                        model.buckle_sub_amount   = "";
                        model.cardcoupon_type     = 1;
                        model.deductible_amount   = (item.Amount - bllStoredValue.GetUseRecordList(item.AutoId, item.UserId).Sum(p => p.UseAmount)).ToString();
                        model.is_store_card       = 1;
                        list.Add(model);
                        totalCount++;
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
                #endregion
            }

            resp.status = true;

            resp.result = new
            {
                totalcount = list.Count,
                list       = list
            };

            context.Response.Write(JsonConvert.SerializeObject(resp));
        }
Exemple #15
0
        public int SendSms(string userName, string userPwd, string mobile, string content, string pipeID)
        {
            try
            {
                //用户名密码不能为空
                if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(userPwd))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_LoginError);
                }

                BLLJIMP.BLLUser userBll = new BLLJIMP.BLLUser(userName);

                //用户登录
                if (!userBll.Login(userName, userPwd))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_LoginError);
                }

                //通道不能为空
                if (string.IsNullOrWhiteSpace(pipeID))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_PipeError);
                }

                //手机号码不能为空
                if (string.IsNullOrWhiteSpace(mobile))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_MobileEmpty);
                }

                //发送内容不能为空
                if (string.IsNullOrWhiteSpace(content))
                {
                    return((int)BLLJIMP.ReturnCode.SMS_ContentEmpty);
                }

                pipeID = pipeID.ToLower().Trim();

                BLLJIMP.BLLSMS smsBll = new BLLJIMP.BLLSMS(userName);


                ////判断通余额是否充足
                //int smsCntLeg = content.Length;//内容长度
                //int smsCntCount = 1;//内容拆分条数
                //int smsCount = 1;//短信扣点数
                //int userPoints = userBll.GetPoints();

                //if (smsCntLeg > 65)
                //{
                //    smsCntCount = (int)Math.Ceiling((double)smsCntLeg / 65);
                //}

                //smsCount = smsCount * smsCntCount;


                //if( userPoints.Equals(0) || userPoints < smsCount)
                //    return (int)BLLJIMP.ReturnCode.SMS_PointNotEnough;

                if (pipeID.Equals("membermission"))
                {
                    return((int)smsBll.SubmitSMSMission("membermission", mobile, content, userName));
                }
                else
                {
                    return((int)smsBll.SubmitSMS(pipeID, mobile, content));
                }
                //switch (channel)
                //{
                //    case "membertrigger"://触发通道



                //        break;
                //    case "mission"://任务发送


                //        break;
                //    default:
                //        return (int)BLLJIMP.ReturnCode.SMS_PipeError;
                //}
            }
            catch
            {
                //SMS_Exception
                return((int)BLLJIMP.ReturnCode.SMS_Exception);
            }
        }
Exemple #16
0
        public void ProcessRequest(HttpContext context)
        {
            //try
            //{
            BLLJIMP.BLLJuActivity   bllJuactivity   = new BLLJIMP.BLLJuActivity("");
            BLLJIMP.BLLUser         bllUser         = new BLLJIMP.BLLUser("");
            BLLJIMP.BLLMonitor      bllMonitor      = new BLLJIMP.BLLMonitor();
            BLLJIMP.BLLWebSite      bllwebSite      = new BLLJIMP.BLLWebSite();
            BLLJIMP.BLLShareMonitor bllShareMonitor = new BLLJIMP.BLLShareMonitor();

            ///推广用户信息
            UserInfo spreadUser = null;

            //分享用户
            UserInfo shareUser = null;

            CompanyWebsite_Config companyConfig = bllwebSite.GetCompanyWebsiteConfig();

            currentUrl = context.Request.Url.ToString(); //当前绝对地址
            string filePath = context.Request.FilePath;  //当前相对路径

            #region 微信推广(展示文章页面)
            if (filePath.Contains(".chtml"))
            {
                ToLog(context, " monitorhandler filePath:" + filePath);
                string[] parameters = filePath.Split('/');
                if (parameters.Length > 2)
                {
                    int activityId = Convert.ToInt32(parameters[1], 16);//ZCJ_JuActivityInfo 文章ID;
                    ToLog(context, " monitorhandler 文章ID:" + activityId);
                    long memberID = 0;

                    if (parameters.Length > 3)
                    {
                        //memberID = parameters[2] == "XXX" ? 0 : Convert.ToInt32(parameters[2], 16);//ZCJ_WXMemberInfo 会员注册ID;
                        spreadUser = bllUser.GetUserInfoByAutoID(Convert.ToInt32(parameters[2], 16));
                    }


                    string currOpenerOpenID = parameters.Length > 5 ? parameters[3] : string.Empty;//当前打开者的OpenID

                    string spreadUserID = context.Request["spreadU"] == null ? "" : context.Request["spreadU"].ToString();

                    string shareTimestamp = context.Request["shareTimestamp"];

                    if (!string.IsNullOrWhiteSpace(spreadUserID))
                    {
                        spreadUserID = Common.Base64Change.DecodeBase64ByUTF8(spreadUserID);
                    }

                    string spreadUserAutoIDStr = context.Request["ua"] == null ? "" : context.Request["ua"].ToString();//推广ID,原始id*1000,16进制后进行base64,然后“=”变成“_”
                    int    spreadUserAutoID    = 0;
                    if (!string.IsNullOrWhiteSpace(spreadUserAutoIDStr))
                    {
                        spreadUserAutoID = bllJuactivity.TransmitIntDeCode(spreadUserAutoIDStr);//Convert.ToInt32(Common.Base64Change.DecodeBase64ByUTF8(spreadUserAutoIDStr.Replace("_", "=")), 16) / 1000;
                    }

                    string shareId = context.Request["comeonshareid"] == null ? "" : context.Request["comeonshareid"].ToString();

                    if (!string.IsNullOrWhiteSpace(shareId))
                    {
                        ToLog(context, " monitorhandler 执行shareId查找分享任务: " + shareId);
                        try
                        {
                            var shareInfo = bllShareMonitor.GetShareInfo(shareId);

                            if (!string.IsNullOrWhiteSpace(shareInfo.UserId))
                            {
                                shareUser = bllUser.GetUserInfo(shareInfo.UserId);
                            }
                        }
                        catch (Exception ex)
                        {
                            ToLog(context, " monitorhandler 获取shareUser异常: " + ex.Message);
                        }
                    }



                    JuActivityInfo activityInfo = bllJuactivity.Get <JuActivityInfo>(string.Format("JuActivityID={0} AND IsDelete=0 ", activityId));//文章信息

                    if (activityInfo == null)
                    {
                        context.Response.WriteFile("/Error/NotExist.html");
                        return;
                    }

                    ToLog(context, " monitorhandler 找到文章,开始构造内容: " + activityInfo.JuActivityID);

                    //if (activityInfo.ArticleType == "activity")
                    //{
                    //    if (activityInfo.ActivityStatus == 1)
                    //    {
                    //        context.Response.Redirect("/Error/CommonMsg.aspx?msg=报名已结束,有疑问请联系我们&&icon=icon iconfont icon-kulian kulian");
                    //        return;
                    //    }
                    //}

                    #region 检查是否付费活动

                    if (activityInfo.IsFee == 1 && !bllJuactivity.IsLogin)
                    {
                        context.Response.Redirect("/App/Cation/Wap/FreeActivityPage.aspx?aid=" + activityInfo.JuActivityID);
                        return;
                    }
                    #endregion

                    #region 检查访问级别
                    if (activityInfo.AccessLevel > 0)
                    {
                        if (!bllUser.IsLogin)
                        {
                            appLoginUrl = Common.ConfigHelper.GetConfigString("appLoginUrl").ToLower();
                            context.Response.Redirect(appLoginUrl + string.Format("?redirect=" + HttpUtility.UrlEncode(currentUrl)), true);
                            return;
                        }
                        //else if (!bllUser.IsMember() && activityInfo.AccessLevel == 1)
                        //{

                        //}
                        else if (bllUser.GetCurrentUserInfo().AccessLevel < activityInfo.AccessLevel)
                        {
                            //if (companyConfig.NoPermissionsPage == 0)
                            //{
                            //    context.Response.WriteFile("/Error/NoPmsMobile.htm");
                            //    return;
                            //}
                            //else if (companyConfig.NoPermissionsPage == 1)
                            //{
                            //    context.Response.Redirect("/App/Cation/Wap/UserEdit.aspx",true);
                            //    context.Response.End();
                            //    return;
                            //}
                            context.Response.WriteFile("/Error/NoPmsMobile.htm");
                            return;
                        }
                    }
                    #endregion

                    #region 检查访问级别

                    //WXMemberInfo regInfo = juactivityBll.Get<WXMemberInfo>(string.Format("MemberID={0}", memberID));//会员注册信息
                    // UserInfo userInfo = juactivityBll.Get<UserInfo>(string.Format("UserID='{0}'", activityInfo.UserID));//文章发布者信息
                    SystemSet systemset  = bllJuactivity.Get <SystemSet>(""); //系统配置信息
                    string    pageSource = "";                                //待输出的html源代码

                    if (systemset != null)
                    {
                        if (string.IsNullOrWhiteSpace(currOpenerOpenID))
                        {
                            //取得Session里的当前OpenID
                            currOpenerOpenID = context.Session[systemset.WXCurrOpenerOpenIDKey] != null ? context.Session[systemset.WXCurrOpenerOpenIDKey].ToString() : "";
                        }

                        if (string.IsNullOrWhiteSpace(currOpenerOpenID))
                        {
                            //如果再为空,由链接上面get参数获取
                            currOpenerOpenID = context.Request[systemset.WXCurrOpenerOpenIDKey] != null ? context.Request[systemset.WXCurrOpenerOpenIDKey].ToString() : "";
                        }
                    }
                    #endregion



                    //if (regInfo == null)
                    //{
                    //    regInfo = new WXMemberInfo() { Name = "none", WeixinOpenID = "" };
                    //}

                    if ((activityInfo != null))//
                    {
                        //var planInfo = bllJuactivity.Get<MonitorPlan>(string.Format("MonitorPlanID={0}", activityInfo.MonitorPlanID));
                        //if (planInfo == null)
                        //{
                        //    return;
                        //}
                        //else
                        //{
                        //    if (planInfo.PlanStatus == "0")//任务已停止
                        //    {
                        //        return;
                        //    }

                        //}

                        ToLog(context, " monitorhandler 开始执行GetJuactivityHtml: " + activityInfo.JuActivityID);
                        pageSource = bllJuactivity.GetJuactivityHtml(activityInfo, currOpenerOpenID, context.Request.Url.ToString(), spreadUser, shareUser);
                        ToLog(context, " monitorhandler 执行GetJuactivityHtml完毕: " + activityInfo.JuActivityID);

                        #region 事件记录
                        //事件
                        //int OpenCount = 0;//打开人数
                        //int DistinctOpenCount = 0;//独立IP数量
                        MonitorEventDetailsInfo detailInfo = new MonitorEventDetailsInfo();
                        detailInfo.MonitorPlanID  = activityInfo.MonitorPlanID;
                        detailInfo.EventType      = 0;
                        detailInfo.EventBrowser   = HttpContext.Current.Request.Browser == null ? "" : HttpContext.Current.Request.Browser.ToString();
                        detailInfo.EventBrowserID = HttpContext.Current.Request.Browser.Id;;
                        if (HttpContext.Current.Request.Browser.Beta)
                        {
                            detailInfo.EventBrowserIsBata = "测试版";
                        }
                        else
                        {
                            detailInfo.EventBrowserIsBata = "正式版";
                        }

                        detailInfo.EventBrowserVersion = HttpContext.Current.Request.Browser.Version;
                        detailInfo.EventDate           = DateTime.Now;
                        if (HttpContext.Current.Request.Browser.Win16)
                        {
                            detailInfo.EventSysByte = "16位系统";
                        }
                        else
                        if (HttpContext.Current.Request.Browser.Win32)
                        {
                            detailInfo.EventSysByte = "32位系统";
                        }
                        else
                        {
                            detailInfo.EventSysByte = "64位系统";
                        }

                        detailInfo.EventSysPlatform = HttpContext.Current.Request.Browser.Platform;
                        detailInfo.SourceIP         = Common.MySpider.GetClientIP();
                        detailInfo.IPLocation       = Common.MySpider.GetIPLocation(detailInfo.SourceIP);
                        detailInfo.SourceUrl        = HttpContext.Current.Request.Url.ToString();
                        detailInfo.RequesSourcetUrl = HttpContext.Current.Request.UrlReferrer != null?HttpContext.Current.Request.UrlReferrer.ToString() : "";

                        if (spreadUser != null)
                        {
                            detailInfo.SpreadUserID = spreadUser.UserID;
                        }
                        detailInfo.SpreadUserAutoID = spreadUserAutoID;
                        detailInfo.ShareTimestamp   = shareTimestamp;
                        detailInfo.WebsiteOwner     = bllJuactivity.WebsiteOwner;
                        detailInfo.ModuleType       = activityInfo.ArticleType;
                        if (bllUser.IsLogin)
                        {
                            detailInfo.EventUserID = bllUser.GetCurrUserID();
                        }


                        if (spreadUser != null)//带推广信息
                        {
                            //try
                            //{
                            //    if (!string.IsNullOrWhiteSpace(currOpenerOpenID))
                            //    {
                            //        //记录触发人
                            //        UserInfo eventUser = new BLLJIMP.BLLUser("").GetUserInfoByOpenId(currOpenerOpenID);
                            //        detailInfo.EventUserID = eventUser.UserID;
                            //    }
                            //}
                            //catch { }
                            string          url = string.Format("http://{0}{1}", context.Request.Url.Host, filePath);
                            MonitorLinkInfo linkInfo;
                            try
                            {
                                linkInfo = bllJuactivity.Get <MonitorLinkInfo>(string.Format(" LinkName='{0}' And MonitorPlanID={1}", spreadUser.UserID, activityInfo.MonitorPlanID));
                            }
                            catch (Exception ex)
                            {
                                context.Response.Write("ex" + ex.ToString());
                                return;
                            }



                            if (linkInfo != null)
                            {
                                linkInfo.ActivityName   = activityInfo.ActivityName;
                                linkInfo.ThumbnailsPath = activityInfo.ThumbnailsPath;
                                //已经为该用户建立推广链接
                                detailInfo.LinkID = linkInfo.LinkID;
                                //if (linkInfo.OpenCount != null)//增加打开人数
                                //{
                                linkInfo.OpenCount++;
                                //}
                                //else
                                //{
                                //    linkInfo.OpenCount = 1;
                                //}
                                int shareCount = bllJuactivity.GetCount <MonitorEventDetailsInfo>("ShareTimestamp", string.Format(" LinkID ={0} and ShareTimestamp is not null and ShareTimestamp <> '' and ShareTimestamp <> '0' ", linkInfo.LinkID));
                                linkInfo.ShareCount = shareCount;
                                int ipCount = bllJuactivity.GetCount <MonitorEventDetailsInfo>(" SourceIP ", string.Format(" LinkID = {0} ", linkInfo.LinkID));
                                linkInfo.DistinctOpenCount = ipCount;
                                bllJuactivity.Update(linkInfo, string.Format(" OpenCount={0},DistinctOpenCount={1},ShareCount={2}", linkInfo.OpenCount, ipCount, shareCount), string.Format("LinkID={0}", linkInfo.LinkID));
                            }
                            else
                            {
                                //还没有为该用户建立推广链接
                                MonitorLinkInfo newLinkinfo = new MonitorLinkInfo();
                                newLinkinfo.LinkID            = int.Parse(bllJuactivity.GetGUID(ZentCloud.BLLJIMP.TransacType.MonitorLinkID));
                                newLinkinfo.MonitorPlanID     = activityInfo.MonitorPlanID;
                                newLinkinfo.WXMemberID        = memberID;
                                newLinkinfo.LinkName          = spreadUser.UserID;
                                newLinkinfo.RealLink          = url;
                                newLinkinfo.InsertDate        = DateTime.Now;
                                newLinkinfo.OpenCount         = 1;
                                newLinkinfo.ActivityName      = activityInfo.ActivityName;
                                newLinkinfo.ThumbnailsPath    = activityInfo.ThumbnailsPath;
                                newLinkinfo.WebsiteOwner      = bllJuactivity.WebsiteOwner;
                                newLinkinfo.DistinctOpenCount = 1; // ip
                                newLinkinfo.ShareCount        = 0; //分享数
                                if (activityInfo.ArticleType == "article")
                                {
                                    newLinkinfo.ForwardType = "fans";
                                    newLinkinfo.ActivityId  = activityInfo.JuActivityID;
                                }
                                if (!string.IsNullOrEmpty(activityInfo.SignUpActivityID) && activityInfo.ArticleType == "activity")
                                {
                                    newLinkinfo.ActivityId = int.Parse(activityInfo.SignUpActivityID);
                                }

                                StringBuilder sqlWhere = new StringBuilder();
                                sqlWhere.AppendFormat(@"
                                if not exists(select 1 from ZCJ_MonitorLinkInfo where LinkName='{14}' and MonitorPlanID={15} ) 
                                begin
                                    insert into ZCJ_MonitorLinkInfo (LinkID,MonitorPlanID,WXMemberID,LinkName,RealLink,InsertDate,OpenCount,ActivityName,ThumbnailsPath,WebsiteOwner,DistinctOpenCount,ShareCount,ForwardType,ActivityId)
                                                values({0},{1},{2},'{3}','{4}','{5}',{6},'{7}','{8}','{9}',{10},{11},'{12}',{13})
                                end 
                                ", newLinkinfo.LinkID, newLinkinfo.MonitorPlanID, newLinkinfo.WXMemberID, newLinkinfo.LinkName, newLinkinfo.RealLink, newLinkinfo.InsertDate, newLinkinfo.OpenCount, newLinkinfo.ActivityName, newLinkinfo.ThumbnailsPath, newLinkinfo.WebsiteOwner, newLinkinfo.DistinctOpenCount, newLinkinfo.ShareCount, newLinkinfo.ForwardType, newLinkinfo.ActivityId, spreadUser.UserID, activityInfo.MonitorPlanID);


                                if (ZentCloud.ZCDALEngine.DALEngine.ExecuteSql(sqlWhere.ToString()) > 0)
                                {
                                    detailInfo.LinkID = newLinkinfo.LinkID;
                                }
                            }
                        }


                        //添加事件详细
                        //if (!filePath.Contains("?"))
                        //{
                        bllJuactivity.Add(detailInfo);
                        //DistinctOpenCount = juactivityBll.GetCount<ZentCloud.BLLJIMP.Model.MonitorEventDetailsInfo>("SourceIP", string.Format("LinkID={0} and EventType=0", detailInfo.LinkID));
                        //juactivityBll.Update(new MonitorLinkInfo(), string.Format(" OpenCount={0},DistinctOpenCount={1}", OpenCount, DistinctOpenCount), string.Format("LinkID={0}", detailInfo.LinkID));
                        #region 微转发活动加积分
                        if (bllUser.IsLogin && spreadUser != null)
                        {
                            if (activityInfo.ArticleType == "activity")
                            {
                                if (bllJuactivity.GetCount <MonitorEventDetailsInfo>(string.Format(" MonitorPlanID='{0}' And EventUserID='{1}' And SpreadUserID='{2}' And EventUserID!='{2}'", detailInfo.MonitorPlanID, bllUser.GetCurrUserID(), spreadUser.UserID)) == 1)
                                {
                                    string remark = string.Format("转发活动《{0}》", activityInfo.ActivityName);
                                    //微转发加积分
                                    bllUser.AddUserScoreDetail(spreadUser.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.ForwardArticle), spreadUser.WebsiteOwner, null, remark);
                                }
                            }
                        }
                        #endregion


                        //}
                        context.Response.ClearContent();
                        //处理完成
                        context.Response.Write(pageSource);
                        //更新微信阅读人数
                        //bllJuactivity.UpdateUVCount(activityInfo.JuActivityID);
                        bllJuactivity.UpDateIPPVShareCount(activityInfo);
                        bllJuactivity.UpdateActivityForwardPVUV(activityInfo);
                        if (spreadUser != null)
                        {
                            bllMonitor.UpdateUV(activityInfo.MonitorPlanID, spreadUser.UserID);
                            //bllMonitor.UpdateSignUpCount(activityInfo.MonitorPlanID, spreadUser.UserID);
                        }
                        if (!string.IsNullOrWhiteSpace(activityInfo.RedirectUrl))
                        {
                            context.Response.Redirect(activityInfo.RedirectUrl);
                        }
                        return;

                        #endregion

                        ToLog(context, " monitorhandler 事件记录完毕: " + activityInfo.JuActivityID);
                    }
                    else
                    {
                        context.Response.Write("<html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1\" /></head><body>链接无效。</body></html>");
                        return;
                    }
                }
            }
            #endregion
            #region 注释
            //#region 微信会员注册
            //else if (filePath.StartsWith("/weixin"))
            //{

            //    //微信会员注册
            //    if (filePath.Contains("wx_reg.chtml") && (!filePath.Contains("/weixin/wx_reg.chtml")))
            //    {
            //        string[] parameters = filePath.Split('/');

            //        string weixinMemberId = Convert.ToInt32(parameters[2], 16).ToString();// ZCJ_WeixinMemberInfo WeixinMemberID
            //        var weixinmemberinfo = juactivityBll.Get<WeixinMemberInfo>(string.Format("WeixinMemberID={0}", weixinMemberId));
            //        string RegCode = Common.IOHelper.GetFileStr(context.Server.MapPath("/weixin/wx_reg.htm"), Encoding.UTF8);//注册代码

            //        if (RegCode.Contains("$CCWXOPENID$"))
            //        {
            //            RegCode = RegCode.Replace("$CCWXOPENID$", weixinmemberinfo.WeixinOpenID);
            //        }
            //        if (RegCode.Contains("$CCWXAID$"))//注册到哪个账户下
            //        {

            //            RegCode = RegCode.Replace("$CCWXAID$", Convert.ToString(juactivityBll.Get<UserInfo>(string.Format("UserID='{0}'", weixinmemberinfo.UserID)).AutoID, 16));

            //        }

            //        context.Response.Write(RegCode);//输出注册代码


            //        //微信会员注册

            //    }

            //}

            //#endregion
            #endregion

            //}
            //catch (Exception ex)
            //{
            //    using (StreamWriter sw = new StreamWriter(@"C:\MonitorHandlerException.txt", true, Encoding.UTF8))
            //    {
            //        sw.WriteLine(string.Format("{0} MonitorHandler拦截处理异常:{1}", DateTime.Now.ToString(), ex.ToString()));

            //    }
            //    context.Response.Write("exception");
            //}
        }
Exemple #17
0
        /// <summary>
        /// 分享统计
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetShareCountStatistics(HttpContext context)
        {
            string preId = context.Request["preId"], //shareId,每次查询是取出传入shareId的子集
                   mid   = context.Request["mid"];

            bool          isRoot       = false;
            StringBuilder strShareInfo = new StringBuilder(" 1=1 ");

            if (string.IsNullOrWhiteSpace(preId))
            {
                //一级目录,返回一级分享和当前检测实体信息, 分享总数  阅读总数  成果总数
                strShareInfo.Append(" AND ( PreId = '' OR PreId IS NULL)");
                isRoot = true;
            }
            else
            {
                if (preId.IndexOf(',') > 0)
                {
                    var tmpList = preId.Split(',').ToList();
                    strShareInfo.AppendFormat(" AND PreId in ({0}) ", Common.StringHelper.ListToStr <string>(tmpList, "'", ","));
                }
                else
                {
                    strShareInfo.AppendFormat(" AND PreId = '{0}' ", preId);
                }
            }

            strShareInfo.AppendFormat(" AND MonitorId = {0} ", mid);

            var shareList = this.bll.GetList <ShareInfo>(strShareInfo.ToString());

            //share信息处理,按个人分享数归类到一块
            List <object> shareResultList = new List <object>();

            #region share信息处理

            if (shareList != null && shareList.Count > 0)
            {
                //取出分享人列表
                var               sharerList = shareList.GroupBy(p => p.UserId).ToList();
                BLLJIMP.BLLUser   userBll    = new BLLJIMP.BLLUser();
                BLLJIMP.BLLWeixin wxBll      = new BLLJIMP.BLLWeixin();

                foreach (var item in sharerList)
                {
                    //获取user信息
                    var userInfo = userBll.GetUserInfo(item.Key);

                    if (userInfo == null)
                    {
                        continue;
                    }

                    //TODO:如果没有头像和姓名  需要去接口取相关头像和姓名 并保存到数据库
                    try
                    {
                        if (string.IsNullOrWhiteSpace(userInfo.WXHeadimgurl))
                        {
                            string accesstoken   = wxBll.GetAccessToken(userInfo.WebsiteOwner);
                            var    newflowerInfo = wxBll.GetWeixinUserInfo(accesstoken, userInfo.WXOpenId);

                            userInfo.WXHeadimgurl = newflowerInfo.headimgurl;
                            userInfo.WXNickname   = newflowerInfo.nickname;

                            this.bll.Update(
                                new UserInfo(),
                                string.Format(" WXHeadimgurl='{0}',WXNickname='{1}' ", userInfo.WXHeadimgurl, userInfo.WXNickname),
                                string.Format(" UserID='{0}' ", userInfo.UserID)
                                );
                        }
                    }
                    catch { }//TODO:临时方案取用户信息,如果出现异常暂时不处理

                    //获取ShareIds
                    var userShareList = shareList.Where(p => (p.UserId != null && p.UserId.ToLower() == userInfo.UserID.ToLower())).Select(p => p.ShareId).ToList();

                    //获取子分享数(所有shareIds的子分享数)
                    var childShareCount = this.bll.GetCount <ShareInfo>(string.Format(" PreId in ({0}) ", Common.StringHelper.ListToStr <string>(userShareList, "'", ",")));

                    //获取阅读数(所有shareIds的阅读总数)
                    var readCount = this.bll.GetCount <ShareReaderInfo>(string.Format(" ShareId in ({0}) ", Common.StringHelper.ListToStr <string>(userShareList, "'", ",")));

                    //获取分享数(等于shareIds总数)
                    var shareCount = userShareList.Count;

                    //获取成果数(所有shareIds带来的报名数,目前统计的是校服对应的那个报名表来统计)
                    //var achievement = this.bll.GetCount<VoteObjectInfo>(string.Format(" ComeonShareId in ({0}) ", Common.StringHelper.ListToStr<string>(userShareList, "'", ",")));

                    //成果数改成活动报名数,取出分享的活动id,查询活动报名是来自哪个用户或者哪个分享id

                    //var achievement =
                    //    this.bll.GetCount<VoteObjectInfo>(string.Format(" ComeonShareId in ({0}) ", Common.StringHelper.ListToStr<string>(userShareList, "'", ",")));

                    var achievement =
                        this.bll.GetCount <ActivityDataInfo>(string.Format(" ShareID in ({0}) ", Common.StringHelper.ListToStr <string>(userShareList, "'", ",")));

                    shareResultList.Add(new
                    {
                        tmpDataKey = Guid.NewGuid().ToString(),
                        userInfo   = new
                        {
                            avatar   = userInfo.WXHeadimgurl,
                            userName = string.IsNullOrWhiteSpace(userInfo.WXNickname) ? "" : userInfo.WXNickname,
                            userId   = userInfo.UserID,
                            wxOpenId = userInfo.WXOpenId
                        },
                        shareIds        = userShareList,
                        preId           = preId,
                        childShareCount = childShareCount,
                        readCount       = readCount,
                        shareCount      = shareCount,
                        achievement     = achievement//成果
                    });
                }
            }
            #endregion

            object rootInfo = new object();

            #region rootInfo处理
            if (isRoot)
            {
                //当前检测实体信息, 分享总数  阅读总数  成果总数
                var monitor         = this.bll.Get <ShareMonitorInfo>(string.Format(" MonitorId = {0} ", mid));
                var shareTotalCount = this.bll.GetCount <ShareInfo>(string.Format(" MonitorId = {0} ", mid));

                //阅读总数= 分享的阅读总数 + 直接阅读总数(未分享)
                var readTotalCount = this.bll.GetCount <ShareReaderInfo>(string.Format(" MonitorId = {0} ", mid));

                //成果总数= 分享的成功总数
                var achievementTotalCount = 0;

                //取出所有分享id
                var allShareList = this.bll.GetList <ShareInfo>(string.Format(" MonitorId = {0} ", mid));
                if (allShareList != null && allShareList.Count > 0)
                {
                    var allShareIds = allShareList.Select(p => p.ShareId).ToList();
                    readTotalCount += this.bll.GetCount <ShareReaderInfo>(string.Format(" ShareId IN ({0}) ", Common.StringHelper.ListToStr <string>(allShareIds, "'", ",")));

                    achievementTotalCount = this.bll.GetCount <VoteObjectInfo>(string.Format(" ComeonShareId IN ({0}) ", Common.StringHelper.ListToStr <string>(allShareIds, "'", ",")));
                }
                rootInfo = new
                {
                    title                 = monitor.MonitorName,
                    shareTotalCount       = shareTotalCount,
                    readTotalCount        = readTotalCount,
                    achievementTotalCount = achievementTotalCount
                };
            }
            #endregion

            return(Common.JSONHelper.ObjectToJson(new
            {
                rootInfo = isRoot ? rootInfo : null,
                shareResultList = shareResultList
            }));
        }