Example #1
0
        /// <summary>
        /// 检测邀请人
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public string CheckBaseUserIdByMobile(string mobile = "")
        {
            if (!ITOrm.Utility.StringHelper.TypeParse.IsMobile(mobile))
            {
                return(ApiReturnStr.getError(-100, "邀请人手机号格式验证失败"));
            }

            var model = userDao.Single(" mobile=@mobile ", new { mobile });

            if (model != null && model.UserId > 0 && model.IsRealState == 0)
            {
                return(ApiReturnStr.getError(-1, "该邀请人还未通过实名认证"));
            }
            if (model != null && model.UserId > 0)
            {
                JObject data = new JObject();
                data["mobile"]   = mobile;
                data["RealName"] = Util.GetHiddenString(model.RealName, 0, model.RealName.Length - 1);
                data["UserId"]   = model.UserId;
                return(ApiReturnStr.getApiData(data));
            }
            else
            {
                return(ApiReturnStr.getError(-1, "邀请码错误"));
            }
        }
Example #2
0
        /// <summary>
        /// 分享
        /// </summary>
        /// <param name="cid"></param>
        /// <param name="UserId"></param>
        /// <param name="Soure"></param>
        /// <returns></returns>
        public string Share(int cid, int UserId, int Soure, string version)
        {
            string url = Constant.CurrentApiHost + "itapi/invite/reg?u=" + ITOrm.Utility.Encryption.AESEncrypter.AESEncrypt(UserId.ToString(), Constant.SystemAESKey);

            UserShare us = new UserShare();

            us.Title    = "速金派邀请您一起刷卡赚收益";
            us.ShareUrl = url;
            us.ImageUrl = Constant.StaticHost + "upload/icon/logo.png";
            us.Context  = "速金派,移动刷卡神器。价格低,秒到账,邀请好友享收益。";
            us.Platform = cid;
            us.Ip       = Ip.GetClientIp();
            us.Soure    = Soure;
            us.UserId   = UserId;
            int     num  = userShareDao.Insert(us);
            JObject data = new JObject();

            data["Title"]    = us.Title;
            data["ShareUrl"] = us.ShareUrl;
            data["ImageUrl"] = us.ImageUrl;
            data["Context"]  = us.Context;
            //用户事件
            userEventDao.UserEventInit(cid, UserId, Ip.GetClientIp(), num > 0 ? 1 : 0, "Profit", "Share", $"{{UserId:{UserId},Soure:{Soure},num:{num},version:{version}}}");


            return(ApiReturnStr.getApiData(data));
        }
Example #3
0
        public string PayFeeTool(int UserId = 0, decimal Amount = 0M, int PayType = 0)
        {
            if (UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "用户ID不能为0"));
            }
            if (Amount < 500M)
            {
                return(ApiReturnStr.getError(-100, "支付金额不能小于500"));
            }
            ToolPay model = null;
            Users   user  = userDao.Single(UserId);

            Logic.VipType vip = (Logic.VipType)user.VipType;

            decimal[] r = Constant.GetRate(PayType, vip);
            model = new ToolPay(Amount, r[0], 0, r[1], 0, 0);

            JObject data = new JObject();

            data["Amount"]       = model.Amount.ToString("F2");
            data["Rate1"]        = model.Rate1.perCent();
            data["Rate2"]        = model.Rate2.ToString("F2");
            data["Rate3"]        = model.Rate3.ToString("F2");
            data["Rate4"]        = model.Rate4.ToString("F2");
            data["Rate5"]        = model.Rate5.ToString("F2");
            data["PayFee"]       = model.PayFee.ToString("F2");
            data["BasicFee"]     = model.BasicFee.ToString("F2");
            data["ExTargetFee"]  = model.ExTargetFee.ToString("F2");
            data["ActualAmount"] = model.ActualAmount.ToString("F2");
            return(ApiReturnStr.getApiData(data));
        }
Example #4
0
        /// <summary>
        /// 查询个人信息
        /// </summary>
        /// <param name="cid"></param>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public string Single(int cid = 0, int UserId = 0)
        {
            if (UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "参数错误"));
            }

            JObject data = new JObject();
            var     user = userDao.Single(UserId);


            if (user == null || user.UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "用户不存在"));
            }
            data["Mobile"]          = user.Mobile;// ITOrm.Utility.StringHelper.Util.GetHiddenString(user.Mobile, 3, 4);
            data["IsRealState"]     = user.IsRealState;
            data["IsRealStateText"] = user.IsRealState == 0 ? "未认证" : "已认证";
            data["RealName"]        = user.RealName;
            data["IdCard"]          = Util.GetHiddenString(user.IdCard, 6, 4);
            data["VipType"]         = user.VipType;
            data["VipTypeTxt"]      = ((Logic.VipType)user.VipType).ToString();
            var version = TQuery.GetString("version");

            if (user.VipType == 1 && version == "1.0.0" && cid == 3)
            {
                data["VipType"] = 2;
            }
            data["AvatarImg"] = ITOrm.Utility.Const.Constant.StaticHost + userImageDao.GetUrl(user.AvatarImg);
            Logic.VipType vip = (Logic.VipType)user.VipType;
            decimal[]     r   = Constant.GetRate(0, vip);
            decimal[]     r2  = Constant.GetRate(1, vip);

            data["Rate1"]     = r[0].perCent();
            data["Rate3"]     = r[1].ToString("F1");
            data["NoneRate1"] = r2[0].perCent();
            data["NoneRate3"] = r2[1].ToString("F1");


            var ubk = userBankCardDao.Single(" UserId=@UserId and TypeId=0 and state=1  ", new { UserId });

            data["BankCard"] = "";
            data["BankName"] = "";
            data["BankCode"] = "";
            if (ubk != null)
            {
                data["BankCard"] = ubk.BankCard;
                data["BankName"] = ubk.BankName;
                data["BankCode"] = ubk.BankCode;
            }

            data["BaseUserName"] = "******";
            if (user.BaseUserId > 0)
            {
                var baseUser = userDao.Single(user.BaseUserId);
                data["BaseUserName"] = baseUser.RealName;
            }
            return(ApiReturnStr.getApiData(data));
        }
Example #5
0
        public string OpenVipRule(int UserId)
        {
            JObject data = new JObject();
            JArray  list = new JArray();
            JObject vip1 = new JObject();

            vip1["Title"]         = "SVIP会员";
            vip1["CurrentPrice"]  = "199";
            vip1["OriginalPrice"] = "原价¥199";
            vip1["QRcode"]        = Constant.StaticHost + "upload/QRcode/199svip.png"; //199svip.png 99svip.png
            list.Add(vip1);
            JObject vip2 = new JObject();

            vip2["Title"]         = "VIP会员";
            vip2["CurrentPrice"]  = "99";
            vip2["OriginalPrice"] = "原价¥99";
            vip2["QRcode"]        = Constant.StaticHost + "upload/QRcode/99vip.png";//99vip.png  49vip.png
            list.Add(vip2);

            JObject vip3 = new JObject();

            vip3["Title"]         = "升级SVIP";
            vip3["CurrentPrice"]  = "129";
            vip3["OriginalPrice"] = "原价¥129";
            vip3["QRcode"]        = Constant.StaticHost + "upload/QRcode/u129svip.png";//u129svip  u69svip.png
            list.Add(vip3);

            data["listTitle"] = "微信扫码支付";
            data["list"]      = list;



            JArray list2 = new JArray();
            string str   = "1.超低费率;2.邀请好友超高返佣;3.单单分润";
            string str2  = "SVIP有积分0.45%,无积分0.39%\nVIP有积分0.50%,无积分0.44%;好友开通SVIP一次性最高返现79元;好友每次刷卡,即可享受高达0.1%的利润返现";

            string[] strs2 = str.Split(';');
            string[] strs3 = str2.Split(';');
            for (int i = 0; i < strs2.Length; i++)
            {
                JObject obj = new JObject();
                if (!string.IsNullOrEmpty(strs2[i]))
                {
                    obj["Title"] = strs2[i];
                }
                if (!string.IsNullOrEmpty(strs3[i]))
                {
                    obj["Context"] = strs3[i];
                }
                list2.Add(obj);
            }
            data["list2Title"]  = "VIP尊享权益";
            data["list2"]       = list2;
            data["DingjiDaili"] = "客户经理:18610122058\n客户经理:18506120807\n微信客服:SJpay-op";


            data["Tips"] = "选择您需要开通会员对应的二维码并使用微信支付,备注速金派已注册的账号,工作人员确认收款后立刻给您开通会员。您还可以将二维码保存在手机里面,方便支付。如有疑问请关注我们的微信公众号SJ派,联系在线客服";
            return(ApiReturnStr.getApiData(data));
        }
Example #6
0
        // GET: DeBug
        public string Version()
        {
            JObject dic = new JObject();

            //Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("Version", "1.0.0.1");
            dic.Add("VersionDate", "2016-7-7");
            return(ApiReturnStr.getApiData(dic));
        }
Example #7
0
        public string GetIndexData(int cid = 0, int UserId = 0, string version = "")
        {
            var serverVersion = keyValueDao.GetAuditingVersion(cid);


            JObject data = new JObject();
            JArray  list = new JArray();
            JObject obj1 = new JObject();

            obj1["Title"]  = "邀请好友";
            obj1["icon"]   = Constant.StaticHost + "upload/btn/01.png";
            obj1["WapUrl"] = "QRcode";
            list.Add(obj1);

            JObject obj2 = new JObject();

            obj2["Title"]  = (cid == (int)Logic.Platform.iOS && version == serverVersion) ? "使用指南":"邀请收益";
            obj2["icon"]   = Constant.StaticHost + "upload/btn/02.png";
            obj2["WapUrl"] = (cid == (int)Logic.Platform.iOS && version == serverVersion) ? Constant.CurrentApiHost : "InviteIncome";
            list.Add(obj2);


            JObject obj3 = new JObject();

            obj3["Title"]  = "新手指引";
            obj3["icon"]   = Constant.StaticHost + "upload/btn/03.png";
            obj3["WapUrl"] = "https://mp.weixin.qq.com/s/wPYnEFtQZOuWYnERcsQfGQ";
            list.Add(obj3);


            JObject obj4 = new JObject();

            obj4["Title"]  = (cid == (int)Logic.Platform.iOS && version == serverVersion)?"火爆上线": "极速办卡";
            obj4["icon"]   = Constant.StaticHost + "upload/btn/04.png";
            obj4["WapUrl"] = (cid == (int)Logic.Platform.iOS && version == serverVersion) ?(Constant.CurrentApiHost + "HuoBao.html"): "http://www.51ley.com/front/card?uid=fc42c00a05784006aefe49dc0c12fa57&rm=1&time=1529568826349";
            list.Add(obj4);

            JObject obj5 = new JObject();

            obj5["Title"]  = "办卡攻略";
            obj5["icon"]   = Constant.StaticHost + "upload/btn/05.png";
            obj5["WapUrl"] = Constant.CurrentApiHost + "bankcard.html";
            list.Add(obj5);


            JObject obj6 = new JObject();

            obj6["Title"]  = "收款攻略";
            obj6["icon"]   = Constant.StaticHost + "upload/btn/06.png";
            obj6["WapUrl"] = Constant.CurrentApiHost + "Swipe.html";
            list.Add(obj6);

            data["btnList"] = list;

            return(ApiReturnStr.getApiData(data));
        }
Example #8
0
        public string UpImg(int cid = 0, int UserId = 0)
        {
            try
            {
                string base64 = TQuery.GetString("base64");

                byte[] bmpBytes = Convert.FromBase64String(base64);


                //base64 = "/9j/4AAQSkZJRgABAQEAYABgAAD/4QA6RXhpZgAATU0AKgAAAAgAA1EQAAEAAAABAQAAAFERAAQAAAABAAAAAFESAAQAAAABAAAAAAAAAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAZACMDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDuKKWkr6A+JCilpKBiYoo4ooAfSU6kpAJS4opT0oGhtFLRQB//2Q==";
                if (base64.Length < 100)
                {
                    return(ApiReturnStr.getError(-100, "图片太小,不能作为照片上传。"));
                }
                var fileLength = Convert.ToInt32(base64.Length - (base64.Length / 8) * 2);//文件字节
                if (fileLength >= 1024 * 1024 / 2)
                {
                    return(ApiReturnStr.getError(-100, "上传图片大小不能大于512K。"));
                }
                string  url  = Constant.StaticHost + "Upload/UpImg";
                JObject data = new JObject();
                data["cid"]    = cid;
                data["UserId"] = UserId;
                data["dic"]    = "users";
                data["base64"] = base64;
                string json  = string.Empty;
                int    state = HttpHelper.HttpPostJson(url, data.ToString(), System.Text.Encoding.UTF8, out json);
                if (state == 200)
                {
                    reqApiModel <JObject> model = JsonConvert.DeserializeObject <reqApiModel <JObject> >(json);
                    if (model.backState == 0)
                    {
                        UserImage userImage = new UserImage();
                        userImage.CTime    = DateTime.Now;
                        userImage.FileName = model.Data["filename"].ToString();
                        userImage.Ip       = Ip.GetClientIp();
                        userImage.PlatForm = cid;
                        userImage.State    = 0;
                        userImage.Url      = model.Data["Url"].ToString();
                        userImage.UserId   = UserId;
                        int result = userImageDao.Insert(userImage);
                        model.Data["ID"] = result;
                        userEventDao.UserEventInit(cid, UserId, Ip.GetClientIp(), result > 0 ? 1 : 0, "Upload", "UpImg", $"{{ImgUrl:{model.Data["ImgUrl"]},version:{TQuery.GetString("version")}}}");
                        return(ApiReturnStr.getApiData(result > 0 ? 0 : -100, result > 0 ? "上传成功" : "上传失败", model.Data));
                    }
                }
                return(ApiReturnStr.getApiData(-100, $"上传失败:httpStatus:{state},message:{json}"));
            }
            catch (Exception ex)
            {
                Logs.WriteLog(string.Format("cmd=UpImg,cid:{0},UserId:{1},ip:{2},ex:{3}", cid, UserId, Ip.GetClientIp(), ex.Message), "d:\\Log\\Upload", "UpImg");

                return(ApiReturnStr.getError(-100, "上传图片失败,请稍后再试。"));
            }
        }
Example #9
0
        // GET: Upload
        public string UpImg()
        {
            int cid    = 1;
            int UserId = TQuery.GetInt("UserId");

            try
            {
                if (Request.Files.Count == 0)
                {
                    return("");
                }
                var files = Request.Files[0];


                byte[] content = new byte[files.InputStream.Length];
                files.InputStream.Read(content, 0, Convert.ToInt32(files.InputStream.Length));


                string base64 = Convert.ToBase64String(content.ToArray());;

                byte[] bmpBytes = Convert.FromBase64String(base64);
                //base64 = "/9j/4AAQSkZJRgABAQEAYABgAAD/4QA6RXhpZgAATU0AKgAAAAgAA1EQAAEAAAABAQAAAFERAAQAAAABAAAAAFESAAQAAAABAAAAAAAAAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAZACMDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDuKKWkr6A+JCilpKBiYoo4ooAfSU6kpAJS4opT0oGhtFLRQB//2Q==";

                string  url  = Constant.StaticHost + "Upload/UpImg";
                JObject data = new JObject();
                data["cid"]    = cid;
                data["UserId"] = UserId;
                data["dic"]    = "banner";
                data["base64"] = base64;
                string json  = string.Empty;
                int    state = HttpHelper.HttpPostJson(url, data.ToString(), System.Text.Encoding.UTF8, out json);
                if (state == 200)
                {
                    reqApiModel <JObject> model = JsonConvert.DeserializeObject <reqApiModel <JObject> >(json);
                    UserImage             img   = new UserImage();
                    img.UserId   = UserId;
                    img.Url      = model.Data["Url"].ToString();
                    img.PlatForm = (int)ITOrm.Utility.Const.Logic.Platform.系统;
                    int ImgId = userImageDao.Insert(img);
                    model.Data["ImgId"] = ImgId;
                    return(ApiReturnStr.getApiData(model.backState, model.message, model.Data));
                }
                return(ApiReturnStr.getApiData(-100, $"上传失败:httpStatus:{state},message:{json}"));
            }
            catch (Exception ex)
            {
                return(ApiReturnStr.getError(-100, "上传图片失败,请稍后再试。err:" + ex.Message));
            }
        }
Example #10
0
        public string AccountTotal(int UserId)
        {
            var     model = accountDao.Single("UserId=@UserId", new { UserId });
            JObject data  = new JObject();

            data["Total"]     = "0.00";
            data["Frozen"]    = "0.00";
            data["Available"] = "0.00";
            if (model != null && model.ID > 0)
            {
                data["Total"]     = model.Total.ToString("F2");
                data["Frozen"]    = model.Frozen.ToString("F2");
                data["Available"] = model.Available.ToString("F2");
            }
            return(ApiReturnStr.getApiData(data));
        }
Example #11
0
        /// <summary>
        /// 验证短信验证码
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="regGuid"></param>
        /// <param name="mcode"></param>
        /// <returns></returns>
        public string ValidateMobileCode(string mobile = "", string forgetGuid = "", string mcode = "")
        {
            #region 验证
            if (!ITOrm.Utility.StringHelper.TypeParse.IsMobile(mobile))
            {
                return(ApiReturnStr.getError(-100, "手机号格式验证失败"));
            }
            if (forgetGuid.Length != 36)
            {
                return(ApiReturnStr.getError(-100, "短信令牌有误"));
            }
            if (mcode.Trim().Length != 6)
            {
                return(ApiReturnStr.getError(-100, "手机验证码错误"));
            }

            string mobileKey = ITOrm.Utility.Const.Constant.forget_mobile_code + forgetGuid;

            if (!ITOrm.Utility.Cache.MemcachHelper.Exists(mobileKey))
            {
                return(ApiReturnStr.getError(-100, "手机验证码已过期"));
            }
            JObject cacheMobileCode = JObject.Parse(ITOrm.Utility.Cache.MemcachHelper.Get(mobileKey).ToString());

            if (mobile != cacheMobileCode["mobile"].ToString())
            {
                return(ApiReturnStr.getError(-100, "当前手机号不是接收短信的手机号"));
            }

            if (mcode.Trim() != cacheMobileCode["code"].ToString())
            {
                return(ApiReturnStr.getError(-100, "手机验证码错误"));
            }



            #endregion

            JObject data = new JObject();
            string  guid = Util.GetGUID;
            data["forgetGuid"] = guid;
            data["mobile"]     = mobile;
            string key = Constant.forget_token + guid;
            MemcachHelper.Delete(mobileKey);//销毁手机短信验证码
            MemcachHelper.Set(key, data.ToString(), ITOrm.Utility.Const.Constant.token_expires);
            return(ApiReturnStr.getApiData(0, "验证成功", data));
        }
Example #12
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="cid"></param>
        /// <param name="mobile">手机号</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        public string Login(int cid = 0, string mobile = "", string password = "", string guid = "")
        {
            if (!TypeParse.IsMobile(mobile))
            {
                return(ApiReturnStr.getError(-100, "请输入正确的手机号"));
            }
            if (password.Length != 32)
            {
                return(ApiReturnStr.getError(-100, "密码格式不正确"));
            }
            if (guid.Length != 36)
            {
                return(ApiReturnStr.getError(-100, "唯一标识错误"));
            }
            var model = userDao.Single("mobile=@mobile ", new { mobile });

            if (model != null && model.UserId > 0 && model.State < 0)
            {
                return(ApiReturnStr.getError(-100, "您的账户被冻结,无法登录"));
            }
            if (model != null && model.UserId > 0)
            {
                var result = userEventDao.UserCheckLogin(model.UserId);//检查用户是否可以登录
                if (!result.backState)
                {
                    return(ApiReturnStr.getError(-100, result.msg));
                }
            }

            if (model != null && model.UserId > 0 && model.Password == password)
            {
                JObject data = new JObject();
                data["UserId"] = model.UserId;
                //记录登录状态
                ITOrm.Utility.Cache.MemcachHelper.Set(Constant.login_key + model.UserId, guid, DateTime.Now.AddYears(1));
                userEventDao.UserLogin(cid, mobile, password, Ip.GetClientIp(), model.UserId, 1, TQuery.GetString("version"), guid);//登录成功的日志
                return(ApiReturnStr.getApiData(0, "登录成功", data));
            }

            if (model != null && model.UserId > 0)
            {
                userEventDao.UserLogin(cid, mobile, password, Ip.GetClientIp(), model.UserId, 0, TQuery.GetString("version"), guid);//登录失败的日志
                return(ApiReturnStr.getError(-100, "用户名或密码错误(登录失败)"));
            }
            return(ApiReturnStr.getError(-100, "用户名或密码错误"));
        }
Example #13
0
        public string IncomeTotal(int UserId)
        {
            JObject total = MemcachHelper.Get <JObject>(Constant.income_total_key + UserId, DateTime.Now.AddMinutes(5), () =>
            {
                JObject data                = new JObject();
                decimal TotalIncome         = ITOrm.Utility.Helper.DapperHelper.ExecScalarSql <decimal>($" SELECT ISNULL(SUM(Amount),0) FROM dbo.AccountRecord WHERE UserId={UserId} AND TypeId IN(100,101,102,103,104) ");
                decimal LastMounthIncome    = ITOrm.Utility.Helper.DapperHelper.ExecScalarSql <decimal>($" SELECT ISNULL(SUM(Amount),0) FROM dbo.AccountRecord WHERE UserId={UserId} AND TypeId IN(100,101,102,103,104) and DATEDIFF(MONTH,CTime,GETDATE())=1 ");
                decimal CurrentMounthIncome = ITOrm.Utility.Helper.DapperHelper.ExecScalarSql <decimal>($" SELECT ISNULL(SUM(Amount),0) FROM dbo.AccountRecord WHERE UserId={UserId} AND TypeId IN(100,101,102,103,104) and DATEDIFF(MONTH,CTime,GETDATE())=0 ");
                data["TotalIncome"]         = TotalIncome.ToString("F2");
                data["LastMounthIncome"]    = LastMounthIncome.ToString("F2");
                data["CurrentMounthIncome"] = CurrentMounthIncome.ToString("F2");
                return(data);
            });

            total["LastMounthIncomeTip"] = "上月收益会扣除2元的手续费在每月的第一个工作日打款到您的结算卡中。";
            return(ApiReturnStr.getApiData(total));
        }
Example #14
0
        //初始版 透传卡号
        public string ReceiveApi(int cid = 0, int UserId = 0, decimal Amount = 0m, string BankCard = "")
        {
            return(ApiReturnStr.getError(-100, "请使用最新版APP"));

            Logs.WriteLog($"ReceiveApi,cid:{cid},UserId:{UserId},Amount:{Amount},BankCard:{BankCard}", "d:\\Log\\Yeepay", "ReceiveApi");
            #region 参数验证
            if (UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "UserId参数错误"));
            }
            if (Amount < 100)
            {
                return(ApiReturnStr.getError(-100, "收款金额不能小于100元"));
            }
            if (string.IsNullOrEmpty(BankCard) || !(BankCard.Length > 13 && BankCard.Length < 21))
            {
                return(ApiReturnStr.getError(-100, "收款银行卡有误"));
            }
            var model = userDao.Single(UserId);
            if (model == null || model.UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "用户不存在"));
            }
            var yeepayUser = yeepayUserDao.Single(" UserId=@UserId ", new { UserId });
            if (yeepayUser == null || model.UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "未开通子商户功能"));
            }
            if (yeepayUser.RateState1 == 0 || yeepayUser.RateState3 == 0 || yeepayUser.RateState4 == 0 || yeepayUser.RateState5 == 0)
            {
                return(ApiReturnStr.getError(-100, "费率未设置"));
            }
            if (yeepayUser.IsAudit == 0)
            {
                return(ApiReturnStr.getError(-100, "子商户未审核通过"));
            }
            #endregion
            var result = YeepayDepository.ReceiveApi(UserId, Amount, cid, BankCard);
            if (result.backState == 0)
            {
                JObject data = new JObject();
                data["PayUrl"] = result.urlAES;
                return(ApiReturnStr.getApiData(data));
            }
            return(ApiReturnStr.getError(-100, result.message));
        }
Example #15
0
        public string InviteRule(int UserId)
        {
            JArray list = new JArray();

            string str = "1.每推荐一名用户开通VIP最高可获得39元现金奖励;2.每推荐一名用户开通SVIP最高可获得79元现金奖励;3.用户邀请好友刷卡可享受高达0.1%的分佣;4.邀请好友刷卡金额累计15万,将送您永久VIP!";

            string[] strs = str.Split(';');
            foreach (var item in strs)
            {
                JObject obj = new JObject();
                obj["line"] = item;
                list.Add(obj);
            }

            JArray list2 = new JArray();

            str  = "1.普通用户刷卡金额累加达到8万元,将获得永久VIP会员;";
            str += "2.普通用户邀请好友:-所有好友刷卡金额累加达到15万元,邀请人将获得永久VIP会员;";
            str += "3.普通用户邀请好友开通VIP会员:-邀请人获得分润19元;";
            str += "4.普通用户邀请好友开通SVIP会员:-被邀请人为普通用户,邀请人获得分润49元;-被邀请人为VIP会员,邀请人获得分润29元;";
            str += "5.VIP会员邀请的好友为普通用户:-刷卡分润a元(a =(普通会员费率 - VIP费率)×刷卡金额;";
            str += "6.VIP会员邀请好友开通VIP会员:-邀请人获得分润29元;";
            str += "7.VIP会员邀请好友开通SVIP会员: -被邀请人为普通用户,邀请人获得分润69元;-被邀请人为VIP会员,邀请人获得分润49元;";
            str += "8.SVIP会员邀请的好友为普通用户:-刷卡分润b元(b =(普通会员费率 - SVIP费率)×刷卡金额);";
            str += "9.SVIP会员邀请好友开通VIP会员:-刷卡分润c元(c =(VIP费率 - SVIP费率)×刷卡金额)-邀请人获得分润39元;";
            str += "10.SVIP会员邀请好友开通SVIP会员:-被邀请人为普通用户,邀请人获得分润79元;-被邀请人为VIP会员,邀请人获得分润59元;";
            string[] strs2 = str.Split(';');
            foreach (var item in strs2)
            {
                JObject obj = new JObject();
                obj["line"] = item;
                if (!string.IsNullOrEmpty(item))
                {
                    list2.Add(obj);
                }
            }

            JObject data = new JObject();

            data["simple"]  = list;
            data["complex"] = list2;
            return(ApiReturnStr.getApiData(data));
        }
Example #16
0
        public string GetVersion(int cid)
        {
            int TypeId = (int)Logic.KeyValueType.平台版本号;
            //通过cid查询APP版本升级信息
            var list = MemcachHelper.Get <List <KeyValue> >(Constant.list_keyvalue_key + TypeId, DateTime.Now.AddDays(7), () =>
            {
                return(keyValueDao.GetQuery(10, " state<>-1 and typeid=@TypeId ", new { TypeId }, "order by Sort desc,CTime desc"));
            });

            list = list.FindAll(m => m.KeyId == cid).OrderByDescending(m => m.Sort).ThenByDescending(m => m.CTime).ToList();
            JObject data = new JObject();

            if (list != null && list.Count > 0)
            {
                bool flag = false;
                foreach (var item in list)
                {
                    var temp = JObject.Parse(item.Value);
                    if (temp["IsAuditing"].ToInt() == 1)
                    {
                        flag                = true;
                        data                = JObject.Parse(item.Value);
                        data["CTime"]       = item.CTime;
                        data["Platform"]    = item.KeyId;
                        data["PlatformTxt"] = ((Logic.Platform)item.KeyId).ToString();
                        break;
                    }
                }
                if (!flag)//未找到最新版本
                {
                    return(ApiReturnStr.getError(0, "暂无新版本"));
                }
            }
            else
            {
                return(ApiReturnStr.getError(0, "暂无新版本"));
            }
            return(ApiReturnStr.getApiData(data));
        }
Example #17
0
 public string UpdateBankMobile(int cid = 0, int UserId = 0, int BankID = 0, string mobile = "")
 {
     userEventDao.UserEventInit(cid, UserId, Ip.GetClientIp(), 0, "Users", "UpdateBankMobile", $"{{BankID:{BankID},mobile:{mobile},version:{TQuery.GetString("version")}}}");
     #region 验证
     if (!TypeParse.IsMobile(mobile))
     {
         return(ApiReturnStr.getError(-100, "预留手机号格式验证失败"));
     }
     var model = userBankCardDao.Single(BankID);
     if (model == null)
     {
         return(ApiReturnStr.getApiData(-100, "BankID记录不存在"));
     }
     if (model.UserId != UserId)
     {
         return(ApiReturnStr.getApiData(-100, "该银行卡不属于此账户下"));
     }
     #endregion
     model.Mobile = mobile;
     model.UTime  = DateTime.Now;
     bool flag = userBankCardDao.Update(model);
     return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "修改成功" : "修改失败"));
 }
Example #18
0
        //1.0.0
        public string ReceiveApi2(int cid = 0, int UserId = 0, decimal Amount = 0m, int BankID = 0, int PayType = 0)
        {
            Logs.WriteLog($"ReceiveApi2,cid:{cid},UserId:{UserId},Amount:{Amount},BankID:{BankID},PayType:{PayType}", "d:\\Log\\Yeepay", "ReceiveApi2");
            userEventDao.UserReceiveApi2(cid, UserId, Ip.GetClientIp(), 0, TQuery.GetString("version"), Amount, BankID, PayType);
            #region 参数验证
            if (UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "UserId参数错误"));
            }
            if (Amount < 500)
            {
                return(ApiReturnStr.getError(-100, "收款金额不能小于500元"));
            }

            var ubk = userBankCardDao.Single(BankID);
            if (ubk == null)
            {
                return(ApiReturnStr.getError(-100, "卡记录不存在"));
            }

            //卡数据验证
            var validateBankResult = userBankCardDao.ValidateBank(ubk);
            if (validateBankResult.backState != 0)
            {
                return(ApiReturnStr.getError(-100, validateBankResult.message));
            }

            var model = userDao.Single(UserId);
            if (model == null || model.UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "用户不存在"));
            }

            JObject data = new JObject();
            data["PayUrl"] = "";

            string msg = "";



            #region 测试通道
            //Thread.Sleep(3000);
            //int ChannelType = 4;
            //data["ChannelType"] = ChannelType;
            //data["BankID"] = BankID;
            //return ApiReturnStr.getApiData(-200, $"快捷协议未开通(03-{ChannelType})", data);
            #endregion

            #region  择通道
            int ChannelType = 0;
            //data["ChannelType"] = ChannelType;
            data["BankID"] = BankID;

            var option = SelectOptionChannel.Optimal(Amount, BankID, PayType);
            if (option.backState == 0)
            {
                ChannelType         = option.Data;
                data["ChannelType"] = ChannelType;
            }
            else
            {
                if (option.Data == 2)
                {
                    return(ApiReturnStr.getError(-100, "通道升级中,敬请期待"));
                }
                return(ApiReturnStr.getError(-100, option.message));
            }
            data["ChannelType"] = option.Data;
            #endregion


            if (Amount > 20000)
            {
                return(ApiReturnStr.getError(-100, "收款金额不能超过20000元"));
            }

            Logic.ChannelType ct = (Logic.ChannelType)ChannelType;
            switch (ct)
            {
            case Logic.ChannelType.易宝:
                #region 易宝逻辑
                var yeepayUser = yeepayUserDao.Single(" UserId=@UserId ", new { UserId });
                if (yeepayUser == null || model.UserId <= 0)
                {
                    return(ApiReturnStr.getError(-100, "未开通子商户功能"));
                }
                if (yeepayUser.RateState1 == 0 || yeepayUser.RateState3 == 0 || yeepayUser.RateState4 == 0 || yeepayUser.RateState5 == 0)
                {
                    return(ApiReturnStr.getError(-100, "费率未设置"));
                }
                if (yeepayUser.IsAudit == 0)
                {
                    return(ApiReturnStr.getError(-100, "子商户未审核通过"));
                }
                var result = YeepayDepository.ReceiveApi(UserId, Amount, cid, BankID);
                if (result.backState == 0)
                {
                    data["PayUrl"] = result.urlAES;
                    return(ApiReturnStr.getApiData(data));
                }
                msg = result.message;
                #endregion
                break;

            case Logic.ChannelType.荣邦科技积分:
            case Logic.ChannelType.荣邦科技无积分:
            case Logic.ChannelType.荣邦3:
                if (ChannelType == 2)
                {
                    return(ApiReturnStr.getError(-100, "通道升级中,敬请期待"));
                }
                #region 荣邦逻辑
                #region 验证
                if (Amount < 500)
                {
                    return(ApiReturnStr.getError(-100, "此通道要求支付金额不得小于500元!"));
                }
                //验证是否开户
                if (!masgetUserDao.QueryIsExist(UserId, ChannelType))
                {
                    return(ApiReturnStr.getApiData(-200, $"快捷协议未开通(01-{ChannelType})", data));                                                     //通道未开户
                }
                if (!masgetUserDao.QueryIsOpen(UserId, ChannelType))
                {
                    return(ApiReturnStr.getApiData(-200, $"快捷协议未开通(02-{ChannelType})", data));                                                    //通道未入驻
                }
                //验证快捷协议是否开通
                if (!bankTreatyApplyDao.QueryTreatycodeIsOpen(BankID, ChannelType))
                {
                    return(ApiReturnStr.getApiData(-200, $"快捷协议未开通(03-{ChannelType})", data));
                }
                #endregion
                //执行请求
                var resultBackPay = MasgetDepository.BackPay(BankID, Amount, cid, ct);
                if (resultBackPay.backState == 0)
                {
                    data["PayUrl"] = resultBackPay.url;
                    return(ApiReturnStr.getApiData(0, "请求成功,待确认支付", data));
                }
                else if (resultBackPay.backState == 8401)
                {
                    return(ApiReturnStr.getError(-8401, "通道暂无额度"));
                }
                else
                {
                    return(ApiReturnStr.getError(-100, resultBackPay.message));
                }

                #endregion
            case Logic.ChannelType.腾付通:
                var resultTeng = TengDepository.CreatePayCashier(UserId, cid, Amount, BankID);
                msg = resultTeng.message;
                if (resultTeng.backState == 0)
                {
                    data["PayUrl"] = resultTeng.Data["url"];
                    return(ApiReturnStr.getApiData(data));
                }
                break;

            case Logic.ChannelType.米刷:
                var resultMi = MiShuaDepository.PayDzero(BankID, cid, Amount);
                msg = resultMi.message;
                if (resultMi.backState == 0 && resultMi.Data.status == "00")
                {
                    data["PayUrl"] = resultMi.Data.tranStr;
                    return(ApiReturnStr.getApiData(data));
                }
                break;

            default:
                break;
            }

            #endregion

            return(ApiReturnStr.getError(-100, msg));
        }
Example #19
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="cid"></param>
        /// <param name="mobile">手机号</param>
        /// <param name="password">密码</param>
        /// <param name="mcode">手机验证码</param>
        /// <param name="regGuid">令牌</param>
        /// <param name="baseUserId">推荐人</param>
        /// <returns></returns>
        public string Register(int cid = 0, string mobile = "", string password = "", string mcode = "", string regGuid = "", int baseUserId = 0, string ip = "")
        {
            Logs.WriteLog($"Register,cid:{cid},mobile:{mobile},password:{password},mcode:{mcode},regGuid:{regGuid},baseUserId:{baseUserId}", "d:\\Log\\ITOrm", "Register");
            #region 验证
            if (!TypeParse.IsMobile(mobile))
            {
                return(ApiReturnStr.getError(-100, "手机号格式验证失败"));
            }
            if (password.Length != 32)
            {
                return(ApiReturnStr.getError(-100, "密码格式错误"));
            }
            if (mcode.Length != 6)
            {
                return(ApiReturnStr.getError(-100, "手机验证码格式错误"));
            }
            if (regGuid.Length != 36)
            {
                return(ApiReturnStr.getError(-100, "短信令牌格式错误"));
            }

            string key = ITOrm.Utility.Const.Constant.reg_mobile_code + regGuid;
            if (!ITOrm.Utility.Cache.MemcachHelper.Exists(key))
            {
                return(ApiReturnStr.getError(-100, "短信验证码已过期"));
            }

            JObject mobileCodeData = JObject.Parse(ITOrm.Utility.Cache.MemcachHelper.Get(key).ToString());
            if (mobileCodeData["code"].ToString() != mcode)
            {
                return(ApiReturnStr.getError(-100, "短信验证码错误"));
            }
            if (mobileCodeData["mobile"].ToString() != mobile)
            {
                return(ApiReturnStr.getError(-100, "手机号码不是接收短信的手机号码"));
            }

            if (baseUserId > 0)
            {
                var baseUser = userDao.Single(baseUserId);
                if (baseUser == null || baseUser.UserId == 0)
                {
                    return(ApiReturnStr.getError(-100, "该邀请人不存在"));
                }
            }
            var modelUsers = userDao.Single(" mobile=@mobile ", new { mobile });
            if (modelUsers != null && modelUsers.UserId > 0)
            {
                return(ApiReturnStr.getError(-100, "该手机号已注册"));
            }
            #endregion
            ip = string.IsNullOrEmpty(ip) ? ITOrm.Utility.Client.Ip.GetClientIp() : ip;
            var model = new Users();
            model.BaseUserId  = baseUserId;
            model.CTime       = DateTime.Now;
            model.Email       = "";
            model.IdCard      = "";
            model.IP          = ip;
            model.IsRealState = 0;
            model.Mobile      = mobile;
            model.Password    = password;
            model.PlatForm    = cid;
            model.RealName    = "";
            model.Soure       = "";
            model.State       = 0;
            model.UserName    = mobile;
            model.UTime       = DateTime.Now;
            model.RealTime    = DateTime.Now;
            model.VipType     = (int)Logic.VipType.SVIP;
            var result  = userDao.Insert(model);
            var account = new Account();
            account.UserId    = result;
            account.CTime     = DateTime.Now;
            account.UTime     = DateTime.Now;
            account.Frozen    = 0m;
            account.Available = 0m;
            account.Total     = 0m;
            var resultAccount = accountDao.Insert(account);
            if (result > 0 && resultAccount > 0)
            {
                JObject obj = new JObject();
                obj["UserId"] = result;
                userEventDao.UserRegister(cid, ip, result, 1, mobile, password, mcode, regGuid, baseUserId, TQuery.GetString("version"));
                ITOrm.Utility.Cache.MemcachHelper.Delete(key);//销毁本次验证码缓存
                return(ApiReturnStr.getApiData(0, "注册成功", obj));
            }
            else
            {
                return(ApiReturnStr.getError(-100, "注册失败"));
            }
        }
Example #20
0
        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <returns></returns>
        public string SendMsgCode(int cid = 0, string mobile = "", string vcode = "", string guid = "")
        {
            #region 验证
            if (!ITOrm.Utility.StringHelper.TypeParse.IsMobile(mobile))
            {
                return(ApiReturnStr.getError(-100, "手机号格式验证失败"));
            }
            if (guid.Length != 36)
            {
                return(ApiReturnStr.getError(-100, "唯一标识错误"));
            }
            if (vcode.Trim().Length != 4)
            {
                return(ApiReturnStr.getError(-100, "验证码错误"));
            }

            string imgKey = ITOrm.Utility.Const.Constant.forget_img_code + guid;

            if (!ITOrm.Utility.Cache.MemcachHelper.Exists(imgKey))
            {
                return(ApiReturnStr.getError(-101, "图形验证码过期"));
            }
            string cacheImgCode = ITOrm.Utility.Cache.MemcachHelper.Get(imgKey).ToString();

            if (vcode.Trim().ToLower() != cacheImgCode.ToLower())
            {
                return(ApiReturnStr.getError(-100, "图形验证码错误"));
            }
            var modelUsers = userDao.Single(" mobile=@mobile ", new { mobile });
            if (modelUsers == null || modelUsers.UserId == 0)
            {
                return(ApiReturnStr.getError(-100, "该手机号未注册"));
            }
            if (sendMsgDao.ValidateForgetCnt(mobile))
            {
                return(ApiReturnStr.getError(-100, "验证码发送次数超限"));
            }
            #endregion

            var regGuid = Util.GetGUID;

            //发送短信
            var resultMsg = SystemSendMsg.Send(Logic.EnumSendMsg.忘记密码短信, mobile);

            SendMsg model = new SendMsg();
            model.Context    = resultMsg.content;
            model.CTime      = DateTime.Now;
            model.TypeId     = (int)Logic.EnumSendMsg.忘记密码短信;
            model.IP         = ITOrm.Utility.Client.Ip.GetClientIp();
            model.Merchant   = resultMsg.Merchant;
            model.Mobile     = mobile;
            model.Platform   = cid;
            model.Service    = "forget";
            model.RelationId = resultMsg.relationId;
            model.State      = resultMsg.backState ? 2 : 1;
            model.UTime      = DateTime.Now;
            int result = sendMsgDao.Insert(model);

            if (resultMsg.backState && result > 0)
            {
                #region 销毁
                ITOrm.Utility.Cache.MemcachHelper.Delete(imgKey);
                #endregion

                string key       = Constant.forget_mobile_code + regGuid;
                var    cacheData = new JObject();
                cacheData["mobile"] = mobile;
                cacheData["code"]   = resultMsg.code;
                MemcachHelper.Set(key, cacheData.ToString(), ITOrm.Utility.Const.Constant.mobile_code_expires);


                var data = new JObject();
                data["forgetGuid"] = regGuid;
                if (Constant.IsDebug)
                {
                    data["code"] = resultMsg.code;
                }
                return(ApiReturnStr.getApiData(0, "发送成功", data));
            }

            return(ApiReturnStr.getApiData(-100, "发送失败"));
        }
Example #21
0
 public string yb()
 {
     return(ApiReturnStr.getApiData());
 }
Example #22
0
        public string UpImg()
        {
            int    cid    = 0;
            int    UserId = 0;
            string dic    = "";

            try
            {
                HttpRequestBase request      = HttpContext.Request;
                Stream          stream       = request.InputStream;
                string          json         = string.Empty;
                string          responseJson = string.Empty;
                if (stream.Length != 0)
                {
                    StreamReader streamReader = new StreamReader(stream);
                    json = streamReader.ReadToEnd();
                }
                JObject obj    = JObject.Parse(json);
                string  base64 = obj["base64"].ToString();
                cid    = obj["cid"].ToInt();
                UserId = obj["UserId"].ToInt();
                dic    = obj["dic"].ToString();

                //base64 = "/9j/4AAQSkZJRgABAQEAYABgAAD/4QA6RXhpZgAATU0AKgAAAAgAA1EQAAEAAAABAQAAAFERAAQAAAABAAAAAFESAAQAAAABAAAAAAAAAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAZACMDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDuKKWkr6A+JCilpKBiYoo4ooAfSU6kpAJS4opT0oGhtFLRQB//2Q==";
                if (base64.Length < 100)
                {
                    return(ApiReturnStr.getError(-100, "图片太小,不能作为照片上传。"));
                }
                var fileLength = Convert.ToInt32(base64.Length - (base64.Length / 8) * 2);//文件字节
                if (fileLength >= 1024 * 1024 * 2)
                {
                    return(ApiReturnStr.getError(-100, "上传图片大小不能超过2M。"));
                }

                string path    = "upload/" + dic + "/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                string dicPath = Server.MapPath("~/" + path);

                if (!Directory.Exists(dicPath))//如果没有文件夹则创建
                {
                    System.IO.Directory.CreateDirectory(dicPath);
                }

                string file_ex = ".jpg";
                string url2    = Constant.StaticHost + path;
                //文件名
                string fileName = DateTime.Now.ToString("HHmmssfff");
                byte[] bmpBytes = Convert.FromBase64String(base64);
                //完整地址
                string aUrl = url2 + fileName + file_ex;

                if (aUrl.Length > 10)
                {
                    MemoryStream ms  = new MemoryStream(bmpBytes);
                    Bitmap       bmp = new Bitmap(ms);
                    bmp.Save(dicPath + fileName + file_ex, System.Drawing.Imaging.ImageFormat.Jpeg);
                }

                JObject data = new JObject();
                data["ImgUrl"]     = aUrl;
                data["fileLength"] = fileLength;
                data["filename"]   = fileName + file_ex;
                data["Url"]        = path + fileName + file_ex;
                return(ApiReturnStr.getApiData(0, "上传成功", data));
            }
            catch (Exception ex)
            {
                Logs.WriteLog(string.Format("static=UpImg,cid:{0},UserId:{1},ip:{2},ex:{3}", cid, UserId, Ip.GetClientIp(), ex.Message), "d:\\Log\\Upload", "UpImg");
                return(ApiReturnStr.getError(-100, "上传图片失败,请稍后再试。"));
            }
        }
Example #23
0
        public string BankBind(int cid = 0, int UserId = 0, string mobile = "", string bankcard = "", string bankcode = "", int typeid = 0, string cvn2 = "", string expiresYear = "", string expiresMouth = "", string OpeningBank = "", string OpeningSerialBank = "", int BankID = 0)
        {
            Logs.WriteLog($"Action:User,Cmd:BankBind,UserId:{UserId},mobile:{mobile},bankcard:{bankcard},bankcode:{bankcode},typeid:{typeid},cvn2:{cvn2},expiresYear:{expiresYear},expiresMouth:{expiresMouth},OpeningBank:{OpeningBank},OpeningSerialBank:{OpeningSerialBank}", "d:\\Log\\ITOrm", "BankBind");
            userEventDao.UserBankBind(cid, UserId, Ip.GetClientIp(), mobile, bankcard, bankcode, typeid, cvn2, expiresYear, expiresMouth, OpeningBank, OpeningSerialBank, BankID);

            var version = TQuery.GetString("version");

            if (cid == 3 && version == "1.0.0")
            {
                string temp = expiresYear;
                expiresYear  = expiresMouth;
                expiresMouth = temp;
            }
            #region 验证
            if (!TypeParse.IsMobile(mobile))
            {
                return(ApiReturnStr.getError(-100, "预留手机号格式验证失败"));
            }
            if (!(bankcard.Length > 13 && bankcard.Length < 21))
            {
                return(ApiReturnStr.getError(-100, "银行卡参数错误"));
            }
            if (string.IsNullOrEmpty(bankcode))
            {
                return(ApiReturnStr.getError(-100, "银行编号不能为空"));
            }
            Users user = userDao.Single(UserId);
            if (user == null || user.UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "用户不存在"));
            }
            if (user.IsRealState != 1)
            {
                return(ApiReturnStr.getError(-100, "用户未实名认证,无法绑卡"));
            }
            if (typeid == 1)//如果是结算卡
            {
                if (string.IsNullOrEmpty(cvn2) || string.IsNullOrEmpty(expiresYear) || string.IsNullOrEmpty(expiresMouth))
                {
                    return(ApiReturnStr.getError(-100, "支付卡参数有误"));
                }

                if (BankID == 0)
                {
                    UserBankCard ubc = userBankCardDao.Single(" UserId=@UserId and BankCard=@bankcard and TypeId=1  ", new { UserId, bankcard });
                    if (ubc != null && ubc.ID > 0)
                    {
                        return(ApiReturnStr.getError(-100, "该支付卡已经绑定过,不能重复绑定"));
                    }
                }
            }
            else
            {
                UserBankCard ubc = userBankCardDao.Single(" UserId=@UserId and TypeId=0 and  State=1 ", new { UserId });
                if (ubc != null && ubc.ID > 0)
                {
                    return(ApiReturnStr.getApiData(-100, "结算卡只能绑定一张"));
                }
            }
            UserBankCard model = null;
            if (BankID > 0)
            {
                model = userBankCardDao.Single(BankID);
                if (model == null)
                {
                    return(ApiReturnStr.getApiData(-100, "BankID记录不存在"));
                }
                if (model.State == 1)
                {
                    return(ApiReturnStr.getApiData(-100, "该银行卡已通过验证,不可修改信息"));
                }
            }
            else
            {
                model = new UserBankCard();
            }
            #endregion

            #region 绑卡
            var result = BankCardBindHelper.Bind(typeid, user.RealName, user.IdCard, bankcard, mobile, cvn2, expiresYear, expiresMouth);

            model.BankCard          = result.bankCard;
            model.BankCode          = bankcode;
            model.BankName          = bankDao.QueryBankName(bankcode);
            model.CVN2              = cvn2;
            model.ExpiresYear       = expiresYear;
            model.ExpiresMouth      = expiresMouth;
            model.UTime             = DateTime.Now;
            model.Mobile            = mobile;
            model.TypeId            = typeid;
            model.OpeningBank       = OpeningBank;
            model.OpeningSerialBank = OpeningSerialBank;
            model.State             = 0;// result.backState ? 1 : 0;//默认为0
            model.RelationId        = ",0,";
            bool flag = false;
            if (BankID == 0)
            {
                model.UserId   = UserId;
                model.IP       = Ip.GetClientIp();
                model.CTime    = DateTime.Now;
                model.Platform = cid;
                int num = userBankCardDao.Insert(model);
                flag = num > 0;
                return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "绑定成功" : "绑定失败"));
            }
            else
            {
                var list = bankTreatyApplyDao.GetQuery(" State=2 And UbkID=@BankID", new { BankID });
                if (list != null && list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        MasgetDepository.TreatyModify(BankID, cvn2, expiresYear, expiresMouth, cid, (Logic.ChannelType)item.ChannelType);
                    }
                }
                flag = userBankCardDao.Update(model);
                return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "修改成功" : "修改失败"));
            }

            #endregion
        }