示例#1
0
        public string MyToken(string tusers)
        {
            var cuo = CLoginService.GetMerchantsBy(tusers);
            //Session["CurrentMerchants"] = cuo;
            string Access_token = "";

            if (cuo.Access_token != "")
            {
                Access_token = cuo.Access_token;
                string url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + Access_token
                             + "&openid=" + (cuo.OneOpenID == null ? "oAWd50qK6bOaprTwyLAn4hvLWDdM" : cuo.OneOpenID);
                string b = PostRequest(url);
                if (b.Contains("errcode"))  //返回错误信息
                {
                    Access_token     = GetAccess(Access_token, cuo);
                    cuo.Access_token = Access_token;
                    SaveMerchants(cuo);
                }
                if (cuo.OneOpenID == "" || cuo.OneOpenID == null)
                {
                    ISystemService sbo  = new SystemService();
                    WXCUST_FANS    fans = sbo.GetOneFans(cuo.ToUserName);
                    if (fans != null)
                    {
                        cuo.OneOpenID = fans.FROMUSERNAME;
                        SaveMerchants(cuo);
                    }
                }
            }
            return(Access_token);
        }
示例#2
0
 public int SaveCustFans(WXCUST_FANS entity)
 {
     if (entity.ID == 0)
     {
         return((int)_set.Insert(entity));
     }
     else
     {
         return(_set.Update(entity));
     }
 }
示例#3
0
        public string Token(string ToUserName)
        {
            ISystemService sbo = new SystemService();

            m = sbo.GetMerchantsByToUserName(ToUserName);
            if (m == null)
            {
                return("");
            }
            string Access_token = "";

            if (m.Access_token != "")
            {
                Access_token = m.Access_token;
                string url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + Access_token + "&openid=" +
                             (m.OneOpenID == null ? "oQaIMwPgnsBpwQYfwLQnUBbmQKS4" : m.OneOpenID);
                string b = PostRequest(url);
                if (b.Contains("errcode"))  //返回错误信息
                {
                    Access_token   = GetAccess(m);
                    m.Access_token = Access_token;
                    sbo.SaveMerchants(m);
                }
                if (m.OneOpenID == "" || m.OneOpenID == null)
                {
                    WXCUST_FANS fans = sbo.GetOneFans(m.ToUserName);
                    if (fans != null)
                    {
                        m.OneOpenID = fans.FROMUSERNAME;
                        sbo.SaveMerchants(m);
                    }
                }
            }
            else
            {
                if (m.OneOpenID == "" || m.OneOpenID == null)
                {
                    WXCUST_FANS fans = sbo.GetOneFans(m.ToUserName);
                    if (fans != null)
                    {
                        m.OneOpenID = fans.FROMUSERNAME;
                        // sbo.SaveMerchants(m);
                    }
                }
                Access_token   = GetAccess(m);
                m.Access_token = Access_token;
                sbo.SaveMerchants(m);
            }
            return(Access_token);
        }
示例#4
0
    public string Token()
    {
        m = CurrentMerchants;
        string Access_token = "";

        if (m.Access_token != "")
        {
            Access_token = m.Access_token;
            string url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + Access_token + "&openid=" + (m.OneOpenID == null ? "oAWd50qK6bOaprTwyLAn4hvLWDdM" : m.OneOpenID);
            string b   = PostRequest(url);
            if (b.Contains("errcode"))  //返回错误信息
            {
                Access_token   = GetAccess(Access_token);
                m.Access_token = Access_token;
                SaveMerchants(m);
            }
            if (m.OneOpenID == "" || m.OneOpenID == null)
            {
                ISystemService sbo  = new SystemService();
                WXCUST_FANS    fans = sbo.GetOneFans(m.ToUserName);
                if (fans != null)
                {
                    m.OneOpenID = fans.FROMUSERNAME;
                    SaveMerchants(m);
                }
            }
        }
        else
        {
            if (m.OneOpenID == "" || m.OneOpenID == null)
            {
                ISystemService sbo  = new SystemService();
                WXCUST_FANS    fans = sbo.GetOneFans(m.ToUserName);
                if (fans != null)
                {
                    m.OneOpenID = fans.FROMUSERNAME;
                    //SaveMerchants(m);
                }
            }
            Access_token   = GetAccess(Access_token);
            m.Access_token = Access_token;
            SaveMerchants(m);
        }
        return(Access_token);
    }
示例#5
0
        public ActionResult Index()
        {
            //Base();
            //Session["FromUserName"] = "******";
            //Session["ToUserName"] = "******";

            string openid = Session["FromUserName"] == null ? "" : Session["FromUserName"].ToString();

            if (!string.IsNullOrEmpty(openid))
            {
                WXCUST_FANS cfan = _service.GetFansByFromUserName(openid);
                if (cfan != null)
                {
                    openid = cfan.ID.ToString();
                }
            }

            List <FILE_EX> fils = _service.GetFiilesImage();

            ViewBag.Files  = fils;
            ViewBag.OpenId = openid;
            return(View());
        }
示例#6
0
 /// <summary>
 /// 修改粉丝信息
 /// </summary>
 /// <param name="f"></param>
 /// <returns></returns>
 public int UpdateFans(WXCUST_FANS f)
 {
     return(_set.Update(f));
 }
示例#7
0
 /// <summary>
 ///插入粉丝信息
 /// </summary>
 /// <param name="f"></param>
 /// <returns></returns>
 public int InsertFans(WXCUST_FANS f)
 {
     return((int)_set.Insert(f));
 }
示例#8
0
        /// <summary>
        /// 绑定会员
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public string BindMember(string mobile, string openid, string Nickname)
        {
            using (TransScope scope = new TransScope())
            {
                WXCUST_FANS fans = _repo.GetFans(openid);

                if (fans == null)
                {
                    return("3");
                }

                CUST_MEMBER member = _repo.GetMemberByMobile(mobile, fans.ID);

                if (member != null)
                {
                    return("2");
                }

                #region 记录会员
                dt_Dyn_DispMember_req w = new dt_Dyn_DispMember_req();
                w.DATA_SOURCE   = "0002";
                w.LOYALTY_BRAND = AppConfig.LOYALTY_BRAND; //忠诚度品牌
                w.SOURCE_SYSTEM = AppConfig.SOURCE_SYSTEM; //来源系统
                w.VGROUP        = AppConfig.VGROUP;        //销售组织
                w.MOB_NUMBER    = mobile;                  //2002652891
                dt_Dyn_DispMember_res dt = WebApiHelp.DispMember(w);

                if (dt.ZCRMT316 == null || dt.ZCRMT316.Count() <= 0)
                {
                    return("4");
                }

                if (dt.ZCRMT316.Count() > 1)
                {
                    return("5");
                }

                ZCRMT302_Dyn meber = dt.ZCRMT316[0];

                CUST_MEMBER mebers = new CUST_MEMBER()
                {
                    ADDRESS     = meber.PSTREET,
                    AVA_POINTS  = (int?)meber.ZCCUR_POINT,
                    BIRTHDAY    = string.IsNullOrEmpty(meber.BIRTHDT) ? null : (DateTime?)DateTime.Parse(meber.BIRTHDT),
                    CITY        = "",
                    COUNTRY     = "",
                    CREATE_DATE = DateTime.Now,
                    CREATE_USER = "******",
                    EMAIL       = meber.CSMTP_ADDR,
                    FANS_ID     = fans.ID,
                    GENDER      = meber.XSEX == "2" ? true : false,
                    MEMBERNO    = meber.ACCOUNT_ID,
                    MEM_LEVEL   = meber.ZTIER,
                    MOBILE      = mobile,
                    STATUS      = 1,
                    STORE       = meber.ZH003,
                    NAME        = meber.NAME1_TEXT,
                    PARTNER     = meber.PARTNER,
                    TYPE        = meber.DATA_SOURCE == "0001" ? 0 : 1
                };

                double counts = _repo.Insert(mebers);
                #endregion
                //如果绑定成功需要告诉crm已经绑定
                if (counts > 0)
                {
                    //绑定接口
                    dt_Dyn_UpdateMemberShip_req updates = new dt_Dyn_UpdateMemberShip_req();
                    ZCRMT322_Dyn z = new ZCRMT322_Dyn();
                    z.DATA_SOURCE = "0002";

                    z.LOYALTY_BRAND      = AppConfig.LOYALTY_BRAND; //忠诚度品牌
                    z.SOURCE_SYSTEM      = AppConfig.SOURCE_SYSTEM; //来源系统
                    z.VGROUP             = AppConfig.VGROUP;        //销售组织
                    z.WECHATNAME         = Nickname;
                    z.WECHATFOLLOWSTATUS = "1";
                    z.OPENID             = openid;
                    z.ACCOUNT_ID         = dt.ZCRMT316[0].ACCOUNT_ID;
                    z.PARTNER            = dt.ZCRMT316[0].PARTNER;
                    updates.ZCRMT316     = new ZCRMT322_Dyn[] { z };

                    dt_Dyn_UpdateMemberShip_res ups = WebApiHelp.UpdateMemberShip(updates);

                    //如果是待激活状态那么就要激活
                    if (meber.ZZAFLD000004 == "E0005")
                    {
                        //激活
                        this.ChageSatus(meber.ACCOUNT_ID);
                    }

                    //绑定成功送三百积分
                    if (fans.IS_REGISTER == null || fans.IS_REGISTER == 0)
                    {
                        #region 注册送积分
                        //如果注册会员成功送积分
                        //si_Dyn_ActCreateTel_obService == si_ActCreateTel_obService
                        dt_Dyn_ActCreateTel_req Actreq = new dt_Dyn_ActCreateTel_req();
                        // 数据源类型
                        Actreq.TYPE = "0002";
                        //处理标识
                        Actreq.OBJECT_ID = DateTime.Now.ToString("yyyyMMddHHmmss") + CommonHelp.GetRand(10);
                        //活动单据类型
                        Actreq.PROCESS_TYPE = "ZXY";
                        //外部会员卡号	"会员卡号(如已传输手机号,可不用填写会员卡号)"
                        Actreq.ACCOUNT_ID   = meber.ACCOUNT_ID;
                        Actreq.POSTING_DATE = DateTime.Today.ToString();
                        //积分类型
                        Actreq.POINT_TYPE = "ZBCJF01";

                        //积分数  要改
                        Actreq.POINTS = decimal.Parse(AppConfig.POINTS);
                        //单据全局活动ID
                        Actreq.CAMPAIGN_HE_ID = "CMP2820171023005";
                        Actreq.LOYALTY_BRAND  = AppConfig.LOYALTY_BRAND; //忠诚度品牌
                        Actreq.SOURCE_SYSTEM  = AppConfig.SOURCE_SYSTEM; //来源系统
                        Actreq.VGROUP         = AppConfig.VGROUP;        //销售组织

                        dt_Dyn_ActCreateTel_res Actres = WebApiHelp.ActCreateTel(Actreq);

                        string remak = string.Empty;

                        if (Actres.I_ZCRMT047_dyn[0].CHECK_FLAG == "N")
                        {
                            remak = "新注册会员送积分失败,原因:" + Actres.I_ZCRMT047_dyn[0].MESSAGE;
                        }
                        #endregion

                        string str = _repo.UpdateIsRegion(fans.ID);
                    }
                }
                scope.Commit();
                return("1");
            }
        }
示例#9
0
        /// <summary>
        /// 注册会员
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="openid"></param>
        /// <param name="nameo"></param>
        /// <param name="namek"></param>
        /// <returns></returns>
        public string RegisterMember(string mobile, string openid,
                                     string nameo, string namek, string brithday, string nickname, string gender)
        {
            WXCUST_FANS fans = _repo.GetFans(openid);

            //没有该粉丝
            if (fans == null)
            {
                return("-1");
            }

            #region 调用接口通知crm创建会员
            dt_Dyn_UploadMemberShip_req req = new dt_Dyn_UploadMemberShip_req();
            ZCRMT316_Dyn meber = new ZCRMT316_Dyn();
            meber.MOB_NUMBER         = mobile;
            meber.OPENID             = openid;
            meber.NAME1_TEXT         = nameo + namek;//全名
            meber.DATA_SOURCE        = "0002";
            meber.ACCOUNT_ID         = mobile;
            meber.NAME_LAST          = nameo;
            meber.NAME_FIRST         = namek;
            meber.XSEX               = gender == "1" ? "2" : "1";
            meber.REGION             = "";
            meber.BIRTHDT            = brithday;
            meber.NAMCOUNTRY         = "CN";
            meber.WECHATNAME         = nickname;
            meber.WECHATFOLLOWSTATUS = "1";
            //meber.LOGINPASS2 = "111111";//兑换密码默认123456
            meber.LOYALTY_BRAND = AppConfig.LOYALTY_BRAND; //忠诚度品牌
            meber.SOURCE_SYSTEM = AppConfig.SOURCE_SYSTEM; //来源系统
            meber.VGROUP        = AppConfig.VGROUP;        //销售组织

            //固定死
            meber.EMPID  = AppConfig.EMPID;
            meber.DEPTID = AppConfig.DEPTID;

            req.ZCRMT316 = new ZCRMT316_Dyn[] { meber };

            //创建会员
            dt_Dyn_UploadMemberShip_res res = WebApiHelp.CreateMemberShip(req);
            #endregion

            if (res.WV_RETURN == "N")
            {
                return(res.WV_MESSAGE);
            }

            //创建成功
            if (res.WV_RETURN == "Y")
            {
                //创建本地会员
                CUST_MEMBER member = new CUST_MEMBER()
                {
                    BIRTHDAY = DateTime.Parse(brithday),
                    FANS_ID  = fans.ID,
                    MEMBERNO = res.ACCOUNT_ID,
                    MOBILE   = mobile,
                    NAME     = nameo + namek,
                    STATUS   = 1,
                    STORE    = AppConfig.DEPTID,
                    TYPE     = 0,
                    //LOGINPASSON = "111111",
                    CREATE_DATE = DateTime.Now,
                    AVA_POINTS  = 0,
                    PARTNER     = res.PARTNER,
                    GENDER      = false
                                  //REMARK = remak
                };

                double counts = _repo.Insert(member);

                if (counts <= 0)
                {
                    return($"请关掉页面并用手机号:{mobile},绑定!");
                }
                else
                {
                    #region 注册送积分
                    //如果注册会员成功送积分
                    //si_Dyn_ActCreateTel_obService == si_ActCreateTel_obService
                    dt_Dyn_ActCreateTel_req Actreq = new dt_Dyn_ActCreateTel_req
                    {
                        // 数据源类型
                        TYPE = "0002",
                        //处理标识
                        OBJECT_ID = DateTime.Now.ToString("yyyyMMddHHmmss") + CommonHelp.GetRand(10),
                        //活动单据类型
                        PROCESS_TYPE = "ZXY",
                        //外部会员卡号	"会员卡号(如已传输手机号,可不用填写会员卡号)"
                        ACCOUNT_ID   = res.ACCOUNT_ID,
                        POSTING_DATE = DateTime.Today.ToString(),
                        //积分类型
                        POINT_TYPE = "ZBCJF01",
                        //积分数  要改
                        POINTS = decimal.Parse(AppConfig.POINTS),
                        //单据全局活动ID
                        CAMPAIGN_HE_ID = "C-00001786",
                        LOYALTY_BRAND  = AppConfig.LOYALTY_BRAND, //忠诚度品牌
                        SOURCE_SYSTEM  = AppConfig.SOURCE_SYSTEM, //来源系统
                        VGROUP         = AppConfig.VGROUP         //销售组织
                    };

                    dt_Dyn_ActCreateTel_res Actres = WebApiHelp.ActCreateTel(Actreq);

                    //if (Actres.I_ZCRMT047_dyn[0].CHECK_FLAG == "N")
                    //{
                    //    remak = "新注册会员送积分失败,原因:" + Actres.I_ZCRMT047_dyn[0].MESSAGE;
                    //}
                    #endregion


                    #region 注册成功就要激活会员
                    ////如果是待激活状态那么就要激活
                    //dt_Dyn_ChangeMemberStatus_req reqs = new dt_Dyn_ChangeMemberStatus_req();
                    //reqs.DATA_SOURCE = "0002";
                    //reqs.ZVTWEG = "102";
                    ////req.STATUS_OLD = "E0000";
                    ////req.STATUS_NEW = "E0001";
                    //reqs.ACCOUNT_ID = meber.ACCOUNT_ID;
                    //reqs.FLAG = "I";//激活
                    //reqs.LOYALTY_BRAND = AppConfig.LOYALTY_BRAND;//忠诚度品牌
                    //reqs.SOURCE_SYSTEM = AppConfig.SOURCE_SYSTEM;//来源系统
                    //reqs.VGROUP = AppConfig.VGROUP; //销售组织
                    //reqs.PASS_FLAG = "N";
                    //reqs.REASON = "激活";
                    //dt_Dyn_ChangeMemberStatus_res resok = WebApiHelp.ChangeMemberStatus(reqs);
                    #endregion
                }
            }

            return("1");
        }