Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var moduleNameReq = Request["moduleName"];

            if (!string.IsNullOrWhiteSpace(moduleNameReq))
            {
                moduleName = moduleNameReq;
            }
            isHideVIPPrice             = Convert.ToInt32(Request["isHideVIPPrice"]);
            isHideVIPPrice0            = Convert.ToInt32(Request["isHideVIPPrice0"]);
            isHideVIPDatelong          = Convert.ToInt32(Request["isHideVIPDatelong"]);
            isHideVIPInterestID        = Convert.ToInt32(Request["isHideVIPInterestID"]);
            isShowSendNotice           = Convert.ToInt32(Request["isShowSendNotice"]);
            isShowMinScore             = Convert.ToInt32(Request["isShowMinScore"]);
            isShowMinWithdrawCashScore = Convert.ToInt32(Request["isShowMinWithdrawCashScore"]);

            UserInfo currentUserInfo = bllKeyValueData.GetCurrentUserInfo();

            if (currentUserInfo != null)
            {
                UserId               = currentUserInfo.UserID;
                Recharge             = bllKeyValueData.GetDataVaule("Recharge", "100", bllKeyValueData.WebsiteOwner);
                SendNoticePrice      = bllKeyValueData.GetDataVaule("SendNoticePrice", "1", bllKeyValueData.WebsiteOwner);
                VIPPrice             = bllKeyValueData.GetDataVaule("VIPPrice", "1", bllKeyValueData.WebsiteOwner);
                VIPPrice0            = bllKeyValueData.GetDataVaule("VIPPrice", "0", bllKeyValueData.WebsiteOwner);
                VIPDatelong          = bllKeyValueData.GetDataVaule("VIPDatelong", "1", bllKeyValueData.WebsiteOwner);
                VIPInterestID        = bllKeyValueData.GetDataVaule("VIPInterestID", "1", bllKeyValueData.WebsiteOwner);
                MinScore             = bllKeyValueData.GetDataVaule("MinScore", "1", bllKeyValueData.WebsiteOwner);
                MinWithdrawCashScore = bllKeyValueData.GetDataVaule("MinWithdrawCashScore", "1", bllKeyValueData.WebsiteOwner);
                if (!string.IsNullOrWhiteSpace(VIPInterestID))
                {
                    JuActivityInfo juAct = bllJuAct.GetJuActivity(Convert.ToInt32(VIPInterestID));
                    if (juAct != null)
                    {
                        VIPInterestDescription = juAct.ActivityDescription;
                    }
                }
                else
                {
                    VIPInterestID = "0";
                }
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Request.InputStream);
                try
                {
                    xmlDoc.Save(string.Format("C:\\WXPay\\Notify{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));
                }
                catch (Exception)
                {
                }
                //全部参数
                Dictionary <string, string> parametersAll = new Dictionary <string, string>();
                foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes)
                {
                    string key   = item.Name;
                    string value = item.InnerText;
                    if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value)))
                    {
                        parametersAll.Add(key, value);
                    }
                }

                parametersAll = (from entry in parametersAll
                                 orderby entry.Key ascending
                                 select entry).ToDictionary(pair => pair.Key, pair => pair.Value);//全部参数排序

                BllOrder bllOrder = new BllOrder();
                BLLJIMP.Model.OrderPay orderPay = bllOrder.GetOrderPay(parametersAll["out_trade_no"], "", bllOrder.WebsiteOwner);

                BllPay    bllPay    = new BllPay();
                PayConfig payConfig = bllPay.GetPayConfig();
                if (bllPay.VerifySignatureWx(parametersAll, payConfig.WXPartnerKey))//验证签名
                {
                    if (orderPay == null)
                    {
                        Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                        return;
                    }

                    if (orderPay.Status == 1)
                    {
                        Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                        return;
                    }
                    orderPay.Status = 1;
                    if (bllOrder.Update(orderPay))
                    {
                        BLLUser bllUser = new BLLUser();
                        if (orderPay.Type == "1")
                        {
                            int score = 0;
                            int.TryParse(orderPay.Ex1, out score);
                            BLLKeyValueData bllKeyValueData  = new BLLKeyValueData();
                            string          ScoreDispalyName = bllKeyValueData.GetDataVaule("ScoreDispalyName", "1", bllKeyValueData.WebsiteOwner);

                            string msg = "消费" + orderPay.Total_Fee + "元,充值" + score + ScoreDispalyName;
                            if (bllUser.AddUserScoreDetail(orderPay.UserId, EnumStringHelper.ToString(ScoreDefineType.Recharge), bllUser.WebsiteOwner, score, msg))
                            {
                                Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                            }
                            else
                            {
                                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                            }
                            //BLLSystemNotice bllSystemNotice = new BLLSystemNotice();
                            //bllSystemNotice.SendNotice(BLLSystemNotice.NoticeType.SystemMessage, null, null, orderPay.UserId, msg);
                        }
                        else if (orderPay.Type == "2")
                        {
                            string invoiceMsg;
                            if (orderPay.Ex1 == "1")
                            {
                                invoiceMsg = "带发票,";
                            }
                            else
                            {
                                invoiceMsg = "无发票,";
                            }

                            string msg = "充值VIP," + invoiceMsg + "消费" + orderPay.Total_Fee.ToString() + "元";


                            BLLKeyValueData bllKeyValueData = new BLLKeyValueData();
                            string          VIPDatelong     = bllKeyValueData.GetDataVaule("VIPDatelong", "1", bllKeyValueData.WebsiteOwner);
                            if (string.IsNullOrWhiteSpace(VIPDatelong))
                            {
                                VIPDatelong = "12";
                            }
                            int datelong = Convert.ToInt32(VIPDatelong);

                            BLLUserExpand bllUserExpand = new BLLUserExpand();
                            UserExpand    userVip       = bllUserExpand.GetUserExpand(BLLJIMP.Enums.UserExpandType.UserIsVip, orderPay.UserId);
                            string        userVipEndDate;
                            if (userVip == null || DateTime.Parse(userVip.DataValue) < DateTime.Now)
                            {
                                userVipEndDate = DateTime.Now.AddMonths(datelong).ToString("yyyy-MM-dd");
                            }
                            else
                            {
                                userVipEndDate = DateTime.Parse(userVip.DataValue).AddMonths(datelong).ToString("yyyy-MM-dd");
                            }
                            bllUserExpand.UpdateUserExpand(BLLJIMP.Enums.UserExpandType.UserIsVip, orderPay.UserId, userVipEndDate);

                            //更新用户字段
                            UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo();
                            scoreModel.AddNote   = msg;
                            scoreModel.AddTime   = DateTime.Now;
                            scoreModel.Score     = 0;
                            scoreModel.UserID    = orderPay.UserId;
                            scoreModel.ScoreType = "RechargeVIP";
                            UserInfo currUser = bllUser.GetUserInfo(orderPay.UserId);
                            scoreModel.TotalScore   = currUser.TotalScore;
                            scoreModel.WebSiteOwner = currUser.WebsiteOwner;
                            if (bllUser.Add(scoreModel))
                            {
                                BLLSystemNotice bllSystemNotice = new BLLSystemNotice();
                                bllSystemNotice.SendNotice(BLLSystemNotice.NoticeType.SystemMessage, null, null, orderPay.UserId, msg);

                                Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                            }
                            else
                            {
                                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                            }
                        }

                        return;
                    }
                    else
                    {
                        Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                        return;
                    }
                }
                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
            }
            catch (Exception)
            {
                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
            }
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            string  scoreStr = context.Request["score"];
            decimal score    = Convert.ToDecimal(scoreStr);

            if (score == 0)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "积分不能为0";
                bllKeyValueData.ContextResponse(context, apiResp);
                return;
            }
            if (CurrentUserInfo == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.UserIsNotLogin;
                apiResp.msg  = "您还没有登录";
                bllKeyValueData.ContextResponse(context, apiResp);
                return;
            }
            BllOrder  bllOrder  = new BllOrder();
            BllPay    bllPay    = new BllPay();
            PayConfig payConfig = bllPay.GetPayConfig();

            string  rechargeValue = bllKeyValueData.GetDataVaule("Recharge", "100", bllKeyValueData.WebsiteOwner);
            decimal rechargeFee   = Convert.ToDecimal(rechargeValue);
            decimal totalFee      = rechargeFee / 100 * score;

            string websiteOwner = bllKeyValueData.WebsiteOwner;

            OrderPay orderPay = new OrderPay();

            orderPay.OrderId      = bllOrder.GetGUID(TransacType.CommAdd);
            orderPay.InsertDate   = DateTime.Now;
            orderPay.Status       = 0;
            orderPay.Type         = "1";
            orderPay.Subject      = "积分充值";
            orderPay.Total_Fee    = totalFee;
            orderPay.UserId       = CurrentUserInfo.UserID;
            orderPay.WebsiteOwner = websiteOwner;
            orderPay.Ex1          = scoreStr;

            var non_str = Payment.WeiXin.CommonUtil.CreateNoncestr();//随机串
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("appid", payConfig.WXAppId);
            dic.Add("body", "订单" + orderPay.OrderId);
            dic.Add("mch_id", payConfig.WXMCH_ID);//商户号
            dic.Add("nonce_str", non_str);
            dic.Add("out_trade_no", orderPay.OrderId);
            dic.Add("spbill_create_ip", context.Request.UserHostAddress);
            dic.Add("total_fee", (totalFee * 100).ToString("F0"));
            dic.Add("notify_url", string.Format("http://{0}/WxPayNotify/DoPayWxNotify.aspx", context.Request.Url.Authority));
            dic.Add("trade_type", "NATIVE");
            dic.Add("product_id", orderPay.OrderId);
            string strtemp = Payment.WeiXin.CommonUtil.FormatBizQueryParaMap(dic, false);
            string sign    = Payment.WeiXin.MD5SignUtil.Sign(strtemp, payConfig.WXPartnerKey);

            dic = (from entry in dic
                   orderby entry.Key ascending
                   select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
            dic.Add("sign", sign);

            string postData = Payment.WeiXin.CommonUtil.ArrayToXml(dic);
            string url      = "https://api.mch.weixin.qq.com/pay/unifiedorder";

            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
            byte[] requestBytes           = System.Text.Encoding.UTF8.GetBytes(postData);
            req.Method        = "POST";
            req.ContentType   = "application/x-www-form-urlencoded";
            req.ContentLength = requestBytes.Length;
            Stream requestStream = req.GetRequestStream();

            requestStream.Write(requestBytes, 0, requestBytes.Length);
            requestStream.Close();

            System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse();
            StreamReader sr      = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);
            string       backStr = sr.ReadToEnd();

            sr.Close();
            res.Close();
            var result      = System.Xml.Linq.XDocument.Parse(backStr);
            var return_code = result.Element("xml").Element("return_code").Value;

            if (!return_code.ToUpper().Equals("SUCCESS"))
            {
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.msg    = "预支付失败";
                apiResp.result = new
                {
                    return_msg = result.Element("xml").Element("return_msg").Value,
                    post_data  = postData
                };
                bllKeyValueData.ContextResponse(context, apiResp);
                return;
            }

            var rusult_code = result.Element("xml").Element("result_code").Value;

            if (return_code.ToUpper().Equals("SUCCESS") && (rusult_code.ToUpper().Equals("SUCCESS")))
            {
                var prepay_id = result.Element("xml").Element("prepay_id").Value;
                var code_url  = result.Element("xml").Element("code_url").Value;
                orderPay.Trade_No = prepay_id;
                bllOrder.Add(orderPay);

                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                apiResp.msg    = "预支付完成";
                apiResp.status = true;
                apiResp.result = new
                {
                    orderId   = orderPay.OrderId,
                    prepay_id = prepay_id,
                    code_url  = code_url
                };
            }
            else
            {
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.result = result.Element("xml").Element("err_code_des").Value;
                apiResp.msg    = "预支付失败";
            }
            bllKeyValueData.ContextResponse(context, apiResp);
        }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Recharge = bllKeyValueData.GetDataVaule("CreditAcountRecharge", "100", bllKeyValueData.WebsiteOwner);
 }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            int    score      = Convert.ToInt32(context.Request["score"]);
            string moduleName = "积分";

            if (!string.IsNullOrWhiteSpace(context.Request["module_name"]))
            {
                moduleName = context.Request["module_name"];
            }
            string websiteOwner = bllKeyValueData.WebsiteOwner;

            if (score <= 0)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = moduleName + "不能为0";
                bllKeyValueData.ContextResponse(context, apiResp);
                return;
            }
            string rechargeValue        = bllKeyValueData.GetDataVaule("Recharge", "100", websiteOwner);
            string minScore             = bllKeyValueData.GetDataVaule("MinScore", "1", websiteOwner);
            string minWithdrawCashScore = bllKeyValueData.GetDataVaule("MinWithdrawCashScore", "1", websiteOwner);

            if (score < Convert.ToDecimal(minWithdrawCashScore))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "提现数额不能少于" + minWithdrawCashScore + moduleName;
                bllKeyValueData.ContextResponse(context, apiResp);
                return;
            }

            double curTotalScore = CurrentUserInfo.TotalScore;
            double sTotalScore   = curTotalScore - score;
            double nScore        = Convert.ToDouble(minScore) + score;

            if (sTotalScore < Convert.ToDouble(minScore))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = moduleName + "不足";
                bllKeyValueData.ContextResponse(context, apiResp);
                return;
            }
            decimal rechargeFee = Convert.ToDecimal(rechargeValue);
            decimal money       = rechargeFee / 100 * score;


            WithdrawCash model = new WithdrawCash();

            model.Amount           = money;
            model.UserId           = CurrentUserInfo.UserID;
            model.TrueName         = CurrentUserInfo.TrueName;
            model.WebSiteOwner     = websiteOwner;
            model.WithdrawCashType = "ScoreOnLine";
            model.TransfersType    = 1;
            model.Status           = 0;
            model.Score            = score;
            model.RealAmount       = money;
            model.ServerFee        = 0;
            model.Phone            = CurrentUserInfo.Phone;
            model.LastUpdateDate   = DateTime.Now;
            model.InsertDate       = DateTime.Now;
            model.IsPublic         = 2;

            //积分明细
            UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo();

            scoreModel.AddNote      = string.Format("申请提现消耗{0}{1}", score, moduleName);
            scoreModel.AddTime      = DateTime.Now;
            scoreModel.Score        = 0 - score;
            scoreModel.UserID       = CurrentUserInfo.UserID;
            scoreModel.ScoreType    = "WithdrawCash";
            scoreModel.TotalScore   = sTotalScore;
            scoreModel.WebSiteOwner = websiteOwner;

            //通知
            BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice();
            notice.Ncontent     = scoreModel.AddNote;
            notice.UserId       = CurrentUserInfo.UserID;
            notice.Receivers    = CurrentUserInfo.UserID;
            notice.SendType     = 2;
            notice.SerialNum    = bllKeyValueData.GetGUID(TransacType.SendSystemNotice);
            notice.Title        = "申请提现消耗淘股币";
            notice.NoticeType   = 1;
            notice.WebsiteOwner = websiteOwner;
            notice.InsertTime   = DateTime.Now;

            BLLTransaction tran = new BLLTransaction();

            if (bllUser.Update(CurrentUserInfo,
                               string.Format("TotalScore=TotalScore-{0}", score),
                               string.Format("AutoID={0} AND WebsiteOwner='{1}' AND TotalScore>{2}", CurrentUserInfo.AutoID, websiteOwner, nScore),
                               tran) > 0 &&
                bllUser.Add(scoreModel, tran) &&
                bllUser.Add(notice, tran) &&
                bllUser.Add(model, tran))
            {
                tran.Commit();
                apiResp.code   = (int)APIErrCode.IsSuccess;
                apiResp.msg    = "申请成功";
                apiResp.status = true;
            }
            else
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "申请失败";
            }
            bllKeyValueData.ContextResponse(context, apiResp);
        }
Ejemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            string id          = context.Request["id"];
            string type        = context.Request["type"];
            string content     = context.Request["content"];
            string articleName = context.Request["article_name"];
            string moduleName  = "积分";

            if (!string.IsNullOrWhiteSpace(context.Request["module_name"]))
            {
                moduleName = context.Request["module_name"];
            }
            UserInfo toUser = bllUser.GetUserInfoByAutoID(Convert.ToInt32(id), bll.WebsiteOwner);

            if (toUser == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                apiResp.msg  = "通知对象未找到";
                bll.ContextResponse(context, apiResp);
                return;
            }

            if (type == "2") // 收费短信通知
            {
                string sendNoticePrice = bllKeyValueData.GetDataVaule("SendNoticePrice", "1", bllKeyValueData.WebsiteOwner);
                if (string.IsNullOrWhiteSpace(sendNoticePrice))
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                    apiResp.msg  = "未配置短信消费" + moduleName;
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                if (string.IsNullOrWhiteSpace(toUser.Phone))
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                    apiResp.msg  = "通知对象的手机未找到";
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                int sendNoticePriceNum = Convert.ToInt32(sendNoticePrice);
                if (CurrentUserInfo.TotalScore < sendNoticePriceNum)
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                    apiResp.msg  = moduleName + "不足";
                    bll.ContextResponse(context, apiResp);
                    return;
                }

                bool sendSmsResult = false;

                string smsMsg = "您的";
                if (!string.IsNullOrEmpty(articleName))
                {
                    smsMsg += "《" + articleName + "》有最新提醒:" + content + "   提醒人:" + bllUser.GetUserDispalyName(CurrentUserInfo);
                }


                string verCode      = new Random().Next(111111, 999999).ToString();
                string msg          = "";
                string smsSignature = string.Format("{0}", bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature);//短信签名

                bllSms.SendSmsMisson(toUser.Phone, smsMsg, DateTime.Now.ToString(), smsSignature, out sendSmsResult, out msg);
                if (sendSmsResult)
                {
                    bllUser.AddUserScoreDetail(CurrentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.SendMessage), bll.WebsiteOwner, (0 - sendNoticePriceNum), string.Format("短信通知消耗{0}{1}", sendNoticePriceNum, moduleName));

                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                    apiResp.msg    = "短信发送成功";
                    apiResp.status = true;
                }
                else
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                    apiResp.msg  = "短信发送失败," + msg;
                }
            }
            else
            {
                BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice();
                notice.InsertTime   = DateTime.Now;
                notice.UserId       = CurrentUserInfo.UserID;
                notice.Receivers    = toUser.UserID;
                notice.WebsiteOwner = bll.WebsiteOwner;
                notice.NoticeType   = (int)BLLSystemNotice.NoticeType.Message;
                notice.SendType     = 2;
                notice.Ncontent     = bll.GetContentHtml(BLLSystemNotice.NoticeType.Message, CurrentUserInfo, null, content);
                notice.SerialNum    = bll.GetGUID(TransacType.SendSystemNotice);
                bool addResult = bll.Add(notice);
                if (addResult)
                {
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                    apiResp.msg    = "通知发送成功";
                    apiResp.status = true;
                }
                else
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                    apiResp.msg  = "通知发送失败";
                }
            }
            bll.ContextResponse(context, apiResp);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 新闻资讯列表
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string getPartnerList(HttpContext context)
        {
            int page       = Convert.ToInt32(context.Request["page"]),
                rows       = Convert.ToInt32(context.Request["rows"]);
            string type    = context.Request["type"];
            string cateId  = "79";
            string keyword = context.Request["keyword"];
            string status  = context.Request["status"];

            if (page == 0)
            {
                page = 1;
            }
            if (rows == 0)
            {
                rows = int.MaxValue;
            }
            int totalCount = 0;
            var dataList   = bll.GetJuActivityList(type, null, out totalCount, page, rows, null, currentUserInfo.UserID, cateId, bll.WebsiteOwner, keyword, "", "", "", "", false, "", false, true, status);

            var data = from p in dataList
                       select new {
                id       = p.JuActivityID,
                title    = p.ActivityName,
                pv       = p.PV,
                hide     = p.IsHide,
                status   = p.TStatus,
                province = (p.ProvinceCode == "0" || string.IsNullOrWhiteSpace(p.ProvinceCode)) ? "全国" : bllKeyValueData.GetDataVaule("Province", p.ProvinceCode),
                favNum   = bllCommRelation.GetRelationCount(CommRelationType.JuActivityFavorite, p.JuActivityID.ToString(), null),
                cmtNum   = p.CommentCount,
                img      = p.ThumbnailsPath,
                sort     = p.Sort
            };

            return(Common.JSONHelper.ObjectToJson(new
            {
                rows = data,
                total = totalCount
            }));
        }