DS7/DSWeb/Areas/Account/Controllers/Chfee_ForeignsettlementCont...

993 lines
40 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.Account.DAL.Chfee_Settlement;
using DSWeb.Areas.Import.DAL.CW;
using DSWeb.Areas.Account.Models.Chfee_Payapplication;
using DSWeb.Areas.Account.Models.Chfee_Settlement;
using DSWeb.Areas.Account.Models.Chfee_do_detail;
using DSWeb.Areas.Account.Models.BillChfeeDetail;
using DSWeb.Areas.Import.Models.CWAdvancePayment;
using DSWeb.Areas.Account.Models.Chfee_Invoice;
using DSWeb.Areas.Account.Models.Chfee_Invoicehexiao;
using DSWeb.Areas.Account.Models.MsCwVouchersGl3;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.CommMng.Models;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.EntityDA;
using DSWeb.Areas.Account.Models.Chfee_Exrate;
using DSWeb.TruckMng.Helper.Repository;
//20150906 复制自Chfee_settlement
//为了应对进口贸易的外币付费申请的购汇结算
namespace DSWeb.Areas.Account.Controllers
{
[JsonRequestBehavior]
public class Chfee_ForeignsettlementController : Controller
{
//
// GET:
public ActionResult PayIndex()
{
return View();
}
//
// GET: /
public ActionResult PayEdit()
{
return View();
}
public ActionResult PayBLEdit()
{
return View();
}
public ActionResult PayAppEdit()
{
return View();
}
// GET:
public ActionResult RecvIndex()
{
return View();
}
//
// GET: /
public ActionResult RecvEdit()
{
return View();
}
public ActionResult RecvBLEdit()
{
return View();
}
public ActionResult RecvAppEdit()
{
return View();
}
public ActionResult RecvInvEdit()
{
return View();
}
public ActionResult PayInvEdit()
{
return View();
}
public ActionResult SettementView()
{
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string sort, string condition,int billtype)
{
int total = 0;
var dataList = ChsettlementDAL.GetDataList(condition,start,limit,out total, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort,billtype);
//var list = dataList.Skip(start).Take(limit);
// var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = total, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListStr(int start, int limit, string sort, string condition, int billtype)
{
var dataListStr = ChsettlementDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort, billtype);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
ChSettlement head = null;
int total = 0;
if (handle == "edit")
{
var list = ChsettlementDAL.GetDataList(condition, 0, 10, out total, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new ChSettlement();
}
if (handle == "add")
{
head.SETTLEUSER = Convert.ToString(Session["USERID"]);
head.SETTLEUSERREF = Convert.ToString(Session["SHOWNAME"]);
head.SETTLETIME = DateTime.Now.ToString("yyyy-MM-dd");
head.ACCOUNTS_CURRENCY="RMB";
head.PREPAY_CURRENCY="RMB";
head.AHSR_CURRENCY="RMB";
head.FINANCIAL_CURRENCY="RMB";
head.ADVANCE_CURRENCY="RMB";
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetPAYRMBData ( string handle, string condition )
{
PAYRMBmb head = null;
if (handle == "edit")
{
var list = ChsettlementDAL.GetPAYRMBData(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new PAYRMBmb();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetBillList(string condition,string sort)
{
var dataList = ChsettlementDAL.GetBodyList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetBillSum(string condition)
{
var dataList = ChsettlementDAL.GetBodySumList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeDataList(int start, int limit, string sort, string condition, int billtype)
{
var dataList = ChsettlementDAL.GetFeeDataList(condition,"", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort, billtype);
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 };
}
public ContentResult GetBillDataList(int start, int limit, string sort, string condition, int billtype)
{
var dataList = ChsettlementDAL.GetAddBillList(condition,"", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort, billtype);
// var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetChildDataList ( string condition )
{
var dataList = ChsettlementDAL.GetChildDataList(condition);
// var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeDetailList(string sort, string condition)
{
var dataList = ChsettlementDAL.GetFeeDetailList(condition, "",Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetAddSum(string condition, int billtype)
{
var dataList = ChsettlementDAL.GetAddSum(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]),billtype);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string accountsdata
, string prepaydata, string ahsrdata, string financialdata
, string advancedata, int billtype,string prepaychange,string PAYRMB
, string Childdata, string ChildDeldata )
{
var headData = JsonConvert.Deserialize<ChSettlement>(data.Replace("}", ",") + accountsdata.Replace("{", "").Replace("}", ",") + prepaydata.Replace("{", "").Replace("}", ",")
+ ahsrdata.Replace("{", "").Replace("}", ",") + financialdata.Replace("{", "").Replace("}", ",") + advancedata.Replace("{", ""));
var _PAYRMB= JsonConvert.Deserialize<PAYRMBmb>(PAYRMB);
var ChildBodyList = JsonConvert.Deserialize<List<SysChildmb>>(Childdata);
var ChildDelBodyList = JsonConvert.Deserialize<List<SysChildmb>>(ChildDeldata);
if (opstatus == "add")
{
headData.GID = Guid.NewGuid().ToString();
if (billtype==2)
headData.BILLNO = PubSysDAL.GetBillNo("0304");
else if (billtype == 1)
headData.BILLNO = PubSysDAL.GetBillNo("0305");
headData.COMPANYID = Convert.ToString(Session["COMPANYID"]);
headData.BILLDATE = DateTime.Now;
headData.DbOperationType = DbOperationType.DbotIns;
headData.ModelUIStatus = "I";
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var BILLNO = headData.BILLNO;
if (headData.CURR == "RMB")
{
headData.AMOUNTRMB = headData.AMOUNT;
headData.ACCOUNTRMB = headData.ACCOUNT;
headData.AMOUNTUSD = 0;
headData.ACCOUNTUSD = "";
}
else
{
headData.AMOUNTUSD = headData.AMOUNT;
headData.ACCOUNTUSD = headData.ACCOUNT;
headData.ACCOUNTRMB = "";
headData.AMOUNTRMB = 0;
}
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
//var modb = new ModelObjectRepository();
//DBResult result = modb.Save(headData,
// ModelObjectConvert<SysChildmb>.ToModelObjectList(ChildBodyList),
// ModelObjectConvert<SysChildmb>.ToModelObjectList(ChildDelBodyList));
if ((result.Success) &&(prepaychange == "true")) {
bool updatepayment=ChsettlementDAL.updatePayment(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
if (!updatepayment) { result.Message="已保存成功,但预收付更新时发生错误,请检查预收付单据是否已生成凭证或有其他错误!";}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = ChsettlementDAL.GetData(" BILLNO='" + BILLNO + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]))
};
var _SavePAYRMB = new DBResult();
if (jsonRespose.Success && _PAYRMB!=null )
if (float.Parse(_PAYRMB.Amount)!=0)
//如果购汇RMB金额大于0则进行购汇付汇逻辑操作
{
var dataList = ChsettlementDAL.GetPayDetailList(headData.BILLNO);
var cando = true;
foreach (var _d in dataList) {
if (_d.CURR == "RMB")
cando = false;
}
if (cando==true)
{
_PAYRMB.BILLNO = headData.BILLNO;
_SavePAYRMB = ChsettlementDAL.SavePAYRMB(_PAYRMB, "购汇", headData.CUSTOMERNAME, Convert.ToString(Session["USERID"]),headData.CURR);
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = ChsettlementDAL.GetData(" BILLNO='" + BILLNO + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]))
};
}
}
if (float.Parse(_PAYRMB.SXF) + float.Parse(_PAYRMB.DHF) > 0)
{
//20160405 增加逻辑 对付美元结算美元 用RMB支付手续费电汇费的情况
//如果是对外支付rmb同时支付手续费电汇费同样按此方法处理
var dataList = ChsettlementDAL.GetPayDetailList(headData.BILLNO);
var cando = true;
var curr = "";
/*
foreach (var _d in dataList)
{//限制不同币别的申请进行这种逻辑
if (curr == "") {
curr = _d.CURR;
}else
if (curr != _d.CURR && _d)
{
cando = false;
}
}*/
if (cando == true)
{
_PAYRMB.BILLNO = headData.BILLNO;
_SavePAYRMB = ChsettlementDAL.SavePAYRMB(_PAYRMB, "手续电汇", headData.CUSTOMERNAME, Convert.ToString(Session["USERID"]),headData.CURR);
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = ChsettlementDAL.GetData(" BILLNO='" + BILLNO + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]))
};
}
//1向申请下增加ch_fee_do 分别为手续费、电汇费,按照
}
//else {
// //删除相关表格
// ChsettlementDAL.DelPAYRMB(BILLNO);
// ChsettlementDAL.DelMakeFee(BILLNO);
// //ChsettlementDAL.p_update_Amount(BILLNO, 2);
// }
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AddDetail(string bill, string data, string curr,int billtype)
{
var bodyList = JsonConvert.Deserialize<List<BillChfeeDetail>>(data);
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddDetail(bill,"", bodyList, curr, Convert.ToString(Session["COMPANYID"]));
if (result.Success) {
ChsettlementDAL.p_update_Amount(bill,billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AddBill(string billno, string billcust, string billcurr, string feesql, string storeCurrExrate, int billtype)
{
var exrateList = JsonConvert.Deserialize<List<ChFeeExrate>>(storeCurrExrate);
if ((exrateList == null) || (exrateList.Count == 0))
{
exrateList = ChsettlementDAL.GetCurrExrateData(billcust, billcurr, feesql);
if (exrateList.Count == 0)
{
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddBill(billno, "",billcust, billcurr, feesql, exrateList, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (result.Success) {
ChsettlementDAL.p_update_Amount(billno, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(billno);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = true, Message = "查询成功", Data = exrateList.ToList() };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else
{
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddBill(billno,"",billcust, billcurr, feesql, exrateList, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (result.Success) {
ChsettlementDAL.p_update_Amount(billno,billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(billno);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DelBill(string data, string billno,int billtype)
{
var bodyList = JsonConvert.Deserialize<List<Chfee_do_detail>>(data);
DBResult result = ChsettlementDAL.DelFeeDo(bodyList);
if (result.Success) {
ChsettlementDAL.p_update_Amount(billno, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(billno);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//
public ContentResult Delete(string data, int settlemode)
{
var headData = JsonConvert.Deserialize<ChSettlement>(data);
DBResult result;
var dataList = ChsettlementDAL.GetPayDetailList(headData.BILLNO);
result = ChsettlementDAL.DelAppStl(dataList, headData.BILLNO);
var dataList2 = ChsettlementDAL.GetBodyList("BILLNO='" + headData.BILLNO + "'");
result = ChsettlementDAL.DelFeeDo(dataList2);
if (result.Success == true)
{
DSWeb.SoftMng.DBUtility.DbHelperSQL.ExecuteSql("delete from ch_fee where F_NO='" + headData.BILLNO + "'");
var modb = new ModelObjectDB();
modb.Delete(headData);
ChsettlementDAL.DelRemit(headData.BILLNO);
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + headData.BILLNO + "','删除结算','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + headData.BILLNO + '(' + headData.CUSTOMERNAME + ')' + "','" + Convert.ToString(Session["USERID"]) + "')";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
if (result.Success == true) {
var APDList = CWAdvancePaymentDAL.GetBodyList(headData.BILLNO);
var _r = ChsettlementDAL.DelPaymentDo(APDList);
}
/* public ContentResult DelAPBill(string data)
{
var bodyList = JsonConvert.Deserialize<List<CWAdvancePaymentBody>>(data);
DBResult result = ChsettlementDAL.DelPaymentDo(bodyList);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}*/
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteRecv(string data, int settlemode)
{
var headData = JsonConvert.Deserialize<ChSettlement>(data);
DBResult result;
if (settlemode == 1)
{
var dataList = ChsettlementDAL.GetRecvDetailList(headData.BILLNO);
result = ChsettlementDAL.DelRecvAppStl(dataList, headData.BILLNO);
}
else if (settlemode == 3) {
var dataList = ChsettlementDAL.GetRecvInvDetailList(headData.BILLNO);
result = ChsettlementDAL.DelRecvInvAppStl(dataList, headData.BILLNO);
}
else
{
var dataList = ChsettlementDAL.GetBodyList("BILLNO='" + headData.BILLNO + "'");
result = ChsettlementDAL.DelFeeDo(dataList);
}
if (result.Success == true)
{
var modb = new ModelObjectDB();
modb.Delete(headData);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 锁定和撤销锁定
public ContentResult Lock(string bill, string remark)
{
DBResult result = ChsettlementDAL.Lock(bill,remark);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult UnLock(string bill)
{
DBResult result = ChsettlementDAL.UnLock(bill);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult LockList(string bills)
{
DBResult result = ChsettlementDAL.LockList(bills);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult UnLockList(string bills)
{
DBResult result = ChsettlementDAL.UnLockList(bills);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
#endregion
#region 付费申请结算
public ContentResult GetPayList(int start, int limit, string sort, string condition)
{
var dataList = ChsettlementDAL.GetPayDataList(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 };
}
public ContentResult GetPayDCList(int start, int limit, string sort, string condition)
{
var dataList = ChsettlementDAL.GetPayDCDataList(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 };
}
public ContentResult GetPaydetailList(string billno)
{
var dataList = ChsettlementDAL.GetPayDetailList(billno);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetAppBodyList(string condition)
{
var dataList = ChsettlementDAL.GetAppBodyList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult AddAppDetail(string bill, string data, string curr, int billtype)
{
var bodyList = JsonConvert.Deserialize<List<ChPaySettlement>>(data);
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]));
if (result.Success) {
ChsettlementDAL.p_update_Amount(bill, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AddAppDCDetail(string bill, string data, string curr, string storeCurrExrate, int billtype, string addcurr)
{
var exrateList = JsonConvert.Deserialize<List<ChFeeExrate>>(storeCurrExrate);
var bodyList = JsonConvert.Deserialize<List<ChPaySettlement>>(data);
if (((exrateList == null) || (exrateList.Count == 0)) && (addcurr != curr))
{
exrateList = ChsettlementDAL.GetAppCurrExrateData(bodyList, curr,addcurr);
if (exrateList.Count == 0)
{
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddAppDCDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), addcurr, exrateList,false);
if (result.Success) {
ChsettlementDAL.p_update_Amount(bill, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = true, Message = "查询成功", Data = exrateList.ToList() };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else
{
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddAppDCDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), addcurr, exrateList,false);
if (result.Success) {
ChsettlementDAL.p_update_Amount(bill, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DelAppBill(string data, string billno, int billtype)
{//删除付费申请明细
var bodyList = JsonConvert.Deserialize<List<ChPaySettlement>>(data);
DBResult result = ChsettlementDAL.DelAppStl(bodyList,billno);
if (result.Success) {
ChsettlementDAL.Set_BS_CUSTOMERNAME(billno);
ChsettlementDAL.DelMakeFee(billno);
ChsettlementDAL.p_update_Amount(billno, billtype);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 收费申请结算
public ContentResult GetRecvList(int start, int limit, string sort, string condition)
{
var dataList = ChsettlementDAL.GetRecvDataList(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 };
}
public ContentResult GetRecvDCList(int start, int limit, string sort, string condition)
{
var dataList = ChsettlementDAL.GetRecvDCDataList(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 };
}
public ContentResult GetRecvdetailList(string billno)
{
var dataList = ChsettlementDAL.GetRecvDetailList(billno);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult AddRecvAppDetail(string bill, string data, string curr, int billtype)
{
var bodyList = JsonConvert.Deserialize<List<ChPaySettlement>>(data);
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.RecvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]));
if (result.Success) {
ChsettlementDAL.p_update_Amount(bill, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AddRecvAppDCDetail(string bill, string data, string curr, string storeCurrExrate, int billtype, string addcurr)
{
var exrateList = JsonConvert.Deserialize<List<ChFeeExrate>>(storeCurrExrate);
var bodyList = JsonConvert.Deserialize<List<ChPaySettlement>>(data);
if (((exrateList == null) || (exrateList.Count == 0))&&(addcurr==""))
{
exrateList = ChsettlementDAL.GetAppCurrExrateData(bodyList, curr, addcurr);
if (exrateList.Count == 0)
{
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddRecvAppDCDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), addcurr, exrateList);
if (result.Success) {
ChsettlementDAL.p_update_Amount(bill, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = true, Message = "查询成功", Data = exrateList.ToList() };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else
{
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddRecvAppDCDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), addcurr, exrateList);
if (result.Success) {
ChsettlementDAL.p_update_Amount(bill, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DelRecvAppBill(string data, string billno, int billtype)
{
var bodyList = JsonConvert.Deserialize<List<ChPaySettlement>>(data);
DBResult result = ChsettlementDAL.DelRecvAppStl(bodyList, billno);
if (result.Success) {
ChsettlementDAL.p_update_Amount(billno, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(billno);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 付费发票结算
public ContentResult GetPayInvList(int start, int limit, string sort, string condition)
{
var dataList = ChsettlementDAL.GetPayInvDataList(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 };
}
public ContentResult GetPayInvdetailList(string billno)
{
var dataList = ChsettlementDAL.GetPayInvDetailList(billno);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult AddPayInvAppDetail(string bill, string data, string curr, int billtype)
{
var bodyList = JsonConvert.Deserialize<List<ChInvoicehexiao>>(data);
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.PayInvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]));
if (result.Success)
{
ChsettlementDAL.p_update_Amount(bill, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DelPayInvAppBill(string data, string billno, int billtype)
{
var bodyList = JsonConvert.Deserialize<List<ChInvoicehexiao>>(data);
DBResult result = ChsettlementDAL.DelPayInvAppStl(bodyList, billno);
if (result.Success)
{
ChsettlementDAL.p_update_Amount(billno, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(billno);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 收费发票结算
public ContentResult GetRecvInvList(int start, int limit, string sort, string condition)
{
var dataList = ChsettlementDAL.GetRecvInvDataList(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 };
}
public ContentResult GetRecvInvdetailList(string billno)
{
var dataList = ChsettlementDAL.GetRecvInvDetailList(billno);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//public ContentResult AddRecvInvAppDetail(string bill, string data, string curr, int billtype)
//{
// var bodyList = JsonConvert.Deserialize<List<ChInvoice>>(data);
// var modb = new ModelObjectDB();
// DBResult result = ChsettlementDAL.RecvInvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]));
// if (result.Success)
// {
// ChsettlementDAL.p_update_Amount(bill, billtype);
// ChsettlementDAL.Set_BS_CUSTOMERNAME(bill);
// }
// var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
public ContentResult DelRecvInvAppBill(string data, string billno, int billtype)
{
var bodyList = JsonConvert.Deserialize<List<ChInvoice>>(data);
DBResult result = ChsettlementDAL.DelRecvInvAppStl(bodyList, billno);
if (result.Success)
{
ChsettlementDAL.p_update_Amount(billno, billtype);
ChsettlementDAL.Set_BS_CUSTOMERNAME(billno);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 预收预付
public ContentResult GetAdvancePayment(int start, int limit, string sort, string condition)
{
var dataList = ChsettlementDAL.GetAPDataList(condition);
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 };
}
public ContentResult GetAPBodyList(string condition)
{
var dataList = ChsettlementDAL.GetAPBodyList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult AddAPDetail(string billno, string data, string stlnogid, int feetype)
{
var bodyList = JsonConvert.Deserialize<List<CWAdvancePayment>>(data);
var modb = new ModelObjectDB();
DBResult result = ChsettlementDAL.AddAPDetail(billno, bodyList, stlnogid, feetype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DelAPBill(string data)
{
var bodyList = JsonConvert.Deserialize<List<CWAdvancePaymentBody>>(data);
DBResult result = ChsettlementDAL.DelPaymentDo(bodyList);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 参照部分
#endregion
}
}