Commit dbb4f612 authored by liudong1993's avatar liudong1993

商品列表

parent 22dcedbd
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 商品表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 商品名称
/// </summary>
public string Name
{
get;
set;
}
/// <summary>
/// 轮播图 json 格式 第一张为封面图
/// </summary>
public string CarouselImage
{
get;
set;
}
/// <summary>
/// 视频地址
/// </summary>
public string VideoAddress
{
get;
set;
}
/// <summary>
/// 自定义分享标题
/// </summary>
public string CustomShareTitles
{
get;
set;
}
/// <summary>
/// 自定义分享图片
/// </summary>
public int? CustomShareImage
{
get;
set;
}
/// <summary>
/// 商品状态 1销售中 2下架中
/// </summary>
public int? GoodsStatus
{
get;
set;
}
/// <summary>
/// 库存数量
/// </summary>
public int? InventoryNum
{
get;
set;
}
/// <summary>
/// 默认规格名
/// </summary>
public string DefaultSpecificationName
{
get;
set;
}
/// <summary>
/// 是否自定义规格 1是 2否
/// </summary>
public int? IsCustomSpecification
{
get;
set;
}
/// <summary>
/// 排序
/// </summary>
public int? Sort
{
get;
set;
}
/// <summary>
/// 售价
/// </summary>
public decimal? SellingPrice
{
get;
set;
}
/// <summary>
/// 原价
/// </summary>
public decimal? OriginalPrice
{
get;
set;
}
/// <summary>
/// 单位
/// </summary>
public string Unit
{
get;
set;
}
/// <summary>
/// 成本价格
/// </summary>
public decimal? CostPrice
{
get;
set;
}
/// <summary>
/// 商品面议 1是 2否
/// </summary>
public int? IsGoodsNegotiable
{
get;
set;
}
/// <summary>
/// 已售出数量
/// </summary>
public int? SalesNum
{
get;
set;
}
/// <summary>
/// 商品货号
/// </summary>
public string GoodsNumbers
{
get;
set;
}
/// <summary>
/// 商品重量 克
/// </summary>
public int? GoodsWeight
{
get;
set;
}
/// <summary>
/// 是否默认服务 1是 2否
/// </summary>
public int? IsDefaultService
{
get;
set;
}
/// <summary>
/// 商品服务 json格式
/// </summary>
public string GoodsService
{
get;
set;
}
/// <summary>
/// 运费设置
/// </summary>
public int? FreightId
{
get;
set;
}
/// <summary>
/// 自定义表单
/// </summary>
public int? FormsId
{
get;
set;
}
/// <summary>
/// 限购商品数量
/// </summary>
public int? LimitBuyGoodsNum
{
get;
set;
}
/// <summary>
/// 限购订单数量
/// </summary>
public int? LimitBuyOrderNum
{
get;
set;
}
/// <summary>
/// 单品满件包邮
/// </summary>
public int? FullNumPinkage
{
get;
set;
}
/// <summary>
/// 单品满额包邮
/// </summary>
public decimal? FullMoneyPinkage
{
get;
set;
}
/// <summary>
/// 是否区域购买 1是 2否
/// </summary>
public int? IsAreaBuy
{
get;
set;
}
/// <summary>
/// 积分赠送
/// </summary>
public int? IntegralPresent
{
get;
set;
}
/// <summary>
/// 赠送类型 1固定值 2百分比
/// </summary>
public int? IntegralPresentType
{
get;
set;
}
/// <summary>
/// 积分抵扣
/// </summary>
public decimal? PointsDeduction
{
get;
set;
}
/// <summary>
/// 抵扣类型 1固定值 2百分比
/// </summary>
public int? PointsDeductionType
{
get;
set;
}
/// <summary>
/// 是否允许多件累计抵扣 1是 2否
/// </summary>
public int? IsMultipleDeduction
{
get;
set;
}
/// <summary>
/// 商品详情
/// </summary>
public string GoodsDetails
{
get;
set;
}
/// <summary>
/// 删除状态
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
/// <summary>
/// 是否开启单独分销 1是 2否
/// </summary>
public int? SeparateDistribution
{
get;
set;
}
/// <summary>
/// 单独分销类型 1普通设置 2详细设置
/// </summary>
public int? SeparateDistributionType
{
get;
set;
}
/// <summary>
/// 分销佣金类型 1固定金额 2百分比
/// </summary>
public int? SeparateDistributionMoneyType
{
get;
set;
}
/// <summary>
/// 是否享受会员功能 1是 2否
/// </summary>
public int? EnjoyMember
{
get;
set;
}
/// <summary>
/// 是否单独设置会员价 1是 2否
/// </summary>
public int? SeparateSetMember
{
get;
set;
}
/// <summary>
/// 是否加入快速购买 1是 2否
/// </summary>
public int? IsQuickBuy { get; set; }
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 商品关联区域表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Area
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 区域id
/// </summary>
public int? AreaId
{
get;
set;
}
/// <summary>
/// 区域类型 1国家 2省 3市 4区
/// </summary>
public int? AreaType
{
get;
set;
}
/// <summary>
/// 删除状态
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 商品关联分类表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Category
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 分类id
/// </summary>
public int? CategoryId
{
get;
set;
}
/// <summary>
/// 删除状态
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 商品关联规格表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Specification
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 规格名称
/// </summary>
public string Name
{
get;
set;
}
/// <summary>
/// 排序
/// </summary>
public int? Sort
{
get;
set;
}
/// <summary>
/// 是否启用规格图片 1是 2否
/// </summary>
public int? EnabledImage
{
get;
set;
}
/// <summary>
/// Status
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 商品关联规格价格表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_SpecificationPrice
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 规格值 排序组
/// </summary>
public string SpecificationSort
{
get;
set;
}
/// <summary>
/// 价格
/// </summary>
public decimal? SellingPrice
{
get;
set;
}
/// <summary>
/// 库存
/// </summary>
public int? InventoryNum
{
get;
set;
}
/// <summary>
/// 商品重量 克
/// </summary>
public int? GoodsWeight
{
get;
set;
}
/// <summary>
/// 商品货号
/// </summary>
public string GoodsNumbers
{
get;
set;
}
/// <summary>
/// Status
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 商品关联规格值表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_SpecificationValue
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// GoodsId
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 规格id
/// </summary>
public int? SpecificationId
{
get;
set;
}
/// <summary>
/// 规格值名称
/// </summary>
public string Name
{
get;
set;
}
/// <summary>
/// 规格图片
/// </summary>
public int? Image
{
get;
set;
}
/// <summary>
/// 排序 不能重复 用于价格绑定Key
/// </summary>
public int? Sort
{
get;
set;
}
/// <summary>
/// Status
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 图片通用类
/// </summary>
[Serializable]
public class RB_ImageCommonModel
{
/// <summary>
/// id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 路径
/// </summary>
public string Path { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品关联区域表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Area_Extend : RB_Goods_Area
{
/// <summary>
/// 区域名称
/// </summary>
public string AreaName { get; set; }
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品关联分类表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Category_Extend : RB_Goods_Category
{
/// <summary>
/// 分类名称
/// </summary>
public string CategoryName { get; set; }
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Extend : RB_Goods
{
/// <summary>
/// 开始时间
/// </summary>
public string StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string EndTime { get; set; }
/// <summary>
/// 是否查询售罄 1是 其他否
/// </summary>
public int? IsSelectSellOut { get; set; }
/// <summary>
/// 分类ids
/// </summary>
public string CategoryIds { get; set; }
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
/// <summary>
/// 封面图
/// </summary>
public string CoverImage { get; set; }
/// <summary>
/// 轮播图列表
/// </summary>
public List<RB_ImageCommonModel> CarouselImageList { get; set; }
/// <summary>
/// 服务列表
/// </summary>
public List<RB_ImageCommonModel> ServiceList { get; set; }
/// <summary>
/// 商品分类
/// </summary>
public List<RB_Goods_Category_Extend> CategoryList { get; set; }
/// <summary>
/// 区域列表
/// </summary>
public List<RB_Goods_Area_Extend> AreaList { get; set; }
/// <summary>
/// 规格名列表
/// </summary>
public List<RB_Goods_Specification_Extend> SpecificationList { get; set; }
/// <summary>
/// 规格价格列表
/// </summary>
public List<RB_Goods_SpecificationPrice_Extend> SpecificationPriceList { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品关联规格价格表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_SpecificationPrice_Extend : RB_Goods_SpecificationPrice
{
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品关联规格值表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_SpecificationValue_Extend : RB_Goods_SpecificationValue
{
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
/// <summary>
/// 图片路径
/// </summary>
public string ImagePath { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品关联规格表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Specification_Extend : RB_Goods_Specification
{
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
/// <summary>
/// 规格值列表
/// </summary>
public List<RB_Goods_SpecificationValue_Extend> SpecificationValueList { get; set; }
}
}
......@@ -50,6 +50,30 @@ namespace Mall.Module.Product
/// 商品服务
/// </summary>
private readonly RB_Product_ServiceRepository product_ServiceRepository = new RB_Product_ServiceRepository();
/// <summary>
/// 商品
/// </summary>
private readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository();
/// <summary>
/// 商品区域
/// </summary>
private readonly RB_Goods_AreaRepository goods_AreaRepository = new RB_Goods_AreaRepository();
/// <summary>
/// 商品分类
/// </summary>
private readonly RB_Goods_CategoryRepository goods_CategoryRepository = new RB_Goods_CategoryRepository();
/// <summary>
/// 商品规格
/// </summary>
private readonly RB_Goods_SpecificationRepository goods_SpecificationRepository = new RB_Goods_SpecificationRepository();
/// <summary>
/// 商品规格值
/// </summary>
private readonly RB_Goods_SpecificationValueRepository goods_SpecificationValueRepository = new RB_Goods_SpecificationValueRepository();
/// <summary>
/// 商品规格价格
/// </summary>
private readonly RB_Goods_SpecificationPriceRepository goods_SpecificationPriceRepository = new RB_Goods_SpecificationPriceRepository();
#region 素材管理
......@@ -1027,7 +1051,7 @@ namespace Mall.Module.Product
else {
return product_QuickBuyRepository.Insert(demodel) > 0;
}
}
}
/// <summary>
/// 删除快速购买
......@@ -1234,5 +1258,531 @@ namespace Mall.Module.Product
return product_ServiceRepository.Update(keyValues, wheres);
}
#endregion
#region 商品管理
/// <summary>
/// 获取后台商品分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetProductGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{
var list = goodsRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) {
//查询分类
string ids = string.Join(",", list.Select(x => x.Id));
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in list) {
item.CategoryList = clist.Where(x => x.GoodsId == item.Id).ToList();
//轮播图
item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]") {
List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(item.CarouselImage);
//封面图
item.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? "";
//轮播图
}
}
}
return list;
}
/// <summary>
/// 新增修改商品信息
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool SetProductGoodsInfo(RB_Goods_Extend demodel)
{
var trans = goodsRepository.DbTransaction;
try
{
if (demodel.Id > 0)
{
//修改
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.Name),demodel.Name},
{ nameof(RB_Goods.CarouselImage),demodel.CarouselImage},
{ nameof(RB_Goods.VideoAddress),demodel.VideoAddress},
{ nameof(RB_Goods.CustomShareTitles),demodel.CustomShareTitles},
{ nameof(RB_Goods.CustomShareImage),demodel.CustomShareImage},
{ nameof(RB_Goods.GoodsStatus),demodel.GoodsStatus},
{ nameof(RB_Goods.InventoryNum),demodel.InventoryNum},
{ nameof(RB_Goods.DefaultSpecificationName),demodel.DefaultSpecificationName},
{ nameof(RB_Goods.IsCustomSpecification),demodel.IsCustomSpecification},
{ nameof(RB_Goods.Sort),demodel.Sort},
{ nameof(RB_Goods.SellingPrice),demodel.SellingPrice},
{ nameof(RB_Goods.OriginalPrice),demodel.OriginalPrice},
{ nameof(RB_Goods.Unit),demodel.Unit},
{ nameof(RB_Goods.CostPrice),demodel.CostPrice},
{ nameof(RB_Goods.IsGoodsNegotiable),demodel.IsGoodsNegotiable},
{ nameof(RB_Goods.SalesNum),demodel.SalesNum},
{ nameof(RB_Goods.GoodsNumbers),demodel.GoodsNumbers},
{ nameof(RB_Goods.GoodsWeight),demodel.GoodsWeight},
{ nameof(RB_Goods.IsDefaultService),demodel.IsDefaultService},
{ nameof(RB_Goods.GoodsService),demodel.GoodsService},
{ nameof(RB_Goods.FreightId),demodel.FreightId},
{ nameof(RB_Goods.FormsId),demodel.FormsId},
{ nameof(RB_Goods.LimitBuyGoodsNum),demodel.LimitBuyGoodsNum},
{ nameof(RB_Goods.LimitBuyOrderNum),demodel.LimitBuyOrderNum},
{ nameof(RB_Goods.FullNumPinkage),demodel.FullNumPinkage},
{ nameof(RB_Goods.FullMoneyPinkage),demodel.FullMoneyPinkage},
{ nameof(RB_Goods.IsAreaBuy),demodel.IsAreaBuy},
{ nameof(RB_Goods.IntegralPresent),demodel.IntegralPresent},
{ nameof(RB_Goods.IntegralPresentType),demodel.IntegralPresentType},
{ nameof(RB_Goods.PointsDeduction),demodel.PointsDeduction},
{ nameof(RB_Goods.PointsDeductionType),demodel.PointsDeductionType},
{ nameof(RB_Goods.IsMultipleDeduction),demodel.IsMultipleDeduction},
{ nameof(RB_Goods.GoodsDetails),demodel.GoodsDetails},
{ nameof(RB_Goods.UpdateDate),demodel.UpdateDate},
{ nameof(RB_Goods.SeparateDistribution),demodel.SeparateDistribution},
{ nameof(RB_Goods.SeparateDistributionType),demodel.SeparateDistributionType},
{ nameof(RB_Goods.SeparateDistributionMoneyType),demodel.SeparateDistributionMoneyType},
{ nameof(RB_Goods.SeparateDistributionMoneyType),demodel.SeparateDistributionMoneyType},
{ nameof(RB_Goods.SeparateSetMember),demodel.SeparateSetMember},
{ nameof(RB_Goods.IsQuickBuy),demodel.IsQuickBuy}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=demodel.Id,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.TenantId),
FiledValue=demodel.TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.MallBaseId),
FiledValue=demodel.MallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = goodsRepository.Update(keyValues, wheres, trans);
if (flag) {
#region 修改分类
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var insertList = demodel.CategoryList.Where(x => !clist.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
//var updateList = clist.Where(x => demodel.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
var deleteList = clist.Where(x => !demodel.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
foreach (var item in insertList) {
goods_CategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item.CategoryId,
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
}, trans);
}
foreach (var item in deleteList) {
goods_CategoryRepository.Delete(item.Id, trans);
}
#endregion
#region 修改规格
if (demodel.IsCustomSpecification == 1)
{
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (slist.Count() != demodel.SpecificationList.Count() || slist.Count() != demodel.SpecificationList.Where(x => x.Id > 0).Count())
{
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
//删除后新增
goods_SpecificationRepository.DeleteBatch(slist, trans);
goods_SpecificationValueRepository.DeleteBatch(svlist, trans);
goods_SpecificationPriceRepository.DeleteBatch(splist, trans);
foreach (var item in demodel.SpecificationList)
{
int sid = goods_SpecificationRepository.Insert(new RB_Goods_Specification()
{
CreateDate = demodel.CreateDate,
EnabledImage = item.EnabledImage,
GoodsId = demodel.Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Name = item.Name,
Sort = item.Sort,
Status = 0,
TenantId = demodel.TenantId
}, trans);
if (sid > 0)
{
foreach (var qitem in item.SpecificationValueList)
{
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = sid
}, trans);
}
}
}
foreach (var item in demodel.SpecificationPriceList)
{
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
GoodsNumbers = item.GoodsNumbers,
GoodsWeight = item.GoodsWeight,
InventoryNum = item.InventoryNum,
MallBaseId = demodel.MallBaseId,
SellingPrice = item.SellingPrice,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
}, trans);
}
}
else
{
//更新
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in slist) {
var supmodel = demodel.SpecificationList.Where(x => x.Id == item.Id).FirstOrDefault();
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_Specification.EnabledImage),supmodel.EnabledImage},
{ nameof(RB_Goods_Specification.Name),supmodel.Name},
{ nameof(RB_Goods_Specification.Sort),supmodel.Sort}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_Specification.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag1 = goods_SpecificationRepository.Update(keyValues1, wheres1, trans);
if (flag1) {
var sv2list = svlist.Where(x => x.SpecificationId == item.Id).ToList();
if (sv2list.Count() != supmodel.SpecificationValueList.Count() || sv2list.Count() != supmodel.SpecificationValueList.Where(x => x.Id > 0).Count())
{
goods_SpecificationValueRepository.DeleteBatch(sv2list, trans);
foreach (var qitem in supmodel.SpecificationValueList)
{
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = item.Id
}, trans);
}
}
else {
foreach (var qitem in sv2list)
{
var supModel1 = supmodel.SpecificationValueList.Where(x => x.Id == qitem.Id).FirstOrDefault();
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ nameof(RB_Goods_SpecificationValue.Image),supModel1.Image},
{ nameof(RB_Goods_SpecificationValue.Name),supModel1.Name},
{ nameof(RB_Goods_SpecificationValue.Sort),supModel1.Sort}
};
List<WhereHelper> wheres2 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_Specification.Id),
FiledValue=qitem.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_SpecificationValueRepository.Update(keyValues2, wheres2, trans);
}
}
}
}
//价格新增/更新
if (splist.Count() != demodel.SpecificationPriceList.Count() || splist.Count() != demodel.SpecificationPriceList.Where(x => splist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count())
{
goods_SpecificationPriceRepository.DeleteBatch(splist, trans);
foreach (var item in demodel.SpecificationPriceList)
{
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
GoodsNumbers = item.GoodsNumbers,
GoodsWeight = item.GoodsWeight,
InventoryNum = item.InventoryNum,
MallBaseId = demodel.MallBaseId,
SellingPrice = item.SellingPrice,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
}, trans);
}
}
else {
foreach (var item in splist) {
var pupmodel = demodel.SpecificationPriceList.Where(x => x.SpecificationSort == item.SpecificationSort).FirstOrDefault();
if (item.SellingPrice != pupmodel.SellingPrice || item.InventoryNum != pupmodel.InventoryNum || item.GoodsNumbers != pupmodel.GoodsNumbers || item.GoodsWeight != pupmodel.GoodsWeight)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_SpecificationPrice.SellingPrice),pupmodel.SellingPrice},
{ nameof(RB_Goods_SpecificationPrice.InventoryNum),pupmodel.InventoryNum},
{ nameof(RB_Goods_SpecificationPrice.GoodsWeight),pupmodel.GoodsWeight},
{ nameof(RB_Goods_SpecificationPrice.GoodsNumbers),pupmodel.GoodsNumbers}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_SpecificationPrice.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_SpecificationPriceRepository.Update(keyValues1, wheres1, trans);
}
}
}
}
}
#endregion
#region 修改区域
var alist = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var insertList1 = demodel.AreaList.Where(x => !alist.Select(y => y.AreaId).Contains(x.AreaId)).ToList();
var deleteList1 = alist.Where(x => !demodel.AreaList.Select(y => y.AreaId).Contains(x.AreaId)).ToList();
foreach (var item in insertList1)
{
goods_AreaRepository.Insert(new RB_Goods_Area()
{
AreaId = item.AreaId,
AreaType = item.AreaType,
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
}, trans);
}
foreach (var item in deleteList1)
{
goods_AreaRepository.Delete(item.Id, trans);
}
#endregion
//修改卡卷
//修改分销佣金
//修改会员价格
}
}
else {
int Id = goodsRepository.Insert(demodel, trans);
bool flag = Id > 0;
if (flag) {
//插入分类
foreach (var item in demodel.CategoryList) {
goods_CategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item.CategoryId,
CreateDate = demodel.CreateDate,
GoodsId = Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
}, trans);
}
//插入规格
if (demodel.IsCustomSpecification == 1) {
foreach (var item in demodel.SpecificationList) {
int sid= goods_SpecificationRepository.Insert(new RB_Goods_Specification()
{
CreateDate = demodel.CreateDate,
EnabledImage = item.EnabledImage,
GoodsId = Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Name = item.Name,
Sort = item.Sort,
Status = 0,
TenantId = demodel.TenantId
}, trans);
if (sid > 0)
{
foreach (var qitem in item.SpecificationValueList)
{
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
{
CreateDate = demodel.CreateDate,
GoodsId = Id,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = sid
}, trans);
}
}
}
foreach (var item in demodel.SpecificationPriceList) {
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = Id,
Id = 0,
GoodsNumbers = item.GoodsNumbers,
GoodsWeight = item.GoodsWeight,
InventoryNum = item.InventoryNum,
MallBaseId = demodel.MallBaseId,
SellingPrice = item.SellingPrice,
SpecificationSort = item.SpecificationSort,
Status = 0,
TenantId = demodel.TenantId,
UpdateDate = demodel.UpdateDate
}, trans);
}
}
//插入区域
foreach (var item in demodel.AreaList) {
goods_AreaRepository.Insert(new RB_Goods_Area()
{
AreaId = item.AreaId,
AreaType = item.AreaType,
CreateDate = demodel.CreateDate,
GoodsId = Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
}, trans);
}
//插入卡卷
//插入分销佣金
//插入会员价格
}
}
goodsRepository.DBSession.Commit();
return true;
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetProductGoodsInfo");
goodsRepository.DBSession.Rollback();
return false;
}
}
/// <summary>
/// 快速修改
/// </summary>
/// <param name="goodsId"></param>
/// <param name="type"></param>
/// <param name="sort"></param>
/// <param name="goodsName"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool SetProductGoodsQuickUpdate(int goodsId, int type, int sort, string goodsName, int tenantId, int mallBaseId)
{
Dictionary<string, object> keyValues;
if (type == 1)
{
keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.Sort),sort}
};
}
else if (type == 2)
{
keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.Name),goodsName}
};
}
else if (type == 3)
{
var model = goodsRepository.GetEntity(goodsId);
if (model == null) {
return false;
}
keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.IsQuickBuy),model.IsQuickBuy==1?2:1}
};
}
else {
return false;
}
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=goodsId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
return goodsRepository.Update(keyValues, wheres);
}
/// <summary>
/// 删除商品
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool DelProcudtGoodsInfo(int goodsId, int tenantId, int mallBaseId)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.Status),1},
{ nameof(RB_Goods.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=goodsId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
return goodsRepository.Update(keyValues, wheres);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品仓储层
/// </summary>
public class RB_GoodsRepository : RepositoryBase<RB_Goods>
{
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_Extend> GetPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel)
{
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0";
if (dmodel.TenantId > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.Name)) {
where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'";
}
if (dmodel.GoodsStatus > 0) {
where += $@" and g.{nameof(RB_Goods_Extend.GoodsStatus)}={dmodel.GoodsStatus}";
}
if (dmodel.IsSelectSellOut == 1) {
where += $@" and g.{nameof(RB_Goods_Extend.InventoryNum)}<=0";
}
if (!string.IsNullOrEmpty(dmodel.CategoryIds)) {
where += $@" and c.{nameof(RB_Goods_Category.CategoryId)} in({dmodel.CategoryIds})";
}
if (!string.IsNullOrEmpty(dmodel.StartTime)) {
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime)) {
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
string sql = $@"select g.* from RB_Goods g
inner join rb_goods_category c on g.Id=c.GoodsId
where {where} group by g.Id order by g.CreateDate desc";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetList(RB_Goods_Extend dmodel)
{
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0";
if (dmodel.TenantId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds))
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'";
}
if (dmodel.GoodsStatus > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsStatus)}={dmodel.GoodsStatus}";
}
if (dmodel.IsSelectSellOut == 1)
{
where += $@" and g.{nameof(RB_Goods_Extend.InventoryNum)}<=0";
}
if (!string.IsNullOrEmpty(dmodel.CategoryIds))
{
where += $@" and c.{nameof(RB_Goods_Category.CategoryId)} in({dmodel.CategoryIds})";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
string sql = $@"select g.* from RB_Goods g
inner join rb_goods_category c on g.Id=c.GoodsId
where {where} group by g.Id order by g.CreateDate desc";
return Get<RB_Goods_Extend>(sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品关联区域仓储层
/// </summary>
public class RB_Goods_AreaRepository : RepositoryBase<RB_Goods_Area>
{
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_Area_Extend> GetList(RB_Goods_Area_Extend dmodel)
{
string where = $" 1=1 and ga.{nameof(RB_Goods_Area.Status)}=0";
if (dmodel.TenantId > 0) {
where += $@" and ga.{nameof(RB_Goods_Area.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0) {
where += $@" and ga.{nameof(RB_Goods_Area.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0) {
where += $@" and ga.{nameof(RB_Goods_Area.Id)}={dmodel.Id}";
}
if (dmodel.GoodsId > 0) {
where += $@" and ga.{nameof(RB_Goods_Area.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and ga.{nameof(RB_Goods_Area.GoodsId)} in({dmodel.GoodsIds})";
}
string sql = $@"select ga.*,d.Name as AreaName from RB_Goods_Area ga
inner join rb_destination d on ga.AreaId=d.ID
where {where} order by ga.Id desc";
return Get<RB_Goods_Area_Extend>(sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品关联分类仓储层
/// </summary>
public class RB_Goods_CategoryRepository : RepositoryBase<RB_Goods_Category>
{
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_Category_Extend> GetList(RB_Goods_Category_Extend dmodel)
{
string where = $" 1=1 and gc.{nameof(RB_Goods_Category.Status)}=0";
if (dmodel.TenantId > 0) {
where += $@" and gc.{nameof(RB_Goods_Category.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0) {
where += $@" and gc.{nameof(RB_Goods_Category.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0) {
where += $@" and gc.{nameof(RB_Goods_Category.Id)}={dmodel.Id}";
}
if (dmodel.GoodsId > 0) {
where += $@" and gc.{nameof(RB_Goods_Category.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and gc.{nameof(RB_Goods_Category.GoodsId)} in({dmodel.GoodsIds})";
}
string sql = $@"select gc.*,pc.Name as CategoryName from RB_Goods_Category gc
inner join rb_product_category pc on gc.CategoryId=pc.Id
where {where} order by gc.Id desc";
return Get<RB_Goods_Category_Extend>(sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品关联规格价格仓储层
/// </summary>
public class RB_Goods_SpecificationPriceRepository : RepositoryBase<RB_Goods_SpecificationPrice>
{
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_SpecificationPrice_Extend> GetList(RB_Goods_SpecificationPrice_Extend dmodel)
{
string where = $" 1=1 and {nameof(RB_Goods_SpecificationPrice.Status)}=0";
if (dmodel.TenantId > 0) {
where += $@" and {nameof(RB_Goods_SpecificationPrice.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0) {
where += $@" and {nameof(RB_Goods_SpecificationPrice.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0) {
where += $@" and {nameof(RB_Goods_SpecificationPrice.Id)}={dmodel.Id}";
}
if (dmodel.GoodsId > 0) {
where += $@" and {nameof(RB_Goods_SpecificationPrice.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and {nameof(RB_Goods_SpecificationPrice.GoodsId)} in({dmodel.GoodsIds})";
}
string sql = $@"select * from RB_Goods_SpecificationPrice where {where} order by Id desc";
return Get<RB_Goods_SpecificationPrice_Extend>(sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品关联规格仓储层
/// </summary>
public class RB_Goods_SpecificationRepository : RepositoryBase<RB_Goods_Specification>
{
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_Specification_Extend> GetList(RB_Goods_Specification_Extend dmodel)
{
string where = $" 1=1 and {nameof(RB_Goods_Specification.Status)}=0";
if (dmodel.TenantId > 0) {
where += $@" and {nameof(RB_Goods_Specification.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0) {
where += $@" and {nameof(RB_Goods_Specification.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0) {
where += $@" and {nameof(RB_Goods_Specification.Id)}={dmodel.Id}";
}
if (dmodel.GoodsId > 0) {
where += $@" and {nameof(RB_Goods_Specification.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and {nameof(RB_Goods_Specification.GoodsId)} in({dmodel.GoodsIds})";
}
string sql = $@"select * from RB_Goods_Specification where {where} order by Id desc";
return Get<RB_Goods_Specification_Extend>(sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品关联规格值仓储层
/// </summary>
public class RB_Goods_SpecificationValueRepository : RepositoryBase<RB_Goods_SpecificationValue>
{
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_SpecificationValue_Extend> GetList(RB_Goods_SpecificationValue_Extend dmodel)
{
string where = $" 1=1 and {nameof(RB_Goods_SpecificationValue.Status)}=0";
if (dmodel.TenantId > 0) {
where += $@" and {nameof(RB_Goods_SpecificationValue.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0) {
where += $@" and {nameof(RB_Goods_SpecificationValue.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0) {
where += $@" and {nameof(RB_Goods_SpecificationValue.Id)}={dmodel.Id}";
}
if (dmodel.SpecificationId > 0) {
where += $@" and {nameof(RB_Goods_SpecificationValue.SpecificationId)}={dmodel.SpecificationId}";
}
if (dmodel.GoodsId > 0) {
where += $@" and {nameof(RB_Goods_SpecificationValue.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and {nameof(RB_Goods_SpecificationValue.GoodsId)} in({dmodel.GoodsIds})";
}
string sql = $@"select * from RB_Goods_SpecificationValue where {where} order by Id desc";
return Get<RB_Goods_SpecificationValue_Extend>(sql).ToList();
}
}
}
......@@ -1037,7 +1037,259 @@ namespace Mall.WebApi.Controllers.MallBase
#region 商品列表
/// <summary>
/// 商品后台分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProductGoodsPageList() {
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(parms.msg.ToString());
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(parms.msg.ToString());
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
var list = productModule.GetProductGoodsPageList(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.SellingPrice,
x.InventoryNum,
x.SalesNum,
x.IsQuickBuy,
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 SetProductGoodsInfo() {
var parms = RequestParm;
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(parms.msg.ToString());
if (string.IsNullOrEmpty(demodel.Name)) {
return ApiResult.ParamIsNull("请输入商品名称");
}
if (demodel.CarouselImageList == null || !demodel.CarouselImageList.Any()) {
return ApiResult.ParamIsNull("请添加商品轮播图");
}
demodel.IsCustomSpecification ??= 1;
demodel.InventoryNum ??= 0;
if (demodel.IsCustomSpecification == 1)
{
if (demodel.SpecificationList == null || !demodel.SpecificationList.Any()) {
return ApiResult.ParamIsNull("请传递规格列表");
}
if (demodel.SpecificationPriceList == null || !demodel.SpecificationPriceList.Any()) {
return ApiResult.ParamIsNull("请传递规格价格库存列表");
}
if (demodel.SpecificationList.Count() != demodel.SpecificationList.Select(x => x.Sort).Distinct().Count()) {
return ApiResult.ParamIsNull("规格名排序有误");
}
int TotalNum = 1;
foreach (var item in demodel.SpecificationList) {
if (item.SpecificationValueList == null || !item.SpecificationValueList.Any())
{
return ApiResult.ParamIsNull("请传递规格值列表");
}
if (item.SpecificationValueList.Count() != item.SpecificationValueList.Select(x => x.Sort).Distinct().Count()) {
return ApiResult.ParamIsNull("规格值排序有误");
}
TotalNum *= item.SpecificationValueList.Count();
if (item.EnabledImage == 1) {
foreach (var qitem in item.SpecificationValueList) {
if ((qitem.Image ?? 0) <= 0) {
return ApiResult.ParamIsNull("请选择规格图片");
}
}
}
}
//验证总keys数量
if (demodel.SpecificationPriceList.Count() != TotalNum) {
return ApiResult.ParamIsNull("规格价格数量有误");
}
//初始化所有keys
List<string> KeyList = new List<string>();
for (var i = 1; i <= TotalNum; i++)
{
KeyList.Add("");
}
int MGBJNum = 1;
//组装所有keys
foreach (var item in demodel.SpecificationList) {
int LBBJNum = TotalNum / item.SpecificationValueList.Count() / MGBJNum;
int KeyIndex = 1;
for (var i = 1; i <= LBBJNum; i++)
{
foreach (var qitem in item.SpecificationValueList)
{
for (var j = 1; j <= MGBJNum; j++) {
KeyList[KeyIndex] = KeyList[KeyIndex] + "," + qitem.Sort;
KeyIndex++;
}
}
}
}
//验证所有keys
foreach (var item in KeyList) {
string keys = item.Substring(1, item.Length);
var pricemodel = demodel.SpecificationPriceList.Where(x => x.SpecificationSort == keys).FirstOrDefault();
if (pricemodel == null) {
return ApiResult.ParamIsNull("规格价格Key有误");
}
if ((pricemodel.SellingPrice ?? 0) <= 0) {
return ApiResult.ParamIsNull("请输入规格列表价格");
}
if ((pricemodel.InventoryNum ?? 0) < 0) {
return ApiResult.ParamIsNull("规格列表库存不正确");
}
pricemodel.InventoryNum ??= 0;
pricemodel.SellingPrice ??= 0;
pricemodel.GoodsNumbers ??= "";
pricemodel.GoodsWeight ??= 0;
demodel.InventoryNum += (pricemodel.InventoryNum ?? 0);
}
}
if ((demodel.SellingPrice ?? 0) <= 0) {
return ApiResult.ParamIsNull("请输入售价");
}
if ((demodel.OriginalPrice ?? 0) <= 0) {
return ApiResult.ParamIsNull("请输入原价");
}
if (string.IsNullOrEmpty(demodel.Unit)) {
return ApiResult.ParamIsNull("请输入单位");
}
demodel.VideoAddress ??= "";
demodel.CustomShareTitles ??= "";
demodel.CustomShareImage ??= 0;
demodel.GoodsStatus ??= 2;
demodel.DefaultSpecificationName ??= "";
demodel.Sort ??= 0;
demodel.CostPrice ??= 0;
demodel.IsGoodsNegotiable ??= 2;
demodel.SalesNum ??= 0;
demodel.GoodsNumbers ??= "";
demodel.GoodsWeight ??= 0;
demodel.IsDefaultService ??= 1;
if (demodel.IsDefaultService == 2)
{
if (demodel.ServiceList == null || !demodel.ServiceList.Any())
{
return ApiResult.ParamIsNull("请选择商品服务");
}
demodel.GoodsService = JsonConvert.SerializeObject(demodel.ServiceList.Select(x => x.Id));
}
else {
demodel.GoodsService = "[]";
}
demodel.FreightId ??= 0;
demodel.FormsId ??= 0;
demodel.LimitBuyGoodsNum ??= -1;
demodel.LimitBuyOrderNum ??= -1;
demodel.FullNumPinkage ??= 0;
demodel.FullMoneyPinkage ??= 0;
demodel.IsAreaBuy ??= 2;
if (demodel.IsAreaBuy == 1) {
if (demodel.AreaList == null || !demodel.AreaList.Any()) {
return ApiResult.ParamIsNull("请选择区域");
}
}
demodel.IntegralPresent ??= 0;
demodel.IntegralPresentType ??= 1;
demodel.PointsDeduction ??= 0;
demodel.PointsDeductionType ??= 1;
demodel.IsMultipleDeduction ??= 2;
demodel.Status = 0;
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
demodel.CreateDate = DateTime.Now;
demodel.UpdateDate = DateTime.Now;
demodel.SeparateDistribution ??= 2;
demodel.SeparateDistributionType ??= 1;
demodel.SeparateDistributionMoneyType ??= 1;
demodel.EnjoyMember ??= 2;
demodel.SeparateSetMember ??= 2;
demodel.IsQuickBuy ??= 2;
bool flag = productModule.SetProductGoodsInfo(demodel);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
/// <summary>
/// 商品快速更新
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetProductGoodsQuickUpdate() {
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
int Type = parms.GetInt("Type", 0);//1排序 2商品名称 3快速购买
int Sort = parms.GetInt("Sort", 0);
string GoodsName = parms.GetStringValue("GoodsName");
if (GoodsId <= 0)
{
return ApiResult.ParamIsNull();
}
if (Type == 2) {
if (string.IsNullOrEmpty(GoodsName)) {
return ApiResult.ParamIsNull("请传递商品名称");
}
}
bool flag = productModule.SetProductGoodsQuickUpdate(GoodsId, Type, Sort, GoodsName, req.TenantId, req.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 删除商品
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult DelProcudtGoodsInfo() {
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
if (GoodsId <= 0) {
return ApiResult.ParamIsNull();
}
bool flag = productModule.DelProcudtGoodsInfo(GoodsId, req.TenantId, req.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
#endregion
}
......
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