示例#1
0
        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <returns></returns>
        public string SendMsgCode(int cid = 0, string mobile = "", string vcode = "", string guid = "")
        {
            #region 验证
            if (!ITOrm.Utility.StringHelper.TypeParse.IsMobile(mobile))
            {
                return(ApiReturnStr.getError(-100, "手机号格式验证失败"));
            }
            if (guid.Length != 36)
            {
                return(ApiReturnStr.getError(-100, "唯一标识错误"));
            }
            if (vcode.Trim().Length != 4)
            {
                return(ApiReturnStr.getError(-100, "验证码错误"));
            }

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

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

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

            var regGuid = Util.GetGUID;

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

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

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

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


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

            return(ApiReturnStr.getApiData(-100, "发送失败"));
        }
示例#2
0
        private void Run()
        {
            Log objL = new Log();

            try
            {
                while (runState == RunNing.运行中)
                {
                    //处理图片
                    UserImageHandle();
                    //处理审核
                    AuditHandle();
                    //处理费率
                    SetFeeHandle();
                    //结算
                    WithDrawApiHandle();
                    //定时任务
                    TimedTaskHandle();
                    //资金队列
                    AccountQueueHandle();
                    //结算检查
                    WithDrawHandle();
                    Thread.Sleep(1000);
                    if (runState == RunNing.暂停等待中)
                    {
                        this.runState        = RunNing.已暂停;
                        _StartButton.Text    = "开始";
                        _StartButton.Enabled = true;
                        break;
                    }
                    runState = RunNing.运行等待中;
                    int i = ConfigInfo.BatchWaitMilliSecond;
                    while (i > 0 && runState == RunNing.运行等待中)
                    {
                        _StartButton.Text = "运行等待中……" + i / 1000 + "秒(可暂停)";
                        Thread.Sleep(1000);
                        i = i - 1000;
                    }
                    runState             = RunNing.运行中;
                    _StartButton.Text    = "运行中……(可暂停)";
                    _StartButton.Enabled = true;
                }
            }
            catch (ThreadAbortException)
            {
                runState          = RunNing.已暂停;
                _StartButton.Text = "开始";
            }
            catch (Exception e)
            {
                objL.fLog(e.ToString());

                string[] ss = ConfigInfo.GetMobile.Split(',');
                foreach (var s in ss)
                {
                    //发送短信
                    var     resultMsg = SystemSendMsg.Send(Logic.EnumSendMsg.自动处理程序出错, s);
                    SendMsg model     = new SendMsg();
                    model.TypeId     = (int)Logic.EnumSendMsg.自动处理程序出错;
                    model.Context    = resultMsg.content;
                    model.CTime      = DateTime.Now;
                    model.IP         = ITOrm.Utility.Client.Ip.GetClientIp();
                    model.Merchant   = resultMsg.Merchant;
                    model.Mobile     = s;
                    model.Platform   = (int)Logic.Platform.系统;
                    model.Service    = "sys_auto";
                    model.RelationId = resultMsg.relationId;
                    model.State      = resultMsg.backState ? 2 : 1;
                    model.UTime      = DateTime.Now;
                    int result = sendMsgDao.Insert(model);

                    //SMShelper.SendMsg(s, ConfigInfo.merchantCode + "存管自动处理程序异常停止!");
                }
                runState          = RunNing.已暂停;
                _StartButton.Text = "开始";
            }
            finally
            {
                _Thread = null;
            }
        }
示例#3
0
        public static ResultModelData <JObject> SendMsgCode(int payCId, int Platform, string tengGuid)
        {
            ResultModelData <JObject> ret = new ResultModelData <JObject>();

            ret.backState = -100;
            ret.message   = "发送失败";


            string       LogDic = "发送收银短信";
            PayCashier   payc   = payCashierDao.Single(payCId);
            PayRecord    pay    = payRecordDao.Single(payc.PayRecordId);
            UserBankCard ubk    = userBankCardDao.Single(payc.UbkId);
            int          typeId = (int)Teng.Enums.TengType.发送收银短信;
            int          cnt    = yeepayLogDao.Count(" UserId=@UserId and KeyId=@PayRecordId and ChannelType=@ChannelType and typeId=@typeId ", new { payc.UserId, payc.PayRecordId, payc.ChannelType, typeId });

            if (cnt > 4)
            {
                ret.message = "该订单短信发送次数超限";
                return(ret);
            }
            //获取请求流水号
            int requestId = yeepayLogDao.Init(typeId, payc.UserId, Platform, payc.PayRecordId, (int)Logic.ChannelType.腾付通);

            Logs.WriteLog($"获取请求流水号:payCId:{payCId},UserId:{payc.UserId},Platform:{Platform},tengGuid:{tengGuid},requestId:{requestId}", TengLogDic, LogDic);
            bool flag = false;

            //发送短信
            var     resultMsg = SystemSendMsg.Send(Logic.EnumSendMsg.腾付通收银短信, ubk.Mobile, pay.Amount);
            SendMsg model     = new SendMsg();

            model.UserId     = payc.UserId;
            model.TypeId     = (int)Logic.EnumSendMsg.腾付通收银短信;
            model.Context    = resultMsg.content;
            model.CTime      = DateTime.Now;
            model.IP         = ITOrm.Utility.Client.Ip.GetClientIp();
            model.Merchant   = resultMsg.Merchant;
            model.Mobile     = resultMsg.Mobile;
            model.Platform   = Platform;
            model.Service    = "teng";
            model.RelationId = resultMsg.relationId;
            model.State      = resultMsg.backState ? 2 : 1;
            model.UTime      = DateTime.Now;
            int result = sendMsgDao.Insert(model);

            if (resultMsg.backState && result > 0)
            {
                string key       = Constant.teng_mobile_code + tengGuid;
                var    cacheData = new JObject();
                cacheData["mobile"] = resultMsg.Mobile;
                cacheData["code"]   = resultMsg.code;
                MemcachHelper.Set(key, cacheData.ToString(), ITOrm.Utility.Const.Constant.mobile_code_expires);
                var data = new JObject();
                data["tengGuid"] = tengGuid;
                if (Constant.IsDebug)
                {
                    data["code"] = resultMsg.code;
                }
                ret.backState = 0;
                ret.message   = "发送成功";
                ret.Data      = data;
            }
            #region 日志处理
            //返回后日志记录
            yeepayLogParasDao.Init(requestId, JsonConvert.SerializeObject(ret), 1);
            //易宝日志状态更新
            flag = yeepayLogDao.UpdateState(requestId, ret.backState.ToString(), ret.message, ret.backState == 0 ? 1 : ret.backState);
            #endregion
            return(ret);
        }