Пример #1
0
        public void SendCardCouponsByCurrUserInfo(UserInfo currUserInfo, string cardId)
        {
            try
            {
                BLLWeixin bllWeixin = new BLLWeixin();

                BLLWebsiteDomainInfo bllDomain = new BLLWebsiteDomainInfo();

                CardCoupons cardCoupon = Get <CardCoupons>(string.Format(" WebsiteOwner='{0}' AND CardId={1} ", currUserInfo.WebsiteOwner, int.Parse(cardId)));

                MyCardCoupons model = new MyCardCoupons();
                model.CardCouponNumber = GetGUID(BLLJIMP.TransacType.CommAdd);
                model.CardCouponType   = cardCoupon.CardCouponType;
                model.CardId           = cardCoupon.CardId;
                model.InsertDate       = DateTime.Now;
                model.UserId           = currUserInfo.UserID;
                model.WebSiteOwner     = currUserInfo.WebsiteOwner;
                if (Add(model))
                {
                    string title     = "您收到一张优惠券";
                    string content   = string.Format("{0}", cardCoupon.Name);
                    string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(currUserInfo.WebsiteOwner));
                    bllWeixin.SendTemplateMessageNotifyComm(currUserInfo, title, content, redicturl);
                }
            }
            catch (Exception)
            {
            }
        }
Пример #2
0
        /// <summary>
        /// 微信支付
        /// </summary>
        /// <param name="id">订单号</param>
        /// <returns></returns>
        public ActionResult SetTopPay(int id, int set_top, decimal money)
        {
            string msg                = "";
            string orderNo            = "";
            string type               = set_top == 1 ? "分类置顶" : "全站置顶";
            var    authenticationUser = BLLAuthentication.GetAuthenticationUser();
            bool   result             = BLLNewsOrder.Add(new ht_news_order()
            {
                news_id = id, type = type, value = set_top.ToString(), money = money, pay = "微信", add_userid = authenticationUser.id
            }, out msg, out orderNo);

            if (!result)
            {
                return(JsonResult(Model.Enum.APIErrCode.OperateFail, msg));
            }
            string Ip      = Request.UserHostAddress;
            string openId  = BLLUser.GetLoginUserInfo().openid;
            string notiUrl = Request.Url.Scheme + "://" + Request.Url.Authority + "/WX/PayNotify";//通知地址

            bool isRequestSuccess = false;
            var  payRequest       = BLLWeixin.WXPay(orderNo, money, openId, Ip, notiUrl, out isRequestSuccess, string.Format("{1}订单号:{0}", orderNo, type));

            if (isRequestSuccess)
            {
                return(JsonResult(Model.Enum.APIErrCode.Success, "OK", payRequest));
            }
            else
            {
                return(JsonResult(Model.Enum.APIErrCode.OperateFail));
            }
        }
Пример #3
0
        private ReturnValue SendSystemNoticeToPersonals(SystemNotice systemNotice, string personals)
        {
            BLLJIMP.BLLUser              bllUser      = new BLLUser("");
            BLLJIMP.BLLWeixin            bllWeixin    = new BLLWeixin("");
            BLLWeixin.TMTaskNotification notificaiton = new BLLWeixin.TMTaskNotification();
            notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/SystemMessageBox.aspx", System.Web.HttpContext.Current.Request.Url.Host);
            var accessToken = bllWeixin.GetAccessToken();

            string[] userArray    = personals.Split(',');
            int      successCount = 0;

            foreach (string userId in userArray)
            {
                successCount += SendSystemNoticeToUserId(systemNotice, userId) ? 1 : 0;


                try
                {
                    notificaiton.First    = "您好,您有新系统消息";
                    notificaiton.Keyword1 = systemNotice.Title;
                    notificaiton.Keyword2 = systemNotice.NoticeTypeString;
                    notificaiton.Remark   = "点击查看";
                    bllWeixin.SendTemplateMessage(accessToken, bllUser.GetUserInfo(userId).WXOpenId, notificaiton);
                }
                catch (Exception)
                {
                    continue;
                }
            }
            return(new ReturnValue {
                Code = 0, Msg = string.Format("成功将消息发送到{0}个人.", successCount)
            });
        }
Пример #4
0
        /// <summary>
        /// 微信支付
        /// </summary>
        /// <param name="id">订单号</param>
        /// <returns></returns>
        public ActionResult Pay(string id)
        {
            var order = BLLNews.GetNewsDetailsByOrderNo(id);

            ViewBag.OrderNo = id;
            if (Request.IsAjaxRequest())
            {
                if (order == null || order.pay_status == 1)
                {
                    return(JsonResult(Model.Enum.APIErrCode.OperateFail, "订单无效或已经支付"));
                }
                string Ip      = Request.UserHostAddress;
                string openId  = BLLUser.GetLoginUserInfo().openid;
                string notiUrl = Request.Url.Scheme + "://" + Request.Url.Authority + "/WX/PayNotify";//通知地址

                bool isRequestSuccess = false;
                var  payRequest       = BLLWeixin.WXPay(order.order_no, order.total.Value, openId, Ip, notiUrl, out isRequestSuccess);
                if (isRequestSuccess)
                {
                    return(JsonResult(Model.Enum.APIErrCode.Success, "OK", payRequest));
                }
                else
                {
                    return(JsonResult(Model.Enum.APIErrCode.OperateFail));
                }
            }
            else
            {
                return(View());
            }
        }
Пример #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.userInfo  = Comm.DataLoadTool.GetCurrUserModel();
     this.weixinBll = new BLLWeixin(this.userInfo.UserID);
     if (!IsPostBack)
     {
         this.LoadData();
     }
 }
Пример #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = 0;
            string result = "false";

            try
            {
                userBll            = new BLLUser("");
                weixinBll          = new BLLWeixin("");
                this.juActivityBll = new BLLJuActivity("");
                this.systemSet     = this.juActivityBll.GetSysSet();
                string Action = context.Request["Action"];

                switch (Action)
                {
                case "QueryJuActivityForWapCommon":    //活动查询
                    result = QueryJuActivityForWapCommon(context);
                    break;

                case "QueryActivityListForSpreadRank":    //活动排名列表
                    result = QueryActivityListForSpreadRank(context);
                    break;

                case "QueryJuActivityForWap":
                    result = QueryJuActivityForWap(context);
                    break;

                case "AddJuActivityPraise":    //增加赞
                    result = AddJuActivityPraise(context);
                    break;

                //case "QueryJuMaster"://查询专家库
                //    result = QueryJuMaster(context);
                //    break;
                //case "QueryJuMasterFeedBack"://查询专家库留言//所有人可见
                //    result = QueryJuMasterFeedBack(context);
                //    break;
                //case "AddJuMasterUserLinkerInfo"://提交联系信息
                //    result = AddJuMasterUserLinkerInfo(context);
                //    break;
                //case "AddJuMasterFeedBack"://提交留言
                //    result = AddJuMasterFeedBack(context);
                //    break;
                case "QueryJuActivitySpreadRank":    //提交留言
                    result = QueryJuActivitySpreadRank(context);
                    break;
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            context.Response.Write(result);
        }
Пример #7
0
        /// <summary>
        /// 增加冻结积分记录:
        /// 真正返积分是确认收货7天退货期过后
        /// 返积分按冻结记录去返,以解决:如果用户7天后升级,防止下单的时候冻结的数量跟真正分的数量不一样
        /// </summary>
        /// <param name="orderInfo"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public bool AddLockScoreByOrder(WXMallOrderInfo orderInfo)
        {
            ToLog("into AddLockScoreByOrder");
            BLLWeixin bllWeiXin = new BLLWeixin();
            bool      result    = false;

            //获取是否已经存有的冻结积分
            var lockModel = GetLockScoreByOrder(orderInfo.OrderID);

            if (lockModel != null)
            {
                return(true);
            }

            ToLog("AddLockScoreByOrder 计算获得积分");
            //计算获得积分
            var addScore = CalcOrderRebateScore(orderInfo);

            ToLog("AddLockScoreByOrder addScore:" + addScore);
            //如获得积分则存入冻结表
            if (addScore > 0)
            {
                ToLog("AddLockScoreByOrder 存入冻结表");
                ScoreLockInfo scoreLockInfo = new ScoreLockInfo()
                {
                    ForeignkeyId = orderInfo.OrderID,
                    LockStatus   = 0,
                    LockTime     = DateTime.Now,
                    LockType     = 1,
                    Score        = addScore,
                    UserId       = orderInfo.OrderUserID,
                    WebsiteOwner = orderInfo.WebsiteOwner
                };

                if (Add(scoreLockInfo))
                {
                    ToLog("AddLockScoreByOrder 存入冻结表成功");
                    result = true;

                    //发送通知;
                    string url = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/lockscores#/lockscores", HttpContext.Current.Request.Url.Host);
                    bllWeiXin.SendTemplateMessageNotifyComm(GetCurrentUserInfo(), "您有一笔即将到账积分",
                                                            string.Format("下单获得 {0} 积分,点击查看", addScore),
                                                            url);
                }
                else
                {
                    ToLog("AddLockScoreByOrder 存入冻结表失败");
                }
            }

            return(result);
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.userInfo  = Comm.DataLoadTool.GetCurrUserModel();
            this.weixinBll = new BLLWeixin(userInfo.UserID);

            if (!IsPostBack)
            {
                this.btnDelete.Attributes.Add("onclick", "return confirm(\"确定删除选中的规则?\");");

                this.LoadData();
            }
        }
Пример #9
0
        /// <summary>
        /// 关注自动送券
        /// </summary>
        public void SubscribeGive(UserInfo userInfo)
        {
            try
            {
                BLLDistribution      bllDis         = new BLLDistribution();
                BLLWeixin            bllWeixin      = new BLLWeixin();
                BLLWebsiteDomainInfo bllDomain      = new BLLWebsiteDomainInfo();
                List <CardCoupons>   cardCouponList = GetList <CardCoupons>(string.Format("WebsiteOwner='{0}' And IsSubscribeGive='1'", userInfo.WebsiteOwner));
                foreach (var cardCoupon in cardCouponList)
                {
                    if (GetCount <MyCardCoupons>(string.Format("CardId='{0}' And UserId='{1}'", cardCoupon.CardId, userInfo.UserID)) > 0)
                    {
                        continue;//已经发过了
                    }
                    if (!string.IsNullOrEmpty(cardCoupon.BindChannelUserId))
                    {
                        if (bllDis.GetUserChannel(userInfo) != cardCoupon.BindChannelUserId)
                        {
                            continue;
                        }
                    }
                    if (cardCoupon.MaxCount > 0)
                    {
                        int sendCount = GetCount <MyCardCoupons>(string.Format(" CardID={0}", cardCoupon.CardId));
                        if (sendCount >= cardCoupon.MaxCount)
                        {
                            continue;
                        }
                    }


                    //给用户发满送券
                    MyCardCoupons model = new MyCardCoupons();
                    model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), GetGUID(BLLJIMP.TransacType.CommAdd));
                    model.CardCouponType   = cardCoupon.CardCouponType;
                    model.CardId           = cardCoupon.CardId;
                    model.InsertDate       = DateTime.Now;
                    model.UserId           = userInfo.UserID;
                    model.WebSiteOwner     = userInfo.WebsiteOwner;
                    if (Add(model))
                    {
                        string title     = "您收到一张优惠券";
                        string content   = string.Format("{0}", cardCoupon.Name);
                        string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(userInfo.WebsiteOwner));
                        bllWeixin.SendTemplateMessageNotifyComm(userInfo, title, content, redicturl);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Пример #10
0
        public void ProcessRequest(HttpContext context)
        {
            string result = "false";

            try
            {
                context.Response.ContentType = "text/plain";
                context.Response.Expires     = 0;
                string action = context.Request["Action"];
                systemSet = this.weixinBll.GetSysSet();
                userBll   = new BLLUser("");
                weixinBll = new BLLWeixin("");
                switch (action)
                {
                case "WXReg":
                    result = WXReg(context);    //注册微信会员
                    break;

                //case "CheckIsWXMember":
                //    result = CheckIsWXMember(context);
                //    break;
                //CheckIsWXMemberWithWeixinVerify
                case "CheckIsWXMemberWithWeixinVerify":
                    result = CheckIsWXMemberWithWeixinVerify(context);
                    break;

                case "GetWeixinMemberInfo":    //获取微信会员信息
                    result = GetWeixinMemberInfo(context);
                    break;

                case "EditWeixinMemberInfo":    //编辑微信会员信息
                    result = EditWeixinMemberInfo(context);
                    break;

                //WXRegWithWeixinVerify
                case "WXRegWithWeixinVerify":    //编辑微信会员信息
                    result = WXRegWithWeixinVerify(context);
                    break;
                }
            }
            catch (Exception ex)
            {
                resp.Status = 0;
                resp.Msg    = ex.Message;
                result      = Common.JSONHelper.ObjectToJson(resp);
            }
            context.Response.Write(result);
        }
Пример #11
0
        private ReturnValue SendSystemNoticeToAll(SystemNotice systemNotice, string websiteOwner)
        {
            BLLJIMP.BLLWeixin            bllWeixin    = new BLLWeixin("");
            BLLWeixin.TMTaskNotification notificaiton = new BLLWeixin.TMTaskNotification();
            notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/SystemMessageBox.aspx", System.Web.HttpContext.Current.Request.Url.Host);
            var acctoken = bllWeixin.GetAccessToken();

            List <UserInfo> userList = new List <UserInfo>();

            if (WebsiteOwner.Equals("wubuhui"))
            {
                userList = this.GetList <UserInfo>(string.Format("WebsiteOwner='{0}' and Phone is not null and Phone <>''", websiteOwner));
            }
            else
            {
                userList = this.GetList <UserInfo>(string.Format("WebsiteOwner='{0}'", websiteOwner));
            }
            int successCount = 0;

            foreach (UserInfo uinfo in userList)
            {
                successCount += SendSystemNoticeToUserId(systemNotice, uinfo.UserID) ? 1 : 0;
                try
                {
                    notificaiton.First    = "您好,您有新系统消息";
                    notificaiton.Keyword1 = systemNotice.Title;
                    notificaiton.Keyword2 = systemNotice.NoticeTypeString;
                    notificaiton.Remark   = "点击查看";
                    bllWeixin.SendTemplateMessage(acctoken, uinfo.WXOpenId, notificaiton);
                }
                catch (Exception)
                {
                    continue;
                }
            }

            return(new ReturnValue {
                Code = 0, Msg = string.Format("成功将消息发送到{0}个人.", successCount)
            });
        }
Пример #12
0
        /// <summary>
        ///客服接口 群发
        /// </summary>
        /// <param name="timingTask"></param>
        /// <returns></returns>
        public bool SendImageTextMessage(TimingTask timingTask)
        {
            BLLWeixin bllWeixin = new BLLWeixin("");
            List <BLLWeixin.WeiXinArticle> articleList = new List <BLLWeixin.WeiXinArticle>();

            string[] idarray = timingTask.TaskInfo.Split(',');
            foreach (string id in idarray)
            {
                WeixinMsgSourceInfo msg = bllWeixin.Get <WeixinMsgSourceInfo>(string.Format("SourceID={0}", id));
                articleList.Add(new BLLWeixin.WeiXinArticle()
                {
                    Title       = msg.Title,
                    Description = msg.Description,
                    Url         = msg.Url,
                    PicUrl      = msg.PicUrl
                });
            }

            switch ((ReceiverType)timingTask.ReceiverType)
            {
            case ReceiverType.All:
                bllWeixin.BroadcastKeFuMessageImageText(timingTask.WebsiteOwner, articleList, timingTask.TaskInfo);
                return(true);

            case ReceiverType.Group:

                return(false);

            case ReceiverType.List:
                string[] openidArray = timingTask.Receivers.Split(',');
                foreach (string openid in openidArray)
                {
                    bllWeixin.SendKeFuMessageImageText(bllWeixin.GetAccessToken(timingTask.WebsiteOwner), openid, articleList);
                }
                return(openidArray.Length > 0);

            default:
                return(false);
            }
        }
Пример #13
0
        /// <summary>
        /// 获取授权公众号的接口调用凭据(令牌)
        /// </summary>
        /// <param name="authorizerAppId">授权公众号AppId</param>
        /// <param name="authorizerRefreshToken">授权公众号刷新Token</param>
        /// <param name="websiteOwner">站点所有者s</param>
        /// <returns></returns>
        private string GetAuthorizerToken(string authorizerAppId, string authorizerRefreshToken, string websiteOwner)
        {
            BLLWeixin bllWeixin = new BLLWeixin();

            bllWeixin.ToBLLWeixinLog("GetAuthorizerToken Open");
            var systemSet = GetSysSet();
            var dataObj   = new
            {
                component_appid          = systemSet.ComponentAppId,
                authorizer_appid         = authorizerAppId,
                authorizer_refresh_token = authorizerRefreshToken
            };

            string data = ZentCloud.Common.JSONHelper.ObjectToJson(dataObj);

            bllWeixin.ToBLLWeixinLog("GetAuthorizerToken Open,data:" + data);

            ZentCloud.Common.HttpInterFace webRequest = new Common.HttpInterFace();
            var result = webRequest.PostWebRequest(data, string.Format("https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token={0}", GetComponentAccessToken()), Encoding.UTF8);

            bllWeixin.ToBLLWeixinLog("result" + result);
            AuthorizerAccessTokenModel model = ZentCloud.Common.JSONHelper.JsonToModel <AuthorizerAccessTokenModel>(result);

            bllWeixin.ToBLLWeixinLog("GetAuthorizerToken Open,AuthorizerAccessTokenModel:" + data);

            //
            //更新 authorizer_access_token
            //
            var currentWebsiteInfo = GetWebsiteInfoModelFromDataBase(websiteOwner);

            if (!string.IsNullOrEmpty(model.authorizer_access_token))
            {
                currentWebsiteInfo.AuthorizerAccessTokenUpdateTime = DateTime.Now;
                currentWebsiteInfo.AuthorizerAccessToken           = model.authorizer_access_token;
                currentWebsiteInfo.AuthorizerRefreshToken          = model.authorizer_refresh_token;
                Update(currentWebsiteInfo);
            }
            //
            return(model.authorizer_access_token);
        }
Пример #14
0
        public static bool SendTMAllUserScoreDailyAccountBillNotify(string websiteOwner)
        {
            BLLWeixin       bllWeixin = new BLLWeixin("");
            WeixinFollowers model     = Common.JSONHelper.JsonToModel <WeixinFollowers>(bllWeixin.GetFollower(bllWeixin.GetAccessToken(), string.Empty));

            while (model.count > 0)
            {
                Dictionary <string, object> dicOpenId = (Dictionary <string, object>)model.data;
                object[] openidArry = (object[])dicOpenId.First().Value;
                foreach (var openid in openidArry)
                {
                    UserInfo userInfo = bllWeixin.Get <UserInfo>(string.Format("WXOpenId='{0}' and WebsiteOwner='{1}'", openid, websiteOwner));
                    if (userInfo == null)
                    {
                        continue;
                    }
                    SendTMUserScoreDailyAccountBillNotify(userInfo.UserID, websiteOwner);
                }
                model = Common.JSONHelper.JsonToModel <WeixinFollowers>(bllWeixin.GetFollower(bllWeixin.GetAccessToken(), string.Empty));
            }
            return(true);
        }
Пример #15
0
        //给用户增加积分(负值为减积分),同时写入积分历史,返回修改的delta分值,
        //并调用微信模板消息通知用户
        public double UpdateUserScoreWithWXTMNotify(UserScore userScore, string accessToken)
        {
            double deltaScore = UpdateUserScore(userScore);

            if ((int)deltaScore != 0 && accessToken != string.Empty)
            {
                switch (userScore.UserScoreType)
                {
                case UserScoreType.ShareActivityToWXFriendGroup:
                case UserScoreType.ShareArticleToWXFriendGroup:
                case UserScoreType.SharePositionToWXFriendGroup:
                case UserScoreType.ShareTutorToWXFriendGroup:
                case UserScoreType.TutorShareActivityToWXFriendGroup:
                case UserScoreType.TutorShareArticleToWXFriendGroup:
                case UserScoreType.TutorShareTutorToWXFriendGroup:
                case UserScoreType.TutorSharePositionToWXFriendGroup:
                    System.Threading.Thread.Sleep(30 * 1000);
                    break;

                default:
                    break;
                }

                BLLJIMP.BLLWeixin             bllWeixin    = new BLLWeixin("");
                BLLWeixin.TMScoreNotification notificaiton = new BLLWeixin.TMScoreNotification();
                notificaiton.Url          = string.Format("http://{0}/WuBuHui/MyCenter/Index.aspx", System.Web.HttpContext.Current.Request.Url.Host);
                notificaiton.TemplateId   = "8JLCEV3HmIYV3C3bDiGARxRBJqAZosnQEOI4C0d5He4";
                notificaiton.First        = "您有新的积分变化,详情如下";
                notificaiton.Account      = userInfo.WXNickname;
                notificaiton.Time         = DateTime.Now.ToString();
                notificaiton.Type         = userScore.RecordTypeString;
                notificaiton.CreditChange = "变化";
                notificaiton.Number       = userScore.Score.ToString();
                notificaiton.Amount       = userInfo.TotalScore.ToString();
                notificaiton.Remark       = "您可以点击下方菜单进入五步会,赚取更多积分!";
                bllWeixin.SendTemplateMessage(accessToken, userInfo.WXOpenId, notificaiton);
            }
            return(deltaScore);
        }
Пример #16
0
        private ReturnValue SendSystemNoticeToGroups(SystemNotice systemNotice, string groups, string websiteOwner)
        {
            BLLJIMP.BLLWeixin            bllWeixin    = new BLLWeixin("");
            BLLWeixin.TMTaskNotification notificaiton = new BLLWeixin.TMTaskNotification();
            notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/SystemMessageBox.aspx", System.Web.HttpContext.Current.Request.Url.Host);
            var acctoken = bllWeixin.GetAccessToken();

            string[] groupArray = groups.Split(',');
            string   strWhere   = string.Format("TagName like '%{0}%'", groupArray[0].Trim());

            foreach (string group in groupArray)
            {
                strWhere += string.Format(" or TagName like '%{0}%'", group);
            }
            List <UserInfo> userList     = this.GetList <UserInfo>(string.Format("WebsiteOwner='{0}' and ({1})", websiteOwner, strWhere));
            int             successCount = 0;

            foreach (UserInfo uinfo in userList)
            {
                successCount += SendSystemNoticeToUserId(systemNotice, uinfo.UserID) ? 1 : 0;

                try
                {
                    notificaiton.First    = "您好,您有新系统消息";
                    notificaiton.Keyword1 = systemNotice.Title;
                    notificaiton.Keyword2 = systemNotice.NoticeTypeString;
                    notificaiton.Remark   = "点击查看";
                    bllWeixin.SendTemplateMessage(acctoken, uinfo.WXOpenId, notificaiton);
                }
                catch (Exception)
                {
                    continue;
                }
            }
            return(new ReturnValue {
                Code = 0, Msg = string.Format("成功将消息发送到{0}个人.", successCount)
            });
        }
Пример #17
0
        public static string SendTMUserScoreDailyAccountBillNotify(string receiverUserId, string websiteOwner)
        {
            BLLWeixin bllWeixin = new BLLWeixin("");

            BLLWeixin.TMScoreNotification notificaiton = new BLLWeixin.TMScoreNotification();
            notificaiton.Url        = string.Format("http://{0}/WuBuHui/MyCenter/Index.aspx", System.Web.HttpContext.Current.Request.Url.Host);
            notificaiton.TemplateId = "8JLCEV3HmIYV3C3bDiGARxRBJqAZosnQEOI4C0d5He4";
            notificaiton.First      = "您今日的积分对账单,详情如下";
            notificaiton.Account    = "积分账户";
            notificaiton.Time       = DateTime.Now.ToString();
            notificaiton.Type       = "每日积分对账单";
            //notificaiton.CreditChange = "每日积分对账单";
            UserInfo userInfo = bllWeixin.Get <UserInfo>(string.Format("UserId='{0}' and WebsiteOwner='{1}'", receiverUserId, websiteOwner));

            if (userInfo == null)
            {
                return(string.Format("用户 {0} 不存在", receiverUserId));
            }
            notificaiton.Number = userInfo.TotalScore.ToString();
            notificaiton.Amount = userInfo.TotalScore.ToString();
            notificaiton.Remark = "您可以点击下方菜单进入五步会,赚取更多积分!";
            return(bllWeixin.SendTemplateMessage(bllWeixin.GetAccessToken(), userInfo.WXOpenId, notificaiton));
        }
Пример #18
0
Файл: BLLMQ.cs Проект: uvbs/mmp
        /// <summary>
        /// 新分销会员通知
        /// </summary>
        /// <param name="messageInfo"></param>
        /// <param name="ramark"></param>
        /// <param name="errMsg"></param>
        public void DistNewMemberNotice(MessageInfo messageInfo, out string ramark, out string errMsg)
        {
            Console.WriteLine("正在处理新分销会员通知");

            BLLUserDistributionMember bllUserDistributionMember = new BLLUserDistributionMember();
            BLLUser   bllUser   = new BLLUser();
            BLLWeixin bllWeixin = new BLLWeixin();

            ramark = "";
            errMsg = "";

            var msgBody = JsonConvert.DeserializeObject <Model.MQ.DistNewMemberNoticeInfo>(messageInfo.Msg);

            Console.WriteLine("转换完msgBody");

            //获取分销员和会员
            var distUser = bllUser.GetUserInfoByAutoID(int.Parse(msgBody.DistributionOwnerAutoId), messageInfo.WebsiteOwner);
            var member   = bllUser.GetUserInfoByAutoID(int.Parse(msgBody.MemberAutoId), messageInfo.WebsiteOwner);

            //记录到会员表
            bllUserDistributionMember.SetUserDistributionOwnerInMember(new List <string>()
            {
                member.UserID
            }, distUser.UserID, member.WebsiteOwner);

            //获取当前是第几位会员
            var rowCount = bllUserDistributionMember.GetMemberRowCount(member.UserID, distUser.UserID, member.WebsiteOwner);

            Console.WriteLine("排名:" + rowCount);

            //获取会员昵称
            if (string.IsNullOrWhiteSpace(member.WXNickname) && !string.IsNullOrWhiteSpace(member.WXOpenId))
            {
                Console.WriteLine("无微信昵称,开始获取微信昵称");

                var accessToken = bllWeixin.GetAccessToken(messageInfo.WebsiteOwner);

                if (!string.IsNullOrEmpty(accessToken))
                {
                    Console.WriteLine("获取到accessToken,开始获取会员信息");
                    var wxUserInfo = bllWeixin.GetWeixinUserInfo(accessToken, member.WXOpenId);
                    Console.WriteLine("处理完获取会员信息");
                    if (wxUserInfo != null)
                    {
                        Console.WriteLine("获取到会员信息");
                        member.WXHeadimgurl = wxUserInfo.headimgurl;
                        member.WXNickname   = string.IsNullOrWhiteSpace(wxUserInfo.nickname) ? "" : wxUserInfo.nickname.Replace("'", "");
                        member.WXProvince   = wxUserInfo.province;
                        member.WXCity       = wxUserInfo.city;

                        bllUser.Update(new UserInfo(), string.Format(" WXHeadimgurl='{0}',WXNickname='{1}',WXProvince='{2}',WXCity='{3}' ",
                                                                     member.WXHeadimgurl,
                                                                     member.WXNickname,
                                                                     member.WXProvince,
                                                                     member.WXCity
                                                                     ), string.Format(" UserId = '{0}' AND WebsiteOwner = '{1}' ", member.UserID, member.WebsiteOwner));
                    }
                    else
                    {
                        Console.WriteLine("获取不到会员信息");
                    }
                }
                else
                {
                    Console.WriteLine("获取不到accessToken");
                }
            }

            var notice = string.Format("恭喜 {0} 成为您的第{1}号会员", member.WXNickname, rowCount);

            Console.WriteLine("开始发通知");
            //发送通知
            bllWeixin.SendTemplateMessageNotifyComm(distUser, string.Format("新会员通知"), notice);

            Console.WriteLine(notice);
        }
Пример #19
0
        /// <summary>
        /// 冻结积分结算
        /// </summary>
        /// <param name="orderInfo"></param>
        /// <returns></returns>
        public bool SettlementOrderLockScore(WXMallOrderInfo orderInfo, out string msg)
        {
            BLLMall bllMall = new BLLMall();
            BLLWebsiteDomainInfo bllWebsiteDomain = new BLLWebsiteDomainInfo();
            BLLWeixin            bllWeixin        = new BLLWeixin();

            msg = "";
            var lockModel = GetLockScoreByOrder(orderInfo.OrderID);

            int addScore = (int)lockModel.Score;

            if (addScore > 0)
            {
                UserInfo orderUserInfo = bllUser.GetUserInfo(orderInfo.OrderUserID, orderInfo.WebsiteOwner);
                if (orderUserInfo == null)
                {
                    return(false);
                }
                WebsiteInfo websiteInfo = bllMall.Get <WebsiteInfo>(string.Format(" WebsiteOwner='{0}'", orderInfo.WebsiteOwner));

                ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZentCloud.ZCBLLEngine.BLLTransaction();
                try
                {
                    UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                    scoreRecord.AddTime      = DateTime.Now;
                    scoreRecord.Score        = addScore;
                    scoreRecord.TotalScore   = orderUserInfo.TotalScore;
                    scoreRecord.ScoreType    = "OrderSuccess";
                    scoreRecord.UserID       = orderInfo.OrderUserID;
                    scoreRecord.AddNote      = "微商城-交易成功获得积分";
                    scoreRecord.WebSiteOwner = orderInfo.WebsiteOwner;
                    scoreRecord.RelationID   = orderInfo.OrderID;

                    if (!bllMall.Add(scoreRecord, tran))
                    {
                        tran.Rollback();
                        return(false);
                    }
                    if (bllUser.Update(orderUserInfo, string.Format(" TotalScore+={0},HistoryTotalScore+={0}", addScore), string.Format(" AutoID={0}", orderUserInfo.AutoID), tran) <= 0)
                    {
                        tran.Rollback();
                        return(false);
                    }

                    #region 宏巍加积分
                    if (websiteInfo.IsUnionHongware == 1)
                    {
                        Open.HongWareSDK.Client hongWareClient = new Open.HongWareSDK.Client(orderInfo.WebsiteOwner);
                        var hongWareMemberInfo = hongWareClient.GetMemberInfo(orderUserInfo.WXOpenId);
                        if (hongWareMemberInfo.member != null)
                        {
                            if (!hongWareClient.UpdateMemberScore(hongWareMemberInfo.member.mobile, orderUserInfo.WXOpenId, addScore))
                            {
                                tran.Rollback();
                                return(false);
                            }
                        }
                    }
                    #endregion

                    //积分解冻
                    if (!string.IsNullOrWhiteSpace(lockModel.Memo))
                    {
                        lockModel.Memo += ";交易成功获得积分解冻";
                    }
                    else
                    {
                        lockModel.Memo = "交易成功获得积分解冻";
                    }

                    if (Update(
                            new ScoreLockInfo(),
                            string.Format(" Memo+='{0}',LockStatus=1,UnLockTime=GETDATE() ", lockModel.Memo),
                            string.Format(" ForeignkeyId='{0}' AND LockType = 1 ", orderInfo.OrderID),
                            tran
                            ) > 0)
                    {
                        #region 微信通知
                        try
                        {
                            string url = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/myscores#/myscores", bllWebsiteDomain.GetWebsiteDoMain(orderInfo.WebsiteOwner));
                            bllWeixin.SendTemplateMessageNotifyCommTask(orderUserInfo.WXOpenId, "您有一笔积分已经到账", string.Format("积分:{0}分", (int)lockModel.Score), url, "", "", "", orderInfo.WebsiteOwner);
                        }
                        catch
                        {
                        }
                        #endregion
                    }
                    else
                    {
                        msg = string.Format("处理即将到账积分失败!订单号:{0}", orderInfo.OrderID);
                        tran.Rollback();
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                    tran.Rollback();
                    return(false);
                }

                tran.Commit();
            }

            return(true);
        }
Пример #20
0
        /// <summary>
        /// 赠送满送券
        /// </summary>
        public void Give(decimal totalAmount, UserInfo userInfo)
        {
            try
            {
                BLLWeixin            bllWeixin      = new BLLWeixin();
                BLLWebsiteDomainInfo bllDomain      = new BLLWebsiteDomainInfo();
                List <CardCoupons>   cardCouponList = GetList <CardCoupons>(string.Format("WebsiteOwner='{0}' And CardCouponType='MallCardCoupon_BuckleGive'", userInfo.WebsiteOwner)).OrderBy(p => p.Ex5).ToList();
                foreach (var cardCoupon in cardCouponList)
                {
                    if (totalAmount >= decimal.Parse(cardCoupon.Ex5))
                    {
                        if (cardCoupon.MaxCount > 0)
                        {
                            int sendCount = GetCount <MyCardCoupons>(string.Format(" CardID={0}", cardCoupon.CardId));
                            if (sendCount >= cardCoupon.MaxCount)
                            {
                                break;
                            }
                        }
                        //给用户发满送券
                        MyCardCoupons model = new MyCardCoupons();
                        model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), GetGUID(BLLJIMP.TransacType.CommAdd));
                        model.CardCouponType   = cardCoupon.CardCouponType;
                        model.CardId           = cardCoupon.CardId;
                        model.InsertDate       = DateTime.Now;
                        model.UserId           = userInfo.UserID;
                        model.WebSiteOwner     = userInfo.WebsiteOwner;
                        if (Add(model))
                        {
                            string title     = "您收到一张优惠券";
                            string content   = string.Format("{0}", cardCoupon.Name);
                            string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(userInfo.WebsiteOwner));
                            bllWeixin.SendTemplateMessageNotifyComm(userInfo, title, content, redicturl);
                        }


                        //给用户发满送券
                        //break;
                    }
                }


                #region New
                List <CardCoupons> cardCouponListNew = GetList <CardCoupons>(string.Format("WebsiteOwner='{0}' And FullGive!=''", userInfo.WebsiteOwner));

                foreach (var cardCoupon in cardCouponListNew)
                {
                    if (totalAmount >= decimal.Parse(cardCoupon.FullGive))
                    {
                        if (cardCoupon.MaxCount > 0)
                        {
                            int sendCount = GetCount <MyCardCoupons>(string.Format(" CardID={0}", cardCoupon.CardId));
                            if (sendCount >= cardCoupon.MaxCount)
                            {
                                break;
                            }
                        }
                        //给用户发券
                        MyCardCoupons model = new MyCardCoupons();
                        model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), GetGUID(BLLJIMP.TransacType.CommAdd));
                        model.CardCouponType   = cardCoupon.CardCouponType;
                        model.CardId           = cardCoupon.CardId;
                        model.InsertDate       = DateTime.Now;
                        model.UserId           = userInfo.UserID;
                        model.WebSiteOwner     = userInfo.WebsiteOwner;
                        if (Add(model))
                        {
                            string title     = "您收到一张优惠券";
                            string content   = string.Format("{0}", cardCoupon.Name);
                            string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(userInfo.WebsiteOwner));
                            bllWeixin.SendTemplateMessageNotifyComm(userInfo, title, content, redicturl);
                        }
                        else
                        {
                        }


                        //给用户发券
                        //break;
                    }
                    else
                    {
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
        }
Пример #21
0
        /// <summary>
        /// 储值卡发放
        /// </summary>
        /// <param name="userIds"></param>
        /// <param name="cardId"></param>
        /// <param name="websiteOwner"></param>
        /// <param name="msg"></param>
        /// <param name="authority">域名加端口</param>
        /// <returns></returns>
        public bool SendRecord(string card_id, string type, string user_ids, string tags, string websiteOwner, string createUserId, out string msg, string authority)
        {
            msg = "";

            if (type == "2" && string.IsNullOrWhiteSpace(tags))
            {
                msg = "请选择接受储值卡的用户标签组";
                return(false);
            }
            else if (type == "1" && string.IsNullOrWhiteSpace(user_ids))
            {
                msg = "请选择接受储值卡的用户";
                return(false);
            }

            StoredValueCard card = GetByKey <StoredValueCard>("AutoId", card_id, websiteOwner: websiteOwner);

            if (card == null)
            {
                msg = "储值卡不存在";
                return(false);
            }
            if (card.Status != 0)
            {
                msg = "储值卡已停用";
                return(false);
            }

            DateTime curDate    = DateTime.Now;
            string   dateString = curDate.ToString("yyyyMMdd");

            if (card.ValidType == 0 && card.ValidTo.HasValue && card.ValidTo.Value < curDate)
            {
                msg = string.Format("储值卡已过有效期");
                return(false);
            }
            List <string> userIdList = new List <string>();

            if (type == "2")
            {
                StringBuilder sbWhere = new StringBuilder();
                sbWhere.AppendFormat(" WebSiteOwner='{0}' And ( 1=2 ", websiteOwner);
                foreach (var tag in tags.Split(','))
                {
                    sbWhere.AppendFormat(" Or ',' + TagName + ',' Like '%,{0},%' ", tag);
                }
                sbWhere.AppendFormat(" )");
                List <UserInfo> userList = GetColList <UserInfo>(int.MaxValue, 1, sbWhere.ToString(), "AutoID,UserID");
                if (userList.Count > 0)
                {
                    userIdList = userList.Select(p => p.UserID).Distinct().ToList();
                }
            }
            else if (type == "1")
            {
                userIdList = user_ids.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).Distinct().ToList();
            }

            if (userIdList.Count == 0)
            {
                msg = "接受卡券的用户未找到";
                return(false);
            }

            int cCount = userIdList.Count - (card.MaxCount - card.SendCount);

            if (cCount > 0)
            {
                msg = string.Format("储值卡可发放数量不足,少{0}张", cCount);
                return(false);
            }

            int startNum = 0;
            StoredValueCardRecord oldRecord = Get <StoredValueCardRecord>(string.Format("{0}{1}", GetRecordWhereString(card.AutoId.ToString(), websiteOwner, null, null), " Order By AutoId Desc"));

            if (oldRecord != null)
            {
                startNum = Convert.ToInt32(oldRecord.CardNumber.Substring(16));
            }

            StoredValueCardRecord baseRecord = new StoredValueCardRecord();

            baseRecord.CardId       = card.AutoId;
            baseRecord.WebsiteOwner = websiteOwner;
            baseRecord.CreateUserId = createUserId;
            baseRecord.CreateDate   = curDate;
            if (card.ValidType == 0)
            {
                baseRecord.ValidTo = card.ValidTo;
            }
            else if (card.ValidType == 1 && card.ValidDay.HasValue)
            {
                baseRecord.ValidTo = curDate.AddDays(card.ValidDay.Value);
            }
            baseRecord.Amount = card.Amount;
            Random ran        = new Random();
            string cardString = card_id.PadLeft(3, '0');

            if (card_id.Length > 3)
            {
                cardString = cardString.Substring(card_id.Length - 3);
            }
            List <StoredValueCardRecord> sendRecordList = new List <StoredValueCardRecord>();
            List <UserInfo> usList = new List <UserInfo>();

            for (int i = 0; i < userIdList.Count; i++)
            {
                UserInfo cru = usList.FirstOrDefault(p => p.UserID == userIdList[i]);
                if (cru == null)
                {
                    cru = GetColByKey <UserInfo>("UserID", userIdList[i], "AutoID,UserID,WXOpenId,WebsiteOwner", websiteOwner: websiteOwner);
                    if (cru == null)
                    {
                        continue;
                    }
                    usList.Add(cru);
                }
                else
                {
                    usList.Add(cru);
                }
                startNum++;
                StoredValueCardRecord rRecord = (StoredValueCardRecord)baseRecord.Clone();
                rRecord.UserId = userIdList[i];
                string numString = startNum.ToString();
                string ranString = ran.Next(99).ToString();
                rRecord.CardNumber = "No." + dateString + cardString + ranString.PadLeft(2, '0') + numString.PadLeft(3, '0');
                sendRecordList.Add(rRecord);
            }
            if (sendRecordList.Count == 0)
            {
                msg = "接收用户未找到";
                return(false);
            }
            BLLWeixin bllWeixin = new BLLWeixin();
            int       suCount   = 0;
            string    redicturl = string.Format("http://{0}/App/SVCard/Wap/List.aspx", authority);

            for (int i = 0; i < sendRecordList.Count; i++)
            {
                if (Add(sendRecordList[i]))
                {
                    suCount++;

                    string content = string.Format("{0}\\n金额:{1}", card.Name, card.Amount);
                    if (sendRecordList[i].ValidTo.HasValue)
                    {
                        content += string.Format("\\n有效期:{0}", sendRecordList[i].ValidTo.Value.ToString("yyyy-MM-dd HH:mm"));
                    }
                    bllWeixin.SendTemplateMessageNotifyComm(usList[i], "您收到一张储值卡", content, redicturl);
                }
            }
            if (Update(card, string.Format("SendCount=SendCount+{0}", suCount),
                       string.Format("AutoId={0} And WebsiteOwner='{1}'", card.AutoId, websiteOwner)) <= 0)
            {
                if (suCount < sendRecordList.Count)
                {
                    msg = "发送成功" + suCount + "张,但更新发放数量出错";
                }
                else
                {
                    msg = "发送成功,但更新发放数量出错";
                }
                return(true);
            }
            if (suCount < sendRecordList.Count)
            {
                msg = "发送成功" + suCount + "张";
            }
            else
            {
                msg = "发放储值卡成功";
            }
            return(true);
        }
Пример #22
0
        public void ProcessRequest(HttpContext context)
        {
            BLLJIMP.BLLDistributionOffLine bll = new BLLJIMP.BLLDistributionOffLine();
            BllPay    bllPay     = new BllPay();
            BLLWeixin bllWeixin  = new BLLWeixin();
            string    ids        = context.Request["ids"];
            string    moduleName = "积分";

            if (!string.IsNullOrWhiteSpace(context.Request["module_name"]))
            {
                moduleName = context.Request["module_name"];
            }

            int total = 0;

            if (string.IsNullOrWhiteSpace(ids))
            {
                apiResp.msg  = "请选中申请";
                apiResp.code = (int)APIErrCode.IsNotFound;
                bll.ContextResponse(context, apiResp);
                return;
            }
            var sourceList = bll.QueryWithdrawCashList(1, int.MaxValue, null, out total, "0", context.Request["type"], ids);

            if (sourceList.Count == 0)
            {
                apiResp.msg  = "选中的申请无待审核申请";
                apiResp.code = (int)APIErrCode.IsNotFound;
                bll.ContextResponse(context, apiResp);
                return;
            }

            string websiteOwner = bll.WebsiteOwner;
            string ip           = System.Web.HttpContext.Current.Request.UserHostAddress;
            int    snum         = 0;

            foreach (var p in sourceList)
            {
                UserInfo pu = bllUser.GetUserInfo(p.UserId, websiteOwner);
                if (pu == null || string.IsNullOrWhiteSpace(pu.WXOpenId))
                {
                    apiResp.status = snum > 0;
                    apiResp.msg    = string.Format("编号:{0},审核出错,用户信息有误", p.AutoID);
                    apiResp.code   = (int)APIErrCode.OperateFail;
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                //通知
                BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice();
                notice.Ncontent     = string.Format("申请提现通过审核,编号:{0}", p.AutoID);
                notice.UserId       = currentUserInfo.UserID;
                notice.Receivers    = pu.UserID;
                notice.SendType     = 2;
                notice.Title        = "申请提现通过审核";
                notice.NoticeType   = 1;
                notice.WebsiteOwner = websiteOwner;
                notice.InsertTime   = DateTime.Now;

                BLLTransaction tran   = new BLLTransaction();
                bool           result = bll.Update(p, string.Format("Status=2,LastUpdateDate=getdate()"), string.Format("AutoID={0}", p.AutoID), tran) > 0;
                if (!result)
                {
                    tran.Rollback();
                    apiResp.status = snum > 0;
                    apiResp.msg    = string.Format("编号:{0},审核出错", p.AutoID);
                    apiResp.code   = snum > 0 ? (int)APIErrCode.IsSuccess : (int)APIErrCode.OperateFail;
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                string msg = "";
                if (bllPay.WeixinTransfers(p.AutoID.ToString(), p.RealAmount, pu.WXOpenId, ip, out msg, "提现"))
                {
                    //发送微信模板消息
                    bllWeixin.SendTemplateMessageNotifyComm(pu, "您提现的佣金已经到账", string.Format("提现金额:{0}元。请查看微信钱包", p.RealAmount));
                    //发送微信模板消息

                    //发送通知
                    notice.SerialNum = bllUser.GetGUID(TransacType.SendSystemNotice);
                    bll.Add(notice);
                    //发送通知
                }
                else//打款失败
                {
                    tran.Rollback();
                    apiResp.status = snum > 0;
                    apiResp.msg    = string.Format("编号:{0},微信打款出错 : {1}", p.AutoID, msg);
                    apiResp.code   = snum > 0 ? (int)APIErrCode.IsSuccess : (int)APIErrCode.OperateFail;
                    bll.ContextResponse(context, apiResp);
                    return;
                }

                tran.Commit();
                snum++;
            }

            if (snum == 0)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "审核失败";
            }
            else
            {
                apiResp.status = true;
                apiResp.code   = (int)APIErrCode.IsSuccess;
                apiResp.msg    = string.Format("审核完成");
            }
            bll.ContextResponse(context, apiResp);
        }