/// <summary>
        /// 是否可以申请销售员
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <bool> > GetCanApplyMyShop()
        {
            CheckUserLogin();
            var             sitesettings       = SiteSettingApplication.SiteSettings;
            DistributorInfo currentDistributor = DistributionApplication.GetDistributor(CurrentUser.Id);

            if (sitesettings.DistributorApplyNeedQuota > 0)
            {
                var _u = MemberApplication.GetMember(CurrentUser.Id);
                if (_u.NetAmount < sitesettings.DistributorApplyNeedQuota)
                {
                    return(Json(ErrorResult <bool>("需要累计消费金额达到" + sitesettings.DistributorApplyNeedQuota + "元才可申请哦!")));
                }
            }
            if (currentDistributor != null)
            {
                if (currentDistributor.DistributionStatus == (int)DistributorStatus.NotAvailable)
                {
                    return(Json(ErrorResult <bool>("您己经被清退,不可以申请!")));
                }
                if (currentDistributor.DistributionStatus == (int)DistributorStatus.Audited)
                {
                    return(Json(ErrorResult <bool>("您己经是销售员,不可以重复申请!")));
                }
                if (currentDistributor.DistributionStatus == (int)DistributorStatus.UnAudit)
                {
                    return(Json(ErrorResult <bool>("您己经提交销售员申请,请耐心等待!")));
                }
            }
            return(JsonResult(true));
        }
Exemple #2
0
        public DistributorInfo GetDistributorInfo(TokenInfo tokenInfo, out string errorMessage)
        {
            DistributorInfo distributorInfo = default(DistributorInfo);

            errorMessage = "";
            //string url = repository.GetKeyValue(retailerInfoUrl);
            //string url = @"https://webservice.bevmedia.com/BMGOrderWebService/api/getRetailerInfo";
            var client  = new RestClient($"{this._baseUrl}/getDistributorInfo");
            var request = new RestRequest(Method.POST);

            request.AddHeader("TokenValue", tokenInfo.Token);
            request.AddHeader("DistributorId", tokenInfo.DistributorID);
            request.AddHeader("UserId", tokenInfo.UserID);
            IRestResponse response = client.Execute(request);

            try
            {
                distributorInfo = JsonConvert.DeserializeObject <DistributorInfo>(response.Content);
            }
            catch (Exception)
            {
                errorMessage = response.Content;
            }
            return(distributorInfo);
        }
        public async Task <IActionResult> PostDistributor([FromBody] UsersView distributor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Users users = new Users();

            users.FirstName = distributor.FirstName;
            users.LastName  = distributor.LastName;
            users.Email     = distributor.Email;
            users.Contact   = distributor.Contact;
            users.Address   = distributor.Address;
            users.Password  = "******";
            _context.Users.Add(users);

            Roles role    = new Roles();
            bool  isExist = _context.Roles.Any(obj => obj.Name == "Distributor");

            if (!isExist)
            {
                role.Name = "Distributor";
                _context.Roles.Add(role);
            }
            else if (isExist)
            {
                role = _context.Roles.Where(obj => obj.Name == "Distributor").FirstOrDefault();
            }

            await _context.SaveChangesAsync();

            DistributorInfo detail = new DistributorInfo();

            detail.DistributorId = users.Id;
            detail.City          = distributor.City;
            detail.Province      = distributor.Province;
            detail.PostalCode    = distributor.PostalCode;
            detail.Country       = distributor.Country;
            _context.DistributorDetail.Add(detail);

            Store store = new Store();

            store.UserId = users.Id;
            store.Name   = distributor.StoreName;
            _context.Store.Add(store);

            UserRoles userRole = new UserRoles();

            userRole.UserId = users.Id;
            userRole.RoleId = role.Id;
            _context.UserRoles.Add(userRole);
            await _context.SaveChangesAsync();

            return(Ok(new { AccountStatus = "RegisteredSuccess" }));
            //            return CreatedAtAction("GetUsers", new { id = users.Id }, users);
        }
        public JsonResult <Result <dynamic> > GetShopHeader(long distributorId)
        {
            DistributorInfo currentDistributor = DistributionApplication.GetDistributor(distributorId);
            dynamic         result             = new System.Dynamic.ExpandoObject();

            result.MemberId   = currentDistributor.MemberId;
            result.ShopLogo   = currentDistributor.ShopLogo;
            result.ShopName   = currentDistributor.ShopName;
            result.ShopLogo   = Himall.Core.HimallIO.GetRomoteImagePath(result.ShopLogo);
            result.IsShowLogo = currentDistributor.IsShowShopLogo;
            return(JsonResult <dynamic>(result));
        }
Exemple #5
0
        /// <summary>
        /// 小店设置
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="shopLogo"></param>
        /// <param name="shopName"></param>
        /// <returns></returns>
        public static void UpdateDistributorConfig(long memberId, string shopLogo, string shopName, bool isShowLogo)
        {
            DistributorInfo result = _iDistributionService.GetDistributor(memberId);

            if (result == null)
            {
                throw new MallException("错误的编号");
            }
            result.ShopLogo       = shopLogo;
            result.ShopName       = shopName;
            result.IsShowShopLogo = isShowLogo;
            _iDistributionService.UpdateDistributor(result);
        }
        /// <summary>
        /// 保存设置
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <bool> > PostSaveShopConfig(PostSaveShopConfigModel model)
        {
            CheckUserLogin();
            DistributorInfo currentDistributor = DistributionApplication.GetDistributor(CurrentUser.Id);

            if (string.IsNullOrWhiteSpace(currentDistributor.ShopLogo) && string.IsNullOrWhiteSpace(model.logoUrl))
            {
                return(Json(ErrorResult <bool>("请上传小店logo!")));
            }
            if (string.IsNullOrWhiteSpace(model.shopName))
            {
                return(Json(ErrorResult <bool>("请填写小店名称!")));
            }
            if (model.shopName.Length > 10)
            {
                return(Json(ErrorResult <bool>("小店名称不能超过10个字符!")));
            }
            string shoplogo = currentDistributor.ShopLogo;

            if (!string.IsNullOrWhiteSpace(model.logoUrl))
            {
                //shoplogo = DownloadWxImage(model.logoWXmediaId);
                shoplogo = model.logoUrl;
            }
            if (string.IsNullOrWhiteSpace(shoplogo))
            {
                return(Json(ErrorResult <bool>("请上传小店logo!")));
            }
            var    oldname  = Path.GetFileName(shoplogo);
            string ImageDir = string.Empty;

            if (!string.IsNullOrWhiteSpace(shoplogo))
            {
                //转移图片
                string relativeDir = DISTRIBUTOR_LOGO_PATH;
                Random ra          = new Random();
                string fileName    = DateTime.Now.ToString("yyyyMMddHHmmssffffff") + ra.Next(4) + ".jpg";
                if (shoplogo.Replace("\\", "/").Contains("/temp/"))//只有在临时目录中的图片才需要复制
                {
                    var de = shoplogo.Substring(shoplogo.LastIndexOf("/temp/"));
                    Core.HimallIO.CopyFile(de, relativeDir + fileName, true);
                    shoplogo = relativeDir + fileName;
                }  //目标地址
                else if (shoplogo.Contains("/Storage"))
                {
                    shoplogo = shoplogo.Substring(shoplogo.LastIndexOf("/Storage"));
                }
            }
            DistributionApplication.UpdateDistributorConfig(currentDistributor.MemberId, shoplogo, model.shopName, model.isShowLogo);
            return(JsonResult(true));
        }
        /// <summary>
        /// 获取分销员信息
        /// </summary>
        /// <param name="openId"></param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetDistributor()
        {
            CheckUserLogin();
            DistributorInfo currentDistributor = DistributionApplication.GetDistributor(CurrentUser.Id);

            return(JsonResult <dynamic>(new
            {
                DistributionIsEnable = SiteSettingApplication.SiteSettings.DistributionIsEnable,
                IsDistributor = currentDistributor != null,
                DistributionStatus = currentDistributor == null ? 0 : currentDistributor.DistributionStatus,
                IsOnlyMember = currentDistributor == null ? true : currentDistributor.IsOnlyMember,
                Remark = currentDistributor == null ? "" : currentDistributor.Remark
            }));
        }
Exemple #8
0
        /// <summary>
        /// 申请成为销售员
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="shopLogo"></param>
        /// <param name="shopName"></param>
        /// <returns></returns>
        public static DistributorInfo ApplyDistributor(long memberId, string shopLogo, string shopName)
        {
            DistributorInfo result = _iDistributionService.GetDistributor(memberId);
            bool            isadd  = false;

            if (result == null)
            {
                result = new DistributorInfo();
                isadd  = true;
                result.ProductCount     = 0;
                result.OrderCount       = 0;
                result.SettlementAmount = 0;
            }
            result.MemberId           = memberId;
            result.ShopLogo           = shopLogo;
            result.IsShowShopLogo     = true;
            result.ShopName           = shopName;
            result.ApplyTime          = DateTime.Now;
            result.DistributionStatus = (int)DistributorStatus.UnAudit;
            if (!SiteSettingApplication.SiteSettings.DistributorNeedAudit)
            {
                result.DistributionStatus = (int)DistributorStatus.Audited;
            }
            var gradeId = GetDistributorGrades().OrderByDescending(d => d.Quota).FirstOrDefault(d => d.Quota <= result.SettlementAmount)?.Id;

            result.GradeId = gradeId ?? 0;

            if (isadd)
            {
                _iDistributionService.AddDistributor(result);
            }
            else
            {
                _iDistributionService.UpdateDistributor(result);
            }
            var uobj = MemberApplication.GetMember(result.MemberId);

            //发送短信通知
            Task.Factory.StartNew(() =>
            {
                MessageApplication.SendMessageOnDistributorApply(result.MemberId, uobj.UserName);
                if (result.DistributionStatus == (int)DistributorStatus.Audited)
                {
                    MessageApplication.SendMessageOnDistributorAuditSuccess(result.MemberId, uobj.UserName);
                }
            });
            return(result);
        }
        /// <summary>
        /// 销售员申请
        /// </summary>
        /// <returns></returns>
        public ActionResult ApplyDistributor()
        {
            var result = CurrentDistributor;

            if (result == null)
            {
                result          = new DistributorInfo();
                result.MemberId = CurrentUser.Id;
            }
            if (string.IsNullOrWhiteSpace(result.ShopLogo))
            {
                result.ShopLogo = CurrentUser.Photo;
            }
            ViewBag.Title = "提交申请";
            return(View(result));
        }
        /// <summary>
        /// 下载微信图片
        /// </summary>
        /// <param name="link">下载地址</param>
        /// <param name="filePath">保存相对路径</param>
        /// <param name="fileName">保存地址</param>
        /// <returns></returns>
        //public string DownloadWxImage(string mediaId)
        //{
        //    var sitesettings = SiteSettingApplication.SiteSettings;
        //    var token = AccessTokenContainer.TryGetToken(sitesettings.WeixinAppId, sitesettings.WeixinAppSecret);
        //    var address = string.Format("https://file.api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}", token, mediaId);
        //    Random ra = new Random();
        //    var fileName = DateTime.Now.ToString("yyyyMMddHHmmssffffff") + ra.Next(4) + ".jpg";
        //    var ImageDir = DISTRIBUTOR_LOGO_PATH;
        //    WebClient wc = new WebClient();
        //    try
        //    {
        //        string fullPath = Path.Combine(ImageDir, fileName);
        //        ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
        //        var data = wc.DownloadData(address);
        //        MemoryStream stream = new MemoryStream(data);
        //        Core.HimallIO.CreateFile(fullPath, stream, FileCreateType.Create);
        //        return DISTRIBUTOR_LOGO_PATH + fileName;
        //    }
        //    catch (Exception ex)
        //    {
        //        Log.Error("下载图片发生异常" + ex.Message);
        //        return string.Empty;
        //    }
        //}
        //public bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        //{  // 总是接受
        //    return true;
        //}


        /// <summary>
        /// 我的小店
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetMyShop()
        {
            CheckUserLogin();
            var             sitesettings       = SiteSettingApplication.SiteSettings;
            DistributorInfo currentDistributor = DistributionApplication.GetDistributor(CurrentUser.Id);
            dynamic         result             = new System.Dynamic.ExpandoObject();

            result.MemberId         = currentDistributor.MemberId;
            result.ShopLogo         = currentDistributor.ShopLogo;
            result.ShopName         = currentDistributor.ShopName;
            result.IsShowLogo       = currentDistributor.IsShowShopLogo;
            result.GradeName        = currentDistributor.GradeName;
            result.SettlementAmount = currentDistributor.SettlementAmount;
            result.Balance          = currentDistributor.Balance;
            if (string.IsNullOrWhiteSpace(currentDistributor.ShopLogo))
            {
                result.ShopLogo = CurrentUser.Photo;
            }
            result.ShopLogo = Himall.Core.HimallIO.GetRomoteImagePath(result.ShopLogo);
            var grades    = DistributionApplication.GetDistributorGrades();
            var nextgrade = grades.Where(d => d.Quota > result.SettlementAmount).OrderBy(d => d.Quota).FirstOrDefault();

            if (nextgrade != null)
            {
                result.NextGradeName     = nextgrade.GradeName;
                result.UpgradeNeedAmount = nextgrade.Quota - result.SettlementAmount;
            }
            result.NoSettlementAmount             = DistributionApplication.GetNoSettlementAmount(currentDistributor.MemberId);
            result.DistributorRenameSpreadShop    = sitesettings.DistributorRenameSpreadShop;    //推广小店
            result.DistributorRenameBrokerage     = sitesettings.DistributorRenameBrokerage;     //佣金
            result.DistributorRenameMarket        = sitesettings.DistributorRenameMarket;        //分销市场
            result.DistributorRenameShopOrder     = sitesettings.DistributorRenameShopOrder;     //小店订单
            result.DistributorRenameMyBrokerage   = sitesettings.DistributorRenameMyBrokerage;   //我的佣金
            result.DistributorRenameMySubordinate = sitesettings.DistributorRenameMySubordinate; //我的下级
            result.DistributorRenameShopConfig    = sitesettings.DistributorRenameShopConfig;    //小店设置

            return(JsonResult <dynamic>(result));
        }
        /// <summary>
        /// 个人中心主页
        /// </summary>
        /// <returns></returns>
        public new JsonResult <Result <dynamic> > GetUser()
        {
            CheckUserLogin();
            dynamic         d                  = new System.Dynamic.ExpandoObject();
            long            id                 = CurrentUser.Id;
            var             member             = MemberApplication.GetMember(id);
            DistributorInfo currentDistributor = DistributionApplication.GetDistributor(member.Id);

            d.UserName  = member.UserName;                                                                     //用户名
            d.RealName  = member.RealName;                                                                     //真实姓名
            d.Nick      = member.Nick;                                                                         //昵称
            d.UserId    = member.Id.ToString();
            d.CellPhone = member.CellPhone;                                                                    //绑定的手机号码
            d.Photo     = String.IsNullOrEmpty(member.Photo) ? "" : HimallIO.GetRomoteImagePath(member.Photo); //头像

            var statistic = StatisticApplication.GetMemberOrderStatistic(id, true);

            d.AllOrders          = statistic.OrderCount;
            d.WaitingForPay      = statistic.WaitingForPay;
            d.WaitingForRecieve  = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(id);
            d.WaitingForDelivery = statistic.WaitingForDelivery;
            d.WaitingForComments = statistic.WaitingForComments;
            d.RefundOrders       = statistic.RefundCount;

            d.FavoriteShop    = ShopApplication.GetUserConcernShopsCount(member.Id);   //收藏的店铺数
            d.FavoriteProduct = FavoriteApplication.GetFavoriteCountByUser(member.Id); //收藏的商品数

            d.Counpon = MemberApplication.GetAvailableCouponCount(id);

            d.Integral = MemberIntegralApplication.GetAvailableIntegral(member.Id); //我的积分
            d.Balance  = MemberCapitalApplication.GetBalanceByUserId(member.Id);    //我的资产
            d.IsOpenRechargePresent = SiteSettingApplication.SiteSettings.IsOpenRechargePresent;
            var phone = SiteSettingApplication.SiteSettings.SitePhone;

            d.ServicePhone  = string.IsNullOrEmpty(phone) ? "" : phone;
            d.IsDistributor = (currentDistributor != null && currentDistributor.DistributionStatus == (int)DistributorStatus.Audited);
            return(JsonResult <dynamic>(d));
        }
Exemple #12
0
        /// <summary>
        /// 获取配置参数
        /// </summary>
        private void GetConfigPara()
        {
            PathOfSource = ConfigHelper.GetConfig("PathOfSource");

            //IP地址
            //string sIPAddress = ConfigHelper.GetConfig("IPAddress");

            ipMask = ConfigHelper.GetConfig("IPMask");
            string sIPAddress = GetLocalIPAddress(ipMask);
            if (IPAddress.TryParse(sIPAddress, out localAddress) == false)
            {
                throw new Exception("IP地址配置错误,必须为一个合法的IP地址!");
            }

            //最大连接数
            string sMaxConnection = ConfigHelper.GetConfig("MaxConnections");
            if (int.TryParse(sMaxConnection, out maxConnections) == false)
            {
                throw new Exception("最大连接数配置错误,必须为一个正整数!");
            }

            //缓冲区大小
            string sBufferSize = ConfigHelper.GetConfig("BufferSize");
            if (int.TryParse(sBufferSize, out bufferSize) == false)
            {
                throw new Exception("缓冲区大小配置错误,必须为一个正整数!");
            }

            string udpportbyweb = ConfigHelper.GetConfig("UdpPortByWeb");
            if (int.TryParse(udpportbyweb, out udpPortByWeb) == false)
            {
                throw new Exception("UDP端口号配置错误,必须为一个合法的监听端口号!");
            }

            string sMaxSendPacket = ConfigHelper.GetConfig("MaxSendPacket");
            if (int.TryParse(sMaxSendPacket, out maxSendPacket) == false)
            {
                throw new Exception("最大发送数据包数量配置错误,必须为一个大于零的数字!");
            }


            string sGwBussIPAddress = ConfigHelper.GetConfig("GwBussIPAddress");
            if (IPAddress.TryParse(sGwBussIPAddress, out GwBussIPAddress) == false)
            {
                throw new Exception("网关应用IP地址配置错误,必须为一个合法的IP地址!");
            }

            string sGwBussUdpPort = ConfigHelper.GetConfig("GwBussUdpPort");
            if (int.TryParse(sGwBussUdpPort, out GwBussUdpPort) == false)
            {
                throw new Exception("网关应用端口号配置错误,必须为一个合法的监听端口号!");
            }

            sServersConfig = ConfigHelper.GetConfig("ServersConfig");
            if (sServersConfig == null || sServersConfig == "")
            {
                throw new Exception("请配置服务器信息");
            }

            //0:210.21.243.157:6666;1:192.138.25.36:5555
            string strDistributor = ConfigHelper.GetConfig("Distributor");
            if (!string.IsNullOrEmpty(strDistributor))
            {
                lstDistributor = new List<DistributorInfo>();
                string[] servers = strDistributor.Split(';');
                for (int i = 0; i < servers.Length; i++)
                {
                    DistributorInfo DIServer = new DistributorInfo(servers[i]);
                    lstDistributor.Add(DIServer);
                }
            }

            string strbol = ConfigHelper.GetConfig("GPSHexDataLogging").ToLower();
            if (strbol == "false" || strbol == "true")
                GPSHexDataLogging = bool.Parse(ConfigHelper.GetConfig("GPSHexDataLogging"));

        }
        public IActionResult GetDistributorView(string token)
        {
            string          baseUrl         = repository.GetKeyValue("BMGBaseUrl");// "https://webservice.bevmedia.com/BMGOrderWebService/api";
            ErrorModel      errorModel      = new ErrorModel();
            BevMediaService bevMediaService = new BevMediaService(baseUrl);
            TokenInfo       tokenInfo       = bevMediaService.VerifyToken(token, out var err);

            if (string.IsNullOrWhiteSpace(err))
            {
                DistributorInfo distributor = bevMediaService.GetDistributorInfo(tokenInfo, out var errMsg);
                //RetailerInfo distributor = bevMediaService.GetRetailerInfo(tokenInfo, out var errMsg);
                if (string.IsNullOrWhiteSpace(errMsg))
                {
                    var creditDataList = _context.CreditData
                                         .Where(x => x.DistributorId == tokenInfo.DistributorID)
                                         .Include(files => files.CreditDataFiles)
                                         .ToList();
                    var ws = new AdobeSignWS();
                    foreach (var creditDataEntity in creditDataList)
                    {
                        if (creditDataEntity.Status == CreditAppStatusEnum.OUT_FOR_SIGNATURE.ToString())
                        {
                            var agreement = ws.GetAgreement(creditDataEntity.AdobeSignAgreementId, creditDataEntity.Id.Value);
                            if (agreement.status != creditDataEntity.Status)
                            {
                                creditDataEntity.Status = agreement.status;
                                _context.SaveChanges();
                            }
                        }
                    }
                    var           creditDataListModel = _mapper.Map <List <CreditData> >(creditDataList);
                    List <string> acceptedStatuses    = new List <string> {
                        CreditAppStatusEnum.OUT_FOR_SIGNATURE.ToString(),
                                  CreditAppStatusEnum.SIGNED.ToString(),
                                  CreditAppStatusEnum.APPROVED.ToString(),
                                  CreditAppStatusEnum.DENIED.ToString(),
                    };
                    List <string> editStatuses = new List <string> {
                        CreditAppStatusEnum.SIGNED.ToString(),
                                  CreditAppStatusEnum.APPROVED.ToString(),
                                  CreditAppStatusEnum.DENIED.ToString(),
                    };
                    foreach (var item in creditDataListModel)
                    {
                        if (acceptedStatuses.Contains(item.Status))
                        {
                            item.DistributorStatus = item.Status;
                        }
                        else
                        {
                            item.DistributorStatus = CreditAppStatusEnum.IN_PROGRESS.ToString();
                        }
                        if (editStatuses.Contains(item.Status))
                        {
                            item.CanAddComments = true;
                        }
                    }
                    var distributorViewModel = new DistributorViewModel();
                    distributorViewModel.CreditDataList = creditDataListModel;

                    distributorViewModel.Distributor = new Distributor();
                    distributorViewModel.Distributor.DistributorLogoURL = distributor.DistributorLogoURL;
                    distributorViewModel.Distributor.DistributorName    = distributor.DistributorName;

                    return(View("DistributorView", distributorViewModel));
                }
                else
                {
                    errorModel.Message = errMsg;
                }
            }
            else
            {
                errorModel.Message = err;
            }
            return(View("ErrorView", errorModel));
        }
        private void distributorInformationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DistributorInfo distributorInfo = new DistributorInfo();

            distributorInfo.Show();
        }
        /// <summary>
        /// 提交申请销售员
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <bool> > PostApplyDistributor(PostSaveShopConfigModel model)
        {
            CheckUserLogin();
            var             sitesettings       = SiteSettingApplication.SiteSettings;
            DistributorInfo currentDistributor = DistributionApplication.GetDistributor(CurrentUser.Id);

            if (sitesettings.DistributorApplyNeedQuota > 0)
            {
                var _u = MemberApplication.GetMember(CurrentUser.Id);
                if (_u.NetAmount < sitesettings.DistributorApplyNeedQuota)
                {
                    return(Json(ErrorResult <bool>("需要累计消费金额达到" + sitesettings.DistributorApplyNeedQuota + "元才可申请哦!")));
                }
            }
            if (currentDistributor == null)
            {
                currentDistributor = new DistributorInfo
                {
                    MemberId = CurrentUser.Id
                };
            }
            if (string.IsNullOrWhiteSpace(currentDistributor.ShopLogo))
            {
                currentDistributor.ShopLogo = CurrentUser.Photo;
            }
            if (string.IsNullOrWhiteSpace(model.logoUrl))
            {
                if (currentDistributor == null || string.IsNullOrWhiteSpace(currentDistributor.ShopLogo))
                {
                    return(Json(ErrorResult <bool>("请上传小店logo!")));
                }
            }
            if (string.IsNullOrWhiteSpace(model.shopName))
            {
                return(Json(ErrorResult <bool>("请填写小店名称!")));
            }
            if (model.shopName.Length > 10)
            {
                return(Json(ErrorResult <bool>("小店名称不能超过10个字符!")));
            }
            if (currentDistributor != null)
            {
                if (currentDistributor.DistributionStatus == (int)DistributorStatus.NotAvailable)
                {
                    return(Json(ErrorResult <bool>("您己经被清退,不可以申请!")));
                }
                if (currentDistributor.DistributionStatus == (int)DistributorStatus.Audited)
                {
                    return(Json(ErrorResult <bool>("您己经是销售员,不可以重复申请!")));
                }
                if (currentDistributor.DistributionStatus == (int)DistributorStatus.UnAudit)
                {
                    return(Json(ErrorResult <bool>("您己经提交销售员申请,请耐心等待!")));
                }
            }

            string shoplogo = currentDistributor != null ? currentDistributor.ShopLogo : "";

            if (!string.IsNullOrWhiteSpace(model.logoUrl))
            {
                //shoplogo = DownloadWxImage(model.logoWXmediaId);
                shoplogo = model.logoUrl;
            }
            if (string.IsNullOrWhiteSpace(shoplogo))
            {
                return(Json(ErrorResult <bool>("请上传小店logo!")));
            }
            var    oldname  = Path.GetFileName(shoplogo);
            string ImageDir = string.Empty;

            if (!string.IsNullOrWhiteSpace(shoplogo))
            {
                //转移图片
                string relativeDir = DISTRIBUTOR_LOGO_PATH;
                Random ra          = new Random();
                string fileName    = DateTime.Now.ToString("yyyyMMddHHmmssffffff") + ra.Next(4) + ".jpg";
                if (shoplogo.Replace("\\", "/").Contains("/temp/"))//只有在临时目录中的图片才需要复制
                {
                    var de = shoplogo.Substring(shoplogo.LastIndexOf("/temp/"));
                    Core.HimallIO.CopyFile(de, relativeDir + fileName, true);
                    shoplogo = relativeDir + fileName;
                }  //目标地址
                else if (shoplogo.Contains("/Storage"))
                {
                    shoplogo = shoplogo.Substring(shoplogo.LastIndexOf("/Storage"));
                }
            }
            var d = DistributionApplication.ApplyDistributor(CurrentUser.Id, shoplogo, model.shopName);

            if (d == null)
            {
                return(Json(ErrorResult <bool>("申请失败,系统异常!")));
            }
            if (d.DistributionStatus == (int)DistributorStatus.Audited)
            {
                return(JsonResult(true, "申请销售员成功!"));
            }
            return(JsonResult(true, "提交销售员申请成功!"));
        }
        /// <summary>
        /// 前置处理
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            if (CurrentUser == null)
            {
                return;
            }
            CurrentDistributor = DistributionApplication.GetDistributor(CurrentUser.Id);
            string actionName = filterContext.RouteData.Values["action"].ToString().ToLower();

            if (!WebHelper.IsAjax())
            {
                if (actionName.IndexOf("tips") > -1)
                {
                    return;
                }
                if (!SiteSettings.DistributionIsEnable)
                {
                    Response.Clear();
                    // Response.BufferOutput = true;
                    Response.Redirect(Url.Action("TipsClose"));
                    //Response.Redirect(Url.Action("Center", "Member"));
                }

                if (PlatformType != PlatformType.WeiXin)
                {
                    Response.Clear();
                    // Response.BufferOutput = true;
                    Response.Redirect(Url.Action("TipsNoWeiXin"));
                }

                //处理其他统一情况
                if ((CurrentDistributor == null || CurrentDistributor.IsOnlyMember) && (actionName != "openmyshop" && actionName != "applydistributor"))
                {
                    Response.Clear();
                    //  Response.BufferOutput = true;
                    Response.Redirect(Url.Action("OpenMyShop"));
                }
                if (CurrentDistributor != null && (actionName != "openmyshop" && actionName != "applydistributor"))
                {
                    if (CurrentDistributor.DistributionStatus == (int)DistributorStatus.NotAvailable)
                    {
                        Response.Clear();
                        // Response.BufferOutput = true;
                        Response.Redirect(Url.Action("TipsNotAvailable"));
                    }
                    if (CurrentDistributor.DistributionStatus == (int)DistributorStatus.Refused)
                    {
                        Response.Clear();
                        // Response.BufferOutput = true;
                        Response.Redirect(Url.Action("TipsRefused"));
                    }
                    if (CurrentDistributor.DistributionStatus == (int)DistributorStatus.UnAudit)
                    {
                        Response.Clear();
                        //    Response.BufferOutput = true;
                        Response.Redirect(Url.Action("TipsUnAudit"));
                    }
                }
            }
        }
        /// <summary>
        /// 提交申请销售员
        /// </summary>
        /// <returns></returns>
        public JsonResult PostApplyDistributor(string logoWXmediaId, string shopname)
        {
            if (SiteSettings.DistributorApplyNeedQuota > 0)
            {
                var _u = MemberApplication.GetMember(CurrentUser.Id);
                if (_u.NetAmount < SiteSettings.DistributorApplyNeedQuota)
                {
                    throw new MallException("需要累计消费金额达到" + SiteSettings.DistributorApplyNeedQuota + "元才可申请哦");
                }
            }
            if (CurrentDistributor == null)
            {
                CurrentDistributor = new DistributorInfo
                {
                    MemberId = CurrentUser.Id
                };
            }
            if (string.IsNullOrWhiteSpace(CurrentDistributor.ShopLogo))
            {
                CurrentDistributor.ShopLogo = CurrentUser.Photo;
            }
            if (string.IsNullOrWhiteSpace(logoWXmediaId))
            {
                if (CurrentDistributor == null || string.IsNullOrWhiteSpace(CurrentDistributor.ShopLogo))
                {
                    throw new MallException("请上传小店logo");
                }
            }
            if (string.IsNullOrWhiteSpace(shopname))
            {
                throw new MallException("请填写小店名称");
            }
            if (shopname.Length > 10)
            {
                throw new MallException("小店名称不能超过10个字符");
            }
            if (CurrentDistributor != null)
            {
                if (CurrentDistributor.DistributionStatus == (int)DistributorStatus.NotAvailable)
                {
                    return(Json(new Result {
                        success = true, msg = "您己经被清退,不可以申请!", code = 12
                    }));
                }
                if (CurrentDistributor.DistributionStatus == (int)DistributorStatus.Audited)
                {
                    return(Json(new Result {
                        success = true, msg = "您己经是销售员,不可以重复申请!", code = 11
                    }));
                }
                if (CurrentDistributor.DistributionStatus == (int)DistributorStatus.UnAudit)
                {
                    return(Json(new Result {
                        success = true, msg = "您己经提交销售员申请,请耐心等待!", code = 13
                    }));
                }
            }

            string shoplogo = CurrentDistributor != null ? CurrentDistributor.ShopLogo : "";

            if (!string.IsNullOrWhiteSpace(logoWXmediaId))
            {
                shoplogo = DownloadWxImage(logoWXmediaId);
            }
            if (string.IsNullOrWhiteSpace(shoplogo))
            {
                throw new MallException("请上传小店logo");
            }
            var    oldname  = Path.GetFileName(shoplogo);
            string ImageDir = string.Empty;

            if (!string.IsNullOrWhiteSpace(shoplogo))
            {
                //转移图片
                string relativeDir = DISTRIBUTOR_LOGO_PATH;
                Random ra          = new Random();
                string fileName    = DateTime.Now.ToString("yyyyMMddHHmmssffffff") + ra.Next(4) + ".jpg";
                if (shoplogo.Replace("\\", "/").Contains("/temp/"))//只有在临时目录中的图片才需要复制
                {
                    var de = shoplogo.Substring(shoplogo.LastIndexOf("/temp/"));
                    Core.MallIO.CopyFile(de, relativeDir + fileName, true);
                    shoplogo = relativeDir + fileName;
                }  //目标地址
                else if (shoplogo.Contains("/Storage"))
                {
                    shoplogo = shoplogo.Substring(shoplogo.LastIndexOf("/Storage"));
                }
            }

            var d = DistributionApplication.ApplyDistributor(CurrentUser.Id, shoplogo, shopname);

            if (d == null)
            {
                return(Json(new Result {
                    success = false, msg = "申请失败,系统异常!", code = 41
                }));
            }
            if (d.DistributionStatus == (int)DistributorStatus.Audited)
            {
                return(Json(new Result {
                    success = true, msg = "申请销售员成功!"
                }));
            }
            return(Json(new Result {
                success = true, msg = "提交销售员申请成功!", code = 21
            }));
        }
Exemple #18
0
        /// <summary>
        /// 获取配置参数
        /// </summary>
        private void GetConfigPara()
        {
            GpsCodesOfSource = ConfigHelper.GetConfig("GpsCodesOfSource");
            PathOfSource = ConfigHelper.GetConfig("PathOfSource");
            
            //IP地址
            //string sIPAddress = ConfigHelper.GetConfig("IPAddress");
            
            ipMask = ConfigHelper.GetConfig("IPMask");
            string sIPAddress = GetLocalIPAddress(ipMask); 
            if (IPAddress.TryParse(sIPAddress, out localAddress) == false)
            {
                throw new Exception("IP地址配置错误,必须为一个合法的IP地址!");
            }

            //TCP监听端口号
            string sTcpPort = ConfigHelper.GetConfig("TcpPort");
            if (int.TryParse(sTcpPort, out tcpPort) == false)
            {
                throw new Exception("TCP端口号配置错误,必须为一个合法的监听端口号!");
            }

            //最大连接数
            string sMaxConnection = ConfigHelper.GetConfig("MaxConnections");
            if (int.TryParse(sMaxConnection, out maxConnections) == false)
            {
                throw new Exception("最大连接数配置错误,必须为一个正整数!");
            }

            //缓冲区大小
            string sBufferSize = ConfigHelper.GetConfig("BufferSize");
            if (int.TryParse(sBufferSize, out bufferSize) == false)
            {
                throw new Exception("缓冲区大小配置错误,必须为一个正整数!");
            }

            string udpportbyweb = ConfigHelper.GetConfig("UdpPortByWeb");
            if (int.TryParse(udpportbyweb, out udpPortByWeb) == false)
            {
                throw new Exception("UDP端口号配置错误,必须为一个合法的监听端口号!");
            }

            string sudpportbygps = ConfigHelper.GetConfig("UdpPortByGps");
            if (int.TryParse(sudpportbygps, out udpPortByGps) == false)
            {
                throw new Exception("UDP端口号配置错误,必须为一个合法的监听端口号!");
            }

            ProtocolType = ConfigHelper.GetConfig("ProtocolType");
            ProtocolType = ProtocolType.Trim();

            string sMaxSendPacket = ConfigHelper.GetConfig("MaxSendPacket");
            if (int.TryParse(sMaxSendPacket, out maxSendPacket) == false)
            {
                throw new Exception("最大发送数据包数量配置错误,必须为一个大于零的数字!");
            }

            if (ProtocolType != "TCP" && ProtocolType != "UDP" && ProtocolType != "TCP|UDP")
            {
                throw new Exception("协议类型错误,请查看配置");
            }

            //0:210.21.243.157:6666;1:192.138.25.36:5555
            string strDistributor = ConfigHelper.GetConfig("Distributor");
            if (!string.IsNullOrEmpty(strDistributor))
            {
                lstDistributor = new List<DistributorInfo>();
                string[] servers = strDistributor.Split(';');
                for (int i = 0; i < servers.Length; i++)
                {
                    DistributorInfo DIServer = new DistributorInfo(servers[i]);
                    lstDistributor.Add(DIServer);
                }
            }

            gpsType = ConfigHelper.GetConfig("GpsType");

            string strbol = ConfigHelper.GetConfig("IsPrivateCar").ToLower();
            if (strbol == "false" || strbol == "true")
                IsPrivateCar = bool.Parse(ConfigHelper.GetConfig("IsPrivateCar"));

            strbol = ConfigHelper.GetConfig("GPSHexDataLogging").ToLower();
            if (strbol == "false" || strbol == "true")
                GPSHexDataLogging = bool.Parse(ConfigHelper.GetConfig("GPSHexDataLogging"));

            translationType = ConfigHelper.GetConfig("TranslationType");
            translationType = translationType.Trim(); 
            translationType = translationType.ToLower(); 
        }