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
This diff is collapsed.
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