/// <summary> /// APP充值 /// </summary> /// <param name="orderId"></param> /// <returns></returns> public ActionResult BalancePayment(decimal orderId) { try { OnlineOrder order = CheckOrder(orderId); if (order.OrderType != OnlineOrderType.APPRecharge) { throw new MyException("支付方法不正确"); } UnifiedPayModel model = GetUnifiedPayModel(order, string.Format("{0}-APP充值", order.PlateNo)); WeiXinPaySignModel payModel = GetWeiXinPaySign(order, model); ViewBag.PayModel = payModel; return(View(order)); } catch (MyException ex) { TxtLogServices.WriteTxtLogEx("WeiXinPayment_Error", "支付失败 orderId:{0};openId:{1}", orderId, WeiXinOpenId, ex, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = "/PurseData/Index" })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPayment_Error", string.Format("APP充值支付失败 orderId:{0};openId:{1}", orderId, WeiXinOpenId), ex, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付失败,请重新支付", returnUrl = "/PurseData/Index" })); } }
public ActionResult Index(string companyId) { try { if (string.IsNullOrWhiteSpace(companyId)) { return(RedirectToAction("Index", "BrowseError", new { errorMsg = "请打开扫一扫" })); } WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(companyId); var timeStamp = DateTimeHelper.TransferUnixDateTime(DateTime.Now).ToString(); var nonceStr = StringHelper.GetRndString(16); var url = Request.Url.ToString(); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret, false); var ticket = WxAdvApi.GetTicket(accessToken); string signature = WxService.GetJsApiSignature(nonceStr, ticket.ticket, timeStamp, url); ViewBag.Signature = signature; ViewBag.AppId = config.AppId; ViewBag.Timestamp = timeStamp; ViewBag.NonceStr = nonceStr; return(View()); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "调用扫码方法异常", ex, LogFrom.WeiXin); return(RedirectToAction("Index", "BrowseError", new { errorMsg = "调用扫码方法异常" })); } }
/// <summary> /// 临停缴费 /// </summary> /// <param name="orderId"></param> /// <returns></returns> public ActionResult ParkCarPayment(decimal orderId, int source = 0) { string returnUrl = source == 0 ? "/ParkingPayment/Index" : "/QRCodeParkPayment/QRCodePaySuccess?orderId=" + orderId; try { OnlineOrder order = CheckOrder(orderId); if (order.OrderType != OnlineOrderType.ParkFee) { throw new MyException("支付方法不正确"); } if (!OnlineOrderServices.UpdateSFMCode(order)) { throw new MyException("处理订单信息异常【SFM】"); } string sAttach = Convert.ToString(Session["SmartSystem_WeiXinTg_personid"]); UnifiedPayModel model = GetUnifiedPayModel(order, string.Format("临停缴费-{0}", order.PlateNo), sAttach); WeiXinPaySignModel payModel = GetWeiXinPaySign(order, model); ViewBag.MaxWaitTime = DateTime.Now.AddMinutes(WXOtherConfigServices.GetTempParkingWeiXinPayTimeOut(order.CompanyID)).ToString("yyyy-MM-dd HH:mm:ss"); ViewBag.PayModel = payModel; ViewBag.ReturnUrl = returnUrl; ViewBag.Source = source; Session["SmartSystem_WeiXinTg_personid"] = null; return(View(order)); } catch (MyException ex) { return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = returnUrl })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPayment_Error", string.Format("支付失败 orderId:{0};openId:{1}", orderId, WeiXinOpenId), ex, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付失败,请重新支付", returnUrl = returnUrl })); } }
/// <summary> /// 发送商家充值成功通知 /// </summary> /// <param name="companyId">单位编号</param> /// <param name="money">充值金额(元)</param> /// <param name="balance">账号预额(元)</param> /// <param name="realPayTime">支付时间</param> /// <param name="openId">接受消息的openid</param> public static bool SendSellerRechargeSuccess(string companyId, decimal money, decimal balance, DateTime realPayTime, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.SellerRechargeTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string topColor = "#FF0000"; string payTimeDes = string.Format("{0}月{1}日 {2}时{3}分", realPayTime.Month.ToString().PadLeft(2, '0'), realPayTime.Day.ToString().PadLeft(2, '0'), realPayTime.Hour.ToString().PadLeft(2, '0'), realPayTime.Minute.ToString().PadLeft(2, '0')); WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = "您好,您已充值成功!", color = "#173177" }, keyword1 = new { value = payTimeDes, color = "#173177" }, keyword2 = new { value = money, color = "#173177" }, keyword3 = new { value = balance, color = "#173177" }, remark = new { value = "您的充值已成功,可在充值记录查看明细", color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送停车场缴费成功通知失败", ex, LogFrom.WeiXin); return(false); } }
public ActionResult ComputeParkingFee(string licensePlate, string parkingId) { licensePlate = licensePlate.ToPlateNo(); if (!string.IsNullOrWhiteSpace(licensePlate) && licensePlate.Length > 2) { string firstPlate = HttpUtility.UrlEncode(licensePlate.Substring(0, 2), Encoding.GetEncoding("UTF-8")); Response.Cookies.Add(new HttpCookie("SmartSystem_WeiXinUser_DefaultPlate", firstPlate)); } try { OnlineOrder model = new OnlineOrder(); model.OrderTime = DateTime.Now; TempParkingFeeResult result = RechargeService.WXTempParkingFee(licensePlate, parkingId, LoginAccountID, model.OrderTime); if (result.Result == APPResult.NoNeedPay || result.Result == APPResult.RepeatPay) { int type = result.Result == APPResult.NoNeedPay ? 0 : 1; return(RedirectToAction("NotNeedPayment", "ParkingPayment", new { licensePlate = licensePlate, type = type, surplusMinutes = result.OutTime, entranceTime = result.EntranceDate })); } RechargeService.CheckCalculatingTempCost(result.Result); if (result.OrderSource == PayOrderSource.Platform) { bool testResult = CarService.WXTestClientProxyConnectionByPKID(result.ParkingID); if (!testResult) { throw new MyException("车场网络异常,暂无法缴停车费!"); } int interfaceOrderState = InterfaceOrderServices.OrderWhetherEffective(result.Pkorder.OrderNo); if (interfaceOrderState != 1) { string msg = interfaceOrderState == 2 ? "重复支付" : "订单已失效"; return(PageAlert("Index", "H5ParkingPayment", new { RemindUserContent = msg })); } } model.ParkCardNo = result.CardNo; model.PKID = result.ParkingID; model.PKName = result.ParkName; model.InOutID = result.Pkorder.TagID; model.PlateNo = result.PlateNumber; model.EntranceTime = result.EntranceDate; model.ExitTime = model.OrderTime.AddMinutes(result.OutTime); model.Amount = result.Pkorder.Amount; model.PayDetailID = result.Pkorder.OrderNo; model.DiscountAmount = result.Pkorder.DiscountAmount; model.OrderSource = result.OrderSource; model.ExternalPKID = result.ExternalPKID; ViewBag.Result = result.Result; ViewBag.PayAmount = result.Pkorder.PayAmount; return(View(model)); } catch (MyException ex) { return(PageAlert("Index", "H5ParkingPayment", new { RemindUserContent = ex.Message })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("H5ParkingPaymentError", "计算缴费金额失败", ex, LogFrom.WeiXin); return(PageAlert("Index", "H5ParkingPayment", new { RemindUserContent = "计算缴费金额失败" })); } }
/// <summary> /// 根据车牌号月卡续期 /// </summary> /// <returns></returns> public ActionResult PlateNoRenewal(string plateNo) { try { List <ParkUserCarInfo> carInfos = RechargeService.GetMonthCarInfoByPlateNumber(plateNo); if (carInfos == null || carInfos.Count == 0) { return(PageAlert("Index", "CardRenewal", new { RemindUserContent = "找不到该车辆信息,请检查车牌输入是否正确" })); } if (carInfos.Count == 1) { if (!carInfos.First().IsAllowOnlIne) { return(PageAlert("Index", "CardRenewal", new { RemindUserContent = "该车辆不支持线上缴费" })); } return(RedirectToAction("MonthCardRenewal", "CardRenewal", new { plateNo = plateNo, cardId = carInfos.First().CardID, source = 1 })); } return(View(carInfos)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinWeb", string.Format("获取车牌信息失败,车牌号:" + plateNo), ex, LogFrom.WeiXin); return(PageAlert("Index", "CardRenewal", new { RemindUserContent = "获取车牌信息失败" })); } }
/// <summary> /// 充值记录 /// </summary> /// <returns></returns> public ActionResult GetRechargeRecordData(int orderSource, DateTime?start, DateTime?end, int page) { try { int pageSize = 10; int total = 0; List <ParkOrder> orders = ParkOrderServices.GetSellerRechargeOrder(SellerLoginUser.SellerID, orderSource, start, end, page, pageSize, out total); var models = from p in orders select new { OrderNo = p.OrderNo, OrderType = p.OrderType.GetDescription(), PayWay = p.PayWay.GetDescription(), Amount = p.Amount, OrderSource = p.OrderSource.GetDescription(), OrderTime = p.OrderTime.ToString("yyyy-MM-dd HH:mm:ss"), Balance = p.NewMoney }; return(Json(MyResult.Success("", models))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXin_XFJM", "获取商家充值记录失败", ex, LogFrom.WeiXin); return(Json(MyResult.Error("获取商家充值记录失败"))); } }
public ActionResult AddMyCar(string licenseplate) { try { WX_CarInfo model = new WX_CarInfo(); model.AccountID = UserAccount.AccountID; model.PlateNo = licenseplate.ToPlateNo(); model.Status = 2; int result = CarService.AddWX_CarInfo(model); if (result == 1) { return(Json(MyResult.Success("添加成功"))); } if (result == 0) { return(Json(MyResult.Error("车牌号重复"))); } return(Json(MyResult.Error("添加失败"))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("H5CarManageError", "添加车牌信息失败", ex, LogFrom.WeiXin); return(Json(MyResult.Error("添加失败"))); } }
/// <summary> /// 商家充值 /// </summary> /// <param name="orderId"></param> /// <returns></returns> public ActionResult SellerRechargePayment(decimal orderId) { try { OnlineOrder order = CheckOrder(orderId); if (order.OrderType != OnlineOrderType.SellerRecharge) { throw new MyException("支付方法不正确"); } if (string.IsNullOrWhiteSpace(order.MWebUrl)) { UnifiedPayModel model = GetUnifiedPayModel(order, string.Format("商家充值-{0}", order.PKName)); } ViewBag.MWeb_Url = order.MWebUrl; return(View(order)); } catch (MyException ex) { TxtLogServices.WriteTxtLogEx("H5WeiXinPayment_Error", "支付失败 orderId:{0};", orderId, ex, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = "/H5Seller/Index" })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("H5WeiXinPayment_Error", string.Format("商家充值支付失败 orderId:{0};", orderId), ex, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付失败,请重新支付", returnUrl = "/H5Seller/Index" })); } }
public ActionResult SaveBindMobile(string phone, string code) { try { if (string.IsNullOrWhiteSpace(phone) || !new Regex("^1[0-9]{10}$").Match(phone).Success) { throw new MyException("手机号码格式错误"); } CheckBindTradePasswordCode(code, phone); bool result = WeiXinAccountService.WXBindingMobilePhone(WeiXinUser.AccountID, phone); if (!result) { throw new MyException("绑定失败"); } RemoveTradePasswordCooike(); WeiXinUser.MobilePhone = phone; Session["SmartSystem_WX_Info"] = WeiXinUser; return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "绑定手机号失败", ex, LogFrom.WeiXin); return(Json(MyResult.Error("绑定失败"))); } }
/// <summary> /// 临停缴费 /// </summary> /// <returns></returns> public ActionResult ParkCarPayment(decimal orderId, int source = 0) { if (string.IsNullOrWhiteSpace(AliPayUserId)) { return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取用户信息失败" })); } try { OnlineOrder order = CheckOrder(orderId); if (order.OrderType != OnlineOrderType.ParkFee) { throw new MyException("支付方法不正确"); } string tradeNo = MakeAlipayTradeOrder(order); OnlineOrderServices.UpdatePrepayIdById(tradeNo, order.OrderID); order.PrepayId = tradeNo; ViewBag.MaxWaitTime = DateTime.Now.AddMinutes(WXOtherConfigServices.GetTempParkingWeiXinPayTimeOut(order.CompanyID)).ToString("yyyy-MM-dd HH:mm:ss"); return(View(order)); } catch (MyException ex) { return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = "/QRCodeParkPayment/Index" })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("AliPay_Error", string.Format("支付失败 orderId:{0};AliUserId:{1}", orderId, AliPayUserId), ex, LogFrom.AliPay); return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付失败,请重新支付", returnUrl = "/QRCodeParkPayment/Index" })); } }
/// <summary> /// 发送商家充值失败 退款失败提醒 /// </summary> /// <param name="orderId">订单编号</param> /// <param name="reason">原因</param> /// <param name="money">金额</param> /// <param name="openId">接受者openid</param> /// <returns></returns> public static bool SendSellerRechargeRefundFail(string companyId, string orderId, string reason, decimal money, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.ParkingRefundFailTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string firstDes = "您好,商家充值失败了,同时退款失败了。"; string topColor = "#FF0000"; WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = firstDes, color = "#173177" }, keyword1 = new { value = orderId, color = "#173177" }, keyword2 = new { value = string.Format("{0}元", money), color = "#173177" }, keyword3 = new { value = reason, color = "#173177" }, remark = new { value = "请尽快联系我们,我们将进行人工退款。", color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送发送商家充值失败通知失败", ex, LogFrom.WeiXin); return(false); } }
public void Process() { try { List <BaseParkinfo> parkings = GetParkingBySupportAutoRefund(); if (parkings.Count > 0) { List <OnlineOrder> models = OnlineOrderServices.QueryWaitRefund(parkings.Select(p => p.PKID).ToList(), DateTime.Now.Date); foreach (var item in models) { if (item.SyncResultTimes < 3) { continue; } try { OnlineOrderServices.AutoRefund(item.OrderID, BackgroundWorkerManager.EnvironmentPath); } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("Background", "自动退款失败:orderId:{0},Message:{1},StackTrace:{2}", item.OrderID, ex.Message, ex.StackTrace); } } } } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("Background", "后台工作线程处理退款异常", ex, LogFrom.WeiXin); } }
/// <summary> /// 发送预约车位支付同步支付结果失败的 退款成功提醒 /// </summary> /// <param name="orderId">订单编号</param> /// <param name="reason">原因</param> /// <param name="money">金额</param> /// <param name="openId">接受者openid</param> /// <returns></returns> public static bool SendBookingBitNoRefundSuccess(string companyId, string orderId, string reason, decimal money, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.ParkingRefundSuccessTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string firstDes = "您好,由于车场网络原因,您预约车位失败了,我们将您支付的钱返还到您的账号了,请查收。"; string topColor = "#FF0000"; WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = firstDes, color = "#173177" }, keyword1 = new { value = orderId, color = "#173177" }, keyword2 = new { value = reason, color = "#173177" }, keyword3 = new { value = string.Format("{0}元", money), color = "#173177" }, remark = new { value = "如有疑问,请尽快联系我们。", color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送车位预订退款成功提醒失败", ex, LogFrom.WeiXin); return(false); } }
/// <summary> /// 账号充值成功提醒 /// </summary> /// <param name="orderId">订单编号</param> /// <param name="money">充值金额(元)</param> /// <param name="openId">接收者编号</param> /// <param name="balance">账号余额</param> /// <param name="payTime">充值时间</param> /// <returns></returns> //public static bool SendAccountRechargeSuccess(string orderId, decimal money, decimal balance, string openId, DateTime payTime) //{ // try // { // string value = WXOtherConfigServices.GetConfigValue(ConfigType.AccountRechargeSuccessTemplateId); // if (string.IsNullOrWhiteSpace(value)) return false; // string payTimeDes = string.Format("{0}月{1}日 {2}时{3}分", payTime.Month.ToString().PadLeft(2, '0'), payTime.Day.ToString().PadLeft(2, '0'), payTime.Hour.ToString().PadLeft(2, '0'), payTime.Minute.ToString().PadLeft(2, '0')); // string topColor = "#FF0000"; // WX_ApiConfig config = GetWX_ApiConfig(); // var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); // var data = new // { // first = new { value = "您好,您的账号已充值成功!", color = "#173177" }, // keyword1 = new { value = string.Format("{0}元", money), color = "#173177" }, // keyword2 = new { value = string.Format("{0}元", balance), color = "#173177" }, // keyword3 = new { value = orderId, color = "#173177" }, // keyword4 = new { value = payTimeDes, color = "#173177" }, // remark = new { value = "如有疑问,请尽快联系我们", color = "#173177" } // }; // return WxAdvApi.SendTemplateMessage(accessToken, openId, value, topColor, data); // } // catch (Exception ex) // { // ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送账号充值成功提醒失败", ex, LogFrom.WeiXin); // return false; // } //} /// <summary> /// 月卡充值成功提醒 /// </summary> /// <param name="plateNumber">车牌号</param> /// <param name="parkingName">停车场名称</param> /// <param name="money">支付金额(分)</param> /// <param name="lastEffectiveTime">最后有效期</param> /// <param name="openId">微信openid</param> /// <returns></returns> public static bool SendMonthCardRechargeSuccess(string companyId, string plateNumber, string parkingName, decimal money, DateTime lastEffectiveTime, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.MonthCardRechargeSuccessTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string topColor = "#FF0000"; string effectiveTime = string.Format("{0}年{1}月{2}日", lastEffectiveTime.Year, lastEffectiveTime.Month, lastEffectiveTime.Day); WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = "您好,您的月卡已续期成功!", color = "#173177" }, keyword1 = new { value = plateNumber, color = "#173177" }, keyword2 = new { value = parkingName, color = "#173177" }, keyword3 = new { value = string.Format("{0}元", money), color = "#173177" }, keyword4 = new { value = string.Format("{0}元", money), color = "#173177" }, keyword5 = new { value = effectiveTime, color = "#173177" }, remark = new { value = "感谢您的使用。", color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送月卡充值成功提醒失败", ex, LogFrom.WeiXin); return(false); } }
/// <summary> /// 发送停车场入场通知 /// </summary> /// <param name="plateNumber">车牌号</param> /// <param name="parkingName">停车场名称</param> /// <param name="entranceTime">进场时间</param> /// <param name="openId">接受消息的openid</param> public static bool SendParkIn(string companyId, string plateNumber, string parkingName, string entranceTime, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.ParkInTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string topColor = "#FF0000"; string remark = "谢谢您的支持!"; WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = "欢迎您再次进入停车场\r\n", color = "#173177" }, keyword1 = new { value = plateNumber, color = "#173177" }, keyword2 = new { value = parkingName, color = "#173177" }, keyword3 = new { value = entranceTime.ToString(), color = "#173177" }, remark = new { value = remark, color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送停车场入场通知失败", ex, LogFrom.WeiXin); return(false); } }
/// <summary> /// 手动退款(退款失败是调用) /// </summary> /// <param name="orderId"></param> /// <param name="certpath"></param> /// <returns></returns> public static bool ManualRefund(decimal orderId, string certpath) { TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "方法名:{0},操作类型:{1},订单编号:{2},备注:{3}", "ManualRefund", "订单退款处理", orderId, "开始订单退款处理"); bool refundResult = false; lock (order_lock) { try { IOnlineOrder factory = OnlineOrderFactory.GetFactory(); OnlineOrder order = factory.QueryByOrderId(orderId); if (order.Status == OnlineOrderStatus.RefundFail) { refundResult = Refund(order, certpath); } if (refundResult) { OperateLogServices.AddOperateLog(OperateType.Other, string.Format("手动执行退款操作,退款订单号:{0}", orderId)); } } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("OnlineOrderServices", "手动执行退款操作失败", ex, LogFrom.WeiXin); } } return(refundResult); }
public ActionResult GetParkingSuggestion(string query, string city, string lat, string lng) { try { string location = !string.IsNullOrWhiteSpace(lat) && !string.IsNullOrWhiteSpace(lng) ? string.Format("{0},{1}", lat, lng) : string.Empty; query = HttpUtility.UrlEncode(query); city = HttpUtility.UrlEncode(city); PlaceSuggestion model = BaiDuLocationService.GetPlaceSuggestion(query, city, location); List <PlaceSuggestionResult> result = model.result.Where(p => p.location != null).Take(8).ToList(); if (!model.IsSuccess) { throw new MyException("查询周边车场失败"); } return(Json(MyResult.Success(model.message, result))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "根据关键字查询地理名称", ex, LogFrom.WeiXin); return(Json(MyResult.Error("查询周边车场失败"))); } }
public void Index() { try { PayDictionary queryArray = YinShengCommon.TransQueryString(Request.Form.ToString()); queryArray.Sort(PaySortEnum.Asc);//异步验证签名需要配需 if (queryArray["sign"] == null) { Response.Write("缺少签名参数"); Response.End(); } string sign = HttpUtility.UrlDecode(queryArray["sign"]); queryArray.Remove("sign"); string parStr = queryArray.GetParmarStr(); if (YinShengCommon.SignVerify(parStr, sign)) { Response.Write("success"); Response.End(); } else { Response.Write("签证签名不一致"); Response.End(); } } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("YSAsyncNotify", "支付通知出错", ex, LogFrom.WeiXin); Response.Write("error"); Response.End(); } }
private string GetCompanyId(string pid, string bid, string gid) { try { if (!string.IsNullOrWhiteSpace(gid)) { ParkGate gate = ParkGateServices.QueryByRecordId(gid); if (gate != null) { bid = gate.BoxID; } } if (!string.IsNullOrWhiteSpace(pid)) { BaseCompany company = CompanyServices.QueryByParkingId(pid); if (company != null) { return(company.CPID); } } if (!string.IsNullOrWhiteSpace(bid)) { BaseCompany company = CompanyServices.QueryByBoxID(bid); if (company != null) { return(company.CPID); } } } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("QRCodeParkPayment", "GetCompanyId方法处理异常", ex, LogFrom.WeiXin); } return(string.Empty); }
/// <summary> /// 微信单独授权 type 0-支付 1-岗亭扫码进入 /// </summary> /// <param name="id">ControllerName_actionName_ispayauthorize=0^orderId=123</param> /// <param name="code"></param> /// <param name="state"></param> /// <returns></returns> public ActionResult Index(string id, string code, string state) { try { if (SourceClient != RequestSourceClient.WeiXin) { return(RedirectToAction("Index", "ErrorPrompt", new { message = "请在微信中打开" })); } ClearQRCodeCookie(); WX_ApiConfig config = null; Dictionary <string, string> dicParams = GetRequestParams(id); if (string.IsNullOrWhiteSpace(dicParams["COMPANYID"])) { throw new MyException("获取单位信息失败"); } config = WXApiConfigServices.QueryWXApiConfig(dicParams["COMPANYID"]); if (config == null) { return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取微信配置失败" })); } if (!config.Status) { return(RedirectToAction("Index", "ErrorPrompt", new { message = "该公众号暂停使用,稍后再试!" })); } Session["CurrLoginWeiXinApiConfig"] = config; if (string.IsNullOrEmpty(state)) { string redirectUri = config.Domain.IndexOf("http://", StringComparison.Ordinal) < 0 ? string.Format("http://{0}", config.Domain) : config.Domain; redirectUri = string.Format("{0}/WeiXinAuthorize/{1}", redirectUri, id); TxtLogServices.WriteTxtLogEx("WeiXinAuthorize", "获取微信OpenId请求redirectUri:{0}", redirectUri); string url = WxAdvApi.GetAuthorizeUrl(config.AppId, redirectUri, "1", OAuthScope.snsapi_base); TxtLogServices.WriteTxtLogEx("WeiXinAuthorize", "获取微信OpenId请求url:{0}", url); return(Redirect(url)); } TxtLogServices.WriteTxtLogEx("WeiXinAuthorize", "state不为空进入,id:{0}, code:{1}, state:{2}", id, code, state); if (string.IsNullOrEmpty(code)) { return(RedirectToAction("Index", "ErrorPrompt", new { message = "微信获取授权失败,请重新进入或请联系管理员" })); } var accessToken = WxAdvApi.GetAccessToken(config.AppId, config.AppSecret, code); TxtLogServices.WriteTxtLogEx("WeiXinAuthorize", "调用微信的AccessToken接口:openid:{0}, access_token:{1}", accessToken.openid, accessToken.access_token); if (accessToken == null || string.IsNullOrWhiteSpace(accessToken.openid)) { throw new MyException("获取微信用户信息失败"); } //添加登陆 Response.Cookies.Add(new HttpCookie("SmartSystem_WeiXinOpenId", accessToken.openid)); TxtLogServices.WriteTxtLogEx("WeiXinAuthorize", "获取OpenId成功:openid:{0},cookie openid:{1}", accessToken.openid, WeiXinOpenId); return(Redir(id, accessToken.openid)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinAuthorize", "WeiXinAuthorize方法处理异常", ex, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "微信获取授权失败,请重新进入或请联系管理员" })); } }
public ActionResult AdvanceParkingPayment(decimal orderId) { try { AdvanceParking order = AdvanceParkingServices.QueryByOrderId(orderId); if (order == null) { throw new MyException("支付信息不存在"); } if (order.OrderState != 0) { throw new MyException("支付状态不正确"); } UnifiedPayModel model = UnifiedPayModel.CreateUnifiedModel(order.CompanyID); if (string.IsNullOrWhiteSpace(order.PrepayId)) { string payNotifyAddress = string.Format("{0}{1}", WXApiConfigServices.QueryWXApiConfig(order.CompanyID).Domain, "/WeiXinPayNotify/AdvanceParking"); //预支付 UnifiedPrePayMessage result = PaymentServices.UnifiedPrePay(model.CreatePrePayPackage(order.OrderId.ToString(), ((int)(order.Amount * 100)).ToString(), WeiXinOpenId, "预停车支付", payNotifyAddress)); if (result == null || !result.ReturnSuccess || !result.ResultSuccess || string.IsNullOrEmpty(result.Prepay_Id)) { throw new Exception(string.Format("获取PrepayId 失败,Message:{0}", result.ToXmlString())); } AdvanceParkingServices.UpdatePrepayIdById(result.Prepay_Id, order.OrderId); order.PrepayId = result.Prepay_Id; } WeiXinPaySignModel payModel = new WeiXinPaySignModel() { AppId = model.AppId, Package = string.Format("prepay_id={0}", order.PrepayId), Timestamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString(), Noncestr = Util.CreateNoncestr(), }; Dictionary <string, string> nativeObj = new Dictionary <string, string>(); nativeObj.Add("appId", payModel.AppId); nativeObj.Add("package", payModel.Package); nativeObj.Add("timeStamp", payModel.Timestamp); nativeObj.Add("nonceStr", payModel.Noncestr); nativeObj.Add("signType", payModel.SignType); payModel.PaySign = model.GetCftPackage(nativeObj); //生成JSAPI 支付签名 ViewBag.PayModel = payModel; return(View(order)); } catch (MyException ex) { return(PageAlert("Index", "AdvanceParking", new { RemindUserContent = ex.Message })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPayment_Error", string.Format("预停车支付失败 orderId:{0};openId:{1}", orderId, WeiXinOpenId), ex, LogFrom.WeiXin); return(PageAlert("Index", "AdvanceParking", new { RemindUserContent = "支付异常,请重新支付" })); } }
/// <summary> /// 月卡续期 /// </summary> /// <returns></returns> public ActionResult MonthCardRenewal(string cardId, string plateNo = "", int source = 0) { try { string selectMonth = string.Empty; string selectPayType = string.Empty; var selectParam = HttpContext.Request.Cookies["SmartSystem_MonthCardPayment_Month"]; if (selectParam != null && !string.IsNullOrWhiteSpace(selectParam.Value)) { if (selectParam.Value.Contains(",")) { string[] strs = selectParam.Value.Split(','); selectMonth = strs[0]; selectPayType = strs[1]; } } ViewBag.SelectMonth = selectMonth; ViewBag.SelectPayType = selectPayType; ViewBag.SystemDate = DateTime.Now.Date; List <ParkUserCarInfo> carInfos = new List <ParkUserCarInfo>(); if (source == 1) { carInfos = RechargeService.GetMonthCarInfoByPlateNumber(plateNo); } else { if (UserAccount != null) { carInfos = RechargeService.GetMonthCarInfoByAccountID(UserAccount.AccountID); } } ParkUserCarInfo card = carInfos.FirstOrDefault(p => p.CardID == cardId); if (card == null) { throw new MyException("获月卡信息失败"); } ViewBag.Source = source; bool canConnection = CarService.WXTestClientProxyConnectionByVID(card.VID); if (!canConnection) { return(PageAlert("Index", "H5CardRenewal", new { RemindUserContent = "车场网络异常,暂无法续期,请稍后再试!" })); } ViewBag.CardRenewalMonthDic = GetCardRenewalMonth(card.OnlineUnit); return(View(card)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", string.Format("获取续费信息失败,编号:" + cardId), ex, LogFrom.WeiXin); return(PageAlert("Index", "H5CardRenewal", new { RemindUserContent = "获取卡信息失败" })); } }
private static void UpdateSyncResultTimes(decimal orderId, string payDetailId) { try { IOnlineOrder factory = OnlineOrderFactory.GetFactory(); factory.UpdateSyncResultTimes(orderId, payDetailId); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("OnlineOrderServices", "修改同步次数失败", ex, LogFrom.WeiXin); } }
/// <summary> /// 获取优免规则 /// </summary> /// <returns></returns> public ActionResult GetParkCarDerate() { try { List <ParkDerate> models = ParkSellerDerateServices.WXGetParkDerate(SellerLoginUser.SellerID, SellerLoginUser.VID); return(Json(MyResult.Success("", models))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXin_XFJM", "获取优免规则异常", ex, LogFrom.WeiXin); return(Json(MyResult.Error("获取优免规则异常"))); } }
public ActionResult GetMyLicenseplate() { try { List <WX_CarInfo> plates = CarService.GetCarInfoByAccountID(UserAccount.AccountID); return(Json(MyResult.Success("获取成功", plates))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("H5CarManageError", "根据账号编号获取车牌信息失败", ex, LogFrom.WeiXin); return(Json(MyResult.Error("获取车辆信息失败"))); } }
/// <summary> /// 打折 /// </summary> /// <returns></returns> public ActionResult Discount(string IORecordID, string DerateID, decimal DerateMoney) { try { ConsumerDiscountResult result = ParkSellerDerateServices.WXDiscountPlateNumber(IORecordID, DerateID, SellerLoginUser.VID, SellerLoginUser.SellerID, DerateMoney); return(Json(MyResult.Success("", result))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXin_XFJM", "打折异常", ex, LogFrom.WeiXin); return(Json(MyResult.Error("打折异常"))); } }
public ActionResult OrderPaymenting(decimal orderId) { try { OnlineOrderServices.OrderPaying(orderId); return(Json(MyResult.Success())); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("AliPay_Error", string.Format("订单状态更改为支付中失败 orderId:{0};openId:{1}", orderId, WeiXinOpenId), ex, LogFrom.WeiXin); return(Json(MyResult.Error("更改未支付中失败"))); } }
private string GetWeiXinSignature(WX_ApiConfig config, string noncestr, string url, string timestamp) { try { var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret, false); var ticket = WxAdvApi.GetTicket(accessToken); return(WxService.GetJsApiSignature(noncestr, ticket.ticket, timestamp, url)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "分享页面获取签名错误", ex, LogFrom.WeiXin); return(string.Empty); } }
/// <summary> /// 获取车场数据 /// </summary> /// <param name="plateNumber"></param> /// <returns></returns> public JsonResult GetParkingData(string villageId) { try { List <BaseParkinfo> parkings = ParkingServices.QueryParkingByVillageId(villageId); return(Json(MyResult.Success("", parkings))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("H5CarVisitorError", "获取车场信息失败", ex, LogFrom.WeiXin); return(Json(MyResult.Error("获取车场信息失败"))); } }