Example #1
0
        /// <summary>
        /// 根据用户ID获取用户信息
        /// </summary>
        /// <param name="registerid"></param>
        /// <returns></returns>
        public M_member_table getMemberInfo(int registerid)
        {
            B_member_table bmt = new B_member_table();
            M_member_table mmt = bmt.GetModel(registerid);

            return(mmt);
        }
Example #2
0
        public JsonResult IsOpenAccount()
        {
            int            userid = Utils.checkloginsession();
            string         temstr = string.Empty;
            string         rs     = "n";//默认没开通
            B_member_table b      = new B_member_table();
            M_member_table pu     = new M_member_table();

            pu = b.GetModel(userid);

            //判断用户是否开户
            if (pu == null)
            {
                rs     = "y";
                temstr = "/login.thml";
            }
            else if (!string.IsNullOrEmpty(pu.UsrCustId))
            {
                rs = "y";
            }
            else
            {
                rs     = "n";
                temstr = "/opening_account/Index/" + userid.ToString();
            }

            var result = new { rs = rs, info = temstr };

            return(Json(result));
        }
        public ActionResult Index(RequestParam <RequestMemberDetail> reqst)
        {
            LoggerHelper.Info(JsonHelper.Entity2Json(reqst));
            UserEntity     br = new UserEntity();
            B_member_table b  = new B_member_table();
            M_member_table p  = new M_member_table();

            p = b.GetModel(reqst.body.userId);

            if (p != null)
            {
                if (p.UsrCustId.Length <= 0)
                {
                    LoggerHelper.Warning("未实名,跳转至实名接口");
                    RequestParam <RequestValidate> vldParam = new RequestParam <RequestValidate>();
                    RequestValidate rv = new RequestValidate();
                    rv.userId     = reqst.body.userId.ToString();
                    vldParam.body = rv;
                    return(RedirectToAction("RequestRealName", "Index", new { area = "UserAuthentication", userId = reqst.body.userId.ToString() }));//未实名,跳转至实名接口
                }



                br.Version   = "10";
                br.CmdId     = "UserLogin";
                br.MerCustId = Settings.Instance.MerCustId;
                br.UsrCustId = p.UsrCustId;
                return(View(br));
            }
            else
            {
                return(Content("异常错误,请联系管理员"));
            }
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public M_member_table GetModel(int registerid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 registerid,username,registration_time,password,mobile,email,UsrCustId,realname,iD_number,transactionpassword,istransactionpassword,ismobile,isrealname,isbankcard,isemail,userstate,account_total_assets,available_balance,collect_total_amount,frozen_sum,open_tonto_account,tonto_account_user,usertypes,invitedcode,UsrId,useridentity,Channelsource,Tid,lastlogintime,lastloginIP,registration_time,LostInvitation,channel_invitedcode from hx_member_table ");
            strSql.Append(" where registerid=@registerid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@registerid", SqlDbType.Int, 4)
            };
            parameters[0].Value = registerid;

            M_member_table model = new M_member_table();
            DataSet        ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataHelper.GetEntity <M_member_table>(ds.Tables[0]));
                //return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        /// <summary>
        /// 判断用户是否为渠道用户
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="channelType">渠道类型</param>
        /// <returns></returns>
        public static bool CheckIsChannel(int userID, ref string channelType)
        {
            //chuangtouEntities ef = new chuangtouEntities();
            bool           t = true;
            B_member_table b_member_table = new B_member_table();
            M_member_table investor       = new M_member_table();

            investor = b_member_table.GetModel(userID);
            if (investor == null)
            {
                return(false);
            }
            string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where  invpersonid=" + investor.registerid + " ";//查询本人是否已经被邀请注册过

            DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
            //if (dtcode.Rows.Count > 0 || (investor != null && !string.IsNullOrWhiteSpace(investor.channel_invitedcode)))
            //{
            int uuid = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0; //邀请用户id

            //用户等级为渠道 不参与活动
            if (investor != null && investor.useridentity == 4)
            {
                return(t);
            }
            int investCount = B_usercenter.GetInvestCountByUserid(investor.registerid);

            //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动
            if (uuid != 0)
            {
                M_member_table py = new M_member_table();
                B_member_table oy = new B_member_table();
                py = oy.GetModel(uuid);//推荐人
                if ((py != null && py.useridentity == 4))
                {
                    return(t);
                }
            }

            if (string.IsNullOrWhiteSpace(investor.channel_invitedcode))
            {
                return(false);
            }
            string     cacheName     = "hx_Channel_" + investor.channel_invitedcode;
            hx_Channel channelEnitty = (hx_Channel)Utils.GetThirdCacheObject(cacheName);

            if (channelEnitty == null)
            {
                channelEnitty = ef.hx_Channel.AsNoTracking().Where(p => p.Invitedcode == investor.channel_invitedcode).FirstOrDefault();
            }
            if (channelEnitty != null)
            {
                channelType = channelEnitty.type;
                Utils.SetThirdCacheName(cacheName, channelEnitty, 5);
            }
            return(channelEnitty != null);
        }
Example #6
0
        // GET: activity/W20160926
        public ActionResult Index(string invitedcode = "")
        {
            if (!string.IsNullOrEmpty(invitedcode))
            {
                Initial(invitedcode);
            }
            bool hadUsed = false;

            ViewBag.CanUseCount = GetCanUseTimes(ref hadUsed);

            string invitationCode = "";
            int    userID         = Settings.Instance.CurrentUserId;

            if (userID < 1)
            {
                invitationCode = "";
            }
            else
            {
                B_member_table bllUser = new B_member_table();
                M_member_table user    = bllUser.GetModel(userID);
                if (user == null || user.registerid <= 0)
                {
                    invitationCode = "";
                }
                else
                {
                    invitationCode = user.invitedcode;
                }
            }
            TXShareHelper tx = new TXShareHelper();

            #region TXShareHelper 赋值逻辑
            //tx.link = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "") + "/register/?invitedcode=" + invitationCode;//
            tx.link = Request.Url.AbsoluteUri.ToString().Trim();
            tx.CheckSignature(tx.link);

            tx.appid = Utils.GetAppSetting("WeiXinAppid");
            tx.title = "金秋十月收获季,创利投给您送红包啦!";
            if (Utils.GetAppSetting("DeBug") == "1")
            {
                tx.imgUrl = Utils.GetAppSetting("MDeBugURL") + "Images/shareoutimg.jpg";
            }
            else
            {
                tx.imgUrl = Utils.GetAppSetting("MReleaseURL") + "Images/shareoutimg.jpg";
            }
            tx.desc = "金秋十月收获季节,创利投为您锦上添花!动动手指,注册完成就能领现金哦……";

            #endregion
            //ViewBag.InvCode = invitationCode;
            ViewBag.linkOutUrl    = Request.Url.AbsoluteUri.ToString().Trim().Split('?')[0] + "?invitedcode=" + invitationCode;
            ViewBag.TXShareHelper = tx;
            return(View());
        }
Example #7
0
        /// <summary>
        /// 用户注册,第三方开户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        // GET: opening_account
        public ActionResult Index(int id)
        {
            B_member_table b   = new B_member_table();
            M_member_table p   = new M_member_table();
            int            uid = Utils.checkloginsession();

            p = b.GetModel(uid);
            string UsrId1 = p.username;
            string url    = Utils.GetChinapnrUrl();

            M_UserRegister m = new M_UserRegister();

            m.MerId     = Utils.GetMerId();
            m.Version   = "10";
            m.CmdId     = "UserRegister";
            m.MerCustId = Utils.GetMerCustID();
            m.BgRetUrl  = Utils.GetRe_url("Thirdparty/Bg_Succ_Registered");
            // m.BgRetUrl = Utils.GetRe_url("22Thirdparty/Bg_Succ_Registered");
            // m.RetUrl = "http://localhost:17745/Register/Succ_Registered";
            m.RetUrl = Utils.GetRe_url("Register/Succ_Registered");
            m.UsrMp  = p.mobile;
            // m.UsrEmail = p.email;
            m.UsrId = UsrId1;
            LogInfo.WriteLog("注册开户请求报文:" + FastJSON.toJOSN(m));
            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(m.Version);
            chkVal.Append(m.CmdId);
            chkVal.Append(m.MerCustId);
            chkVal.Append(m.BgRetUrl);
            chkVal.Append(m.RetUrl);
            chkVal.Append(m.UsrId);
            chkVal.Append(m.UsrMp);

            string chkv = chkVal.ToString();
            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr();
            //需要指定提交字符串的长度
            int           len        = Encoding.UTF8.GetBytes(chkv).Length;
            StringBuilder sbChkValue = new StringBuilder(256);
            //加签
            int str = DllInterop.SignMsg(m.MerId, merKeyFile, chkv, len, sbChkValue);

            m.ChkValue = sbChkValue.ToString();



            ViewBag.url = url;
            ViewBag.uid = uid;
            return(View(m));
        }
Example #8
0
        /// <summary>
        /// 银行卡管理
        /// </summary>
        /// <returns></returns>

        public ActionResult Index()
        {
            int userid = CurrentUserId;

            B_member_table b  = new B_member_table();
            M_member_table pu = new M_member_table();

            pu = b.GetModel(userid);



            //判断用户是否开户
            if (string.IsNullOrEmpty(pu.UsrCustId))
            {
                string temstr = "/opening_account/Index/" + userid.ToString();
                return(Redirect(temstr));
            }


            //if (pu.isbankcard == 0)
            //{
            checkbank(pu.UsrCustId);

            //}

            V_UsrBindCardBank Ucard = new V_UsrBindCardBank();

            Ucard = ef.V_UsrBindCardBank.Where(p => p.registerid == userid).OrderByDescending(p => p.defCard).Take(1).FirstOrDefault();

            List <V_UsrBindCardBank> cards = ef.V_UsrBindCardBank.Where(c => c.registerid == userid).ToList();

            cards = BusinessLogicHelper.LeftOne(cards);
            List <V_UsrBindCardBank> listcard = cards;                                               //网银卡列表

            List <V_UsrBindCardBank> listquickcard = cards.Where(c => c.BindCardType == 1).ToList(); //快捷卡列表

            var flag = listquickcard != null && listquickcard.Count() > 0;

            if (flag)
            {
                ViewBag.listcard = listquickcard;
            }
            else
            {
                ViewBag.listcard = listcard;
            }

            ViewBag.flag = flag;
            return(View(Ucard));
        }
Example #9
0
        /// <summary>
        /// 绑定银行卡
        /// </summary>
        /// <returns></returns>

        public ActionResult Bind()
        {
            int    userid = CurrentUserId;
            string url    = Utils.GetChinapnrUrl();

            B_member_table b = new B_member_table();
            M_member_table p = new M_member_table();

            p = b.GetModel(userid);
            string Version   = "10";
            string CmdId     = "UserBindCard";
            string MerCustId = Utils.GetMerCustID();
            string UsrCustId = p.UsrCustId;
            string BgRetUrl  = Utils.GetRe_url("Thirdparty/Bgthirdpartybindbank");
            string MerPriv   = Utils.Base64Encoder("chuanglitou");

            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(Version);
            chkVal.Append(CmdId);
            chkVal.Append(MerCustId);
            chkVal.Append(UsrCustId);
            chkVal.Append(BgRetUrl);
            chkVal.Append(MerPriv);

            string chkv = chkVal.ToString();

            LogInfo.WriteLog(chkv);

            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr();
            //需要指定提交字符串的长度
            int           len        = Encoding.UTF8.GetBytes(chkv).Length;
            StringBuilder sbChkValue = new StringBuilder(256);
            //加签
            int str = DllInterop.SignMsg(Utils.GetMerId(), merKeyFile, chkv, len, sbChkValue);

            string ChkValue = sbChkValue.ToString();

            ViewBag.url       = url;
            ViewBag.Version   = Version;
            ViewBag.CmdId     = CmdId;
            ViewBag.MerCustId = MerCustId;
            ViewBag.UsrCustId = UsrCustId;
            ViewBag.BgRetUrl  = BgRetUrl;
            ViewBag.MerPriv   = MerPriv;
            ViewBag.ChkValue  = ChkValue;

            return(View());
        }
Example #10
0
        /// <summary>
        /// 判断当前用户是否可以参加活动
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <returns></returns>
        public static bool CheckChannel(int userID)
        {
            bool           t = false;
            B_member_table b_member_table = new B_member_table();
            M_member_table investor       = new M_member_table();

            investor = b_member_table.GetModel(userID);
            if (investor == null)
            {
                return(false);
            }
            string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where  invpersonid=" + investor.registerid + " ";//查询本人是否已经被邀请注册过

            DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
            //if (dtcode.Rows.Count > 0 || (investor != null && !string.IsNullOrWhiteSpace(investor.channel_invitedcode)))
            //{
            int uuid = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0; //邀请用户id

            //用户等级为渠道 不参与活动
            if (investor != null && investor.useridentity == 4)
            {
                return(t);
            }
            int investCount = B_usercenter.GetInvestCountByUserid(investor.registerid);

            //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动
            if (uuid != 0)
            {
                M_member_table py = new M_member_table();
                B_member_table oy = new B_member_table();
                py = oy.GetModel(uuid);//推荐人
                if ((py != null && py.useridentity == 4) && investCount <= 1)
                {
                    return(t);
                }
            }

            //新渠道机制判断
            using (ChannelAct channelAct = new ChannelAct())
            {
                //按照渠道类型和投资次数判断是否参与此次活动
                if (!string.IsNullOrWhiteSpace(investor.channel_invitedcode) && !channelAct.IsParticipateActivity(investor.channel_invitedcode, investCount))
                {
                    return(t);
                }
            }
            return(true);
        }
Example #11
0
        /// <summary>
        /// 新用户注册活动
        /// </summary>
        /// <param name="registerid">用户id</param>
        /// <param name="ActUser">面向用户 0不限  1首次投资用户 2非首投用户 3每标首投用户 4每标最大投资用户 5所有投资用户</param>
        protected internal void SendBonusAfterRegister(int registerid, string targetPlatform, int ActUser = 0)
        {
            /// <param name="ActTypeId">活动类型id  1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送 </param>

            bool            t        = true;
            B_member_table  oy       = new B_member_table();
            hx_member_table investor = new hx_member_table();

            investor = ef.hx_member_table.Where(c => c.registerid == registerid).FirstOrDefault();                                                  //oy.GetModel(Registerid);//被推荐人  也就是投资人
            string    codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where  invpersonid=" + registerid + " "; //查询本人是否已经被邀请注册过
            DataTable dtcode  = DbHelperSQL.GET_DataTable_List(codesql);
            int       uuid    = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0;                                    //邀请用户id

            //用户等级为渠道 不参与活动
            if (investor != null && investor.useridentity == 4)
            {
                t = false;
            }
            //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动
            if (uuid != 0)
            {
                M_member_table py = new M_member_table();
                py = oy.GetModel(uuid);//推荐人
                if (py != null && py.useridentity == 4)
                {
                    t = false;
                }
            }
            //新渠道机制判断
            using (ChannelAct channelAct = new ChannelAct())
            {
                //按照渠道类型和投资次数判断是否参与此次活动
                if (!channelAct.IsParticipateActivity(investor.channel_invitedcode, 0))
                {
                    t = false;
                }
            }

            if (t == true)
            {
                //新人注册奖励
                List <hx_UserAct> hut = RegisterActBonus(registerid, targetPlatform, ActUser);

                BonusRecordOperate(registerid, hut, "新人注册");
            }
        }
Example #12
0
        public ActionResult Index(RequestParam <RequestMemberDetail> reqst)
        {
            B_member_table b = new B_member_table();
            M_member_table p = new M_member_table();

            p = b.GetModel(reqst.body.userId);
            string Version   = "10";
            string CmdId     = "UserBindCard";
            string MerCustId = Settings.Instance.MerCustId;
            string UsrCustId = p.UsrCustId;
            string BgRetUrl  = Settings.Instance.GetCallbackUrl("/MemberCenter/BindCard/BindCardCallback");
            string MerPriv   = Settings.Instance.Base64Encoder("chuanglitou");

            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(Version);
            chkVal.Append(CmdId);
            chkVal.Append(MerCustId);
            chkVal.Append(UsrCustId);
            chkVal.Append(BgRetUrl);
            chkVal.Append(MerPriv);

            string chkv = chkVal.ToString();

            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.MerPr;
            //需要指定提交字符串的长度
            int           len        = Encoding.UTF8.GetBytes(chkv).Length;
            StringBuilder sbChkValue = new StringBuilder(256);
            //加签
            int str = DllInterop.SignMsg(Settings.Instance.MerId, merKeyFile, chkv, len, sbChkValue);

            string ChkValue = sbChkValue.ToString();

            UserEntity br = new UserEntity();

            br.Version   = Version;
            br.CmdId     = CmdId;
            br.MerCustId = MerCustId;
            br.UsrCustId = UsrCustId;
            br.BgRetUrl  = BgRetUrl;
            br.MerPriv   = MerPriv;
            br.ChkValue  = ChkValue;

            return(View(br));
        }
Example #13
0
        /// <summary>
        /// 发放现金奖励
        /// </summary>
        /// <param name="luckDrawID"></param>
        /// <returns></returns>
        public ActionResult CheckCashAward(string luckDrawID)
        {
            JavaScriptSerializer jss   = new JavaScriptSerializer();
            int     online_adminuserid = 0;
            M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString());

            if (M_uid == null)
            {
                return(Content(jss.Serialize(new { code = -1, data = "请登录后在进行该操作!" })));
            }
            B_LuckDraw       bllLuckDraw = new B_LuckDraw();
            M_LuckDrawRecord record      = bllLuckDraw.GetModel(luckDrawID);

            if (record.Ldre_AwardType != (int)EnumHelp.LuckDrawEnum.E_AwardType.type0)
            {
                return(Content(jss.Serialize(new { code = -1, data = "只有未发放的现金奖励才能进行该操作!" })));
            }
            B_member_table bllUser = new B_member_table();
            M_member_table user    = bllUser.GetModel(record.Ldre_UserID);

            decimal orderID = decimal.Parse(Utils.Createcode());
            string  errMsg  = "";

            if (string.IsNullOrWhiteSpace(user.UsrCustId))
            {
                return(Content(jss.Serialize(new { code = -1, data = "会员未开通汇付账号,无法完成转账操作" })));
            }
            record.Ldre_AwardType = (int)EnumHelp.LuckDrawEnum.E_AwardType.type4;
            record.Ldre_OrderID   = orderID.ToString();
            if (!bllLuckDraw.UpdateModel(record))
            {
                LogInfo.WriteLog("九月抽奖活动,后台列表审核,更新抽奖记录状态失败:" + string.Format(" operater:{0};operateTime:{1};", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                return(Content(jss.Serialize(new { code = -1, data = "更新抽奖记录失败" })));
            }
            //hx_Activity_schedule 活动表中 50元红包的ID 为 53,对应于LuckDrawRecord中的awardID 为 -2 的数据均替换为 53
            //if (!LuckDrawSendCash(orderID, 50, user.UsrCustId, 53, user.registerid, record.Ldre_AwardName, ref errMsg))
            if (SendCash(record.Ldre_AwardID, user.registerid))
            {
                LogInfo.WriteLog("九月抽奖活动,后台列表审核,现金奖励发放失败:" + string.Format(" operater:{0};operateTime:{1};errMsg:{2}", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), errMsg));
                return(Content(jss.Serialize(new { code = -1, data = errMsg })));
            }
            LogInfo.WriteLog("九月抽奖活动,后台列表审核,现金发放成功:" + string.Format(" operater:{0};operateTime:{1};", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            return(Content(jss.Serialize(new { code = 0, data = "现金发放成功" })));
        }
Example #14
0
        /// <summary>
        /// 获取可用的抽奖次数
        /// </summary>
        /// <returns></returns>
        private int GetCanUseTimes(ref bool hadUsed)
        {
            chuangtouEntities ef = new chuangtouEntities();
            int userID           = Settings.Instance.CurrentUserId;

            if (userID < 1)
            {
                return(0);
            }
            B_member_table bllUser = new B_member_table();
            M_member_table user    = bllUser.GetModel(userID);

            if (user == null || user.registerid <= 0)
            {
                return(0);
            }
            int cut = 0;

            //如果用户是新用户且已经实名认证,则抽奖次数加一
            if (user.Registration_time > _activityTime && !string.IsNullOrWhiteSpace(user.UsrCustId))
            {
                cut += 1;
            }
            //用户邀请好友,好友实名注册且投资的人数
            B_td_Userinvitation bllUserInvitation = new B_td_Userinvitation();
            int tcuc = bllUserInvitation.GetTotalCanUseCount(_activityTime, userID);

            if (tcuc > 0)
            {
                cut += tcuc;
            }
            int awardID   = ConfigHelper.GetConfigInt("GrabCash");
            int usedCount = ef.hx_UserAct.Where(c => c.ActID == awardID && c.registerid == userID).Count();

            hadUsed = usedCount > 0;
            if (hadUsed)
            {
                cut -= usedCount;
            }
            return(cut);
        }
Example #15
0
        public JsonResult IsExistUser()
        {
            int            userid = Utils.checkloginsession();
            string         temstr = string.Empty;
            string         rs     = "n";//默认没有用户
            B_member_table b      = new B_member_table();
            M_member_table pu     = new M_member_table();

            pu = b.GetModel(userid);
            //判断用户是否存在
            if (pu != null && userid != 0)
            {
                rs = "y";
            }
            else
            {
                rs = "n";
            }

            var result = new { rs = rs };

            return(Json(result));
        }
Example #16
0
        // GET: BindCard
        public ActionResult Index()
        {
            int userid = Utils.checkloginsession();

            B_member_table b  = new B_member_table();
            M_member_table pu = new M_member_table();

            pu = b.GetModel(userid);



            //判断用户是否开户
            if (string.IsNullOrEmpty(pu.UsrCustId))
            {
                string temstr = "/opening_account/Index/" + userid.ToString();
                return(Redirect(temstr));
            }


            //if (pu.isbankcard == 0)
            //{
            checkbank(pu.UsrCustId);

            //}

            V_UsrBindCardBank Ucard = new V_UsrBindCardBank();

            Ucard = ef.V_UsrBindCardBank.Where(p => p.registerid == userid).OrderByDescending(p => p.defCard).Take(1).FirstOrDefault();


            List <V_UsrBindCardBank> listcard = ef.V_UsrBindCardBank.Where(c => c.registerid == userid).ToList();

            listcard         = BusinessLogicHelper.LeftOne(listcard);
            ViewBag.listcard = listcard;
            return(View(Ucard));
        }
Example #17
0
        public bool SendCash(int actID, int Registerid)
        {
            bool t = false;
            chuangtouEntities ef  = new chuangtouEntities();
            hx_ActivityTable  hat = new ActFacade().GetActivityModel(actID); //GetActTableInfo(ActTypeId, ActUser, 1);

            if (hat != null)
            {
                //判是否过期
                if (hat.ActStarttime <= DateTime.Now && DateTime.Now <= hat.ActEndtime)
                {
                    string               ActRule = hat.ActRule;
                    List <MAmtList>      mlist   = new List <MAmtList>();
                    JavaScriptSerializer js      = new JavaScriptSerializer();
                    //MActCash mc = new MActCash();
                    Mcoupon mcp = new Mcoupon();
                    mcp = js.Deserialize <Mcoupon>(ActRule);
                    //mlist = js.Deserialize<List<MAmtList>>(ActRule);

                    //检查分发奖励是否超过顶限,如果超过直接跳过
                    //int TopNum = B_usercenter.GetTopNum(hat.ActID);
                    //项目已经发放的金额
                    //decimal totalAmt = B_usercenter.GetTopAmtCount(hat.ActID);
                    //第一次投资获取对应奖励
                    decimal actamt = mcp.cash;//GetActAmt(mc, InvestAmt, TopNum);

                    //if (mc.TopAmt > totalAmt && mc.TopNum > TopNum)
                    //{

                    t = true;
                    if (actamt > 0)//大于 0里写入对应的奖励数据
                    {
                        hx_UserAct hua = new hx_UserAct();
                        hua.ActTypeId    = hat.ActTypeId;
                        hua.registerid   = Registerid;
                        hua.RewTypeID    = hat.RewTypeID;
                        hua.ActID        = hat.ActID;
                        hua.Amt          = actamt;
                        hua.Uselower     = 0.00M;
                        hua.Usehight     = 0.00M;
                        hua.AmtEndtime   = DateTime.Parse(hat.ActEndtime.ToString()).AddMonths(1);
                        hua.AmtUses      = 1; //没指定情况下默认为单独使用
                        hua.UseState     = 5; //现金未转账
                        hua.UseTime      = DateTime.Now;
                        hua.AmtProid     = 0; //未使用默认为0
                        hua.ISSmsOne     = 0;
                        hua.IsSmsThree   = 0;
                        hua.isSmsFifteen = 0;
                        hua.IsSmsSeven   = 0;
                        hua.isSmsSixteen = 0;
                        hua.OrderID      = decimal.Parse(Utils.Createcode());
                        hua.Createtime   = DateTime.Now;
                        hua.Title        = hat.ActName;
                        hua.UseLifeLoan  = "";
                        ef.hx_UserAct.Add(hua);
                        int i = ef.SaveChanges();
                        if (i > 0)
                        {
                            //录入成功,后进行转账操作
                            //1.获取用户对向
                            M_member_table p = new M_member_table();
                            B_member_table o = new B_member_table();
                            p = o.GetModel(Registerid);

                            if (p != null)
                            {
                                //2.调用商户向用户转账接口
                                Transfer   tf   = new Transfer();
                                ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, actamt, hua.OrderID.ToString(), hua.ActID.ToString(), "/Thirdparty/ToUserTransfer");
                                if (retf != null)
                                {
                                    if (retf.RespCode == "000")
                                    {
                                        //3.事务处理操作账户及插入流水

                                        #region 验签缓存处理
                                        string cachename = retf.OrdId + "ToUserTransfer" + retf.InCustId;

                                        if (Utils.GeTThirdCache(cachename) == 0)
                                        {
                                            Utils.SetThirdCache(cachename);
                                            B_usercenter BUC = new B_usercenter();
                                            int          ic  = BUC.UpateActToUserTransfer(retf, 0); //用户余更新
                                            if (ic > 0)
                                            {
                                                string    sql = "SELECT registerid,username,mobile  from hx_member_table where UsrCustId='" + retf.InCustId + "'";
                                                DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);
                                                if (dt.Rows.Count > 0)
                                                {
                                                    /*短信接口*/


                                                    #region 流水信息
                                                    B_usercenter ors = new B_usercenter();
                                                    decimal      di  = ors.GetUsridAvailable_balance(int.Parse(dt.Rows[0]["registerid"].ToString()));
                                                    // di = di + decimal.Parse(hua.Amt.ToString());
                                                    StringBuilder strSql = new StringBuilder();
                                                    strSql.Append("insert into hx_Capital_account_water(");
                                                    strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                                                    strSql.Append(" values (");
                                                    strSql.Append("" + int.Parse(dt.Rows[0]["registerid"].ToString()) + "," + decimal.Parse(hua.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.现金奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + "现金奖励" + "')");

                                                    DbHelperSQL.RunSql(strSql.ToString());

                                                    strSql.Clear();
                                                    #endregion

                                                    #region 奖励流水
                                                    M_bonus_account_water mbaw = new M_bonus_account_water();
                                                    B_bonus_account_water bbaw = new B_bonus_account_water();
                                                    DateTime dte = DateTime.Now;
                                                    mbaw.bonus_account_id       = int.Parse(hua.ActID.ToString());
                                                    mbaw.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString());
                                                    mbaw.income             = decimal.Parse(retf.TransAmt);
                                                    mbaw.expenditure        = 0.00M;
                                                    mbaw.time_of_occurrence = DateTime.Now;

                                                    mbaw.award_description = hat.ActName + "奖励已汇入个人账户";
                                                    mbaw.water_type        = 0;
                                                    bbaw.Add(mbaw);

                                                    #endregion


                                                    #region MyRegion  系统消息
                                                    DateTime            dti = DateTime.Now;
                                                    M_td_System_message pm  = new M_td_System_message();
                                                    pm.MReg     = int.Parse(dt.Rows[0]["registerid"].ToString());
                                                    pm.Mstate   = 0;
                                                    pm.MTitle   = hat.ActName;
                                                    pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功" + hat.ActName + ",现金奖励 " + retf.TransAmt + "元。如有问题可咨询创利投的客服!";
                                                    pm.PubTime  = dti;
                                                    B_usercenter.AddMessage(pm);
                                                    #endregion
                                                }
                                            }

                                            t = true;
                                        }
                                        #endregion
                                    }
                                }
                            }
                        }
                    }
                    //}
                }
            }


            return(t);
        }
Example #18
0
        public ActionResult Su_Repayment()
        {
            Utils.SetSYSDateTimeFormat();

            chuangtouEntities ef  = new chuangtouEntities();
            string            str = "";
            ReRepayment       Re  = new ReRepayment();

            Re.CmdId        = DNTRequest.GetString("CmdId");
            Re.RespCode     = DNTRequest.GetString("RespCode");
            Re.MerCustId    = DNTRequest.GetString("MerCustId");
            Re.ProId        = DNTRequest.GetString("ProId");
            Re.OrdId        = DNTRequest.GetString("OrdId");
            Re.OrdDate      = DNTRequest.GetString("OrdDate");
            Re.OutCustId    = DNTRequest.GetString("OutCustId");
            Re.SubOrdId     = DNTRequest.GetString("SubOrdId");
            Re.SubOrdDate   = DNTRequest.GetString("SubOrdDate");
            Re.OutAcctId    = DNTRequest.GetString("OutAcctId");
            Re.TransAmt     = DNTRequest.GetString("TransAmt");
            Re.PrincipalAmt = DNTRequest.GetString("PrincipalAmt");
            Re.InterestAmt  = DNTRequest.GetString("InterestAmt");
            Re.Fee          = DNTRequest.GetString("Fee");
            Re.InCustId     = DNTRequest.GetString("InCustId");
            Re.InAcctId     = DNTRequest.GetString("InAcctId");
            Re.FeeObjFlag   = DNTRequest.GetString("FeeObjFlag");
            Re.DzObject     = DNTRequest.GetString("DzObject");
            Re.BgRetUrl     = DNTRequest.GetString("BgRetUrl");
            Re.MerPriv      = DNTRequest.GetString("MerPriv");
            Re.RespExt      = DNTRequest.GetString("RespExt");
            LogInfo.WriteLog("后台还款返回报文:" + FastJSON.toJOSN(Re));

            string version = "20";

            if (string.IsNullOrEmpty(Re.TransAmt) || Re.TransAmt == "0.00")
            {
                version = "30";
            }
            StringBuilder builder = new StringBuilder();

            builder.Append(Re.CmdId);
            builder.Append(Re.RespCode);
            builder.Append(Re.MerCustId);
            if (version == "30")
            {
                builder.Append(Re.ProId);
            }
            builder.Append(Re.OrdId);
            builder.Append(Re.OrdDate);
            builder.Append(Re.OutCustId);
            builder.Append(Re.SubOrdId);
            builder.Append(Re.SubOrdDate);
            builder.Append(Re.OutAcctId);
            if (version == "30")
            {
                builder.Append(Re.PrincipalAmt);
                builder.Append(Re.InterestAmt);
            }
            else
            {
                builder.Append(Re.TransAmt);
            }
            builder.Append(Re.Fee);
            builder.Append(Re.InCustId);
            builder.Append(Re.InAcctId);
            builder.Append(Re.FeeObjFlag);
            if (version == "30")
            {
                builder.Append(Re.DzObject);
            }
            builder.Append(HttpUtility.UrlDecode(Re.BgRetUrl));
            builder.Append(Re.MerPriv);
            builder.Append(HttpUtility.UrlDecode(Re.RespExt));
            // builder.Append(Re.ChkValue);
            var msg = builder.ToString();

            if (version == "30")
            {
                msg = Utils.MD5(msg);
            }
            string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
            int    ret        = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, Re.ChkValue);

            LogInfo.WriteLog("后台验签 ret= " + ret.ToString());
            if (ret == 0)
            {
                if (Re.RespCode == "000" || Re.TransAmt == "0.00")
                {
                    string cachename = "Repayment" + Re.OrdId;
                    if (Utils.GeTThirdCache(cachename) == 0)
                    {
                        Utils.SetThirdCache(cachename);

                        B_member_table          o   = new B_member_table();
                        M_member_table          p   = new M_member_table();
                        M_member_table          p2  = new M_member_table();
                        M_Capital_account_water baw = new M_Capital_account_water();
                        V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement();
                        int income_statement_id = int.Parse(Re.MerPriv);
                        item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault();
                        p    = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象

                        baw.membertable_registerid = p.registerid;
                        baw.income             = 0.00M;
                        baw.expenditure        = decimal.Parse(Re.TransAmt);
                        baw.time_of_occurrence = DateTime.Now;
                        baw.account_balance    = p.available_balance - baw.expenditure; //面要得么帐户余额
                        baw.types_Finance      = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.还款.ToString());
                        baw.createtime         = DateTime.Now;
                        baw.keyid   = 0;
                        baw.remarks = Re.OrdId + "," + Re.OrdDate;

                        M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象


                        p2 = o.GetModel(int.Parse(item.investor_registerid.ToString())); //投资人用户对象

                        iaw.membertable_registerid = p2.registerid;
                        iaw.income             = decimal.Parse(Re.TransAmt);
                        iaw.expenditure        = 0.00M;
                        iaw.time_of_occurrence = DateTime.Now;
                        iaw.account_balance    = p2.available_balance + iaw.income; //面要得么帐户余额
                        iaw.types_Finance      = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款人还款.ToString());
                        iaw.createtime         = DateTime.Now;
                        iaw.keyid   = 0;
                        iaw.remarks = Re.OrdId + "," + Re.OrdDate;


                        int targetid = int.Parse(item.targetid.ToString());
                        //判断是否为最后一期还款,并进行相应状态处理
                        hx_repayment_plan plan = (from a in ef.hx_repayment_plan where a.targetid == targetid select a).OrderByDescending(a => a.current_period).Take(1).FirstOrDefault();
                        var lastcur            = plan.current_period;
                        //判断是否是最后一期,如果是对本金处理。得直接用最后一期还款金额减去本金,这样就解决多出本金问题
                        bool lastrepamt = false;

                        if (item.current_investment_period.ToString() == lastcur.ToString())
                        {
                            lastrepamt = true;
                        }



                        //需要更新投资记录表已还款金额

                        B_usercenter BUC = new B_usercenter();

                        decimal PrincipalInterest = decimal.Parse(item.Principal.ToString()) + decimal.Parse(item.interestpayment.ToString()); //本金加利息

                        decimal PInterest = decimal.Parse(item.interestpayment.ToString());                                                    //利息

                        Re.MerPriv = DateTime.Parse(item.interest_payment_date.ToString()).ToString("yyyy-MM-dd");                             //传入还款日期
                        int bucd = BUC.Repayment_Successfully(Re, baw, iaw, lastrepamt, PrincipalInterest, PInterest);

                        if (bucd > 0)
                        {
                            // 尊敬#UserName#,您投资的第#PID#号标第#ORDER#期还款已到帐,本次已成功还款#MONEY#元.欢迎继续投资!【创利投】



                            #region 短信通知
                            //短信通知

                            string contxt = Utils.GetMSMEmailContext(11, 1); // 获取注册成功邮件内容

                            StringBuilder sbsms = new StringBuilder(contxt);

                            sbsms = sbsms.Replace("#USERANEM#", item.username.ToString());

                            sbsms = sbsms.Replace("#PID#", item.targetid.ToString());

                            sbsms = sbsms.Replace("#ORDER#", item.current_investment_period.ToString());

                            sbsms = sbsms.Replace("#MONEY#", item.repayment_amount.ToString());


                            string mobile = item.mobile.ToString();

                            M_td_SMS_record psms    = new M_td_SMS_record();
                            B_td_SMS_record osms    = new B_td_SMS_record();
                            int             smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资回款.ToString());
                            psms.phone_number = mobile;
                            psms.sendtime     = DateTime.Now;
                            psms.senduserid   = int.Parse(item.investor_registerid.ToString());
                            psms.smstype      = smstype;
                            psms.smscontext   = sbsms.ToString();
                            psms.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                            psms.vcode        = "";

                            osms.Add(psms);
                            #endregion


                            #region 系统消息
                            //系统消息


                            DateTime dti = DateTime.Now;

                            M_td_System_message pm = new M_td_System_message();
                            pm.MReg   = int.Parse(item.investor_registerid.ToString());
                            pm.Mstate = 0;
                            pm.MTitle = "投资回款";
                            //  pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + dt.Rows[0]["investment_amount"].ToString() + "。如有问题可咨询创利投的客服!谢谢!";
                            pm.MContext = sbsms.ToString();
                            pm.PubTime  = dti;
                            pm.Mtype    = 2;
                            B_usercenter.AddMessage(pm);


                            #endregion

                            #region 更新标的状态为还还清
                            ///更新标的状态为还还清

                            if (item.current_investment_period.ToString() == lastcur.ToString())
                            {
                                //更新标的状态为还还清

                                string sql = "update hx_borrowing_target set tender_state=5 where targetid=" + item.targetid.ToString() + "";
                                DbHelperSQL.ExecuteSql(sql);

                                sql = "update  hx_Bid_records  set  payment_status =1 where bid_records_id=" + item.bid_records_id.ToString();
                                DbHelperSQL.ExecuteSql(sql);
                            }
                            #endregion


                            //Response.Write("还款验签成功!");
                        }
                        else
                        {
                            //Response.Write("还款更新失败!" + bucd.ToString());
                        }
                    }

                    str = "RECV_ORD_ID_" + Re.OrdId;
                    LogInfo.WriteLog(str + "后台还款成功");
                }
                else
                {
                    string cc = Utils.GetReturnCode(Int32.Parse(Re.RespCode));


                    if (cc.Contains("还款金额超过还款总额") || cc.Contains("重复的还款请求"))
                    {
                        B_member_table          o   = new B_member_table();
                        M_member_table          p   = new M_member_table();
                        M_member_table          p2  = new M_member_table();
                        M_Capital_account_water baw = new M_Capital_account_water();
                        V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement();
                        int income_statement_id = int.Parse(Re.MerPriv);
                        item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault();
                        p    = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象

                        baw.membertable_registerid = p.registerid;
                        baw.income             = 0.00M;
                        baw.expenditure        = decimal.Parse(Re.TransAmt);
                        baw.time_of_occurrence = DateTime.Now;
                        baw.account_balance    = p.available_balance - baw.expenditure; //面要得么帐户余额
                        baw.types_Finance      = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.还款.ToString());
                        baw.createtime         = DateTime.Now;
                        baw.keyid   = 0;
                        baw.remarks = Re.OrdId + "," + Re.OrdDate;

                        M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象


                        p2 = o.GetModel(int.Parse(item.investor_registerid.ToString())); //投资人用户对象

                        iaw.membertable_registerid = p2.registerid;
                        iaw.income             = decimal.Parse(Re.TransAmt);
                        iaw.expenditure        = 0.00M;
                        iaw.time_of_occurrence = DateTime.Now;
                        iaw.account_balance    = p2.available_balance + iaw.income; //面要得么帐户余额
                        iaw.types_Finance      = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款人还款.ToString());
                        iaw.createtime         = DateTime.Now;
                        iaw.keyid   = 0;
                        iaw.remarks = Re.OrdId + "," + Re.OrdDate;


                        int targetid = int.Parse(item.targetid.ToString());
                        //判断是否为最后一期还款,并进行相应状态处理
                        hx_repayment_plan plan = (from a in ef.hx_repayment_plan where a.targetid == targetid select a).OrderByDescending(a => a.current_period).Take(1).FirstOrDefault();
                        var lastcur            = plan.current_period;
                        //判断是否是最后一期,如果是对本金处理。得直接用最后一期还款金额减去本金,这样就解决多出本金问题
                        bool lastrepamt = false;

                        if (item.current_investment_period.ToString() == lastcur.ToString())
                        {
                            lastrepamt = true;
                        }



                        //需要更新投资记录表已还款金额

                        B_usercenter BUC = new B_usercenter();

                        decimal PrincipalInterest = decimal.Parse(item.Principal.ToString()) + decimal.Parse(item.interestpayment.ToString()); //本金加利息

                        decimal PInterest = decimal.Parse(item.interestpayment.ToString());                                                    //利息

                        Re.MerPriv = DateTime.Parse(item.interest_payment_date.ToString()).ToString("yyyy-MM-dd");                             //传入还款日期
                        int bucd = BUC.Repayment_Successfully(Re, baw, iaw, lastrepamt, PrincipalInterest, PInterest);

                        if (bucd > 0)
                        {
                            // 尊敬#UserName#,您投资的第#PID#号标第#ORDER#期还款已到帐,本次已成功还款#MONEY#元.欢迎继续投资!【创利投】



                            #region 短信通知
                            //短信通知

                            string contxt = Utils.GetMSMEmailContext(11, 1); // 获取注册成功邮件内容

                            StringBuilder sbsms = new StringBuilder(contxt);

                            sbsms = sbsms.Replace("#USERANEM#", item.username.ToString());

                            sbsms = sbsms.Replace("#PID#", item.targetid.ToString());

                            sbsms = sbsms.Replace("#ORDER#", item.current_investment_period.ToString());

                            sbsms = sbsms.Replace("#MONEY#", item.repayment_amount.ToString());


                            string mobile = item.mobile.ToString();

                            M_td_SMS_record psms    = new M_td_SMS_record();
                            B_td_SMS_record osms    = new B_td_SMS_record();
                            int             smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资回款.ToString());
                            psms.phone_number = mobile;
                            psms.sendtime     = DateTime.Now;
                            psms.senduserid   = int.Parse(item.investor_registerid.ToString());
                            psms.smstype      = smstype;
                            psms.smscontext   = sbsms.ToString();
                            psms.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                            psms.vcode        = "";

                            osms.Add(psms);
                            #endregion


                            #region 系统消息
                            //系统消息


                            DateTime dti = DateTime.Now;

                            M_td_System_message pm = new M_td_System_message();
                            pm.MReg   = int.Parse(item.investor_registerid.ToString());
                            pm.Mstate = 0;
                            pm.MTitle = "投资回款";
                            //  pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + dt.Rows[0]["investment_amount"].ToString() + "。如有问题可咨询创利投的客服!谢谢!";
                            pm.MContext = sbsms.ToString();
                            pm.PubTime  = dti;
                            pm.Mtype    = 2;
                            B_usercenter.AddMessage(pm);


                            #endregion

                            #region 更新标的状态为还还清
                            ///更新标的状态为还还清

                            if (item.current_investment_period.ToString() == lastcur.ToString())
                            {
                                //更新标的状态为还还清

                                string sql = "update hx_borrowing_target set tender_state=5 where targetid=" + item.targetid.ToString() + "";
                                DbHelperSQL.ExecuteSql(sql);

                                sql = "update  hx_Bid_records  set  payment_status =1 where bid_records_id=" + item.bid_records_id.ToString();
                                DbHelperSQL.ExecuteSql(sql);
                            }
                            #endregion


                            //Response.Write("还款验签成功!");
                        }
                        else
                        {
                            //Response.Write("还款更新失败!" + bucd.ToString());
                        }
                    }


                    //Response.Write("出现错误! " + Utils.GetReturnCode(Int32.Parse(Re.RespCode)));

                    /*
                     * string cc = Utils.GetReturnCode(Int32.Parse(Re.RespCode));
                     *
                     *
                     * if (cc.Contains("还款金额超过还款总额") || cc.Contains("重复的还款请求"))
                     * {
                     *
                     *  B_member_table o = new B_member_table();
                     *  M_member_table p = new M_member_table();
                     *  M_member_table p2 = new M_member_table();
                     *  M_Capital_account_water baw = new M_Capital_account_water();
                     *  V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement();
                     *  int income_statement_id = int.Parse(Re.MerPriv);
                     *  item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault();
                     *  p = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象
                     *
                     *
                     *  int ic = ef.hx_income_statement.Where(c => c.bid_records_id == item.bid_records_id && c.targetid == item.targetid && c.orderid== Re.OrdId).Update(c => new hx_income_statement { payment_status = 1, repayment_period = DateTime.Now });
                     *
                     *  if (ic > 0)
                     *  {
                     *      int userid = int.Parse(item.borrower_registerid.ToString());
                     *      UserInfoData ud = new UserInfoData();
                     *      ReQueryBalanceBg retloan = ud.Querybalance(userid);
                     *
                     *      if (retloan.RespCode == "000")
                     *      {
                     *          // sql = "update  hx_member_table  set  available_balance=" + decimal.Parse(retloan.AvlBal) + " ,frozen_sum=" + decimal.Parse(retloan.FrzBal) + " where  registerid=" + userid.ToString() + "";
                     *
                     *          //sql = "update  hx_member_table  set  available_balance=" + decimal.Parse(retloan.AvlBal) + "  where  registerid=" + userid.ToString() + "";
                     *
                     *          //DbHelperSQL.RunSql(sql);
                     *          B_usercenter bu = new B_usercenter();
                     *          bu.DataSync(retloan, userid.ToString());
                     *
                     *
                     *
                     *
                     *      }
                     *  }
                     */
                }
            }



            return(Content(str));
        }
Example #19
0
        public ActionResult BgLoans()
        {
            string outstr = "";

            ReLoans m = new ReLoans();

            m.CmdId         = DNTRequest.GetString("CmdId");
            m.RespCode      = DNTRequest.GetString("RespCode");
            m.RespDesc      = DNTRequest.GetString("RespDesc");
            m.MerCustId     = DNTRequest.GetString("MerCustId");
            m.OrdId         = DNTRequest.GetString("OrdId");
            m.OrdDate       = DNTRequest.GetString("OrdDate");
            m.OutCustId     = DNTRequest.GetString("OutCustId");
            m.OutAcctId     = DNTRequest.GetString("OutAcctId");
            m.TransAmt      = DNTRequest.GetString("TransAmt");
            m.Fee           = DNTRequest.GetString("Fee");
            m.InCustId      = DNTRequest.GetString("InCustId");
            m.InAcctId      = DNTRequest.GetString("InAcctId");
            m.SubOrdId      = DNTRequest.GetString("SubOrdId");
            m.SubOrdDate    = DNTRequest.GetString("SubOrdDate");
            m.FeeObjFlag    = DNTRequest.GetString("FeeObjFlag");
            m.IsDefault     = DNTRequest.GetString("IsDefault");
            m.IsUnFreeze    = DNTRequest.GetString("IsUnFreeze");
            m.UnFreezeOrdId = DNTRequest.GetString("UnFreezeOrdId");
            m.FreezeTrxId   = DNTRequest.GetString("FreezeTrxId");
            m.BgRetUrl      = DNTRequest.GetString("BgRetUrl");
            m.MerPriv       = DNTRequest.GetString("MerPriv");
            m.RespExt       = DNTRequest.GetString("RespExt");
            m.ChkValue      = DNTRequest.GetString("ChkValue");

            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(m.CmdId);
            chkVal.Append(m.RespCode);
            chkVal.Append(m.MerCustId);
            chkVal.Append(m.OrdId);
            chkVal.Append(m.OrdDate);
            chkVal.Append(m.OutCustId);
            chkVal.Append(m.OutAcctId);
            chkVal.Append(m.TransAmt);
            chkVal.Append(m.Fee);
            chkVal.Append(m.InCustId);
            chkVal.Append(m.InAcctId);
            chkVal.Append(m.SubOrdId);
            chkVal.Append(m.SubOrdDate);
            chkVal.Append(m.FeeObjFlag);
            chkVal.Append(m.IsDefault);
            chkVal.Append(m.IsUnFreeze);
            chkVal.Append(m.UnFreezeOrdId);
            chkVal.Append(m.FreezeTrxId);
            chkVal.Append(m.BgRetUrl);
            chkVal.Append(m.MerPriv);
            chkVal.Append(m.RespExt);

            string msg = chkVal.ToString();

            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
            //需要指定提交字符串的长度
            int           len        = Encoding.UTF8.GetBytes(msg).Length;
            StringBuilder sbChkValue = new StringBuilder(256);

            int ret = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue);


            LogInfo.WriteLog("验签:" + ret.ToString());

            if (ret == 0)
            {
                if (m.RespCode == "000")
                {
                    // M_borrowing_target m = new M_borrowing_target();
                    B_borrowing_target o = new B_borrowing_target();

                    B_member_table o1  = new B_member_table();
                    M_member_table p1  = new M_member_table();
                    M_member_table p2  = new M_member_table();
                    B_usercenter   BUC = new B_usercenter();


                    string cachename = m.OrdId + "Loans" + m.FreezeTrxId;

                    if (Utils.GeTThirdCache(cachename) == 0)
                    {
                        Utils.SetThirdCache(cachename);

                        M_Capital_account_water baw = new M_Capital_account_water(); //借款人流水对象


                        //标的id,借款人id,投资人id,投资记录bid,抵扣券金额
                        string   strings = m.MerPriv;
                        string[] sArray  = strings.Split('_');
                        if (sArray.Count() == 5)
                        {
                            p1 = o1.GetModel(int.Parse(sArray[1])); //借款人用户对象

                            LogInfo.WriteLog("sArray[1].ToString():" + sArray[1].ToString());
                            baw.membertable_registerid = p1.registerid;
                            baw.income      = decimal.Parse(m.TransAmt);
                            baw.expenditure = 0.00M;

                            baw.time_of_occurrence = DateTime.Now;

                            // decimal ff = p1.available_balance + decimal.Parse(retloan.TransAmt);
                            baw.account_balance = p1.available_balance;  //面要得么帐户余额

                            LogInfo.WriteLog("借款人余额:" + p1.available_balance);

                            baw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款转入.ToString());
                            baw.createtime    = DateTime.Now;
                            baw.keyid         = 0;
                            baw.remarks       = m.OrdId + "," + m.OrdDate;


                            M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象


                            p2 = o1.GetModel(int.Parse(sArray[2].ToString())); //投款人用户对象

                            iaw.membertable_registerid = p2.registerid;
                            iaw.income             = 0.00M;
                            iaw.expenditure        = decimal.Parse(m.TransAmt);
                            iaw.time_of_occurrence = DateTime.Now;
                            // decimal df=p1.available_balance - decimal.Parse(retloan.TransAmt);
                            iaw.account_balance = p2.available_balance;  //面要得么帐户余额
                            LogInfo.WriteLog("投资人余额:" + p2.ToString());

                            iaw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.项目投资.ToString());
                            iaw.createtime    = DateTime.Now;
                            iaw.keyid         = 0;
                            iaw.remarks       = m.OrdId + "," + m.OrdDate;

                            LogInfo.WriteLog("放款bid_records_id:" + sArray[3].ToString());


                            if (BUC.Loan_Successfully(m, baw, iaw, sArray[3].ToString(), decimal.Parse(sArray[4].ToString())) > 0)
                            {
                                //成功

                                outstr = "RECV_ORD_ID_" + m.OrdId;
                                LogInfo.WriteLog("后台主动通知操作成功:" + outstr);
                                return(Content(outstr));
                                //  Response.Redirect("/usercenter/index.html");
                            }
                        }
                    }
                }
            }



            return(Content(""));
        }
Example #20
0
        //汇付模拟发起的请求,没有携带用户的cookie,造成邀请丢失,邀请关系逻辑迁移至注册成功
        /// <summary>
        /// 注册成功汇付返回通知
        /// </summary>
        /// <returns></returns>
        public ActionResult Succ_Registered()
        {
            int            it        = -10000;
            string         username  = "";
            string         useremail = "";
            ReUserRegister m         = new ReUserRegister();

            m.CmdId     = DNTRequest.GetString("CmdId");
            m.RespCode  = DNTRequest.GetString("RespCode");
            m.RespDesc  = DNTRequest.GetString("RespDesc");
            m.MerCustId = DNTRequest.GetString("MerCustId");
            m.UsrId     = DNTRequest.GetString("UsrId");
            m.UsrCustId = DNTRequest.GetString("UsrCustId");
            m.BgRetUrl  = DNTRequest.GetString("BgRetUrl");
            m.TrxId     = DNTRequest.GetString("TrxId");
            m.RetUrl    = DNTRequest.GetString("RetUrl");
            m.MerPriv   = DNTRequest.GetString("MerPriv");
            m.IdType    = DNTRequest.GetString("IdType");
            m.IdNo      = DNTRequest.GetString("IdNo");
            m.UsrMp     = DNTRequest.GetString("UsrMp");
            useremail   = DNTRequest.GetString("UsrEmail");
            m.UsrEmail  = useremail;
            username    = HttpUtility.UrlDecode(DNTRequest.GetString("UsrName"));
            m.UsrName   = username;
            m.ChkValue  = DNTRequest.GetString("ChkValue");
            string        log    = "注册开户返回报文:" + FastJSON.toJOSN(m);
            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(m.CmdId);
            chkVal.Append(m.RespCode);
            chkVal.Append(m.MerCustId);
            chkVal.Append(m.UsrId);
            chkVal.Append(m.UsrCustId);
            chkVal.Append(m.BgRetUrl);
            chkVal.Append(m.TrxId);
            chkVal.Append(m.RetUrl);
            chkVal.Append(m.MerPriv);
            string chkv = chkVal.ToString();
            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
            int    ret        = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, m.ChkValue);

            log += ";ret:" + ret;
            if (ret == 0)
            {
                B_member_table ob = new B_member_table();
                M_member_table pm = new M_member_table();
                if (m.RespCode == "000")
                {
                    //为避免重复调用,增加缓存校验
                    string cachename = "UserRegister" + m.TrxId;
                    if (Utils.GeTThirdCache(cachename) == 0)
                    {
                        Utils.SetThirdCache(cachename);
                        M_bonus_account_water mbaw = new M_bonus_account_water();
                        B_bonus_account_water bbaw = new B_bonus_account_water();
                        B_usercenter          b    = new B_usercenter();
                        it   = b.Succ_Reg(m);
                        log += ";汇付开户成功后进行用户数据更新返回:" + it;
                        if (it > 0)
                        {
                            pm = ob.GetModel(Utils.GetUserSplit(m.UsrId));
                            ViewBag.registerid = pm.registerid;

                            //新人注册奖励
                            ActFacade act = new ActFacade();
                            log += ";注册ID:" + pm.registerid;
                            act.SendBonusAfterRegister(pm.registerid, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web);
                        }
                        else
                        {
                            /*第三方成功,本地服务器操作失败*/
                        }
                    }
                }
            }
            else
            {
                log += "验签不成功";
                /*验签不成功*/
            }
            LogInfo.WriteLog(log);
            return(View(m));
        }
Example #21
0
        /// <summary>
        /// 发放奖励
        /// </summary>
        /// <param name="activity"></param>
        /// <param name="registerID"></param>
        public static void DrawBonus(hx_ActivityTable activity, int registerID, int effectiveDays)
        {
            //chuangtouEntities ef = new chuangtouEntities();
            M_bonus_account_water mbaw = new M_bonus_account_water();
            B_bonus_account_water bbaw = new B_bonus_account_water();

            DateTime dte = DateTime.Now;//当前时间截点

            //if (activity.ActEndtime >= dte && activity.ActStarttime <= dte)   //发布的时候要释放
            if (true)
            {
                Mcoupon mcp             = new Mcoupon();
                JavaScriptSerializer js = new JavaScriptSerializer();
                mcp = js.Deserialize <Mcoupon>(activity.ActRule);
                hx_UserAct hua = new hx_UserAct();
                hua.ActTypeId  = activity.ActTypeId;
                hua.registerid = registerID;
                hua.RewTypeID  = activity.RewTypeID;
                if (activity.RewTypeID == 3)
                {
                    hua.UseLifeLoan = "3-0";
                }
                hua.ActID        = activity.ActID;
                hua.Amt          = mcp.cash;
                hua.Uselower     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].startAmt;
                hua.Usehight     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].endAmt;
                hua.AmtEndtime   = Convert.ToDateTime(dte.AddDays(effectiveDays).ToShortDateString() + " 23:59:59"); //有效期为10天
                hua.AmtUses      = 1;                                                                                //没指定情况下默认为单独使用
                hua.UseState     = activity.RewTypeID == 1 ? 5 : 0;
                hua.AmtProid     = 0;                                                                                //未使用默认为0
                hua.ISSmsOne     = 0;
                hua.IsSmsThree   = 0;
                hua.isSmsFifteen = 0;
                hua.IsSmsSeven   = 0;
                hua.isSmsSixteen = 0;
                hua.Title        = activity.ActName;
                hua.Createtime   = dte;
                hua.OrderID      = decimal.Parse(Utils.Createcode());//根据日期生成单号
                ef.hx_UserAct.Add(hua);
                ef.SaveChanges();


                if (activity.RewTypeID == 1)  //当奖品为现金时
                {
                    Transfer       tf = new Transfer();
                    M_member_table p  = new M_member_table();
                    B_member_table o  = new B_member_table();
                    p = o.GetModel(registerID);
                    ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, mcp.cash, hua.OrderID.ToString(), hua.ActID.ToString(), "/Thirdparty/ToUserTransfer");
                    if (retf != null)
                    {
                        if (retf.RespCode == "000")
                        {
                            //3.事务处理操作账户及插入流水
                            #region 验签缓存处理
                            string cachename = retf.OrdId + "ToUserTransfer" + retf.InCustId;
                            if (Utils.GeTThirdCache(cachename) == 0)
                            {
                                Utils.SetThirdCache(cachename);
                                B_usercenter BUC = new B_usercenter();
                                BUC.UpateActToUserTransfer(retf, 0);

                                //增加账户资金流水
                                hx_Capital_account_water Caw = new hx_Capital_account_water();

                                Caw.membertable_registerid = registerID;
                                Caw.income             = mcp.cash;
                                Caw.expenditure        = 0;
                                Caw.time_of_occurrence = dte;
                                Caw.account_balance    = p.available_balance + mcp.cash;
                                Caw.types_Finance      = 43;
                                Caw.createtime         = dte;
                                Caw.keyid   = 0;
                                Caw.remarks = "现金奖励";
                                ef.hx_Capital_account_water.Add(Caw);
                                ef.SaveChanges();
                            }
                            #endregion
                        }
                    }
                }
            }
        }
Example #22
0
        public ActionResult Index(RequestParam <RequestCash> reqst)
        {
            LoggerHelper.Info(reqst);
            ResultInfo <string> res = new ResultInfo <string>("99999");

            int            userId        = ConvertHelper.ParseValue(reqst.body.userId.ToString(), 0);        //用户id
            decimal        Amt           = reqst.body.transAmt;                                              //提现金额
            int            usrBindCardId = ConvertHelper.ParseValue(reqst.body.usrBindCardId.ToString(), 0); //提现卡id
            decimal        servf         = 0.00M;
            string         orderid       = Settings.Instance.OrderCode;
            B_member_table b             = new B_member_table();
            M_member_table p             = new M_member_table();
            M_Cash         mc            = new M_Cash();
            M_ReqExt       mr            = new M_ReqExt();

            p = b.GetModel(userId);
            MemberLogic _logic = new MemberLogic();


            var result = _logic.SelectUserBindCards(usrBindCardId);

            if (result == null || result.Count < 0)
            {
                LoggerHelper.Info("提现失败,用户关联的银行卡不存在:" + JsonHelper.Entity2Json(reqst));
                return(Content("提现失败,用户关联的银行卡不存在!"));
            }
            if (!_logic.IsAllowWithdrawalCash(usrBindCardId, reqst.body.withdrawalType))
            {
                LoggerHelper.Info("提现失败,用户关联的银行卡不支持此类型的取现请求:" + JsonHelper.Entity2Json(reqst));
                return(Content("提现失败,用户关联的银行卡不支持此类型的取现请求!"));
            }

            MemberBankEntity ubc = result.FirstOrDefault();

            if (ubc.UsrCustId == p.UsrCustId)
            {
                mc.Version   = "20";
                mc.CmdId     = "Cash";
                mc.MerCustId = Settings.Instance.MerCustId;
                mc.OrdId     = orderid;
                mc.UsrCustId = p.UsrCustId;
                mc.TransAmt  = Amt.ToString("0.00");

                /*普通取现不收会员手续费*/
                mc.ServFee       = "";
                mc.ServFeeAcctId = Settings.Instance.MerDt;
                mc.OpenAcctId    = ubc.OpenAcctId;
                mc.RetUrl        = Settings.Instance.GetCallbackUrl("/Cash/Index/CashCallback");

                mc.BgRetUrl = Settings.Instance.GetCallbackUrl("/Cash/Index/CashBgCallback");
                mc.Remark   = "";
                mc.CharSet  = "UTF-8";
                mc.MerPriv  = "chuanglitou";
                //if (reqst.body.withdrawalType == 2)
                //    mr.FeeObjFlag = "U";  //客户承担提现手费续
                //else
                mr.FeeObjFlag = "M";  //商家承担提现手费续
                mr.FeeAcctId  = Settings.Instance.MerDt;
                //reqst.body.withdrawalType = 1;
                switch (reqst.body.withdrawalType)
                {
                case 2:
                    mr.CashChl = "IMMEDIATE";
                    break;

                case 1:
                    mr.CashChl = "FAST";
                    break;

                case 0:
                default:
                    mr.CashChl = "GENERAL";     //一般取现
                    break;
                }
                //mr.CashChl = "GENERAL"; //一般取现
                // mr.CashChl = "FAST";  //快速取现
                // mr.CashChl = "IMMEDIATE";  // 即时取现
                mc.ReqExt = "[" + FastJSON.toJOSN(mr) + "]";

                StringBuilder chkVal = new StringBuilder();
                chkVal.Append(mc.Version);
                chkVal.Append(mc.CmdId);
                chkVal.Append(mc.MerCustId);
                chkVal.Append(mc.OrdId);
                chkVal.Append(mc.UsrCustId);
                chkVal.Append(mc.TransAmt);
                chkVal.Append(mc.ServFee);
                chkVal.Append(mc.ServFeeAcctId);
                chkVal.Append(mc.OpenAcctId);
                chkVal.Append(mc.RetUrl);
                chkVal.Append(mc.BgRetUrl);
                chkVal.Append(mc.Remark);
                chkVal.Append(mc.MerPriv);
                chkVal.Append(mc.ReqExt);
                string chkv = chkVal.ToString();

                LoggerHelper.Info("取现chkv字符:" + chkv);

                //私钥文件的位置(这里是放在了站点的根目录下)
                string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.MerPr;
                //需要指定提交字符串的长度
                int           len        = Encoding.UTF8.GetBytes(chkv).Length;
                StringBuilder sbChkValue = new StringBuilder(256);
                //加签
                int str = DllInterop.SignMsg(Settings.Instance.MerId, merKeyFile, chkv, len, sbChkValue);
                mc.ChkValue = sbChkValue.ToString();
                if (str == 0)
                {
                    M_td_UserCash mu = new M_td_UserCash();
                    B_td_UserCash mo = new B_td_UserCash();
                    mu.registerid = p.registerid;
                    mu.UsrCustId  = p.UsrCustId;
                    mu.TransAmt   = decimal.Parse(mc.TransAmt);
                    mu.FeeAmt     = servf;
                    mu.OrdId      = mc.OrdId;
                    mu.OrdIdTime  = DateTime.Now;
                    mu.OrdIdState = 0;
                    mu.FeeObjFlag = mr.FeeObjFlag;
                    mo.Add(mu);
                }
                LoggerHelper.Info("加签字符:" + str);
                LoggerHelper.Info("提现提交表单:" + JsonHelper.Entity2Json(mc));
                return(View(mc));
            }
            else
            {
                LoggerHelper.Info("提现失败,用户提现的银行卡的关联帐户和当前用户关联的银行卡帐户不一致:" + JsonHelper.Entity2Json(reqst));
                return(Content("提现失败,用户提现的银行卡的关联帐户和当前用户关联的银行卡帐户不一致!"));
            }
        }
Example #23
0
        /// <summary>
        /// 无效投资标的处理
        /// </summary>
        /// <param name="investor_registerid">投资用户id</param>
        /// <param name="bid_records_id">投资记录id</param>
        /// <param name="OrdId">投资订单号</param>
        /// <param name="OrdDate">投资订单日期</param>
        /// <param name="UsrCustId">客户号</param>
        /// <param name="FreezeOrdId">冻结订单号</param>
        /// <param name="TransAmt">交易金额</param>
        /// <param name="FreezeTrxId">冻结唯一标识</param>
        /// <param name="MerPriv">优惠券字符串</param>
        /// <param name="QueryTransType">查询类型   LOANS:放款交易查询 REPAYMENT:还款交易查询 TENDER:投标交易查询 CASH:取现交易查询     FREEZE:冻结解冻交易查询     </param>
        public void setRecords_Lost(string investor_registerid, string bid_records_id, string OrdId, string OrdDate, string UsrCustId, string FreezeOrdId, string TransAmt, string FreezeTrxId, string MerPriv, string QueryTransType = "TENDER")
        {
            TransStat ts = new TransStat();
            bool      d  = ts.checktrans(OrdId, OrdDate, QueryTransType);

            if (d == false)
            {
                string sql = "update hx_UserAct set UseState=0,AmtProid=0 where UseState=3 and AmtProid=" + bid_records_id + "and registerid=" + investor_registerid;
                DbHelperSQL.RunSql(sql);
                sql = "delete hx_Bid_records where OrdId ='" + OrdId + "' and ordstate=0 and bid_records_id=" + bid_records_id;
                DbHelperSQL.RunSql(sql);
            }
            else
            {//TODO 此处有bug,自动查询的更新冻结表时缺少 FreezeTrxId 值,放款时没有该值会报错。 考虑注释该逻辑,等待汇付异步回调????
                B_usercenter BUC = new B_usercenter();
                //取得投标记录使用的优惠券
                string AmtProid = BUC.GetBid_AmtProid(int.Parse(bid_records_id));
                int    de       = BUC.ReInvest_success(UsrCustId, FreezeOrdId, TransAmt, FreezeTrxId, OrdId, AmtProid);
                if (de > 0)
                {
                    string    sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt  from  V_hx_Bid_records_borrowing_target where OrdId='" + OrdId + "'";
                    DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);
                    if (dt.Rows.Count > 0)
                    {
                        decimal investAmt  = decimal.Parse(dt.Rows[0]["investment_amount"].ToString());
                        int     registerid = int.Parse(dt.Rows[0]["investor_registerid"].ToString());
                        string  targetid   = dt.Rows[0]["targetid"].ToString();

                        #region 待提取为公共方法
                        #region MyRegion  系统消息
                        DateTime            dti = DateTime.Now;
                        M_td_System_message pm  = new M_td_System_message();
                        pm.MReg     = registerid;
                        pm.Mstate   = 0;
                        pm.MTitle   = "投资成功";
                        pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + investAmt + "。如有问题可咨询创利投的客服!谢谢!";
                        pm.PubTime  = dti;
                        pm.Mtype    = 1;
                        B_usercenter.AddMessage(pm);
                        #endregion

                        #region MyRegion                                        //短信通知
                        string        contxt = Utils.GetMSMEmailContext(15, 1); // 获取注册成功邮件内容
                        StringBuilder sbsms  = new StringBuilder(contxt);
                        sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString());
                        sbsms = sbsms.Replace("#PID#", targetid);
                        sbsms = sbsms.Replace("#MONEY#", investAmt.ToString());
                        string          mobile  = dt.Rows[0]["mobile"].ToString();
                        M_td_SMS_record psms    = new M_td_SMS_record();
                        B_td_SMS_record osms    = new B_td_SMS_record();
                        int             smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资成功.ToString());
                        psms.phone_number = mobile;
                        psms.sendtime     = DateTime.Now;
                        psms.senduserid   = registerid;
                        psms.smstype      = smstype;
                        psms.smscontext   = sbsms.ToString();
                        psms.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                        psms.vcode        = "";
                        osms.Add(psms);
                        #endregion

                        #region 远程调用生成合同??? 稍后替换为本地方法调用  微信端可远程调用
                        string postString = "action=MUserPDF&data=" + targetid.ToString() + "&uc=" + registerid.ToString() + "&OrdId=" + OrdId;
                        string sr         = Utils.PostWebRequest(Utils.GetRemote_url("pdf/index"), postString, Encoding.UTF8);
                        #endregion

                        #region  道合作 第一投标调用接口???
                        B_member_table bmt = new B_member_table();
                        M_member_table mmt = new M_member_table();
                        mmt = bmt.GetModel(registerid);
                        if (mmt.Tid != null && mmt.Channelsource == 1)
                        {
                            if (B_usercenter.GetInvestCountByUserid(mmt.registerid) == 1)
                            {
                                string ret3 = Utils.GetCoopAPI(mmt.Tid, investAmt.ToString("0.00"), 2);
                                LogInfo.WriteLog("前台渠道合作第一次返回结果:" + ret3 + "  用户id:" + mmt.registerid + " 订单id " + OrdId);
                            }
                        }
                        #endregion
                        #endregion 待提取为公共方法

                        //发放奖励
                        ActFacade act = new ActFacade();
                        act.SendBonusAfterInvest(dt, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web);
                    }
                }
            }
        }
Example #24
0
        /// <summary>
        /// 分页列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="startdatetime"></param>
        /// <param name="enddatetime"></param>
        /// <param name="timeday"></param>
        /// <param name="pgaesize"></param>
        /// <returns></returns>
        // GET: Cash
        public ActionResult Index(int?pageIndex, string startdatetime, string enddatetime, int timeday = 0, int pgaesize = 5)
        {
            ViewBag.rndstr = Utils.RndNumChar(10).ToString();

            int OrdIdState = DNTRequest.GetInt("OrdIdState", 0);

            ViewBag.OrdIdState = OrdIdState;
            int     userid    = Utils.checkloginsession();
            int     Counts    = 0;
            int     lostCount = 0;
            int     succCount = 0;
            decimal Totals    = 0.00M;
            decimal lostTotal = 0.00M;
            decimal succTotal = 0.00M;

            B_member_table b  = new B_member_table();
            M_member_table pu = new M_member_table();

            pu = b.GetModel(userid);

            //判断用户是否开户
            if (string.IsNullOrEmpty(pu.UsrCustId))
            {
                string temstr = "/opening_account/Index/" + userid.ToString();
                return(Redirect(temstr));
            }


            new BindCardController().checkbank(pu.UsrCustId);

            if (userid > 0)
            {
                if (Session["retloan1"] != null)
                {
                }
                else
                {
                    UserInfoData     ud      = new UserInfoData();
                    ReQueryBalanceBg retloan = ud.Querybalance(userid);

                    if (retloan.RespCode == "000")
                    {
                        //  string sql = "update  hx_member_table  set  available_balance=" + decimal.Parse(retloan.AvlBal) + " ,frozen_sum=" + decimal.Parse(retloan.FrzBal) + " where  registerid=" + userid.ToString() + "";

                        //string sql = "update  hx_member_table  set  available_balance=" + decimal.Parse(retloan.AvlBal) + "  where  registerid=" + userid.ToString() + "";

                        //DbHelperSQL.RunSql(sql);
                        B_usercenter bu = new B_usercenter();
                        bu.DataSync(retloan, userid.ToString());

                        Session["retloan1"] = "updateUserbalance";
                    }
                }
            }


            List <V_UsrBindCardBank> vubc = ef.V_UsrBindCardBank.Where(c => c.registerid == userid && c.OpenBankId != null).ToList();



            //判断用户是否绑定一行卡
            //if (vubc.Count <= 0)
            //{
            //    string temstr = "/BindCard/Index";
            //    return Redirect(temstr);
            //}


            var ListByOwner = ef.hx_td_UserCash.Where(l => l.registerid == userid && l.OpenBankId != null).GroupBy(l => l.registerid)
                              .Select(lg => new
            {
                Owner     = lg.Key,
                Counts    = lg.Count(),
                lostCount = lg.Where(lo => lo.OrdIdState == 0).Count(),
                succCount = lg.Where(su => su.OrdIdState == 3).Count(),
                Totals    = lg.Where(w => w.OrdIdState == 3).Sum(w => w.TransAmt),
                lostTotal = lg.Where(w => w.OrdIdState == 0).Sum(w => w.TransAmt),
                succTotal = lg.Where(w => w.OrdIdState == 3).Sum(w => w.TransAmt),
            });

            foreach (var itc in ListByOwner)
            {
                if (itc.Counts > 0)
                {
                    //Counts = itc.Counts;
                    // Totals = (decimal)itc.Totals;
                    int.TryParse(itc.Counts.ToString(), out Counts);
                    decimal.TryParse(itc.Totals.ToString(), out Totals);
                    int.TryParse(itc.lostCount.ToString(), out lostCount);
                    int.TryParse(itc.succCount.ToString(), out succCount);
                    decimal.TryParse(itc.lostTotal.ToString(), out lostTotal);
                    decimal.TryParse(itc.succTotal.ToString(), out succTotal);
                }
            }
            Expression <Func <hx_td_UserCash, bool> > where = PredicateExtensionses.True <hx_td_UserCash>();
            where = where.And(p => p.UserCashId > 0);
            where = where.And(p => p.registerid == userid);

            where = where.And(p => p.OpenBankId != null);

            if (ViewBag.OrdIdState == 3)
            {
                where = where.And(p => p.OrdIdState == OrdIdState);
            }


            DateTime sdatetime = new DateTime();
            DateTime edatetime = new DateTime();

            if (Utils.IsDate(startdatetime))
            {
                sdatetime = DateTime.Parse(startdatetime);
            }

            if (Utils.IsDate(enddatetime))
            {
                edatetime = DateTime.Parse(enddatetime);
            }

            if (sdatetime > DateTime.Parse("0001-01-01 00:00:00") && edatetime > DateTime.Parse("0001-01-01 00:00:00"))
            {
                where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0);
                DateTime dt2 = Convert.ToDateTime(edatetime.ToString("yyyy-MM-dd") + " 23:59:59");
                where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0);
            }
            else
            {
                DateTime dt2;
                switch (timeday)
                {
                case 0:

                    break;

                case 1:
                    sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
                    dt2       = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0);
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0);
                    break;

                case 30:
                    sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00").AddDays(-30);
                    dt2       = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0);
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0);
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0);
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0);
                    break;

                case 90:
                    sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00").AddDays(-90);
                    dt2       = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
                    break;

                default:
                    break;
                }
            }
            var list = ef.hx_td_UserCash.Where(where).OrderByDescending(p => p.UserCashId).ToPagedList(pageIndex ?? 1, pgaesize);



            ViewBag.startdatetime = startdatetime;
            ViewBag.enddatetime   = enddatetime;
            ViewBag.timeday       = timeday;
            ViewBag.pageIndex     = pageIndex;
            ViewBag.Counts        = Counts;
            ViewBag.Totals        = Totals;
            ViewBag.lostCount     = lostCount;

            ViewBag.lostTotal = lostTotal;


            ViewBag.succTotal = succTotal;
            ViewBag.succCount = succCount;

            ViewBag.users       = pu;
            vubc                = BusinessLogicHelper.LeftOne(vubc);
            ViewBag.UsrBindCard = vubc.OrderByDescending(c => c.defCard).ToList();

            ViewBag.Isquick = vubc.Where(c => c.Isquick == 1).Count() > 0;

            ViewBag.GENERAL = DateTime.Now.AddDays(1).ToString("MM月dd日");
            ViewBag.QM      = DateTime.Now.ToString("MM月dd日");
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Cashlist", list));
            }
            return(View(list));
        }
Example #25
0
        /// <summary>
        /// 新人注册 现金奖励
        /// </summary>
        /// <returns></returns>
        private bool GeneralActCash(int Registerid, hx_ActivityTable hat)
        {
            bool t = false;

            if (hat != null)
            {
                string               ActRule = hat.ActRule;
                List <MAmtList>      mlist   = new List <MAmtList>();
                JavaScriptSerializer js      = new JavaScriptSerializer();
                MActCash             mc      = new MActCash();
                mc = js.Deserialize <MActCash>(ActRule);
                //获取对应奖励
                decimal actamt = GetActAmt(mc, 0, 0, 0);
                if (actamt > 0)//大于 0里写入对应的奖励数据
                {
                    hx_UserAct hua = new hx_UserAct();
                    hua.ActTypeId    = hat.ActTypeId;
                    hua.registerid   = Registerid;
                    hua.RewTypeID    = hat.RewTypeID;
                    hua.ActID        = hat.ActID;
                    hua.Amt          = actamt;
                    hua.Uselower     = 0.00M;
                    hua.Usehight     = 0.00M;
                    hua.AmtEndtime   = DateTime.Parse(hat.ActEndtime.ToString()).AddMonths(1);
                    hua.AmtUses      = 1; //没指定情况下默认为单独使用
                    hua.UseState     = 5; //现金未转账
                    hua.AmtProid     = 0; //未使用默认为0
                    hua.ISSmsOne     = 0;
                    hua.IsSmsThree   = 0;
                    hua.isSmsFifteen = 0;
                    hua.IsSmsSeven   = 0;
                    hua.isSmsSixteen = 0;
                    hua.OrderID      = decimal.Parse(Utils.Createcode());
                    hua.Createtime   = DateTime.Now;
                    ef.hx_UserAct.Add(hua);
                    int i = ef.SaveChanges();
                    if (i > 0)
                    {
                        //录入成功,后进行转账操作 1.获取用户对向
                        M_member_table p = new M_member_table();
                        B_member_table o = new B_member_table();
                        p = o.GetModel(Registerid);
                        if (p != null)
                        {
                            //2.调用商户向用户转账接口
                            Transfer   tf   = new Transfer();
                            ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, actamt, hua.OrderID.ToString(), hua.ActID.ToString(), "/Thirdparty/ToUserTransfer");
                            if (retf != null)
                            {
                                if (retf.RespCode == "000")
                                {//3.事务处理操作账户及插入流水
                                    #region 验签缓存处理
                                    string cachename = retf.OrdId + "ToUserTransfer" + retf.InCustId;
                                    if (Utils.GeTThirdCache(cachename) == 0)
                                    {
                                        Utils.SetThirdCache(cachename);
                                        B_usercenter BUC = new B_usercenter();
                                        int          ic  = BUC.UpateActToUserTransfer(retf, 0);
                                        if (ic > 0)
                                        {
                                            string    sql = "SELECT registerid,username,mobile  from hx_member_table where UsrCustId='" + retf.InCustId + "'";
                                            DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);
                                            if (dt.Rows.Count > 0)
                                            {
                                                #region MyRegion  记录奖励流水表
                                                string awardDescription = string.Format("{0},已汇入个人账户{1}{2}", hat.ActName, retf.TransAmt, GetBunusDescription(hat.RewTypeID));
                                                AddBonusAccoutWater(int.Parse(hua.UserAct.ToString()), Registerid, decimal.Parse(retf.TransAmt), awardDescription);
                                                #endregion

                                                #region MyRegion  发送系统消息
                                                string MContext = string.Format("尊敬的用户:您好!恭喜您成功参与{0},获得{1}{2}如有问题可咨询创利投的客服!", hat.ActName, retf.TransAmt, GetBunusDescription(hat.RewTypeID));
                                                AddSytemMessage(Registerid, hat.ActName, MContext);
                                                #endregion

                                                /*短信接口*/
                                            }
                                        }
                                        t = true;
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                }
            }
            return(t);
        }
Example #26
0
        public string Register(string Validatecode, string userpassword1, string mobile1, string username1, bool realMobileUser = false)
        {
            Utils.SetSYSDateTimeFormat();
            string json = "";
            //注册奖励
            M_Activity_schedule ma = new M_Activity_schedule();
            B_Activity_schedule ba = new B_Activity_schedule();

            B_member_table o = new B_member_table();
            M_member_table p = new M_member_table();

            B_bonus_account bb = new B_bonus_account();
            M_bonus_account mb = new M_bonus_account();

            M_bonus_account_water mbaw = new M_bonus_account_water();
            B_bonus_account_water bbaw = new B_bonus_account_water();

            string email1   = "";
            string strvcode = realMobileUser ? "y" : ck.GetVcode(Validatecode, mobile1);
            string tid      = "";//富爸爸参数uid //Utils.GetCookie("Cooperation", "tid");//渠道来源ID
            string invcode  = Utils.GetInvCode();

            // 用户邀请用户关系存在的时候,不走 新渠道机制(channel)
            #region  道
            //渠道的cookie
            var    cc_keyValue  = Utils.GetInvCookie("channel");
            string cInvitedcode = string.Empty;
            if (string.IsNullOrEmpty(invcode) && cc_keyValue.Count != 0)
            {
                cInvitedcode = cc_keyValue["Invitedcode"];
                var channelInvitedCode = ef.hx_Channel.Where(c => c.ChannelName == "fubaba").Select(c => c.Invitedcode).FirstOrDefault();
                if (cInvitedcode.Trim() == channelInvitedCode)
                {
                    tid = cc_keyValue["uid"];
                }
            }
            #endregion
            int ch = 0;
            if (Utils.GetCookie("Cooperation", "ch") != "")
            {
                try
                {
                    ch = int.Parse(Utils.GetCookie("Cooperation", "ch"));//渠道来源
                }
                catch
                {
                    ch = 0;
                }
            }

            if (ch == 0)
            {
                if (invcode != "")
                {
                    ch = 1;
                }
            }

            if (strvcode != null)
            {
                if (strvcode == "y")
                {
                    string checkMob = ck.checkmobile(mobile1, 0);

                    if (checkMob != "y")
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""手机号已被注册!""}";
                        return(json);
                    }

                    p.username            = username1;
                    p.password            = DESEncrypt.Encrypt(userpassword1, ConfigurationManager.AppSettings["webp"].ToString());
                    p.mobile              = mobile1;
                    p.email               = email1;
                    p.usertypes           = 0;
                    p.invitedcode         = Calculator.Getinvitedcode();
                    p.ismobile            = 1;
                    p.Channelsource       = ch;
                    p.Tid                 = tid;
                    p.channel_invitedcode = cInvitedcode;
                    LogInfo.WriteLog("用户注册内容:" + FastJSON.toJOSN(p) + "     IP:" + Utils.GetRealIP());
                    int uid = o.Add(p);
                    if (uid > 0)
                    {
                        CheckXiCai(p.mobile, cInvitedcode);
                        //if (tid != "")
                        //{
                        //    Utils.GetCoopAPI(tid, uid.ToString(), 1);
                        //}
                        string keys = DESEncrypt.Encrypt(uid.ToString(), ConfigurationManager.AppSettings["webp"].ToString());

                        string keys1 = DESEncrypt.Encrypt(username1, ConfigurationManager.AppSettings["webp"].ToString());

                        M_td_SMS_record pm        = new M_td_SMS_record();
                        B_td_SMS_record om        = new B_td_SMS_record();
                        int             smstype   = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.注册成功.ToString());
                        string          smscontxt = Utils.GetMSMEmailContext(18, 1); // 获取注册成功邮件内容
                        StringBuilder   sbsms     = new StringBuilder(smscontxt);
                        string          mobile    = mobile1;
                        sbsms           = sbsms.Replace("#USERANEM#", p.username.ToString());
                        pm.phone_number = mobile;
                        pm.sendtime     = DateTime.Now;
                        pm.senduserid   = uid;
                        pm.smstype      = smstype;
                        pm.smscontext   = sbsms.ToString();
                        pm.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                        pm.vcode        = "";
                        om.Add(pm);

                        M_login mlogin = new M_login();
                        mlogin.userid   = uid;
                        mlogin.username = p.username;
                        mlogin.codeno   = Utils.SetSessioncode();
                        int remember = 0;
                        if (Utils.LoginWriteSession(mlogin, remember) > 0)
                        {
                            string sql = "update hx_member_table set lastlogintime='" + DateTime.Now + "',lastloginIP='" + Utils.GetRealIP() + "' where registerid=" + uid.ToString();
                            LogInfo.WriteLog(sql);
                            DbHelperSQL.ExecuteSql(sql);
                        }


                        #region MyRegion   //记录邀请关系

                        LogInfo.WriteLog("注册:邀请码:" + invcode);
                        if (invcode != "")
                        {
                            string codesql = "SELECT invcode from  hx_td_Userinvitation where  invpersonid=" + uid.ToString();//查询本人是否已经被邀请注册过  invcode='" + invcode + "' and
                            LogInfo.WriteLog("codesql2:" + codesql);
                            DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
                            if (dtcode.Rows.Count == 0)
                            {
                                M_td_Userinvitation myao = new M_td_Userinvitation();
                                B_td_Userinvitation dyao = new B_td_Userinvitation();
                                int yaouids = Utils.GetCodeUid();
                                myao.invcode       = invcode;
                                myao.invtime       = DateTime.Now;
                                myao.invpersonid   = uid;
                                myao.Invpeopleid   = yaouids;
                                myao.InvitesStates = 0;
                                myao.Invitereward  = 0;
                                int myaoint = dyao.Add(myao);
                            }
                        }
                        #endregion MyRegion   //记录邀请关系

                        json = @" {""rs""    : ""y"", ""url""      :  ""/""}";
                        string temstr = "/opening_account/Index/" + uid.ToString();
                        json = json.Replace("/", temstr);
                        return(json);
                    }
                    else
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""注册失败!""}";
                        return(json);
                    }
                }
                else
                {
                    json = @" {""rs""    : ""n"", ""error""      :  ""验证码不对!""}";
                    return(json);
                }
            }
            else
            {
                json = @" {""rs""    : ""n"", ""error""      :  ""验证码不存在或过期!""}";
            }
            return(json);
        }
Example #27
0
        public string Register(string Validatecode, string userpassword1, string mobile1, string username1, bool realMobileUser = false)
        {
            Utils.SetSYSDateTimeFormat();
            string json = "";
            //注册奖历
            M_Activity_schedule ma = new M_Activity_schedule();
            B_Activity_schedule ba = new B_Activity_schedule();

            B_member_table o = new B_member_table();
            M_member_table p = new M_member_table();

            B_bonus_account bb = new B_bonus_account();
            M_bonus_account mb = new M_bonus_account();

            M_bonus_account_water mbaw = new M_bonus_account_water();
            B_bonus_account_water bbaw = new B_bonus_account_water();
            string email1   = "";
            string strvcode = realMobileUser ? "y" : ck.GetVcode(Validatecode, mobile1);

            //string strvcode = "y";
            if ((Settings.Instance.SiteDomain.IndexOf(PublicURL.NewWXUrl) >= 0))
            {
                strvcode = ck.GetVcodeWX(Validatecode, mobile1);
            }
            string tid = Utils.GetCookie("Cooperation", "tid");
            int    ch  = 0;

            string invcode = Utils.GetInvCode();

            #region  道
            //渠道的cookie
            var    cc_keyValue  = Utils.GetInvCookie("channel");
            string cInvitedcode = string.Empty;
            if (string.IsNullOrEmpty(invcode) && cc_keyValue.Count != 0)
            {
                cInvitedcode = cc_keyValue["Invitedcode"];
            }
            #endregion

            if (Utils.GetCookie("Cooperation", "ch") != "")
            {
                try
                {
                    ch = int.Parse(Utils.GetCookie("Cooperation", "ch"));
                }
                catch
                {
                    ch = 0;
                }
            }

            if (ch == 0)
            {
                if (invcode != "")
                {
                    ch = 3;
                }
                else
                {
                    ch = 2;
                }
            }

            if (realMobileUser || strvcode != null)
            {
                if (realMobileUser || strvcode == "y")
                {
                    string checkMob = ck.checkmobile(mobile1, 0);

                    if (checkMob != "y")
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""手机号已被注册!""}";
                        return(json);
                    }

                    p.username      = username1;
                    p.password      = DESEncrypt.Encrypt(userpassword1, ConfigurationManager.AppSettings["webp"].ToString());
                    p.mobile        = mobile1;
                    p.email         = email1;
                    p.usertypes     = 0;
                    p.invitedcode   = Calculator.Getinvitedcode();
                    p.ismobile      = 1;
                    p.Channelsource = ch;
                    p.Tid           = tid;

                    p.channel_invitedcode = cInvitedcode;
                    LogInfo.WriteLog("用户注册内容:" + FastJSON.toJOSN(p) + "     IP:" + Utils.GetRealIP());
                    int uid = o.Add(p);//注册成功返回会员ID
                    if (uid > 0)
                    {
                        //记录用户信息到活动流量发放表里  2016.10.21-31日
                        //string CookCode = Utils.GetCookie("CookCode");
                        //if (!string.IsNullOrWhiteSpace(CookCode))
                        //{
                        //    if (CookCode== "liumi")
                        //    {
                        //        AddReceiveInfo(uid);
                        //    }

                        //}

                        if (tid != "")
                        {
                            //    Utils.GetCoopAPI(tid, uid.ToString(), 1);
                        }
                        string keys = DESEncrypt.Encrypt(uid.ToString(), ConfigurationManager.AppSettings["webp"].ToString());

                        string keys1 = DESEncrypt.Encrypt(username1, ConfigurationManager.AppSettings["webp"].ToString());

                        M_td_SMS_record pm        = new M_td_SMS_record();
                        B_td_SMS_record om        = new B_td_SMS_record();
                        int             smstype   = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.注册成功.ToString());
                        string          smscontxt = Utils.GetMSMEmailContext(18, 1); // 获取注册成功邮件内容
                        StringBuilder   sbsms     = new StringBuilder(smscontxt);
                        string          mobile    = mobile1;
                        sbsms           = sbsms.Replace("#USERANEM#", p.username.ToString());
                        pm.phone_number = mobile;
                        pm.sendtime     = DateTime.Now;
                        pm.senduserid   = uid;
                        pm.smstype      = smstype;
                        pm.smscontext   = sbsms.ToString();
                        pm.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                        pm.vcode        = "";
                        om.Add(pm);

                        M_login mlogin = new M_login();
                        mlogin.userid   = uid;
                        mlogin.username = p.username;
                        mlogin.codeno   = Utils.SetSessioncode();
                        int remember = 0;


                        FormsAuthentication.SignOut();

                        Utils.AddLoginCache(p.username, mlogin);

                        string sql = "update hx_member_table set lastlogintime='" + DateTime.Now + "',lastloginIP='" + Utils.GetRealIP() + "' where registerid=" + uid.ToString();
                        DbHelperSQL.ExecuteSql(sql);

                        #region MyRegion   //记录邀请关系
                        LogInfo.WriteLog("注册:邀请码:" + invcode);
                        if (invcode != "")
                        {
                            string codesql = "SELECT invcode from  hx_td_Userinvitation where  invpersonid=" + uid.ToString();//查询本人是否已经被邀请注册过  invcode='" + invcode + "' and
                            LogInfo.WriteLog("codesql2:" + codesql);
                            DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
                            if (dtcode.Rows.Count == 0)
                            {
                                M_td_Userinvitation myao = new M_td_Userinvitation();
                                B_td_Userinvitation dyao = new B_td_Userinvitation();
                                int yaouids = Utils.GetCodeUid();
                                myao.invcode       = invcode;
                                myao.invtime       = DateTime.Now;
                                myao.invpersonid   = uid;
                                myao.Invpeopleid   = yaouids;
                                myao.InvitesStates = 0;
                                myao.Invitereward  = 0;
                                int myaoint = dyao.Add(myao);
                            }
                        }
                        #endregion MyRegion   //记录邀请关系

                        json = @" {""rs""    : ""y"", ""url""      :  ""/index.html"",""uid"":" + uid + "}";
                        string temstr = "/opening_account/Index/" + uid.ToString();
                        json = json.Replace("/index.html", temstr);
                        return(json);
                    }
                    else
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""注册失败!""}";
                        return(json);
                    }
                }
                else
                {
                    json = @" {""rs""    : ""n"", ""error""      :  ""验证码不对!""}";
                    return(json);
                }
            }
            else
            {
                json = @" {""rs""    : ""n"", ""error""      :  ""验证码不存在或过期!""}";
            }
            return(json);
        }
Example #28
0
        public ActionResult CashIMMEDIATE()
        {
            int     userid        = Utils.checkloginsession();
            string  url           = Utils.GetChinapnrUrl();
            decimal Amt           = decimal.Parse(DNTRequest.GetString("TransAmt"));
            int     UsrBindCardID = DNTRequest.GetInt("UsrBindCardID", 0);
            //string vcode = DNTRequest.GetString("vcode");
            string strIdentify = "CashValidateCode"; //随机字串存储键值,以便存储到Session中

            LogInfo.WriteLog("即时取现:userid=" + userid + ";url=" + url + ";Amt=" + Amt + ";UsrBindCardID=" + UsrBindCardID + ";strIdentify=" + strIdentify);

            decimal ServFee = 0.00M;
            //if (Session[strIdentify] != null)
            //{
            //    if (Session[strIdentify].ToString() != vcode)
            //    {
            //        return Content(StringAlert.Alert("验证码不对!"), "text/html");
            //    }
            //}
            //else
            //{
            //    return Content(StringAlert.Alert("验证码已过期!"), "text/html");
            //}
            decimal servf = ServFee;

            ViewBag.errCode = "0";
            B_member_table b = new B_member_table();
            M_member_table p = new M_member_table();

            p = b.GetModel(userid);
            if (p.available_balance < Amt)
            {
                ViewBag.errCode = "-1";
                return(View(new M_Cash()));
            }
            if (Amt <= ServFee)
            {
                return(Content(StringAlert.Alert("取现金额小于或等于手续费,不能提现!"), "text/html"));
            }
            else if (p.available_balance < Amt + ServFee)
            {
                Amt = Amt - ServFee;
            }
            hx_UsrBindCardC ubc = ef.hx_UsrBindCardC.Where(g => g.UsrBindCardID == UsrBindCardID).FirstOrDefault();

            if (ubc == null)
            {
                ViewBag.errCode = "-2";
                return(View(new M_Cash()));
            }
            ViewBag.url = url;
            string FeeObjFlag = "M";//"U";

            string cashChl = Enum.GetName(typeof(EnumCommon.E_hx_td_UserCash.EnumCashChl), (int)EnumCommon.E_hx_td_UserCash.EnumCashChl.IMMEDIATE);
            M_Cash mc      = ChinapnrFacade.Cash(p.UsrCustId, Amt.ToString("0.00"), ubc.OpenAcctId, cashChl, ServFee.ToString("0.00"), FeeObjFlag);

            if (mc != null)
            {
                M_td_UserCash mu = new M_td_UserCash();
                B_td_UserCash mo = new B_td_UserCash();
                mu.registerid = p.registerid;
                mu.UsrCustId  = p.UsrCustId;
                mu.TransAmt   = decimal.Parse(mc.TransAmt);
                mu.FeeAmt     = ChinapnrFacade.CalcCashFee(Amt.ToString("0.00"), cashChl, FeeObjFlag) + servf;
                mu.OrdId      = mc.OrdId;
                mu.OrdIdTime  = DateTime.Now;
                mu.OrdIdState = 0;
                mu.FeeObjFlag = FeeObjFlag;
                mu.CashChl    = cashChl;
                mo.Add(mu);
            }
            return(View("CashQm", mc));
        }
Example #29
0
        /// <summary>
        ///
        /// </summary>
        public void zf()
        {
            B_member_table bmt = new B_member_table();
            M_member_table mmt = new M_member_table();

            mmt = bmt.GetModel(42620);
            #region 投资六月专享标一元抢Iphone 2016年9月11日 9点 至2016年10月31日
            if (true)
            {
                DateTime nowdate = DateTime.Now;
                //DateTime startdate = new DateTime(2016, 09, 10, 9, 00, 00);
                //DateTime enddate = new DateTime(2016, 10, 31, 23, 59, 59);2016-09-07 17:42:59.430
                DateTime startdate = new DateTime(2016, 09, 11, 9, 00, 00);
                DateTime enddate   = new DateTime(2016, 10, 31, 23, 59, 59);
                string   log       = "一元抢Iphone";
                if (nowdate > startdate && nowdate < enddate)
                {
                    DateTime dt = mmt.Registration_time;
                    log += " 用户注册时间:" + dt.ToString();
                    if (dt > new DateTime(2016, 09, 11, 0, 0, 0))
                    {
                        //if (dt.Rows[0]["unit_day"].ToString() == "1" && dt.Rows[0]["life_of_loan"].ToString() == "6")//是否六月标
                        //{

                        Bll.B_GrabIphone gi = new Bll.B_GrabIphone();

                        bool isCount = gi.Exists(mmt.registerid);//查询是否存在该用户
                        log += "; 用户ID:" + mmt.registerid + ";查询是否存在该用户:" + isCount;
                        if (isCount != true)
                        {
                            M_GrabIphone model = new M_GrabIphone();
                            model.RegrsterID       = mmt.registerid;
                            model.Color            = "";
                            model.Addtime          = nowdate;
                            model.LuckDrawState    = 0;
                            model.WinningState     = 0;
                            model.WinningTime      = nowdate;
                            model.TargetID         = 232;                                                // int.Parse(dt.Rows[0]["targetid"].ToString());
                            model.BidRecordsID     = 3333;                                               // int.Parse(dt.Rows[0]["bid_records_id"].ToString());
                            model.InvestmentAmount = "22";                                               //dt.Rows[0]["investment_amount"].ToString();
                            gi.Add(model);                                                               //增加一条数据

                            List <M_GrabIphone> giList = gi.GetModelList(5388, "LuckDrawState=0", "ID"); //获取当前阶段投资人数
                            if (giList != null)
                            {
                                log += "; 当前阶段投资人数:" + giList.Count;
                                int ljcount = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["GrabIphone"].ToString());//获取启动抽奖人数
                                if (giList.Count >= ljcount)
                                {
                                    bool bo = gi.UpdateLuckDrawState();//批量更新抽奖状态
                                    log += "; 批量更新抽奖状态:" + bo;
                                    if (bo == true)
                                    {
                                        int          count      = giList.Count;
                                        int          index      = new Random().Next(count);
                                        M_GrabIphone randowitem = giList[index];

                                        if (randowitem != null)
                                        {
                                            log += "; 获奖用户ID:" + randowitem.RegrsterID;
                                            bool co = gi.Update("", 1, DateTime.Now, randowitem.RegrsterID);//更新中奖用户状态
                                            log += "; 更新中奖用户状态:" + co;
                                        }
                                    }
                                }
                            }
                        }
                        // }
                    }
                    Common.LogInfo.WriteLog(log);//写入日志
                }
            }
            #endregion
        }
Example #30
0
        /// <summary>
        /// 抽奖方法
        /// </summary>
        /// <param name="userID">用户id</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="amount">规则金额</param>
        /// <returns>提示信息</returns>
        public static string LuckDrawAward(int userID, DateTime startTime, DateTime endTime, int amount)
        {
            string msg = "";

            try
            {
                int state = CheckActivityTime(startTime, endTime, ref msg);
                if (state != 0)
                {
                    return(msg = "4;" + msg);
                }
                if (userID <= 0)
                {
                    return(msg = "1;请登录后重试");
                }
                if (GetCanUseTimes(userID, startTime, endTime, amount) <= 0) //如果可抽奖次数是0的话,则不能抽奖
                {
                    return(msg = "2;抽奖机会已用完,请明天再来");
                }
                #region 规则及数据

                //1-10 --小米手环(2代) --0.10%  --5个
                //10-35  --京东卡100元  --0.25%     --2个
                //35-535  --现金5元  --5.00%       --100个
                //535-1500  --2%加息券  --9.65%    --193个
                //1500-3500  --1%加息券  --20.00%  --400个
                //3500-6000  --50元抵扣券 --25.00%  --500个
                //6000-10000  --20元抵扣券 --40.00%     --800个
                #endregion

                //奖品编号
                int awardID = 0;
                //奖品标题
                string title = "";

                // 奖品类型   (前端现金1、抵扣券2、加息券3,后台管理现金4、抵扣券1、加息券2、谢谢参与3、实物-4)
                int awardType = -1;

                //轮盘区块编号
                int    awardBlockID = 0;
                Random random       = new Random();
                //随机数
                int randomRate = random.Next(1, 10001);

                B_LuckDraw bllLuckDraw = new B_LuckDraw();

                //获得用户对象
                M_member_table p = new M_member_table();
                B_member_table o = new B_member_table();
                p = o.GetModel(userID);

                if (randomRate <= 10)
                {
                    awardID = ConfigHelper.GetConfigInt("MiBandWristband");
                    if (bllLuckDraw.GetCash50RecordsCount(awardID, startTime, endTime) < 5)     //最多5个,如果超过了5个,则获得20元抵扣券
                    {
                        awardType = -4; title = "双12抽奖送小米手环"; awardBlockID = 5;
                        string mailStr = "恭喜您抽到了 '小米手环(第二代)' 奖品,我司客服将于3个工作日与您联系,请您保持手机畅通。";
                        SendSMS.Send_SMS(p.mobile, mailStr);
                    }
                    else
                    {
                        awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; title = "双12抽奖送20元抵扣券"; awardBlockID = 0;
                    }
                }
                else if (randomRate <= 35)
                {
                    awardID = ConfigHelper.GetConfigInt("JDCard");
                    if (bllLuckDraw.GetCash50RecordsCount(awardID, startTime, endTime) < 2)     //最多2个,如果超过了2个,则获得20元抵扣券
                    {
                        awardType = -4; title = "双12抽奖送京东卡100元"; awardBlockID = 6;
                        string mailStr = "恭喜您抽到了 '京东卡100元' 奖品,我司客服将于3个工作日与您联系,请您保持手机畅通。";
                        SendSMS.Send_SMS(p.mobile, mailStr);
                    }
                    else
                    {
                        awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; title = "双12抽奖送20元抵扣券"; awardBlockID = 0;
                    }
                }
                else if (randomRate <= 535)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardCash5");
                    if (bllLuckDraw.GetCash50RecordsCount(awardID, startTime, endTime) < 100)   //最多100个,如果超过了100个,则获得20元抵扣券
                    {
                        awardType = 4; title = "双12抽奖送现金5元"; awardBlockID = 1;
                    }
                    else
                    {
                        awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; title = "双12抽奖送20元抵扣券"; awardBlockID = 0;
                    }
                }
                else if (randomRate <= 1500)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardRate2");
                    if (bllLuckDraw.GetCash50RecordsCount(awardID, startTime, endTime) < 193)   //最多193个,如果超过了193个,则获得20元抵扣券
                    {
                        awardType = 2; title = "双12抽奖送2%加息券"; awardBlockID = 2;
                    }
                    else
                    {
                        awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; title = "双12抽奖送20元抵扣券"; awardBlockID = 0;
                    }
                }
                else if (randomRate <= 3500)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardRate1");
                    if (bllLuckDraw.GetCash50RecordsCount(awardID, startTime, endTime) < 400)   //最多400个,如果超过了400个,则获得20元抵扣券
                    {
                        awardType = 2; title = "双12抽奖送1%加息券"; awardBlockID = 7;
                    }
                    else
                    {
                        awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; title = "双12抽奖送20元抵扣券"; awardBlockID = 0;
                    }
                }
                else if (randomRate <= 6000)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus50");
                    if (bllLuckDraw.GetCash50RecordsCount(awardID, startTime, endTime) < 500)   //最多500个,如果超过了500个,则获得20元抵扣券
                    {
                        awardType = 1; title = "双12抽奖送50元抵扣券 "; awardBlockID = 4;
                    }
                    else
                    {
                        awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; title = "双12抽奖送20元抵扣券"; awardBlockID = 0;
                    }
                }
                else if (randomRate <= 10000)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; title = "双12抽奖送20元抵扣券"; awardBlockID = 0;
                }

                ActFacade act        = new ActFacade();
                var       sourceData = act.GetActivityModel(awardID); //bllASchedule.GetModel(awardID);
                #region 发放现金、抵扣券和加息券
                if (awardType != -4)
                {
                    if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                        Ldre_AwardID = awardID, Ldre_AwardName = title, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID, Ldre_OrderID = awardType == 4 ? Utils.Createcode() : null, Ldre_ActivityName = "双12抽奖"
                    }))
                    {
                        //发放奖励
                        //sourceData.ActStarttime = DateTime.Now;
                        //sourceData.ActEndtime = DateTime.Now.AddDays(10);   //有效期10天
                        sourceData.ActTypeId = 2; //短期活动
                        switch (awardType)        //后台类别规则和前台规则不一样,所以需要处理,具体说明看awardType定义
                        {
                        case 4:
                            sourceData.RewTypeID = 1;
                            break;

                        case 1:
                            sourceData.RewTypeID = 2;
                            break;

                        case 2:
                            sourceData.RewTypeID = 3;
                            break;
                        }
                        sourceData.ActID   = awardID;
                        sourceData.ActName = title;
                        DrawBonus(sourceData, userID, 10);
                        return(msg = "0;" + awardBlockID.ToString());
                    }
                }

                else if (awardType == -1)
                {
                    return(msg = "3;碰到点小问题,刷新一下试试^v^");
                }

                #endregion

                #region 实体奖品的抽奖记录
                if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                    Ldre_AwardID = awardID, Ldre_AwardName = title, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID, Ldre_ActivityName = "双12抽奖"
                }))
                {
                    return(msg = "0;" + awardBlockID.ToString());
                }
                else
                {
                    return(msg = "3;碰到点小问题,刷新一下试试^v^");
                }
                #endregion
            }
            catch (Exception ex)
            {
                LogInfo.WriteLog("双12抽奖活动异常日志:" + "msg:" + ex.Message + "   StackTrace" + ex.StackTrace);

                //没有增加任何抽奖记录时的异常状态
                return(msg = "3;" + ex.Message);
            }
        }