Beispiel #1
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));
        }
Beispiel #2
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, "上传图片失败,请稍后再试。"));
            }
        }
Beispiel #3
0
        public ActionResult TreatyQuery()
        {
            respMasgetModel <respTreatyQueryModel> result = new respMasgetModel <respTreatyQueryModel>();

            result.ret = -100;

            string BankCard    = TQuery.GetString("BankCard");
            int    ChannelType = TQuery.GetInt("ChannelType");

            if (string.IsNullOrEmpty(BankCard))
            {
                return(View(result));
            }
            result = MasgetDepository.TreatyQuery(1, (Logic.ChannelType)ChannelType, BankCard);
            return(View(result));
        }
Beispiel #4
0
        public ActionResult TradeReviceQuery()
        {
            string requestId = TQuery.GetString("requestId");
            respTradeReviceQueryModel result = new respTradeReviceQueryModel();

            if (string.IsNullOrEmpty(requestId))
            {
                result.backState = -100;
                result.message   = "";
            }
            else
            {
                result = YeepayDepository.TradeReviceQuery(requestId, (int)Logic.Platform.系统);
            }
            return(View(result));
        }
Beispiel #5
0
        public ActionResult Memcached()
        {
            var keyName = TQuery.GetString("keyName");
            var cmd     = TQuery.GetString("cmd");

            ResultModel result = new ResultModel();

            result.data             = new JObject();
            result.data["keyName"]  = keyName;
            result.data["keyValue"] = "";
            if (cmd == "查询")
            {
                if (!string.IsNullOrEmpty(keyName))
                {
                    if (!MemcachHelper.Exists(keyName))
                    {
                        result.backState = -100;
                        result.message   = "键值不存在";
                    }
                    else
                    {
                        result.data["keyValue"] = JsonConvert.SerializeObject(MemcachHelper.Get(keyName));
                        result.data["keyName"]  = keyName;
                        result.message          = "查询成功";
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(keyName))
                {
                    if (!MemcachHelper.Exists(keyName))
                    {
                        result.backState = -100;
                        result.message   = "键值不存在";
                    }
                    else
                    {
                        result.backState = -100;
                        MemcachHelper.Delete(keyName);
                        result.message = "删除成功";
                    }
                }
            }

            return(View(result));
        }
Beispiel #6
0
        public ActionResult TransferQuery()
        {
            //externalNo
            string externalNo             = TQuery.GetString("externalNo");
            respTransferQueryModel result = new respTransferQueryModel();

            if (string.IsNullOrEmpty(externalNo))
            {
                result.backState = -100;
                result.message   = "";
            }
            else
            {
                result = YeepayDepository.TransferQuery(externalNo, (int)Logic.Platform.系统);
            }
            return(View(result));
        }
Beispiel #7
0
        public ActionResult CheckDzero()
        {
            string tradeNo = TQuery.GetString("tradeNo");
            respModel <respCheckDzeroModel> result = new respModel <respCheckDzeroModel>();

            if (string.IsNullOrEmpty(tradeNo))
            {
                result.backState = -100;
                result.message   = "";
            }
            else
            {
                result = MiShuaDepository.CheckDzero(Convert.ToInt32(tradeNo), Utility.Const.Logic.Platform.系统);
            }

            return(View(result));
        }
Beispiel #8
0
        public string GetVipTypeIntroduce(int cid = 0, int VipType = 0)
        {
            if (VipType < 0)
            {
                return(ApiReturnStr.getError(-100, "参数错误"));
            }
            var version = TQuery.GetString("version");

            if (VipType == 1 && version == "1.0.0" && cid == 3)
            {
                VipType = 4;
            }

            int TypeId       = (int)Logic.KeyValueType.支付类型管理;
            var listKeyValue = MemcachHelper.Get <List <KeyValue> >(Constant.list_keyvalue_key + TypeId, DateTime.Now.AddDays(7), () =>
            {
                return(keyValueDao.GetQuery("typeid=@TypeId ", new { TypeId }, "order by Sort desc,CTime desc"));
            });

            Logic.VipType vip  = (Logic.VipType)VipType;
            JArray        list = new JArray();

            foreach (var item in listKeyValue)
            {
                JObject m       = JObject.Parse(item.Value);
                JObject data    = new JObject();
                int     PayType = m["PayType"].ToInt();
                data["PayName"] = m["PayName"].ToString();
                data["Quota"]   = m["Quota"].ToString();
                decimal[] r = Constant.GetRate(PayType, vip);
                data["Fee"] = $"{r[0].perCent()}+{r[1].ToString("F1")}元/笔";
                if (!(PayType == 1 && vip == Logic.VipType.顶级代理))//顶级代理隐藏无积分费率
                {
                    list.Add(data);
                }
            }
            return(ApiReturnStr.getApiDataList(list));
        }
Beispiel #9
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, "注册失败"));
            }
        }
Beispiel #10
0
        //腾付通  代付回调
        public string NoticeWithTeng()
        {
            string[] paramtersKey       = System.Web.HttpContext.Current.Request.Form.AllKeys;
            var      sortedParamtersKey = from s in paramtersKey
                                          orderby s ascending
                                          select s;
            StringBuilder str = new StringBuilder();

            str.Append("{");
            foreach (string key in sortedParamtersKey)
            {
                str.AppendFormat("\"{0}\":\"{1}\",", key, System.Web.HttpContext.Current.Request.Form[key].Trim());
            }
            if (str.Length > 0)
            {
                str.Remove(str.Length - 1, 1);//移除最后一个逗号
            }
            str.Append("}");

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + str.ToString(), "d:\\Log\\Teng", "NoticeWithTeng");

            lock (lockNoticeWithTeng)
            {
                string        result = "fail";
                respTengModel model  = new respTengModel();
                model.version  = TQuery.GetString("version");
                model.agentId  = TQuery.GetString("agentId");
                model.merId    = TQuery.GetString("merId");
                model.orderId  = TQuery.GetString("orderId");
                model.respCode = TQuery.GetString("respCode");
                model.respMsg  = TQuery.GetString("respMsg");
                model.sign     = TQuery.GetString("sign");

                //string json = "{\"agentId\":\"A1000000009\",\"merId\":\"1000000010\",\"orderId\":\"100001261\",\"respCode\":\"00\",\"respMsg\":\"成功\",\"sign\":\"C3735B3E932CA3335ED7258E9DB21524\",\"version\":\"1.0.0\"}";
                //model = JsonConvert.DeserializeObject<respTengModel>(json);
                bool flag = false;
                //返回后日志记录
                Logs.WriteLog("回调参数:" + JsonConvert.SerializeObject(model), "d:\\Log\\Teng", "NoticeWithTeng");
                yeepayLogParasDao.Init(Convert.ToInt32(model.orderId), JsonConvert.SerializeObject(model), 2);

                if (TengDepository.isSign(model))
                {
                    if (model.backState == 0)//处理成功
                    {
                        result = "SUCCESS";
                        var yeepayLog = yeepayLogDao.Single(Convert.ToInt32(model.orderId));
                        var pay       = payRecordDao.Single(yeepayLog.KeyId);
                        if (pay.State == 10)
                        {
                            Logs.WriteLog($"重复处理:State=10,orderId:{model.orderId},返回结果:{result}", "d:\\Log\\Teng", "NoticeWithTeng");
                            return(result);
                        }
                        pay.State      = 10;
                        pay.DrawState  = 10;
                        pay.UTime      = DateTime.Now;
                        pay.HandleTime = DateTime.Now;
                        flag           = payRecordDao.Update(pay);
                        Logs.WriteLog($"修改支付订单结果:flag={flag}", "d:\\Log\\Teng", "NoticeWithTeng");
                        //交易成功回调
                        UsersDepository.NoticeSuccess(pay.ID, pay.UserId);
                        yeepayLogDao.UpdateState(Convert.ToInt32(model.orderId), model.respCode, model.respMsg, 10);
                    }
                }
                else
                {
                    Logs.WriteLog($"签名比对失败:sign:{model.sign}", "d:\\Log\\Teng", "NoticeWithTeng");
                }
                Logs.WriteLog($"返回结果:{result}", "d:\\Log\\Teng", "NoticeWithTeng");
                return(result);
            }
        }
Beispiel #11
0
        //腾付通  支付回调
        public string NoticePayTeng()
        {
            string[] paramtersKey       = System.Web.HttpContext.Current.Request.Form.AllKeys;
            var      sortedParamtersKey = from s in paramtersKey
                                          orderby s ascending
                                          select s;
            StringBuilder str = new StringBuilder();

            str.Append("{");
            foreach (string key in sortedParamtersKey)
            {
                str.AppendFormat("\"{0}\":\"{1}\",", key, System.Web.HttpContext.Current.Request.Form[key].Trim());
            }
            if (str.Length > 0)
            {
                str.Remove(str.Length - 1, 1);//移除最后一个逗号
            }
            str.Append("}");

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + str.ToString(), "d:\\Log\\Teng", "NoticePayTeng");

            lock (lockNoticePayTeng)
            {
                string        result = "fail";
                respTengModel model  = new respTengModel();
                model.version  = TQuery.GetString("version");
                model.agentId  = TQuery.GetString("agentId");
                model.merId    = TQuery.GetString("merId");
                model.orderId  = TQuery.GetString("orderId");
                model.respCode = TQuery.GetString("respCode");
                model.respMsg  = TQuery.GetString("respMsg");
                model.sign     = TQuery.GetString("sign");
                bool flag = false;
                //返回后日志记录
                Logs.WriteLog("回调参数:" + JsonConvert.SerializeObject(model), "d:\\Log\\Teng", "NoticePayTeng");
                yeepayLogParasDao.Init(Convert.ToInt32(model.orderId), JsonConvert.SerializeObject(model), 2);


                if (TengDepository.isSign(model))
                {
                    if (model.backState == 0)//处理成功
                    {
                        result = "SUCCESS";
                        var yeepayLog = yeepayLogDao.Single(Convert.ToInt32(model.orderId));
                        var pay       = payRecordDao.Single(yeepayLog.KeyId);
                        if (pay.State == 5)
                        {
                            Logs.WriteLog($"重复处理:orderId:{model.orderId},返回结果:{result}", "d:\\Log\\Teng", "NoticePayTeng");
                            return(result);
                        }
                        flag = payRecordDao.UpdateState(yeepayLog.KeyId, 5, "支付成功,等待回调");
                        Logs.WriteLog($"修改订单状态:支付成功,等待回调,orderId:{model.orderId},flag:{flag}", "d:\\Log\\Teng", "NoticePayTeng");

                        yeepayLogDao.UpdateState(Convert.ToInt32(model.orderId), model.respCode, model.respMsg, 5);

                        //发起代付申请
                        var ret = ITOrm.Payment.Teng.TengDepository.DebitWithdraw(yeepayLog.ID, (int)Logic.Platform.系统);
                        Logs.WriteLog($"代付申请:json:{JsonConvert.SerializeObject(ret)}", "d:\\Log\\Teng", "NoticePayTeng");
                    }
                }
                else
                {
                    Logs.WriteLog($"签名比对失败:sign:{model.sign},orderId:{model.orderId}", "d:\\Log\\Teng", "NoticePayTeng");
                }
                Logs.WriteLog($"返回结果:{result}", "d:\\Log\\Teng", "NoticePayTeng");
                return(result);
            }
        }
Beispiel #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, "用户名或密码错误"));
        }
Beispiel #13
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
        }
Beispiel #14
0
        /// <summary>
        /// 子商户注册
        /// </summary>
        /// <param name="cid"></param>
        /// <param name="UserId"></param>
        /// <param name="IdCard">身份证号码</param>
        /// <param name="RealName">真实姓名</param>
        /// <param name="BankName">银行名称</param>
        /// <param name="BankAccountNumber">银行卡号码</param>
        /// <param name="AreaCode">地区编码</param>
        /// <param name="BankCardPhoto">银行卡照片</param>
        /// <param name="IdCardPhoto">身份证照片</param>
        /// <param name="IdCardBackPhoto">身份证背面照片</param>
        /// <param name="PersonPhoto">三合一照片</param>
        /// <returns></returns>
        public string Register(int cid = 0, int UserId = 0, string IdCard = "", string RealName = "", string BankName = "", string BankAccountNumber = "", string AreaCode = "", int BankCardPhoto = 0, int IdCardPhoto = 0, int IdCardBackPhoto = 0, int PersonPhoto = 0)
        {
            //Thread.Sleep(3000);
            //return ApiReturnStr.getError(-100, "注册失败,测试终点");

            Logs.WriteLog($"Register,cid:{cid},UserId:{UserId},IdCard:{IdCard},RealName:{RealName},BankName:{BankName},BankAccountNumber:{BankAccountNumber},AreaCode:{AreaCode},BankCardPhoto:{BankCardPhoto},IdCardPhoto:{IdCardPhoto},IdCardBackPhoto:{IdCardBackPhoto},PersonPhoto:{PersonPhoto}", "d:\\Log\\Yeepay", "Register");
            if (UserId == 100103)
            {
                Thread.Sleep(3000);
                Users m = userDao.Single(UserId);
                m.IsRealState = 1;
                m.RealName    = "啊啊啊";
                userDao.Update(m);
                return(ApiReturnStr.getError(0, "开户成功"));
            }
            #region 参数验证
            if (UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "UserId参数错误"));
            }
            if (!RegexHelper.IsMatch(RealName, @"^\s*[\u4e00-\u9fa5]{1,}[\u4e00-\u9fa5.·]{0,15}[\u4e00-\u9fa5]{1,}\s*$"))
            {
                return(ApiReturnStr.getError(-100, "请输入真实的姓名!"));
            }
            if (!TypeParse.IsIdentity(IdCard))
            {
                return(ApiReturnStr.getError(-100, "身份证号格式错误!"));
            }
            if (!TypeParse.IsChinese(BankName))
            {
                return(ApiReturnStr.getError(-100, "银行卡开户行有误"));
            }
            if (string.IsNullOrEmpty(BankAccountNumber) || !(BankAccountNumber.Length > 13 && BankAccountNumber.Length < 21))
            {
                return(ApiReturnStr.getError(-100, "银行卡卡号有误"));
            }
            if (!BankCardBindHelper.ValidateBank(BankName, BankAccountNumber))
            {
                return(ApiReturnStr.getError(-100, "银行卡卡bin识别失败"));
            }
            if (string.IsNullOrEmpty(AreaCode) || AreaCode.Length != 4)
            {
                return(ApiReturnStr.getError(-100, "请选择地区码"));
            }
            if (BankCardPhoto == 0)
            {
                return(ApiReturnStr.getError(-100, "银行卡正面照未上传"));
            }
            if (IdCardPhoto == 0)
            {
                return(ApiReturnStr.getError(-100, "身份证正面照未上传"));
            }
            if (IdCardBackPhoto == 0)
            {
                return(ApiReturnStr.getError(-100, "身份证背面照未上传"));
            }
            if (PersonPhoto == 0)
            {
                PersonPhoto = IdCardPhoto;                 //取消手持三合一
            }
            var user = userDao.Single(" IdCard=@IdCard  and IsRealState=1", new { IdCard });
            if (user != null && user.UserId > 0)
            {
                return(ApiReturnStr.getError(-100, "该身份证号码已认证"));
            }

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

            var cnt = yeepayLogDao.Count(string.Format("typeId={0} and UserId={1} and DateDiff(dd,CTime,getdate())=0 ", (int)YeepayType.子商户注册, UserId));
            if (cnt > 4)
            {
                return(ApiReturnStr.getError(-100, "当日开户次数超过5次,请次日再操作!"));
            }
            #endregion

            #region 组装子商户报文实体
            reqRegisterModel yeepayRegModel = new reqRegisterModel();
            yeepayRegModel.signedName        = RealName;
            yeepayRegModel.idCard            = IdCard;
            yeepayRegModel.bankAccountNumber = BankAccountNumber;
            yeepayRegModel.bankName          = BankName.ConvertBank();//转换易宝可识别的银行
            yeepayRegModel.areaCode          = AreaCode;

            #endregion
            //易宝子商户注册
            var result = YeepayDepository.Register(yeepayRegModel, UserId, cid, BankCardPhoto, IdCardPhoto, IdCardBackPhoto, PersonPhoto);
            //事件日志
            userEventDao.RealNameAuthentication(cid, UserId, Ip.GetClientIp(), IdCard, RealName, result.backState == 0 ? 1 : 0, TQuery.GetString("version"));
            return(ApiReturnStr.getError(result.backState, result.backState == 0 ? "开户成功" : result.message));
        }
Beispiel #15
0
        public string BankCardSubmitActivateCode(int cid = 0, int UserId = 0, int BankID = 0, int ChannelType = 0, string Code = "")
        {
            //Thread.Sleep(3000);
            //return ApiReturnStr.getError(-100, "开通失败,测试终点");
            var result = MasgetDepository.TreatyConfirm(BankID, Code, cid, (Logic.ChannelType)ChannelType);

            userEventDao.BankCardSubmitActivateCode(cid, UserId, Ip.GetClientIp(), result.backState == 0 ? 1 : 0, TQuery.GetString("version"), BankID, ChannelType, Code);
            return(ApiReturnStr.getError(result.backState == 0 ? 0 : -100, result.message));
        }
Beispiel #16
0
        public string BankCardActivate(int cid = 0, int UserId = 0, int BankID = 0, int ChannelType = 0)
        {
            userEventDao.BankCardActivate(cid, UserId, Ip.GetClientIp(), 0, TQuery.GetString("version"), BankID, ChannelType);
            Logic.ChannelType ct = (Logic.ChannelType)ChannelType;
            var ubk = userBankCardDao.Single(BankID);

            //Thread.Sleep(3000);
            //return ApiReturnStr.getError(0, "验证码发送成功");
            if (ubk == null)
            {
                return(ApiReturnStr.getError(-100, "银行卡不存在"));
            }
            if (ubk.UserId != UserId)
            {
                return(ApiReturnStr.getError(-100, "此卡不属于该用户"));
            }
            switch (ct)
            {
            case Logic.ChannelType.易宝:
                return(ApiReturnStr.getError(-100, "易宝通道无需激活"));

            case Logic.ChannelType.荣邦科技积分:
            case Logic.ChannelType.荣邦科技无积分:
            case Logic.ChannelType.荣邦3:
                //进件
                if (!masgetUserDao.QueryIsExist(UserId, ChannelType))
                {
                    var resultSubcompany = MasgetDepository.SubcompanyAdd(UserId, cid, ct);
                    if (resultSubcompany.backState != 0)
                    {
                        return(ApiReturnStr.getError(-100, $"开户失败({resultSubcompany.message},ct={ChannelType})"));
                    }
                }
                //入驻
                if (!masgetUserDao.QueryIsOpen(UserId, ChannelType))
                {
                    var resultSamenameOpen = MasgetDepository.SamenameOpen(UserId, cid, ct);
                    if (resultSamenameOpen.backState != 0)
                    {
                        return(ApiReturnStr.getError(-100, $"入驻失败({resultSamenameOpen.message},ct={ChannelType})"));
                    }
                }
                if (bankTreatyApplyDao.QueryTreatycodeIsOpen(BankID, ChannelType))
                {
                    return(ApiReturnStr.getError(-100, "此通道已开通快捷协议"));
                }
                //发送验证码
                var resultTreatyApply = MasgetDepository.TreatyApply(BankID, cid, ct);
                if (resultTreatyApply.backState != 0)
                {
                    return(ApiReturnStr.getError(-100, $"申请开通快捷协议失败({resultTreatyApply.message})"));
                }
                else
                {
                    return(ApiReturnStr.getError(0, "验证码发送成功"));
                }

            default:
                break;
            }
            return(ApiReturnStr.getError(-100, "参数错误"));
        }
Beispiel #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 ? "修改成功" : "修改失败"));
 }
Beispiel #18
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="forgetGuid"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public string UpdatePassword(int cid = 0, string forgetGuid = "", string password = "")
 {
     #region 验证
     if (forgetGuid.Length != 36)
     {
         return(ApiReturnStr.getError(-100, "验证令牌有误"));
     }
     if (password.Length != 32)
     {
         return(ApiReturnStr.getError(-100, "密码格式错误"));
     }
     string key = Constant.forget_token + forgetGuid;
     if (!MemcachHelper.Exists(key))
     {
         return(ApiReturnStr.getError(-100, "验证令牌过期,请重试!"));
     }
     JObject obj    = JObject.Parse(MemcachHelper.Get(key).ToString());
     string  mobile = obj["mobile"].ToString();
     Users   model  = userDao.Single(" mobile= @mobile ", new { mobile });
     if (model != null && model.UserId > 0)
     {
         model.Password = password;
         model.UTime    = DateTime.Now;
         var flag = userDao.Update(model);
         userEventDao.UserForget(cid, model.UserId, flag ? 1 : 0, Ip.GetClientIp(), key, password, TQuery.GetString("version")); //事件日志
         Logs.WriteLog(string.Format("Action:Forget,Cmd:UpdatePassword,UserId:{0},Mobile{1},forgetGuid:{2},State:{3}", model.UserId, mobile, forgetGuid, flag), "d:\\Log\\ITOrm", "ForgetUpdatePassword");
         MemcachHelper.Delete(key);                                                                                              //销毁令牌
         return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "修改成功" : "修改失败"));
     }
     #endregion
     Logs.WriteLog(string.Format("Action:Forget,Cmd:UpdatePassword,Mobile{0},forgetGuid:{1},用户不存在", mobile, forgetGuid), "d:\\Log\\ITOrm", "ForgetUpdatePassword");
     return(ApiReturnStr.getError(-100, "用户不存在"));
 }
Beispiel #19
0
        //易宝收款回调
        public string receiveApi()
        {
            string[] paramtersKey       = System.Web.HttpContext.Current.Request.Form.AllKeys;
            var      sortedParamtersKey = from s in paramtersKey
                                          orderby s ascending
                                          select s;
            StringBuilder str = new StringBuilder();

            str.Append("{");
            foreach (string key in sortedParamtersKey)
            {
                str.AppendFormat("\"{0}\":\"{1}\",", key, System.Web.HttpContext.Current.Request.Form[key].Trim());
            }
            if (str.Length > 0)
            {
                str.Remove(str.Length - 1, 1);//移除最后一个逗号
            }
            str.Append("}");

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + str.ToString(), "d:\\Log\\Yeepay", "ReceiveApiNotice");
            noticeReceiveApiModel model = new noticeReceiveApiModel();

            model.code           = TQuery.GetString("code");
            model.message        = TQuery.GetString("message");
            model.amount         = TQuery.GetString("amount");
            model.fee            = TQuery.GetString("fee");
            model.externalld     = TQuery.GetString("externalld");
            model.payerPhone     = TQuery.GetString("payerPhone");
            model.payerName      = TQuery.GetString("payerName");
            model.payTime        = TQuery.GetString("payTime");
            model.requestId      = TQuery.GetString("requestId");
            model.src            = TQuery.GetString("src");
            model.status         = TQuery.GetString("status");
            model.lastNo         = TQuery.GetString("lastNo");
            model.bankCode       = TQuery.GetString("bankCode");
            model.busiType       = TQuery.GetString("busiType");
            model.customerNumber = TQuery.GetString("customerNumber");
            model.createTime     = TQuery.GetString("createTime");
            model.hmac           = TQuery.GetString("hmac");
            //string json = "{\"requestId\":\"100000091\",\"customerNumber\":\"10019321635\",\"externalld\":\"661461948596449280\",\"createTime\":\"2018-02-24 15:49:19\",\"payTime\":\"2018-02-24 16:17:55\",\"amount\":\"100\",\"fee\":\"0.43\",\"status\":\"SUCCESS\",\"busiType\":\"COMMON\",\"bankCode\":\"CCB\",\"payerName\":\"刘*敏\",\"payerPhone\":\"185****6235\",\"lastNo\":\"625362******0286\",\"src\":\"B\",\"mainCustomerNumber\":null,\"hmac\":\"54a4145327a2db38e2ab7f0146eb2cea\",\"code\":\"0000\",\"message\":\"成功\",\"backState\":0}";
            //model = JsonConvert.DeserializeObject<noticeReceiveApiModel>(json);
            lock (lockReceiveApi)
            {
                string result = "fail";
                bool   flag   = false;
                //返回后日志记录
                Logs.WriteLog("回调参数:" + JsonConvert.SerializeObject(model), "d:\\Log\\Yeepay", "ReceiveApiNotice");
                yeepayLogParasDao.Init(Convert.ToInt32(model.requestId), JsonConvert.SerializeObject(model), 2);


                //签名验证
                StringBuilder sb = new StringBuilder();
                sb.Append(model.code);
                sb.Append(model.message);
                sb.Append(model.requestId);
                sb.Append(model.customerNumber);
                sb.Append(model.externalld);
                sb.Append(model.createTime);
                sb.Append(model.payTime);
                sb.Append(model.amount);
                sb.Append(model.fee);
                sb.Append(model.status);
                sb.Append(model.busiType);
                sb.Append(model.bankCode);
                sb.Append(model.payerName);
                sb.Append(model.payerPhone);
                sb.Append(model.lastNo);
                sb.Append(model.src);

                string sign = ITOrm.Utility.Encryption.EncryptionHelper.HMACMD5(ITOrm.Payment.Yeepay.YeepayDepository.YeepayHmacKey, sb.ToString());
                if (model.hmac != sign)
                {
                    Logs.WriteLog($"签名比对失败:mac:{model.hmac},sign:{sign}", "d:\\Log\\Yeepay", "ReceiveApiNotice");
                    return(result);
                }
                //更新
                yeepayLogDao.UpdateState(Convert.ToInt32(model.requestId), model.code, model.message, (model.backState == 0 && model.status == "SUCCESS") ? 10 : -1);

                if (model.backState == 0 && model.status == "SUCCESS")//成功
                {
                    var yeepayLog = yeepayLogDao.Single(Convert.ToInt32(model.requestId));
                    var payRecord = payRecordDao.Single(yeepayLog.KeyId);
                    if (payRecord.State == 10)
                    {
                        result = "SUCCESS";
                        Logs.WriteLog($"重复处理:{result},payRecord.State == 10", "d:\\Log\\Yeepay", "ReceiveApiNotice");
                        return(result);
                    }
                    //修改订单信息
                    payRecord.PayTime = Convert.ToDateTime(model.payTime);
                    payRecord.State   = 10;
                    //payRecord.PayerPhone = model.payerPhone;
                    //payRecord.PayerName = model.payerName;
                    payRecord.LastNo  = model.lastNo;
                    payRecord.Message = model.message;
                    payRecord.Fee     = Convert.ToDecimal(model.fee);
                    payRecord.Src     = model.src;
                    flag = payRecordDao.Update(payRecord);
                    Logs.WriteLog($"修改订单信息:flag={flag}", "d:\\Log\\Yeepay", "ReceiveApiNotice");
                    ////添加支付银行卡
                    //int ubkCnt = userBankCardDao.Count(" UserId=@UserId and TypeId=1 and State=1 and  BankCard=@BankCard ", new { payRecord.UserId, payRecord.BankCard });
                    //Logs.WriteLog($"支付银行卡个数:ubkCnt:{ubkCnt}", "d:\\Log\\Yeepay", "ReceiveApiNotice");
                    //if (ubkCnt == 0)
                    //{
                    //    UserBankCard ubk = new UserBankCard();
                    //    ubk.BankCard = payRecord.BankCard;
                    //    ubk.TypeId = 1;
                    //    ubk.State = 1;
                    //    ubk.UserId = payRecord.UserId;
                    //    ubk.Mobile = model.payerPhone;
                    //    ubk.IP = ITOrm.Utility.Client.Ip.GetClientIp();
                    //    ubk.Platform = 1;
                    //    ubk.BankCode = model.bankCode;
                    //    int ubkId= userBankCardDao.Insert(ubk);
                    //    Logs.WriteLog($"支付银行卡添加Id:ubkId:{ubkId}", "d:\\Log\\Yeepay", "ReceiveApiNotice");
                    //}
                    if (flag)
                    {
                        result = "SUCCESS";
                    }
                }
                Logs.WriteLog($"返回结果:{result}", "d:\\Log\\Yeepay", "ReceiveApiNotice");
                return(result);
            }
        }
Beispiel #20
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));
        }
Beispiel #21
0
        //荣邦科技  支付回调
        public string backpayNotice()
        {
            string[] paramtersKey       = System.Web.HttpContext.Current.Request.Form.AllKeys;
            var      sortedParamtersKey = from s in paramtersKey
                                          orderby s ascending
                                          select s;
            StringBuilder str = new StringBuilder();

            str.Append("{");
            foreach (string key in sortedParamtersKey)
            {
                str.AppendFormat("\"{0}\":\"{1}\",", key, System.Web.HttpContext.Current.Request.Form[key].Trim());
            }
            if (str.Length > 0)
            {
                str.Remove(str.Length - 1, 1);//移除最后一个逗号
            }
            str.Append("}");

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + str.ToString(), "d:\\Log\\Masget", "backpayNotice");


            bool flag = false;


            //string json= "{\"Appid\":\"402862423\",\"Data\":\"5JuUVmDLj4r9d-7FhjaEn1LtxEUAdBv3Aco2lYdyOhzPEWt-ZFCPe8vHFDaPvrc8AG4s0cH1lJ393A1aSWCRTTGEp5rDl0aYCp2ijBlN_jyAp8HwEDdYpGyKE5PkO8XGLmjbPPyj3zLXVNuHvgHuhTRiQ5pNgNTj6ZG2vSqsmednikP5MOEo4HBQX_mTMpzi_P_fnTFHfK4MlVmPamHqxdG1uOeu2vLPJjVB01crohdtiEBU-ZE6WHsRwmgxVPrcUdWCSzsipukK4Ebgfzz34F8d4ZBcOnR0aNz7_ZB-xDLK66yNBnhI7V6fY-Pg_oaqK13Cc9tJYssbzqPX4S5Ek29KX4lous7BCyjvYYJmp_3MTbDU0Sq1t_A8IMUeNI8K4iHyubHYnS2-vclmwIY0_YnYqOSuZASS12juzDR_nDyFzf_k5iWbMQ_E6vEoGTz0Vmq-r93rDZkpcXeS2TRYjnkZNXSRvihdqL3ZA4BtCt9uRDQ02E3hemJDetnCGAYRfm8d_yoHQhc_GNcIXA_MQt-lzVT2Cp1Qj2kPDBxjZyVm7SlL_ticf44MvitGpxxueDOywcJkV0Az0iVyWsjuAXDJovBaoSCA-AZAi35jYcV3_O0hv1Qne9juWhDm7JKh_OGEP2qVf8MfgNDNB8yOXK258UMoEfQEfzk5uQT3txjmq75BqpwEXrpA44AjEBTpxSvbIYID-crcBrYbhHpzP3X1zMJXh3TeAerTC-QigIx4u6FdDMXyzFD9PpyFft2kixCnf1P0xL1azAYRlD6H7UmgJC-wfZR-eFR3_hrbC8RymD8AVdwiJGzSikPERAIXcQbF760M4qIfATg71WC6lirRuL-wRrFwCtbrcurzHxp95kUMSlF1UH0XI5p7S6GZ\",\"Method\":\"paymentreport\",\"Sign\":\"b6609c9bf0b74b23249a733c9dd2524e\"}";
            //JObject data = JObject.Parse(json);
            //string Secretkey = "dxn47a9egzljq3pw";
            //string AesD = ITOrm.Payment.Masget.AES.Decrypt(data["Data"].ToString(), Secretkey, Secretkey);
            //string lastSign =$"{data["Data"].ToString()}{Secretkey}";
            //string sign = SecurityHelper.GetMD5String(lastSign);

            lock (lockbackpayNotice)
            {
                noticeMasgetModel <noticePayConfirmpayModel> notice = new noticeMasgetModel <noticePayConfirmpayModel>();
                notice.Appid  = TQuery.GetString("Appid");
                notice.Data   = TQuery.GetString("Data");
                notice.Sign   = TQuery.GetString("Sign");
                notice.Method = TQuery.GetString("Method");

                //notice = JsonConvert.DeserializeObject<noticeMasgetModel<noticePayConfirmpayModel>>(json);
                JObject respNotice = new JObject();
                respNotice["response"] = "00";
                respNotice["message"]  = "成功";

                Logs.WriteLog($"参数序列化记录:{JsonConvert.SerializeObject(notice)}", "d:\\Log\\Masget", "backpayNotice");

                if (notice.IsSign)
                {
                    if (notice.dataExpress != null && notice.dataExpress.respcode == "2" && notice.Method == "paymentreport")
                    {
                        //支付成功
                        int requestId = Convert.ToInt32(notice.dataExpress.ordernumber);
                        var yeepayLog = yeepayLogDao.Single(requestId);

                        if (yeepayLog.State == 10)
                        {
                            Logs.WriteLog($"重复处理:requestId:{requestId},payRecord.State == 10,返回数据:{respNotice.ToString()}", "d:\\Log\\Masget", "backpayNotice");
                            return(respNotice.ToString());
                        }
                        yeepayLogParasDao.Init(requestId, JsonConvert.SerializeObject(notice), 2);
                        Logs.WriteLog($"记录日志:requestId:{requestId},notice:{JsonConvert.SerializeObject(notice)}", "d:\\Log\\Masget", "backpayNotice");

                        //更新
                        yeepayLogDao.UpdateState(requestId, notice.dataExpress.respcode, notice.dataExpress.respmsg, (notice.dataExpress.respcode == "2") ? 10 : -1);
                        Logs.WriteLog($"更新日志:requestId:{requestId},respmsg:{notice.dataExpress.respmsg}", "d:\\Log\\Masget", "backpayNotice");


                        int payRecordId = yeepayLog.KeyId;
                        var payRecord   = payRecordDao.Single(payRecordId);
                        payRecord.State      = 10;
                        payRecord.DrawState  = 10;
                        payRecord.Message    = "支付成功";
                        payRecord.HandleTime = Convert.ToDateTime(notice.dataExpress.businesstime);
                        flag = payRecordDao.Update(payRecord);
                        //更新支付记录
                        Logs.WriteLog($"更新支付记录:requestId:{requestId},payRecordId:{payRecordId},flag:{flag}", "d:\\Log\\Masget", "backpayNotice");
                        //交易成功回调
                        UsersDepository.NoticeSuccess(payRecord.ID, payRecord.UserId);
                    }
                    else
                    {
                        Logs.WriteLog($"其他错误:appid:{notice.Appid},Method:{notice.Method}", "d:\\Log\\Masget", "backpayNotice");
                        respNotice["response"] = "99";
                        respNotice["message"]  = "其他错误";
                    }
                }
                else//签名失败
                {
                    Logs.WriteLog($"签名比对失败:appid:{notice.Appid},Method:{notice.Method},sign:{notice.Sign},sysSign:{notice.sysSign}", "d:\\Log\\Masget", "backpayNotice");
                    respNotice["response"] = "99";
                    respNotice["message"]  = "签名比对失败";
                }
                Logs.WriteLog($"返回数据:{respNotice.ToString()}", "d:\\Log\\Masget", "backpayNotice");
                return(respNotice.ToString());
            }
        }
Beispiel #22
0
        // 易宝结算回调
        public string withDrawApi()
        {
            string[] paramtersKey       = System.Web.HttpContext.Current.Request.Form.AllKeys;
            var      sortedParamtersKey = from s in paramtersKey
                                          orderby s ascending
                                          select s;
            StringBuilder str = new StringBuilder();

            str.Append("{");
            foreach (string key in sortedParamtersKey)
            {
                str.AppendFormat("\"{0}\":\"{1}\",", key, System.Web.HttpContext.Current.Request.Form[key].Trim());
            }
            if (str.Length > 0)
            {
                str.Remove(str.Length - 1, 1);//移除最后一个逗号
            }
            str.Append("}");

            //返回后日志记录
            Logs.WriteLog("页面首次记录:" + str.ToString(), "d:\\Log\\Yeepay", "WithDrawApiNotice");


            noticeWithDrawApiModel model = new noticeWithDrawApiModel();

            model.mainCustomerNumber = TQuery.GetString("mainCustomerNumber");
            model.externalNo         = TQuery.GetString("externalNo");
            model.customerNumber     = TQuery.GetString("customerNumber");
            model.serialNo           = TQuery.GetString("serialNo");
            model.transferStatus     = TQuery.GetString("transferStatus");
            model.requestTime        = TQuery.GetString("requestTime");
            model.handleTime         = TQuery.GetString("handleTime");
            model.transferWay        = TQuery.GetString("transferWay");
            model.receiver           = TQuery.GetString("receiver");
            model.receiverBankCardNo = TQuery.GetString("receiverBankCardNo");
            model.receiverBank       = TQuery.GetString("receiverBank");
            model.amount             = TQuery.GetString("amount");
            model.fee          = TQuery.GetString("fee");
            model.basicFee     = TQuery.GetString("basicFee");
            model.exTargetFee  = TQuery.GetString("exTargetFee");
            model.actualAmount = TQuery.GetString("actualAmount");
            model.failReason   = TQuery.GetString("failReason");
            model.hmac         = TQuery.GetString("hmac");
            model.code         = TQuery.GetString("code");
            model.message      = TQuery.GetString("message");
            //string json = "{\"actualAmount\":\"98.62\",\"amount\":\"99.62\",\"basicFee\":\"1.0\",\"customerNumber\":\"10019642647\",\"exTargetFee\":\"0.0\",\"externalNo\":\"100000178\",\"failReason\":\"\",\"fee\":\"0\",\"handleTime\":\"2018-03-07 17:18:39\",\"hmac\":\"8200ea9ccdf38d43a0e0ba9606bb504a\",\"mainCustomerNumber\":\"10018708270\",\"receiver\":\"渠*树\",\"receiverBank\":\"中国银行\",\"receiverBankCardNo\":\"621790*********6547\",\"requestTime\":\"2018-03-07 17:18:38\",\"serialNo\":\"SKBRJT325245e2492a4fdfad9066b89a0ef4a9\",\"transferStatus\":\"SUCCESSED\",\"transferWay\":\"1\"}";
            //string json = "{\"actualAmount\":\"175.23\",\"amount\":\"177.23\",\"basicFee\":\"2.0\",\"customerNumber\":\"10020136223\",\"exTargetFee\":\"0.0\",\"externalNo\":\"100000245\",\"failReason\":\"\",\"fee\":\"0\",\"handleTime\":\"2018-03-13 15:01:57\",\"hmac\":\"bbed9dfa537fef9658d27f1e444c210c\",\"mainCustomerNumber\":\"10018708270\",\"receiver\":\"王*凯\",\"receiverBank\":\"中国银行\",\"receiverBankCardNo\":\"621790*********9332\",\"requestTime\":\"2018-03-13 15:01:54\",\"serialNo\":\"SKBRJTa4ce8f5595c54e47a12a939f1202a680\",\"transferStatus\":\"SUCCESSED\",\"transferWay\":\"1\"}";
            //string json = "{\"actualAmount\":\"103.6\",\"amount\":\"104.6\",\"basicFee\":\"1.0\",\"customerNumber\":\"10020136223\",\"exTargetFee\":\"0.0\",\"externalNo\":\"100000233\",\"failReason\":\"\",\"fee\":\"0\",\"handleTime\":\"2018-03-12 22:32:14\",\"hmac\":\"b5a06307c9e40dffe7b697ea20045406\",\"mainCustomerNumber\":\"10018708270\",\"receiver\":\"王*凯\",\"receiverBank\":\"中国银行\",\"receiverBankCardNo\":\"621790*********9332\",\"requestTime\":\"2018-03-12 22:32:14\",\"serialNo\":\"SKBRJT7262630296714a8191468c61d4235399\",\"transferStatus\":\"SUCCESSED\",\"transferWay\":\"1\"}";
            //model = JsonConvert.DeserializeObject<noticeWithDrawApiModel>(json);

            lock (lockWithDrawApi)
            {
                bool   flag   = false;
                string result = "fail";
                //返回后日志记录
                Logs.WriteLog("回调参数:" + JsonConvert.SerializeObject(model), "d:\\Log\\Yeepay", "WithDrawApiNotice");

                //签名验证
                StringBuilder sb = new StringBuilder();
                sb.Append(model.mainCustomerNumber);
                sb.Append(model.customerNumber);
                sb.Append(model.externalNo);
                sb.Append(model.serialNo);
                sb.Append(model.transferStatus);
                sb.Append(model.requestTime);
                sb.Append(model.handleTime);
                sb.Append(model.transferWay);
                sb.Append(model.receiver);
                sb.Append(model.receiverBankCardNo);
                sb.Append(model.receiverBank);
                sb.Append(model.amount);
                sb.Append(model.fee);
                sb.Append(model.basicFee);
                sb.Append(model.exTargetFee);
                sb.Append(model.actualAmount);
                sb.Append(model.failReason);

                string sign = ITOrm.Utility.Encryption.EncryptionHelper.HMACMD5(ITOrm.Payment.Yeepay.YeepayDepository.YeepayHmacKey, sb.ToString());
                if (model.hmac != sign)
                {
                    Logs.WriteLog($"签名比对失败:mac:{model.hmac},sign:{sign}", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                    return(result);
                }

                yeepayLogParasDao.Init(Convert.ToInt32(model.externalNo), JsonConvert.SerializeObject(model), 2);

                int state = -1;
                switch (model.transferStatus)
                {
                case "SUCCESSED":
                    state = 10;
                    break;

                case "RECEIVED":
                    state = 1;
                    break;

                case "PROCESSING":
                    state = 2;
                    break;

                case "FAILED":
                    state = -1;
                    break;

                case "REFUNED":
                    state = -2;
                    break;

                case "CANCELLED":
                    state = -3;
                    break;

                default:
                    state = -4;
                    break;
                }
                //更新
                yeepayLogDao.UpdateState(Convert.ToInt32(model.externalNo), model.transferStatus == "SUCCESSED" ? "0000" : "9999", model.failReason, state);
                var yeepayLog = yeepayLogDao.Single(Convert.ToInt32(model.externalNo));
                var draw      = withDrawDao.Single(yeepayLog.KeyId);
                var pay       = payRecordDao.Single(draw.PayId);
                if (draw.State == 10)
                {
                    result = "SUCCESS";
                    Logs.WriteLog($"重复处理 :{result},draw.State ==10", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                    return(result);
                }


                //修改订单信息
                draw.UTime    = DateTime.Now;
                draw.State    = state;
                draw.Message  = model.failReason;
                pay.DrawState = state;
                if (state == 10)
                {
                    draw.HandleTime         = Convert.ToDateTime(model.handleTime);
                    draw.Receiver           = model.receiver;
                    draw.ReceiverBankCardNo = model.receiverBankCardNo;
                    draw.ReceiverBank       = model.receiverBank;
                    draw.Fee          = Convert.ToDecimal(model.fee);
                    draw.BasicFee     = Convert.ToDecimal(model.basicFee);
                    draw.ExTargetFee  = Convert.ToDecimal(model.exTargetFee);
                    draw.ActualAmount = Convert.ToDecimal(model.actualAmount);
                    pay.HandleTime    = draw.HandleTime;
                    //pay.DrawBankCard = draw.ReceiverBankCardNo;
                }
                flag = withDrawDao.Update(draw);
                Logs.WriteLog($"结算订单修改:flag:{flag},transferStatus:{model.transferStatus},state:{state}", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                flag = payRecordDao.Update(pay);
                Logs.WriteLog($"支付订单修改:flag:{flag},transferStatus:{model.transferStatus},state:{state}", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                if (pay.State == 10)
                {
                    //交易成功回调
                    UsersDepository.NoticeSuccess(pay.ID, pay.UserId);
                }
                if (flag)
                {
                    result = "SUCCESS";
                }
                Logs.WriteLog($"返回结果:{result}", "d:\\Log\\Yeepay", "WithDrawApiNotice");
                return(result);
            }
        }
Beispiel #23
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="cid"></param>
        /// <param name="UserId"></param>
        /// <param name="oldPwd"></param>
        /// <param name="newPwd"></param>
        /// <returns></returns>
        public string UpdatePassword(int cid = 0, int UserId = 0, string oldPwd = "", string newPwd = "")
        {
            Logs.WriteLog($"Action:User,Cmd:UpdatePassword,UserId:{UserId},oldPwd{oldPwd},newPwd:{oldPwd}", "d:\\Log\\ITOrm", "UserUpdatePassword");
            if (oldPwd.Length != 32 || newPwd.Length != 32 || UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "参数错误"));
            }

            Users model = userDao.Single(UserId);

            if (model == null || model.UserId < 0)
            {
                return(ApiReturnStr.getError(-100, "用户不存在"));
            }
            if (model.Password != oldPwd)
            {
                return(ApiReturnStr.getError(-100, "旧密码与原密码不一致"));
            }
            if (oldPwd == newPwd)
            {
                return(ApiReturnStr.getError(-100, "旧密码与新密码一致"));
            }
            model.Password = newPwd;
            model.UTime    = DateTime.Now;;
            bool flag = userDao.Update(model);

            userEventDao.UserUpdatePassword(cid, UserId, Ip.GetClientIp(), oldPwd, newPwd, flag ? 1 : 0, TQuery.GetString("version"));//事件日志
            Logs.WriteLog($"Action:User,Cmd:UpdatePassword,UserId:{UserId},oldPwd{oldPwd},newPwd:{newPwd},State:{flag}", "d:\\Log\\ITOrm", "UserUpdatePassword");
            return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "修改成功" : "修改失败"));
        }