private void sms_message_post(HttpContext context) { string mobiles = RequestHelper.GetFormString("mobiles"); string content = RequestHelper.GetFormString("content"); if (mobiles == "") { context.Response.Write("{\"status\": 0, \"msg\": \"手机号码不能为空!\"}"); return; } if (content == "") { context.Response.Write("{\"status\": 0, \"msg\": \"短信内容不能为空!\"}"); return; } //开始发送 string msg = string.Empty; bool result = new BLL.sms_message().Send(mobiles, content, 2, out msg); if (result) { context.Response.Write("{\"status\": 1, \"msg\": \"" + msg + "\"}"); return; } context.Response.Write("{\"status\": 0, \"msg\": \"" + msg + "\"}"); return; }
//提交发送 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("user_sms", Vincent._DTcms.DTEnums.ActionEnum.Add.ToString()); //检查权限 //检查短信内容 if (txtSmsContent.Text.Trim() == "") { JscriptMsg("请输入短信内容!", "", "Error"); return; } //检查发送类型 if (rblSmsType.SelectedValue == "1") { if (txtMobileNumbers.Text.Trim() == "") { JscriptMsg("请输入手机号码!", "", "Error"); return; } //开始发送短信 string msg = string.Empty; bool result = new BLL.sms_message().Send(txtMobileNumbers.Text.Trim(), txtSmsContent.Text.Trim(), 2, out msg); if (result) { AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "发送手机短信"); //记录日志 JscriptMsg(msg, "user_list.aspx", "Success"); return; } JscriptMsg(msg, "", "Error"); return; } else { ArrayList al = new ArrayList(); for (int i = 0; i < cblGroupId.Items.Count; i++) { if (cblGroupId.Items[i].Selected) { al.Add(cblGroupId.Items[i].Value); } } if (al.Count < 1) { JscriptMsg("请选择会员组别!", "", "Error"); return; } string _mobiles = GetGroupMobile(al); //开始发送短信 string msg = string.Empty; bool result = new BLL.sms_message().Send(_mobiles, txtSmsContent.Text.Trim(), 2, out msg); if (result) { AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "发送手机短信"); //记录日志 JscriptMsg(msg, "user_sms.aspx", "Success"); return; } JscriptMsg(msg, "", "Error"); return; } }
//提交发送 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("user_sms", DTEnums.ActionEnum.Add.ToString()); //检查权限 //检查短信内容 if (txtSmsContent.Text.Trim() == "") { JscriptMsg("请输入短信内容!", ""); return; } //检查发送类型 if (rblSmsType.SelectedValue == "1") { if (txtMobileNumbers.Text.Trim() == "") { JscriptMsg("请输入手机号码!", ""); return; } //开始发送短信 string msg = string.Empty; bool result = new BLL.sms_message().Send(txtMobileNumbers.Text.Trim(), txtSmsContent.Text.Trim(), 2, out msg); if (result) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "发送手机短信"); //记录日志 JscriptMsg(msg, "user_list.aspx"); return; } JscriptMsg(msg, ""); return; } else { ArrayList al = new ArrayList(); for (int i = 0; i < cblGroupId.Items.Count; i++) { if (cblGroupId.Items[i].Selected) { al.Add(cblGroupId.Items[i].Value); } } if (al.Count < 1) { JscriptMsg("请选择会员组别!", ""); return; } string _mobiles = GetGroupMobile(al); //开始发送短信 string msg = string.Empty; bool result = new BLL.sms_message().Send(_mobiles, txtSmsContent.Text.Trim(), 2, out msg); if (result) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "发送手机短信"); //记录日志 JscriptMsg(msg, "user_sms.aspx"); return; } JscriptMsg(msg, ""); return; } }
private string GetSmsCount() { string code = string.Empty; int count = new BLL.sms_message().GetAccountQuantity(out code); if (code == "115") { return("查询出错:请完善账户信息"); } else if (code != "100") { return("错误代码:" + code); } return(count + " 条"); }
private string verify_mobile(Model.users userModel) { //生成随机码 string strcode = Vincent._DTcms.Utils.Number(4); BLL.user_code codeBll = new BLL.user_code(); Model.user_code codeModel; //检查是否重复提交 codeModel = codeBll.GetModel(userModel.user_name, Vincent._DTcms.DTEnums.CodeEnum.RegVerify.ToString(), "n"); if (codeModel == null) { codeModel = new Model.user_code(); codeModel.user_id = userModel.id; codeModel.user_name = userModel.user_name; codeModel.type = Vincent._DTcms.DTEnums.CodeEnum.RegVerify.ToString(); codeModel.str_code = strcode; codeModel.eff_time = DateTime.Now.AddMinutes(userConfig.regsmsexpired); codeModel.add_time = DateTime.Now; new BLL.user_code().Add(codeModel); } //获得短信模板内容 Model.sms_template smsModel = new BLL.sms_template().GetModel("usercode"); if (smsModel == null) { return("{\"status\":0, \"msg\":\"发送失败,短信模板内容不存在!\"}"); } //替换模板内容 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{webtel}", siteConfig.webtel); msgContent = msgContent.Replace("{weburl}", siteConfig.weburl); msgContent = msgContent.Replace("{username}", userModel.user_name); msgContent = msgContent.Replace("{code}", codeModel.str_code); msgContent = msgContent.Replace("{valid}", userConfig.regsmsexpired.ToString()); //发送短信 string tipMsg = string.Empty; bool sendStatus = new BLL.sms_message().Send(userModel.mobile, msgContent, 2, out tipMsg); if (!sendStatus) { return("{\"status\": 0, \"msg\": \"短信发送失败," + tipMsg + "\"}"); } return("success"); }
private void SetSmsCount() { string errorMsg = string.Empty; int start, len, count = new BLL.sms_message().GetAccountQuantity(out errorMsg); //分析 start = siteConfig.smsqueryformat.IndexOf("{"); if (start > 0) { smsTip.Text = siteConfig.smsqueryformat.Substring(0, start); if (!string.IsNullOrWhiteSpace(errorMsg)) { labSmsCount.InnerText = errorMsg; } else { len = siteConfig.smsqueryformat.Length - start; labSmsCount.InnerText = siteConfig.smsqueryformat.Substring(start, len).Replace("{0}", count.ToString()); } } }
private void edit_order_status(HttpContext context) { //取得管理员登录信息 Model.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo(); if (adminInfo == null) { context.Response.Write("{\"status\": 0, \"msg\": \"未登录或已超时,请重新登录!\"}"); return; } //取得站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //取得订单配置信息 Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); string order_no = MXRequest.GetString("order_no"); string edit_type = MXRequest.GetString("edit_type"); if (order_no == "") { context.Response.Write("{\"status\": 0, \"msg\": \"传输参数有误,无法获取订单号!\"}"); return; } if (edit_type == "") { context.Response.Write("{\"status\": 0, \"msg\": \"无法获取修改订单类型!\"}"); return; } BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { context.Response.Write("{\"status\": 0, \"msg\": \"订单号不存在或已被删除!\"}"); return; } switch (edit_type.ToLower()) { case "order_confirm": //确认订单 //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Confirm.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有确认订单的权限!\"}"); return; } if (model.status > 1) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已经确认,不能重复处理!\"}"); return; } model.status = 2; model.confirm_time = DateTime.Now; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"订单确认失败!\"}"); return; } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Confirm.ToString(), "确认订单号:" + model.order_no); //记录日志 #region 发送短信或邮件 if (orderConfig.confirmmsg > 0) { switch (orderConfig.confirmmsg) { case 1: //短信通知 if (string.IsNullOrEmpty(model.mobile)) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}"); return; } Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.confirmcallindex); //取得短信内容 if (smsModel == null) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}"); return; } //替换标签 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{username}", model.user_name); msgContent = msgContent.Replace("{orderno}", model.order_no); msgContent = msgContent.Replace("{amount}", model.order_amount.ToString()); //发送短信 string tipMsg = string.Empty; bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg); if (!sendStatus) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}"); return; } break; case 2: //邮件通知 //取得用户的邮箱地址 if (model.user_id > 0) { Model.users userModel = new BLL.users().GetModel(model.user_id); if (userModel == null || string.IsNullOrEmpty(userModel.email)) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户不存在或没有填写邮箱地址。\"}"); return; } //取得邮件模板内容 Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.confirmcallindex); if (mailModel == null) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}"); return; } //替换标签 string mailTitle = mailModel.maill_title; mailTitle = mailTitle.Replace("{username}", model.user_name); string mailContent = mailModel.content; mailContent = mailContent.Replace("{webname}", siteConfig.webname); mailContent = mailContent.Replace("{weburl}", siteConfig.weburl); mailContent = mailContent.Replace("{webtel}", siteConfig.webtel); mailContent = mailContent.Replace("{username}", model.user_name); mailContent = mailContent.Replace("{orderno}", model.order_no); mailContent = mailContent.Replace("{amount}", model.order_amount.ToString()); //发送邮件 MXMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname, siteConfig.emailfrom, userModel.email, mailTitle, mailContent); } break; } } #endregion context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功!\"}"); break; case "order_payment": //确认付款 //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Confirm.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有确认付款的权限!\"}"); return; } if (model.status > 1 || model.payment_status == 2) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已确认,不能重复处理!\"}"); return; } model.payment_status = 2; model.payment_time = DateTime.Now; model.status = 2; model.confirm_time = DateTime.Now; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"订单确认付款失败!\"}"); return; } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Confirm.ToString(), "确认付款订单号:" + model.order_no); //记录日志 #region 发送短信或邮件 if (orderConfig.confirmmsg > 0) { switch (orderConfig.confirmmsg) { case 1: //短信通知 if (string.IsNullOrEmpty(model.mobile)) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}"); return; } Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.confirmcallindex); //取得短信内容 if (smsModel == null) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}"); return; } //替换标签 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{username}", model.user_name); msgContent = msgContent.Replace("{orderno}", model.order_no); msgContent = msgContent.Replace("{amount}", model.order_amount.ToString()); //发送短信 string tipMsg = string.Empty; bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg); if (!sendStatus) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}"); return; } break; case 2: //邮件通知 //取得用户的邮箱地址 if (model.user_id > 0) { Model.users userModel = new BLL.users().GetModel(model.user_id); if (userModel == null || string.IsNullOrEmpty(userModel.email)) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户不存在或没有填写邮箱地址。\"}"); return; } //取得邮件模板内容 Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.confirmcallindex); if (mailModel == null) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}"); return; } //替换标签 string mailTitle = mailModel.maill_title; mailTitle = mailTitle.Replace("{username}", model.user_name); string mailContent = mailModel.content; mailContent = mailContent.Replace("{webname}", siteConfig.webname); mailContent = mailContent.Replace("{weburl}", siteConfig.weburl); mailContent = mailContent.Replace("{webtel}", siteConfig.webtel); mailContent = mailContent.Replace("{username}", model.user_name); mailContent = mailContent.Replace("{orderno}", model.order_no); mailContent = mailContent.Replace("{amount}", model.order_amount.ToString()); //发送邮件 MXMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname, siteConfig.emailfrom, userModel.email, mailTitle, mailContent); } break; } } #endregion context.Response.Write("{\"status\": 1, \"msg\": \"订单确认付款成功!\"}"); break; case "order_express": //确认发货 //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Confirm.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有确认发货的权限!\"}"); return; } if (model.status > 2 || model.express_status == 2) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已完成或已发货,不能重复处理!\"}"); return; } int express_id = MXRequest.GetFormInt("express_id"); string express_no = MXRequest.GetFormString("express_no"); if (express_id == 0) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择配送方式!\"}"); return; } model.express_id = express_id; model.express_no = express_no; model.express_time = DateTime.Now; string ret = ""; if (model.payment_id == 3 && model.express_status != 2) { //通知微信支付,改变发货状态 FaHuoProc fahuo = new FaHuoProc(); BLL.wx_payment_wxpay payBll = new BLL.wx_payment_wxpay(); Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(model.wid.Value); Dictionary<string, object> fahuoDict = fahuo.fahuomgr(paymentInfo, model); string errcode = fahuoDict["errcode"].ToString(); string errmsg = fahuoDict["errmsg"].ToString(); model.fahuoCode = errcode; model.fahuoMsg = errmsg; if (errcode == "0") { model.express_status = 2; } else { ret = "通知微信支付,改变发货状态失败:"+errmsg; } } model.express_status = 2; if (!bll.Update(model)) { ret += "订单发货失败!"; context.Response.Write("{\"status\": 0, \"msg\": \"" + ret + "\"}"); return; } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Confirm.ToString(), "确认发货订单号:" + model.order_no); //记录日志 #region 发送短信或邮件 if (orderConfig.expressmsg > 0) { switch (orderConfig.expressmsg) { case 1: //短信通知 if (string.IsNullOrEmpty(model.mobile)) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}"); return; } Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.expresscallindex); //取得短信内容 if (smsModel == null) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}"); return; } //替换标签 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{username}", model.user_name); msgContent = msgContent.Replace("{orderno}", model.order_no); msgContent = msgContent.Replace("{amount}", model.order_amount.ToString()); //发送短信 string tipMsg = string.Empty; bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg); if (!sendStatus) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}"); return; } break; case 2: //邮件通知 //取得用户的邮箱地址 if (model.user_id > 0) { Model.users userModel = new BLL.users().GetModel(model.user_id); if (userModel == null || string.IsNullOrEmpty(userModel.email)) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户不存在或没有填写邮箱地址。\"}"); return; } //取得邮件模板内容 Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.expresscallindex); if (mailModel == null) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}"); return; } //替换标签 string mailTitle = mailModel.maill_title; mailTitle = mailTitle.Replace("{username}", model.user_name); string mailContent = mailModel.content; mailContent = mailContent.Replace("{webname}", siteConfig.webname); mailContent = mailContent.Replace("{weburl}", siteConfig.weburl); mailContent = mailContent.Replace("{webtel}", siteConfig.webtel); mailContent = mailContent.Replace("{username}", model.user_name); mailContent = mailContent.Replace("{orderno}", model.order_no); mailContent = mailContent.Replace("{amount}", model.order_amount.ToString()); //发送邮件 MXMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname, siteConfig.emailfrom, userModel.email, mailTitle, mailContent); } break; } } #endregion context.Response.Write("{\"status\": 1, \"msg\": \"订单发货成功!\"}"); break; case "order_complete": //完成订单========================================= //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Confirm.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有确认完成订单的权限!\"}"); return; } if (model.status > 2) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已经完成,不能重复处理!\"}"); return; } model.status = 3; model.complete_time = DateTime.Now; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"确认订单完成失败!\"}"); return; } //给会员增加积分检查升级 if (model.user_id > 0 && model.point > 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "购物获得积分,订单号:" + model.order_no, true); } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Confirm.ToString(), "确认交易完成订单号:" + model.order_no); //记录日志 #region 发送短信或邮件 if (orderConfig.completemsg > 0) { switch (orderConfig.completemsg) { case 1: //短信通知 if (string.IsNullOrEmpty(model.mobile)) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}"); return; } Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.completecallindex); //取得短信内容 if (smsModel == null) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}"); return; } //替换标签 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{username}", model.user_name); msgContent = msgContent.Replace("{orderno}", model.order_no); msgContent = msgContent.Replace("{amount}", model.order_amount.ToString()); //发送短信 string tipMsg = string.Empty; bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg); if (!sendStatus) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}"); return; } break; case 2: //邮件通知 //取得用户的邮箱地址 if (model.user_id > 0) { Model.users userModel = new BLL.users().GetModel(model.user_id); if (userModel == null || string.IsNullOrEmpty(userModel.email)) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户不存在或没有填写邮箱地址。\"}"); return; } //取得邮件模板内容 Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.completecallindex); if (mailModel == null) { context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}"); return; } //替换标签 string mailTitle = mailModel.maill_title; mailTitle = mailTitle.Replace("{username}", model.user_name); string mailContent = mailModel.content; mailContent = mailContent.Replace("{webname}", siteConfig.webname); mailContent = mailContent.Replace("{weburl}", siteConfig.weburl); mailContent = mailContent.Replace("{webtel}", siteConfig.webtel); mailContent = mailContent.Replace("{username}", model.user_name); mailContent = mailContent.Replace("{orderno}", model.order_no); mailContent = mailContent.Replace("{amount}", model.order_amount.ToString()); //发送邮件 MXMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname, siteConfig.emailfrom, userModel.email, mailTitle, mailContent); } break; } } #endregion context.Response.Write("{\"status\": 1, \"msg\": \"确认订单完成成功!\"}"); break; case "order_cancel": //取消订单========================================== //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Cancel.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有取消订单的权限!\"}"); return; } if (model.status > 2) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已经完成,不能取消订单!\"}"); return; } model.status = 4; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"取消订单失败!\"}"); return; } int check_revert1 = MXRequest.GetFormInt("check_revert"); if (check_revert1 == 1) { //如果存在积分换购则返还会员积分 if (model.user_id > 0 && model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, (model.point * -1), "取消订单返还积分,订单号:" + model.order_no, false); } //如果已支付则退还金额到会员账户 if (model.user_id > 0 && model.payment_status == 2 && model.order_amount > 0) { new BLL.user_amount_log().Add(model.user_id, model.user_name, MXEnums.AmountTypeEnum.BuyGoods.ToString(), model.order_amount, "取消订单退还金额,订单号:" + model.order_no); } } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Cancel.ToString(), "取消订单号:" + model.order_no); //记录日志 context.Response.Write("{\"status\": 1, \"msg\": \"取消订单成功!\"}"); break; case "order_invalid": //作废订单========================================== //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Invalid.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有作废订单的权限!\"}"); return; } if (model.status != 3) { context.Response.Write("{\"status\": 0, \"msg\": \"订单尚未完成,不能作废订单!\"}"); return; } model.status = 5; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"作废订单失败!\"}"); return; } int check_revert2 = MXRequest.GetFormInt("check_revert"); if (check_revert2 == 1) { //扣除购物赠送的积分 if (model.user_id > 0 && model.point > 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, (model.point * -1), "作废订单扣除积分,订单号:" + model.order_no, false); } //退还金额到会员账户 if (model.user_id > 0 && model.order_amount > 0) { new BLL.user_amount_log().Add(model.user_id, model.user_name, MXEnums.AmountTypeEnum.BuyGoods.ToString(), model.order_amount, "取消订单退还金额,订单号:" + model.order_no); } } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Invalid.ToString(), "作废订单号:" + model.order_no); //记录日志 context.Response.Write("{\"status\": 1, \"msg\": \"作废订单成功!\"}"); break; case "edit_accept_info": //修改收货信息==================================== //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Edit.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有修改收货信息的权限!\"}"); return; } if (model.express_status == 2) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已经发货,不能修改收货信息!\"}"); return; } string accept_name = MXRequest.GetFormString("accept_name"); string province = MXRequest.GetFormString("province"); string city = MXRequest.GetFormString("city"); string area = MXRequest.GetFormString("area"); string address = MXRequest.GetFormString("address"); string post_code = MXRequest.GetFormString("post_code"); string mobile = MXRequest.GetFormString("mobile"); string telphone = MXRequest.GetFormString("telphone"); if (accept_name == "") { context.Response.Write("{\"status\": 0, \"msg\": \"请填写收货人姓名!\"}"); return; } if (area == "") { context.Response.Write("{\"status\": 0, \"msg\": \"请选择所在地区!\"}"); return; } if (address == "") { context.Response.Write("{\"status\": 0, \"msg\": \"请填写详细的送货地址!\"}"); return; } if (mobile == "" && telphone == "") { context.Response.Write("{\"status\": 0, \"msg\": \"联系手机或电话至少填写一项!\"}"); return; } model.accept_name = accept_name; model.area = province + "," + city + "," + area; model.address = address; model.post_code = post_code; model.mobile = mobile; model.telphone = telphone; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"修改收货人信息失败!\"}"); return; } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改收货信息,订单号:" + model.order_no); //记录日志 context.Response.Write("{\"status\": 1, \"msg\": \"修改收货人信息成功!\"}"); break; case "edit_order_remark": //修改订单备注================================= string remark = MXRequest.GetFormString("remark"); if (remark == "") { context.Response.Write("{\"status\": 0, \"msg\": \"请填写订单备注内容!\"}"); return; } model.remark = remark; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"修改订单备注失败!\"}"); return; } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改订单备注,订单号:" + model.order_no); //记录日志 context.Response.Write("{\"status\": 1, \"msg\": \"修改订单备注成功!\"}"); break; case "edit_real_amount": //修改商品总金额================================ //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Edit.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有修改商品金额的权限!\"}"); return; } if (model.status > 1) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已经确认,不能修改金额!\"}"); return; } decimal real_amount = MXRequest.GetFormDecimal("real_amount", 0); model.real_amount = real_amount; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"修改商品总金额失败!\"}"); return; } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改商品金额,订单号:" + model.order_no); //记录日志 context.Response.Write("{\"status\": 1, \"msg\": \"修改商品总金额成功!\"}"); break; case "edit_express_fee": //修改配送费用================================== //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Edit.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有配送费用的权限!\"}"); return; } if (model.status > 1) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已经确认,不能修改金额!\"}"); return; } decimal express_fee = MXRequest.GetFormDecimal("express_fee", 0); model.express_fee = express_fee; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"修改配送费用失败!\"}"); return; } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改配送费用,订单号:" + model.order_no); //记录日志 context.Response.Write("{\"status\": 1, \"msg\": \"修改配送费用成功!\"}"); break; case "edit_payment_fee": //修改支付手续费================================= //检查权限 if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Edit.ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"您没有修改支付手续费的权限!\"}"); return; } if (model.status > 1) { context.Response.Write("{\"status\": 0, \"msg\": \"订单已经确认,不能修改金额!\"}"); return; } decimal payment_fee = MXRequest.GetFormDecimal("payment_fee", 0); model.payment_fee = payment_fee; if (!bll.Update(model)) { context.Response.Write("{\"status\": 0, \"msg\": \"修改支付手续费失败!\"}"); return; } new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改支付手续费,订单号:" + model.order_no); //记录日志 context.Response.Write("{\"status\": 1, \"msg\": \"修改支付手续费成功!\"}"); break; } }
private void sms_message_post(HttpContext context) { //检查管理员是否登录 if (!new ManagePage().IsAdminLogin()) { context.Response.Write("{\"status\": 0, \"msg\": \"尚未登录或已超时,请登录后操作!\"}"); return; } string mobiles = MXRequest.GetFormString("mobiles"); string content = MXRequest.GetFormString("content"); if (mobiles == "") { context.Response.Write("{\"status\": 0, \"msg\": \"手机号码不能为空!\"}"); return; } if (content == "") { context.Response.Write("{\"status\": 0, \"msg\": \"短信内容不能为空!\"}"); return; } //开始发送 string msg = string.Empty; bool result = new BLL.sms_message().Send(mobiles, content, 2, out msg); if (result) { context.Response.Write("{\"status\": 1, \"msg\": \"" + msg + "\"}"); return; } context.Response.Write("{\"status\": 0, \"msg\": \"" + msg + "\"}"); return; }
private string send_verify_sms_code(HttpContext context,string mobile) { //检查手机 if (string.IsNullOrEmpty(mobile)) { return "{\"status\":0, \"msg\":\"发送失败,请填写手机号码!\"}"; } //检查是否过期 string cookie = Utils.GetCookie(DTKeys.COOKIE_USER_MOBILE); if (cookie == mobile) { return "{\"status\":1, \"time\":\"" + userConfig.regsmsexpired + "\", \"msg\":\"已发送短信," + userConfig.regsmsexpired + "分钟后再试!\"}"; } Model.sms_template smsModel = new BLL.sms_template().GetModel("usercode"); //取得短信内容 if (smsModel == null) { return "{\"status\":0, \"msg\":\"发送失败,短信模板不存在,请联系管理员!\"}"; } string strcode = Utils.Number(4); //随机验证码 //替换标签 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{weburl}", siteConfig.weburl); msgContent = msgContent.Replace("{webtel}", siteConfig.webtel); msgContent = msgContent.Replace("{code}", strcode); msgContent = msgContent.Replace("{valid}", userConfig.regsmsexpired.ToString()); //发送短信 string tipMsg = string.Empty; bool result = new BLL.sms_message().Send(mobile, msgContent, 1, out tipMsg); if (!result) { return "{\"status\":0, \"msg\":\"发送失败," + tipMsg + "\"}"; } //写入SESSION,保存验证码 context.Session[DTKeys.SESSION_SMS_CODE] = strcode; Utils.WriteCookie(DTKeys.COOKIE_USER_MOBILE, mobile, userConfig.regsmsexpired); //规定时间内无重复发送 return "success"; }
private void user_getpassword(HttpContext context) { string site = DTRequest.GetQueryString("site"); string code = DTRequest.GetFormString("txtCode"); string type = DTRequest.GetFormString("txtType"); string username = DTRequest.GetFormString("txtUserName").Trim(); //检查站点目录 if (string.IsNullOrEmpty(site)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,网站传输参数有误!\"}"); return; } //检查用户名 if (string.IsNullOrEmpty(username)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户名不可为空!\"}"); return; } //检查取回密码类型 if (string.IsNullOrEmpty(type)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择取回密码类型!\"}"); return; } //校检验证码 string result = verify_code(context, code); if (result != "success") { context.Response.Write(result); return; } //检查用户信息 BLL.users bll = new BLL.users(); Model.users model = bll.GetModel(username); if (model == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,您输入的用户名不存在!\"}"); return; } //发送取回密码的短信或邮件 if (type.ToLower() == "mobile") //使用手机取回密码 { #region 发送短信================== if (string.IsNullOrEmpty(model.mobile)) { context.Response.Write("{\"status\":0, \"msg\":\"您尚未绑定手机号码,无法取回密码!\"}"); return; } Model.sms_template smsModel = new BLL.sms_template().GetModel("usercode"); //取得短信内容 if (smsModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"发送失败,短信模板不存在,请联系管理员!\"}"); } string strcode = Utils.Number(4); //随机验证码 //检查是否重复提交 BLL.user_code codeBll = new BLL.user_code(); Model.user_code codeModel; codeModel = codeBll.GetModel(username, DTEnums.CodeEnum.RegVerify.ToString(), "d"); if (codeModel == null) { codeModel = new Model.user_code(); //写入数据库 codeModel.user_id = model.id; codeModel.user_name = model.user_name; codeModel.type = DTEnums.CodeEnum.Password.ToString(); codeModel.str_code = strcode; codeModel.eff_time = DateTime.Now.AddMinutes(userConfig.regsmsexpired); codeModel.add_time = DateTime.Now; codeBll.Add(codeModel); } //替换标签 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{weburl}", siteConfig.weburl); msgContent = msgContent.Replace("{webtel}", siteConfig.webtel); msgContent = msgContent.Replace("{code}", codeModel.str_code); msgContent = msgContent.Replace("{valid}", userConfig.regsmsexpired.ToString()); //发送短信 string tipMsg = string.Empty; bool result1 = new BLL.sms_message().Send(model.mobile, msgContent, 1, out tipMsg); if (!result1) { context.Response.Write("{\"status\":0, \"msg\":\"发送失败," + tipMsg + "\"}"); return; } context.Response.Write("{\"status\":1, \"msg\":\"手机验证码发送成功!\", \"url\":\"" + new BasePage().getlink(site, new BasePage().linkurl("repassword", "?action=mobile&username="******"\"}"); return; #endregion } else if (type.ToLower() == "email") //使用邮箱取回密码 { #region 发送邮件================== if (string.IsNullOrEmpty(model.email)) { context.Response.Write("{\"status\":0, \"msg\":\"您尚未绑定邮箱,无法取回密码!\"}"); return; } //生成随机码 string strcode = Utils.GetCheckCode(20); //获得邮件内容 Model.mail_template mailModel = new BLL.mail_template().GetModel("getpassword"); if (mailModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"邮件发送失败,邮件模板内容不存在!\"}"); return; } //检查是否重复提交 BLL.user_code codeBll = new BLL.user_code(); Model.user_code codeModel; codeModel = codeBll.GetModel(username, DTEnums.CodeEnum.RegVerify.ToString(), "d"); if (codeModel == null) { codeModel = new Model.user_code(); //写入数据库 codeModel.user_id = model.id; codeModel.user_name = model.user_name; codeModel.type = DTEnums.CodeEnum.Password.ToString(); codeModel.str_code = strcode; codeModel.eff_time = DateTime.Now.AddDays(userConfig.regemailexpired); codeModel.add_time = DateTime.Now; codeBll.Add(codeModel); } //替换模板内容 string titletxt = mailModel.maill_title; string bodytxt = mailModel.content; titletxt = titletxt.Replace("{webname}", siteConfig.webname); titletxt = titletxt.Replace("{username}", model.user_name); bodytxt = bodytxt.Replace("{webname}", siteConfig.webname); bodytxt = bodytxt.Replace("{weburl}", siteConfig.weburl); bodytxt = bodytxt.Replace("{webtel}", siteConfig.webtel); bodytxt = bodytxt.Replace("{valid}", userConfig.regemailexpired.ToString()); bodytxt = bodytxt.Replace("{username}", model.user_name); bodytxt = bodytxt.Replace("{linkurl}", "http://" + HttpContext.Current.Request.Url.Authority.ToLower() + new BasePage().getlink(site, new BasePage().linkurl("repassword", "?action=email&code=" + codeModel.str_code))); //发送邮件 try { DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailusername, DESEncrypt.Decrypt(siteConfig.emailpassword), siteConfig.emailnickname, siteConfig.emailfrom, model.email, titletxt, bodytxt); } catch { context.Response.Write("{\"status\":0, \"msg\":\"邮件发送失败,请联系本站管理员!\"}"); return; } context.Response.Write("{\"status\":1, \"msg\":\"邮件发送成功,请登录邮箱查看邮件!\"}"); return; #endregion } context.Response.Write("{\"status\":0, \"msg\":\"发生未知错误,请检查参数是否正确!\"}"); return; }
private string GetSmsCount() { string code = string.Empty; int count = new BLL.sms_message().GetAccountQuantity(out code); if (code == "115") { return "查询出错:请完善账户信息"; } else if (code != "100") { return "错误代码:" + code; } return count + " 条"; }
private void sms_message_post(HttpContext context) { string mobiles = DTRequest.GetFormString("mobiles"); string content = DTRequest.GetFormString("content"); if (mobiles == "") { context.Response.Write("{\"status\": 0, \"msg\": \"手机号码不能为空!\"}"); return; } if (content == "") { context.Response.Write("{\"status\": 0, \"msg\": \"短信内容不能为空!\"}"); return; } //开始发送 string msg = string.Empty; bool result = new BLL.sms_message().Send(mobiles, content, 2, out msg); if (result) { context.Response.Write("{\"status\": 1, \"msg\": \"" + msg + "\"}"); return; } context.Response.Write("{\"status\": 0, \"msg\": \"" + msg + "\"}"); return; }
private string verify_mobile(Model.users userModel) { //生成随机码 string strcode = Utils.Number(4); BLL.user_code codeBll = new BLL.user_code(); Model.user_code codeModel; //检查是否重复提交 codeModel = codeBll.GetModel(userModel.user_name, DTEnums.CodeEnum.RegVerify.ToString(), "n"); if (codeModel == null) { codeModel = new Model.user_code(); codeModel.user_id = userModel.id; codeModel.user_name = userModel.user_name; codeModel.type = DTEnums.CodeEnum.RegVerify.ToString(); codeModel.str_code = strcode; codeModel.eff_time = DateTime.Now.AddMinutes(userConfig.regsmsexpired); codeModel.add_time = DateTime.Now; new BLL.user_code().Add(codeModel); } //获得短信模板内容 Model.sms_template smsModel = new BLL.sms_template().GetModel("usercode"); if (smsModel == null) { return "{\"status\":0, \"msg\":\"发送失败,短信模板内容不存在!\"}"; } //替换模板内容 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{webtel}", siteConfig.webtel); msgContent = msgContent.Replace("{weburl}", siteConfig.weburl); msgContent = msgContent.Replace("{username}", userModel.user_name); msgContent = msgContent.Replace("{code}", codeModel.str_code); msgContent = msgContent.Replace("{valid}", userConfig.regsmsexpired.ToString()); //发送短信 string tipMsg = string.Empty; bool sendStatus = new BLL.sms_message().Send(userModel.mobile, msgContent, 2, out tipMsg); if (!sendStatus) { return "{\"status\": 0, \"msg\": \"短信发送失败," + tipMsg + "\"}"; } return "success"; }
private void user_register_smscode(HttpContext context) { string mobile = DTRequest.GetFormString("mobile"); if (mobile == "") { context.Response.Write("{\"status\":0, \"msg\":\"发送失败,请填写手机号码!\"}"); return; } //检查是否过快 string cookie = Utils.GetCookie("user_register_sms"); if (cookie == mobile) { context.Response.Write("{\"status\":0, \"msg\":\"刚已发送过短信,请2分钟后再试!\"}"); return; } Model.sms_template smsModel = new BLL.sms_template().GetModel("usercode"); //取得短信内容 if (smsModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"发送失败,短信模板不存在!\"}"); return; } string strcode = Utils.Number(4); //随机验证码 //替换标签 string msgContent = smsModel.content; msgContent = msgContent.Replace("{webname}", siteConfig.webname); msgContent = msgContent.Replace("{weburl}", siteConfig.weburl); msgContent = msgContent.Replace("{webtel}", siteConfig.webtel); msgContent = msgContent.Replace("{code}", strcode); msgContent = msgContent.Replace("{valid}", "二十"); //发送短信 string tipMsg = string.Empty; bool result = new BLL.sms_message().Send(mobile, msgContent, 1, out tipMsg); if (!result) { context.Response.Write("{\"status\":0, \"msg\":\"发送失败," + tipMsg + "\"}"); return; } //写入SESSION,保存验证码 context.Session[DTKeys.SESSION_SMS_CODE] = strcode; Utils.WriteCookie("user_register_sms", mobile, 2); //2分钟内无重复发送 context.Response.Write("{\"status\":1, \"msg\":\"短信发送成功,请注意查收验证码!\"}"); return; }
//提交发送 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("issue_coupon", Vincent._DTcms.DTEnums.ActionEnum.Add.ToString()); //检查权限 //优惠券类型 if (ddlGroupId.SelectedValue == "") { JscriptMsg("请选择优惠券类型!", "", "Error"); return; } //检查短信内容 if (txtSmsContent.Text.Trim() == "") { JscriptMsg("请输入短信内容!", "", "Error"); return; } //检查发送类型 if (rblSmsType.SelectedValue == "1") { if (txtMobileNumbers.Text.Trim() == "") { JscriptMsg("请输入手机号码!", "", "Error"); return; } string[] oldMobileArr = txtMobileNumbers.Text.Trim().Split(',');//将手机号存入数组 DataTable dt = new BLL.user_coupon().GetList(0, " title='" + ddlGroupId.SelectedValue + "' and status!=2 and status!=4", " id").Tables[0]; if (dt.Rows.Count < 0) { JscriptMsg("没有可发放的优惠券!", "", "Error"); return; } if (oldMobileArr.Length > dt.Rows.Count) { JscriptMsg("该类型优惠券数量不够!", "", "Error"); return; } for (int i = 0; i < oldMobileArr.Length; i++) { Model.users model = new BLL.users().GetModelMobile(oldMobileArr[i]); if (model != null) { Model.user_coupon couponm = new BLL.user_coupon().GetModel(int.Parse(dt.Rows[i]["id"].ToString())); couponm.userid = model.id; couponm.status = 4; new BLL.user_coupon().Update(couponm); } } //开始发送短信 string msg = string.Empty; bool result = new BLL.sms_message().Send(txtMobileNumbers.Text.Trim(), txtSmsContent.Text.Trim(), 2, out msg); if (result) { AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "发送手机短信"); //记录日志 JscriptMsg(msg, "../coupon/coupon_list.aspx", "Success"); return; } JscriptMsg(msg, "", "Error"); return; } else { ArrayList al = new ArrayList(); for (int i = 0; i < cblGroupId.Items.Count; i++) { if (cblGroupId.Items[i].Selected) { al.Add(cblGroupId.Items[i].Value); } } if (al.Count < 1) { JscriptMsg("请选择会员组别!", "", "Error"); return; } string _mobiles = GetGroupMobile(al); string[] oldMobileArr = _mobiles.Split(',');//将手机号存入数组 DataTable dt = new BLL.user_coupon().GetList(0, " title='" + ddlGroupId.SelectedValue + "' and status!=2 and status!=4", " id").Tables[0]; if (dt.Rows.Count < 0) { JscriptMsg("没有可发放的优惠券!", "", "Error"); return; } if (oldMobileArr.Length > dt.Rows.Count) { JscriptMsg("该类型优惠券数量不够!", "", "Error"); return; } for (int i = 0; i < oldMobileArr.Length; i++) { Model.users model = new BLL.users().GetModelMobile(oldMobileArr[i]); if (model != null) { Model.user_coupon couponm = new BLL.user_coupon().GetModel(int.Parse(dt.Rows[i]["id"].ToString())); couponm.userid = model.id; couponm.status = 4; new BLL.user_coupon().Update(couponm); } } //开始发送短信 string msg = string.Empty; bool result = new BLL.sms_message().Send(_mobiles, txtSmsContent.Text.Trim(), 2, out msg); if (result) { AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "发送手机短信"); //记录日志 JscriptMsg(msg, "issue_coupon.aspx", "Success"); return; } JscriptMsg(msg, "", "Error"); return; } }