//确认设计 protected void btnOK_Click(object sender, EventArgs e) { string orderNO = hiddNO.Value; if (orderNO == "") { JscriptMsg("传输参数不正确!", "back", "Error"); return; } if (!new BLL.orders().Exists(orderNO)) { JscriptMsg("订单不存在或已被删除!", "back", "Error"); return; } model = bll.GetModel(orderNO); model.status = 3; model.confirm_time = DateTime.Now; if (bll.Update(model)) { JscriptMsg("DIY设计确认成功!", "back", "success"); } else { JscriptMsg("DIY设计确认失败!", "back", "Error"); } //if (bll.Update(model)) //{ // Response.Write("{\"status\":\"1\",\"msg\":\"DIY设计确认成功!\"}"); //} //else //{ // Response.Write("{\"status\":\"0\",\"msg\":\"DIY设计确认失败!\"}"); //} }
//將excel的資料寫入資料庫 private string InsertGoods(DataTable dt) { string result = ""; BLL.orders bll = new BLL.orders(); Model.orders model = null; //判斷列名是否規範 string[] strColumn = { "訂單號", "發票號" }; int num = 0; for (int i = 0; i < dt.Columns.Count; i++) { foreach (string str in strColumn) { if (str == dt.Columns[i].ColumnName) { num++; } } } if (num == strColumn.Length) { //遍歷主件 foreach (DataRow dr in dt.Rows) { if (dr[0].ToString().Trim() != "" && dr[1].ToString().Trim() != "") { bool update = true; try { model = bll.GetModel(dr[0].ToString()); } catch (Exception eee) { } if (model != null) { model.trade_no = dr[1].ToString(); if (update) { bll.Update(model); } } } } } else { result = "請檢查excel檔案格式!" + num + strColumn.Length; } return(result); }
//确认生产 protected void btnConfirm_Click(object sender, EventArgs e) { ChkAdminLevel("order_list", Vincent._DTcms.DTEnums.ActionEnum.Confirm.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.orders bll = new BLL.orders(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { Model.orders model = bll.GetModel(id); if (model != null) { //检查订单是否使用在线支付方式 //if (model.payment_status > 0) //{ //在线支付方式 //model.payment_status = 2; //标志已付款 //model.payment_time = DateTime.Now; //支付时间 //model.status = 3; // 订单为确认状态 //model.confirm_time = DateTime.Now; //确认时间 //} //else //{ //线下支付方式 // model.status = 3; // 订单为确认状态 // model.confirm_time = DateTime.Now; //确认时间 //} model.status = 4; // 已确认生产 model.winery_time = DateTime.Now; if (bll.Update(model)) { sucCount++; } else { errorCount++; } } else { errorCount++; } } } AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Confirm.ToString(), "确认订单成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("确认成功" + sucCount + "条,失败" + errorCount + "条!", Vincent._DTcms.Utils.CombUrlTxt("order_confirm.aspx", "keywords={0}", this.keywords), "Success"); }
//确认订单 protected void btnConfirm_Click(object sender, EventArgs e) { ChkAdminLevel("order_list", DTEnums.ActionEnum.Confirm.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.orders bll = new BLL.orders(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { Model.orders model = bll.GetModel(id); if (model != null) { //检查订单是否使用在线支付方式 if (model.payment_status > 0) { //在线支付方式 model.payment_status = 2; //标志已付款 model.payment_time = DateTime.Now; //支付时间 model.status = 2; // 订单为确认状态 model.confirm_time = DateTime.Now; //确认时间 } else { //线下支付方式 model.status = 2; // 订单为确认状态 model.confirm_time = DateTime.Now; //确认时间 } if (bll.Update(model)) { sucCount++; } else { errorCount++; } } else { errorCount++; } } } AddAdminLog(DTEnums.ActionEnum.Confirm.ToString(), "确认订单成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("确认成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("order_confirm.aspx", "keywords={0}", this.keywords), "Success"); }
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; } }
/// <summary> /// 【微支付】 订单付款成功,处理订单:1将订单的状态改成付款完成; /// 李朴 add /// </summary> /// <param name="beforeFunName"></param> /// <param name="out_trade_no">商户订单号</param> /// <param name="transaction_id">订单交易号</param> /// <param name="result_code">支付结果</param> /// <param name="total_fee">付款金额(单位为分)</param> /// <param name="otid">订单临时表id</param> /// <returns>有错误则返回错误信息,正确,则返回空字符串</returns> public string ProcessPaySuccess_wx(string beforeFunName, string out_trade_no, string transaction_id, string result_code, int total_fee, int otid, int wid) { string payTmpType = "【微支付】"; decimal total_fee_d = (decimal)total_fee / 100; BLL.orders orderBll = new BLL.orders(); string funName = payTmpType + beforeFunName + " ProcessPaySuccess_wx "; WXLogs.AddLog(wid, "微支付", funName, "开始执行ProcessPaySuccess_wx方法[otid:" + otid + "]"); try { #region 数据同步前 IList <Model.orders> orderlist = orderBll.GetModelList("id=" + otid + " and order_no='" + out_trade_no + "'"); if (orderlist == null || orderlist.Count <= 0) { WXLogs.AddLog(wid, payTmpType, funName, "订单号【" + out_trade_no + "】订单号不存在", 0); return("订单号不存在"); } //这个暂时不处理 if (WXLogs.ExistsFlg((out_trade_no + otid))) { //如果已经处理过,则不再处理 return(""); } WXLogs.AddFlg(wid, payTmpType, funName, (out_trade_no + otid));//加标志,防止重复提交 Model.orders orderEntity = orderlist[0]; if (orderEntity.order_amount > total_fee_d) { return("付款的金额(" + total_fee_d + ")小于订单的预付款金额(" + orderEntity.order_amount + ")信息,直接退款"); } orderEntity.notify_id = ""; orderEntity.trade_no = transaction_id; orderEntity.pay_info = result_code; orderEntity.order_amount = total_fee_d; orderEntity.payment_time = DateTime.Now; orderEntity.status = 2; orderEntity.payment_status = 2; //判断是否需要立即发货 if (orderEntity.express_status == 0) { //立即发货 orderEntity.express_status = 2; orderEntity.express_time = DateTime.Now; //FaHuoProc fahuo = new FaHuoProc(); //BLL.wx_payment_wxpay payBll = new BLL.wx_payment_wxpay(); //Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(wid); //Dictionary<string, object> fahuoDict = fahuo.fahuomgr(paymentInfo, orderEntity); //string errcode = fahuoDict["errcode"].ToString(); //string errmsg = fahuoDict["errmsg"].ToString(); //orderEntity.fahuoCode = errcode; //orderEntity.fahuoMsg = errmsg; //if (errcode == "0") //{ // orderEntity.express_status = 2; // orderEntity.express_time = DateTime.Now; //} //else //{ // orderEntity.express_status =1; //} } bool ret = orderBll.Update(orderEntity); //把订单里的商品库存减少 #region 减少库存 BLL.wx_shop_product spBll = new BLL.wx_shop_product(); BLL.orders oBll = new BLL.orders(); //根据订单号得到订单 Model.orders oModel = oBll.GetModelByNo(orderEntity.order_no); //得到所有订购商品 List <Model.order_goods> ogList = oModel.order_goods; //根据订购商品的数量修改库存 foreach (Model.order_goods item in ogList) { Model.wx_shop_product spModel = spBll.GetModel(item.goods_id); spModel.stock = spModel.stock - item.quantity; spBll.Update(spModel); } #endregion if (!ret) { WXLogs.AddLog(wid, payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后处理数据失败", 0); return("订单号【" + out_trade_no + "】支付成功后处理数据失败"); } WXLogs.AddLog(payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后,处理数据成功", 1); return(""); #endregion } catch (Exception ex) { WXLogs.AddLog(wid, payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后处理数据同步出现错误:" + ex.Message, 0); return(null); } }
/// <summary> /// 【微支付】 订单付款成功,处理订单:1将订单的状态改成付款完成; /// /// </summary> /// <param name="beforeFunName"></param> /// <param name="notify_id">通知id</param> /// <param name="out_trade_no">商户订单号</param> /// <param name="transaction_id">订单交易号</param> /// <param name="pay_info">支付结果</param> /// <param name="total_fee">付款金额(单位为分)</param> /// <param name="otid">订单临时表id</param> /// <returns>有错误则返回错误信息,正确,则返回空字符串</returns> public string ProcessPaySuccess_wx(string beforeFunName, string notify_id, string out_trade_no, string transaction_id, string pay_info, int total_fee, int otid, int wid) { string payTmpType = "【微支付】"; total_fee = total_fee / 100; BLL.orders orderBll = new BLL.orders(); string funName = payTmpType + beforeFunName + " ProcessPaySuccess_wx "; BLL.wx_logs logBll = new BLL.wx_logs(); logBll.AddLog(wid, "微支付", funName, "开始执行ProcessPaySuccess_wx方法[otid:" + otid + "]"); try { #region 数据同步前 IList <Model.orders> orderlist = orderBll.GetModelList("id=" + otid + " and order_no='" + out_trade_no + "'"); if (orderlist == null || orderlist.Count <= 0) { logBll.AddLog(wid, payTmpType, funName, "订单号【" + out_trade_no + "】订单号不存在", 0); return("订单号不存在"); } //这个暂时不处理 if (logBll.ExistsFlg((out_trade_no + otid))) { //如果已经处理过,则不再处理 return(""); } logBll.AddFlg(wid, payTmpType, funName, (out_trade_no + otid));//加标志,防止重复提交 Model.orders orderEntity = orderlist[0]; if (orderEntity.order_amount > total_fee) { return("付款的金额(" + total_fee + ")小于订单的预付款金额(" + orderEntity.order_amount + ")信息,直接退款"); } orderEntity.notify_id = notify_id; orderEntity.trade_no = transaction_id; orderEntity.pay_info = pay_info; orderEntity.order_amount = total_fee; orderEntity.payment_time = DateTime.Now; orderEntity.status = 2; orderEntity.payment_status = 2; //判断是否需要立即发货 if (orderEntity.express_status == 0) { //立即发货 FaHuoProc fahuo = new FaHuoProc(); BLL.wx_payment_wxpay payBll = new BLL.wx_payment_wxpay(); Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(wid); Dictionary <string, object> fahuoDict = fahuo.fahuomgr(paymentInfo, orderEntity); string errcode = fahuoDict["errcode"].ToString(); string errmsg = fahuoDict["errmsg"].ToString(); orderEntity.fahuoCode = errcode; orderEntity.fahuoMsg = errmsg; if (errcode == "0") { orderEntity.express_status = 2; orderEntity.express_time = DateTime.Now; } else { orderEntity.express_status = 1; } } bool ret = orderBll.Update(orderEntity); if (!ret) { logBll.AddLog(wid, payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后处理数据失败", 0); return("订单号【" + out_trade_no + "】支付成功后处理数据失败"); } logBll.AddLog(payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后,处理数据成功", 1); return(""); #endregion } catch (Exception ex) { logBll.AddLog(wid, payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后处理数据同步出现错误:" + ex.Message, 0); return(null); } }
/// <summary> /// 【微支付】 订单付款成功,处理订单:1将订单的状态改成付款完成; /// /// </summary> /// <param name="beforeFunName"></param> /// <param name="notify_id">通知id</param> /// <param name="out_trade_no">商户订单号</param> /// <param name="transaction_id">订单交易号</param> /// <param name="pay_info">支付结果</param> /// <param name="total_fee">付款金额(单位为分)</param> /// <param name="otid">订单临时表id</param> /// <returns>有错误则返回错误信息,正确,则返回空字符串</returns> public string ProcessPaySuccess_wx(string beforeFunName, string notify_id, string out_trade_no, string transaction_id, string pay_info, int total_fee, int otid, int wid) { string payTmpType = "【微支付】"; total_fee = total_fee / 100; BLL.orders orderBll = new BLL.orders(); string funName = payTmpType + beforeFunName + " ProcessPaySuccess_wx "; BLL.wx_logs logBll = new BLL.wx_logs(); logBll.AddLog(wid, "微支付", funName, "开始执行ProcessPaySuccess_wx方法[otid:" + otid + "]"); try { #region 数据同步前 IList<Model.orders> orderlist = orderBll.GetModelList("id=" + otid + " and order_no='" + out_trade_no + "'"); if (orderlist == null || orderlist.Count <= 0) { logBll.AddLog(wid,payTmpType, funName, "订单号【" + out_trade_no + "】订单号不存在", 0); return "订单号不存在"; } //这个暂时不处理 if (logBll.ExistsFlg((out_trade_no + otid))) { //如果已经处理过,则不再处理 return ""; } logBll.AddFlg(wid,payTmpType, funName, (out_trade_no + otid));//加标志,防止重复提交 Model.orders orderEntity = orderlist[0]; if (orderEntity.order_amount > total_fee) { return "付款的金额(" + total_fee + ")小于订单的预付款金额(" + orderEntity.order_amount + ")信息,直接退款"; } orderEntity.notify_id = notify_id; orderEntity.trade_no = transaction_id; orderEntity.pay_info = pay_info; orderEntity.order_amount = total_fee; orderEntity.payment_time = DateTime.Now; orderEntity.status = 2; orderEntity.payment_status = 2; //判断是否需要立即发货 if (orderEntity.express_status == 0) { //立即发货 FaHuoProc fahuo = new FaHuoProc(); BLL.wx_payment_wxpay payBll = new BLL.wx_payment_wxpay(); Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(wid); Dictionary<string, object> fahuoDict = fahuo.fahuomgr(paymentInfo, orderEntity); string errcode = fahuoDict["errcode"].ToString(); string errmsg = fahuoDict["errmsg"].ToString(); orderEntity.fahuoCode = errcode; orderEntity.fahuoMsg = errmsg; if (errcode == "0") { orderEntity.express_status = 2; orderEntity.express_time = DateTime.Now; } else { orderEntity.express_status =1; } } bool ret = orderBll.Update(orderEntity); if (!ret) { logBll.AddLog(wid,payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后处理数据失败", 0); return "订单号【" + out_trade_no + "】支付成功后处理数据失败"; } logBll.AddLog(payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后,处理数据成功", 1); return ""; #endregion } catch (Exception ex) { logBll.AddLog(wid,payTmpType, funName, "订单号【" + out_trade_no + "】支付成功后处理数据同步出现错误:" + ex.Message, 0); return null; } }
private void order_pay(HttpContext context) { Model.users model = new BasePage().GetUserInfo(); if (model == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,请重新登录!\"}"); return; } string pay_type = DTRequest.GetQueryString("pay_type");//支付类型 int pay_ment = DTRequest.GetQueryInt("pay_ment");//支付方式 int order_id = DTRequest.GetQueryInt("order_id"); BLL.orders bll = new BLL.orders(); Model.orders model_order = bll.GetModel(order_id); if (model_order == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"订单不存在!\"}"); return; } switch (pay_type) { case "month": model_order.is_up = 3; break; case "is_up": model_order.is_up = 2; break; case "payno": model_order.is_up = 1; break; } //直接支付 BLL.payment bll_pay = new BLL.payment(); Model.payment model_pay = new Model.payment(); string url = ""; if (pay_type == "payno") { model_pay = bll_pay.GetModel(pay_ment); if (model_pay == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"支付方式不存在或已删除!\"}"); return; } model_order.payment_id = model_pay.id; if (model_pay.type == 1) { //用户余额 if (model_pay.api_path == "balance") { if (model.amount < model_order.order_amount) { context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,您的用户余额不足请充值!\"}"); return; } decimal user_amount = model.amount - model_order.order_amount; if (new BLL.users().UpdateField(model.id, "amount=" + user_amount) <= 0) { context.Response.Write("{\"status\":\"0\", \"msg\":\"扣除余额失败,支付失败!\"}"); return; } model_order.status = 2; model_order.payment_status = 2; } else { url = siteConfig.webpath + "api/payment/" + model_pay.api_path + "/index.aspx?action=pay&pay_user_name=" + model.nick_name.Trim() + "&pay_order_type=" + DTEnums.AmountTypeEnum.BuyGoods.ToString() + "&pay_order_no=" + model_order.order_no + "&pay_order_amount=" + model_order.order_amount + "&pay_subject=商品订单"; } } else { //货到付款 } } if (!bll.Update(model_order)) { context.Response.Write("{\"status\":\"0\", \"msg\":\"支付方式保存失败!\"}"); return; } else { context.Response.Write("{\"status\":\"1\", \"msg\":\"支付成功!\",\"url\":\"" + url + "\"}"); return; } }