예제 #1
0
        public string CreateCustomer(DonationFormModel model)
        {
            Address address                   = new Address(model.StreetAddress1, model.StreetAddress2, null, model.City, null, null, null, model.State, null, null, model.ZipCode, null, model.FirstName, model.LastName, null);
            CreateCustomerRequest body        = new CreateCustomerRequest(model.FirstName, model.LastName, null, null, model.Email, address, model.Phone, null, null);
            CustomerApi           customerAPI = new CustomerApi();
            var response = customerAPI.CreateCustomer(squareAuthorization, body);

            return(response.Customer.Id);
        }
예제 #2
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int num = 0;

            int.TryParse(context.Request["id"].ToString(), out num);
            CustomerServiceSettings masterSettings = CustomerServiceManager.GetMasterSettings(false);
            string unit       = masterSettings.unit;
            string text       = context.Request["userver"].ToString();
            string password   = context.Request["password"].ToString();
            string text2      = context.Request["nickname"].ToString();
            string value      = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            string tokenValue = TokenApi.GetTokenValue(masterSettings.AppId, masterSettings.AppSecret);

            if (string.IsNullOrEmpty(tokenValue))
            {
                context.Response.Write("{\"type\":\"error\",\"data\":\"获取access_token失败!\"}");
                return;
            }
            System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
            dictionary.Add("unit", unit);
            dictionary.Add("userver", text);
            dictionary.Add("password", value);
            dictionary.Add("nickname", text2);
            dictionary.Add("realname", "");
            dictionary.Add("level", "");
            dictionary.Add("tel", "");
            string empty = string.Empty;
            CustomerServiceInfo customerServiceInfo = new CustomerServiceInfo();

            if (num != 0)
            {
                string text3 = CustomerApi.UpdateCustomer(tokenValue, dictionary);
                if (string.IsNullOrWhiteSpace(text3))
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"修改客服信息失败!\"}");
                    return;
                }
                string jsonValue  = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text3, "errcode");
                string jsonValue2 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text3, "errmsg");
                if (!(jsonValue == "0"))
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"" + jsonValue2 + "\"}");
                    return;
                }
                customerServiceInfo          = CustomerServiceHelper.GetCustomer(num);
                customerServiceInfo.unit     = unit;
                customerServiceInfo.userver  = text;
                customerServiceInfo.password = password;
                customerServiceInfo.nickname = text2;
                bool flag = CustomerServiceHelper.UpdateCustomer(customerServiceInfo, ref empty);
                if (flag)
                {
                    context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                    return;
                }
                context.Response.Write("{\"type\":\"error\",\"data\":\"" + empty + "\"}");
                return;
            }
            else
            {
                string text4 = CustomerApi.CreateCustomer(tokenValue, dictionary);
                if (string.IsNullOrWhiteSpace(text4))
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"注册客服用户失败!\"}");
                    return;
                }
                string jsonValue3 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text4, "errcode");
                string jsonValue4 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text4, "errmsg");
                if (!(jsonValue3 == "0"))
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"" + jsonValue4 + "\"}");
                    return;
                }
                customerServiceInfo.unit     = unit;
                customerServiceInfo.userver  = text;
                customerServiceInfo.password = password;
                customerServiceInfo.nickname = text2;
                int num2 = CustomerServiceHelper.CreateCustomer(customerServiceInfo, ref empty);
                if (num2 > 0)
                {
                    context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                    return;
                }
                context.Response.Write("{\"type\":\"error\",\"data\":\"" + empty + "\"}");
                return;
            }
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (Globals.GetCurrentManagerUserId() <= 0)
            {
                context.Response.Write("{\"type\":\"error\",\"data\":\"请先登录\"}");
                context.Response.End();
            }
            int result = 0;

            int.TryParse(context.Request["id"].ToString(), out result);
            CustomerServiceSettings masterSettings = CustomerServiceManager.GetMasterSettings(false);
            string unit       = masterSettings.unit;
            string str2       = context.Request["userver"].ToString();
            string password   = context.Request["password"].ToString();
            string str4       = context.Request["nickname"].ToString();
            string str5       = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            string tokenValue = TokenApi.GetTokenValue(masterSettings.AppId, masterSettings.AppSecret);

            if (!string.IsNullOrEmpty(tokenValue))
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("unit", unit);
                parameters.Add("userver", str2);
                parameters.Add("password", str5);
                parameters.Add("nickname", str4);
                parameters.Add("realname", "");
                parameters.Add("level", "");
                parameters.Add("tel", "");
                string msg = string.Empty;
                CustomerServiceInfo customer = new CustomerServiceInfo();
                if (result != 0)
                {
                    string str8 = CustomerApi.UpdateCustomer(tokenValue, parameters);
                    if (!string.IsNullOrWhiteSpace(str8))
                    {
                        string jsonValue = Hishop.MeiQia.Api.Util.Common.GetJsonValue(str8, "errcode");
                        string str10     = Hishop.MeiQia.Api.Util.Common.GetJsonValue(str8, "errmsg");
                        if (jsonValue == "0")
                        {
                            customer          = CustomerServiceHelper.GetCustomer(result);
                            customer.unit     = unit;
                            customer.userver  = str2;
                            customer.password = password;
                            customer.nickname = str4;
                            if (CustomerServiceHelper.UpdateCustomer(customer, ref msg))
                            {
                                context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"type\":\"error\",\"data\":\"" + msg + "\"}");
                            }
                        }
                        else
                        {
                            context.Response.Write("{\"type\":\"error\",\"data\":\"" + str10 + "\"}");
                        }
                    }
                    else
                    {
                        context.Response.Write("{\"type\":\"error\",\"data\":\"修改客服信息失败!\"}");
                    }
                }
                else
                {
                    string str11 = CustomerApi.CreateCustomer(tokenValue, parameters);
                    if (!string.IsNullOrWhiteSpace(str11))
                    {
                        string str12 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(str11, "errcode");
                        string str13 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(str11, "errmsg");
                        if (str12 == "0")
                        {
                            customer.unit     = unit;
                            customer.userver  = str2;
                            customer.password = password;
                            customer.nickname = str4;
                            if (CustomerServiceHelper.CreateCustomer(customer, ref msg) > 0)
                            {
                                context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"type\":\"error\",\"data\":\"" + msg + "\"}");
                            }
                        }
                        else
                        {
                            context.Response.Write("{\"type\":\"error\",\"data\":\"" + str13 + "\"}");
                        }
                    }
                    else
                    {
                        context.Response.Write("{\"type\":\"error\",\"data\":\"注册客服用户失败!\"}");
                    }
                }
            }
            else
            {
                context.Response.Write("{\"type\":\"error\",\"data\":\"获取access_token失败!\"}");
            }
        }