Exemplo n.º 1
0
        public ActionResult LoginTokenVerify(string loginToken)
        {
            try
            {
                string        appid         = CheckAPPID();
                string        phone         = "";
                dm_userEntity dm_UserEntity = dm_userIBLL.LoginTokenVerify(loginToken, appid, ref phone);
                if (dm_UserEntity.IsEmpty())
                {
                    if (!phone.IsEmpty())
                    {
                        return(FailNoExistUser(new { phone = phone }));
                    }
                    else
                    {
                        return(Fail("快捷登录失败,请检查token是否正确!"));
                    }
                }

                return(Success("验证成功", dm_UserEntity));
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
Exemplo n.º 2
0
 public ActionResult GetSonChildDetail(int user_id, int PageNo = 1, int PageSize = 20)
 {
     try
     {
         dm_userEntity dm_UserEntity = dm_userIBLL.GetEntityByCache(user_id);
         if (dm_UserEntity.IsEmpty())
         {
             return(Fail("用户信息异常!"));
         }
         else
         {
             string    cacheKey  = Md5Helper.Hash("SonChildDetail" + user_id + PageNo + PageSize);
             DataTable dataTable = redisCache.Read(cacheKey, 7);
             if (dataTable == null)
             {
                 dataTable = dm_UserRelationIBLL.GetMySonChildDetail(user_id, PageNo, PageSize);
                 if (dataTable.Rows.Count >= PageSize)
                 {
                     redisCache.Write(cacheKey, dataTable, DateTime.Now.AddHours(3), 7);
                 }
                 else
                 {
                     redisCache.Write(cacheKey, dataTable, DateTime.Now.AddMinutes(5), 7);
                 }
             }
             return(SuccessList("获取成功!", dataTable));
         }
     }
     catch (Exception ex)
     {
         return(FailException(ex));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 获取个人信息
        /// </summary>
        /// <param name="id">用户id</param>
        /// <returns></returns>

        public ActionResult GetPersonInfo(int User_ID = 0)
        {
            try
            {
                string        token         = base.Request.Headers["token"];
                dm_userEntity dm_UserEntity = dm_userIBLL.GetPersonInfo(token);

                if (!dm_UserEntity.IsEmpty())
                {
                    if (dm_UserEntity.id != User_ID && User_ID > 0)
                    {
                        dm_UserEntity = dm_userIBLL.GetEntityByCache(User_ID);
                    }
                    return(Success("获取成功", dm_UserEntity));
                }
                else
                {
                    return(Fail("用户信息异常!"));
                }
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
Exemplo n.º 4
0
        public ActionResult DecodeInviteCode(string InviteCode)
        {
            try
            {
                if (InviteCode.Length != 6)
                {
                    return(null);
                }

                string appid = CheckAPPID();

                dm_userEntity dm_UserEntity = dm_userIBLL.DecodeInviteCode(InviteCode);
                if (dm_UserEntity.IsEmpty())
                {
                    return(Fail("邀请码错误!"));
                }

                return(Success("获取成功!", new
                {
                    UserID = dm_UserEntity.id,
                    NickName = dm_UserEntity.nickname,
                    HeadPic = dm_UserEntity.headpic,
                    RealName = dm_UserEntity.realname,
                    Phone = dm_UserEntity.phone
                }));;
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
Exemplo n.º 5
0
        public ActionResult ReviceActivityTask(string token, string taskids)
        {
            dm_userEntity dm_UserEntity = CacheHelper.ReadUserInfoByToken(token);

            if (!dm_UserEntity.IsEmpty())
            {
                dM_Task_ReviceIBLL.ReviceActivityTask(taskids.Split(','), (int)dm_UserEntity.id);
            }
            return(Success("领取成功!"));
        }
Exemplo n.º 6
0
        public ActionResult GetRandActivityTaskList(string token)
        {
            dm_userEntity dm_UserEntity   = CacheHelper.ReadUserInfoByToken(token);
            DataTable     dm_TaskEntities = new DataTable();

            if (!dm_UserEntity.IsEmpty())
            {
                dm_TaskEntities = dM_TaskIBLL.GetRandActivityTaskList((int)dm_UserEntity.id);
            }
            else
            {
                return(Fail("用户信息异常!"));
            }
            return(Success(dm_TaskEntities));
        }
Exemplo n.º 7
0
        public ActionResult ActivityPage(string token, string appid, string platform, string version)
        {
            /*
             * 1、随机生成金额分配给对应用户,金额区间26.5~28.2
             * 2、生成用户和任务的关联信息,用于校验任务的状态(一个用户同时接受多个任务  并对任务进行编号)
             */
            dm_userEntity dm_UserEntity = CacheHelper.ReadUserInfoByToken(token);

            if (!dm_UserEntity.IsEmpty())
            {
                dm_activity_manageEntity dm_Activity_ManageEntity = dm_Activity_ManageIBLL.GetActivityInfo();

                if (!dm_Activity_ManageEntity.IsEmpty())
                {
                    ViewBag.ActivityRemark = dm_Activity_ManageEntity.ActivityRemark;

                    dm_activity_recordEntity dm_Activity_RecordEntity = dm_Activity_RecordIBLL.GetEntityByUserID((int)dm_UserEntity.id, dm_Activity_ManageEntity.f_id);

                    if (!dm_Activity_RecordEntity.IsEmpty())
                    {
                        dm_UserEntity = dM_UserIBLL.GetEntity(dm_UserEntity.id);
                    }
                    else
                    {
                        dm_UserEntity            = dM_UserIBLL.JoinActivity((int)dm_UserEntity.id);
                        dm_Activity_RecordEntity = new dm_activity_recordEntity();
                    }

                    ViewBag.ActivityPrice = dm_UserEntity.activityprice;

                    ViewBag.MyActivityInfo = dm_Activity_RecordEntity;
                }
            }
            else
            {
                ViewBag.MyActivityInfo = new dm_activity_recordEntity();
            }


            ViewBag.Token    = token;
            ViewBag.AppID    = appid;
            ViewBag.Platform = platform;
            ViewBag.Version  = version;

            return(View());
        }
        /// <summary>
        /// 写入用户信息
        /// </summary>
        /// <param name="oldToken">原有用户信息的token</param>
        /// <param name="dm_UserEntity">里面的token是最新的</param>
        public static void SaveUserInfo(string oldToken, dm_userEntity dm_UserEntity)
        {
            #region 重新构造用户缓存信息
            if (!dm_UserEntity.IsEmpty())
            {
                string cacheKey = SingleLogin + dm_UserEntity.token;
                redisCache.Write <dm_userEntity>(cacheKey, dm_UserEntity, 8);

                #region 移除用户信息
                if (!oldToken.IsEmpty())
                {
                    string old_cacheKey = SingleLogin + oldToken;
                    redisCache.Remove(old_cacheKey, 8);
                }
                #endregion
            }
            #endregion
        }
Exemplo n.º 9
0
        public ActionResult GetPartnersChildDetail(int User_ID, int PageNo = 1, int PageSize = 20)
        {
            try
            {
                if (User_ID <= 0)
                {
                    return(FailNoLogin());
                }

                dm_userEntity dm_UserEntity = dm_userIBLL.GetEntityByCache(User_ID);
                if (dm_UserEntity.IsEmpty())
                {
                    return(Fail("用户信息异常!"));
                }
                if (dm_UserEntity.partnersstatus == 0)
                {
                    return(Fail("当前非合伙人,无法看团队粉丝"));
                }
                else
                {
                    string    cacheKey  = Md5Helper.Hash("PartnersChildDetail" + User_ID + PageNo + PageSize);
                    DataTable dataTable = redisCache.Read(cacheKey, 7);
                    if (dataTable == null)
                    {
                        dataTable = dm_UserRelationIBLL.GetPartnersChildDetail(dm_UserEntity.partners, PageNo, PageSize);
                        if (dataTable.Rows.Count >= PageSize)
                        {
                            redisCache.Write(cacheKey, dataTable, DateTime.Now.AddMinutes(3), 7);
                        }
                        else
                        {
                            redisCache.Write(cacheKey, dataTable, DateTime.Now.AddSeconds(30), 7);
                        }
                    }
                    return(SuccessList("获取成功!", dataTable));
                }
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
Exemplo n.º 10
0
        public ActionResult GetUserInfoByPhone(string Phone)
        {
            try
            {
                string        appid = CheckAPPID(); bool IsNewUser = false;
                dm_userEntity dm_UserEntity = dm_userIBLL.GetEntityByPhone(Phone, appid);
                if (dm_UserEntity.IsEmpty())
                {
                    IsNewUser = true;
                }

                return(Success("获取成功!", new
                {
                    UserEntity = dm_UserEntity,
                    IsNewUser = IsNewUser
                }));
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
Exemplo n.º 11
0
        List <FriendCircleEntity> GeneralPraise(IEnumerable <dm_friend_circleEntity> dm_Friend_CircleEntities, string cacheKey, bool IsGovernment = false)
        {
            //获取用户信息
            dm_userEntity dm_UserEntity = CacheHelper.ReadUserInfo(base.Request.Headers);

            #region 构造点赞信息
            List <int> friend_ids = dm_Friend_CircleEntities.Select(t => t.id).ToList();

            DataTable dataTable = null;
            IEnumerable <dm_friend_thumb_recordEntity> dm_friend_thumb_recordList = null;
            IEnumerable <dm_userEntity> dm_UserList = null;
            if (friend_ids.Count > 0)
            {
                #region 获取哆米圈文章的点赞记录
                dataTable = dm_Friend_Thumb_RecordIBLL.GetPraiseRecord(friend_ids);
                #endregion

                #region 获取我的点赞情况
                dm_friend_thumb_recordList = dm_Friend_Thumb_RecordIBLL.GetPraiseRecord(friend_ids, (int)dm_UserEntity.id);
                #endregion

                if (!IsGovernment)
                {
                    List <string> user_ids = dm_Friend_CircleEntities.Select(t => t.createcode).Distinct().ToList();//获取任务创建人
                    dm_UserList = dM_UserIBLL.GetUserListByIDS(user_ids);
                }
            }

            List <FriendCircleEntity> dyList = new List <FriendCircleEntity>();
            foreach (var item in dm_Friend_CircleEntities)
            {
                List <string> headPicList = new List <string>();
                int           MyPariseStatus = 0;
                string        NickName = "", HeadPic = "";
                if (IsGovernment)
                {
                    NickName = "哆来米";
                    HeadPic  = "http://dlaimi.cn/Content/Images/default.png";
                }
                else
                {
                    if (!dm_UserList.IsEmpty())
                    {
                        dm_userEntity Pub_UserEntity = dm_UserList.Where(t => item.createcode == t.id.ToString()).FirstOrDefault();
                        if (!Pub_UserEntity.IsEmpty())
                        {
                            NickName = Pub_UserEntity.nickname;
                            HeadPic  = Pub_UserEntity.headpic;
                        }
                    }
                }


                if (!dataTable.IsEmpty())
                {
                    DataRow[] dataRows = dataTable.Select(" friend_id=" + item.id);
                    foreach (DataRow itemRow in dataRows)
                    {
                        headPicList.Add(itemRow["headpic"].IsEmpty() ? "" : itemRow["headpic"].ToString());
                    }
                }

                if (!dm_friend_thumb_recordList.IsEmpty())
                {
                    dm_friend_thumb_recordEntity dm_Friend_Thumb_RecordEntity = dm_friend_thumb_recordList.Where(t => t.user_id == dm_UserEntity.id && t.friend_id == item.id).FirstOrDefault();
                    MyPariseStatus = dm_Friend_Thumb_RecordEntity.IsEmpty() ? 0 : (int)dm_Friend_Thumb_RecordEntity.status;
                }
                dyList.Add(new FriendCircleEntity
                {
                    TemplateDetail = item,
                    PraiseRecord   = headPicList,
                    MyPariseStatus = MyPariseStatus,
                    Pub_UserInfo   = new PubUserInfo {
                        NickName = NickName, HeadPic = HeadPic, PubTime = TimeConvert(item.createtime)
                    },
                    CacheKey = cacheKey
                });
            }
            #endregion

            return(dyList);
        }
Exemplo n.º 12
0
        public ActionResult GetCommonSetting()
        {
            try
            {
                string appid = CheckAPPID(); string token = base.Request.Headers["token"];
                string platform = CheckPlaform();

                string            cacheKey          = Md5Helper.Hash("CommonSettingInfo" + appid + token + platform);
                CommonSettingInfo commonSettingInfo = redisCache.Read <CommonSettingInfo>(cacheKey, 7);

                if (commonSettingInfo.IsEmpty())
                {
                    dm_basesettingEntity dm_BasesettingEntity = dm_BaseSettingIBLL.GetEntityByCache(appid);
                    int Status = 0;
                    if (dm_BasesettingEntity.openchecked == "1")
                    { //开启审核模式
                        string version = CheckVersion();
                        if ((platform == "ios" && version == dm_BasesettingEntity.previewversion) || (platform == "android" && version == dm_BasesettingEntity.previewversionandroid))
                        {
                            Status = 1;
                        }
                    }

                    #region 活动配置校验
                    bool JoinActivity = false;
                    dm_activity_manageEntity dm_Activity_ManageEntity = new dm_activity_manageEntity();

                    dm_Activity_ManageEntity = dm_Activity_ManageIBLL.GetActivityInfo();
                    if (dm_Activity_ManageEntity.IsEmpty())
                    {
                        dm_Activity_ManageEntity = new dm_activity_manageEntity {
                            ActivityStatus = 0
                        }
                    }
                    ;
                    else
                    {
                        if (!token.IsEmpty())
                        {
                            dm_userEntity dm_UserEntity = CacheHelper.ReadUserInfoByToken(token);
                            if (!dm_UserEntity.IsEmpty())
                            {
                                dm_activity_recordEntity dm_Activity_RecordEntity = dm_Activity_RecordIBLL.GetEntityByUserID((int)dm_UserEntity.id, dm_Activity_ManageEntity.f_id);
                                if (!dm_Activity_RecordEntity.IsEmpty())
                                {
                                    JoinActivity = true;
                                }
                            }
                        }
                    }
                    #endregion

                    if (platform != "android")
                    {
                        JoinActivity = false;
                    }

                    commonSettingInfo = new CommonSettingInfo
                    {
                        //isAppStorePreview = ((base.Request.Headers["version"].ToString() == dm_BasesettingEntity.previewversion) ? 1 : 0)
                        //previewversion = dm_BasesettingEntity.previewversion,
                        ischecked                = Status, //dm_BasesettingEntity.openchecked,
                        welcomenewperson         = dm_BasesettingEntity.welcomenewperson,
                        showcommission           = dm_BasesettingEntity.showcommission,
                        miquan_remark            = dm_BasesettingEntity.miquan_remark,
                        task_remark              = "http://dlaimi.cn/dm_appmanage/dm_article/lookarticle?id=16",
                        task_submit_remark_title = "任务提交小建议",
                        task_submit_remark       = dm_BasesettingEntity.task_submit_remark,
                        nodatatip                = CommonConfig.NoDataTip,
                        sign_rule                = dm_BasesettingEntity.sign_rule,
                        cashrecord_fee           = dm_BasesettingEntity.cashrecord_fee,
                        cashrecord_remark        = dm_BasesettingEntity.cashrecord_remark,
                        activitysetting          = dm_Activity_ManageEntity,
                        JoinActivity             = JoinActivity ? 1 : 0
                    };

                    redisCache.Write <CommonSettingInfo>(cacheKey, commonSettingInfo, DateTime.Now.AddMinutes(1), 7);
                }

                return(Success("获取成功", commonSettingInfo));
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
Exemplo n.º 13
0
        public ActionResult AuthorCallBack(string code, string state)
        {
            Learun.Loger.Log log = LogFactory.GetLogger("workflowapi");

            try
            {
                int           user_id       = int.Parse(state);
                dm_userEntity dm_UserEntity = dm_userIBLL.GetEntityByCache(user_id);

                dm_basesettingEntity dm_BasesettingEntity = dm_BaseSettingIBLL.GetEntityByCache(dm_UserEntity.appid);


                WebUtils webUtils = new WebUtils();
                IDictionary <string, string> pout = new Dictionary <string, string>();
                pout.Add("grant_type", "authorization_code");
                pout.Add("client_id", dm_BasesettingEntity.tb_appkey);
                pout.Add("client_secret", dm_BasesettingEntity.tb_appsecret);
                pout.Add("code", code);
                pout.Add("redirect_uri", HttpUtility.UrlEncode(CommonConfig.tb_auth_address));
                string output = webUtils.DoPost("http://oauth.taobao.com/token", pout);

                log.Error(output);

                AuthorInfo authorInfo = JsonConvert.DeserializeObject <AuthorInfo>(output);

                ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", dm_BasesettingEntity.tb_appkey, dm_BasesettingEntity.tb_appsecret);
                TbkScPublisherInfoSaveRequest req = new TbkScPublisherInfoSaveRequest();
                req.RelationFrom = "1";
                req.OfflineScene = "1";
                req.OnlineScene  = "1";
                req.InviterCode  = dm_BasesettingEntity.tb_relation_invitecode;
                req.InfoType     = 1L;
                req.Note         = "哆来米代理申请";
                req.RegisterInfo = "{\"phoneNumber\":\"18801088599\",\"city\":\"江苏省\",\"province\":\"南京市\",\"location\":\"玄武区花园小区\",\"detailAddress\":\"5号楼3单元101室\"}";
                TbkScPublisherInfoSaveResponse rsp = client.Execute(req, authorInfo.access_token);
                log.Error(rsp.Body);
                log.Error(HttpUtility.UrlDecode(authorInfo.taobao_user_nick));
                if (rsp.Data == null)
                {
                    throw new Exception(rsp.SubErrMsg);
                }
                else
                {
                    string relation_id = rsp.Data.RelationId.ToString();
                    if (dm_userIBLL.NoExistRelationID(relation_id, user_id))
                    {
                        string[] pids = dm_BasesettingEntity.tb_relation_pid.Split('_');
                        dm_UserEntity.tb_pid           = pids.Length == 4 ? pids[3] : "";
                        dm_UserEntity.tb_relationid    = relation_id;
                        dm_UserEntity.tb_nickname      = HttpUtility.UrlDecode(authorInfo.taobao_user_nick);
                        dm_UserEntity.isrelation_beian = 1;
                        dm_userIBLL.SaveEntity(user_id, dm_UserEntity);
                    }
                    else
                    {
                        string otherAccount = "其他账号";
                        if (!dm_UserEntity.IsEmpty() && !dm_UserEntity.phone.IsEmpty() && dm_UserEntity.phone.Length > 10)
                        {
                            otherAccount = "账号" + Regex.Replace(dm_UserEntity.phone, "(\\d{3})\\d{4}(\\d{4})", "$1****$2");
                        }
                        throw new Exception("当前淘宝账号已在" + otherAccount + "下授权,请更换账号!");
                    }
                }



                return(RedirectToAction("AuthorResult", new { IsSuccess = "授权成功", ErrorMessage = "" }));

                //return Success("授权成功", output);
            }
            catch (Exception ex)
            {
                return(RedirectToAction("AuthorResult", new { IsSuccess = "授权失败", ErrorMessage = ex.Message }));
            }
        }
        public ActionResult CheckApplyCashRecordByAli(int id)
        {
            try
            {
                UserInfo             userInfo             = LoginUserInfo.Get();
                dm_basesettingEntity dm_BasesettingEntity = dM_BaseSettingIBLL.GetEntity(userInfo.companyId);

                dm_apply_cashrecordEntity jlm_Xcx_Apply_CashrecordEntity = dM_Apply_CashRecordIBLL.GetEntity(id);

                if (jlm_Xcx_Apply_CashrecordEntity.IsEmpty())
                {
                    throw new Exception("未找到提现记录!");
                }

                if (jlm_Xcx_Apply_CashrecordEntity.status != 0)
                {
                    throw new Exception("当前提现记录不可操作!");
                }

                dm_userEntity dm_UserEntity = dM_UserIBLL.GetEntity(jlm_Xcx_Apply_CashrecordEntity.user_id);
                if (dm_UserEntity.IsEmpty())
                {
                    throw new Exception("未检测到用户信息!");
                }
                if (dm_UserEntity.realname.IsEmpty())
                {
                    throw new Exception("该用户未实名!");
                }
                if (dm_UserEntity.zfb.IsEmpty())
                {
                    throw new Exception("该用户未绑定支付宝账号!");
                }


                IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", dm_BasesettingEntity.alipay_appid, dm_BasesettingEntity.merchant_private_key, "json", "1.0", "RSA2", "utf-8", false, AliPayHelper.GetCertParams(dm_BasesettingEntity.alipay_appid, base.Server));
                AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
                request.BizContent = "{" +
                                     "\"out_biz_no\":\"" + Guid.NewGuid().ToString() + "\"," +
                                     "\"trans_amount\":" + jlm_Xcx_Apply_CashrecordEntity.price + "," +
                                     "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," +
                                     "\"biz_scene\":\"DIRECT_TRANSFER\"," +
                                     "\"order_title\":\"哆来米\"," +
                                     "\"original_order_id\":\"\"," +
                                     "\"payee_info\":{" +
                                     "\"identity\":\"" + dm_UserEntity.zfb + "\"," +
                                     "\"identity_type\":\"ALIPAY_LOGON_ID\"," +
                                     "\"name\":\"" + dm_UserEntity.realname + "\"" +
                                     "    }," +
                                     "\"remark\":\"余额提现\"," +
                                     "\"business_params\":\"{\\\"sub_biz_scene\\\":\\\"REDPACKET\\\"}\"" +
                                     "  }";
                AlipayFundTransUniTransferResponse response = client.CertificateExecute(request);
                if (response.IsError)
                {
                    throw new Exception(response.Msg + "=>" + response.SubMsg);
                }

                jlm_Xcx_Apply_CashrecordEntity.paytype        = 2;
                jlm_Xcx_Apply_CashrecordEntity.status         = 1;
                jlm_Xcx_Apply_CashrecordEntity.OrderId        = response.OrderId;
                jlm_Xcx_Apply_CashrecordEntity.PayFundOrderId = response.PayFundOrderId;
                jlm_Xcx_Apply_CashrecordEntity.TransDate      = DateTime.Parse(response.TransDate);
                jlm_Xcx_Apply_CashrecordEntity.checktime      = DateTime.Now;

                dM_Apply_CashRecordIBLL.CheckApplyCashRecordByAli(jlm_Xcx_Apply_CashrecordEntity);

                return(Success("打款成功!"));
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
Exemplo n.º 15
0
        public ActionResult ConvertFunLink(int module_fun_id)
        {
            try
            {
                NameValueCollection nameValueCollection = base.Request.Headers;
                dm_userEntity       dm_UserEntity       = CacheHelper.ReadUserInfo(nameValueCollection);


                if (!dm_UserEntity.IsEmpty())
                {
                    string cacheKey = Md5Helper.Hash(module_fun_id + "module_fun_id" + dm_UserEntity.id);
                    string to_link  = redisCache.Read <string>(cacheKey, 7);
                    if (to_link.IsEmpty())
                    {
                        dm_decoration_fun_manageEntity dm_Decoration_Fun_ManageEntity = dm_Decoration_Fun_ManageIBLL.GetEntity(module_fun_id);
                        if (dm_Decoration_Fun_ManageEntity.fun_type == 2)
                        {
                            #region 多麦模块处理  多麦模块fun_param为int类型
                            CPS_Convert_LinkResponse cPS_Convert_LinkResponse = dm_Dauomai_Plan_ManageIBLL.ConvertLink(int.Parse(dm_Decoration_Fun_ManageEntity.fun_param), (int)dm_UserEntity.id);
                            to_link = cPS_Convert_LinkResponse.short_url;
                            #endregion
                        }
                        else if (dm_Decoration_Fun_ManageEntity.fun_type == 3)
                        {
                            #region 站内H5页面 fun_param为自定义的h5链接地址
                            if (dm_Decoration_Fun_ManageEntity.fun_param.EndsWith("?"))
                            {
                                dm_Decoration_Fun_ManageEntity.fun_param = dm_Decoration_Fun_ManageEntity.fun_param.TrimEnd('?');
                            }
                            string param = string.Format("token={0}&version={1}&platform={2}&timestamp={3}", nameValueCollection["token"], nameValueCollection["version"], nameValueCollection["platform"], nameValueCollection["timestamp"]);
                            if (dm_Decoration_Fun_ManageEntity.fun_param.Contains("?"))
                            {
                                param = "&" + param;
                            }
                            else
                            {
                                param = "?" + param;
                            }

                            to_link = dm_Decoration_Fun_ManageEntity.fun_param + param;
                            #endregion
                        }
                        else if (dm_Decoration_Fun_ManageEntity.fun_type == 4)
                        {
                            string appid = CheckAPPID();
                            dm_basesettingEntity dm_BasesettingEntity = dM_BaseSettingIBLL.GetEntityByCache(appid);
                            DTK_ApiManage        dTK_ApiManage        = new DTK_ApiManage(dm_BasesettingEntity.dtk_appkey, dm_BasesettingEntity.dtk_appsecret);

                            #region 淘宝官方活动
                            DTK_TB_ActivityLinkRequest dTK_TB_ActivityLinkRequest = new DTK_TB_ActivityLinkRequest();
                            dTK_TB_ActivityLinkRequest.promotionSceneId = dm_Decoration_Fun_ManageEntity.fun_param;
                            dTK_TB_ActivityLinkRequest.pid        = dm_UserEntity.tb_pid;
                            dTK_TB_ActivityLinkRequest.relationId = dm_UserEntity.tb_relationid;
                            dTK_TB_ActivityLinkRequest.unionId    = "dlm" + dm_UserEntity.id;
                            DTK_TB_ActivityLinkResponse dTK_TB_ActivityLinkResponse = dTK_ApiManage.GetTB_ActivityConvertLink(dTK_TB_ActivityLinkRequest);
                            if (dTK_TB_ActivityLinkResponse.code == 200 && !dTK_TB_ActivityLinkResponse.data.IsEmpty())
                            {
                                to_link = dTK_TB_ActivityLinkResponse.data.click_url;
                            }
                            else
                            {
                                throw new Exception("淘宝官方活动转链失败!");
                            }
                            #endregion
                        }
                        else
                        {
                            throw new Exception("未找到扩展类型!");
                        }
                    }

                    return(Success(to_link));
                }
                else
                {
                    throw new Exception("模块转链:用户信息异常!");
                }
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 响应前执行登录验证,查看当前用户是否有效
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            /*签名生成格式*/
            /*md5(md5(appidplatform=androidtimestamp=1611907265000version=1.2.0appid)+"174PYR5Wwtce")  最后转为小写  参数放在header里面  参数名sign*/
            string ActionName = filterContext.RouteData.Values["action"].ToString().ToLower();

            //登录拦截是否忽略
            if (_customMode == FilterMode.Ignore || nosign.Contains(ActionName))
            {
                return;
            }

            var attrNeeds = filterContext.ActionDescriptor.GetCustomAttributes(typeof(NoNeedLoginAttribute), false);

            if (!attrNeeds.IsEmpty() && attrNeeds.Count() > 0)
            {
                //NoNeedLoginAttribute needPass = attrNeeds[0] as NoNeedLoginAttribute;
                return;
            }

            string       token       = filterContext.HttpContext.Request.Headers["token"];     //用户登录token
            string       platform    = filterContext.HttpContext.Request.Headers["platform"];  //平台类型
            string       appid       = filterContext.HttpContext.Request.Headers["appid"];     //appid
            string       timestamp   = filterContext.HttpContext.Request.Headers["timestamp"]; //时间戳
            string       version     = filterContext.HttpContext.Request.Headers["version"];   //版本号
            string       sign        = filterContext.HttpContext.Request.Headers["sign"];      //请求签名
            DateTime     currentTime = DateTime.Now;
            ResParameter modelResult = new ResParameter();

            //参数判断
            if (filterContext.HttpContext.Request.Headers["appid"] == null)
            {
                modelResult.code     = ResponseCode.fail;
                modelResult.info     = "缺少appid参数!";
                filterContext.Result = new ContentResult {
                    Content = modelResult.ToJson()
                };
                return;
            }
            else if (filterContext.HttpContext.Request.Headers["timestamp"] == null)
            {
                modelResult.code     = ResponseCode.fail;
                modelResult.info     = "缺少timestamp参数!";
                filterContext.Result = new ContentResult {
                    Content = modelResult.ToJson()
                };
                return;
            }
            else if (filterContext.HttpContext.Request.Headers["version"] == null)
            {
                modelResult.code     = ResponseCode.fail;
                modelResult.info     = "缺少version参数!";
                filterContext.Result = new ContentResult {
                    Content = modelResult.ToJson()
                };
                return;
            }
            else if (platform == null)
            {
                modelResult.code     = ResponseCode.fail;
                modelResult.info     = "缺少platform参数!";
                filterContext.Result = new ContentResult {
                    Content = modelResult.ToJson()
                };
                return;
            }

            int version_num = int.Parse(version.Replace(".", ""));

            if ((platform == "ios" && version_num > 103) || (platform == "android" && version_num > 119))
            {
                if (sign != "dlm_hyg")
                {
                    #region 校验签名
                    string signContent = string.Format("{0}platform={1}timestamp={2}version={3}{0}", appid, platform, timestamp, version);
                    string check_sign  = Md5Helper.Encrypt(Md5Helper.Encrypt(signContent, 32) + "174PYR5Wwtce", 32).ToLower();
                    if (sign != check_sign)
                    {
                        modelResult.code     = ResponseCode.fail;
                        modelResult.info     = "签名校验失败!";
                        filterContext.Result = new ContentResult {
                            Content = modelResult.ToJson()
                        };
                        return;
                    }
                    #endregion

                    #region 校验时间戳区间
                    long timestamp_long = long.Parse(timestamp);
                    long startTime      = long.Parse(Time.GetTimeStamp(currentTime.AddMinutes(-2), true));
                    long endTime        = long.Parse(Time.GetTimeStamp(currentTime.AddMinutes(2), true));
                    if (startTime > timestamp_long || timestamp_long > endTime)
                    {
                        modelResult.code     = ResponseCode.fail;
                        modelResult.info     = "本地时间和网络时间存在较大差别,请调整后重新使用APP!";
                        filterContext.Result = new ContentResult {
                            Content = modelResult.ToJson()
                        };
                        return;
                    }
                    #endregion

                    #region 校验请求频率
                    string   ip       = Net.Ip;
                    IP_Limit iP_Limit = CommonConfig.iP_Limits.Where(t => t.IP == ip).FirstOrDefault();//获取IP限制记录
                    if (!iP_Limit.IsEmpty())
                    {
                        double diffTime = (currentTime - iP_Limit.RequestTime).TotalSeconds;//该IP请求时间间隔在1分钟以内  增加接口请求的数量   不在1分钟以内的重新记录IP请求
                        if (diffTime < 60)
                        {
                            if (iP_Limit.RequestCount > 100)
                            {
                                modelResult.code     = ResponseCode.fail;
                                modelResult.info     = "操作过于频繁,请稍后重试!";
                                filterContext.Result = new ContentResult {
                                    Content = modelResult.ToJson()
                                };
                                return;
                            }
                            iP_Limit.RequestCount += 1;
                        }
                        else
                        {
                            iP_Limit.RequestTime  = currentTime;
                            iP_Limit.RequestCount = 1;
                        }
                    }
                    else
                    {
                        CommonConfig.iP_Limits.Add(new IP_Limit
                        {
                            IP           = ip,
                            RequestCount = 1,
                            RequestTime  = currentTime
                        });
                    }
                    CommonConfig.iP_Limits.RemoveAll(t => t.RequestTime < currentTime.AddMinutes(-2));//清空超过2分钟的请求记录
                    #endregion
                }
            }


            #region 屏蔽不需要校验登录的接口
            if (actionNameList.Contains(ActionName))
            {
                return;
            }
            #endregion

            #region 校验当前用户是否在线
            if (token.IsEmpty())
            {
                modelResult.code     = ResponseCode.NoLogin;
                modelResult.info     = "请登录后操作!";
                filterContext.Result = new ContentResult {
                    Content = modelResult.ToJson()
                };
                return;
            }
            else
            {
                dm_userEntity dm_UserEntity = CacheHelper.ReadUserInfo(filterContext.HttpContext.Request.Headers);
                if (dm_UserEntity.IsEmpty())
                {
                    dm_UserEntity = dM_UserIBLL.GetUserInfoByToken(token);
                    if (!dm_UserEntity.IsEmpty())
                    {
                        CacheHelper.UpdateUserInfo(dm_UserEntity);
                    }
                    else
                    {
                        string header = string.Format("ActionName={0}&token={1}&platform={2}", ActionName, token, platform);
                        Hyg.Common.OtherTools.LogHelper.WriteDebugLog("测试token", header);

                        modelResult.code = ResponseCode.LoginExpire;
                        modelResult.info = "您的账号在另一台设备登录。如非本人操作,请注意账户安全!";
                        //modelResult.info = "亲,离开太久了,重新登录一下吧!";
                        filterContext.Result = new ContentResult {
                            Content = modelResult.ToJson()
                        };
                        return;
                    }
                }
            }
            #endregion
        }
        public ActionResult ExecuteImportExcel(string templateId, string fileId, int chunks, string ext)
        {
            string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks);

            if (!string.IsNullOrEmpty(path))
            {
                DataTable dt = ExcelHelper.ExcelImport(path);
                dm_user_relationEntity dm_User_RelationEntity = new dm_user_relationEntity();
                if (templateId == "a21c6d88-16bf-489d-a019-96047431f0b4")
                {
                    int       snum   = 0;
                    int       fnum   = 0;
                    DataTable failDt = new DataTable();
                    dt.Columns.Add("导入错误", typeof(string));
                    foreach (DataColumn dc in dt.Columns)
                    {
                        failDt.Columns.Add(dc.ColumnName, dc.DataType);
                    }

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataRow dataRow = dt.Rows[i];

                        if (dataRow[0].IsEmpty())
                        {
                            continue;
                        }
                        string Phone         = dataRow[0].ToString();     //手机号
                        string RealName      = ConvertEmpty(dataRow[1]);  //真实姓名
                        string NickName      = ConvertEmpty(dataRow[2]);  //用户昵称
                        string CardNo        = ConvertEmpty(dataRow[3]);  //身份证号
                        string UserLevel     = ConvertEmpty(dataRow[4]);  //用户等级
                        string InviteCode    = ConvertEmpty(dataRow[5]);  //邀请码
                        string Province      = ConvertEmpty(dataRow[6]);  //省份
                        string City          = ConvertEmpty(dataRow[7]);  //城市
                        string Down          = ConvertEmpty(dataRow[8]);  //区域
                        string DetailAddress = ConvertEmpty(dataRow[9]);  //详细地址
                        string WeChat        = ConvertEmpty(dataRow[10]); //微信号
                        string IntegralNum   = ConvertEmpty(dataRow[11]); //积分数量

                        int?          partner_id    = 0;
                        dm_userEntity dm_UserEntity = dm_UserBLL.GetEntityByInviteCode(InviteCode, ref dm_User_RelationEntity);
                        if (!dm_UserEntity.IsEmpty() && !dm_User_RelationEntity.IsEmpty())
                        {
                            if (dm_UserEntity.partnersstatus == 2)
                            {
                                partner_id = dm_UserEntity.partners;//如果邀请码对应的用户是合伙人 则合伙人编号直接用该用户的
                            }
                            else
                            {
                                partner_id = dm_User_RelationEntity.partners_id;//如果上级非合伙人则继承上级合伙人
                            }

                            UserInfo userInfo = LoginUserInfo.Get();
                            if (dm_UserBLL.ImportUserInfo(userInfo.companyId, Phone, RealName, NickName, CardNo, UserLevel, Province, City, Down, DetailAddress, WeChat, dm_UserEntity.id.ToString(), dm_UserEntity.nickname, partner_id.ToString(), IntegralNum))
                            {
                                snum++;
                            }
                            else
                            {
                                fnum++;
                                failDt.Rows.Add(dataRow.ItemArray);
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }

                    #region 用户导入成功之后修复没有邀请码的用户
                    dm_UserBLL.BatchGeneralInviteCode();
                    #endregion

                    var data = new
                    {
                        Success = snum,
                        Fail    = fnum
                    };

                    // 写入缓存如果有未导入的数据
                    if (failDt.Rows.Count > 0)
                    {
                        string errordt = failDt.ToJson();

                        cache.Write <string>(cacheKey + fileId, errordt, CacheId.excel);
                    }

                    return(Success(data));
                }
                else
                {
                    string res  = excelImportIBLL.ImportTable(templateId, fileId, dt);
                    var    data = new
                    {
                        Success = res.Split('|')[0],
                        Fail    = res.Split('|')[1]
                    };

                    return(Success(data));
                }
            }
            else
            {
                return(Fail("导入数据失败!"));
            }
        }