示例#1
0
        /// <summary>
        /// 5月任性赚,“三重好礼”送不停   活动时间 2015年5月4日—2015年5月31日
        /// </summary>
        ///

        public void MayPan(decimal TrAMT, int month, int Reg)
        {
            if (month == 3 || month == 6)  //只有3个月和6个月才生成奖励记录
            {
                M_Activity_schedule ma = new M_Activity_schedule();
                B_Activity_schedule ba = new B_Activity_schedule();

                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();


                DateTime nowdate = DateTime.Now;

                DateTime startdate = new DateTime(2015, 06, 26, 00, 00, 00);
                DateTime enddate   = new DateTime(2015, 07, 31, 23, 59, 59);

                if (startdate < nowdate && nowdate < enddate) //在有效范围之内则执行活动计划
                {
                    ma = ba.GetModel(8);                      //获取奖励对象

                    // ma = ba.GetModel(10);  //获取奖励对象
                    //
                    decimal rewardamt = GetAmt(TrAMT, month);
                    mb.activity_schedule_id   = ma.activity_schedule_id;
                    mb.membertable_registerid = Reg;
                    mb.activity_schedule_name = ma.activity_schedule_name;
                    mb.amount_of_reward       = rewardamt;
                    mb.use_lower_limit        = ma.use_lower_limit;
                    mb.reward     = ma.reward;
                    mb.start_date = nowdate;
                    mb.end_date   = ma.end_date;
                    mb.entry_time = nowdate;
                    int bbid = bb.Add(mb);
                    if (bbid > 0) //奖励记录成功后插入明细记录
                    {
                        mbaw.bonus_account_id       = bbid;
                        mbaw.membertable_registerid = Reg;
                        mbaw.income             = rewardamt;
                        mbaw.expenditure        = 0.00M;
                        mbaw.time_of_occurrence = mb.entry_time;
                        // mbaw.
                        mbaw.award_description = "7月“投资拿现金大奖”  活动时间 2015年7月1日—2015年7月31日 投资" + TrAMT.ToString() + "周期" + month.ToString() + "月 奖励" + rewardamt.ToString();
                        mbaw.water_type        = 0;
                        bbaw.Add(mbaw);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 12月份元旦活动转账专用 获取活动信息  短信通知部分需要更改
        /// </summary>
        /// <param name="mc"></param>
        /// <param name="TrAMT"></param>
        /// <param name="TransAmt"></param>
        public void YuandaiToUserTransfer(M_CashAwards mc, decimal TrAMT, decimal TransAmt)
        {
            M_Transfer m = new M_Transfer();

            m.Version = "10";
            m.CmdId   = "Transfer";

            // m.OrdId = Utils.Createcode();

            m.OrdId     = mc.OrdId.ToString();
            m.OutCustId = Utils.GetMerCustID();
            m.OutAcctId = "MDT000001";
            m.TransAmt  = mc.Amounts.ToString("0.00");
            m.InCustId  = mc.UsrCustId;
            m.BgRetUrl  = Utils.GetRe_url("Thirdparty/ToUserTransfer.aspx");
            m.MerPriv   = mc.proid.ToString();


            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(m.Version);
            chkVal.Append(m.CmdId);
            chkVal.Append(m.OrdId);
            chkVal.Append(m.OutCustId);
            chkVal.Append(m.OutAcctId);
            chkVal.Append(m.TransAmt);
            chkVal.Append(m.InCustId);
            chkVal.Append(m.RetUrl);
            chkVal.Append(m.BgRetUrl);
            chkVal.Append(m.MerPriv);

            string chkv = chkVal.ToString();

            LogInfo.WriteLog("12月份元旦活动平台向用户活动转账加签chkv字符:" + 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);

            LogInfo.WriteLog("12月份元旦活动平台向用户活动转账加签字符:" + str.ToString());

            m.ChkValue = sbChkValue.ToString();

            LogInfo.WriteLog("12月份元旦活动平台向用户活动转账提交信息:" + FastJSON.toJOSN(m));
            LogInfo.WriteLog("ChkValue:" + m.ChkValue);


            using (var client = new WebClient())
            {
                var values = new NameValueCollection();
                values.Add("Version", m.Version);
                values.Add("CmdId", m.CmdId);
                values.Add("OrdId", m.OrdId);
                values.Add("OutCustId", m.OutCustId);
                values.Add("OutAcctId", m.OutAcctId);
                values.Add("TransAmt", m.TransAmt);
                values.Add("InCustId", m.InCustId);
                values.Add("InAcctId", m.InAcctId);
                values.Add("RetUrl", m.RetUrl);
                values.Add("BgRetUrl", m.BgRetUrl);
                values.Add("MerPriv", m.MerPriv);
                values.Add("ChkValue", m.ChkValue);
                string url = Utils.GetChinapnrUrl();
                //同步发送form表单请求
                byte[] result = client.UploadValues(url, "POST", values);
                var    retStr = Encoding.UTF8.GetString(result);
                // Response.Write(retStr);
                LogInfo.WriteLog("12月份元旦活动自动扣款转账(商户用)返回报文" + retStr);
                ReTransfer reg = new ReTransfer();

                var           retloan = (ReTransfer)FastJSON.ToObject(retStr, reg);
                StringBuilder builder = new StringBuilder();
                builder.Append(retloan.CmdId);
                builder.Append(retloan.RespCode);
                builder.Append(retloan.OrdId);
                builder.Append(retloan.OutCustId);
                builder.Append(retloan.OutAcctId);
                builder.Append(retloan.TransAmt);
                builder.Append(retloan.InCustId);
                builder.Append(retloan.InAcctId);
                builder.Append(HttpUtility.UrlDecode(retloan.RetUrl));
                builder.Append(HttpUtility.UrlDecode(retloan.BgRetUrl));
                builder.Append(retloan.MerPriv);
                var msg = builder.ToString();

                LogInfo.WriteLog("12月份元旦活动平台向用户活动转账返回参数:" + msg);
                //验签
                string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
                int    ret        = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, retloan.ChkValue);

                LogInfo.WriteLog("12月份元旦活动平台向用户活动转账验签ret:" + ret.ToString());
                if (ret == 0)
                {
                    if (retloan.RespCode == "000")
                    {
                        /*
                         * string sql = "update hx_CashAwards  set  OrdIdstate=3  where OrdIdstate=1 and OrdId=" + retloan.OrdId + " and  proid =" + retloan.MerPriv;
                         * DbHelperSQL.RunSql(sql);
                         * LogInfo.WriteLog("平台向用户活动转账验签更新"+ sql);
                         */
                        // Response.Write(retloan.RespCode + "  <br> ");
                        B_usercenter BUC = new B_usercenter();

                        int dint = BUC.UpateAwa(retloan);
                        LogInfo.WriteLog("12月份元旦活动事务执行返回:" + dint.ToString());
                        if (dint > 0)
                        {
                            B_member_table dmt = new B_member_table();

                            string    sql = "SELECT registerid,username,mobile  from hx_member_table where UsrCustId='" + retloan.InCustId + "'";
                            DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);

                            if (dt.Rows.Count > 0)
                            {
                                //活动奖历
                                M_Activity_schedule ma = new M_Activity_schedule();
                                B_Activity_schedule ba = new B_Activity_schedule();
                                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();
                                DateTime dte = DateTime.Now;


                                // ma = ba.GetModel(16);  //测试平台
                                ma = ba.GetModel(15);  //获取奖励对象


                                mb.activity_schedule_id   = ma.activity_schedule_id;
                                mb.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString());
                                mb.activity_schedule_name = ma.activity_schedule_name;
                                mb.amount_of_reward       = decimal.Parse(retloan.TransAmt);
                                mb.use_lower_limit        = ma.use_lower_limit;
                                mb.reward       = ma.reward;
                                mb.start_date   = dte;
                                mb.end_date     = dte;
                                mb.entry_time   = dte;
                                mb.reward_state = 3;
                                int bbid = bb.Add(mb);
                                if (bbid > 0) //奖励记录成功后插入明细记录
                                {
                                    mbaw.bonus_account_id       = bbid;
                                    mbaw.membertable_registerid = mb.membertable_registerid;
                                    mbaw.income             = mb.amount_of_reward;
                                    mbaw.expenditure        = 0.00M;
                                    mbaw.time_of_occurrence = mb.entry_time;
                                    // mbaw.
                                    mbaw.award_description = "已汇入个人账户";
                                    mbaw.water_type        = 0;
                                    bbaw.Add(mbaw);


                                    //短信通知

                                    #region MyRegion                                 //短信通知
                                    string contxt = Utils.GetMSMEmailContext(20, 1); // 获取注册成功邮件内容

                                    StringBuilder sbsms = new StringBuilder(contxt);

                                    sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString());

                                    sbsms = sbsms.Replace("#MONEY#", TrAMT.ToString("0.00"));

                                    sbsms = sbsms.Replace("#AMTM#", TransAmt.ToString("0.00"));


                                    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   = int.Parse(dt.Rows[0]["registerid"].ToString());
                                    psms.smstype      = smstype;
                                    psms.smscontext   = sbsms.ToString();
                                    psms.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                                    psms.vcode        = "";

                                    osms.Add(psms);
                                    #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   = "投资成功现金奖励";
                                pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目,现金奖励 " + retloan.TransAmt + "元。如有问题可咨询创利投的客服!";
                                pm.PubTime  = dti;
                                B_usercenter.AddMessage(pm);
                                #endregion
                            }

                            LogInfo.WriteLog("12月份元旦活动 平台向用户活动转账验签更新成功,需要写入消息");
                        }
                    }
                    else
                    {
                        //Response.Write(HttpUtility.UrlDecode(retloan.));
                    }
                }
            }
        }
示例#3
0
        public static string LuckDrawAward()
        {
            JavaScriptSerializer jss    = new JavaScriptSerializer();
            AjaxResponseData     arData = new AjaxResponseData();

            try
            {
                string msg   = "";
                int    state = new LuckDraw().CheckActivityTime(ref msg);
                if (state != 0)
                {
                    arData = new AjaxResponseData {
                        code = "4", data = msg
                    };
                    return(jss.Serialize(arData));
                }
                M_login M_uid = (M_login)DataCache.GetCache(Utils.GetUserIDCookieslocahost().ToString());
                if (M_uid == null)
                {
                    arData = new AjaxResponseData {
                        code = "1", data = "请登录后重试"
                    };
                    return(jss.Serialize(arData));
                }
                if (M_uid.codeno != Utils.getSessioncode())
                {
                    arData = new AjaxResponseData {
                        code = "1", data = "请登录后重试"
                    };
                    return(jss.Serialize(arData));
                }
                //获取登录用户编号
                int userID = M_uid.userid;
                //可抽奖次数
                int            CanUseTimes = 1;
                B_member_table bllMember   = new B_member_table();
                //获取会员信息
                PartialMemberModel member = bllMember.GetPartialModel(userID);
                //验证用户是否为今天新注册的用户
                if (member.registration_time >= DateTime.Now.Date && member.registration_time < DateTime.Now.AddDays(1).Date&& member.isrealname == 1)
                {
                    CanUseTimes += 1;
                }
                B_LuckDraw bllLuckDraw = new B_LuckDraw();
                //获取用户的抽奖记录数量(当天的)
                int recordsCount = bllLuckDraw.GetRecordsCount(userID, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);
                CanUseTimes -= recordsCount;

                if (CanUseTimes <= 0)
                {
                    arData = new AjaxResponseData {
                        code = "2", data = "抽奖机会已用完,请明天再来"
                    };
                    return(jss.Serialize(arData));
                }
                #region 规则及数据
                // 现金50元   50  0.17 %(60次抽满后,每天限中2次,概率填充入50元代金券)
                //1 -17
                //50元代金券  2450    23.33 %
                //18-2350
                //20元代金卷  2100    20.00 %
                //2351-4350
                //10元代金卷  2100    20.00 %
                //4351-6350
                //1 % 加息券   1750    16.67 %
                //6351-8017
                //2 % 加息券   1400    13.33 %
                //8018-9350
                //谢谢参与    682.5   6.50 %
                //9351-10000

                //47    9月注册送500元奖励
                //48    9月注册送200元奖励
                //49    9月注册送50元奖励
                //50    9月注册送20元奖励
                //51    [9月注册送10元奖励]
                //52    [9月注册送8元奖励]

                //1   3 % 加息券
                //2   1 % 加息券
                //3   2 % 加息券
                //4   加息券
                #endregion
                //现金50元已抽中的个数
                int cash50Count = bllLuckDraw.GetCash50RecordsCount(-2, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);
                B_Activity_schedule         bllASchedule = new B_Activity_schedule();
                B_Activity                  bllActivity  = new B_Activity();
                admin.users.AddBonusForUser adfu         = new admin.users.AddBonusForUser();
                //奖品编号
                int awardID = 0;
                //奖品标题
                string title = "";
                //奖品类型
                int awardType = -1;
                //轮盘区块编号
                int    awardBlockID = 0;
                Random random       = new Random();
                //随机数
                int randomRate = random.Next(1, 10001);
                //randomRate = 9350;
                //switch (randomRate)
                //{
                if (randomRate <= 8)
                {
                    //每天限中2次,概率填充入50元代金券
                    if (cash50Count < 2)
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardCash50");
                        awardType    = 0;
                        title        = "现金50元";
                        awardBlockID = 3;
                    }
                    else
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardBonus50");
                        awardType    = 1;
                        awardBlockID = 7;
                    }
                }
                //现金50元
                else if (randomRate <= 17)
                {
                    //每天限中2次,概率填充入50元代金券
                    if (cash50Count < 2)
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardCash50");
                        awardType    = 0;
                        title        = "现金50元";
                        awardBlockID = 5;
                    }
                    else
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardBonus50");
                        awardType    = 1;
                        awardBlockID = 7;
                    }
                }
                //50元代金券
                else if (randomRate <= 2350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus50"); awardType = 1; awardBlockID = 7;
                }
                //20元代金卷
                else if (randomRate <= 4350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; awardBlockID = 4;
                }
                //10元代金卷
                else if (randomRate <= 6350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus10"); awardType = 1; awardBlockID = 6;
                }
                //1 % 加息券
                else if (randomRate <= 8017)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardRate1"); awardType = 2; awardBlockID = 0;
                }
                //2 % 加息券
                else if (randomRate <= 9350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardRate2"); awardType = 2; awardBlockID = 2;
                }
                //谢谢参与
                else if (randomRate <= 10000)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardThankYou"); awardType = 3; title = "谢谢参与"; awardBlockID = 1;
                }
                //谢谢参与
                if (awardType == -1)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardThankYou"); awardType = 3; title = "谢谢参与"; awardBlockID = 1;
                }
                //}
                //发放代金券
                if (awardType == 1)
                {
                    var sourceData = bllASchedule.GetModel(awardID);
                    title = sourceData.activity_schedule_name.Replace("活动", "抽奖");
                    if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                        Ldre_AwardID = awardID, Ldre_AwardName = sourceData.activity_schedule_name, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID
                    }))
                    {
                        adfu.SubmitBonus(awardID, 1, userID, DateTime.Now, sourceData.end_date, title);
                        arData = new AjaxResponseData {
                            code = "0", data = awardBlockID.ToString()
                        };
                        return(jss.Serialize(arData));
                    }
                }
                //发放加息券
                if (awardType == 2)
                {
                    var sourceData = bllActivity.GetModel(awardID);
                    title = "9月抽奖" + sourceData.ActivityName;
                    if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                        Ldre_AwardID = awardID, Ldre_AwardName = sourceData.ActivityName, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID
                    }))
                    {
                        adfu.SubmitRate(awardID, 1, userID, DateTime.Now, sourceData.EndDate, title);
                        arData = new AjaxResponseData {
                            code = "0", data = awardBlockID.ToString()
                        };
                        return(jss.Serialize(arData));
                    }
                }
                //增加现金和“谢谢参与”的抽奖记录
                if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                    Ldre_AwardID = awardID, Ldre_AwardName = title, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID
                }))
                {
                    arData = new AjaxResponseData {
                        code = "0", data = awardBlockID.ToString()
                    };
                    return(jss.Serialize(arData));
                }
                //没有增加任何抽奖记录时的异常状态
                arData = new AjaxResponseData {
                    code = "3", data = "碰到点小问题,刷新一下试试"
                };
                return(jss.Serialize(arData));
            }
            catch (Exception ex)
            {
                LogInfo.WriteLog("9月抽奖活动异常日志:" + "msg:" + ex.Message + "   StackTrace" + ex.StackTrace);

                //没有增加任何抽奖记录时的异常状态
                arData = new AjaxResponseData {
                    code = "3", data = ex.Message
                };
                return(jss.Serialize(arData));
            }
        }