Ejemplo n.º 1
0
        public string SendRedPack(string re_openid, string sub_mch_id, string wishing, string act_name, string remark, int amount, int sendredpackrecordid)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false, wid);

            if (masterSettings.EnableWeiXinRequest)
            {
                DateTime now   = DateTime.Now;
                DateTime time2 = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:01");
                DateTime time3 = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 08:00:00");
                if ((now > time2) && (now < time3))
                {
                    return("北京时间0:00-8:00不触发红包赠送");
                }
                if ((string.IsNullOrEmpty(masterSettings.WeixinAppId) || string.IsNullOrEmpty(masterSettings.WeixinPartnerID)) || ((string.IsNullOrEmpty(masterSettings.WeixinPartnerKey) || string.IsNullOrEmpty(masterSettings.WeixinCertPath)) || string.IsNullOrEmpty(masterSettings.WeixinCertPassword)))
                {
                    return("系统微信发红包配置接口未配置好");
                }
                if (string.IsNullOrEmpty(re_openid))
                {
                    return("用户未绑定微信");
                }
                string        siteName = masterSettings.SiteName;
                string        str3     = masterSettings.SiteName;
                RedPackClient client   = new RedPackClient();
                return(client.SendRedpack(masterSettings.WeixinAppId, masterSettings.WeixinPartnerID, sub_mch_id, siteName, str3, re_openid, wishing, Globals.IPAddress, act_name, remark, amount, masterSettings.WeixinPartnerKey, masterSettings.WeixinCertPath, masterSettings.WeixinCertPassword, sendredpackrecordid));
            }
            return("管理员后台未开启微信付款!");
        }
Ejemplo n.º 2
0
        public string SendRedPack(string re_openid, string sub_mch_id, string wishing, string act_name, string remark, int amount, string RedpackId)
        {
            string       result         = string.Empty;
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);

            if (masterSettings.EnableWeiXinRequest)
            {
                System.DateTime now = System.DateTime.Now;
                System.DateTime t   = System.DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:01");
                System.DateTime t2  = System.DateTime.Parse(now.ToString("yyyy-MM-dd") + " 08:00:00");
                if (now > t && now < t2)
                {
                    result = "北京时间0:00-8:00不触发红包赠送";
                    return(result);
                }
                if (string.IsNullOrEmpty(masterSettings.WeixinAppId) || string.IsNullOrEmpty(masterSettings.WeixinPartnerID) || string.IsNullOrEmpty(masterSettings.WeixinPartnerKey) || string.IsNullOrEmpty(masterSettings.WeixinCertPath) || string.IsNullOrEmpty(masterSettings.WeixinCertPassword))
                {
                    result = "系统微信发红包配置接口未配置好";
                    return(result);
                }
                if (string.IsNullOrEmpty(re_openid))
                {
                    result = "用户未绑定微信";
                    return(result);
                }
                string        siteName      = masterSettings.SiteName;
                string        siteName2     = masterSettings.SiteName;
                RedPackClient redPackClient = new RedPackClient();
                try
                {
                    string text = Globals.IPAddress;
                    if (text.Length < 8)
                    {
                        text = "192.168.1.1";
                    }
                    result = redPackClient.SendRedpack(masterSettings.WeixinAppId, masterSettings.WeixinPartnerID, sub_mch_id, siteName, siteName2, re_openid, wishing, text, act_name, remark, amount, masterSettings.WeixinPartnerKey, masterSettings.WeixinCertPath, masterSettings.WeixinCertPassword, RedpackId, masterSettings.EnableSP, masterSettings.Main_AppId, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey);
                    return(result);
                }
                catch (System.Exception ex)
                {
                    result = ex.Message.ToString().Trim();
                    return(result);
                }
            }
            result = "管理员后台未开启微信付款!";
            return(result);
        }
Ejemplo n.º 3
0
        public string SendRedPack(string re_openid, string sub_mch_id, string wishing, string act_name, string remark, int amount, int sendredpackrecordid, bool isSend)
        {
            string       empty          = string.Empty;
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            if (!masterSettings.EnableWeiXinRequest)
            {
                empty = "管理员后台未开启微信付款!";
            }
            else
            {
                DateTime now       = DateTime.Now;
                DateTime dateTime  = DateTime.Parse(string.Concat(now.ToString("yyyy-MM-dd"), " 00:00:01"));
                DateTime dateTime1 = DateTime.Parse(string.Concat(now.ToString("yyyy-MM-dd"), " 08:00:00"));
                if (now > dateTime && now < dateTime1)
                {
                    empty = "北京时间0:00-8:00不触发红包赠送";
                }
                else if (string.IsNullOrEmpty(masterSettings.WeixinAppId) || string.IsNullOrEmpty(masterSettings.WeixinPartnerID) || string.IsNullOrEmpty(masterSettings.WeixinPartnerKey) || string.IsNullOrEmpty(masterSettings.WeixinCertPath) || string.IsNullOrEmpty(masterSettings.WeixinCertPassword))
                {
                    empty = "系统微信发红包配置接口未配置好";
                }
                else if (!string.IsNullOrEmpty(re_openid))
                {
                    if (!isSend)
                    {
                        string        siteName      = masterSettings.SiteName;
                        string        str           = masterSettings.SiteName;
                        RedPackClient redPackClient = new RedPackClient();
                        empty = redPackClient.SendRedpack(masterSettings.WeixinAppId, masterSettings.WeixinPartnerID, sub_mch_id, siteName, str, re_openid, wishing, Globals.IPAddress, act_name, remark, amount, masterSettings.WeixinPartnerKey, masterSettings.WeixinCertPath, masterSettings.WeixinCertPassword, sendredpackrecordid);
                    }
                    else
                    {
                        empty = "已经发送过,不能重复发送";
                    }
                }
                else
                {
                    empty = "用户未绑定微信";
                }
            }
            return(empty);
        }
Ejemplo n.º 4
0
        public string SendRedPack(string re_openid, string sub_mch_id, string wishing, string act_name, string remark, int amount, string sendredpackrecordid)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            if (masterSettings.EnableWeiXinRequest)
            {
                DateTime now   = DateTime.Now;
                DateTime time2 = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:01");
                DateTime time3 = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 08:00:00");
                if ((now > time2) && (now < time3))
                {
                    return("北京时间0:00-8:00不触发红包赠送");
                }
                if ((string.IsNullOrEmpty(masterSettings.WeixinAppId) || string.IsNullOrEmpty(masterSettings.WeixinPartnerID)) || ((string.IsNullOrEmpty(masterSettings.WeixinPartnerKey) || string.IsNullOrEmpty(masterSettings.WeixinCertPath)) || string.IsNullOrEmpty(masterSettings.WeixinCertPassword)))
                {
                    return("系统微信发红包配置接口未配置好");
                }
                if (string.IsNullOrEmpty(re_openid))
                {
                    return("用户未绑定微信");
                }
                string        siteName = masterSettings.SiteName;
                string        str3     = masterSettings.SiteName;
                RedPackClient client   = new RedPackClient();
                try
                {
                    string iPAddress = Globals.IPAddress;
                    if (iPAddress.Length < 8)
                    {
                        iPAddress = "192.168.1.1";
                    }
                    return(client.SendRedpack(masterSettings.WeixinAppId, masterSettings.WeixinPartnerID, sub_mch_id, siteName, str3, re_openid, wishing, iPAddress, act_name, remark, amount, masterSettings.WeixinPartnerKey, masterSettings.WeixinCertPath, masterSettings.WeixinCertPassword, sendredpackrecordid, masterSettings.EnableSP, masterSettings.Main_AppId, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey));
                }
                catch (Exception exception)
                {
                    return(exception.Message.ToString().Trim());
                }
            }
            return("管理员后台未开启微信付款!");
        }