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> /// <returns></returns> /// </summary> /// <param name="parkingId">车场编号</param> /// <param name="GateID"></param> /// <param name="AccountID"></param> /// <param name="OrderSource"></param> /// <returns></returns> public static TempParkingFeeResult WXScanCodeTempParkingFeeByParkGateID(string parkingId, string GateID, string AccountID, OrderSource OrderSource) { TxtLogServices.WriteTxtLogEx("BWYInterfaceProcess", string.Format("WXScanCodeTempParkingFeeByParkGateID,GateID:{0},AccountID:{1},OrderSource:{2},parkingId:{3}", GateID, AccountID, (int)OrderSource, parkingId)); if (parkingId == SystemDefaultConfig.SFMPKID) { string[] sPData = GateID.Split('$'); if (sPData.Length == 2) { return(SFMTempParkingFeeResult(sPData[0], sPData[1])); } else { TempParkingFeeResult r = new TempParkingFeeResult(); r.Result = APPResult.OtherException; return(r); } } if (parkingId == SystemDefaultConfig.BWPKID) { return(BWYTempParkingFeeResult(GateID)); } WXServiceClient client = ServiceUtil <WXServiceClient> .GetServiceClient("WXService"); string result = client.WXScanCodeTempParkingFeeByGateID(GateID, AccountID, (int)OrderSource); client.Close(); client.Abort(); return(JsonHelper.GetJson <TempParkingFeeResult>(result)); }
/// <summary> /// 车牌号缴费 /// </summary> /// <param name="PlateNumber"></param> /// <param name="CardNo"></param> /// <param name="ParkingID"></param> /// <param name="SystemID"></param> /// <param name="AccountID"></param> /// <returns></returns> public static TempParkingFeeResult WXTempParkingFee(string PlateNumber, string ParkingID, string AccountID, DateTime CalculatDate) { WXServiceClient client = ServiceUtil <WXServiceClient> .GetServiceClient("WXService"); string result = client.WXTempParkingFee(PlateNumber, ParkingID, CalculatDate, AccountID, 1); client.Close(); client.Abort(); TempParkingFeeResult model = JsonHelper.GetJson <TempParkingFeeResult>(result); try { if (!string.IsNullOrWhiteSpace(BWYInterfaceUrl) && !string.IsNullOrWhiteSpace(BWYSessionID) && !string.IsNullOrWhiteSpace(BWPKID)) { if (model.Result == APPResult.NotFindIn || model.Result == APPResult.ProxyException || model.Result == APPResult.NoTempCard || model.Result == APPResult.NotFindCard || model.Result == APPResult.OtherException) { BWYOrderQueryResult bwyResult = BWYInterfaceProcess.TempParkingFee(PlateNumber); if (bwyResult != null) { //return TransforTempParkingFeeResult(model, bwyResult, PlateNumber); model = BWYTransforTempParkingFeeResult(model, bwyResult, PlateNumber); } } } } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("BWYInterfaceProcess", string.Format("WXTempParkingFee方法,异常:{0}", ex.Message)); } try { if (model.Result == APPResult.NotFindIn || model.Result == APPResult.ProxyException || model.Result == APPResult.NoTempCard || model.Result == APPResult.NotFindCard || model.Result == APPResult.OtherException) { if (!string.IsNullOrWhiteSpace(SFMInterfaceUrl) && !string.IsNullOrWhiteSpace(SFMSecretKey) && !string.IsNullOrWhiteSpace(SFMPKID)) { PlateQueryResult sfmResult = SFMInterfaceProcess.GetCarPrice(PlateNumber); if (sfmResult != null) { model = SFMTransforTempParkingFeeResult(model, sfmResult); } } } } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("SFMError", string.Format("WXTempParkingFee方法,异常:{0}", ex.Message)); } return(model); }
public static bool SetParkingFee(string key, TempParkingFeeResult info) { //if (FeeData.ContainsKey(key)) //{ // FeeData[key] = info; //} //else //{ // FeeData.Add(key,info); //} FeeData[key] = info; return(true); }
public static TempParkingFeeResult SFMTempParkingFeeResult(string ParkNo, string GateID) { TempParkingFeeResult result = new TempParkingFeeResult(); result.Result = APPResult.OtherException; result.ErrorDesc = "车场或通道编号未配置"; if (!string.IsNullOrWhiteSpace(SystemDefaultConfig.SFMPKID) && !string.IsNullOrWhiteSpace(ParkNo) && !string.IsNullOrWhiteSpace(GateID)) { try { BWYGateMapping gate = BWYGateMappingServices.QueryByGateID(1, ParkNo, GateID); if (gate == null) { result.Result = APPResult.OtherException; result.ErrorDesc = "获取车场信息失败"; TxtLogServices.WriteTxtLogEx("SFMError", string.Format("SFMTempParkingFeeResult方法,获取车场信息失败,通道编号:{0}", GateID)); return(result); } TxtLogServices.WriteTxtLogEx("SFMError", string.Format("SFMTempParkingFeeResult方法,SFMInterfaceUrl:{0},SFMSecretKey:{1},SFMPKID:{2}", SFMInterfaceUrl, SFMSecretKey, SFMPKID)); if (!string.IsNullOrWhiteSpace(SFMInterfaceUrl) && !string.IsNullOrWhiteSpace(SFMSecretKey) && !string.IsNullOrWhiteSpace(SFMPKID)) { OutCarInfoResult sfmResult = SFMInterfaceProcess.QueryOutCarOrder(gate.ParkNo, GateID); if (!sfmResult.Success) { result.Result = APPResult.OtherException; result.ErrorDesc = string.Format("{0}[{1}]", sfmResult.Message, sfmResult.Code); return(result); } if (sfmResult.Data == null) { result.Result = APPResult.NoCarInBox; result.ErrorDesc = string.Empty; return(result); } return(SFMTransforTempParkingFeeResult(result, sfmResult)); } } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("SFMError", string.Format("SFMTempParkingFeeResult方法,异常:{0}", ex.Message)); } } else { TxtLogServices.WriteTxtLogEx("SFMError", string.Format("SFMTempParkingFeeResult方法,参数无效:{0},GateID:{1}", SystemDefaultConfig.SFMPKID, GateID)); } return(result); }
public static TempParkingFeeResult BWYTempParkingFeeResult(string GateID) { TempParkingFeeResult result = new TempParkingFeeResult(); result.Result = APPResult.NoCarInBox; result.ErrorDesc = "未知异常"; int bwyGateId = 0; if (!string.IsNullOrWhiteSpace(SystemDefaultConfig.BWPKID) && int.TryParse(GateID, out bwyGateId)) { try { OutCarResult bwyResult = BWYInterfaceProcess.QueryOutCar(bwyGateId); if (bwyResult.Result != 0) { result.Result = APPResult.OtherException; result.ErrorDesc = bwyResult.Desc; return(result); } if (bwyResult.Reference == null || string.IsNullOrWhiteSpace(bwyResult.Reference.LPR)) { result.Result = APPResult.NoCarInBox; result.ErrorDesc = bwyResult.Desc; return(result); } TxtLogServices.WriteTxtLogEx("BWYInterfaceProcess", string.Format("BWYTempParkingFeeResult方法,BWYInterfaceUrl:{0},BWYSessionID:{1},BWPKID:{2}", BWYInterfaceUrl, BWYSessionID, BWPKID)); if (!string.IsNullOrWhiteSpace(BWYInterfaceUrl) && !string.IsNullOrWhiteSpace(BWYSessionID) && !string.IsNullOrWhiteSpace(BWPKID)) { BWYOrderQueryResult tempResult = BWYInterfaceProcess.TempParkingFee(bwyResult.Reference.LPR); if (tempResult != null) { return(BWYTransforTempParkingFeeResult(result, tempResult, bwyResult.Reference.LPR)); } } } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("BWYInterfaceProcess", string.Format("BWYTempParkingFeeResult方法,异常:{0}", ex.Message)); } } else { TxtLogServices.WriteTxtLogEx("BWYInterfaceProcess", string.Format("BWYTempParkingFeeResult方法,参数无效:{0},GateID:{1}", SystemDefaultConfig.BWPKID, GateID)); } return(result); }
public string SendParkingFees(string sData) { TempParkingFeeResult model = JsonHelper.GetJson <TempParkingFeeResult>(sData); string plateNo = model.PlateNumber; //string rid = model.Pkorder.TagID; string pid = model.ParkingID; //string bid = model.BoxID; //string gid = model.GateID; model.PayDate = DateTime.Now; //统一服务器时间 string sKey = plateNo + pid; bool bSuc = WeiXinInerface.ParkingFeeService.SetParkingFee(sKey, model); if (bSuc) { return("1"); } return("0"); }
//private string GetCompanyId(string pid, string bid) { // try // { // 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> /// 计算停车费 /// </summary> /// <param name="pid">车场编号</param> /// <param name="licensePlate">车牌号</param> /// <param name="bid">岗亭编号</param> /// <param name="gid">通道编号</param> /// <returns></returns> public ActionResult ComputeParkingFee(string pid, string licensePlate, string bid, string gid) { licensePlate = licensePlate.ToPlateNo(); TxtLogServices.WriteTxtLogEx("QRCodeParkPayment", "进入ComputeParkingFee,pid:{0}, licensePlate:{1}, bid:{2},gid:{3},opendId:{4}", pid, licensePlate, bid, gid, WeiXinOpenId); bool IsShowPlateNumber = true; try { OnlineOrder model = new OnlineOrder(); model.OrderTime = DateTime.Now; TempParkingFeeResult result = null; bool bClient = false; if (!string.IsNullOrWhiteSpace(gid)) { //result = RechargeService.WXScanCodeTempParkingFeeByGateID(pid, gid, string.Empty, GetOrderSource()); result = ParkingFeeService.GetParkingFeeByGateID(pid, gid); if (result == null) { TxtLogServices.WriteTxtLogEx("QRCodeParkPayment", "GetParkingFeeByGateID Result:null"); } else { bClient = true; TxtLogServices.WriteTxtLogEx("QRCodeParkPayment", "GetParkingFeeByGateID Result:{0}", (int)result.Result); } if (result == null) { result = RechargeService.WXScanCodeTempParkingFeeByParkGateID(pid, gid, string.Empty, GetOrderSource()); } TxtLogServices.WriteTxtLogEx("QRCodeParkPayment", "Result:{0}", (int)result.Result); if (result == null || result.Result == APPResult.NoNeedPay || result.Result == APPResult.RepeatPay) { int type = result.Result == APPResult.NoNeedPay ? 0 : 1; return(RedirectToAction("NotNeedPayment", "QRCodeParkPayment", new { licensePlate = result.PlateNumber, type = type, surplusMinutes = result.OutTime, entranceTime = result.EntranceDate, backUrl = "/QRCode/Index" })); } if (result.Result == APPResult.NoLp) { return(RedirectToAction("Index", "ScanCodeInOut", new { pid = pid, io = gid, source = 1 })); } } else if (!string.IsNullOrWhiteSpace(bid)) { result = ParkingFeeService.GetParkingFeeByBoxID(bid); if (result == null) { TxtLogServices.WriteTxtLogEx("QRCodeParkPayment", "GetParkingFeeByBoxID Result:null"); result = RechargeService.WXScanCodeTempParkingFee(bid, string.Empty); } else { bClient = true; TxtLogServices.WriteTxtLogEx("QRCodeParkPayment", "GetParkingFeeByBoxID Result:{0}", (int)result.Result); } if (result == null || result.Result == APPResult.NoNeedPay || result.Result == APPResult.RepeatPay) { int type = result.Result == APPResult.NoNeedPay ? 0 : 1; return(RedirectToAction("NotNeedPayment", "QRCodeParkPayment", new { licensePlate = result.PlateNumber, type = type, surplusMinutes = result.OutTime, entranceTime = result.EntranceDate, backUrl = "/QRCode/Index" })); } } else { if (string.IsNullOrWhiteSpace(licensePlate)) { return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取车牌信息失败" })); } result = ParkingFeeService.GetParkingFeeByParkingID(pid, licensePlate); if (result == null) { result = RechargeService.WXTempParkingFee(licensePlate, pid, string.Empty, model.OrderTime); } else { bClient = true; } if (result == null || result.Result == APPResult.NoNeedPay || result.Result == APPResult.RepeatPay) { int type = result.Result == APPResult.NoNeedPay ? 0 : 1; return(RedirectToAction("NotNeedPayment", "QRCodeParkPayment", new { licensePlate = licensePlate, type = type, surplusMinutes = result.OutTime, entranceTime = result.EntranceDate })); } } if (!bClient) { RechargeService.CheckCalculatingTempCost(result.Result, result.ErrorDesc); if (result.OrderSource == PayOrderSource.Platform) { bool testResult = CarService.WXTestClientProxyConnectionByPKID(result.ParkingID); if (!testResult) { throw new MyException("车场网络异常,暂无法缴停车费!"); } //int interfaceOrderState = InterfaceOrderServices.OrderWhetherEffective(result.Pkorder.OrderNo); int interfaceOrderState = InterfaceOrderServices.OrderWhetherEffective(result.Pkorder.OrderNo, result.ParkingID, result.Pkorder.TagID); TxtLogServices.WriteTxtLogEx("QRCodeParkPayment", "ComputeParkingFee,Tag:{0}, OrderNo:{1}, PKID:{2}\r\nResult:{3}", result.Pkorder.TagID, result.Pkorder.OrderNo, result.ParkingID, interfaceOrderState); if (interfaceOrderState != 1) { string msg = interfaceOrderState == 2 ? "重复支付" : "订单已失效"; string companyId = GetCompanyId(pid, bid, gid); return(RedirectToAction("Index", "ErrorPrompt", new { message = msg, returnUrl = "/QRCode/Index?companyId=" + companyId + "" })); } } } model.OrderSource = result.OrderSource; model.ExternalPKID = result.ExternalPKID; model.ParkCardNo = result.CardNo; model.PKID = result.ParkingID; model.PKName = result.ParkName; model.InOutID = result.Pkorder.TagID; model.TagID = 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; ViewBag.Result = result.Result; ViewBag.PayAmount = result.Pkorder.PayAmount; ViewBag.IsShowPlateNumber = IsShowPlateNumber; if (result.ImageUrl.IsEmpty()) { ParkIORecord record = ParkIORecordServices.QueryLastExitIORecordByPlateNumber(model.PlateNo); string htmlurl = ""; if (record != null && record.EntranceImage.IsEmpty() == false) { htmlurl = "http://www.yft166.net/Pic/" + record.EntranceImage.Replace('\\', '/'); } else { result.ImageUrl = htmlurl; } result.ImageUrl = htmlurl; } //显示图片的 ViewBag.url = result.ImageUrl; return(View(model)); } catch (MyException ex) { string companyId = GetCompanyId(pid, bid, gid); string parkingId = GetParkingId(pid, bid, gid); return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, parkingId = parkingId, returnUrl = "/QRCode/Index?companyId=" + companyId + "" })); } catch (Exception ex) { string companyId = GetCompanyId(pid, bid, gid); ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "扫描缴费计算缴费金额失败", ex, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "计算缴费金额失败", returnUrl = "/QRCode/Index?companyId=" + companyId + "" })); } }
public string Pay() { string sTag = Request["paytype"]; //string sBody = Request["body"]; string sAmount = Request["fee"]; string sPayAccount = Request["auth_code"]; string sPlateNumber = Request["PlateNumber"]; string sPKID = Request["PKID"]; if (sTag.IsEmpty() || (sTag != "0" && sTag != "1" && sTag != "2")) { return("2"); } //if (string.IsNullOrEmpty(sBody)) //{ // return "2sBody"; //} if (string.IsNullOrEmpty(sAmount)) { return("2"); } if (sTag != "2") { if (string.IsNullOrEmpty(sPayAccount)) { return("2"); } } if (string.IsNullOrEmpty(sPlateNumber)) { return("2"); } if (string.IsNullOrEmpty(sPKID)) { return("2"); } OnlineOrder model = new OnlineOrder(); model.OrderTime = DateTime.Now; TempParkingFeeResult result = RechargeService.WXTempParkingFee(sPlateNumber, sPKID, sPayAccount, model.OrderTime); if (result.Result == APPResult.NoNeedPay) { return("3"); //不需要交费 } if (result.Result == APPResult.RepeatPay) { return("4"); //重复交费 } decimal dAmount = decimal.Parse(sAmount) / 100; //if (result.Pkorder.Amount != dAmount) //{ // return "6"; //金额不一致 //} try { RechargeService.CheckCalculatingTempCost(result.Result); } catch (Exception ex) { return(((int)result.Result).ToString()); } if (result.OrderSource == PayOrderSource.Platform) { bool testResult = CarService.WXTestClientProxyConnectionByPKID(result.ParkingID); if (!testResult) { throw new MyException("车场网络异常,暂无法缴停车费!"); } //int interfaceOrderState = InterfaceOrderServices.OrderWhetherEffective(result.Pkorder.OrderNo); int interfaceOrderState = InterfaceOrderServices.OrderWhetherEffective(result.Pkorder.OrderNo, result.ParkingID, result.Pkorder.TagID); if (interfaceOrderState != 1) { if (interfaceOrderState == 2) { return("4"); //重复交费 } else { return("5"); //订单已失效 } } } 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.Amount = dAmount; model.PayDetailID = result.Pkorder.OrderNo; model.DiscountAmount = result.Pkorder.DiscountAmount; // model.OrderSource = PayOrderSource.HAND; model.ExternalPKID = result.ExternalPKID; model.OrderID = IdGenerator.Instance.GetId(); model.Status = OnlineOrderStatus.WaitPay; model.OrderType = OnlineOrderType.ParkFee; BaseCompany company = CompanyServices.QueryByParkingId(model.PKID); if (company == null) { throw new MyException("获取单位信息失败"); } if (sTag == "0") { WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(company.CPID); if (config == null) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "获取微信配置信息失败", "单位编号:" + company.CPID, LogFrom.WeiXin); return("-1"); } if (!config.Status) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "该车场暂停使用微信支付", "单位编号:" + company.CPID, LogFrom.WeiXin); return("-1"); } model.PayeeUser = config.SystemName; model.PayeeAccount = config.PartnerId; model.PayAccount = sPayAccount; model.Payer = sPayAccount; model.AccountID = model.AccountID; model.CardId = model.AccountID; model.PayeeChannel = PaymentChannel.WeiXinPay; model.PaymentChannel = PaymentChannel.WeiXinPay; model.CompanyID = config.CompanyID; bool isSuc = OnlineOrderServices.Create(model); if (!isSuc) { throw new MyException("生成待缴费订单失败"); } } else if (sTag == "1") { //支付宝 AliPayApiConfig config = AliPayApiConfigServices.QueryAliPayConfig(company.CPID); if (config == null) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "获取支付宝配置信息失败[0001]", "单位编号:" + company.CPID, LogFrom.WeiXin); return("-1"); } if (!config.Status) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "该支付宝暂停使用", "单位编号:" + config.CompanyID, LogFrom.WeiXin); return("-1"); } model.AccountID = string.Empty; model.CardId = string.Empty; model.PayeeChannel = PaymentChannel.AliPay; model.PaymentChannel = PaymentChannel.AliPay; model.PayeeUser = config.SystemName; model.PayeeAccount = config.PayeeAccount; model.Payer = sPayAccount; model.PayAccount = sPayAccount; model.CompanyID = config.CompanyID; bool isSuc = OnlineOrderServices.Create(model); if (!isSuc) { throw new MyException("生成待缴费订单失败"); } } else if (sTag == "2") { //现金支付的 model.AccountID = string.Empty; model.CardId = string.Empty; model.Payer = sPayAccount; model.PayAccount = sPayAccount; model.CompanyID = company.CPID; } //调用刷卡支付,如果内部出现异常则在页面上显示异常原因 try { //int status=1; string tradeNo = ""; string sDataInfo = ""; if (sTag == "0") //微信 { if (!MicroPay.Run(model, out sDataInfo)) { return("-2"); } else { tradeNo = sDataInfo; //发送通知开闸 bool isPayState = OnlineOrderServices.PaySuccess(model.OrderID, tradeNo, DateTime.Now, sPayAccount); if (!isPayState) { throw new Exception("修改微信订单状态失败"); } TxtLogServices.WriteTxtLogEx("WXPayReturn", string.Format("WXPayResult:{0}支付完成", tradeNo)); } } else if (sTag == "1") //支付宝 { if (AliPayPay.Run(model, out sDataInfo) == false) { return("-3"); } else { tradeNo = sDataInfo; bool isPayState = OnlineOrderServices.PaySuccess(model.OrderID, tradeNo, DateTime.Now, sPayAccount); if (!isPayState) { throw new Exception("修改支付宝订单状态失败"); } TxtLogServices.WriteTxtLogEx("AliPayReturn", string.Format("AliPayShowResult:{0}支付完成", tradeNo)); } } else if (sTag == "2") //现金支付的 { TempStopPaymentResult payResult = RechargeService.WXTempStopPayment(result.Pkorder.OrderNo, (int)OrderPayWay.Cash, dAmount, sPKID, "", model.OrderID.ToString(), DateTime.Now); TxtLogServices.WriteTxtLogEx("CashReturn", string.Format("CashShowResult:{1}:{0} 支付完成", payResult.ToXml(System.Text.Encoding.UTF8), dAmount)); if (payResult.Result != APPResult.Normal) { return("5"); } } //不是预支付的订单 就暂时不修改了 //bool results = OnlineOrderServices.UpdatePrepayIdById(tradeNo, model.OrderID); //Response.Write("<span style='color:#00CD00;font-size:20px'>" + result + "</span>"); ParkingFeeService.DeleteParkingFee(model.PlateNo + model.PKID); return("0"); } //catch (WxPayException ex) //{ // return "1"; // //Response.Write("<span style='color:#FF0000;font-size:20px'>" + ex.ToString() + "</span>"); //} catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("PayError", "该支付失败", "单位编号:" + model.CompanyID + "<br/>" + ex.StackTrace, LogFrom.UnKnown); return("-4"); //Response.Write("<span style='color:#FF0000;font-size:20px'>" + ex.ToString() + "</span>"); } }
/// <summary> /// 计算停车费 /// </summary> /// <returns></returns> /// public ActionResult ComputeParkingFee(string licensePlate, string parkingId) { string htmlurl = string.Empty; 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)); //licensePlate = "浙B81X83"; //string errMsg = ""; ////string aa = string.Empty; ////aa=WXotherServices.GETURL(licensePlate).ToString(); //ParkIORecord record = ParkIORecordServices.GetNoExitIORecordByPlateNumber(parkingId, licensePlate, out errMsg); //if (record != null && record.EntranceImage.IsEmpty() == false) //{ // htmlurl = "http://www.yft166.net/Pic/" + record.EntranceImage; //} //else { // htmlurl = "/Content/mobile/images/images.png"; //} // //ViewBag.meas = parkingId; } bool IsShowPlateNumber = true; try { OnlineOrder model = new OnlineOrder(); model.OrderTime = DateTime.Now; List <WX_CarInfo> myPlates = CarService.GetCarInfoByAccountID(WeiXinUser.AccountID); if (myPlates.Count(p => p.PlateNo.ToPlateNo() == licensePlate) == 0) { IsShowPlateNumber = false; } TempParkingFeeResult result = RechargeService.WXTempParkingFee(licensePlate, parkingId, WeiXinUser.AccountID, 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); int interfaceOrderState = InterfaceOrderServices.OrderWhetherEffective(result.Pkorder.OrderNo, result.ParkingID, result.Pkorder.TagID); if (interfaceOrderState != 1) { string msg = interfaceOrderState == 2 ? "重复支付" : "订单已失效"; return(PageAlert("LicensePlatePayment", "ParkingPayment", new { RemindUserContent = msg })); } } model.ParkCardNo = result.CardNo; model.PKID = result.ParkingID; model.PKName = result.ParkName; model.InOutID = result.Pkorder.TagID; model.TagID = 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; ParkIORecord record = ParkIORecordServices.QueryLastExitIORecordByPlateNumber(licensePlate); if (record != null && record.EntranceImage.IsEmpty() == false) { htmlurl = "http://www.yft166.net/Pic/" + record.EntranceImage.Replace('\\', '/'); } else { htmlurl = "/Content/mobile/images/images.png"; } ViewBag.url = htmlurl; ViewBag.Result = result.Result; ViewBag.PayAmount = result.Pkorder.PayAmount; ViewBag.IsShowPlateNumber = IsShowPlateNumber; return(View(model)); } catch (MyException ex) { return(PageAlert("LicensePlatePayment", "ParkingPayment", new { RemindUserContent = ex.Message })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "计算缴费金额失败", ex, LogFrom.WeiXin); return(PageAlert("LicensePlatePayment", "ParkingPayment", new { RemindUserContent = "计算缴费金额失败" })); } }
private static TempParkingFeeResult SFMTransforTempParkingFeeResult(TempParkingFeeResult model, OutCarInfoResult sfmResult) { if (!sfmResult.Success || sfmResult.Data == null) { return(model); } if (sfmResult.Code == "400") { model.Result = APPResult.AmountIsNot; return(model); } if (sfmResult.Code != "0000") { model.Result = APPResult.OtherException; return(model); } SMFOutCarInfo payInfo = sfmResult.Data; if (!payInfo.payAmount.HasValue || payInfo.payAmount <= 0) { model.Result = APPResult.NoNeedPay; return(model); } TempParkingFeeResult result = new TempParkingFeeResult(); result.OrderSource = PayOrderSource.SFM; result.PlateNumber = payInfo.carNo; result.CardNo = payInfo.carNo; result.ParkingID = SFMPKID; result.ExternalPKID = payInfo.Parking_Key; BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(SystemDefaultConfig.SFMPKID); if (parking != null) { result.ParkName = parking.PKName; } result.EntranceDate = DateTime.Parse(payInfo.enterTime); result.OutTime = payInfo.freeTimeout.HasValue ? payInfo.freeTimeout.Value : 10; result.isAdd = true; result.PayDate = DateTime.Now; ParkOrder order = new ParkOrder(); order.RecordID = payInfo.ParkOrder_OrderNo; order.OrderNo = payInfo.ParkOrder_OrderNo; order.TagID = "1"; order.OrderType = OrderType.TempCardPayment; order.PayWay = OrderPayWay.WeiXin; order.DiscountAmount = payInfo.couponAmount.HasValue ? payInfo.couponAmount.Value : 0; order.Amount = payInfo.totalAmount.HasValue ? payInfo.totalAmount.Value : 0; order.UnPayAmount = 0; order.PayAmount = payInfo.payAmount.HasValue ? payInfo.payAmount.Value : 0; order.CarderateID = ""; order.Status = 0; order.OrderSource = OrderSource.WeiXin; order.OrderTime = DateTime.Now; order.PayTime = DateTime.Now; order.PKID = SFMPKID; order.UserID = ""; order.OnlineUserID = ""; order.OnlineOrderNo = ""; order.Remark = ""; result.Pkorder = order; result.OrderSource = PayOrderSource.SFM; return(result); }
private static TempParkingFeeResult BWYTransforTempParkingFeeResult(TempParkingFeeResult model, BWYOrderQueryResult bwyResult, string plateNumber) { if (bwyResult.Result != 0 || bwyResult.Reference == null || bwyResult.Reference.Count == 0) { return(model); } OrderQueryResultReference reference = bwyResult.Reference.First(); TempParkingFeeResult result = new TempParkingFeeResult(); result.OrderSource = PayOrderSource.BWY; result.PlateNumber = plateNumber; result.CardNo = plateNumber; OrderResultReferenceParkingLot parking = reference.ParkingLot; if (parking == null) { TxtLogServices.WriteTxtLogEx("BWYInterfaceProcess", string.Format("TransforTempParkingFeeResult方法,OrderResultReferenceParkingLot is null")); return(model); } result.ParkingID = BWPKID; result.ParkName = parking.Name; result.ExternalPKID = parking.Index.ToString(); OrderResultBill bill = reference.Bill; if (bill == null) { TxtLogServices.WriteTxtLogEx("BWYInterfaceProcess", string.Format("TransforTempParkingFeeResult方法,OrderResultBill is null")); return(model); } if (bill.PayState == 3) { result.Result = APPResult.NoNeedPay; } //if (bill.PayState == 10) //{ // result.Result = APPResult.NotFindIn; //} if (bill.PayState == 1 || bill.PayState == 2 || bill.PayState == 10) { result.Result = APPResult.Normal; } result.EntranceDate = bill.StartDate; result.OutTime = 10; result.isAdd = true; result.PayDate = DateTime.Now; ParkOrder order = new ParkOrder(); order.ID = bill.Index; order.RecordID = bill.Index.ToString(); order.OrderNo = bill.Index.ToString(); order.TagID = bill.Index.ToString(); order.OrderType = OrderType.TempCardPayment; order.PayWay = OrderPayWay.WeiXin; OrderResultCostDetail detail = reference.CostDetail; if (detail == null) { TxtLogServices.WriteTxtLogEx("BWYInterfaceProcess", string.Format("TransforTempParkingFeeResult方法,OrderResultCostDetail is null")); return(model); } if (detail != null && detail.Discount != null) { order.DiscountAmount = detail.Discount.Sums / 100; } if (detail.Sums == 0) { result.Result = APPResult.NoNeedPay; } order.Amount = (detail.Sums - order.DiscountAmount) / 100; order.UnPayAmount = 0; order.PayAmount = (detail.Sums - order.DiscountAmount) / 100; order.CarderateID = ""; order.Status = 0; order.OrderSource = OrderSource.WeiXin; order.OrderTime = DateTime.Now; order.PayTime = DateTime.Now; //order.OldUserulDate = DateTime.MinValue; //order.NewUsefulDate = DateTime.MinValue; //order.OldMoney = null; //order.NewMoney = null; order.PKID = parking.Index.ToString(); order.UserID = ""; order.OnlineUserID = ""; order.OnlineOrderNo = ""; order.Remark = ""; //order.LastUpdateTime = ""; //order.HaveUpdate = ""; //order.DataStatus = ""; result.Pkorder = order; result.OrderSource = PayOrderSource.BWY; return(result); }