using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using DSWebMobileService.Common;
using DSWeb.Areas.Account.DAL.Chfee_Payapplication;
using DSWeb.Areas.Account.Models.Chfee_Payapplication;
using Newtonsoft.Json;
using HcUtility.Comm;
namespace DSWebMobile.Handler
{
///
/// Payment 的摘要说明
///
public class Payment : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
string action = context.Request.QueryString["action"].ToString();
switch (action)
{
case "0":
GetDataList(context);
break;
case "1":
GetDataInfo(context);
break;
case "2":
GetDataDetailList(context);
break;
case "3":
//GetDataBalanceList(context);
break;
case "4":
SubmitAudit(context);
break;
case "5":
SubmitAuditBack(context);
break;
case "6":
//GetReason(context);
break;
}
}
private void SubmitAuditBack(HttpContext context)
{
string relGID = "";
//string relReason = "";
string id = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["gid"].ToString());
//string reason = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["r"].ToString());
string pattern = "\0";
string replacement = "";
Regex rgx = new Regex(pattern);
relGID = rgx.Replace(id, replacement);
//relReason = rgx.Replace(reason, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relGID = rgx2.Replace(relGID, relGID);
//relReason = rgx2.Replace(relReason, relReason);
List dataList = ChpayapplicationDAL.GetAuditDataList("", Convert.ToString(SessionUtil.Session["USERID"]), "", Convert.ToString(SessionUtil.Session["UserName"]), Convert.ToString(SessionUtil.Session["COMPANYID"]), "");
//List list = dataList.Where(p => p.GID == relGID);
List listPay = new List();
ChPayapplication listItem = new ChPayapplication();
foreach (ChPayapplication temp in dataList)
{
if (temp.GID == relGID)
{
listItem.BILLNO = temp.BILLNO;
listItem.BILLSTATUS = temp.BILLSTATUS;
listPay.Add(listItem);
}
}
//List result = //JsonConvert.SerializeObject(list);
DBResult result = ChpayapplicationDAL.AuditBackList(listPay, SessionUtil.Session["USERID"].ToString());
StringBuilder sb = new StringBuilder();
if (!result.Success) { sb.Append("[{\"result\":\"fail\"}]"); }
else { sb.Append("[{\"result\":\"success\"}]"); }
context.Response.ContentType = "text/plain";
context.Response.Write(sb.ToString());
context.Response.End();
}
private void SubmitAudit(HttpContext context)
{
string relGID = "";
//string relReason = "";
string id = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["gid"].ToString());
//string reason = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["r"].ToString());
string pattern = "\0";
string replacement = "";
Regex rgx = new Regex(pattern);
relGID = rgx.Replace(id, replacement);
//relReason = rgx.Replace(reason, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relGID = rgx2.Replace(relGID, relGID);
//relReason = rgx2.Replace(relReason, relReason);
List dataList = ChpayapplicationDAL.GetAuditDataList("", Convert.ToString(SessionUtil.Session["USERID"]), "", Convert.ToString(SessionUtil.Session["UserName"]), Convert.ToString(SessionUtil.Session["COMPANYID"]), "");
//List list = dataList.Where(p => p.GID == relGID);
List listPay = new List();
ChPayapplication listItem = new ChPayapplication();
foreach (ChPayapplication temp in dataList) {
if (temp.GID == relGID)
{
listItem.BILLNO = temp.BILLNO;
listItem.BILLSTATUS = temp.BILLSTATUS;
listPay.Add(listItem);
}
}
//List result = //JsonConvert.SerializeObject(list);
DBResult result = ChpayapplicationDAL.AuditList(listPay, SessionUtil.Session["USERID"].ToString());
StringBuilder sb = new StringBuilder();
if (!result.Success) { sb.Append("[{\"result\":\"fail\"}]"); }
else { sb.Append("[{\"result\":\"success\"}]"); }
context.Response.ContentType = "text/plain";
context.Response.Write(sb.ToString());
context.Response.End();
}
private void GetDataDetailList(HttpContext context)
{
string relBillNo = "";
string billNo = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["b"].ToString());
string pattern = "\0";
string replacement = "";
Regex rgx = new Regex(pattern);
relBillNo = rgx.Replace(billNo, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relBillNo = rgx2.Replace(relBillNo, replacement);
/*DataTable dt = BaseInfo.PaymentAuditingListDBServer.PaymentAuditingDetailList(relCacheKey, relBillNo);
StringBuilder sb = new StringBuilder();
if (dt == null || dt.Rows.Count == 0) { sb.Append("[{\"GID\":\"\"}]"); }
else { sb.Append(JsonClass.DataTable2JsonNoneTotalCount(dt)); }*/
var dataList = ChpayapplicationDAL.GetBodyAuditList("c.BILLNO = '" + relBillNo + "'", null);
string result = JsonConvert.SerializeObject(dataList);
context.Response.ContentType = "text/plain";
context.Response.Write(result);
context.Response.End();
}
private void GetDataInfo(HttpContext context)
{
string relStrCondition = "";
string relGID = "";
string gid = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["i"].ToString());
//string strCondition = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["s"].ToString());
//string IsAudit = context.Request.QueryString["au"].ToString();
string IsAudit = "";
string pattern = "\0";
string replacement = "";
Regex rgx = new Regex(pattern);
relGID = rgx.Replace(gid, replacement);
//relStrCondition = rgx.Replace(strCondition, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relGID = rgx2.Replace(relGID, replacement);
//relStrCondition = rgx2.Replace(relStrCondition, replacement);
if (IsAudit == "0") { IsAudit = ""; }
/*DataTable dt = BaseInfo.PaymentAuditingListDBServer.PaymentAuditionInfo(relCacheKey, relGID);
StringBuilder sb = new StringBuilder();
if (dt == null || dt.Rows.Count == 0) { sb.Append("[{\"GID\":\"\"}]"); }
else { sb.Append(JsonClass.DataTable2JsonNoneTotalCount(dt)); }*/
var dataList = ChpayapplicationDAL.GetAuditDataList(relStrCondition, Convert.ToString(SessionUtil.Session["USERID"]), IsAudit, Convert.ToString(SessionUtil.Session["UserName"]), Convert.ToString(SessionUtil.Session["COMPANYID"]), "");
//var list = dataList.Where(p => p.GID == relGID);
ChPayapplication chpay = new ChPayapplication();
foreach (ChPayapplication data in dataList)
{
if (data.GID == relGID)
{
/*
GID,i.BILLNO,i.BILLSTATUS,i.CUSTOMERNAME,i.CURR,i.CHEQUEPAYABLE,i.SETTLETYPE,i.PAYTYPE ");
i.PAYABLETIME,i.AMOUNTRMB,i.RATE,i.AMOUNTUSD,i.SETTLERMB as RMBDOAMOUNT,i.SETTLEUSD as USDDOAMOUNT,i.SETTLERATE");
i.APPLICANT,i.APPLYTIME,i.ENTERTIME,i.SETTLEUSER,i.SETTLETIME,i.AUDITUSER,i.AUDITTIME ");
i.REMARK,i.COMPANYID,i.ISAPP,i.PAYAPPID,i.CHEQUENUMREMARK,INVDATE,INVNO, ");
(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97005 and EnumValueID=i.BILLSTATUS) as BILLSTATUSREF");
(select ShowName from [user] where GID=i.APPLICANT) as APPLICANTNAME");
(select ShowName from [user] where GID=i.AUDITUSER) as AUDITUSERREF");
i.CUSTACCOUNTGID");
(select CODENAME+'_'+bankname from info_client_bank where gid=i.CUSTACCOUNTGID) CUSTBANKNAME");
(select ACCOUNT from info_client_bank where gid=i.CUSTACCOUNTGID) CUSTACCOUNT");
ISNULL((select sum(isnull(amount,0)-isnull(invoice,0)) as noinvoice from ch_fee where ISINVOICE<>1 and gid in (select feeid from ch_fee_do where BILLNO=i.BILLNO)),0) as NOINVOICE");
i.BS_CUSTOMERNAME,dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno) as IsAudit ");
i.PREAMOUNTRMB,i.PREAMOUNTUSD ");
dbo.GetBalNoByPayNo(i.BILLNO) as BALBILLNO
*
billNo = item.BILLNO; //申请单号
BillNo = item.BILLNO;
billStatus = parseInt(item.BILLSTATUS); //状态
customerName = item.CUSTOMERNAME; //结算单位
settlementClient = item.CUSTOMERNAME;
amountRMB = new Number(item.AMOUNTRMB);
amountUSD = item.AMOUNTUSD; //USD
amountUSD = new Number(item.AMOUNTUSD);
applyTime = item.APPLYTIME; //申请日期
applyTime = applyTime.substring(0, 8);
applyTime = applyTime.replace(/\//g, "-");
applicantName = item.APPLICANTNAME; //申请人
payableTime = item.PAYABLETIME; //支付日期
payableTime = payableTime.substring(0, 8);
payableTime = payableTime.replace(/\//g, "-");
*/
chpay.BILLNO = data.BILLNO;
chpay.BILLSTATUS = data.BILLSTATUS;
chpay.CUSTOMERNAME = data.CUSTOMERNAME;
chpay.AMOUNTRMB = data.AMOUNTRMB;
chpay.AMOUNTUSD = data.AMOUNTUSD;
chpay.APPLYTIME = data.APPLYTIME;
chpay.APPLICANTNAME = data.APPLICANTNAME;
chpay.PAYABLETIME = data.PAYABLETIME;
}
}
string applytime = chpay.APPLYTIME.ToString();
applytime = applytime.Substring(0, applytime.IndexOf(" "));
string result = "[{\"BILLNO\":\"" + chpay.BILLNO + "\",\"BILLSTATUS\":\"" + chpay.BILLSTATUS + "\",\"CUSTOMERNAME\":\"" + chpay.CUSTOMERNAME + "\",\"AMOUNTRMB\":\"" + chpay.AMOUNTRMB + "\",\"AMOUNTUSD\":\"" + chpay.AMOUNTUSD + "\",\"APPLYTIME\":\"" + applytime + "\",\"APPLICANTNAME\":\"" + chpay.APPLICANTNAME + "\",\"PAYABLETIME\":\"" + chpay.PAYABLETIME + "\",\"INVNO\":\"" + chpay.INVNO + "\"}]";
context.Response.ContentType = "text/plain";
context.Response.Write(result);
context.Response.End();
}
private void GetDataList(HttpContext context)
{
string relStrCondition = "";
string relBeginFrom = "";
string relBeginTo = "";
string strCondition = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["s"].ToString());
string bf = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["bf"].ToString());
string bt = Encrypt.DesDecrypt("#7c&e@63", context.Request.Form["bt"].ToString());
string IsAudit = context.Request.QueryString["au"].ToString();
string pattern = "\0";
string replacement = "";
/*int pageIndex = int.Parse(context.Request.QueryString["i"].ToString());
int pageCount = int.Parse(context.Request.QueryString["c"].ToString());
int TotalCount = 0;*/
int start = int.Parse(context.Request.QueryString["t"].ToString());
int limit = int.Parse(context.Request.QueryString["l"].ToString());
Regex rgx = new Regex(pattern);
relStrCondition = rgx.Replace(strCondition, replacement);
relBeginFrom = rgx.Replace(bf, replacement);
relBeginTo = rgx.Replace(bt, replacement);
pattern = "\t";
Regex rgx2 = new Regex(pattern);
relStrCondition = rgx2.Replace(relStrCondition, replacement);
relBeginFrom = rgx2.Replace(relBeginFrom, replacement);
relBeginTo = rgx2.Replace(relBeginTo, replacement);
if (IsAudit == "0") { IsAudit = ""; }
//APPLYTIME
if (relBeginFrom != "") {
if (relStrCondition != "")
{
relStrCondition += " and APPLYTIME>='" + relBeginFrom + " 00:00:00' ";
}
else {
relStrCondition = " APPLYTIME>='" + relBeginFrom + " 00:00:00' ";
}
}
if (relBeginTo != "") {
relStrCondition += " and APPLYTIME<='" + relBeginTo + " 23:59:59' ";
}
var dataList = ChpayapplicationDAL.GetAuditDataList(relStrCondition, Convert.ToString(SessionUtil.Session["USERID"]), IsAudit, Convert.ToString(SessionUtil.Session["UserName"]), Convert.ToString(SessionUtil.Session["COMPANYID"]), "");
//var list = dataList.Skip(start).Take(limit);
string result = JsonConvert.SerializeObject(dataList);
/*string result2 = result.Substring(25, result.Length - 72);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };*/
context.Response.ContentType = "text/plain";
context.Response.Write(result);
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}