You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/Account/Controllers/Chfee_PayController.cs

739 lines
35 KiB
C#

5 months ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.Account.DAL.Chfee_Jinzhang;
using DSWeb.Areas.Account.Models.Chfee_jinzhang;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using DSWeb.Areas.CommMng.DAL;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.EntityDA;
using DSWeb.Areas.Account.Models.Chfee_Exrate;
using System.Data;
using DSWeb.Areas.Account.Models.Chfee_Pay;
using DSWeb.Areas.Account.DAL.Chfee_bankdata;
using System.IO;
using DSWeb.Areas.Account.Models.Chfee_Invoice;
using DSWeb.Areas.Account.Models.Chfee_Settlement;
using DSWeb.SoftMng.Filter;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using javax.crypto;
using System.Security.Cryptography;
using System.Text;
using System.Collections.Specialized;
using DSWeb.MvcShipping.DAL.OP_SERVICEBILLDAL;
using DSWeb.Areas.Dispatch.Helper;
using NPOI.SS.Formula.Functions;
using DSWeb.MvcShipping.DAL.MsSeaeOrderDAL;
using DSWeb.Areas.Account.DAL.Chfee_Pay;
using DSWeb.MvcShipping.Models.MsChFee;
using DSWeb.Areas.Account.DAL.Chfee_Settlement;
using DSWeb.Areas.Account.Models.Chfee_Payapplication;
using DSWeb.Areas.Account.Models.Chfee_payapplication;
using System.Web;
using java.nio.file;
4 months ago
using DSWeb.MvcShipping.DAL.MsCompanysDAL;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.Models.WMSNew;
using com.sun.org.apache.bcel.@internal.classfile;
//using Spire.Pdf.Graphics;
using System.Drawing.Imaging;
using System.Drawing;
using PdfiumViewer;
5 months ago
namespace DSWeb.Areas.Account.Controllers
{
[JsonRequestBehavior]
public class Chfee_PayController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
public ActionResult StlIndex()
{
return View();
}
public ActionResult StlMateIndex()
{
return View();
}
//
// GET
#region
//[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
//public ContentResult GetDataList(int start, int limit, string sort, string condition)
//{
// var dataList = ChBankdataDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort);
// var list = dataList.Skip(start).Take(limit);
// var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
// return new ContentResult() { Content = json };
//}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult CreatePay(string GID)
{
DBResult result = new DBResult();
var HeadData = ChsettlementDAL.GetData("GID='" + GID + "'");
4 months ago
if (HeadData.PAYSTATUS == "提交支付"|| HeadData.PAYSTATUS == "支付完成")
5 months ago
{
var jsonRespose = new JsonResponse { Success = false, Message = "当前状态不允许生成支付!",Data="0" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var CompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select FULLNAME from [company] where GID='" + Convert.ToString(Session["COMPANYID"]).ToString().Trim() + "'");
var PayCompanyList = ChPayDAL.GetDataList("", CompanyName);
if (PayCompanyList == null || PayCompanyList.Count == 0)
{
var jsonRespose = new JsonResponse { Success = false, Message = "没有注册信息无法支付!", Data = "1" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var CompanyFunName = T_ALL_DA.GetStrSQL("FULLNAME", "select [DESCRIPTION] FULLNAME from [info_client] where [SHORTNAME]='" + HeadData.CUSTOMERNAME + "'");
var newChPaymentFrom = new ChPaymentFrom();
newChPaymentFrom.Username = PayCompanyList[0].Username;
newChPaymentFrom.PayeeCompanyName = CompanyFunName;
newChPaymentFrom.PayeeCompanyAccount = HeadData.CUSTACCOUNT;
newChPaymentFrom.PayAmount = HeadData.AMOUNT;
newChPaymentFrom.PAYGID = GID;
newChPaymentFrom.PAYBILLNO = HeadData.BILLNO;
//newChPaymentFrom.SwiftCode = headData.SwiftCode;
//newChPaymentFrom.BankName = headData.BankName;
//newChPaymentFrom.BankId = headData.BankId;
//newChPaymentFrom.IsAcrossBank = headData.IsAcrossBank;
//newChPaymentFrom.IsQuickPay = headData.IsQuickPay;
//newChPaymentFrom.IsPartialPayment = headData.IsPartialPayment;
//newChPaymentFrom.IsCNYPay = headData.IsCNYPay;
//newChPaymentFrom.InvoiceFileNum = headData.InvoiceFileNum;
//newChPaymentFrom.BankBranchName = headData.BankBranchName;
//newChPaymentFrom.PayRemark = headData.PayRemark;
//newChPaymentFrom.CallBackUrl = headData.CallBackUrl;
//newChPaymentFrom.IsCNYPay = headData.IsCNYPay;
result.Success = true;
var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message,Data= newChPaymentFrom });
return new ContentResult() { Content = json };
}
4 months ago
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult CreateReg(string GID)
{
DBResult result = new DBResult();
var company = MsCompanysDAL.GetNoPicData("GID='"+ Convert.ToString(Session["COMPANYID"]).ToString().Trim() + "'");
var newChPaymentFrom = new ChRegisterFrom();
newChPaymentFrom.CompanyName = company.FULLNAME;
newChPaymentFrom.CompanyCode= company.TAXCODE;
newChPaymentFrom.CompanyAddress = company.ADDRESS;
newChPaymentFrom.ContactName = Convert.ToString(Session["SHOWNAME"]);
newChPaymentFrom.Email = company.EMAIL;
newChPaymentFrom.Phone = company.OFFICEPHONE;
var bankList = MsBaseInfoDAL.GetBANKList("", Convert.ToString(Session["COMPANYID"]).ToString().Trim());
if (bankList != null && bankList.Count != 0)
{
foreach (var bank in bankList)
{
if ((bank.CURRENCY == "USD" && (bank.ISDEF == "True"))){
newChPaymentFrom.CompanyBank = bank.BANKNAME;
newChPaymentFrom.CompanyAccount = bank.ACCOUNT;
}
}
}
5 months ago
4 months ago
result.Success = true;
var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message, Data = newChPaymentFrom });
return new ContentResult() { Content = json };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult CreateUrl(string GID)
{
DBResult result = new DBResult();
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var dspayid=MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
var DSPAYUSERNAME = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYUSERNAME'").PARAMVALUE;
var url = payUrl + "/User/SetDRACCNOList?AppId=" + dspayid + "&UserName=" + DSPAYUSERNAME;
result.Success = true;
var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message, Data = url });
return new ContentResult() { Content = json };
}
5 months ago
public ContentResult GetPayCityList()
{
DBResult result = new DBResult();
var Timestamp = ConvertDateTimeToInt(DateTime.Now);
var NonceStr = Guid.NewGuid().ToString().Replace("-", "");
if (NonceStr.Length > 32) NonceStr = NonceStr.Substring(0, 32);
var NewPayGet = new PayGet();
NewPayGet.AppId=MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
NewPayGet.ApiSerialNo= Guid.NewGuid().ToString();
var secretKey= MsSysParamSetDAL.GetData("PARAMNAME='DSPAYKEY'").PARAMVALUE;
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(NewPayGet);
var Signature = signatureGet(jsonstr, NonceStr, Timestamp.ToString(), secretKey);
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicData.Add("Signature", Signature);
dicData.Add("Timestamp", Timestamp.ToString());
dicData.Add("NonceStr", NonceStr);
BasicDataRefDAL.SaveLog(jsonstr, "admin", "快付获取城市列表", "发送");
var rtn = WebRequestHelper.DoPostHead(payUrl+ "/api/GetCityList", dicData, jsonstr);
var _rd = JsonConvert.Deserialize<JosnPayGetCity>(rtn);
BasicDataRefDAL.SaveLog(rtn, "", "快付获取城市列表", "返回");
result.Success = _rd.Code == 0;
result.Message = _rd.Msg;
var CityList = _rd.Data;
var jsonRespose = new jsonresponse { success = result.Success, message = result.Message, data = CityList.ToList() };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetPayBankList()
{
DBResult result = new DBResult();
var Timestamp = ConvertDateTimeToInt(DateTime.Now);
var NonceStr = Guid.NewGuid().ToString().Replace("-", "");
if (NonceStr.Length > 32) NonceStr = NonceStr.Substring(0, 32);
var NewPayGet = new PayGet();
NewPayGet.AppId = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
NewPayGet.ApiSerialNo = Guid.NewGuid().ToString();
var secretKey = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYKEY'").PARAMVALUE;
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(NewPayGet);
var Signature = signatureGet(jsonstr, NonceStr, Timestamp.ToString(), secretKey);
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicData.Add("Signature", Signature);
dicData.Add("Timestamp", Timestamp.ToString());
dicData.Add("NonceStr", NonceStr);
BasicDataRefDAL.SaveLog(jsonstr, "admin", "快付获取银行列表", "发送");
var rtn = WebRequestHelper.DoPostHead(payUrl + "/api/GetBankList", dicData, jsonstr);
var _rd = JsonConvert.Deserialize<JosnPayGetBank>(rtn);
BasicDataRefDAL.SaveLog(rtn, "", "快付获取银行列表", "返回");
result.Success = _rd.Code == 0;
result.Message = _rd.Msg;
var CityList = _rd.Data;
var jsonRespose = new jsonresponse { success = result.Success, message = result.Message, data = CityList.ToList() };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetCompanyIsPay()
{
DBResult result = new DBResult();
var Timestamp = ConvertDateTimeToInt(DateTime.Now);
var NonceStr = Guid.NewGuid().ToString().Replace("-", "");
if (NonceStr.Length > 32) NonceStr = NonceStr.Substring(0,32);
var NewPayGet = new PayGetCompany();
NewPayGet.AppId = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
NewPayGet.ApiSerialNo = Guid.NewGuid().ToString();
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var CompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select FULLNAME from [company] where GID='" + Convert.ToString(Session["COMPANYID"]).ToString().Trim() + "'");
NewPayGet.CompanyName = CompanyName;
var secretKey = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYKEY'").PARAMVALUE;
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(NewPayGet);
var Signature = signatureGet(jsonstr, NonceStr, Timestamp.ToString(), secretKey);
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicData.Add("Signature", Signature);
dicData.Add("Timestamp", Timestamp.ToString());
dicData.Add("NonceStr", NonceStr);
BasicDataRefDAL.SaveLog(jsonstr, "admin", "快付验证公司", "发送");
var rtn = WebRequestHelper.DoPostHead(payUrl + "/api/CompanyRegistered", dicData, jsonstr);
var _rd = JsonConvert.Deserialize<PayGetIsCompany>(rtn);
BasicDataRefDAL.SaveLog(rtn, "", "快付验证公司", "返回");
result.Success = _rd.Code == 0;
result.Message = _rd.Msg;
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SendReg(string data)
{
var headData = JsonConvert.Deserialize<ChRegisterFrom>(data);
var localurl = System.Web.HttpContext.Current.Request.Url.Host;
var DSPAYUSERNAME = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYUSERNAME'").PARAMVALUE;
var newPaymentFrom = new RegisterFrom();
newPaymentFrom.AppId = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
4 months ago
newPaymentFrom.Username = headData.Username;
newPaymentFrom.Password = MD5Encrypt32(headData.Password);
newPaymentFrom.PayPassword = MD5Encrypt32(headData.PayPassword);
5 months ago
newPaymentFrom.ContactName = headData.ContactName;
newPaymentFrom.Phone = headData.Phone;
newPaymentFrom.City = headData.City;
newPaymentFrom.CompanyName = headData.CompanyName;
newPaymentFrom.CompanyCode = headData.CompanyCode;
newPaymentFrom.CompanyAddress = headData.CompanyAddress;
newPaymentFrom.CompanyBank = headData.CompanyBank;
newPaymentFrom.CompanyAccount = headData.CompanyAccount;
newPaymentFrom.Email = headData.Email;
newPaymentFrom.LegalName = headData.LegalName;
4 months ago
if (!string.IsNullOrEmpty(headData.ValidatePassword))
4 months ago
newPaymentFrom.ValidatePassword = MD5Encrypt32(headData.ValidatePassword);
5 months ago
newPaymentFrom.ApiSerialNo = Guid.NewGuid().ToString();
DBResult result = new DBResult();
var Timestamp = ConvertDateTimeToInt(DateTime.Now);
var NonceStr = Guid.NewGuid().ToString().Replace("-", "");
if (NonceStr.Length > 32) NonceStr = NonceStr.Substring(0, 32);
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var CompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select FULLNAME from [company] where GID='" + Convert.ToString(Session["COMPANYID"]).ToString().Trim() + "'");
var secretKey = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYKEY'").PARAMVALUE;
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(newPaymentFrom);
var Signature = signatureGet(jsonstr, NonceStr, Timestamp.ToString(), secretKey);
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicData.Add("Signature", Signature);
dicData.Add("Timestamp", Timestamp.ToString());
dicData.Add("NonceStr", NonceStr);
4 months ago
BasicDataRefDAL.SaveLog(jsonstr, "admin", "快付发起公司注册", "发送");
var rtn = WebRequestHelper.DoPostHead(payUrl + "/api/RegisterFromApi", dicData, jsonstr);
5 months ago
4 months ago
var _rd = JsonConvert.Deserialize<RegResult>(rtn);
BasicDataRefDAL.SaveLog(rtn, "", "快付发起公司注册", "返回");
if (_rd.Code == 0)
{
var blUpSQL = " update sys_param_set set PARAMVALUE='" + headData.Username + "' WHERE GID='99F5C3F6-FE80-4401-9C0E-3B5312320F26'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
headData.AppId = newPaymentFrom.AppId;
headData.ApiSerialNo = newPaymentFrom.ApiSerialNo;
headData.GID = NonceStr;
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.CREATEUSER = Convert.ToString(Session["USERID"]).ToString().Trim();
headData.DbOperationType = DbOperationType.DbotIns;
var modb = new ModelObjectDB();
var ss=modb.Save(headData);
var msgstr = "";
if (_rd.Data.IsRecharged == 0)
{
if (_rd.Data.IsNewUser == 0)
{
msgstr = "老客户未充值!";
}
else
{
msgstr = "新客户未充值!";
}
}
if (_rd.Data.RegistrationInfo.IsRegisteredUSDOne == 0)
{
msgstr = msgstr + "美金第一账户未备案";
}
result.Success = _rd.Code == 0;
result.Message = msgstr;
}
else
{
result.Success =false;
result.Message = _rd.Msg;
}
5 months ago
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SendPay(string data,string filedata)
{
var headData = JsonConvert.Deserialize<ChPaymentFrom>(data);
4 months ago
var HeadData = ChsettlementDAL.GetData("GID='" + headData.PAYGID + "'");
if (HeadData.PAYSTATUS == "提交支付" || HeadData.PAYSTATUS == "支付完成")
{
var jsonRespose3 = new JsonResponse { Success = false, Message = "当前状态不允许生成支付!", Data = "0" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose3) };
}
5 months ago
var filelist = JsonConvert.Deserialize<List<ChfeeFile>>(filedata);
4 months ago
var localurl = "http://"+System.Web.HttpContext.Current.Request.Url.Authority;
5 months ago
var DSPAYUSERNAME = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYUSERNAME'").PARAMVALUE;
4 months ago
var path = Server.MapPath("../../UploadFiles/MsOpFiles/TmpInv");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
5 months ago
var InvFiles = new List<InvFiles>();
foreach (var invfile in filelist) {
4 months ago
if (System.IO.File.Exists(invfile.File_Path))
{
var fileExt = System.IO.Path.GetExtension(invfile.File_Path);
if (fileExt == ".pdf")
{
string randomFileName = System.IO.Path.GetRandomFileName().Replace(".", "");
var destinationFile = path + "/" + randomFileName + ".pdf";
System.IO.File.Copy(invfile.File_Path, destinationFile);
var file = new InvFiles();
file.Path = localurl + "/UploadFiles/MsOpFiles/TmpInv/" + randomFileName + ".pdf" + "?a=23451";
file.fileExtension = "pdf";
InvFiles.Add(file);
using (var document = PdfiumViewer.PdfDocument.Load(invfile.File_Path))
{
for (int pageIndex = 0; pageIndex < document.PageCount; pageIndex++)
{
var pageImage = document.Render(pageIndex, 500, 500, true); // 300 dpi
string randomImgFileName = System.IO.Path.GetRandomFileName().Replace(".", "");
var destinationImgFile = path + "/" + randomImgFileName + ".jpg";
pageImage.Save(destinationImgFile, System.Drawing.Imaging.ImageFormat.Jpeg);
var file2 = new InvFiles();
file2.Path = localurl + "/UploadFiles/MsOpFiles/TmpInv/" + randomImgFileName + ".jpg" + "?a=23451";
file2.fileExtension = "jpg";
InvFiles.Add(file2);
}
}
//Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
//doc.LoadFromFile(invfile.File_Path);
//doc.Pages.Insert(0);
//for (var i = 0; i < doc.Pages.Count; i++)
//{
// Image image = doc.SaveAsImage(i, PdfImageType.Bitmap, 500, 500);
// string randomImgFileName = System.IO.Path.GetRandomFileName().Replace(".", "");
// var destinationImgFile = path + "/" + randomImgFileName + ".jpg";
// image.Save(destinationImgFile, ImageFormat.Jpeg);
// if (i != 0)
// {
// var file2 = new InvFiles();
// file2.Path = localurl + "/UploadFiles/MsOpFiles/TmpInv/" + randomImgFileName + ".jpg" + "?a=23451";
// file2.fileExtension = "jpg";
// InvFiles.Add(file2);
// }
//}
}
else {
var jsonRespose2 = new JsonResponse { Success =false, Message ="发票文件请上传pdf文件" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
5 months ago
}
var newPaymentFrom = new PaymentFrom();
newPaymentFrom.AppId = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
newPaymentFrom.Username = DSPAYUSERNAME;
newPaymentFrom.PayeeCompanyName = headData.PayeeCompanyName;
newPaymentFrom.PayeeCompanyAccount = headData.PayeeCompanyAccount;
newPaymentFrom.PaymentAmount =Convert.ToInt32(headData.PayAmount*100);
if (headData.IsAcrossBank == 0)
{
newPaymentFrom.SwiftCode ="";
4 months ago
newPaymentFrom.BankName ="中国银行";
4 months ago
newPaymentFrom.BankId =5;
5 months ago
}
else
{
newPaymentFrom.SwiftCode = headData.SwiftCode;
newPaymentFrom.BankName = headData.BankName;
newPaymentFrom.BankId = headData.BankId;
}
newPaymentFrom.IsAcrossBank = headData.IsAcrossBank;
newPaymentFrom.IsQuickPay = headData.IsQuickPay;
newPaymentFrom.IsPartialPayment = headData.IsPartialPayment;
newPaymentFrom.IsCNYPay = headData.IsCNYPay;
newPaymentFrom.InvoiceFileNum = filelist.Count;
newPaymentFrom.BankBranchName = headData.BankBranchName;
newPaymentFrom.PayRemark = headData.PayRemark;
newPaymentFrom.CallBackUrl = localurl+ "/Dispatch/Dispatch/PaymentCallback";
newPaymentFrom.IsCNYPay = headData.IsCNYPay;
newPaymentFrom.ApiSerialNo = Guid.NewGuid().ToString();
newPaymentFrom.Files = InvFiles;
DBResult result = new DBResult();
var Timestamp = ConvertDateTimeToInt(DateTime.Now);
var NonceStr = Guid.NewGuid().ToString().Replace("-", "");
if (NonceStr.Length > 32) NonceStr = NonceStr.Substring(0, 32);
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var CompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select FULLNAME from [company] where GID='" + Convert.ToString(Session["COMPANYID"]).ToString().Trim() + "'");
var secretKey = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYKEY'").PARAMVALUE;
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(newPaymentFrom);
var Signature = signatureGet(jsonstr, NonceStr, Timestamp.ToString(), secretKey);
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicData.Add("Signature", Signature);
dicData.Add("Timestamp", Timestamp.ToString());
dicData.Add("NonceStr", NonceStr);
BasicDataRefDAL.SaveLog(jsonstr, "admin", "快付发起支付", "发送");
var rtn = WebRequestHelper.DoPostHead(payUrl + "/api/PaymentFromApi", dicData, jsonstr);
var _rd = JsonConvert.Deserialize<PaymentResult>(rtn);
BasicDataRefDAL.SaveLog(rtn, "", "快付发起支付", "返回");
if (_rd.Code == 0) {
var blUpSQL = " update ch_fee_settlement set PAYID='"+ _rd.Data.SerialNo+ "',PAYSTATUS='提交付费' WHERE GID='" + headData.PAYGID+ "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
headData.GID = NonceStr;
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.CREATEUSER = Convert.ToString(Session["USERID"]).ToString().Trim();
headData.DbOperationType = DbOperationType.DbotIns;
var modb = new ModelObjectDB();
modb.Save(headData);
}
result.Success = _rd.Code == 0;
result.Message = _rd.Msg;
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
4 months ago
public ContentResult SendBankRecord()
{
var GID = Guid.NewGuid().ToString().Replace("-", "");
if (GID.Length > 32) GID = GID.Substring(0, 32);
var NonceStr = Guid.NewGuid().ToString().Replace("-", "");
if (NonceStr.Length > 32) NonceStr = NonceStr.Substring(0, 32);
var DSPAYUSERNAME = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYUSERNAME'").PARAMVALUE;
var newPaymentFrom = new Bankrecord();
newPaymentFrom.AppId = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
newPaymentFrom.Username = DSPAYUSERNAME;
newPaymentFrom.SerialNo = GID;
newPaymentFrom.BankCode ="0000";
newPaymentFrom.BankMsg = "";
newPaymentFrom.Username = "ds_hxt";
newPaymentFrom.CompanyName = "青岛东胜伟业软件有限公司";
newPaymentFrom.RegistrationType = 0;
newPaymentFrom.ApiSerialNo = NonceStr;
DBResult result = new DBResult();
var Timestamp = ConvertDateTimeToInt(DateTime.Now);
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var CompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select FULLNAME from [company] where GID='" + Convert.ToString(Session["COMPANYID"]).ToString().Trim() + "'");
var secretKey = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYKEY'").PARAMVALUE;
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(newPaymentFrom);
var Signature = signatureGet(jsonstr, NonceStr, Timestamp.ToString(), secretKey);
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicData.Add("Signature", Signature);
dicData.Add("Timestamp", Timestamp.ToString());
dicData.Add("NonceStr", NonceStr);
BasicDataRefDAL.SaveLog(jsonstr, "admin", "快付发起备案", "发送");
var rtn = WebRequestHelper.DoPostHead(payUrl + "/api/ManualBankRecordCallback", dicData, jsonstr);
var _rd = JsonConvert.Deserialize<PaymentResult>(rtn);
BasicDataRefDAL.SaveLog(rtn, "", "快付发起备案", "返回");
result.Success = _rd.Code == 0;
result.Message = _rd.Msg;
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
4 months ago
public ContentResult SendPayReCharge()
{
var GID = Guid.NewGuid().ToString().Replace("-", "");
if (GID.Length > 32) GID = GID.Substring(0, 32);
var NonceStr = Guid.NewGuid().ToString().Replace("-", "");
if (NonceStr.Length > 32) NonceStr = NonceStr.Substring(0, 32);
var DSPAYUSERNAME = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYUSERNAME'").PARAMVALUE;
var newPaymentFrom = new PayReCharge();
newPaymentFrom.AppId = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
newPaymentFrom.Username = DSPAYUSERNAME;
newPaymentFrom.RechargeCode = "0000";
newPaymentFrom.RechargeAmount =10000;
newPaymentFrom.Username = "ds_hxt";
newPaymentFrom.CompanyName = "青岛东胜伟业软件有限公司";
newPaymentFrom.RechargePackage = "111";
newPaymentFrom.ApiSerialNo = NonceStr;
newPaymentFrom.RechargeStartTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");
newPaymentFrom.RechargeEndTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");
newPaymentFrom.RechargeTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");
DBResult result = new DBResult();
var Timestamp = ConvertDateTimeToInt(DateTime.Now);
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var CompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select FULLNAME from [company] where GID='" + Convert.ToString(Session["COMPANYID"]).ToString().Trim() + "'");
var secretKey = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYKEY'").PARAMVALUE;
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(newPaymentFrom);
var Signature = signatureGet(jsonstr, NonceStr, Timestamp.ToString(), secretKey);
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicData.Add("Signature", Signature);
dicData.Add("Timestamp", Timestamp.ToString());
dicData.Add("NonceStr", NonceStr);
BasicDataRefDAL.SaveLog(jsonstr, "admin", "快付发起备案", "发送");
var rtn = WebRequestHelper.DoPostHead(payUrl + "/api/ManualBankRecordCallback", dicData, jsonstr);
var _rd = JsonConvert.Deserialize<PaymentResult>(rtn);
BasicDataRefDAL.SaveLog(rtn, "", "快付发起备案", "返回");
result.Success = _rd.Code == 0;
result.Message = _rd.Msg;
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SendPaymentCallBack()
{
var GID = Guid.NewGuid().ToString().Replace("-", "");
if (GID.Length > 32) GID = GID.Substring(0, 32);
var NonceStr = Guid.NewGuid().ToString().Replace("-", "");
if (NonceStr.Length > 32) NonceStr = NonceStr.Substring(0, 32);
var DSPAYUSERNAME = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYUSERNAME'").PARAMVALUE;
var newPaymentFrom = new PaymentCallBack();
newPaymentFrom.AppId = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYID'").PARAMVALUE;
newPaymentFrom.SerialNo = "ff5beca2-85aa-4c02-830c-e40c5cd51214";
newPaymentFrom.BankCode = "0000";
newPaymentFrom.ChargeAmount = 30000;
newPaymentFrom.BankMsg = "111";
newPaymentFrom.ApiSerialNo = NonceStr;
newPaymentFrom.CallbackUrl = "http://47.104.102.13:8081/Dispatch/Dispatch/PaymentCallback";
DBResult result = new DBResult();
var Timestamp = ConvertDateTimeToInt(DateTime.Now);
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var CompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select FULLNAME from [company] where GID='" + Convert.ToString(Session["COMPANYID"]).ToString().Trim() + "'");
var secretKey = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYKEY'").PARAMVALUE;
var payUrl = MsSysParamSetDAL.GetData("PARAMNAME='DSPAYURL'").PARAMVALUE;
var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(newPaymentFrom);
var Signature = signatureGet(jsonstr, NonceStr, Timestamp.ToString(), secretKey);
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicData.Add("Signature", Signature);
dicData.Add("Timestamp", Timestamp.ToString());
dicData.Add("NonceStr", NonceStr);
BasicDataRefDAL.SaveLog(jsonstr, "admin", "快付发起备案", "发送");
var rtn = WebRequestHelper.DoPostHead(payUrl + "/api/ManualBankRecordCallback", dicData, jsonstr);
var _rd = JsonConvert.Deserialize<PaymentResult>(rtn);
BasicDataRefDAL.SaveLog(rtn, "", "快付发起备案", "返回");
result.Success = _rd.Code == 0;
result.Message = _rd.Msg;
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
5 months ago
public static long ConvertDateTimeToInt(System.DateTime time)
{
long t = (time.Ticks - 621356256000000000) / 10000;
return t;
}
public static string signatureGet(string bodyJson, string noncestr, string timestamp, string secretKey)
{
string singature = string.Empty;
string md5str = $"{bodyJson}NonceStr={noncestr}Timestamp={timestamp}{secretKey}";
singature = MD5Encrypt32(md5str);
return singature;
}
public static string MD5Encrypt32(string password)
{
string cl = password;
string pwd = "";
MD5 md5 = MD5.Create(); //实例化一个md5对像
// 加密后是一个字节类型的数组这里要注意编码UTF8/Unicode等的选择 
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(cl));
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
for (int i = 0; i < s.Length; i++)
{
// 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母如果使用大写X则格式后的字符是大写字符
pwd = pwd + s[i].ToString("x2");
}
return pwd;
}
#endregion
#region 参照部分
#endregion
}
}