Exemplo n.º 1
0
        private void MyBind()
        {
            if (Mid > 0)
            {
                M_WX_RedPacket redMod = redBll.SelReturnModel(Mid);
                Name_T.Text        = redMod.Name;
                Flow_T.Text        = redMod.Flow;
                AmountRange_T.Text = redMod.AmountRange;
                RedNum_T.Text      = redMod.RedNum.ToString();
                CodeFormat_T.Text  = redMod.CodeFormat;
                SDate_T.Text       = redMod.SDate.ToString("yyyy-MM-dd");
                EDate_T.Text       = redMod.EDate.ToString("yyyy-MM-dd");
                Wishing_T.Text     = redMod.Wishing;
                Remind_T.Text      = redMod.Remind;
                Save_Btn.Text      = "保存信息";

                CodeFormat_T.Attributes["disabled"]  = "disabled";
                RedNum_T.Attributes["disabled"]      = "disabled";
                AmountRange_T.Attributes["disabled"] = "disabled";
            }
            else
            {
                Flow_T.Text  = function.GetRandomString(10).ToUpper();
                SDate_T.Text = DateTime.Now.ToString("yyyy-MM-dd");
                EDate_T.Text = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd");
            }
            M_WX_APPID appMod = appBll.SelReturnModel(AppID);

            Alias_L.Text = appMod.Alias;
            Call.SetBreadCrumb(Master, "<li><a href='Home.aspx'>移动微信</a></li><li class='active'><a href='RedPacket.aspx'>红包列表</a></li><li><a href='" + Request.RawUrl + "'>红包管理</a>[公众号:" + appMod.Alias + "]</li>");
        }
        private void MyBind()
        {
            EGV.DataSource = detBll.Sel(MainID, "");
            EGV.DataBind();
            M_WX_RedPacket redMod = redBll.SelReturnModel(MainID);

            Call.SetBreadCrumb(Master, "<li><a href='Home.aspx'>移动微信</a></li><li class='active'><a href='RedPacket.aspx?appid=" + redMod.AppID + "'>红包列表</a></li><li>红包详情列表</li>");
            RedPacket_L.Text = string.Format("红包:{0},起始时间:{1},到期时间:{2},金额范围:{3}", redMod.Name, redMod.SDate.ToString("yyyy-MM-dd"), redMod.EDate.ToString("yyyy-MM-dd"), redMod.AmountRange);
        }
Exemplo n.º 3
0
        private void MyBind()
        {
            M_WX_RedDetail detMod = detBll.SelReturnModel(Mid);
            M_WX_RedPacket redMod = redBll.SelReturnModel(detMod.MainID);
            M_WX_APPID     appMod = appBll.SelReturnModel(redMod.AppID);

            Alias_L.Text    = "[" + appMod.Alias + "]的红包[" + redMod.Name + "]";
            RedCode_L.Text  = detMod.RedCode;
            UserName_L.Text = detMod.UserName;
            function.Script(this, "SetRadVal('zstatus_rad','" + detMod.ZStatus + "');");
            Call.SetBreadCrumb(Master, "<li><a href='Home.aspx'>移动微信</a></li><li class='active'><a href='RedPacketFlow.aspx?mainid=" + detMod.MainID + "'>红包列表</a></li><li>红包详情</li>");
        }
Exemplo n.º 4
0
        public ActionResult GetRedPacket()
        {
            ViewBag.state = "2";
            ViewBag.err   = "";
            string flow    = Request["flow"];
            string redcode = Request["redcode"];
            string rurl    = Request["rurl"];//成功后的返回页
            //红包相关检测
            M_WX_RedDetail detMod = new M_WX_RedDetail();

            try
            {
                detMod = detBll.SelModelByCode(redcode);
                M_UserAPP uaMod = uaBll.SelModelByUid(mu.UserID, "wechat");
                if (detMod == null)
                {
                    ViewBag.err = "红包不存在";
                }
                else if (detMod.ZStatus != 1)
                {
                    ViewBag.err = "该红包已经被使用";
                }
                else if (detMod.Amount < 1 || detMod.Amount > 200)
                {
                    ViewBag.err = "红包金额不正确";
                }
                if (!string.IsNullOrEmpty(ViewBag.err))
                {
                    return(View("RedPacket"));
                }
                M_WX_RedPacket redMod = redBll.SelReturnModel(detMod.MainID);
                if (!redMod.Flow.Equals(flow))
                {
                    ViewBag.err = "匹配码不正确";
                }
                else if (redMod.SDate > DateTime.Now)
                {
                    ViewBag.err = "活动尚未开始";
                }
                else if (redMod.EDate < DateTime.Now)
                {
                    ViewBag.err = "活动已经结束";
                }
                if (!string.IsNullOrEmpty(ViewBag.err))
                {
                    return(View("RedPacket"));
                }
                WxAPI api = WxAPI.Code_Get(redMod.AppID);
                WxAPI.AutoSync(Request.RawUrl, api.AppId);
                if (mu.IsNull)
                {
                    ViewBag.err = "用户不存在";
                }
                if (uaMod == null)
                {
                    ViewBag.err = "用户信息不存在";
                }
                if (!string.IsNullOrEmpty(ViewBag.err))
                {
                    return(View("RedPacket"));
                }
                //-------------------
                string apiUrl = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack";
                //生成提交参数
                WxPayData wxdata = new WxPayData();
                wxdata.SetValue("nonce_str", WxAPI.nonce);
                wxdata.SetValue("mch_billno", api.AppId.Pay_AccountID + DateTime.Now.ToString("yyyyMMdd") + function.GetRandomString(10, 2));
                wxdata.SetValue("mch_id", api.AppId.Pay_AccountID);
                wxdata.SetValue("wxappid", api.AppId.APPID);
                wxdata.SetValue("send_name", SiteConfig.SiteInfo.SiteName);
                //接受红包的用户用户在wxappid下的openid
                wxdata.SetValue("re_openid", uaMod.OpenID);//oDTTbwLa7WuySP0WcJJzYJmErCQ4
                wxdata.SetValue("total_amount", (int)(detMod.Amount * 100));
                wxdata.SetValue("total_num", 1);
                wxdata.SetValue("wishing", redMod.Wishing);   //红包祝福语
                wxdata.SetValue("client_ip", "58.215.75.11"); //调用接口的机器IP地址
                wxdata.SetValue("act_name", redMod.Name);     //活动名称
                wxdata.SetValue("remark", redMod.Remind);
                wxdata.SetValue("sign", wxdata.MakeSign());
                //随机码,签名
                string xml      = wxdata.ToXml();
                string response = HttpService.Post(xml, apiUrl, true, 60, api.AppId);
                //------------------------发放完成(不论成功失败均算已领取,记录好返回)
                detMod.UserID   = mu.UserID;
                detMod.UserName = mu.UserName;
                detMod.UseTime  = DateTime.Now.ToString();
                //WxPayData result = new WxPayData(api.AppId.Pay_Key);
                //result.FromXml(response);
                //if (result.GetValue("return_code").ToString().Equals("SUCCESS"))//return_msg
                //{
                //    detMod.ZStatus = 99;
                //}
                //else
                //{
                //    detMod.ZStatus = -1;
                //    detMod.Remind = response;
                //}
                detMod.ZStatus = 99; detMod.Remind = response;
                detBll.UpdateByID(detMod);
                ViewBag.state  = "3";
                ViewBag.amount = detMod.Amount.ToString("f2");
                return(View("RedPacket"));
            }
            catch (Exception ex)
            {
                ZLLog.L(ZLEnum.Log.pay, "微信红包异常,领取码:" + redcode + ",原因:" + ex.Message);
                ViewBag.state = "3";
                ViewBag.err   = ex.Message;
                //如异常,该红包禁用,等待管理员审核
                detMod.ZStatus = -1;
                detMod.Remind  = ex.Message;
                detBll.UpdateByID(detMod);
                return(View("RedPacket"));
            }
        }
Exemplo n.º 5
0
 public bool UpdateByID(M_WX_RedPacket model)
 {
     return(DBCenter.UpdateByID(model, model.ID));
 }
Exemplo n.º 6
0
 public int Insert(M_WX_RedPacket model)
 {
     return(DBCenter.Insert(model));
 }
Exemplo n.º 7
0
        protected void Save_Btn_Click(object sender, EventArgs e)
        {
            M_AdminInfo    adminMod = B_Admin.GetLogin();
            M_WX_RedPacket redMod   = new M_WX_RedPacket();

            if (Mid > 0)
            {
                redMod = redBll.SelReturnModel(Mid);
            }
            redMod.AppID   = AppID;
            redMod.Name    = Name_T.Text;
            redMod.SDate   = Convert.ToDateTime(SDate_T.Text);
            redMod.EDate   = Convert.ToDateTime(EDate_T.Text);
            redMod.Wishing = Wishing_T.Text;
            redMod.Remind  = Remind_T.Text;
            redMod.Flow    = Flow_T.Text;
            if (redMod.EDate <= redMod.SDate)
            {
                function.WriteErrMsg("结束时间不能小于起始时间");
            }
            if (string.IsNullOrEmpty(redMod.Wishing))
            {
                redMod.Wishing = "祝你生活愉快";
            }
            if (redMod.ID > 0)
            {
                redBll.UpdateByID(redMod);
            }
            else
            {
                redMod.RedNum      = DataConvert.CLng(RedNum_T.Text);
                redMod.AmountRange = AmountRange_T.Text;
                redMod.CodeFormat  = CodeFormat_T.Text;
                if (redMod.RedNum < 1)
                {
                    function.WriteErrMsg("红包数量不能小于1");
                }
                double minMoney = 0, maxMoney = 0;
                if (redMod.AmountRange.Contains("-"))
                {
                    minMoney = DataConvert.CDouble(redMod.AmountRange.Split('-')[0]);
                    maxMoney = DataConvert.CDouble(redMod.AmountRange.Split('-')[1]);
                }
                else
                {
                    minMoney = DataConvert.CDouble(redMod.AmountRange);
                    maxMoney = DataConvert.CDouble(redMod.AmountRange);
                }
                if (minMoney < 1 || maxMoney < 1)
                {
                    function.WriteErrMsg("红包金额不能小于1");
                }
                if (minMoney > 200 || maxMoney > 200)
                {
                    function.WriteErrMsg("红包金额不能大于200");
                }
                if (maxMoney < minMoney)
                {
                    function.WriteErrMsg("红包的最大值不能小于最小值");
                }

                redMod.AdminID = adminMod.AdminId;
                redMod.ID      = redBll.Insert(redMod);
                //------------------------
                for (int i = 0; i < redMod.RedNum; i++)
                {
                    M_WX_RedDetail model = new M_WX_RedDetail();
                    model.MainID  = redMod.ID;
                    model.ZStatus = 1;
                    model.Amount  = new Random(Guid.NewGuid().GetHashCode()).NextDouble() * (maxMoney - minMoney) + minMoney;
                    model.RedCode = function.GetCodeByFormat(redMod.CodeFormat);
                    detBll.Insert(model);
                }
            }
            function.WriteSuccessMsg("修改成功", "RedPacket.aspx?AppID=" + AppID);
        }