You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
9.3 KiB
160 lines
9.3 KiB
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain.Entity.ProductManage;
|
|
using NFine.Domain.IRepository.ProductManage;
|
|
using NFine.Repository.ProductManage;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace NFine.Application.ProductManage
|
|
{
|
|
public class PreSellDetailApp
|
|
{
|
|
private IICSProductRepository servicePro = new MaintainRepository();
|
|
//private IICSProductPreSellRepository service = new PreSellRepository();
|
|
private IICSProductPreSellDetailRepository service = new PreSellDetailRepository();
|
|
|
|
public List<ICSProductPreSellDetailEntity> GetList(string itemId, string keyword = "")
|
|
{
|
|
var expression = ExtLinq.True<ICSProductPreSellDetailEntity>();
|
|
if (!string.IsNullOrEmpty(itemId))
|
|
{
|
|
expression = expression.And(t => t.PreSell_Id == itemId);
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
expression = expression.And(t => t.Product_Id.Contains(keyword));
|
|
}
|
|
return service.IQueryable(expression).OrderBy(t => t.PreSellTime).ToList();
|
|
}
|
|
|
|
public DataTable GetList2(string itemId, string keyword)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
#region
|
|
//string sql = @"SELECT DISTINCT a.F_Id,a.Product_Id,c.ProductSN,a.PreSellTime,c.Weight,c.GrossWeight,c.Measurement,c.Shape,
|
|
// c.CertificateNo,(case when c.WHCode ='12' then '评估仓' when c.WHCode ='10' then '成品仓' else '' end ) as WHCodes,
|
|
// (CASE WHEN c.WHCode = '10' THEN c.Price WHEN c.WHCode = '12' THEN c.BasePrice ELSE 0 END ) AS RapaPrice,
|
|
// (CASE WHEN c.WHCode = '10' THEN c.Price WHEN c.WHCode = '12' THEN c.Weight*c.BasePrice ELSE 0 END ) AS Price,
|
|
// (CAST((e.Discount*100) AS VARCHAR(50))+'%') AS Discount,
|
|
// (CASE WHEN c.WHCode = '10' THEN c.Price*e.Discount
|
|
// WHEN c.WHCode = '12' THEN c.Weight*c.BasePrice*(1+e.Discount) ELSE 0 END ) AS Amount,
|
|
// c.Location,c.Other
|
|
// FROM ICSProductPreSellDetail a
|
|
// LEFT JOIN ICSProductPreSell b ON a.PreSell_Id = b.F_Id
|
|
// LEFT JOIN ICSProduct c ON a.Product_Id = c.F_Id
|
|
// LEFT JOIN Sys_Customer d ON b.CustomerId = d.F_Id
|
|
// LEFT JOIN WMS_ZHENGSHI.dbo.ICSPriceRule e ON d.F_CusCode = e.CusCode AND c.WHCode = e.cWHType
|
|
// AND (c.Weight >= e.StartValue AND c.Weight <= e.EndValue)
|
|
// WHERE b.F_Id = '{0}'";
|
|
#endregion
|
|
string sql = @"SELECT DISTINCT a.F_Id,a.Product_Id,c.ProductSN,a.PreSellTime,c.Weight,c.GrossWeight,c.Measurement,c.Shape,
|
|
c.CertificateNo,(CASE WHEN c.WHCode ='12' THEN '评估仓' WHEN c.WHCode ='10' THEN '成品仓' ELSE '' END ) AS WHCodes,
|
|
(CASE WHEN c.WHCode = '10' THEN c.Price WHEN c.WHCode = '12' THEN f.Discount ELSE 0 END ) AS RapaPrice,
|
|
(CASE WHEN c.WHCode = '10' THEN c.Price WHEN c.WHCode = '12' THEN c.Weight*f.Discount ELSE 0 END ) AS Price,
|
|
(CAST((e.Discount*100) AS VARCHAR(50))+'%') AS Discount,
|
|
(CASE WHEN c.WHCode = '10' THEN c.Price*e.Discount
|
|
WHEN c.WHCode = '12' THEN c.Weight*c.BasePrice*(1+e.Discount) ELSE 0 END ) AS Amount,
|
|
c.Location,c.Other,f.Discount
|
|
FROM ICSProductPreSellDetail a
|
|
LEFT JOIN ICSProductPreSell b ON a.PreSell_Id = b.F_Id
|
|
LEFT JOIN ICSProduct c ON a.Product_Id = c.F_Id
|
|
LEFT JOIN Sys_Customer d ON b.CustomerId = d.F_Id
|
|
LEFT JOIN ICSDiscountRate e ON d.F_CusCode = e.CusCode AND c.WHCode = e.WHType
|
|
AND (c.Weight >= e.StartValue AND c.Weight <= e.EndValue) AND e.CusCode <> 'RapaPort'
|
|
LEFT JOIN (SELECT x.Discount,x.WHType,x.StartValue,x.EndValue FROM ICSDiscountRate x WHERE x.CusCode = 'RapaPort' ) f
|
|
ON f.WHType= c.WHCode AND (c.Weight >= f.StartValue AND c.Weight <= f.EndValue)
|
|
WHERE b.F_Id = '{0}'";
|
|
sql = string.Format(sql, itemId);
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
sql = sql + " AND c.ProductSN LIKE '%{0}%' ";
|
|
sql = string.Format(sql, keyword);
|
|
}
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt == null || dt.Rows.Count <= 0)
|
|
throw new Exception("No exportable data.");
|
|
return dt;
|
|
//return DbHelper.GetDataTable(sql);
|
|
}
|
|
|
|
public DataTable GetListForWebService(string idList)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
string sql = @"SELECT DISTINCT b.PreSellNo,d.F_CusCode,c.ProductSN,g.F_Account AS UserCode,
|
|
(CASE WHEN c.WHCode = '10' THEN c.Price WHEN c.WHCode = '12' THEN f.Discount ELSE 0 END ) AS RapaPrice,
|
|
(CASE WHEN c.WHCode = '10' THEN c.Price WHEN c.WHCode = '12' THEN c.Weight*f.Discount ELSE 0 END ) AS Price,
|
|
(CAST((e.Discount*100) AS VARCHAR(50))+'%') AS Discount,
|
|
(CASE WHEN c.WHCode = '10' THEN c.Price*e.Discount
|
|
WHEN c.WHCode = '12' THEN c.Weight*c.BasePrice*(1+e.Discount) ELSE 0 END ) AS Amount
|
|
FROM ICSProductPreSellDetail a
|
|
LEFT JOIN ICSProductPreSell b ON a.PreSell_Id = b.F_Id
|
|
LEFT JOIN ICSProduct c ON a.Product_Id = c.F_Id
|
|
LEFT JOIN Sys_Customer d ON b.CustomerId = d.F_Id
|
|
LEFT JOIN ICSDiscountRate e ON d.F_CusCode = e.CusCode AND c.WHCode = e.WHType
|
|
AND (c.Weight >= e.StartValue AND c.Weight <= e.EndValue) AND e.CusCode <> 'RapaPort'
|
|
LEFT JOIN (SELECT x.Discount,x.WHType,x.StartValue,x.EndValue FROM ICSDiscountRate x WHERE x.CusCode = 'RapaPort' ) f
|
|
ON f.WHType= c.WHCode AND (c.Weight >= f.StartValue AND c.Weight <= f.EndValue)
|
|
LEFT JOIN Sys_User g ON g.F_Id = b.F_CreatorUserId
|
|
WHERE b.F_Id IN ({0})";
|
|
sql = string.Format(sql, idList);
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public ICSProductPreSellDetailEntity GetForm(string keyValue)
|
|
{
|
|
return service.FindEntity(keyValue);
|
|
}
|
|
|
|
public void DeleteForm(string[] keyValues, List<ICSProductEntity> entityList)
|
|
{
|
|
foreach (string keyValue in keyValues)
|
|
{
|
|
string sql = @"SELECT b.IsConfirm FROM ICSProductPreSellDetail a
|
|
LEFT JOIN ICSProductPreSell b ON a.PreSell_Id = b.F_Id
|
|
WHERE a.F_Id='{0}'";
|
|
sql = string.Format(sql, keyValue);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
if (!string.IsNullOrEmpty(dt.Rows[0][0].ToString()))
|
|
{
|
|
bool isConfirm = bool.Parse(dt.Rows[0][0].ToString());
|
|
if (isConfirm)
|
|
{
|
|
throw new Exception("Confirmed order cannot be cancelled.");
|
|
}
|
|
}
|
|
}
|
|
service.Delete(t => t.F_Id == keyValue);
|
|
}
|
|
foreach (ICSProductEntity model in entityList)
|
|
{
|
|
model.Modify(model.F_Id);
|
|
servicePro.Update(model);
|
|
}
|
|
}
|
|
|
|
public DataTable GetSODetails(string keyword)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
string sql = @"SELECT a.AutoID,a.cInvCode,b.Measurement,a.cInvCName,b.Weight,b.GrossWeight,
|
|
(CASE a.bgift WHEN '0' THEN '否' ELSE '是' END) AS 赠品,b.Price,a.iMoney,a.iTax,a.iSum,a.iDisCount,
|
|
100.00 AS 扣率,a.iNatSum,c.cInvDefine1 AS Color,c.cInvDefine3 AS Clarity,100.00 AS 扣率2,
|
|
c.cInvDefine2 AS Shape,a.cMemo,c.cInvDefine4 AS Cut,c.cInvDefine5 AS Polish,c.cInvDefine6 AS Symmetry,
|
|
c.cInvDefine10 AS Discount,c.cInvDefine11 AS Rapport,a.cFree1 AS zColor,a.cFree2 AS zShape,
|
|
a.cFree3 AS zClarity,a.cFree4 AS zDiscount,a.cFree5 AS zPolish,a.cFree6 AS zRapport,
|
|
a.cFree7 AS zRoughWeight,a.cFree8 AS zFinishedWeight,a.cFree9 AS zPrice,a.cFree10 AS zSize
|
|
FROM WMS_ZHENGSHI.dbo.SO_SODetails a
|
|
LEFT JOIN WMS_ZHENGSHI.dbo.ICSProduct b ON a.cInvCode = b.ProductSN
|
|
LEFT JOIN WMS_ZHENGSHI.dbo.Inventory c ON c.cInvCode = a.cInvCode
|
|
WHERE a.cSOCode = '{0}'";
|
|
sql = string.Format(sql, keyword);
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
}
|
|
}
|