/// <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 ? "修改成功" : "修改失败")); }
public string asdfs() { UserEventRecordBLL userEventDao = new UserEventRecordBLL(); bool num = userEventDao.RealNameAuthentication(0, 100000, Ip.GetClientIp(), "511112199101312410", "陈鑫", 0); return(num.ToString()); }
/// <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)); }
public static ResultModelData <JObject> CreatePayCashier(int UserId, int Platform, decimal Amount, int UbkId) { string LogDic = "生成收银台"; bool flag = false; //获得支付ID int keyId = payRecordDao.Init(UbkId, Amount, Platform, Ip.GetClientIp(), (int)Logic.ChannelType.腾付通); //获取请求流水号 int requestId = yeepayLogDao.Init((int)Teng.Enums.TengType.生成收银台, UserId, Platform, keyId, (int)Logic.ChannelType.腾付通); Logs.WriteLog($"获取请求流水号:UserId:{UserId},Platform:{Platform},requestId:{requestId}", TengLogDic, LogDic); //生成收银台 var payCId = payCashierDao.Init((int)Logic.ChannelType.腾付通, requestId, UbkId, UserId, keyId); ResultModelData <JObject> resp = new ResultModelData <JObject>(); resp.backState = 0; resp.message = "请求成功"; JObject data = new JObject(); data["url"] = $"{Constant.CurrentApiHost}itapi/pay/tengcashier?payid={payCId}"; resp.Data = data; if (payCId > 0) { #region 日志处理 //返回后日志记录 yeepayLogParasDao.Init(requestId, JsonConvert.SerializeObject(resp), 1); //易宝日志状态更新 flag = yeepayLogDao.UpdateState(requestId, resp.backState.ToString(), resp.message, resp.backState == 0 ? 1 : resp.backState); #endregion } return(resp); }
/// <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, "用户不存在")); }
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)); }
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, "上传图片失败,请稍后再试。")); } }
public static respModel <respPayDzeroModel> PayDzero(int UbkId, int Platform, decimal Amount) { string LogDic = "无卡支付接口"; Logic.ChannelType channel = Logic.ChannelType.米刷; var ubk = userBankCardDao.Single(UbkId); var withBank = userBankCardDao.Single(" TypeId=0 and UserId=@UserId ", new { ubk.UserId }); var user = usersDao.Single(ubk.UserId); //获取请求流水号 int keyId = payRecordDao.Init(UbkId, Amount, Platform, Ip.GetClientIp(), (int)channel); //int keyId = payRecordDao.Init(bta.UserId, Amount, Platform, Ip.GetClientIp(), bta.BankCard); Logs.WriteLog($"创建支付记录:UserId:{ubk.UserId},Platform:{Platform},keyId:{keyId},Amount={Amount}", MiShuaLogDic, LogDic); int requestId = yeepayLogDao.Init((int)MiShua.Enums.MiShuaType.无卡支付接口, ubk.UserId, Platform, keyId, (int)channel); Logs.WriteLog($"获取请求流水号:UserId:{ubk.UserId},Platform:{Platform},requestId:{requestId},keyId:{keyId}", MiShuaLogDic, LogDic); //reqModel model = new reqModel(); //model.mchNo = mchNo; //model. reqPayDzeroModel model = new reqPayDzeroModel(); model.versionNo = "1"; model.mchNo = mchNo; model.price = Amount.ToString("F2"); model.description = "SJ商品"; model.orderDate = DateTime.Now.ToString("yyyyMMddHHmmss"); model.tradeNo = requestId.ToString(); model.notifyUrl = noticeUrl + "MiShuaNotice"; model.callbackUrl = ITOrm.Utility.Const.Constant.CurrentApiHost + "itapi/pay/success?backState=0&message=支付成功";; model.payCardNo = ubk.BankCard; model.userToken = ubk.Mobile; model.accTel = withBank.Mobile; model.accName = user.RealName; model.accIdCard = user.IdCard; model.bankName = withBank.BankName; var bank = bankDao.Single("BankName=@BankName", new { withBank.BankName }); model.bankCode = bank.UnionCode; model.cardNo = withBank.BankCard; decimal[] r = Constant.GetRate(0, (Logic.VipType)user.VipType); model.downPayFee = (r[0] * 1000M).ToString("F1"); model.downDrawFee = r[1].ToString("F2"); return(Post <respPayDzeroModel>(requestId, "payDzero", JObject.FromObject(model), LogDic)); }
public ActionResult QRcode(int cid, int UserId, string version) { string url = Constant.CurrentApiHost + "itapi/invite/reg?u=" + ITOrm.Utility.Encryption.AESEncrypter.AESEncrypt(UserId.ToString(), Constant.SystemAESKey); //url = "http://api.sujintech.com/itapi/invite/reg?u=" + ITOrm.Utility.Encryption.AESEncrypter.AESEncrypt(UserId.ToString(), Constant.SystemAESKey);; //用户事件 userEventDao.UserEventInit(cid, UserId, Ip.GetClientIp(), 1, "Profit", "QRcode", $"{{UserId:{UserId},version:{version}}}"); var bytes = QrCodeHelper.Instance.QrCodeCreate(url); return(File(bytes, @"image/jpeg")); }
public ActionResult Cashier(int payid, string code) { var payCashier = payCashierDao.Single(payid); respBackPayModel model = JsonConvert.DeserializeObject <respBackPayModel>(payCashier.Value); UserBankCard ubk = userBankCardDao.Single(payCashier.UbkId); JObject data = new JObject(); data["respBackPay"] = JObject.FromObject(model); data["ubk"] = JObject.FromObject(ubk); ResultModel result = new ResultModel(data); if (!ITOrm.Utility.StringHelper.TypeParse.IsNumeric(code)) { result.backState = -100; result.message = "验证码必须为数字"; return(View(result)); } if (payCashier.State == 1) { result.backState = -200; result.message = "订单已支付完成"; return(View(result)); } else if (payCashier.State == -1) { result.backState = -200; result.message = "订单已过期"; return(View(result)); } var payResult = MasgetDepository.PayConfirmpay(payid, code, (int)Logic.Platform.系统, (Logic.ChannelType)payCashier.ChannelType); userEventDao.UserEventInit((int)Logic.Platform.系统, payCashier.UserId, Ip.GetClientIp(), payResult.backState == 0 ? 1 : 0, "Pay", "Cashier", $"{{payid:{payid},code:{code}}}"); if (payResult.backState == 0) { result.backState = -200; result.message = "支付成功"; return(new RedirectResult("/itapi/pay/success?backState=0&message=支付成功")); } else { result.backState = -100; result.message = payResult.message; return(View(result)); } }
public string AvatarImg(int cid = 0, int UserId = 0, int ImgId = 0) { if (cid == 0 || UserId == 0 || ImgId == 0) { return(ApiReturnStr.getError(-100, "参数有误")); } var user = userDao.Single(UserId); user.AvatarImg = ImgId; user.UTime = DateTime.Now; bool flag = userDao.Update(user); bool flag2 = userImageDao.UpdateState(ImgId, 1); userEventDao.UserEventInit(cid, UserId, Ip.GetClientIp(), flag && flag2 ? 1 : 0, "Users", "AvatarImg", $"{{ImgId:{ImgId},flag:{flag},flag2:{flag2}}}"); return(ApiReturnStr.getError(flag && flag2 ? 0 : -100, flag && flag2 ? "设置成功" : "设置失败")); }
/// <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, "用户名或密码错误")); }
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 ? "修改成功" : "修改失败")); }
//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)); }
/// <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)); }
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, "上传图片失败,请稍后再试。")); } }
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, "参数错误")); }
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 }
public static respMasgetModel <respBackPayModel> BackPay(int UbkId, decimal Amount, int Platform, Logic.ChannelType chanel) { string LogDic = "订单支付"; int TypeId = (int)chanel; BankTreatyApply bta = bankTreatyApplyDao.Single(" UbkId=@UbkId and ChannelType=@TypeId", new { UbkId, TypeId }); MasgetUser mUser = masgetUserDao.Single(" UserId=@UserId and TypeId=@TypeId", new { bta.UserId, TypeId }); if (mUser == null) { Logs.WriteLog($"未查到用户:UserId:{bta.UserId},Platform:{Platform},BtaId:{bta.ID}", MasgetLogDic, LogDic); return(new respMasgetModel <respBackPayModel>() { ret = -9999, message = "用户未进件" }); } Users user = usersDao.Single(bta.UserId); bool flag = false; //获取请求流水号 int keyId = payRecordDao.Init(UbkId, Amount, Platform, Ip.GetClientIp(), (int)chanel); //int keyId = payRecordDao.Init(bta.UserId, Amount, Platform, Ip.GetClientIp(), bta.BankCard); Logs.WriteLog($"创建支付记录:UserId:{bta.UserId},Platform:{Platform},keyId:{keyId},Amount={Amount}", MasgetLogDic, LogDic); int requestId = yeepayLogDao.Init((int)Masget.Enums.MasgetType.订单支付, bta.UserId, Platform, keyId, (int)chanel); Logs.WriteLog($"获取请求流水号:UserId:{bta.UserId},Platform:{Platform},requestId:{requestId},keyId:{keyId}", MasgetLogDic, LogDic); reqBackPayModel model = new reqBackPayModel(); model.ordernumber = requestId.ToString(); model.body = "SJ商品购买"; model.amount = (Amount * 100).ToString("F0"); model.businesstype = "1001"; model.paymenttypeid = "25"; model.backurl = MasgetNoticeUrl + "backpayNotice"; var ext = new PayExtraParamsModel(); ext.password = ""; ext.authcode = ""; ext.treatycode = bta.Treatycode; model.payextraparams = Order <PayExtraParamsModel>(ext); //model.accountrule = "1"; string json = Order <reqBackPayModel>(model); var resp = PostUrl <respBackPayModel>(requestId, "masget.pay.compay.router.back.pay", json, LogDic, chanel, mUser.ID); if (resp.backState == 0) { //添加收银记录表 PayCashier payCash = new PayCashier(); payCash.ChannelType = (int)chanel; payCash.Value = JsonConvert.SerializeObject(resp.data); payCash.LogId = requestId; payCash.State = 0; payCash.UserId = bta.UserId; payCash.PayRecordId = keyId; payCash.UbkId = UbkId; int payCId = payCashierDao.Insert(payCash); Logs.WriteLog($"添加收银记录表:UserId:{bta.UserId},Platform:{Platform},requestId:{requestId},payCId:{payCId}", MasgetLogDic, LogDic); resp.url = $"{Constant.CurrentApiHost}itapi/pay/cashier?payid={payCId}"; } return(resp); }
public ActionResult TengCashier(int payid, string tengGuid, string code) { var payCashier = payCashierDao.Single(payid); var pay = payRecordDao.Single(payCashier.PayRecordId); var ubk = userBankCardDao.Single(payCashier.UbkId); JObject data = new JObject(); data["amount"] = pay.Amount.ToString("F2"); data["ordernumber"] = payCashier.LogId; data["BankCode"] = ubk.BankCode; data["BankName"] = ubk.BankName; data["BankCard"] = ubk.BankCard; data["Mobile"] = ITOrm.Utility.StringHelper.Util.GetHiddenString(ubk.Mobile, 3, 4); ResultModel result = new ResultModel(data); if (!ITOrm.Utility.StringHelper.TypeParse.IsNumeric(code)) { result.backState = -100; result.message = "验证码必须为数字"; return(View(result)); } if (tengGuid.Length != 36) { result.backState = -100; result.message = "未获取短信"; return(View(result)); } if (payCashier.State == 1) { result.backState = -200; result.message = "订单已支付完成"; return(View(result)); } else if (payCashier.State == -1) { result.backState = -200; result.message = "订单已过期"; return(View(result)); } var validResult = TengDepository.ValidateMobileCode(payid, (int)Logic.Platform.系统, tengGuid, code); if (validResult.backState == 0)//短信验证成功 { //respTengModel payResult = new respTengModel(); //payResult.respCode = "00"; //payResult.respMsg = "支付成功"; var payResult = TengDepository.DebitPayment(payid, (int)Logic.Platform.系统); //var payResult = JsonConvert.DeserializeObject<respTengModel>("{\"respCode\":\"E99999\",\"respMsg\":\"支付卡已超过有效期\",\"sign\":\"B231ED5797458C3D02374D14317E59EA\"}"); userEventDao.UserEventInit((int)Logic.Platform.系统, payCashier.UserId, Ip.GetClientIp(), payResult.backState == 0 ? 1 : 0, "Pay", "TengCashier", $"{{payid:{payid},code:{code},tengGuid:{tengGuid}}}"); if (payResult.backState == 0)//支付成功 { result.backState = 0; result.message = "支付成功"; return(new RedirectResult("/itapi/pay/success?backState=0&message=支付成功")); } result.backState = -100; result.message = payResult.respMsg; return(View(result)); } else//短信验证失败 { result.backState = -100; result.message = validResult.message; return(View(result)); } }