dev
dengyu 3 weeks ago
parent 449678ca40
commit 6303605130

@ -3695,8 +3695,10 @@ namespace DSWeb.Common.DB
public void SetAmount(string _UNIT,decimal _PRICE, decimal _QUANTITY=1)
{
//QUANTITY = 1;
UNIT = _UNIT;
UNITPRICE = _PRICE;
TAXUNITPRICE = _PRICE;
//EXCHANGERATE = 1;

@ -49,6 +49,7 @@ using DSWeb.MvcShipping.Models.MsChFee;
using static DSWeb.Areas.CommMng.DAL.PublicAPIDAL.OAHelper;
using Microsoft.AspNet.SignalR.Hosting;
using DSWeb.MvcShipping.Helper.Repository;
using Quartz.Util;
//using System.Web.Http;
namespace DSWeb.Areas.Dispatch.Controllers
@ -217,6 +218,7 @@ namespace DSWeb.Areas.Dispatch.Controllers
public int limit { get; set; } = 30;
public string bsno { get; set; }
}
/// <summary>
@ -728,6 +730,70 @@ namespace DSWeb.Areas.Dispatch.Controllers
return Json(new { ErrorCode = 500, Message = "发生错误" }, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 获取用户列表
/// </summary>
/// <param name="CUSTOMERNAME"></param>
/// <returns></returns>
///
public class UserActionParam {
public string CODENAME { get; set; }
public string MODULENAME { get; set; }
}
[HttpPost]
public JsonResult GetUserActionRefListRm(EnumQueryInfo QueryInfo)
{
#region 正式逻辑
var openidok = BasicDataRefDAL.GetWxappUserInfo(QueryInfo.AuthCode);
if (!openidok.Success)
{
return Json(new { ErrorCode = 500, Message = $"发生错误:{openidok.Message}" }, JsonRequestBehavior.AllowGet);
}
var userinfo = (VW_user_md)openidok.Data;
#endregion
#region 测试逻辑
//var userinfo = cdc.VW_user .Where(x => x.CODENAME.ToUpper() == "ADMIN").FirstOrDefault();
#endregion
var condition = QueryInfo.condition;
Stream postData = Request.InputStream;
StreamReader sRead = new StreamReader(postData);
string postContent = sRead.ReadToEnd();
sRead.Close();
var searchparam = JsonConvert.DeserializeObject<UserActionParam>(postContent);
if (!string.IsNullOrWhiteSpace(searchparam.CODENAME))
{
if (string.IsNullOrWhiteSpace(QueryInfo.condition))
{
}
else
{
condition = condition + " and ";
}
condition = condition + " (UserCode like '" + searchparam.CODENAME + "%' or UserName like '%" + searchparam.CODENAME + "%') ";
}
List<UserRefModel> evList = BasicDataRefDAL.GetActionUserRefList(condition, searchparam.MODULENAME);
if (evList.Count == 0)
{
return Json(new { success = false });
}
else
{
return Json(new { success = true, data = evList.ToList() });
}
}
#endregion
/// <summary>
@ -3323,6 +3389,9 @@ namespace DSWeb.Areas.Dispatch.Controllers
try
{
//BasicDataRefDAL.SaveLog(JsonConvert.SerializeObject( QueryInfo), "", "wxapp保存销售订舱", "head");
Stream postData = Request.InputStream;
StreamReader sRead = new StreamReader(postData);
string postContent = sRead.ReadToEnd();
@ -3350,6 +3419,8 @@ namespace DSWeb.Areas.Dispatch.Controllers
var aaa = "";
//BasicDataRefDAL.SaveLog(postContent,"","wxapp保存销售订舱","body");
var saveinfo = JsonConvert.DeserializeObject<SaveSeaeOrderParam>(postContent);
var headData = saveinfo.Head;
@ -3365,11 +3436,11 @@ namespace DSWeb.Areas.Dispatch.Controllers
//1 如果没用费用 产生费用
//2 如果有费用 根据费用单价和单位,回写至集装箱的应收应付单价中(找不到对应的就不处理)
var updbodylist= MsSeaeOrderDAL.CreateFeeOrder(headData);
var updbodylist= MsSeaeOrderDAL.CreateFeeOrder(headData, userinfo.USERID);
if (updbodylist != null && updbodylist.Count > 0) {
result = DSWeb.MvcShipping.DAL.MsSeaeOrderDAL.MsSeaeOrderDAL.DoSave(saveinfo.opstatus, userinfo.USERID, userinfo.SHOWNAME, headData, updbodylist);
}
//if (updbodylist != null && updbodylist.Count > 0) {
// result = DSWeb.MvcShipping.DAL.MsSeaeOrderDAL.MsSeaeOrderDAL.DoSave(saveinfo.opstatus, userinfo.USERID, userinfo.SHOWNAME, headData, updbodylist);
//}
return Json(new { ErrorCode = 0,Message= result.Message, Data = result.Data });
}
@ -4126,6 +4197,82 @@ namespace DSWeb.Areas.Dispatch.Controllers
return Json(new { ErrorCode = 500, Message = "发生错误" }, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 获取销售订舱利润
/// </summary>
/// <param name="CUSTOMERNAME"></param>
/// <returns></returns>
[HttpPost]
public ActionResult GetOrderGainList(EnumQueryInfo QueryInfo)
{
var cdc = new Common.DB.CommonDataContext();
#region 正式逻辑
var openidok = BasicDataRefDAL.GetWxappUserInfo(QueryInfo.AuthCode);
if (!openidok.Success)
{
return Json(new { ErrorCode = 500, Message = $"发生错误:{openidok.Message}" }, JsonRequestBehavior.AllowGet);
}
var userinfo = (VW_user_md)openidok.Data;
#endregion
#region 测试逻辑
//var userinfo = cdc.VW_user .Where(x => x.CODENAME.ToUpper() == "ADMIN").FirstOrDefault();
#endregion
var _result = Json(new { });
try
{
var bsno = QueryInfo.bsno;
var evList = DSWeb.MvcShipping.DAL.MsChFeeDAL.MsChFeeDAL.GetOrderDataList($" bsno='{bsno}' ");
var = 0m;
var ysamount = 0M;
var yfamount = 0M;
if (evList != null && evList.Count > 0)
{
//计算利润
foreach (var ys in evList.Where(x => x.FeeType == 1))
{
ysamount += ys.Amount * ys.ExChangerate;
}
foreach (var yf in evList.Where(x => x.FeeType == 1))
{
yfamount += yf.Amount * yf.ExChangerate;
}
if (ysamount != 0) {
= (ysamount - yfamount) / ysamount;
}
}
_result = Json(new
{
ErrorCode = 0,
Message = "获取成功",
BaseInfo = new { LRL=, ysamount= ysamount , yfamount = yfamount }
});
return _result;
}
catch (Exception e)
{
BasicDataRefDAL.SaveLog(JsonConvert.SerializeObject(e), e.Message, "wxapp", "查询错误");
_result = Json(new
{
ErrorCode = 500,
Message = e.Message,
Data = e
});
}
return Json(new { ErrorCode = 500, Message = "发生错误" }, JsonRequestBehavior.AllowGet);
}
/// <summary>

@ -1692,6 +1692,11 @@ namespace DSWeb.MvcShipping.Controllers
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
/// <summary>
/// 获取销售订舱的利润
/// </summary>
/// <param name="bsno"></param>
/// <returns></returns>
public ContentResult GetOrderGainList(string bsno)
{
var dataList = MsChFeeDAL.GetOrderGainList("BsNo='" + bsno + "'");

@ -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.GetcurrRefList();
var addFeeList = new List<ch_fee_order_md>();
try
{
if (bodylist.Exists(x => x.Price_YS > 0))
if (bodylist != null && bodylist.Count > 0 && bodylist.Exists(x => x.Price_YF > 0 || x.Price_YS > 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)
{

@ -70,6 +70,8 @@ namespace DSWeb.MvcShipping.Models.MsSeaeOrder
public decimal? Price_YF { get; set; } = 0;
#endregion
public MsSeaeOrderCtn()
{
TableName = "crm_seaeorderctn";

Loading…
Cancel
Save