Commit 0abd000c authored by liudong1993's avatar liudong1993

采购

parent 9fe4335f
using System;
using Mall.Common.AOP;
using Mall.Common.Plugin;
namespace Mall.Model.Entity.Property
{
/// <summary>
/// 采购单实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Procurement
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 采购仓库
/// </summary>
public int? WareHouseId
{
get;
set;
}
/// <summary>
/// 总成本
/// </summary>
public decimal? TotalCostMoney
{
get;
set;
}
/// <summary>
/// 总数量
/// </summary>
public int? TotalNumber
{
get;
set;
}
/// <summary>
/// 备注
/// </summary>
public string Remark
{
get;
set;
}
/// <summary>
/// 状态 0 正常 1删除
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 公司
/// </summary>
public int? RB_Branch_Id
{
get;
set;
}
/// <summary>
/// 集团
/// </summary>
public int? RB_Group_Id
{
get;
set;
}
/// <summary>
/// CreateBy
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateBy
/// </summary>
public int? UpdateBy
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// 财务单据id
/// </summary>
public int? FinanceId { get; set; }
}
}
\ No newline at end of file
using System;
using Mall.Common.AOP;
using Mall.Common.Plugin;
namespace Mall.Model.Entity.Property
{
/// <summary>
/// 采购单明细实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Procurement_Detail
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 采购单id
/// </summary>
public int? ProcurementId
{
get;
set;
}
/// <summary>
/// 耗材id
/// </summary>
public int? MaterialId
{
get;
set;
}
/// <summary>
/// 成本价格
/// </summary>
public decimal? CostMoney
{
get;
set;
}
/// <summary>
/// 采购数量
/// </summary>
public int? Number
{
get;
set;
}
/// <summary>
/// 状态 0 正常 1删除
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 公司
/// </summary>
public int? RB_Branch_Id
{
get;
set;
}
/// <summary>
/// 集团
/// </summary>
public int? RB_Group_Id
{
get;
set;
}
/// <summary>
/// CreateBy
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
}
}
\ No newline at end of file
......@@ -201,5 +201,13 @@ namespace Mall.Model.Entity.Property
/// 商品分类名称
/// </summary>
public string GoodsCategoryName { get; set; }
/// <summary>
/// 商户号id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using Mall.Model.Entity.Property;
using Mall.Common.AOP;
namespace Mall.Model.Extend.Property
{
/// <summary>
/// 꽃뭔데츠玖윈嵐茄竟
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Procurement_Detail_Extend : RB_Procurement_Detail
{
/// <summary>
/// 꽃뭔데ids
/// </summary>
public string ProcurementIds { get; set; }
/// <summary>
/// 膠죕도갭
/// </summary>
public RB_Supplies_Material_Extend MaterialModel { get; set; }
/// <summary>
/// 방목key
/// </summary>
public string SpecificationKey { get; set; }
/// <summary>
/// /틔id
/// </summary>
public int GoodsId { get; set; }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using Mall.Model.Entity.Property;
using Mall.Common.AOP;
namespace Mall.Model.Extend.Property
{
/// <summary>
/// 采购单扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Procurement_Extend : RB_Procurement
{
/// <summary>
/// 商品名称
/// </summary>
public string GoodsName { get; set; }
/// <summary>
/// 商品id
/// </summary>
public int GoodsId { get; set; }
/// <summary>
/// 开始时间
/// </summary>
public string StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string EndTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 仓库名称
/// </summary>
public string WareHouseName { get; set; }
/// <summary>
/// 明细列表
/// </summary>
public List<RB_Procurement_Detail_Extend> DetailList { get; set; }
}
}
\ No newline at end of file
......@@ -39,5 +39,17 @@ namespace Mall.Model.Extend.Property
/// 档案ids
/// </summary>
public string SuppliesIdStr { get; set; }
/// <summary>
/// 商品规格
/// </summary>
public List<string> GoodsSpecificationList { get; set; }
/// <summary>
/// 商品分类
/// </summary>
public List<string> GoodsCategoryList { get; set; }
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
}
}
\ No newline at end of file
......@@ -24,5 +24,9 @@ namespace Mall.Model.Entity.User
return str;
}
}
/// <summary>
/// 员工ids
/// </summary>
public string EmployeeIds { get; set; }
}
}
\ No newline at end of file
......@@ -67,7 +67,156 @@ namespace Mall.Module.Property
/// 日志
/// </summary>
private readonly RB_Property_LogRepository property_LogRepository = new RB_Property_LogRepository();
/// <summary>
/// 采购单
/// </summary>
private readonly RB_ProcurementRepository procurementRepository = new RB_ProcurementRepository();
/// <summary>
/// 采购单明细
/// </summary>
private readonly RB_Procurement_DetailRepository procurement_DetailRepository = new RB_Procurement_DetailRepository();
/// <summary>
/// 员工
/// </summary>
private readonly RB_EmployeeRepository employeeRepository = new RB_EmployeeRepository();
/// <summary>
/// 仓库
/// </summary>
private readonly RB_Supplies_WareHouseRepository supplies_WareHouseRepository = new RB_Supplies_WareHouseRepository();
#region 获取采购单
/// <summary>
/// 获取采购单分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="demodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Procurement_Extend> GetProcurementPageList(int pageIndex, int pageSize, RB_Procurement_Extend demodel, out long count)
{
var list = procurementRepository.GetPageList(pageIndex, pageSize, demodel, out count);
if (list.Any()) {
string procurementIds = string.Join(",", list.Select(x => x.Id));
//查询明细
var pdList = procurement_DetailRepository.GetList(new RB_Procurement_Detail_Extend() { ProcurementIds = procurementIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
//查询物料
if (pdList.Any()) {
string MaterialIds = string.Join(",", pdList.Select(x => x.MaterialId).Distinct());
var mList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { SuppliesIdStr = MaterialIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in pdList) {
item.MaterialModel = mList.Where(x => x.Id == item.MaterialId).FirstOrDefault();
if (item.MaterialModel != null)
{
item.MaterialModel.GoodsSpecificationList = new List<string>();
item.MaterialModel.GoodsCategoryList = new List<string>();
if (!string.IsNullOrEmpty(item.MaterialModel.SpecificationName))
{
item.MaterialModel.GoodsSpecificationList = JsonConvert.DeserializeObject<List<string>>(item.MaterialModel.SpecificationName);
}
if (!string.IsNullOrEmpty(item.MaterialModel.GoodsCategoryName))
{
item.MaterialModel.GoodsCategoryList = JsonConvert.DeserializeObject<List<string>>(item.MaterialModel.GoodsCategoryName);
}
if (item.MaterialModel.Images == "" || item.MaterialModel.Images == null)
{
item.MaterialModel.Images = "[]";
}
var imglist = JsonConvert.DeserializeObject<List<string>>(item.MaterialModel.Images);
item.MaterialModel.ImageList = new List<string>();
}
else {
item.MaterialModel = new RB_Supplies_Material_Extend();
}
}
}
var elist = employeeRepository.GetEmployeeListRepository(new RB_Employee_Extend() { EmployeeIds = string.Join(",", list.Select(x => x.CreateBy ?? 0).Distinct()) });
var wlist = supplies_WareHouseRepository.GetList(new RB_Supplies_WareHouse_Extend() { WareHouseIdStr = string.Join(",", list.Select(x => x.WareHouseId ?? 0).Distinct()) });
foreach (var item in list) {
item.DetailList = pdList.Where(x => x.ProcurementId == item.Id).ToList();
item.CreateByName = elist.Where(x => x.EmpId == item.CreateBy).FirstOrDefault()?.EmpName ?? "";
item.WareHouseName = wlist.Where(x => x.Id == item.WareHouseId).FirstOrDefault()?.Name ?? "";
}
}
return list;
}
/// <summary>
/// 提交采购单
/// </summary>
/// <param name="demodel"></param>
/// <param name="eRPEmpId"></param>
/// <param name="eRPBranchId"></param>
/// <param name="eRPGroupId"></param>
/// <param name="empId"></param>
/// <returns></returns>
public string SetProcurementInfo(RB_Procurement_Extend demodel, int eRPEmpId, int eRPBranchId, int eRPGroupId, int tenantId, int mallBaseId, int empId)
{
//核实提交的商品物料里是否存在
string GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId).Distinct());
var mList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { GoodsIds = GoodsIds, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var item in demodel.DetailList) {
var mModel = mList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationKey).FirstOrDefault();
if (mModel == null) {
return "商品未找到对应的资产物料档案,商品ID:" + item.GoodsId;
}
item.MaterialId = mModel.Id;
}
demodel.TotalCostMoney = demodel.DetailList.Sum(x => x.CostMoney ?? 0);
demodel.TotalNumber = demodel.DetailList.Sum(x => x.Number ?? 0);
demodel.Status = 0;
demodel.RB_Branch_Id = eRPBranchId;
demodel.RB_Group_Id = eRPGroupId;
demodel.CreateBy = eRPEmpId;
demodel.CreateDate = DateTime.Now;
demodel.UpdateBy = eRPEmpId;
demodel.UpdateDate = DateTime.Now;
demodel.TenantId = tenantId;
demodel.MallBaseId = mallBaseId;
demodel.FinanceId = 0;
var trans = procurementRepository.DbTransaction;
try
{
int pid = procurementRepository.Insert(demodel, trans);
if (pid > 0)
{
//插入明细
foreach (var item in demodel.DetailList)
{
procurement_DetailRepository.Insert(new Model.Entity.Property.RB_Procurement_Detail()
{
CostMoney = item.CostMoney,
CreateBy = eRPEmpId,
CreateDate = DateTime.Now,
Id = 0,
MallBaseId = mallBaseId,
MaterialId = item.MaterialId,
Number = item.Number,
ProcurementId = pid,
RB_Branch_Id = eRPBranchId,
RB_Group_Id = eRPGroupId,
Status = 0,
TenantId = tenantId
}, trans);
}
//生成采购财务单
}
}
catch (Exception)
{
throw;
}
return "";
}
#endregion
#region 获取资产物料列表
......@@ -97,11 +246,19 @@ namespace Mall.Module.Property
}
var imglist = JsonConvert.DeserializeObject<List<string>>(item.Images);
item.ImageList = new List<string>();
foreach (var img in imglist)
{
item.ImageList.Add(Config.GetFileUrl(img));
}
//foreach (var img in imglist)
//{
// item.ImageList.Add(Config.GetFileUrl(img));
//}
item.InventoryNum = iList.Where(x => x.SuppliesId == item.Id).FirstOrDefault()?.Number ?? 0;
item.GoodsSpecificationList = new List<string>();
item.GoodsCategoryList = new List<string>();
if (!string.IsNullOrEmpty(item.SpecificationName)) {
item.GoodsSpecificationList = JsonConvert.DeserializeObject<List<string>>(item.SpecificationName);
}
if (!string.IsNullOrEmpty(item.GoodsCategoryName)) {
item.GoodsCategoryList = JsonConvert.DeserializeObject<List<string>>(item.GoodsCategoryName);
}
}
return list;
}
......@@ -175,13 +332,13 @@ namespace Mall.Module.Property
{
if (!string.IsNullOrEmpty(item.SpecificationSort))
{
var SpList = SpecificationList.Where(x => x.GoodsId == item.GoodsId).ToList();
var ssarr = item.SpecificationSort.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
string pic_url = SpecificationList[0].SpecificationValueList.Where(x => x.Sort == Sort).FirstOrDefault()?.ImagePath;
List<string> AttrList = new List<string>();
for (int i = 0; i < ssarr.Length; i++)
{
var smodel = SpecificationList[i];
var smodel = SpList[i];
var svmodel = smodel.SpecificationValueList.Where(x => x.Sort == Convert.ToInt32(ssarr[i])).FirstOrDefault();
AttrList.Add(smodel.Name + ":" + svmodel.Name);
}
......@@ -192,7 +349,7 @@ namespace Mall.Module.Property
var GCList = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = string.Join(",", GoodsList.Select(x => x.Id)), TenantId = tenantId, MallBaseId = mallBaseId });
string SupplierIds = string.Join(",", GoodsList.Where(x => x.SupplierId > 0).Select(x => x.SupplierId).Distinct());
var Supplierlist = supplierRepository.GetList(new RB_Supplier_Extend() { SupplierIds = SupplierIds, TenantId = tenantId, MallBaseId = mallBaseId });
var mList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { WareHouseId = wareHouseId, RB_Group_Id = eRPGroupId });
var mList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { RB_Group_Id = eRPGroupId, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var item in GoodsList)
{
var supplierModel = Supplierlist.Where(x => x.ID == item.SupplierId).FirstOrDefault();
......@@ -233,7 +390,9 @@ namespace Mall.Module.Property
SuppliesNum = "",
Units = item.Unit,
UpdateBy = eRPEmpId,
UpdateDate = DateTime.Now
UpdateDate = DateTime.Now,
TenantId = tenantId,
MallBaseId = mallBaseId
});
if (MaterialId > 0) {
//编码自动生成
......@@ -322,7 +481,9 @@ namespace Mall.Module.Property
SuppliesNum = "",
Units = item.Unit,
UpdateBy = eRPEmpId,
UpdateDate = DateTime.Now
UpdateDate = DateTime.Now,
TenantId = tenantId,
MallBaseId = mallBaseId
});
if (MaterialId > 0)
{
......
using Mall.Model.Entity.Property;
using Mall.Model.Extend.Property;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Property
{
/// <summary>
/// 采购单仓储类
/// </summary>
public partial class RB_ProcurementRepository : RepositoryBase<RB_Procurement>
{
/// <summary>
/// 获取采购单分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Procurement_Extend> GetPageList(int pageIndex, int pageSize, RB_Procurement_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND p.{0}={1}", nameof(RB_Procurement_Extend.Status), 0);
where += $@" and p.RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrWhiteSpace(dmodel.GoodsName))
{
where += " and m." + nameof(RB_Supplies_Material_Extend.Name) + " like '%" + dmodel.GoodsName + "%'";
}
if (dmodel.GoodsId > 0)
{
where += " and m." + nameof(RB_Supplies_Material_Extend.GoodsId) + "=" + dmodel.GoodsId;
}
if (dmodel.TenantId > 0)
{
where += " and p." + nameof(RB_Procurement_Extend.TenantId) + "=" + dmodel.TenantId;
}
if (dmodel.MallBaseId > 0)
{
where += " and p." + nameof(RB_Procurement_Extend.MallBaseId) + "=" + dmodel.MallBaseId;
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += " and p.CreateTime >='" + dmodel.StartTime + "'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += " and p.CreateTime <='" + dmodel.EndTime + " 23:59:59'";
}
string sql = $@" SELECT p.* FROM rb_procurement p
INNER JOIN rb_procurement_detail pd on p.Id = pd.ProcurementId
INNER JOIN rb_supplies_material m on pd.MaterialId = m.Id
{where}
GROUP BY p.Id order by p.Id desc";
return GetPage<RB_Procurement_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
}
}
using Mall.Model.Entity.Property;
using Mall.Model.Extend.Property;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Property
{
/// <summary>
/// 采购单仓储类
/// </summary>
public partial class RB_Procurement_DetailRepository : RepositoryBase<RB_Procurement_Detail>
{
/// <summary>
/// 获取采购单分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Procurement_Detail_Extend> GetList(RB_Procurement_Detail_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND p.{0}={1}", nameof(RB_Procurement_Detail_Extend.Status), 0);
where += $@" and p.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.TenantId > 0)
{
where += " and p." + nameof(RB_Procurement_Detail_Extend.TenantId) + "=" + dmodel.TenantId;
}
if (dmodel.MallBaseId > 0)
{
where += " and p." + nameof(RB_Procurement_Detail_Extend.MallBaseId) + "=" + dmodel.MallBaseId;
}
if (dmodel.ProcurementId > 0)
{
where += " and p." + nameof(RB_Procurement_Detail_Extend.ProcurementId) + "=" + dmodel.ProcurementId;
}
if (!string.IsNullOrEmpty(dmodel.ProcurementIds))
{
where += " and p." + nameof(RB_Procurement_Detail_Extend.ProcurementId) + " in(" + dmodel.ProcurementIds + ")";
}
if (dmodel.MaterialId > 0)
{
where += " and p." + nameof(RB_Procurement_Detail_Extend.MaterialId) + "=" + dmodel.MaterialId;
}
string sql = $@" SELECT * FROM RB_Procurement_Detail p {where} order by p.Id desc";
return Get<RB_Procurement_Detail_Extend>(sql).ToList();
}
}
}
......@@ -25,27 +25,38 @@ namespace Mall.Repository.Property
string where = " where 1=1 ";
where += string.Format(" AND sm.{0}={1}", nameof(RB_Supplies_Material_Extend.Status), 0);
where += $@" and sm.RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrWhiteSpace(dmodel.Name.Trim()))
if (!string.IsNullOrWhiteSpace(dmodel.Name))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.Name) + " like '%" + dmodel.Name.Trim() + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SuppliesNum.Trim()))
if (!string.IsNullOrWhiteSpace(dmodel.SuppliesNum))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.SuppliesNum) + " like '%" + dmodel.SuppliesNum.Trim() + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.BrandName.Trim()))
if (!string.IsNullOrWhiteSpace(dmodel.BrandName))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.BrandName) + " like '%" + dmodel.BrandName.Trim() + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SupplierName.Trim()))
if (!string.IsNullOrWhiteSpace(dmodel.SupplierName))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.SupplierName) + " like '%" + dmodel.SupplierName.Trim() + "%'";
}
if (dmodel.GoodsId > 0)
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.GoodsId) + "=" + dmodel.GoodsId;
}
if (dmodel.CategoryId > 0) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.CategoryId) + "=" + dmodel.CategoryId;
}
if (dmodel.TenantId > 0)
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.TenantId) + "=" + dmodel.TenantId;
}
if (dmodel.MallBaseId > 0)
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.MallBaseId) + "=" + dmodel.MallBaseId;
}
string sql = $@" select sm.*,pc.Name as CategoryName from RB_Supplies_Material sm
left join rb_property_category pc on sm.CategoryId=pc.Id
{where} order by sm.Id desc";
......@@ -78,10 +89,6 @@ left join rb_property_category pc on sm.CategoryId=pc.Id
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.SupplierName) + " like '%" + dmodel.SupplierName + "%'";
}
if (dmodel.WareHouseId > 0)
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.WareHouseId) + "=" + dmodel.WareHouseId;
}
if (dmodel.CategoryId > 0)
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.CategoryId) + "=" + dmodel.CategoryId;
......@@ -89,6 +96,15 @@ left join rb_property_category pc on sm.CategoryId=pc.Id
if (!string.IsNullOrEmpty(dmodel.SuppliesIdStr)) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.Id) + " in(" + dmodel.SuppliesIdStr + ")";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.GoodsId) + " in(" + dmodel.GoodsIds + ")";
}
if (dmodel.TenantId > 0) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.TenantId) + "=" + dmodel.TenantId;
}
if (dmodel.MallBaseId > 0) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.MallBaseId) + "=" + dmodel.MallBaseId;
}
string sql = $@" select sm.*,pc.Name as CategoryName from RB_Supplies_Material sm
left join rb_property_category pc on sm.CategoryId=pc.Id
......
......@@ -23,6 +23,117 @@ namespace Mall.WebApi.Controllers.MallBase
private readonly PropertyModule propertyModule = new PropertyModule();
#region 商品采购
/// <summary>
/// 获取采购单分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProcurementPageList()
{
var requestParm = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(requestParm.msg.ToString());
RB_Procurement_Extend demodel = JsonConvert.DeserializeObject<RB_Procurement_Extend>(requestParm.msg.ToString());
if (requestParm.ERPEmpId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
demodel.RB_Group_Id = requestParm.ERPGroupId;
var list = propertyModule.GetProcurementPageList(pagelist.pageIndex, pagelist.pageSize, demodel, out long count);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.WareHouseId,
x.WareHouseName,
x.TotalCostMoney,
x.TotalNumber,
x.Remark,
DetailList = x.DetailList.Select(y=>new
{
y.Id,
y.MaterialId,
y.CostMoney,
y.Number,
MaterialModel = new {
y.MaterialModel.Name,
y.MaterialModel.SuppliesNum,
y.MaterialModel.Units,
y.MaterialModel.Money,
y.MaterialModel.GoodsSpecificationList,
y.MaterialModel.GoodsCategoryList,
y.MaterialModel.GoodsId,
y.MaterialModel.SpecificationKey,
y.MaterialModel.ImageList
}
}),
x.FinanceId,
x.CreateByName,
CreateDate = x.CreateDate.Value.ToString("yyyy-MM-dd")
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取商品规格列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetGoodsToProcurementPageList() {
}
/// <summary>
/// 提交采购单
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetProcurementInfo()
{
var requestParm = RequestParm;
RB_Procurement_Extend demodel = JsonConvert.DeserializeObject<RB_Procurement_Extend>(requestParm.msg.ToString());
if (requestParm.ERPEmpId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
if (requestParm.EmpId <= 0) {
return ApiResult.ParamIsNull("请传递参数");
}
if ((demodel.WareHouseId ?? 0) <= 0) {
return ApiResult.ParamIsNull("请传递仓库id");
}
if (demodel.DetailList == null || !demodel.DetailList.Any()) {
return ApiResult.ParamIsNull("请选择商品");
}
foreach (var item in demodel.DetailList) {
if (item.GoodsId <= 0) {
return ApiResult.ParamIsNull("商品id未传递");
}
if ((item.CostMoney ?? 0) <= 0) {
return ApiResult.ParamIsNull("请输入价格");
}
if ((item.Number ?? 0) <= 0) {
return ApiResult.ParamIsNull("请输入数量");
}
}
string msg = propertyModule.SetProcurementInfo(demodel, requestParm.ERPEmpId, requestParm.ERPBranchId, requestParm.ERPGroupId, requestParm.EmpId);
if (msg=="")
{
return ApiResult.Success();
}
else {
return ApiResult.Failed(msg);
}
}
#endregion
#region 同步商品
/// <summary>
/// 获取物料档案分页列表
......@@ -46,20 +157,15 @@ namespace Mall.WebApi.Controllers.MallBase
{
x.Id,
x.Name,
x.CategoryId,
x.CategoryName,
x.BrandName,
x.Money,
x.Units,
x.ImageList,
x.Remark,
x.SupplierName,
x.Barcode,
x.ReservedStock,
x.SafetyStock,
x.SuppliesModel,
x.SuppliesNum,
x.InventoryNum,
x.GoodsSpecificationList,
x.GoodsCategoryList,
//UpdateBy = CacheManager.User.UserReidsCache.GetEmployee(x.UpdateBy)?.EmName ?? "",
UpdateDate = x.UpdateDate.Value.ToString("yyyy-MM-dd")
});
......@@ -74,12 +180,9 @@ namespace Mall.WebApi.Controllers.MallBase
public ApiResult SetSyncGoodsToMaterial() {
var requestParm = RequestParm;
JObject parms = JObject.Parse(requestParm.msg.ToString());
int WareHouseId = parms.GetInt("WareHouseId", 0);//仓库id
//int WareHouseId = parms.GetInt("WareHouseId", 0);//仓库id
string CategoryIds = parms.GetStringValue("CategoryIds");//同步的商品分类
if (WareHouseId <= 0) {
return ApiResult.ParamIsNull("请传递仓库id");
}
if (string.IsNullOrEmpty(CategoryIds) || CategoryIds == "[]")
{
return ApiResult.ParamIsNull("请传递分类");
......@@ -97,7 +200,7 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.ParamIsNull("请传递关联ERP用户id");
}
bool flag = propertyModule.SetSyncGoodsToMaterial(WareHouseId, categoryIdList, requestParm.ERPEmpId, requestParm.ERPBranchId, requestParm.ERPGroupId, requestParm.TenantId, requestParm.MallBaseId, requestParm.EmpId);
bool flag = propertyModule.SetSyncGoodsToMaterial(0, categoryIdList, requestParm.ERPEmpId, requestParm.ERPBranchId, requestParm.ERPGroupId, requestParm.TenantId, requestParm.MallBaseId, requestParm.EmpId);
if (flag)
{
return ApiResult.Success();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment