Commit e2a6a18e authored by 黄奎's avatar 黄奎
parents bb8e3c8d f04a6778
...@@ -64,6 +64,10 @@ namespace Mall.Module.Product ...@@ -64,6 +64,10 @@ namespace Mall.Module.Product
/// </summary> /// </summary>
private readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository(); private readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository();
/// <summary> /// <summary>
/// 商品日志
/// </summary>
private readonly RB_Goods_LogRepository goods_LogRepository = new RB_Goods_LogRepository();
/// <summary>
/// 商品区域 /// 商品区域
/// </summary> /// </summary>
private readonly RB_Goods_AreaRepository goods_AreaRepository = new RB_Goods_AreaRepository(); private readonly RB_Goods_AreaRepository goods_AreaRepository = new RB_Goods_AreaRepository();
...@@ -5152,6 +5156,57 @@ namespace Mall.Module.Product ...@@ -5152,6 +5156,57 @@ namespace Mall.Module.Product
return goods_SpecificationValueRepository.GetList(model); return goods_SpecificationValueRepository.GetList(model);
} }
/// <summary>
/// 商品分类修改
/// </summary>
/// <param name="categoryId"></param>
/// <param name="newCategoryId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public string SetGoodsCategoryTransfer(int categoryId, int newCategoryId, int tenantId, int mallBaseId,int empId)
{
var newModel = product_CategoryRepository.GetEntity(newCategoryId);
if (newModel == null) { return "新分类不存在"; }
if (newModel.Enabled != 1) { return "新分类未启用"; }
var list = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { CategoryId = categoryId, TenantId = tenantId, MallBaseId = mallBaseId });
if (list.Any())
{
foreach (var item in list) {
//修改分类
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods_Category.CategoryId),newCategoryId}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName= nameof(RB_Goods_Category.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = goods_CategoryRepository.Update(keyValues, wheres);
if (flag) {
//记录该商品日志
goods_LogRepository.Insert(new RB_Goods_Log()
{
Id = 0,
Type = 2,
TenantId = tenantId,
MallBaseId = mallBaseId,
SourceId = item.GoodsId,
CreateDate = DateTime.Now,
Content = "商品分类转移,empId:" + empId + ",由" + categoryId + "转移至" + newCategoryId
});
}
}
return "转移成功,总计:" + list.Count() + "商品";
}
else {
return "该分类下未找到相关商品";
}
}
#endregion #endregion
#region 商品代理 #region 商品代理
......
...@@ -36,6 +36,9 @@ namespace Mall.Repository.Product ...@@ -36,6 +36,9 @@ namespace Mall.Repository.Product
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) { if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and gc.{nameof(RB_Goods_Category.GoodsId)} in({dmodel.GoodsIds})"; where += $@" and gc.{nameof(RB_Goods_Category.GoodsId)} in({dmodel.GoodsIds})";
} }
if (dmodel.CategoryId > 0) {
where += $@" and gc.{nameof(RB_Goods_Category.CategoryId)}={dmodel.CategoryId}";
}
string sql = $@" string sql = $@"
SELECT gc.*,pc.Name as CategoryName,pc.IsForeignShare,pc.ParentId,pc.Tier SELECT gc.*,pc.Name as CategoryName,pc.IsForeignShare,pc.ParentId,pc.Tier
......
...@@ -2111,6 +2111,41 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -2111,6 +2111,41 @@ namespace Mall.WebApi.Controllers.MallBase
} }
} }
/// <summary>
/// 保存商品分类转移
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetGoodsCategoryTransfer()
{
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int CategoryId = parms.GetInt("CategoryId", 0);
int NewCategoryId = parms.GetInt("NewCategoryId", 0);//新分类
if (CategoryId <= 0)
{
return ApiResult.ParamIsNull("请选择需转移分类id");
}
if (NewCategoryId < 0)
{
return ApiResult.ParamIsNull("请选择转入分类id");
}
if (CategoryId == NewCategoryId)
{
return ApiResult.ParamIsNull("不能转入同一分类下");
}
string msg = productModule.SetGoodsCategoryTransfer(CategoryId, NewCategoryId, req.TenantId, req.MallBaseId, req.EmpId);
if (msg.Contains("转移成功"))
{
return ApiResult.Success(msg);
}
else
{
return ApiResult.Failed(msg);
}
}
#endregion #endregion
#region 商品代理 #region 商品代理
......
...@@ -379,7 +379,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -379,7 +379,7 @@ namespace Mall.WebApi.Controllers.User
demodel.AuditStatus ??= DistributorAuditStatusEnum.Auditing; demodel.AuditStatus ??= DistributorAuditStatusEnum.Auditing;
demodel.Status = 0; demodel.Status = 0;
demodel.HPGradeId ??= 0; demodel.HPGradeId ??= 0;
demodel.FXGradeId ??= 0; demodel.FXGradeId ??= 1;
demodel.CreateDate = DateTime.Now; demodel.CreateDate = DateTime.Now;
demodel.UpdateDate = DateTime.Now; demodel.UpdateDate = DateTime.Now;
bool flag = userModule.SetUserApplyForBeDistrbutor(demodel); bool flag = userModule.SetUserApplyForBeDistrbutor(demodel);
......
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