Commit 8dcce85e authored by liudong1993's avatar liudong1993

商品采购

parent 210d19f4
...@@ -387,6 +387,25 @@ namespace Mall.Model.Entity.Product ...@@ -387,6 +387,25 @@ namespace Mall.Model.Entity.Product
/// 供应商id /// 供应商id
/// </summary> /// </summary>
public int SupplierId { get; set; } public int SupplierId { get; set; }
/// <summary>
/// 商品是否可代理 1是 2否
/// </summary>
public int? IsProxy { get; set; }
/// <summary>
/// 代理成本上浮类型 1百分比 2固定金额
/// </summary>
public int? ProxyType { get; set; }
/// <summary>
/// 价格上涨
/// </summary>
public decimal? ProxyRises { get; set; }
/// <summary>
/// 代理价格
/// </summary>
public decimal? ProxyMoney { get; set; }
/// <summary>
/// 是否是采购商品 1是 2否
/// </summary>
public int? IsProcurement { get; set; }
} }
} }
...@@ -22,6 +22,14 @@ namespace Mall.Model.Extend.Product ...@@ -22,6 +22,14 @@ namespace Mall.Model.Extend.Product
/// </summary> /// </summary>
public int? GoodsId { get; set; } public int? GoodsId { get; set; }
/// <summary> /// <summary>
/// 采购商品id
/// </summary>
public int? ProcurementGoodsId { get; set; }
/// <summary>
/// 其他商户
/// </summary>
public int? NotTenantId { get; set; }
/// <summary>
/// 商品购买的数量 /// 商品购买的数量
/// </summary> /// </summary>
public int? GoodsBuyNum { get; set; } public int? GoodsBuyNum { get; set; }
......
...@@ -13,6 +13,9 @@ namespace Mall.Model.Extend.Product ...@@ -13,6 +13,9 @@ namespace Mall.Model.Extend.Product
[DB(ConnectionName = "DefaultConnection")] [DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Proxy_Extend : RB_Goods_Proxy public class RB_Goods_Proxy_Extend : RB_Goods_Proxy
{ {
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
} }
} }
This diff is collapsed.
...@@ -27,6 +27,9 @@ namespace Mall.Repository.Product ...@@ -27,6 +27,9 @@ namespace Mall.Repository.Product
if (dmodel.TenantId > 0) { if (dmodel.TenantId > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
} }
if (dmodel.NotTenantId > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}<>{dmodel.NotTenantId}";
}
if (dmodel.MallBaseId > 0) { if (dmodel.MallBaseId > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}"; where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
} }
...@@ -54,6 +57,12 @@ namespace Mall.Repository.Product ...@@ -54,6 +57,12 @@ namespace Mall.Repository.Product
if (!string.IsNullOrEmpty(dmodel.EndTime)) { if (!string.IsNullOrEmpty(dmodel.EndTime)) {
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'"; where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
} }
if (dmodel.IsProcurement > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.IsProcurement)}={dmodel.IsProcurement}";
}
if (dmodel.IsProxy > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.IsProxy)}={dmodel.IsProxy}";
}
string sql = $@"select g.* from RB_Goods g string sql = $@"select g.* from RB_Goods g
inner join rb_goods_category c on g.Id=c.GoodsId inner join rb_goods_category c on g.Id=c.GoodsId
......
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
using Mall.Model.Entity.User;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品代理仓储层
/// </summary>
public class RB_Goods_ProxyRepository : RepositoryBase<RB_Goods_Proxy>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_Proxy_Extend> GetList(RB_Goods_Proxy_Extend dmodel)
{
string where = $" 1=1 and Status =0";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_Goods_Proxy.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_Goods_Proxy.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.ProxyTenantId > 0)
{
where += $@" and {nameof(RB_Goods_Proxy.ProxyTenantId)}={dmodel.ProxyTenantId}";
}
if (dmodel.ProxyMallBaseId > 0)
{
where += $@" and {nameof(RB_Goods_Proxy.ProxyMallBaseId)}={dmodel.ProxyMallBaseId}";
}
if (dmodel.GoodsId > 0)
{
where += $@" and {nameof(RB_Goods_Proxy.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds))
{
where += $@" and {nameof(RB_Goods_Proxy.GoodsId)} in({dmodel.GoodsIds})";
}
if (dmodel.ProxyGoodsId > 0)
{
where += $@" and {nameof(RB_Goods_Proxy.ProxyGoodsId)}={dmodel.ProxyGoodsId}";
}
string sql = $@"SELECT * FROM RB_Goods_Proxy where {where} order by Id asc";
return Get<RB_Goods_Proxy_Extend>(sql).ToList();
}
}
}
...@@ -1091,6 +1091,8 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1091,6 +1091,8 @@ namespace Mall.WebApi.Controllers.MallBase
x.SalesNum, x.SalesNum,
x.GoodsBuyNum, x.GoodsBuyNum,
x.IsQuickBuy, x.IsQuickBuy,
x.IsProxy,
x.IsProcurement,
x.GoodsStatus, x.GoodsStatus,
x.TenantId, x.TenantId,
x.MallBaseId, x.MallBaseId,
...@@ -1384,6 +1386,11 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1384,6 +1386,11 @@ namespace Mall.WebApi.Controllers.MallBase
model.SeparateSetMember, model.SeparateSetMember,
model.IsQuickBuy, model.IsQuickBuy,
model.SupplierId, model.SupplierId,
model.IsProxy,
model.ProxyType,
model.ProxyRises,
model.ProxyMoney,
model.IsProcurement,
CategoryList = model.CategoryList.Select(x=>new { CategoryList = model.CategoryList.Select(x=>new {
x.Id, x.Id,
x.CategoryId, x.CategoryId,
...@@ -1859,6 +1866,25 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1859,6 +1866,25 @@ namespace Mall.WebApi.Controllers.MallBase
demodel.GoodsType ??= Common.Enum.Goods.OrderTypeEnum.Mall; demodel.GoodsType ??= Common.Enum.Goods.OrderTypeEnum.Mall;
demodel.GoodsStatus ??= 2; demodel.GoodsStatus ??= 2;
demodel.IsProxy ??= 2;
demodel.ProxyType ??= 1;
demodel.ProxyRises ??= 0;
demodel.ProxyMoney ??= 0;
demodel.IsProcurement = 2;//新增时
if (demodel.IsProxy == 1 && demodel.CostPrice > 0) {
decimal ProxyMoney = 0;
if (demodel.ProxyType == 1)
{
ProxyMoney = Math.Round((demodel.CostPrice ?? 0) * (1 + (demodel.ProxyRises ?? 0)), 2, MidpointRounding.AwayFromZero);
}
else {
ProxyMoney = (demodel.CostPrice ?? 0) + (demodel.ProxyRises ?? 0);
}
if (ProxyMoney != (demodel.ProxyMoney ?? 0)) {
return ApiResult.ParamIsNull("代理价格不正确");
}
}
bool flag = productModule.SetProductGoodsInfo(demodel); bool flag = productModule.SetProductGoodsInfo(demodel);
if (flag) if (flag)
{ {
...@@ -1939,6 +1965,63 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1939,6 +1965,63 @@ namespace Mall.WebApi.Controllers.MallBase
#endregion #endregion
#region 商品代理
/// <summary>
/// 商品代理分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProductGoodsProxyPageList()
{
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(parms.msg.ToString());
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(parms.msg.ToString());
demodel.NotTenantId = parms.TenantId;
//demodel.MallBaseId = parms.MallBaseId;
demodel.IsProxy = 1;
demodel.IsProcurement = 2;
var list = productModule.GetProductGoodsProxyPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.Name,
x.Sort,
x.CoverImage,
CategoryList = x.CategoryList.Select(y => new { y.Id, y.CategoryName }),
x.ProxyMoney,
x.InventoryNum,
SalesNum = (x.SalesNum ?? 0) + (x.GoodsBuyNum ?? 0),
x.IsProcurement,
x.ProcurementGoodsId,
x.GoodsStatus,
x.TenantId,
x.MallBaseId,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 设置商品代理
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetProductGoodsProxy() {
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
if (GoodsId <= 0) {
return ApiResult.ParamIsNull("请传递商品id");
}
return productModule.SetProductGoodsProxy(GoodsId, req.TenantId, req.MallBaseId);
}
#endregion
#region 商品导入 #region 商品导入
/// <summary> /// <summary>
......
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