string cpyUrl = "http://payment-test.chinapay.com/pay/TransGet"; //测试地址,测试的时候用这个地址,应用到网站时用下面那个地址 #endregion Fields #region Constructors /// <summary> /// 构造函数,必须提供银联接口系统级参数 /// </summary> /// <remarks> /// </remarks> public BaseAPI(LiveEntities entity, FinancePayType payType) : base(entity) { this.dbEntity = entity; this.oPayType = payType; this.oConfig = oPayType.Config; }
/// <summary> /// 添加支付方式页面 /// </summary> /// <returns></returns> public ActionResult AddPayType() { if (base.GetProgramNode("EnableEdit") == "1") { FinancePayType oPayType = new FinancePayType { Name = NewResource(ModelEnum.ResourceType.STRING) }; ViewBag.organization = GetOrganizationList(); ViewBag.isCod = SelectEnumList(oPayType.IsCod); ViewBag.isOnline = SelectEnumList(oPayType.IsOnline); ViewBag.payStatus = GetPayState(oPayType); return PartialView(oPayType); } return RedirectToAction("ErrorPage", "Home", new { message = LiveAzure.Resource.Common.NoPermission }); }
/// <summary> /// 导入支付方式 /// </summary> /// <param name="sExcelFile">Excel文件名</param> /// <param name="sSheetName">Sheet名</param> public void ImportPaymentType(string sExcelFile, string sSheetName) { try { ExcelData oExcel = new ExcelData(sExcelFile, sSheetName); DataColumn colOrgan = oExcel.ExcelTable.Columns["组织"]; DataColumn colCode = oExcel.ExcelTable.Columns["代码"]; DataColumn colNameCN = oExcel.ExcelTable.Columns["中文名称"]; DataColumn colNameUS = oExcel.ExcelTable.Columns["英文名称"]; DataColumn colMatter = oExcel.ExcelTable.Columns["简单描述"]; DataColumn colStatus = oExcel.ExcelTable.Columns["状态"]; DataColumn colSorting = oExcel.ExcelTable.Columns["排序"]; DataColumn colIsCod = oExcel.ExcelTable.Columns["货到付款"]; DataColumn colIsOnline = oExcel.ExcelTable.Columns["在线支付"]; DataColumn colIsSecured = oExcel.ExcelTable.Columns["担保交易"]; DataColumn colFee = oExcel.ExcelTable.Columns["手续费率"]; DataColumn colConfig = oExcel.ExcelTable.Columns["配置密钥"]; DataColumn colRemark = oExcel.ExcelTable.Columns["备注"]; foreach (DataRow row in oExcel.ExcelTable.Rows) { string sOrganCode = row[colOrgan].ToString(); var oOrgan = (from o in dbEntity.MemberOrganizations where o.Code == sOrganCode && o.Otype == (byte)ModelEnum.OrganizationType.CORPORATION select o).FirstOrDefault(); string sCode = row[colCode].ToString(); GeneralResource oName = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colNameCN].ToString(), 1033, row[colNameUS].ToString()); string sMatter = row[colMatter].ToString(); byte nStatus; Byte.TryParse(row[colStatus].ToString(), out nStatus); int nSorting; Int32.TryParse(row[colSorting].ToString(), out nSorting); bool bIsCod = (row[colIsCod].ToString() == "1") ? true : false; bool bIsOnline = (row[colIsOnline].ToString() == "1") ? true : false; bool bIsSecured = (row[colIsSecured].ToString() == "1") ? true : false; decimal mFee; Decimal.TryParse(row[colFee].ToString(), out mFee); string sConfig = row[colConfig].ToString(); string sRemark = row[colRemark].ToString(); var oPayType = (from t in dbEntity.FinancePayTypes where t.OrgID == oOrgan.Gid && t.Code == sCode select t).FirstOrDefault(); if (oPayType == null) { oPayType = new FinancePayType { Organization = oOrgan, Code = sCode }; dbEntity.FinancePayTypes.Add(oPayType); } if (oPayType.Name == null) oPayType.Name = oName; else oPayType.Name.SetResource(ModelEnum.ResourceType.STRING, oName); oPayType.Matter = sMatter; oPayType.Pstatus = nStatus; oPayType.Sorting = nSorting; oPayType.IsCod = bIsCod; oPayType.IsOnline = bIsOnline; oPayType.IsSecured = bIsSecured; oPayType.Fee = mFee; oPayType.Config = sConfig; oPayType.Remark = sRemark; dbEntity.SaveChanges(); if (Utility.ConfigHelper.GlobalConst.IsDebug) Debug.WriteLine("{0} {1} {2}", this.ToString(), sCode, sRemark); } oEventBLL.WriteEvent(String.Format("导入FinancePayType成功: {0} {1}", sExcelFile, sSheetName), ModelEnum.ActionLevel.GENERIC, ModelEnum.ActionSource.SYSTEM, this.ToString()); } catch (Exception ex) { oEventBLL.WriteEvent(String.Format("导入FinancePayType错误: {0} {1} {2}", sExcelFile, sSheetName, ex.Message), ModelEnum.ActionLevel.ERROR, ModelEnum.ActionSource.SYSTEM, this.ToString()); } }
/// <summary> /// 测试ProductOnPayment /// </summary> /// <returns>新建的ProductOnPayment对象</returns> public ProductOnPayment ProductOnPaymentTest() { MemberOrganization oOrg = new MemberOrganization { Code = GetRandCode() }; oLiveEntities.MemberOrganizations.Add(oOrg); FinancePayType oFinancePayType = new FinancePayType { Organization = oOrg, Code = GetRandCode() }; oLiveEntities.FinancePayTypes.Add(oFinancePayType); ProductOnPayment oProductOnPayment = new ProductOnPayment { OnSale = ProductOnSaleTest(), PayType = oFinancePayType }; oLiveEntities.ProductOnPayments.Add(oProductOnPayment); oLiveEntities.SaveChanges(); return oProductOnPayment; }
/// <summary> /// 保存编辑的支付方式 /// </summary> /// <param name="newPayType"></param> public void SavePayType(FinancePayType newPayType) { try { FinancePayType oldPayType = dbEntity.FinancePayTypes.Where(f => f.Gid == newPayType.Gid).Single(); oldPayType.OrgID = newPayType.OrgID; oldPayType.Code = newPayType.Code; oldPayType.Name.SetResource(ModelEnum.ResourceType.STRING, newPayType.Name); oldPayType.Matter = newPayType.Matter; oldPayType.Pstatus = newPayType.Pstatus; oldPayType.Sorting = newPayType.Sorting; oldPayType.IsCod = newPayType.IsCod; oldPayType.IsOnline = newPayType.IsOnline; oldPayType.Fee = newPayType.Fee; oldPayType.Config = newPayType.Config; oldPayType.Remark = newPayType.Remark; if (ModelState.IsValid) { dbEntity.Entry(oldPayType).State = EntityState.Modified; dbEntity.SaveChanges(); } } catch (Exception ex) { RedirectToAction("ErrorPage", "Home", new { message = ex.Message }); } }
/// <summary> /// 保存添加的支付方式 /// </summary> /// <param name="newPayType"></param> public void SaveNewPayType(FinancePayType newPayType) { try { dbEntity.FinancePayTypes.Add(newPayType); dbEntity.SaveChanges(); } catch (Exception ex) { RedirectToAction("ErrorPage", "Home", new { message = ex.Message }); } }
/// <summary> /// 获取支付状态列表 /// </summary> /// <param name="oPayType"></param> /// <returns></returns> private List<SelectListItem> GetPayState(FinancePayType oPayType) { var oPayState = base.SelectEnumList(typeof(ModelEnum.PointStatus), oPayType.Pstatus); return oPayState; }