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.

1613 lines
79 KiB
C#

11 months ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.Import.DAL.ImportSales;
using DSWeb.Areas.Import.Models.ImportTrade;
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 DSWeb.TruckMng.Helper.Repository;
using DSWeb.Areas.CommMng.Models;
using DSWeb.Areas.Import.DAL.Comm;
using DSWeb.Areas.Import.Models.Comm;
using DSWeb.Areas.Account.DAL.Chfee_Settlement;
using DSWeb.MvcShipping.Models.WMS;
using DSWeb.MvcShipping.DAL.WMS;
using DSWeb.MvcShipping.Controllers;
using DSWeb.Areas.Import.DAL.XXH;
using DSWeb.Areas.Import.DAL.ImportTrade;
using System.Text;
namespace DSWeb.Areas.Import.Controllers
{
[JsonRequestBehavior]
public class ImportSalesController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
public ActionResult BLEdit()
{
return View();
}
//付费申请审核
public ActionResult Audit()
{
return View();
}
//财务核销
public ActionResult CWSTL ( )
{
return View();
}
public ActionResult CWSTLEdit ( )
{
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = ImportSalesDAL.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 };
}
public ContentResult GetData ( string handle, string condition )
{
ImportSalesmb head = null;
if (handle == "edit" || handle == "audit")
{
var list = ImportSalesDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new ImportSalesmb();
}
if (handle == "add")
{
head.OP = Convert.ToString(Session["SHOWNAME"]);
//head.OPRef = Convert.ToString(Session["SHOWNAME"]);
head.BSSTATUS = "1";
head.FEESTATUS = "1";
head.CURRENCY = "RMB";
head.AMOUNT = "0";
head.EXCHANGERATE = "1";
head.AMOUNTRMB = "0";
head.SALESTATUS = "0";
//head.SALESDATE = DateTime.Now.ToString();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save ( string opstatus, string data, string SaleDetailList,string OrderFeeList )
{
var headData = JsonConvert.Deserialize<ImportSalesmb>(data);
var SaleDetailData = JsonConvert.Deserialize<List<ImportSaledetailmb>>(SaleDetailList);
var SaleDetailDEL = JsonConvert.Deserialize<List<ImportSaledetailmb>>("");
var OrderFee = JsonConvert.Deserialize<List<MsOrderFee>>(OrderFeeList);
var OrderFeeDel = JsonConvert.Deserialize<List<MsOrderFee>>("");
if (!string.IsNullOrEmpty(OrderFeeList)) {
foreach (var _f in OrderFee) {
_f.MODIFIEDTIME = System.DateTime.Now.ToString();
_f.MODIFIEDUSER = Session["USERID"].ToString();
}
}
if (opstatus == "add")
{
headData.GID = Guid.NewGuid().ToString();
//headData.SALESNO = PubSysDAL.GetBillNo("0207");
headData.SALESNO = ImportSalesDAL.GetSALESNO(headData.SALESNO);
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
//headData.OP = CookieConfig.GetCookie_UserName(Request);
headData.SALESDATE = DateTime.Now.ToString();
headData.DbOperationType = DbOperationType.DbotIns;
headData.ModelUIStatus = "I";
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var SALESNO = headData.SALESNO;
//if (headData.INVDATE == "") headData.INVDATE = null;
var modb = new ModelObjectRepository();
DBResult result = modb.Save(headData
, ModelObjectConvert<ImportSaledetailmb>.ToModelObjectList(SaleDetailData)
, ModelObjectConvert<ImportSaledetailmb>.ToModelObjectList(SaleDetailDEL)
, ModelObjectConvert<MsOrderFee>.ToModelObjectList(OrderFee)
, ModelObjectConvert<MsOrderFee>.ToModelObjectList(OrderFeeDel)
);
PubSysDAL.ExecSql(" update Import_Saledetail set CURRENCY='"+headData.CURRENCY+"' ,EXCHANGERATE="+headData.EXCHANGERATE+" where SALESNO='"+headData.SALESNO+"' ");
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = ImportSalesDAL.GetData(" s.SALESNO='" + SALESNO + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetCargoList(int start, int limit, string sort, string condition)
{
var dataList = ImportSalesDAL.GetCargoList(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 AddSales(string SALESNO,string CargoList)
{
var _count = 0;
var corpcode = CookieConfig.GetCookie_OrgCode(Request);
var userid = CookieConfig.GetCookie_UserId(Request);
_count = ImportSalesDAL.AddSales(SALESNO, CargoList, corpcode, userid);
var _success = false;
if (_count>0){
_success = true;
}
var json = JsonConvert.Serialize(new { Success = _success, Message = "查询成功", totalCount = _count });
return new ContentResult() { Content = json };
}
public ContentResult GetDetailList(int start, int limit, string sort, string condition)
{
var dataList = ImportSalesDAL.GetDetailList(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 DeleteDetail(string SALESNO, string GIDList)
{
var _count = 0;
var corpcode = CookieConfig.GetCookie_OrgCode(Request);
var userid = CookieConfig.GetCookie_UserId(Request);
_count = ImportSalesDAL.DeleteDetail(SALESNO, GIDList);
var _success = false;
if (_count > 0)
{
_success = true;
}
var json = JsonConvert.Serialize(new { Success = _success, Message = "查询成功", totalCount = _count });
return new ContentResult() { Content = json };
}
public ContentResult Delete ( string data )
{
var head = JsonConvert.Deserialize<ImportSalesmb>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head);
ContentResult _r = DeleteDetail(head.SALESNO, "");
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetFeeList(string SALESNO, string sort)
{
var corpid = Convert.ToString(Session["COMPANYID"]);
var USERID = Convert.ToString(Session["USERID"]);
var DEPTGID = Convert.ToString(Session["DEPTGID"]);
//var OPERATERANGE="";
var VISIBLERANGE = "";
var modName = "modImport_Fee";
var evList = BasicDataRefDAL.GetAR(modName, USERID);
AuthorityRangemb head = null;
if (evList.Count > 0)
head = evList[0];
if (head == null)
{
head = new AuthorityRangemb();
//OPERATERANGE = "3";
VISIBLERANGE = "3";
}
else
{
//OPERATERANGE = head.OPERATERANGE;
VISIBLERANGE = head.VISIBLERANGE;
}
var condition = "SALESNO='" + SALESNO + "'";
/* 访
if (VISIBLERANGE == "1")
{
condition = condition + " and SALER in(select userid from user_company where companyid='" + corpid + "')";
}
if (VISIBLERANGE == "2")
{
condition = condition + " and SALER in(select userid from user_baseinfo where companyname=(select name from company where gid='" + corpid + "') ";
condition = condition + " and deptname=(select deptname from sys_dept where gid='" + DEPTGID + "')) ";
}
if (VISIBLERANGE == "3")
{
condition = condition + " and SALER ='" + USERID + "'";
}*/
var dataList = ImportSalesDAL.GetFeeList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult SaveFee ( string SALESNO, string chfeebody, string chfeedelbody )
{
var chfeeBodyList = JsonConvert.Deserialize<List<MsChFee_Sales>>(chfeebody);
var chfeeDelBodyList = JsonConvert.Deserialize<List<MsChFee_Sales>>(chfeedelbody);
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("BsNo", SALESNO,
ModelObjectConvert<MsChFee_Sales>.ToModelObjectList(chfeeBodyList),
ModelObjectConvert<MsChFee_Sales>.ToModelObjectList(chfeeDelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SetSettlement ( string SALESNO, string chfeebody )
{
var corpid = Convert.ToString(Session["COMPANYID"]);
var userid = Convert.ToString(Session["USERID"]);
var BILLNO = PubSysDAL.GetBillNo("0304");
var FeeList = JsonConvert.Deserialize<List<MsChFee>>(chfeebody);
//首先删除相关结算//目前的逻辑已不需要删除旧结算
//var _count2 = ImportSalesDAL.DelSettlement(SALESNO);
//此时在前台调用处已同过js中的MakeFees方法生成费用
//此处要做的是
//1 通过SALESNO查询出所有费用 //现改为由前台提供
//var condition = " isnull(SALESNO,'')<>'' and SALESNO='" + SALESNO + "'";
//var FeeList = ImportSalesDAL.GetFeeList(condition, "");
//2 建立一个Ch_fee_do的对象List依照费用信息编写和插入ch_fee_do信息
var ChFeeDoList = new List<DSWeb.Areas.Import.Models.ImportTrade.MsChFeeDo>();
var ChFeeDoDEL = new List<DSWeb.Areas.Import.Models.ImportTrade.MsChFeeDo>();//保持为空 仅用来填充参数
decimal AMOUNT = 0;
var CUSTOMERNAME = "";
foreach (var Fee in FeeList)
{
var _do = new DSWeb.Areas.Import.Models.ImportTrade.MsChFeeDo();
_do.GID = Guid.NewGuid().ToString();
_do.BILLNO = "";//SALESNO;
_do.BSNO = Fee.BsNo;
_do.CUSTOMERNAME = Fee.CustomerName;
_do.BSTYPE = "0";
_do.FEEID = Fee.GId;
_do.FEENAME = Fee.FeeName;
_do.CURRENCY = Fee.Currency;
_do.AMOUNT = Fee.Amount.ToString();
_do.DOAMOUNT = Fee.Amount.ToString();
_do.FEETYPE = Fee.FeeType.ToString();
_do.CATEGORY = "2";
_do.BILLSTATUS = "2";
_do.CREATETIME = DateTime.Now.ToString();
_do.EXCHANGERATE = Fee.ExChangerate.ToString();
_do.ORIGAMOUNT = Fee.Amount.ToString();
_do.COMPANYID = corpid;
CUSTOMERNAME = Fee.CustomerName;
ChFeeDoList.Add(_do);
AMOUNT = AMOUNT + Fee.Amount * Fee.ExChangerate;
}
// 并计算总金额
var condition = " SETTLEBILLNO='" + BILLNO + "' ";
decimal SettlementAmount = 0;
//2 建立一个Ch_fee_do的对象List依照费用信息编写和插入ch_fee_do信息
//
var _countAD = ImportSalesDAL.SetAdvancePay(BILLNO, SALESNO);
var _APD = ChsettlementDAL.GetAPBodyList(condition);
foreach (var apd in _APD)
{
SettlementAmount = SettlementAmount + decimal.Parse(apd.DOAMOUNT);
}
if (AMOUNT != SettlementAmount)
{
var json2 = JsonConvert.Serialize(new { Success = false, Message = "核销的费用金额和预收取用的金额不一致" });
return new ContentResult() { Content = json2 };
}
//3 建立一个Ch_fee_settlement对象插入数据
var _S = new DSWeb.Areas.Import.Models.ImportTrade.MsChFeeSettlement();
_S.GID = Guid.NewGuid().ToString();
_S.BILLNO = BILLNO;
_S.BILLDATE = DateTime.Now.ToString();
_S.SETTLEMODE = "2";
_S.CUSTOMERNAME = CUSTOMERNAME;
_S.SETTLETYPE = "4";
_S.AMOUNTRMB = AMOUNT.ToString();
_S.ACCOUNTRMB = "";
_S.RATE = "1";
_S.AMOUNTUSD = "0";
_S.ACCOUNTUSD = "";
_S.BILLTYPE = "1";
_S.SETTLEUSER = userid;
_S.SETTLETIME = DateTime.Now.ToString();
_S.ISEXPORT = "0";
_S.BILLSTATUS = "2";
_S.COMPANYID = corpid;
_S.ACCOUNTS_CURRENCY = "0";
_S.ACCOUNTS_RATE = "1";
_S.ACCOUNTS_MONEY = AMOUNT.ToString();
_S.PREPAY_CURRENCY = "0";
_S.PREPAY_RATE = "1";
_S.PREPAY_MONEY = "0";
_S.AHSR_CURRENCY = "0";
_S.AHSR_RATE = "1";
_S.AHSR_MONEY = "0";
_S.FINANCIAL_CURRENCY = "0";
_S.FINANCIAL_RATE = "1";
_S.FINANCIAL_MONEY = "0";
_S.ADVANCE_CURRENCY = "0";
_S.ADVANCE_RATE = "1";
_S.ADVANCE_MONEY = SettlementAmount.ToString();
_S.CURR = "RMB";
//4 将Ch_fee_settlement作为主Ch_fee_doList作为从进行保存
_S.DbOperationType = DbOperationType.DbotIns;
_S.ModelUIStatus = "I";
var modb = new ModelObjectRepository();
DBResult result = modb.Save(_S,
ModelObjectConvert<DSWeb.Areas.Import.Models.ImportTrade.MsChFeeDo>.ToModelObjectList(ChFeeDoList),
ModelObjectConvert<DSWeb.Areas.Import.Models.ImportTrade.MsChFeeDo>.ToModelObjectList(ChFeeDoDEL)
);
if (result.Success)
{
var _count3 = ImportSalesDAL.FeeSettlement(BILLNO);
}
var json = JsonConvert.Serialize(new { Success = result.Success, Message = "设置完成", data = BILLNO });
return new ContentResult() { Content = json };
}
public ContentResult SetUnSettlement ( string BILLNO )
{
var corpcode = CookieConfig.GetCookie_OrgCode(Request);
var userid = CookieConfig.GetCookie_UserId(Request);
var json = JsonConvert.Serialize(new { Success = false, Message = "设置失败", totalCount = 0 });
var VOUCount = ImportSalesDAL.GetVOUNO(BILLNO);
if (VOUCount > 0)
{
json = JsonConvert.Serialize(new { Success = false, Message = "该次结算已经生成凭证,不能撤销,请联系财务部门", totalCount = 0 });
}
else
{
//var _count2 = ImportSalesDAL.FeeUnSettlement(BILLNO);
var _count = ImportSalesDAL.SetUnSettlement(BILLNO);
if (_count < 0)
{
json = JsonConvert.Serialize(new { Success = false, Message = "设置失败", totalCount = _count });
}
else
{
_count = _count + ImportSalesDAL.ResetDoamount();
json = JsonConvert.Serialize(new { Success = true, Message = "设置成功", totalCount = _count });
}
}
return new ContentResult() { Content = json };
}
public ContentResult SetSaleStatus(string SALESNO, string SALESTATUS)
{//认款出库
var _count = 0;
if (SALESTATUS == "0") //财务取消申过。前台限制只能对1的进行此操作。
{
_count = ImportSalesDAL.UnLockSaleStatus(SALESNO);
if (_count != -1)
{
_count = ImportSalesDAL.SetSalesUnAudit(SALESNO);
}
}
if (SALESTATUS == "1" ) //财务申过,或撤销提交出库 需同时解锁出库信息 //20160120改为直接算是提交出库
{
//_count = ImportSalesDAL.UnLockSaleStatus(SALESNO);
//if (_count != -1) { _count = ImportSalesDAL.SetSalesAudit(SALESNO); }
_count = ImportSalesDAL.SetSalesAudit(SALESNO);
_count = _count+ImportSalesDAL.LockSaleStatus(SALESNO);
}
if (SALESTATUS == "2") //提交出库(锁定销售单) //实际上不由前台调取 而由/Import/ImportDelivery/LockDelivery生成
{
_count = ImportSalesDAL.LockSaleStatus(SALESNO);
}
if (SALESTATUS == "3") //完结 只改状态
{
_count = ImportSalesDAL.SetSalesOver(SALESNO);
}
if ((SALESTATUS == "1" || SALESTATUS == "0") && _count == -1)
{
var json = JsonConvert.Serialize(new { Success = false, Message = "已经进行出库操作,不能解锁", totalCount = _count });
return new ContentResult() { Content = json };
}
else {
var json = JsonConvert.Serialize(new { Success = true, Message = "设置成功", totalCount = _count });
return new ContentResult() { Content = json };
}
}
public ContentResult SetRKState ( string GID, string PASSED )//仅仅修改认款状态值
{//认款未出库
var _count = ImportSalesDAL.SetRKState(GID,PASSED);
var json = JsonConvert.Serialize(new { Success = true, Message = "设置成功", totalCount = _count });
return new ContentResult() { Content = json };
}
public ContentResult GetSALESNO ( string BSNO ) {
var SALESNO = ImportSalesDAL.GetSALESNO(BSNO);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = true,
Message = "获取完成",
Data = SALESNO
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetSalesStateDataList ( int start, int limit, string sort, string condition )
{
var dataList = ImportSalesDAL.GetSalesStateDataList(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 GetSalesAdvancePay_state_DELList ( int start, int limit, string sort, string condition )
{
var dataList = ImportSalesDAL.GetSalesAdvancePay_state_DELList(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 SaveSalesState ( string YSYFNO, string SalesStateBody, string SalesStateDelBody )
{
var SalesStateBodyList = JsonConvert.Deserialize<List<SalesStateAuditmb>>(SalesStateBody);
var SalesStateBodyDelList = JsonConvert.Deserialize<List<SalesStateAuditmb>>(SalesStateDelBody);
var SalesStateDelList = new List<SalesAdvancePay_state_DELmb>();
if (SalesStateDelBody!="")
{
foreach (var _D in SalesStateBodyDelList)
{
var SalesStateDel = new SalesAdvancePay_state_DELmb();
SalesStateDel.GID = _D.GID;
SalesStateDel.SALESNO = _D.SALESNO;
SalesStateDel.DOAMOUNT = _D.DOAMOUNT;
SalesStateDel.PASSED = _D.PASSED;
SalesStateDel.AD_BILLNO = "";
SalesStateDel.CREATEUSER = _D.CREATEUSER;
SalesStateDel.CREATETIME = _D.CREATETIME;
SalesStateDel.DELETEUSER = Convert.ToString(Session["USERID"]);
SalesStateDel.DELETETIME = DateTime.Now.ToString();
SalesStateDelList.Add(SalesStateDel);
}
}
var SalesStateDelList2 = JsonConvert.Deserialize<List<SalesAdvancePay_state_DELmb>>("");
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("AD_BILLNO", YSYFNO,
ModelObjectConvert<SalesStateAuditmb>.ToModelObjectList(SalesStateBodyList),
ModelObjectConvert<SalesStateAuditmb>.ToModelObjectList(SalesStateBodyDelList),
ModelObjectConvert<SalesAdvancePay_state_DELmb>.ToModelObjectList(SalesStateDelList),
ModelObjectConvert<SalesAdvancePay_state_DELmb>.ToModelObjectList(SalesStateDelList2)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//账单列表
public ContentResult GetZDList(string condition)
{
var dataList = ImportSalesDAL.GetZDList(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 GetZDDetailList(string condition)
{
var dataList = ImportSalesDAL.GetZDDetailList(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 AddZD(string SALESNO,string type)
{
var head = new Import_SaleZDmb();
head.GID = Guid.NewGuid().ToString();
head.SALESNO = SALESNO;
head.CREATEUSER = Session["SHOWNAME"].ToString();
head.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.OP = Session["SHOWNAME"].ToString();
head.OPDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
if (type == "1"){
head.REMARK = "期货账单";
}
else
{
head.REMARK = "现货账单";
}
var _SH=ImportSalesDAL. GetData("s.SALESNO='"+SALESNO+"'");
var DetailList=new List<Import_SaleZDDetailmb>();
var DetailDelList = new List<Import_SaleZDDetailmb>();
var startdate = new List<GeneralModel>();
var CargoList=new List<Cargomb2>();
if(type=="1"){
CargoList=ImportTradeDAL.GetCargoList(" c.gid in(select CARGO_GID from import_saledetail where SALESNO='"+SALESNO+"')");
var sqlstartdate = new StringBuilder();
sqlstartdate.Append(" select '' GID,dbo.trimdate( ");
sqlstartdate.Append(" case isnull((select dbo.trimdate(Unsealdate) from import_main where ContractNo in(select bsno from import_saledetail where SALESNO='" + SALESNO + "')),'') ");
sqlstartdate.Append(" when '' then (select top 1 wmsdate from wms where Cargo_gid in(select cargo_gid from import_saledetail where SALESNO='" + SALESNO + "')) ");
sqlstartdate.Append(" else isnull((select dbo.trimdate(Unsealdate) from import_main where ContractNo in(select bsno from import_saledetail where SALESNO='" + SALESNO + "')),'') end) GVALUE ");
startdate = BasicDataRefDAL.GeneralSelect(sqlstartdate.ToString());
}
var saledetaillist = ImportSalesDAL.GetDetailList("s.SALESNO='" + SALESNO + "'");
foreach (var _sd in saledetaillist) {
var _D = new Import_SaleZDDetailmb();
_D.GID = Guid.NewGuid().ToString();
_D.SALESNO = SALESNO;
_D.ZD_GID = "";
_D.SALEDETAIL_GID = _sd.GID;
_D.BOXCOUNT = _sd.BOXCOUNT;
_D.CURRENCY = _sd.CURRENCY;
_D.WEIGHT = _sd.WEIGHT;
_D.PRICE = _sd.PRICE;
_D.AMOUNT = _sd.AMOUNT;
_D.EXCHANGERATE_CUST = _sd.Exchangerate_Cust;
_D.PREPAYMENT = _sd.PREPAYMENT_ACT;
if (_D.PREPAYMENT == "") {
_D.PREPAYMENT = "0";
}
_D.FUNDRATE = _sd.FUNDRATE;
var dt = new DateTime();
if (_SH.SALESDATE != "")
{
dt = Convert.ToDateTime(_SH.SALESDATE);
dt = dt.AddDays(3);
_D.STOCKDATE_1 = dt.ToString("yyyy-MM-dd");
}else{
_D.STOCKDATE_1 = _sd.STOCKDATE_2;
}
_D.STOCKDATE_2 = _sd.STOCKDATE_2;
_D.AGENCRATE_CUST = _sd.AGENCRATE_Cust;
_D.REMARK = "";
if (type == "1")
{
//期货账单 重量件数取商品信息的单据重量单据件数
foreach (var _C in CargoList)
{
if (_C.GID == _sd.CARGO_GID)
{
_D.WEIGHT = _C.weight;
_D.BOXCOUNT = _C.BoxCount;
}
}
if (startdate[0].GVALUE != "")
_D.STOCKDATE_1 = startdate[0].GVALUE;
else
_D.STOCKDATE_1 = _sd.STOCKDATE_2;
//_D.REMARK = "期货账单";
}
else {
//_D.REMARK = "现货账单";
}
DetailList.Add(_D);
}
var modb = new ModelObjectRepository();
DBResult result = modb.Save(head
, ModelObjectConvert<Import_SaleZDDetailmb>.ToModelObjectList(DetailList)
, ModelObjectConvert<Import_SaleZDDetailmb>.ToModelObjectList(DetailDelList));
var json = JsonConvert.Serialize(new { Success = result.Success, Message = "查询成功" });
return new ContentResult() { Content = json };
}
public ContentResult DelZD(string data)
{
var head = JsonConvert.Deserialize<Import_SaleZDmb>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head
,"delete from Import_SaleZDDetail where ZD_GID='"+head.GID+"'"
, "delete from CH_FEE_ORDER where BSNO='" + head.GID + "'");
var json = JsonConvert.Serialize(new { Success = result.Success, Message = "查询成功" });
return new ContentResult() { Content = json };
}
public ContentResult SaveZDDetail(string SALESNO, string ZDDetail, string ZDDetaildel)
{
var ZDDetailList = JsonConvert.Deserialize<List<Import_SaleZDDetailmb>>(ZDDetail);
var ZDDetaildelList = JsonConvert.Deserialize<List<Import_SaleZDDetailmb>>(ZDDetaildel);
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("SALESNO", SALESNO,
ModelObjectConvert<Import_SaleZDDetailmb>.ToModelObjectList(ZDDetailList),
ModelObjectConvert<Import_SaleZDDetailmb>.ToModelObjectList(ZDDetaildelList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult MakeOrderFee_RMB2(string ZD_GID,string type)
{
//获取相关费用 计算出目标费用数值
var head = new ImportSalesmb();
var list = ImportSalesDAL.GetDataList(" s.SALESNO=(select SALESNO from import_saleZD where gid='" + ZD_GID + "') ");
if (list.Count > 0)
head = list[0];
//var _BodyList = ImportSalesDAL.GetDetailList(" s.SALESNO='" + SALESNO + "' ", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), "");
var ZDList = ImportSalesDAL.GetZDList(" GID='" + ZD_GID + "'");
var _ZD = ZDList[0];
var _BodyList = ImportSalesDAL.GetZDDetailList(" ZD_GID='" + ZD_GID + "' ");
var OrderFeeList = new List<MsOrderFee_Import>();
var CargoList = new List<Cargomb2>();
//if (type == "1")
//{
CargoList = ImportTradeDAL.GetCargoList(" c.contractno in(select BSNO from import_saledetail where SALESNO in (select SALESNO from Import_SaleZD where GID='" + ZD_GID + "'))");
//}
var AmountAll=0M;
foreach (var _c in CargoList)
{
AmountAll += Convert.ToDecimal(_c.price) * Convert.ToDecimal(_c.weight) * Convert.ToDecimal(_c.Exchangerate);
}
var _count = 0;
foreach (var _SD in _BodyList)
{
var _ = Convert.ToDecimal(_SD.PRICE) * Convert.ToDecimal(_SD.EXCHANGERATE_CUST) * 1000;
var _ = Convert.ToDecimal(_SD.WEIGHT) / 1000;
var _RMB = _ * _;
var _ = Convert.ToDecimal(_SD.BOXCOUNT);
var _ = 0M;
var _ = 0M;
foreach (var _C in CargoList)
{
if (_C.GID == _SD.CARGO_GID)
{
_ = Convert.ToDecimal( _C.BoxCount);
_ = Convert.ToDecimal(_C.BOXCOUNT_ACT);
}
}
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'冷藏费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));// * Convert.ToDecimal(_SD.WEIGHT) / 1000
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select isnull(DATEDIFF(DAY, dbo.trimdate('" + _SD.STOCKDATE_1 + "'), dbo.trimdate('" + _SD.STOCKDATE_2 + "')), 0)+1 "));
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'出入库费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
var _ = _ * _;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'倒柜费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
var _ = _ * _;
if (_ == 0M && _count==0)
{
_ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'倒柜费_每柜') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
_ = _;
}
var _ = _ * _ * _;
var _ = 0M;
if (type == "出入库") {
_ = _ + _;
}
if (type == "倒柜")
{
_ = _;
}
var _ = _RMB + _;
var _ = Convert.ToDecimal(_SD.PREPAYMENT);
var _ = _ - _;
var _= Convert.ToDecimal(ImportSalesDAL.GetField("select charindex('调快',m.remark_6) TKINDEX from import_main m where contractno=(select contractno from import_cargo where gid='" + _SD.CARGO_GID + "')"));
if (_ > 0 )
{
var _C_Amount = 0M;
foreach (var _c in CargoList)
{
if (_c.GID == _SD.CARGO_GID)
{
_C_Amount = Convert.ToDecimal(_c.price) * Convert.ToDecimal(_c.weight) * Convert.ToDecimal(_c.Exchangerate);
}
}
_ = 1000 * _C_Amount / AmountAll;
}
else
{
_ = 0;
}
var _ = Convert.ToDecimal(_SD.FUNDRATE);
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select isnull(DATEDIFF(DAY, dbo.trimdate('" + _SD.STOCKDATE_1 + "'), dbo.trimdate('" + _SD.STOCKDATE_2 + "')), 0)+1 "));
if (_ZD.REMARK == "期货账单")
{
_ = _RMB + _ + _;
}
var _ = _ * _ * _ / 30;
if (_ZD.REMARK == "期货账单" && type == "倒柜")
{
_ = 0M;
}
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select substring(sd.PRICEREMARK,charindex('+',sd.PRICEREMARK)+1,len(sd.PRICEREMARK)) from import_saledetail sd where gid='" + _SD.SALEDETAIL_GID + "'"));
var _ = _ * _;
var _ = _ + _ + _;
if (_ZD.REMARK == "期货账单")
{
_ = _ - _;
}
var = NewOrderFee2(head.CUSTOMERNAME, "单价吨", _, _SD);
OrderFeeList.Add();
if (_ZD.REMARK == "期货账单")
{
var = NewOrderFee2(head.CUSTOMERNAME, "单据吨数", _, _SD);
OrderFeeList.Add();
}
if (_ZD.REMARK == "期货账单")
{
var = NewOrderFee2(head.CUSTOMERNAME, "销售吨数", _, _SD);
OrderFeeList.Add();
}
var = NewOrderFee2(head.CUSTOMERNAME, "件数", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "单据件数", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "入库件数", _, _SD);
OrderFeeList.Add();
var RMB = NewOrderFee2(head.CUSTOMERNAME, "货款RMB", _RMB, _SD);
OrderFeeList.Add(RMB);
if (type == "出入库")
{
var = NewOrderFee2(head.CUSTOMERNAME, "出入库费率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "出入库费", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "冷藏费", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "冷藏费率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "冷藏天数", _, _SD);
OrderFeeList.Add();
}
if (type == "倒柜")
{
var = NewOrderFee2(head.CUSTOMERNAME, "倒柜费率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "倒柜费", _, _SD);
OrderFeeList.Add();
}
var = NewOrderFee2(head.CUSTOMERNAME, "冷库费用", _, _SD);
OrderFeeList.Add();
if (_ZD.REMARK == "期货账单")
{
var = NewOrderFee2(head.CUSTOMERNAME, "价格备注费率", _, _SD);
OrderFeeList.Add();
if (type == "倒柜")
{
//////
}
if (type == "出入库")
{
var = NewOrderFee2(head.CUSTOMERNAME, "资金利息利率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "资金占用时间", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "资金利息", _, _SD);
OrderFeeList.Add();
}
var = NewOrderFee2(head.CUSTOMERNAME, "调快费", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "其他费用", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "总应收", _, _SD);
OrderFeeList.Add();
}
var = NewOrderFee2(head.CUSTOMERNAME, "货款应收", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "定金", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "应付尾款", _, _SD);
OrderFeeList.Add();
_count++;
}
var chfeeDelBodyList = JsonConvert.Deserialize<List<MsOrderFee_Import>>("");
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("BsNo", ZD_GID,
ModelObjectConvert<MsOrderFee_Import>.ToModelObjectList(OrderFeeList),
ModelObjectConvert<MsOrderFee_Import>.ToModelObjectList(chfeeDelBodyList)
);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult MakeOrderFee_USD2(string ZD_GID,string type)
{
//获取相关费用 计算出目标费用数值
var head = new ImportSalesmb();
var list = ImportSalesDAL.GetDataList(" s.SALESNO=(select SALESNO from import_saleZD where gid='" + ZD_GID + "') ");
if (list.Count > 0)
head = list[0];
var _BodyList = ImportSalesDAL.GetZDDetailList(" ZD_GID='" + ZD_GID + "' ");
var OrderFeeList = new List<MsOrderFee_Import>();
var GDDATA = ImportTradeDAL.GetData_ALL(" M.contractno in(select BSNO from Import_Saledetail where SALESNO in(select SALESNO from Import_SaleZD where GID='" + ZD_GID + "')) ", CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_UserName(Request), CookieConfig.GetCookie_CompanyId(Request));
var CargoList = new List<Cargomb2>();
//if (type == "1")
//{
CargoList = ImportTradeDAL.GetCargoList(" c.contractno in(select BSNO from import_saledetail where SALESNO in (select SALESNO from Import_SaleZD where GID='" + ZD_GID + "'))");
//}
var AmountAll = 0M;
foreach (var _c in CargoList)
{
AmountAll += Convert.ToDecimal(_c.price) * Convert.ToDecimal(_c.weight) * Convert.ToDecimal(_c.Exchangerate);
}
var = 0M;
foreach (var _SD1 in _BodyList)
{
+= Convert.ToDecimal(_SD1.WEIGHT);
}
var _count = 0;
foreach (var _SD in _BodyList)
{
var CargoList2 = ImportTradeDAL.GetCargoList(" c.gid='" + _SD.CARGO_GID + "'");
var Cargo = CargoList2[0];
var _ = Convert.ToDecimal(_SD.PRICE) * 1000;
var _ = Convert.ToDecimal(_SD.WEIGHT) / 1000;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select charindex('调快',m.remark_6) TKINDEX from import_main m where contractno=(select contractno from import_cargo where gid='" + _SD.CARGO_GID + "')"));
if (_ > 0)
{
var _C_Amount = Convert.ToDecimal(Cargo.price) * Convert.ToDecimal(Cargo.weight) * Convert.ToDecimal(Cargo.Exchangerate);
_ = 1000 * _C_Amount / AmountAll;
}
//var _件数 = Convert.ToDecimal(_SD.BOXCOUNT);
var _ = Convert.ToDecimal(_SD.EXCHANGERATE_CUST);
var _ = _ * _;
var _RMB = _ * _ * _;
var _ = _RMB * 0.001M;
var _ = 150 * _ / ( / 1000);
{
var _C_Amount = Convert.ToDecimal(Cargo.price) * Convert.ToDecimal(Cargo.weight) * Convert.ToDecimal(Cargo.Exchangerate);
_ = 150 * _C_Amount / AmountAll;
}
var _ = _RMB + _ + _;
var _ = Convert.ToDecimal(Cargo.price_limit) * 1000;
var _ = Convert.ToDecimal(Cargo.Exchangerate_Customs);
//var _采购价吨 = Convert.ToDecimal(Cargo.price) * 1000;
var _ = Convert.ToDecimal(Cargo.baolv);
var _ = 0M;
if (_ > _)
{
_ = _ * _ * _ * _;
}
else
{
_ = _ * _ * _ * _;
}
var _ = Convert.ToDecimal(Cargo.tax);
var _ = Convert.ToDecimal(Cargo.tax_zz);
var _ = _ * _;
var _ = (_ + _) * _;
var _ = Convert.ToDecimal(_SD.AGENCRATE_CUST);
var _ = _ * _;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select substring(sd.PRICEREMARK,charindex('+',sd.PRICEREMARK)+1,len(sd.PRICEREMARK)) from import_saledetail sd where gid='" + _SD.SALEDETAIL_GID + "'"));
var _ = Convert.ToDecimal(_SD.FUNDRATE);
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select isnull(DATEDIFF(DAY, dbo.trimdate('" + _SD.STOCKDATE_1 + "'), dbo.trimdate('" + _SD.STOCKDATE_2 + "')), 0)+1 "));
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'冷藏费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));//* Convert.ToDecimal(_SD.WEIGHT) / 1000
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select isnull(DATEDIFF(DAY, dbo.trimdate('" + _SD.STOCKDATE_1 + "'), dbo.trimdate('" + _SD.STOCKDATE_2 + "')), 0)+1 "));
//var _冷藏费 = _冷藏费率 * _冷藏天数 * _销售吨数;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'出入库费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'倒柜费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
var _ = _ * _;
if (_ == 0M && _count == 0)
{
_ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'倒柜费_每柜') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
_ = _;
}
//var _货款应收 = 货款RMB.Amount + (_冷藏费率 * _冷藏天数 * _销售吨数) + _出入库费率 * _销售吨数;
var _ = _ * _ * _;
var _ = _ * _;
//var _倒柜费 = _销售吨数 * _倒柜费率;
var _ = 0M;
if (type == "出入库")
{
_ = _ + _;
}
if (type == "倒柜")
{
_ = _;
}
var _ = Convert.ToDecimal(_SD.PREPAYMENT);
var _ = _RMB + _ + _ + _ + _ + _ +_+ _;
var _ = _ * _ * _ / 30;
var _ = _SD.BOXCOUNT;
var _ = 0M;
foreach (var _C in CargoList)
{
if (_C.GID == _SD.CARGO_GID)
{
_ = Convert.ToDecimal(_C.BOXCOUNT_ACT);
}
}
var _ = _ * _;
var _ = 0M;
if (type == "出入库")
{
_=_ + _ + _;
}
if (type == "倒柜")
{
_ = _ + _;
}
var _ = _ - _;
var = NewOrderFee2(head.CUSTOMERNAME, "单价吨", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "销售吨数", _, _SD);
OrderFeeList.Add();
//var 件数 = NewOrderFee2(head.CUSTOMERNAME, "件数", _件数, _SD);
//OrderFeeList.Add(件数);
var = NewOrderFee2(head.CUSTOMERNAME, "应收账单汇率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "货款币别", _, _SD);
OrderFeeList.Add();
var RMB = NewOrderFee2(head.CUSTOMERNAME, "货款RMB", _RMB, _SD);
OrderFeeList.Add(RMB);
var = NewOrderFee2(head.CUSTOMERNAME, "手续费", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "电汇费", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "总货款", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "海关限价吨", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "海关汇率", _, _SD);
OrderFeeList.Add();
//var 采购价吨 = NewOrderFee2(head.CUSTOMERNAME, "采购价吨", _采购价吨, _SD);
//OrderFeeList.Add(采购价吨);
var = NewOrderFee2(head.CUSTOMERNAME, "保率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "完税金额", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "关税税率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "增值税税率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "关税", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "增值税", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "代理费单价", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "代理费", _, _SD);
OrderFeeList.Add();
var = NewOrderFee3(head.CUSTOMERNAME, "调快费", _, _SD,GDDATA.remark_6);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "价格备注费率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "货款应收", _, _SD);
OrderFeeList.Add();
//var 出入库费率 = NewOrderFee2(head.CUSTOMERNAME, "出入库费率", _出入库费率, _SD);
//OrderFeeList.Add(出入库费率);
//var 倒柜费率 = NewOrderFee2(head.CUSTOMERNAME, "倒柜费率", _倒柜费率, _SD);
//OrderFeeList.Add(倒柜费率);
if (type == "出入库")
{
var = NewOrderFee2(head.CUSTOMERNAME, "出入库费率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "出入库费", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "冷藏费", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "冷藏费率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "冷藏天数", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "资金利息利率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "资金占用时间", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "资金利息", _, _SD);
OrderFeeList.Add();
}
if (type == "倒柜")
{
var = NewOrderFee2(head.CUSTOMERNAME, "倒柜费率", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "倒柜费", _, _SD);
OrderFeeList.Add();
}
var = NewOrderFee2(head.CUSTOMERNAME, "冷库费用", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "定金", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "入库件数", Convert.ToDecimal(_), _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "件数", Convert.ToDecimal(_), _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "其他费用", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "总应收", _, _SD);
OrderFeeList.Add();
var = NewOrderFee2(head.CUSTOMERNAME, "应付尾款", _, _SD);
OrderFeeList.Add();
_count++;
}
var chfeeDelBodyList = JsonConvert.Deserialize<List<MsOrderFee_Import>>("");
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("BsNo", ZD_GID,
ModelObjectConvert<MsOrderFee_Import>.ToModelObjectList(OrderFeeList),
ModelObjectConvert<MsOrderFee_Import>.ToModelObjectList(chfeeDelBodyList)
);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
private MsOrderFee_Import NewOrderFee2(string CUSTOMERNAME, string FEENAME, decimal AMOUNT, Import_SaleZDDetailmb _ZD)
{
var _r = new MsOrderFee_Import();
_r.CustomerName = CUSTOMERNAME;
_r.FeeName = FEENAME;
_r.Amount = AMOUNT;
_r.GId = System.Guid.NewGuid().ToString();
_r.FeeType = 1;
_r.BsNo = "";
_r.CARGO_GID = _ZD.CARGO_GID;
_r.BXGID = _ZD.ZD_GID;
_r.MODIFIEDTIME = System.DateTime.Now.ToString();
_r.MODIFIEDUSER = Session["USERID"].ToString();
_r.UnitPrice = 0;
return _r;
}
private MsOrderFee_Import NewOrderFee3 ( string CUSTOMERNAME, string FEENAME, decimal AMOUNT, Import_SaleZDDetailmb _ZD,string Remark )
{
var _r = new MsOrderFee_Import();
_r.CustomerName = CUSTOMERNAME;
_r.FeeName = FEENAME;
_r.Amount = AMOUNT;
_r.GId = System.Guid.NewGuid().ToString();
_r.FeeType = 1;
_r.BsNo = "";
_r.CARGO_GID = _ZD.CARGO_GID;
_r.BXGID = _ZD.ZD_GID;
_r.MODIFIEDTIME = System.DateTime.Now.ToString();
_r.MODIFIEDUSER = Session["USERID"].ToString();
_r.Remark = Remark;
_r.UnitPrice = 0;
return _r;
}
public ContentResult SetUse ( string DetailBody )
{
var DetailbodyList = JsonConvert.Deserialize<List<Import_SaleZDmb>>(DetailBody);
var GIDList = "";
foreach (var _d in DetailbodyList)
{
if (GIDList == "")
{
GIDList = "'" + _d.GID + "'";
}
else
{
GIDList = GIDList + ",'" + _d.GID + "'";
}
}
var SQL = "Update Import_SaleZD set ISUSE=1-isnull(ISUSE,0) where GID in(" + GIDList + ")";
var _r = PubSysDAL.ExecSql(SQL);
var jsonRespose = new JsonResponse();
if (_r > 0)
{
jsonRespose = new JsonResponse
{
Success = true,
Message = "设置完成",
Data = null
};
}
else
jsonRespose = new JsonResponse
{
Success = false,
Message = "设置0条数据",
Data = null
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 生成账单费用
public ContentResult GetOrderDataList2(string strCondition)
{
var dataList = ImportSalesDAL.GetOrderDataList(strCondition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetOrderDataList(string billno)
{
var dataList = ImportSalesDAL.GetOrderDataList("BsNo='" + billno + "'" , 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 MakeOrderFee_RMB ( string SALESNO )
{
//获取相关费用 计算出目标费用数值
var head=new ImportSalesmb();
var list = ImportSalesDAL.GetDataList(" s.SALESNO='" + SALESNO + "' ", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
var _BodyList = ImportSalesDAL.GetDetailList(" s.SALESNO='" + SALESNO + "' ", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), "");
var OrderFeeList = new List<MsOrderFee>();
foreach (var _SD in _BodyList) {
var RMB = NewOrderFee(head.CUSTOMERNAME, "货款RMB", Convert.ToDecimal(_SD.AMOUNTRMB), _SD.CARGO_GID);
OrderFeeList.Add(RMB);
var _ = Convert.ToDecimal(_SD.PRICERMB)*1000;
var _ = Convert.ToDecimal(_SD.WEIGHT)/1000;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'冷藏费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"))*Convert.ToDecimal(_SD.WEIGHT)/1000;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select isnull(DATEDIFF(DAY, dbo.trimdate(dateadd(day,3,'"+head.SALESDATE+"')), dbo.trimdate('"+_SD.STOCKDATE_2+"')), 0)+1 ")) ;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'出入库费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'")) ;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'倒柜费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
var _ = RMB.Amount + (_ * _ * _) + _ * _;
var _ = Convert.ToDecimal(_SD.PREPAYMENT_ACT);
var _ = _ - _;
var = NewOrderFee(head.CUSTOMERNAME, "单价吨", _,_SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "销售吨数", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "冷藏费率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "冷藏天数", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "出入库费率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "倒柜费率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "货款应收", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "定金", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "应付尾款", _, _SD.CARGO_GID);
OrderFeeList.Add();
}
var chfeeDelBodyList = JsonConvert.Deserialize<List<MsOrderFee>>("");
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("BsNo", head.SALESNO,
ModelObjectConvert<MsOrderFee>.ToModelObjectList(OrderFeeList),
ModelObjectConvert<MsOrderFee>.ToModelObjectList(chfeeDelBodyList)
);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult MakeOrderFee_USD ( string SALESNO )
{
//获取相关费用 计算出目标费用数值
var head = new ImportSalesmb();
var list = ImportSalesDAL.GetDataList(" s.SALESNO='" + SALESNO + "' ", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
var _BodyList = ImportSalesDAL.GetDetailList(" s.SALESNO='" + SALESNO + "' ", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), "");
var OrderFeeList = new List<MsOrderFee>();
var = 0M;
foreach (var _SD1 in _BodyList) {
+= Convert.ToDecimal(_SD1.WEIGHT);
}
foreach (var _SD in _BodyList)
{
var CargoList = XXHDAL.GetCargoList(" c.gid='"+_SD.CARGO_GID+"'");
var Cargo = CargoList[0];
var _ = Convert.ToDecimal(_SD.PRICE) * 1000;
var _ = Convert.ToDecimal(_SD.WEIGHT) / 1000;
var _=Convert.ToDecimal(_SD.Exchangerate_Cust);
var _ =_*_;
var _RMB = _ * _ * _;
var _ = _RMB*0.001M;
var _ = 150 * _ / (/1000);
var _ = _RMB + _ + _;
var _ = Convert.ToDecimal(Cargo.price_limit)*1000;
var _ = Convert.ToDecimal(Cargo.Exchangerate_Customs);
var _ =Convert.ToDecimal(Cargo.price)*1000;
var _=Convert.ToDecimal(Cargo.baolv);
var _ = 0M;
if (_ > _) {
_ = _ * _ * _ * _;
} else {
_ = _ * _ * _ * _;
}
var _ = Convert.ToDecimal(Cargo.tax);
var _ = Convert.ToDecimal(Cargo.tax_zz);
var _ = _ * _ * _;
var _ = (_ + _) * _;
var _ = Convert.ToDecimal(_SD.AGENCRATE_Cust);
var _ = _ * _;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select charindex('调快',m.remark_6) TKINDEX from import_main m where contractno=(select contractno from import_cargo where gid='" + _SD.CARGO_GID + "')")) ;
if (_ > 0) { _ = 1000; }
else{
_=0;
}
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select substring(sd.PRICEREMARK,charindex('+',sd.PRICEREMARK)+1,len(sd.PRICEREMARK)) from import_saledetail sd where gid='" + _SD.GID + "'"));
var _ = _RMB + _ + _ + _ + _ + _;
var _ = Convert.ToDecimal(_SD.FUNDRATE);
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select isnull(DATEDIFF(DAY,dateadd(day,3,s.SALESDATE), sd.STOCKDATE_2), 0)+1 from import_saledetail sd left join import_sales s on s.salesno=sd.salesno where sd.gid='" + _SD.GID + "'")) ;
var _ = _ * _ * _/30;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'冷藏费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'")) * Convert.ToDecimal(_SD.WEIGHT) / 1000;
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select isnull(DATEDIFF(DAY, dbo.trimdate(dateadd(day,3,'" + head.SALESDATE + "')), dbo.trimdate('" + _SD.STOCKDATE_2 + "')), 0)+1 "));
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'出入库费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
var _ = Convert.ToDecimal(ImportSalesDAL.GetField("select top 1 dbo.[Get_ClientFee](STORAGENAME,'倒柜费') from WMS where Cargo_gid='" + _SD.CARGO_GID + "'"));
//var _货款应收 = 货款RMB.Amount + (_冷藏费率 * _冷藏天数 * _销售吨数) + _出入库费率 * _销售吨数;
var _ = _ * _ * _;
var _ = _ * _;
var _ = _ * _;
var _ = _ + _ + _;
var _ = Convert.ToDecimal(_SD.PREPAYMENT_ACT);
var _ = _SD.BOXCOUNT;
var _ = _ * _;
var _ = _ + _ + _;
var _ = _ - _;
var = NewOrderFee(head.CUSTOMERNAME, "单价吨", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "销售吨数", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "应收账单汇率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "货款币别", _, _SD.CARGO_GID);
OrderFeeList.Add();
var RMB = NewOrderFee(head.CUSTOMERNAME, "货款RMB", _RMB, _SD.CARGO_GID);
OrderFeeList.Add(RMB);
var = NewOrderFee(head.CUSTOMERNAME, "手续费", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "电汇费", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "总货款", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "海关限价吨", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "海关汇率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "采购价吨", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "保率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "完税金额", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "关税税率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "增值税税率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "关税", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "增值税", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "代理费单价", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "代理费", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "调快费", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "价格备注费率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "货款应收", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "资金利息利率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "资金占用时间", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "资金利息", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "冷藏费率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "冷藏天数", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "出入库费率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "倒柜费率", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "冷藏费", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "出入库费", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "倒柜费", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "冷库费用", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "定金", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "入库件数", Convert.ToDecimal(_), _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "其他费用", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "总应收", _, _SD.CARGO_GID);
OrderFeeList.Add();
var = NewOrderFee(head.CUSTOMERNAME, "应付尾款", _, _SD.CARGO_GID);
OrderFeeList.Add();
}
var chfeeDelBodyList = JsonConvert.Deserialize<List<MsOrderFee>>("");
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("BsNo", head.SALESNO,
ModelObjectConvert<MsOrderFee>.ToModelObjectList(OrderFeeList),
ModelObjectConvert<MsOrderFee>.ToModelObjectList(chfeeDelBodyList)
);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
private MsOrderFee NewOrderFee ( string CUSTOMERNAME, string FEENAME, decimal AMOUNT ,string CARGO_GID) {
var _r = new MsOrderFee();
_r.CustomerName = CUSTOMERNAME;
_r.FeeName = FEENAME;
_r.Amount = AMOUNT;
_r.GId = System.Guid.NewGuid().ToString();
_r.FeeType = 1;
_r.BsNo = "";
_r.CARGO_GID = CARGO_GID;
_r.MODIFIEDTIME = System.DateTime.Now.ToString();
_r.MODIFIEDUSER = Session["USERID"].ToString();
return _r;
}
public ContentResult SaveOrderFee ( string bsno, string type, string OrderFeeBody )
{
var chfeeBodyList = JsonConvert.Deserialize<List<MsOrderFee>>(OrderFeeBody);
var chfeeDelBodyList = JsonConvert.Deserialize<List<MsOrderFee>>("");
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("BsNo", bsno,
ModelObjectConvert<MsOrderFee>.ToModelObjectList(chfeeBodyList),
ModelObjectConvert<MsOrderFee>.ToModelObjectList(chfeeDelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 参照部分
#endregion
}
}