@ -30,6 +30,8 @@ using DSWeb.Common.DB;
using DSWeb.MvcShipping.Models.MsChFee ;
using com.sun.crypto.provider ;
using System.Linq ;
using DSWeb.Areas.MvcShipping.Models.MsOpSeaeBaoXian ;
using Newtonsoft.Json ;
namespace DSWeb.MvcShipping.DAL.MsSeaeOrderDAL
{
@ -767,7 +769,7 @@ namespace DSWeb.MvcShipping.DAL.MsSeaeOrderDAL
}
else
{
var cmdUpdate = db . GetSqlStringCommand ( @"update crm_seaeorderctn set CTNNUM=" + enumValue . CTNNUM + ",CTNALL='" + enumValue . CTNALL + "',REMARK='" + enumValue . REMARK + "' where ORDNO='" + enumValue . ORDNO + "' AND CTN_ID='" + enumValue . CTN_ID + "' AND Price_YS=" + enumValue . Price_YS + " AND Price_YF=" + enumValue . Price_YF + " ") ;
var cmdUpdate = db . GetSqlStringCommand ( @"update crm_seaeorderctn set CTNNUM=" + enumValue . CTNNUM + ",CTNALL='" + enumValue . CTNALL + "',REMARK='" + enumValue . REMARK + "' ,Price_YS=" + enumValue . Price_YS + " , Price_YF=" + enumValue . Price_YF + " where ORDNO='" + enumValue . ORDNO + "' AND CTN_ID='" + enumValue . CTN_ID + "' ") ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
@ -1741,11 +1743,11 @@ namespace DSWeb.MvcShipping.DAL.MsSeaeOrderDAL
#region 通过微信小程序保存时 产生ch_fee_order
public static List< MsSeaeOrderCtn > CreateFeeOrder ( MsSeaeOrder OrderData ) {
public static DBResult CreateFeeOrder ( MsSeaeOrder OrderData , string USERID ) {
//var result = new DBResult() ;
var result = new DBResult ( ) ;
//result.OK() ;
result . OK ( ) ;
var updbody = new List < MsSeaeOrderCtn > ( ) ;
@ -1754,19 +1756,25 @@ namespace DSWeb.MvcShipping.DAL.MsSeaeOrderDAL
var bodycondition = " ordno='" + OrderData . ORDNO + "'" ;
var bodylist = GetBodyList ( bodycondition ) ;
if ( bodylist ! = null & & bodylist . Count > 0 & & bodylist . Exists ( x = > x . Price_YF > 0 | | x . Price_YS > 0 ) )
{
//生成费用 应收结算对象为委托单位 应付对象为订舱代理
var cdc = new CommonDataContext ( ) ;
var addFeeList = new List < ch_fee_order_md > ( ) ;
var cdc = new CommonDataContext ( ) ;
var currentorderfee = cdc . ch_fee_order . Where ( x = > x . BSNO = = OrderData . BSNO & & x . FEENAME = = "海运费" ) . ToList ( ) ;
var 币 别 费 率 List = BasicDataRefDAL . GetcurrRef List( ) ;
var addFeeList = new List < ch_fee_order_md > ( ) ;
try
{
if ( bodylist . Exists ( x = > x . Price_Y S > 0 ) )
if ( bodylist ! = null & & bodylist . Count > 0 & & bodylist . Exists ( x = > x . Price_Y F > 0 | | x . Price_Y S > 0 ) )
{
foreach ( var ctn in bodylist . Where ( x = > x . Price_YS > 0 ) )
//生成费用 应收结算对象为委托单位 应付对象为订舱代理
var currentorderfee = cdc . ch_fee_order . Where ( x = > x . BSNO = = OrderData . BSNO & & x . FEENAME = = "海运费" ) . ToList ( ) ;
foreach ( var ctn in bodylist . Where ( x = > x . Price_YS > 0 ) )
{
if ( ! currentorderfee . Exists ( x = > x . FEETYPE = = 1 & & x . CTN_ID = = ctn . CTN_ID ) )
{ //目前费用里面没有这个箱型的单价 生成之
@ -1779,19 +1787,29 @@ namespace DSWeb.MvcShipping.DAL.MsSeaeOrderDAL
newfee . CUSTOMERTYPE = "委托单位" ;
newfee . CUSTOMERNAME = OrderData . CUSTOMERNAME ;
newfee . CTN_ID = ctn . CTN_ID ;
newfee . ENTEROPERATOR = USERID ;
newfee . CURRENCY = "USD" ;
newfee . EXCHANGERATE = 1 ;
if ( 币 别 费 率 List . Exists ( x = > x . codename = = "USD" ) ) {
newfee . EXCHANGERATE = Convert . ToDecimal ( 币 别 费 率 List . First ( x = > x . codename = = "USD" ) . defaultrate ) ;
}
addFeeList . Add ( newfee ) ;
}
else {
//目前费用里面有了这个箱的单价 看看单价是否和箱信息中相同,如果不同则修改箱信息中的单价
var _fee = currentorderfee . First ( x = > x . FEETYPE = = 1 & & x . CTN_ID = = ctn . CTN_ID ) ;
var updrec = ctn ;
ctn . CTNALL = _fee . UNIT ;
ctn . Price_YS = _fee . UNITPRICE ;
ctn . CTNNUM = ( int ) _fee . QUANTITY ;
updbody . Add ( ctn ) ;
}
}
//else {
// //目前费用里面有了这个箱的单价 看看单价是否和箱信息中相同,如果不同则修改箱信息中的单价
// var _fee = currentorderfee.First(x => x.FEETYPE == 1 && x.CTN_ID == ctn.CTN_ID);
// var updrec = ctn;
// ctn.CTNALL= _fee.UNIT;
// ctn.Price_YS = _fee.UNITPRICE;
// ctn.CTNNUM =(int) _fee.QUANTITY;
// updbody.Add(ctn);
//}
foreach ( var ctn in bodylist . Where ( x = > x . Price_YF > 0 ) )
{
if ( ! currentorderfee . Exists ( x = > x . FEETYPE = = 2 & & x . CTN_ID = = ctn . CTN_ID ) )
{ //目前费用里面没有这个箱型的单价 生成之
var newfee = new ch_fee_order_md ( ) ;
@ -1803,45 +1821,61 @@ namespace DSWeb.MvcShipping.DAL.MsSeaeOrderDAL
newfee . CUSTOMERTYPE = "订舱代理" ;
newfee . CUSTOMERNAME = OrderData . FORWARDER ;
newfee . CTN_ID = ctn . CTN_ID ;
addFeeList . Add ( newfee ) ;
}
else
{
//目前费用里面有了这个箱的单价 看看单价是否和箱信息中相同,如果不同则修改箱信息中的单价
var _fee = currentorderfee . First ( x = > x . FEETYPE = = 2 & & x . CTN_ID = = ctn . CTN_ID ) ;
newfee . ENTEROPERATOR = USERID ;
if ( updbody . Exists ( x = > x . CTN_ID = = ctn . CTN_ID ) )
newfee . CURRENCY = "USD" ;
newfee . EXCHANGERATE = 1 ;
if ( 币 别 费 率 List . Exists ( x = > x . codename = = "USD" ) )
{
updbody . First ( x = > x . CTN_ID = = ctn . CTN_ID ) . CTNALL = _fee . UNIT ;
updbody . First ( x = > x . CTN_ID = = ctn . CTN_ID ) . Price_YF = _fee . UNITPRICE ;
updbody . First ( x = > x . CTN_ID = = ctn . CTN_ID ) . CTNNUM = ( int ) _fee . QUANTITY ;
}
else {
var updrec = ctn ;
ctn . CTNALL = _fee . UNIT ;
ctn . Price_YF = _fee . UNITPRICE ;
ctn . CTNNUM = ( int ) _fee . QUANTITY ;
updbody . Add ( ctn ) ;
newfee . EXCHANGERATE = Convert . ToDecimal ( 币 别 费 率 List . First ( x = > x . codename = = "USD" ) . defaultrate ) ;
}
addFeeList . Add ( newfee ) ;
}
}
//else
//{
// //目前费用里面有了这个箱的单价 看看单价是否和箱信息中相同,如果不同则修改箱信息中的单价
// var _fee = currentorderfee.First(x => x.FEETYPE == 2 && x.CTN_ID == ctn.CTN_ID);
// if (updbody.Exists(x => x.CTN_ID == ctn.CTN_ID))
// {
// updbody.First(x => x.CTN_ID == ctn.CTN_ID).CTNALL = _fee.UNIT;
// updbody.First(x => x.CTN_ID == ctn.CTN_ID).Price_YF = _fee.UNITPRICE;
// updbody.First(x => x.CTN_ID == ctn.CTN_ID).CTNNUM = (int)_fee.QUANTITY;
// }
// else {
// var updrec = ctn;
// ctn.CTNALL = _fee.UNIT;
// ctn.Price_YF = _fee.UNITPRICE;
// ctn.CTNNUM = (int)_fee.QUANTITY;
// updbody.Add(ctn);
// }
//}
}
}
if ( addFeeList ! = null & & addFeeList . Count > 0 ) {
if ( addFeeList ! = null & & addFeeList . Count > 0 )
{
cdc . ch_fee_order . AddRange ( addFeeList ) ;
cdc . SaveChanges ( ) ;
}
//if (updbody != null && updbody.Count > 0) {
//}
}
return updbody ;
return result ;
}
catch ( Exception e ) {
result . SetErrorInfo ( JsonConvert . SerializeObject ( e ) ) ;
return result ;
}
}
public static DBResult DeleteFeeOrder ( MsSeaeOrder OrderData )
{