/// <summary> /// 获取近三个月交易明细 /// </summary> protected String GetThreeMonthsHistoryDetails(String SPID, String CustID, String wt) { Int32 Result = ErrorDefinition.CIP_IError_Result_UnknowError_Code; String ErrMsg = ErrorDefinition.CIP_IError_Result_UnknowError_Msg; StringBuilder returnMsg = new StringBuilder(); DateTime startDate = new DateTime(DateTime.Now.AddMonths(-2).Year, DateTime.Now.AddMonths(-2).Month, 1); DateTime endDate = DateTime.Now; wt = "json"; //仅支持json if (String.IsNullOrEmpty(SPID)) { returnMsg.Length = 0; if ("json".Equals(wt)) { returnMsg.Append("{"); returnMsg.AppendFormat("\"errcode\":\"{0}\",", "995"); returnMsg.AppendFormat("\"errmsg\":\"{0}\"", "SPID不能为空!"); returnMsg.Append("}"); } else { returnMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); returnMsg.Append("<PayPlatRequestParameter>"); returnMsg.Append("<PARAMETERS>"); returnMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "995"); returnMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "SPID不能为空!"); returnMsg.Append("</PARAMETERS>"); returnMsg.Append("</PayPlatRequestParameter>"); } return(returnMsg.ToString()); } if (String.IsNullOrEmpty(CustID)) { returnMsg.Length = 0; if ("json".Equals(wt)) { returnMsg.Append("{"); returnMsg.AppendFormat("\"errcode\":\"{0}\",", "996"); returnMsg.AppendFormat("\"errmsg\":\"{0}\"", "CustID不能为空!"); returnMsg.Append("}"); } else { returnMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); returnMsg.Append("<PayPlatRequestParameter>"); returnMsg.Append("<PARAMETERS>"); returnMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "996"); returnMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "CustID不能为空!"); returnMsg.Append("</PARAMETERS>"); returnMsg.Append("</PayPlatRequestParameter>"); } return(returnMsg.ToString()); } String bestPayAccount = String.Empty; try { BesttoneAccount _besttoneAccount_entity = _besttoneAccount_dao.QueryByCustID(CustID); if (_besttoneAccount_entity == null) { returnMsg.Length = 0; if ("json".Equals(wt)) { returnMsg.Append("{"); returnMsg.AppendFormat("\"errcode\":\"{0}\",", "997"); returnMsg.AppendFormat("\"errmsg\":\"{0}\"", "号码百事通账户未开通!"); returnMsg.Append("}"); } else { returnMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); returnMsg.Append("<PayPlatRequestParameter>"); returnMsg.Append("<PARAMETERS>"); returnMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "997"); returnMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "号码百事通账户未开通!"); returnMsg.Append("</PARAMETERS>"); returnMsg.Append("</PayPlatRequestParameter>"); } return(returnMsg.ToString()); } else { bestPayAccount = _besttoneAccount_entity.BestPayAccount; } List <TxnItem> list = new List <TxnItem>(); IList <TxnItem> list1, list2; Result = BesttoneAccountHelper.QueryAllTxnCurrentDay(bestPayAccount, out list1, out ErrMsg); Result = BesttoneAccountHelper.QueryAllTxnHistory(startDate, endDate, bestPayAccount, 10000, 1, out list2, out ErrMsg); if (list1 != null && list1.Count > 0) { foreach (TxnItem item in list1) { list.Add(item); } } if (list2 != null && list2.Count > 0) { foreach (TxnItem item in list2) { list.Add(item); } } //测试数据 //list = CreateTestList(); if (list != null && list.Count > 0) { list.Sort(); returnMsg.Length = 0; foreach (TxnItem item in list) { //如果是交易类型是“退货退还手续费”记录,则过滤掉不显示 if (item.TxnType == "261020") { continue; } String sign = "+"; String txnType = BesttoneAccountHelper.ConvertTxnType(item.TxnType); String flag = item.CancelFlag == "1" ? "已撤销" : "成功"; if (item.TxnType == "131090") { sign = "-"; } AccountRechargeRecord _recharge_redcord = _accountRechargeRecord_dao.QueryByTransactionID(item.AcceptSeqNO); returnMsg.Append("{"); returnMsg.AppendFormat("\"AcceptSeqNO\":\"{0}\",", item.AcceptSeqNO); returnMsg.AppendFormat("\"AcceptDate\":\"{0}\",", item.AcceptDate); returnMsg.AppendFormat("\"AcceptTime\":\"{0}\",", item.AcceptTime); returnMsg.AppendFormat("\"TxnAmount\":\"{0}\",", sign + BesttoneAccountHelper.ConvertAmountToYuan(item.TxnAmount)); returnMsg.AppendFormat("\"TxnType\":\"{0}\",", txnType); returnMsg.AppendFormat("\"TxnChannel\":\"{0}\",", item.TxnChannel); returnMsg.AppendFormat("\"MerchantName\":\"{0}\",", item.MerchantName); returnMsg.AppendFormat("\"TxnDscpt\":\"{0}\",", item.TxnDscpt); returnMsg.AppendFormat("\"CancelFlag\":\"{0}\",", flag); if (_recharge_redcord != null) { returnMsg.AppendFormat("\"OrderSeq\":\"{0}\",", _recharge_redcord.OrderSeq); } returnMsg.AppendFormat("\"TxnTime\":\"{0}\"", item.TxnTime); returnMsg.Append("},"); } returnMsg.Insert(0, "{\"errcode\":\"0\",\"errmsg\":\"\",\"txninfo\":["); returnMsg = returnMsg.Remove(returnMsg.Length - 1, 1); returnMsg.Append("]}"); } else { returnMsg.Append("{\"errcode\":\"-2012\",\"errmsg\":\"NoData\"}"); } } catch (Exception ex) { returnMsg.Append("{\"errcode\":\"-2013\",\"errmsg\":\"异常:" + ex.Message + "\"}"); } return(returnMsg.ToString()); }
/// <summary> /// 获取近三个月交易明细 /// </summary> protected String GetThreeMonthsHistoryDetails() { Int32 Result = ErrorDefinition.CIP_IError_Result_UnknowError_Code; String ErrMsg = ErrorDefinition.CIP_IError_Result_UnknowError_Msg; StringBuilder returnMsg = new StringBuilder(); DateTime startDate = new DateTime(DateTime.Now.AddMonths(-2).Year, DateTime.Now.AddMonths(-2).Month, 1); DateTime endDate = DateTime.Now; try { String bestPayAccount = Request["BestPayAccount"]; List <TxnItem> list = new List <TxnItem>(); IList <TxnItem> list1, list2; Result = BesttoneAccountHelper.QueryAllTxnCurrentDay(bestPayAccount, out list1, out ErrMsg); Result = BesttoneAccountHelper.QueryAllTxnHistory(startDate, endDate, bestPayAccount, 10000, 1, out list2, out ErrMsg); if (list1 != null && list1.Count > 0) { foreach (TxnItem item in list1) { list.Add(item); } } if (list2 != null && list2.Count > 0) { foreach (TxnItem item in list2) { list.Add(item); } } //测试数据 //list = CreateTestList(); if (list != null && list.Count > 0) { list.Sort(); foreach (TxnItem item in list) { //如果是交易类型是“退货退还手续费”记录,则过滤掉不显示 if (item.TxnType == "261020") { continue; } String sign = "+"; String txnType = BesttoneAccountHelper.ConvertTxnType(item.TxnType); String flag = item.CancelFlag == "1" ? "已撤销" : "成功"; if (item.TxnType == "131090") { sign = "-"; } AccountRechargeRecord _recharge_redcord = _accountRechargeRecord_dao.QueryByTransactionID(item.AcceptSeqNO); returnMsg.Append("{"); returnMsg.AppendFormat("\"AcceptSeqNO\":\"{0}\",", item.AcceptSeqNO); returnMsg.AppendFormat("\"AcceptDate\":\"{0}\",", item.AcceptDate); returnMsg.AppendFormat("\"AcceptTime\":\"{0}\",", item.AcceptTime); returnMsg.AppendFormat("\"TxnAmount\":\"{0}\",", sign + BesttoneAccountHelper.ConvertAmountToYuan(item.TxnAmount)); returnMsg.AppendFormat("\"TxnType\":\"{0}\",", txnType); returnMsg.AppendFormat("\"TxnChannel\":\"{0}\",", item.TxnChannel); returnMsg.AppendFormat("\"MerchantName\":\"{0}\",", item.MerchantName); returnMsg.AppendFormat("\"TxnDscpt\":\"{0}\",", item.TxnDscpt); returnMsg.AppendFormat("\"CancelFlag\":\"{0}\",", flag); if (_recharge_redcord != null) { returnMsg.AppendFormat("\"OrderSeq\":\"{0}\",", _recharge_redcord.OrderSeq); } returnMsg.AppendFormat("\"TxnTime\":\"{0}\"", item.TxnTime); returnMsg.Append("},"); } returnMsg.Insert(0, "{\"result\":\"true\",\"txninfo\":["); returnMsg = returnMsg.Remove(returnMsg.Length - 1, 1); returnMsg.Append("]}"); } else { returnMsg.Append("{\"result\":\"NoData\"}"); } } catch (Exception ex) { returnMsg.Append("{\"result\":\"false\",\"info\":\"异常:" + ex.Message + "\"}"); } return(returnMsg.ToString()); }