Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        public void ProcessRequest(HttpContext context)
        {
            BLLJIMP.BLLDistributionOffLine bll = new BLLJIMP.BLLDistributionOffLine();
            BllPay    bllPay     = new BllPay();
            BLLWeixin bllWeixin  = new BLLWeixin();
            string    ids        = context.Request["ids"];
            string    moduleName = "积分";

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

            int total = 0;

            if (string.IsNullOrWhiteSpace(ids))
            {
                apiResp.msg  = "请选中申请";
                apiResp.code = (int)APIErrCode.IsNotFound;
                bll.ContextResponse(context, apiResp);
                return;
            }
            var sourceList = bll.QueryWithdrawCashList(1, int.MaxValue, null, out total, "0", context.Request["type"], ids);

            if (sourceList.Count == 0)
            {
                apiResp.msg  = "选中的申请无待审核申请";
                apiResp.code = (int)APIErrCode.IsNotFound;
                bll.ContextResponse(context, apiResp);
                return;
            }

            string websiteOwner = bll.WebsiteOwner;
            string ip           = System.Web.HttpContext.Current.Request.UserHostAddress;
            int    snum         = 0;

            foreach (var p in sourceList)
            {
                UserInfo pu = bllUser.GetUserInfo(p.UserId, websiteOwner);
                if (pu == null || string.IsNullOrWhiteSpace(pu.WXOpenId))
                {
                    apiResp.status = snum > 0;
                    apiResp.msg    = string.Format("编号:{0},审核出错,用户信息有误", p.AutoID);
                    apiResp.code   = (int)APIErrCode.OperateFail;
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                //通知
                BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice();
                notice.Ncontent     = string.Format("申请提现通过审核,编号:{0}", p.AutoID);
                notice.UserId       = currentUserInfo.UserID;
                notice.Receivers    = pu.UserID;
                notice.SendType     = 2;
                notice.Title        = "申请提现通过审核";
                notice.NoticeType   = 1;
                notice.WebsiteOwner = websiteOwner;
                notice.InsertTime   = DateTime.Now;

                BLLTransaction tran   = new BLLTransaction();
                bool           result = bll.Update(p, string.Format("Status=2,LastUpdateDate=getdate()"), string.Format("AutoID={0}", p.AutoID), tran) > 0;
                if (!result)
                {
                    tran.Rollback();
                    apiResp.status = snum > 0;
                    apiResp.msg    = string.Format("编号:{0},审核出错", p.AutoID);
                    apiResp.code   = snum > 0 ? (int)APIErrCode.IsSuccess : (int)APIErrCode.OperateFail;
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                string msg = "";
                if (bllPay.WeixinTransfers(p.AutoID.ToString(), p.RealAmount, pu.WXOpenId, ip, out msg, "提现"))
                {
                    //发送微信模板消息
                    bllWeixin.SendTemplateMessageNotifyComm(pu, "您提现的佣金已经到账", string.Format("提现金额:{0}元。请查看微信钱包", p.RealAmount));
                    //发送微信模板消息

                    //发送通知
                    notice.SerialNum = bllUser.GetGUID(TransacType.SendSystemNotice);
                    bll.Add(notice);
                    //发送通知
                }
                else//打款失败
                {
                    tran.Rollback();
                    apiResp.status = snum > 0;
                    apiResp.msg    = string.Format("编号:{0},微信打款出错 : {1}", p.AutoID, msg);
                    apiResp.code   = snum > 0 ? (int)APIErrCode.IsSuccess : (int)APIErrCode.OperateFail;
                    bll.ContextResponse(context, apiResp);
                    return;
                }

                tran.Commit();
                snum++;
            }

            if (snum == 0)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "审核失败";
            }
            else
            {
                apiResp.status = true;
                apiResp.code   = (int)APIErrCode.IsSuccess;
                apiResp.msg    = string.Format("审核完成");
            }
            bll.ContextResponse(context, apiResp);
        }
Exemple #4
0
        public void ProcessRequest(HttpContext context)
        {
            string ids        = context.Request["ids"];
            string moduleName = "积分";

            if (!string.IsNullOrWhiteSpace(context.Request["module_name"]))
            {
                moduleName = context.Request["module_name"];
            }
            int total = 0;

            if (string.IsNullOrWhiteSpace(ids))
            {
                apiResp.msg  = "请选中申请";
                apiResp.code = (int)APIErrCode.IsNotFound;
                bll.ContextResponse(context, apiResp);
                return;
            }
            var        sourceList   = bll.QueryWithdrawCashList(1, int.MaxValue, null, out total, "0", context.Request["type"], ids);
            string     websiteOwner = bll.WebsiteOwner;
            List <int> idList       = new List <int>();

            foreach (var p in sourceList)
            {
                UserInfo pu = bllUser.GetUserInfo(p.UserId, websiteOwner);

                //积分明细
                UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo();
                if (pu != null)
                {
                    scoreModel.AddNote      = string.Format("申请提现未通过审核,返还{0}{1},编号:{2}", p.Score, moduleName, p.AutoID);
                    scoreModel.AddTime      = DateTime.Now;
                    scoreModel.Score        = p.Score;
                    scoreModel.UserID       = p.UserId;
                    scoreModel.ScoreType    = "RefuseWithdrawCash";
                    scoreModel.TotalScore   = pu.TotalScore + p.Score;
                    scoreModel.WebSiteOwner = websiteOwner;
                }

                //通知
                BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice();
                if (pu != null)
                {
                    notice.Ncontent     = scoreModel.AddNote;
                    notice.UserId       = currentUserInfo.UserID;
                    notice.Receivers    = pu.UserID;
                    notice.SendType     = 2;
                    notice.Title        = "申请提现未通过审核";
                    notice.NoticeType   = 1;
                    notice.WebsiteOwner = websiteOwner;
                    notice.InsertTime   = DateTime.Now;
                }

                BLLTransaction tran   = new BLLTransaction();
                bool           result = bll.Update(p, string.Format("Status=3,LastUpdateDate=getdate()"), string.Format("AutoID={0}", p.AutoID), tran) > 0;
                if (!result)
                {
                    idList.Add(p.AutoID);
                    tran.Rollback();
                    continue;
                }
                if (pu != null)
                {
                    result = bll.Update(pu, string.Format("TotalScore=TotalScore+{0}", p.Score), string.Format("UserID='{0}' And WebsiteOwner='{1}'", pu.UserID, websiteOwner), tran) > 0;
                    if (!result)
                    {
                        idList.Add(p.AutoID);
                        tran.Rollback();
                        continue;
                    }

                    result = bll.Add(scoreModel, tran);
                    if (!result)
                    {
                        idList.Add(p.AutoID);
                        tran.Rollback();
                        continue;
                    }
                    notice.SerialNum = bllUser.GetGUID(TransacType.SendSystemNotice);
                    result           = bll.Add(notice, tran);
                    if (!result)
                    {
                        idList.Add(p.AutoID);
                        tran.Rollback();
                        continue;
                    }
                }
                tran.Commit();
            }

            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            if (idList.Count == 0)
            {
                apiResp.msg = "处理完成";
            }
            else
            {
                apiResp.msg = string.Format("处理完成,编号[{0}]处理失败", ZentCloud.Common.MyStringHelper.ListToStr(idList, "", ","));
            }
            bll.ContextResponse(context, apiResp);
        }