Commit 30a83125 authored by 吴春's avatar 吴春

提交代码

parent be8f6978
......@@ -42,5 +42,10 @@ namespace Edu.Common.Enum.Course
/// </summary>
[EnumField("教育同行")]
EduClient = 7,
/// <summary>
/// 甲鹤小程序
/// </summary>
[EnumField("甲鹤小程序")]
MallApplet = 8,
}
}
......@@ -21,5 +21,11 @@ namespace Edu.Model.ViewModel.Mall
/// 图片路径
/// </summary>
public string ImagePath { get; set; }
/// <summary>
/// 班级ids
/// </summary>
public string ClassIds { get; set; }
}
}
......@@ -24,6 +24,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VT.FW.DB;
using Edu.Model.Entity.Mall;
namespace Edu.Module.Course
{
......@@ -586,7 +587,7 @@ namespace Edu.Module.Course
model.ClassPlanList = classPlanList;
#region 同步班级到甲鹤小程序 Add by:W 2021-08-02 09:49
//SetGoodsSpecificationValue(model);
SetGoodsSpecificationValue(model);
#endregion
......@@ -975,7 +976,7 @@ namespace Edu.Module.Course
if (flag)
{
#region 同步班级到甲鹤小程序 Add by:W 2021-08-02 09:49
// System.Threading.Tasks.Task.Run(() => SetGoodsSpecificationValue(model));
System.Threading.Tasks.Task.Run(() => SetGoodsSpecificationValue(model));
#endregion
}
return flag;
......@@ -3875,163 +3876,168 @@ namespace Edu.Module.Course
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
//public bool SetGoodsSpecificationValue(RB_Class_ViewModel model)
//{
// bool flag = false;
// var courseModel = courseRepository.GetEntity(model.CouseId).RefMapperTo<RB_Course_ViewModel>();
// if (courseModel != null && courseModel.MallGoodsId > 0)
// {
// if (courseModel.SalePlatList != null && courseModel.SalePlatList.Any(x => x == 4) && model.ClassStatus == ClassStatusEnum.NonOpenClass)//课程关联到了小程序
// {
// Model.ViewModel.Mall.RB_Goods_Extend demodel = new Model.ViewModel.Mall.RB_Goods_Extend();
// demodel.MallBaseId = Convert.ToInt32(Config.JHMallBaseId);
// demodel.TenantId = Convert.ToInt32(Config.JHTenantId);
// demodel.SpecificationList = new List<RB_Goods_Specification_Extend>();
// demodel.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
// demodel.Id = courseModel.MallGoodsId;
// demodel.CreateDate = System.DateTime.Now;
// RB_Goods_Specification_Extend modelSpecification = new RB_Goods_Specification_Extend();
// modelSpecification.Id = 0;//暂定
// modelSpecification.EnabledImage = 2;
// modelSpecification.Name = "开班日期";
// modelSpecification.Sort = 1;
// modelSpecification.SpecificationValueList = new List<RB_Goods_SpecificationValue_Extend>();
// //查询课程对应班级开课时间大于今天的班级
// var classList = classRepository.GetClassAndCourseListRepository(new RB_Class_ViewModel { CouseId = model.CouseId, StartTime = System.DateTime.Now.ToString("yyyy-MM-dd") }).Where(x => x.ClassStatus == Common.Enum.Course.ClassStatusEnum.NonOpenClass && x.OpenTime > System.DateTime.Now).ToList();
// if (classList != null && classList.Any())
// {
// int Sort = 1;
// foreach (var item in classList)
// {
// RB_Goods_SpecificationValue_Extend modelSpecificationValue = new RB_Goods_SpecificationValue_Extend();
// modelSpecificationValue.Id = 0;
// modelSpecificationValue.Image = "";
// modelSpecificationValue.ImagePath = "";
// modelSpecificationValue.Name = item.OpenTime.ToString("MM月dd日");
// modelSpecificationValue.Sort = Sort;///暂定1
// modelSpecificationValue.ClassId = item.ClassId;
// modelSpecification.SpecificationValueList.Add(modelSpecificationValue);
// RB_Goods_SpecificationPrice_Extend pModel = new RB_Goods_SpecificationPrice_Extend()
// {
// Commission = 0,
// CostMoney = 0,
// GoodsNumbers = item.ClassNo,
// GoodsWeight = 0,
// InventoryNum = item.ClassPersion - item.OrderStudentCount,//暂定
// SellingPrice = item.SellPrice,
// SpecificationSort = Sort.ToString(),//暂定
// AttrList = new object()
// };
// demodel.SpecificationPriceList.Add(pModel);
// Sort += 1;
// }
// }
// demodel.SpecificationList.Add(modelSpecification);
// #region 删除规格
// var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
// 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 });
// if (slist != null && slist.Any())
// {
// //删除后新增
// goods_SpecificationRepository.DeleteBatch(slist);
// }
// if (svlist != null && svlist.Any())
// {
// goods_SpecificationValueRepository.DeleteBatch(svlist);
// }
// if (splist != null && splist.Any())
// {
// goods_SpecificationPriceRepository.DeleteBatch(splist);
// }
// #endregion
// #region 新增规格
// foreach (var item in demodel.SpecificationList)
// {
// int sid = goods_SpecificationRepository.Insert(new RB_Goods_Specification()
// {
// CreateDate = demodel.CreateDate,
// EnabledImage = item.EnabledImage,
// GoodsId = courseModel.MallGoodsId,
// Id = 0,
// MallBaseId = demodel.MallBaseId,
// Name = item.Name,
// Sort = item.Sort,
// Status = 0,
// TenantId = demodel.TenantId
// });
// if (sid > 0)
// {
// foreach (var qitem in item.SpecificationValueList)
// {
// goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
// {
// CreateDate = demodel.CreateDate,
// GoodsId = courseModel.MallGoodsId,
// Id = 0,
// Image = qitem.Image,
// MallBaseId = demodel.MallBaseId,
// Name = qitem.Name,
// Sort = qitem.Sort,
// Status = 0,
// TenantId = demodel.TenantId,
// SpecificationId = sid,
// ClassId = qitem.ClassId
// });
// }
// }
// }
// foreach (var item in demodel.SpecificationPriceList)
// {
// goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
// {
// CreateDate = demodel.CreateDate,
// GoodsId = courseModel.MallGoodsId,
// 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,
// Commission = item.Commission,
// CostMoney = item.CostMoney
// });
// }
// #endregion
// }
// else
// {
// var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
// var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
// if (svlist != null && svlist.Any(x => x.ClassId == model.ClassId))
// {
// var svModel = svlist.Where(x => x.ClassId == model.ClassId).FirstOrDefault();
// var spModel = splist.Where(x => x.SortNum == svModel.Sort).FirstOrDefault();
// if (svModel != null && svModel.Id > 0)
// {
// goods_SpecificationValueRepository.Delete(svModel);
// }
// if (spModel != null && spModel.Id > 0)
// {
// goods_SpecificationPriceRepository.Delete(spModel);
// }
// }
// }
// }
// return flag;
//}
public bool SetGoodsSpecificationValue(RB_Class_ViewModel model)
{
bool flag = false;
var courseModel = courseRepository.GetEntity(model.CouseId).RefMapperTo<RB_Course_ViewModel>();
if (courseModel != null && courseModel.MallGoodsId > 0)
{
if (courseModel.SalePlatList != null && courseModel.SalePlatList.Any(x => x == 4) && model.ClassStatus == ClassStatusEnum.NonOpenClass)//课程关联到了小程序
{
Model.ViewModel.Mall.RB_Goods_Extend demodel = new Model.ViewModel.Mall.RB_Goods_Extend();
demodel.MallBaseId = Convert.ToInt32(Config.JHMallBaseId);
demodel.TenantId = Convert.ToInt32(Config.JHTenantId);
demodel.SpecificationList = new List<RB_Goods_Specification_Extend>();
demodel.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
demodel.Id = courseModel.MallGoodsId;
demodel.CreateDate = System.DateTime.Now;
RB_Goods_Specification_Extend modelSpecification = new RB_Goods_Specification_Extend();
modelSpecification.Id = 0;//暂定
modelSpecification.EnabledImage = 2;
modelSpecification.Name = "开班日期";
modelSpecification.Sort = 1;
modelSpecification.SpecificationValueList = new List<RB_Goods_SpecificationValue_Extend>();
//查询课程对应班级开课时间大于今天的班级
var classList = classRepository.GetClassAndCourseListRepository(new RB_Class_ViewModel { CouseId = model.CouseId, StartTime = System.DateTime.Now.ToString("yyyy-MM-dd") }).Where(x => x.ClassStatus == Common.Enum.Course.ClassStatusEnum.NonOpenClass && x.OpenTime > System.DateTime.Now).ToList();
if (classList != null && classList.Any())
{
int Sort = 1;
foreach (var item in classList)
{
RB_Goods_SpecificationValue_Extend modelSpecificationValue = new RB_Goods_SpecificationValue_Extend();
modelSpecificationValue.Id = 0;
modelSpecificationValue.Image = "";
modelSpecificationValue.ImagePath = "";
modelSpecificationValue.Name = item.OpenTime.ToString("MM月dd日");
modelSpecificationValue.Sort = Sort;///暂定1
modelSpecificationValue.ClassId = item.ClassId;
modelSpecification.SpecificationValueList.Add(modelSpecificationValue);
RB_Goods_SpecificationPrice_Extend pModel = new RB_Goods_SpecificationPrice_Extend()
{
Commission = 0,
CostMoney = 0,
GoodsNumbers = item.ClassNo,
GoodsWeight = 0,
InventoryNum = item.ClassPersion - item.OrderStudentCount,//暂定
SellingPrice = item.SellPrice,
SpecificationSort = Sort.ToString(),//暂定
AttrList = new object()
};
demodel.SpecificationPriceList.Add(pModel);
Sort += 1;
}
}
demodel.SpecificationList.Add(modelSpecification);
#region 删除规格
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
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 });
if (slist != null && slist.Any())
{
//删除后新增
goods_SpecificationRepository.DeleteBatch(slist);
}
if (svlist != null && svlist.Any())
{
goods_SpecificationValueRepository.DeleteBatch(svlist);
}
if (splist != null && splist.Any())
{
goods_SpecificationPriceRepository.DeleteBatch(splist);
}
#endregion
#region 新增规格
foreach (var item in demodel.SpecificationList)
{
int sid = goods_SpecificationRepository.Insert(new RB_Goods_Specification()
{
CreateDate = demodel.CreateDate,
EnabledImage = item.EnabledImage,
GoodsId = courseModel.MallGoodsId,
Id = 0,
MallBaseId = demodel.MallBaseId,
Name = item.Name,
Sort = item.Sort,
Status = 0,
TenantId = demodel.TenantId
});
if (sid > 0)
{
foreach (var qitem in item.SpecificationValueList)
{
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
{
CreateDate = demodel.CreateDate,
GoodsId = courseModel.MallGoodsId,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = sid,
ClassId = qitem.ClassId
});
}
}
}
foreach (var item in demodel.SpecificationPriceList)
{
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = courseModel.MallGoodsId,
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,
Commission = item.Commission,
CostMoney = item.CostMoney
});
}
#endregion
}
else
{
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
if (svlist != null && svlist.Any(x => x.ClassId == model.ClassId))
{
var svModel = svlist.Where(x => x.ClassId == model.ClassId).FirstOrDefault();
var spModel = splist.Where(x => x.SortNum == svModel.Sort).FirstOrDefault();
if (svModel != null && svModel.Id > 0)
{
goods_SpecificationValueRepository.Delete(svModel);
}
if (spModel != null && spModel.Id > 0)
{
goods_SpecificationPriceRepository.Delete(spModel);
}
}
}
}
return flag;
}
#endregion
......
......@@ -303,12 +303,12 @@ namespace Edu.Module.Course
}
if (model.SalePlatList != null && model.SalePlatList.Any(x => x == 4))//上架小程序端,则要同步到小程序
{
//int GoodsId = SetMallGoods(model);//新增字段保存返回电商商品ID
//Dictionary<string, object> fileds = new Dictionary<string, object>()
//{
// {nameof(RB_Course_ViewModel.MallGoodsId),GoodsId },
//};
//flag = courseRepository.Update(fileds, new WhereHelper(nameof(RB_Course_ViewModel.CourseId), model.CourseId));
int GoodsId = SetMallGoods(model);//新增字段保存返回电商商品ID
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Course_ViewModel.MallGoodsId),GoodsId },
};
flag = courseRepository.Update(fileds, new WhereHelper(nameof(RB_Course_ViewModel.CourseId), model.CourseId));
}
if (model.MallGoodsId > 0 && !model.SalePlatList.Any(x => x == 4))//之前上架了小程序端,现在取消了则下架商品
{
......@@ -1557,7 +1557,7 @@ namespace Edu.Module.Course
if (flag && courseModel.SalePlatList != null && courseModel.SalePlatList.Any(x => x == 4))//上架小程序端,则要同步到小程序
{
// System.Threading.Tasks.Task.Run(() => UpdateMallGoodsPrice(courseModel, list));
System.Threading.Tasks.Task.Run(() => UpdateMallGoodsPrice(courseModel, list));
}
return flag;
}
......@@ -1607,540 +1607,540 @@ namespace Edu.Module.Course
#region 小程序商品
//public int SetMallGoods(RB_Course_ViewModel model)
//{
// int goodsId = 0;
// Model.ViewModel.Mall.RB_Goods_Extend demodel = new Model.ViewModel.Mall.RB_Goods_Extend();
// if (model.MallGoodsId > 0)
// {
// demodel = mallGoodsRepository.GetGoodsList(new Model.ViewModel.Mall.RB_Goods_Extend { Id = model.MallGoodsId }).FirstOrDefault();
// if (demodel == null || demodel.Id == 0)//不存在
// {
// demodel = new Model.ViewModel.Mall.RB_Goods_Extend();
// }
// }
// demodel.CarouselImageList = new List<Model.ViewModel.Mall.RB_ImageCommonModel>();
// if (!string.IsNullOrWhiteSpace(model.CoverImg))
// {
// demodel.CarouselImageList.Add(new Model.ViewModel.Mall.RB_ImageCommonModel
// {
// Id = 0,
// Name = "",
// Path = model.CoverImg,
// Type = 0
// });
// demodel.CarouselImage = JsonHelper.Serialize(demodel.CarouselImageList.Select(x => x.Path));
// }
// demodel.Name = model.CourseName;
// demodel.Remark ??= model.CourseFeature;
// demodel.VideoAddress = "";
// demodel.CustomShareTitles = "";
// demodel.CustomShareImage = "";
// demodel.GoodsStatus = 1;
// demodel.InventoryNum = 100;//
// demodel.DefaultSpecificationName = "";
// demodel.SellingPrice = model.SellPrice;
// demodel.OriginalPrice = model.OriginalPrice;
// demodel.Unit = "课";//
// demodel.CostPrice = 0;//
// demodel.IsGoodsNegotiable = 0;
// demodel.SalesNum = 0;
// demodel.GoodsNumbers = "";
// demodel.IsCustomSpecification = 1;//
// demodel.GoodsWeight = 0;
// demodel.IsDefaultService = 1;
// demodel.FreightId = -1;
// demodel.FormsId = 1;
// demodel.LimitBuyGoodsNum = -1;
// demodel.LimitBuyOrderNum = -1;
// demodel.IsAreaBuy = 0;
// demodel.IntegralPresent = 0;
// demodel.IntegralPresentType = 2;
// demodel.PointsDeduction = 0;
// demodel.PointsDeductionType = 2;
// demodel.IsMultipleDeduction = 2;
// demodel.GoodsDetails = model.CourseIntro;
// demodel.SeparateDistribution = 0;//
// demodel.SeparateDistributionType = 1;
// demodel.SeparateDistributionMoneyType = 2;
// demodel.EnjoyMember = 1;
// demodel.SeparateSetMember = 0;
// demodel.IsQuickBuy = 1;
// demodel.FullNumPinkage = 0;
// demodel.FullMoneyPinkage = 0;
// demodel.SupplierId = 0;
// demodel.Sort = 1;
// demodel.Commission = 0;
// demodel.SendArea = "";
// demodel.VideoType = 1;
// demodel.GoodsPageType = 0;
// demodel.IsNoTax = 0;
// demodel.GoodsCountry = "";
// demodel.FatCode = "";
// demodel.GoodsUrl = "";
// demodel.goodsLogo = "";
// demodel.SeparateDistributionMoneyType ??= 1;
// demodel.EnjoyMember ??= 2;
// demodel.SeparateSetMember ??= 2;
// demodel.IsQuickBuy ??= 2;
// demodel.IsSellWell ??= 2;
// demodel.GoodsType ??= OrderTypeEnum.Mall;
// demodel.GoodsStatus ??= 2;
// demodel.IsProxy ??= 2;
// demodel.ProxyType ??= 1;
// demodel.ProxyRises ??= 0;
// demodel.ProxyMoney ??= 0;
// demodel.IsProcurement = 2;//新增时
// demodel.PresentFXGrade ??= 0;//赠送粉象等级
// demodel.PresentFXMonth ??= 0;
// demodel.Advertising ??= "";//广告词
// demodel.SubName ??= "";//副标题
// demodel.IsLiveGoods ??= 2;//是否直播商品 1是 2否
// demodel.SendArea ??= "";//发货地
// demodel.GoodsClassify = 0;
// demodel.IntegralComment ??= 0;//评论反积分
// demodel.IntegralCommentType ??= 1;
// demodel.GoodsPageType ??= GoodsPageTypeEnum.All;
// demodel.TenantId = Convert.ToInt32(Config.JHTenantId);
// demodel.MallBaseId = Convert.ToInt32(Config.JHMallBaseId);
// #region 商品规格信息
// demodel.SpecificationList = new List<RB_Goods_Specification_Extend>();
// demodel.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
// RB_Goods_Specification_Extend modelSpecification = new RB_Goods_Specification_Extend();
// modelSpecification.Id = 0;//暂定
// modelSpecification.EnabledImage = 2;
// modelSpecification.Name = "开班日期";
// modelSpecification.Sort = 1;
// modelSpecification.SpecificationValueList = new List<RB_Goods_SpecificationValue_Extend>();
// //查询课程对应班级开课时间大于今天的班级
// var classList = classRepository.GetClassAndCourseListRepository(new RB_Class_ViewModel { CouseId = model.CourseId, StartTime = System.DateTime.Now.ToString("yyyy-MM-dd") }).Where(x => x.ClassStatus == Common.Enum.Course.ClassStatusEnum.NonOpenClass && x.OpenTime > System.DateTime.Now).ToList();
// if (classList != null && classList.Any())
// {
// int Sort = 1;
// foreach (var item in classList)
// {
// RB_Goods_SpecificationValue_Extend modelSpecificationValue = new RB_Goods_SpecificationValue_Extend();
// modelSpecificationValue.Id = 0;
// modelSpecificationValue.Image = "";
// modelSpecificationValue.ImagePath = "";
// modelSpecificationValue.Name = item.OpenTime.ToString("MM月dd日");
// modelSpecificationValue.Sort = Sort;///暂定1
// modelSpecificationValue.ClassId = item.ClassId;
// modelSpecification.SpecificationValueList.Add(modelSpecificationValue);
// RB_Goods_SpecificationPrice_Extend pModel = new RB_Goods_SpecificationPrice_Extend()
// {
// Commission = 0,
// CostMoney = 0,
// GoodsNumbers = item.ClassNo,
// GoodsWeight = 0,
// InventoryNum = item.ClassPersion - item.OrderStudentCount,//暂定
// SellingPrice = item.SellPrice,
// SpecificationSort = "1",//暂定
// AttrList = new object()
// };
// demodel.SpecificationPriceList.Add(pModel);
// Sort += 1;
// }
// }
// demodel.SpecificationList.Add(modelSpecification);
// #endregion
public int SetMallGoods(RB_Course_ViewModel model)
{
int goodsId = 0;
Model.ViewModel.Mall.RB_Goods_Extend demodel = new Model.ViewModel.Mall.RB_Goods_Extend();
if (model.MallGoodsId > 0)
{
demodel = mallGoodsRepository.GetGoodsList(new Model.ViewModel.Mall.RB_Goods_Extend { Id = model.MallGoodsId }).FirstOrDefault();
if (demodel == null || demodel.Id == 0)//不存在
{
demodel = new Model.ViewModel.Mall.RB_Goods_Extend();
}
}
demodel.CarouselImageList = new List<Model.ViewModel.Mall.RB_ImageCommonModel>();
if (!string.IsNullOrWhiteSpace(model.CoverImg))
{
demodel.CarouselImageList.Add(new Model.ViewModel.Mall.RB_ImageCommonModel
{
Id = 0,
Name = "",
Path = model.CoverImg,
Type = 0
});
demodel.CarouselImage = JsonHelper.Serialize(demodel.CarouselImageList.Select(x => x.Path));
}
demodel.Name = model.CourseName;
demodel.Remark ??= model.CourseFeature;
demodel.VideoAddress = "";
demodel.CustomShareTitles = "";
demodel.CustomShareImage = "";
demodel.GoodsStatus = 1;
demodel.InventoryNum = 100;//
demodel.DefaultSpecificationName = "";
demodel.SellingPrice = model.SellPrice;
demodel.OriginalPrice = model.OriginalPrice;
demodel.Unit = "课";//
demodel.CostPrice = 0;//
demodel.IsGoodsNegotiable = 0;
demodel.SalesNum = 0;
demodel.GoodsNumbers = "";
demodel.IsCustomSpecification = 1;//
demodel.GoodsWeight = 0;
demodel.IsDefaultService = 1;
demodel.FreightId = -1;
demodel.FormsId = 1;
demodel.LimitBuyGoodsNum = -1;
demodel.LimitBuyOrderNum = -1;
demodel.IsAreaBuy = 0;
demodel.IntegralPresent = 0;
demodel.IntegralPresentType = 2;
demodel.PointsDeduction = 0;
demodel.PointsDeductionType = 2;
demodel.IsMultipleDeduction = 2;
demodel.GoodsDetails = model.CourseIntro;
demodel.SeparateDistribution = 0;//
demodel.SeparateDistributionType = 1;
demodel.SeparateDistributionMoneyType = 2;
demodel.EnjoyMember = 1;
demodel.SeparateSetMember = 0;
demodel.IsQuickBuy = 1;
demodel.FullNumPinkage = 0;
demodel.FullMoneyPinkage = 0;
demodel.SupplierId = 0;
demodel.Sort = 1;
demodel.Commission = 0;
demodel.SendArea = "";
demodel.VideoType = 1;
demodel.GoodsPageType = 0;
demodel.IsNoTax = 0;
demodel.GoodsCountry = "";
demodel.FatCode = "";
demodel.GoodsUrl = "";
demodel.goodsLogo = "";
demodel.SeparateDistributionMoneyType ??= 1;
demodel.EnjoyMember ??= 2;
demodel.SeparateSetMember ??= 2;
demodel.IsQuickBuy ??= 2;
demodel.IsSellWell ??= 2;
demodel.GoodsType ??= OrderTypeEnum.Mall;
demodel.GoodsStatus ??= 2;
demodel.IsProxy ??= 2;
demodel.ProxyType ??= 1;
demodel.ProxyRises ??= 0;
demodel.ProxyMoney ??= 0;
demodel.IsProcurement = 2;//新增时
demodel.PresentFXGrade ??= 0;//赠送粉象等级
demodel.PresentFXMonth ??= 0;
demodel.Advertising ??= "";//广告词
demodel.SubName ??= "";//副标题
demodel.IsLiveGoods ??= 2;//是否直播商品 1是 2否
demodel.SendArea ??= "";//发货地
demodel.GoodsClassify = 0;
demodel.IntegralComment ??= 0;//评论反积分
demodel.IntegralCommentType ??= 1;
demodel.GoodsPageType ??= GoodsPageTypeEnum.All;
demodel.TenantId = Convert.ToInt32(Config.JHTenantId);
demodel.MallBaseId = Convert.ToInt32(Config.JHMallBaseId);
#region 商品规格信息
demodel.SpecificationList = new List<RB_Goods_Specification_Extend>();
demodel.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
RB_Goods_Specification_Extend modelSpecification = new RB_Goods_Specification_Extend();
modelSpecification.Id = 0;//暂定
modelSpecification.EnabledImage = 2;
modelSpecification.Name = "开班日期";
modelSpecification.Sort = 1;
modelSpecification.SpecificationValueList = new List<RB_Goods_SpecificationValue_Extend>();
//查询课程对应班级开课时间大于今天的班级
var classList = classRepository.GetClassAndCourseListRepository(new RB_Class_ViewModel { CouseId = model.CourseId, StartTime = System.DateTime.Now.ToString("yyyy-MM-dd") }).Where(x => x.ClassStatus == Common.Enum.Course.ClassStatusEnum.NonOpenClass && x.OpenTime > System.DateTime.Now).ToList();
if (classList != null && classList.Any())
{
int Sort = 1;
foreach (var item in classList)
{
RB_Goods_SpecificationValue_Extend modelSpecificationValue = new RB_Goods_SpecificationValue_Extend();
modelSpecificationValue.Id = 0;
modelSpecificationValue.Image = "";
modelSpecificationValue.ImagePath = "";
modelSpecificationValue.Name = item.OpenTime.ToString("MM月dd日");
modelSpecificationValue.Sort = Sort;///暂定1
modelSpecificationValue.ClassId = item.ClassId;
modelSpecification.SpecificationValueList.Add(modelSpecificationValue);
RB_Goods_SpecificationPrice_Extend pModel = new RB_Goods_SpecificationPrice_Extend()
{
Commission = 0,
CostMoney = 0,
GoodsNumbers = item.ClassNo,
GoodsWeight = 0,
InventoryNum = item.ClassPersion - item.OrderStudentCount,//暂
SellingPrice = item.SellPrice,
SpecificationSort = Sort.ToString(),//暂定
AttrList = new object()
};
demodel.SpecificationPriceList.Add(pModel);
Sort += 1;
}
}
demodel.SpecificationList.Add(modelSpecification);
#endregion
// if (demodel.Id == 0)//已存在,更新
// {
// demodel.Status = 0;
// demodel.CreateDate = System.DateTime.Now;
// demodel.UpdateDate = System.DateTime.Now;
// goodsId = mallGoodsRepository.Insert(demodel);
if (demodel.Id == 0)//已存在,更新
{
demodel.Status = 0;
demodel.CreateDate = System.DateTime.Now;
demodel.UpdateDate = System.DateTime.Now;
goodsId = mallGoodsRepository.Insert(demodel);
// if (goodsId > 0)
// {
if (goodsId > 0)
{
// //插入分类
// foreach (var item in model.CategoryList)
// {
// MallGoodsCategoryRepository.Insert(new RB_Goods_Category()
// {
// CategoryId = item.CategoryId,
// CreateDate = demodel.CreateDate,
// GoodsId = goodsId,
// Id = 0,
// MallBaseId = demodel.MallBaseId,
// Status = 0,
// TenantId = demodel.TenantId
// });
// }
//插入分类
foreach (var item in model.CategoryList)
{
MallGoodsCategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item.CategoryId,
CreateDate = demodel.CreateDate,
GoodsId = goodsId,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
});
}
// }
// }
// else
// { //修改
// 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.EnjoyMember),demodel.EnjoyMember},
// { nameof(RB_Goods.SeparateSetMember),demodel.SeparateSetMember},
// { nameof(RB_Goods.IsQuickBuy),demodel.IsQuickBuy},
// { nameof(RB_Goods.SupplierId),demodel.SupplierId},
// { nameof(RB_Goods.IsProxy),demodel.IsProxy},
// { nameof(RB_Goods.ProxyType),demodel.ProxyType},
// { nameof(RB_Goods.ProxyRises),demodel.ProxyRises},
// { nameof(RB_Goods.ProxyMoney),demodel.ProxyMoney},
// { nameof(RB_Goods.Commission),demodel.Commission},
// { nameof(RB_Goods.PresentFXGrade),demodel.PresentFXGrade},
// { nameof(RB_Goods.PresentFXMonth),demodel.PresentFXMonth},
// { nameof(RB_Goods.Advertising),demodel.Advertising},
// { nameof(RB_Goods.SubName),demodel.SubName},
// { nameof(RB_Goods.MarketingLogo),demodel.MarketingLogo},
// { nameof(RB_Goods.IsLiveGoods),demodel.IsLiveGoods},
// { nameof(RB_Goods.ShelvesDate),demodel.ShelvesDate },
// { nameof(RB_Goods.DownDate),demodel.DownDate },
// { nameof(RB_Goods.SendArea),demodel.SendArea },
// { nameof(RB_Goods.VideoType),demodel.VideoType },
// { nameof(RB_Goods.IntegralComment),demodel.IntegralComment },
// { nameof(RB_Goods.IntegralCommentType),demodel.IntegralCommentType },
// { nameof(RB_Goods.Remark),demodel.Remark },
// { nameof(RB_Goods.GoodsPageType),demodel.GoodsPageType },
// { nameof(RB_Goods.IsNoTax),demodel.IsNoTax },
// { nameof(RB_Goods.MinProfitRate),demodel.MinProfitRate },
// { nameof(RB_Goods.GoodsCountry),demodel.GoodsCountry },
// { nameof(RB_Goods.FatCode),demodel.FatCode },
// { nameof(RB_Goods.GoodsUrl),demodel.GoodsUrl },
// { nameof(RB_Goods.goodsLogo),demodel.goodsLogo },
// };
// 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 = mallGoodsRepository.Update(keyValues, wheres);
// if (flag)
// {
// #region 删除规格
// var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
// 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 });
// if (slist != null && slist.Any())
// {
// //删除后新增
// goods_SpecificationRepository.DeleteBatch(slist);
// }
// if (svlist != null && svlist.Any())
// {
// goods_SpecificationValueRepository.DeleteBatch(svlist);
// }
// if (splist != null && splist.Any())
// {
// goods_SpecificationPriceRepository.DeleteBatch(splist);
// }
// #endregion
}
}
else
{ //修改
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.EnjoyMember),demodel.EnjoyMember},
{ nameof(RB_Goods.SeparateSetMember),demodel.SeparateSetMember},
{ nameof(RB_Goods.IsQuickBuy),demodel.IsQuickBuy},
{ nameof(RB_Goods.SupplierId),demodel.SupplierId},
{ nameof(RB_Goods.IsProxy),demodel.IsProxy},
{ nameof(RB_Goods.ProxyType),demodel.ProxyType},
{ nameof(RB_Goods.ProxyRises),demodel.ProxyRises},
{ nameof(RB_Goods.ProxyMoney),demodel.ProxyMoney},
{ nameof(RB_Goods.Commission),demodel.Commission},
{ nameof(RB_Goods.PresentFXGrade),demodel.PresentFXGrade},
{ nameof(RB_Goods.PresentFXMonth),demodel.PresentFXMonth},
{ nameof(RB_Goods.Advertising),demodel.Advertising},
{ nameof(RB_Goods.SubName),demodel.SubName},
{ nameof(RB_Goods.MarketingLogo),demodel.MarketingLogo},
{ nameof(RB_Goods.IsLiveGoods),demodel.IsLiveGoods},
{ nameof(RB_Goods.ShelvesDate),demodel.ShelvesDate },
{ nameof(RB_Goods.DownDate),demodel.DownDate },
{ nameof(RB_Goods.SendArea),demodel.SendArea },
{ nameof(RB_Goods.VideoType),demodel.VideoType },
{ nameof(RB_Goods.IntegralComment),demodel.IntegralComment },
{ nameof(RB_Goods.IntegralCommentType),demodel.IntegralCommentType },
{ nameof(RB_Goods.Remark),demodel.Remark },
{ nameof(RB_Goods.GoodsPageType),demodel.GoodsPageType },
{ nameof(RB_Goods.IsNoTax),demodel.IsNoTax },
{ nameof(RB_Goods.MinProfitRate),demodel.MinProfitRate },
{ nameof(RB_Goods.GoodsCountry),demodel.GoodsCountry },
{ nameof(RB_Goods.FatCode),demodel.FatCode },
{ nameof(RB_Goods.GoodsUrl),demodel.GoodsUrl },
{ nameof(RB_Goods.goodsLogo),demodel.goodsLogo },
};
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 = mallGoodsRepository.Update(keyValues, wheres);
if (flag)
{
#region 删除规格
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
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 });
if (slist != null && slist.Any())
{
//删除后新增
goods_SpecificationRepository.DeleteBatch(slist);
}
if (svlist != null && svlist.Any())
{
goods_SpecificationValueRepository.DeleteBatch(svlist);
}
if (splist != null && splist.Any())
{
goods_SpecificationPriceRepository.DeleteBatch(splist);
}
#endregion
// #region 修改分类
// var clist = MallGoodsCategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
// var insertList = model.CategoryList.Where(x => !clist.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
// var deleteList = clist.Where(x => !model.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
// foreach (var item in insertList)
// {
// MallGoodsCategoryRepository.Insert(new RB_Goods_Category()
// {
// CategoryId = item.CategoryId,
// CreateDate = demodel.CreateDate,
// GoodsId = demodel.Id,
// Id = 0,
// MallBaseId = demodel.MallBaseId,
// Status = 0,
// TenantId = demodel.TenantId
// });
// }
// foreach (var item in deleteList)
// {
// MallGoodsCategoryRepository.Delete(item.Id);
// }
// #endregion
// }
// goodsId = demodel.Id;
// }
// //插入规格
// 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 = goodsId,
// Id = 0,
// MallBaseId = demodel.MallBaseId,
// Name = item.Name,
// Sort = item.Sort,
// Status = 0,
// TenantId = demodel.TenantId
// });
// if (sid > 0)
// {
// foreach (var qitem in item.SpecificationValueList)
// {
// goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
// {
// CreateDate = demodel.CreateDate,
// GoodsId = goodsId,
// Id = 0,
// Image = qitem.Image,
// MallBaseId = demodel.MallBaseId,
// Name = qitem.Name,
// Sort = qitem.Sort,
// Status = 0,
// TenantId = demodel.TenantId,
// SpecificationId = sid,
// ClassId = qitem.ClassId
// });
// }
// }
// }
// foreach (var item in demodel.SpecificationPriceList)
// {
// goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
// {
// CreateDate = demodel.CreateDate,
// GoodsId = goodsId,
// 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,
// Commission = item.Commission,
// CostMoney = item.CostMoney
// });
// }
// }
#region 修改分类
var clist = MallGoodsCategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var insertList = model.CategoryList.Where(x => !clist.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
var deleteList = clist.Where(x => !model.CategoryList.Select(y => y.CategoryId).Contains(x.CategoryId)).ToList();
foreach (var item in insertList)
{
MallGoodsCategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item.CategoryId,
CreateDate = demodel.CreateDate,
GoodsId = demodel.Id,
Id = 0,
MallBaseId = demodel.MallBaseId,
Status = 0,
TenantId = demodel.TenantId
});
}
foreach (var item in deleteList)
{
MallGoodsCategoryRepository.Delete(item.Id);
}
#endregion
}
goodsId = demodel.Id;
}
//插入规格
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 = goodsId,
Id = 0,
MallBaseId = demodel.MallBaseId,
Name = item.Name,
Sort = item.Sort,
Status = 0,
TenantId = demodel.TenantId
});
if (sid > 0)
{
foreach (var qitem in item.SpecificationValueList)
{
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
{
CreateDate = demodel.CreateDate,
GoodsId = goodsId,
Id = 0,
Image = qitem.Image,
MallBaseId = demodel.MallBaseId,
Name = qitem.Name,
Sort = qitem.Sort,
Status = 0,
TenantId = demodel.TenantId,
SpecificationId = sid,
ClassId = qitem.ClassId
});
}
}
}
foreach (var item in demodel.SpecificationPriceList)
{
goods_SpecificationPriceRepository.Insert(new RB_Goods_SpecificationPrice()
{
CreateDate = demodel.CreateDate,
GoodsId = goodsId,
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,
Commission = item.Commission,
CostMoney = item.CostMoney
});
}
}
// #region 商品优惠价格
// var oldList = MallGoodsPreferentialRepository.GetGoodsPreferentialListRepostory(new RB_Goods_Preferential_Extend() { GoodsId = goodsId });
// List<RB_Goods_Preferential_Extend> goodsPreferentialLsit = new List<RB_Goods_Preferential_Extend>();
// if (model.PreferentialList!=null&& model.PreferentialList.Any())
// {
// foreach (var item in model.PreferentialList)
// {
// RB_Goods_Preferential_Extend goodsPreferential = new RB_Goods_Preferential_Extend()
// {
// Id = 0,
// GoodsId = goodsId,
// PreferentialTerms = item.PreferentialTerms,
// SaleCommissionType = item.SaleCommissionType,
// SaleCommissionMoney = item.SaleCommissionMoney,
// B2BCommissionType = item.B2BCommissionType,
// B2BCommissionMoney = item.B2BCommissionMoney,
// PriceDiscountType = item.PriceDiscountType,
// BuyNum = item.BuyNum,
// SendNum = item.SendNum,
// PriceType = item.PriceType,
// PriceMoney = item.PriceMoney,
// TenantId = Convert.ToInt32(Config.JHTenantId),
// MallBaseId = Convert.ToInt32(Config.JHMallBaseId),
// Status = 0,
// EduCommissionType = item.EduCommissionType,
// EduCommissionMoney = item.EduCommissionMoney
// };
// goodsPreferentialLsit.Add(goodsPreferential);
// }
// }
#region 商品优惠价格
var oldList = MallGoodsPreferentialRepository.GetGoodsPreferentialListRepostory(new RB_Goods_Preferential_Extend() { GoodsId = goodsId });
List<RB_Goods_Preferential_Extend> goodsPreferentialLsit = new List<RB_Goods_Preferential_Extend>();
if (model.PreferentialList != null && model.PreferentialList.Any())
{
foreach (var item in model.PreferentialList)
{
RB_Goods_Preferential_Extend goodsPreferential = new RB_Goods_Preferential_Extend()
{
Id = 0,
GoodsId = goodsId,
PreferentialTerms = item.PreferentialTerms,
SaleCommissionType = item.SaleCommissionType,
SaleCommissionMoney = item.SaleCommissionMoney,
B2BCommissionType = item.B2BCommissionType,
B2BCommissionMoney = item.B2BCommissionMoney,
PriceDiscountType = item.PriceDiscountType,
BuyNum = item.BuyNum,
SendNum = item.SendNum,
PriceType = item.PriceType,
PriceMoney = item.PriceMoney,
TenantId = Convert.ToInt32(Config.JHTenantId),
MallBaseId = Convert.ToInt32(Config.JHMallBaseId),
Status = 0,
EduCommissionType = item.EduCommissionType,
EduCommissionMoney = item.EduCommissionMoney
};
goodsPreferentialLsit.Add(goodsPreferential);
}
}
// if (oldList == null || !oldList.Any())
// {
// foreach (var item in goodsPreferentialLsit)
// {
// MallGoodsPreferentialRepository.Insert(item);
// }
// }
// //原来有优惠数据
// else
// {
// if (model.PreferentialList == null || (model.PreferentialList != null && model.PreferentialList.Count == 0))
// {
// MallGoodsPreferentialRepository.DeleteGoodsPreferentialRepostory(goodsId);
// }
// else
// {
// //找出差异的数据
// var deleteList = oldList.Where(qitem => !goodsPreferentialLsit.Any(oldItem => qitem.PriceDiscountType == oldItem.PriceDiscountType)).ToList();
// foreach (var dItem in deleteList)
// {
// if (dItem.Id > 0)
// {
// MallGoodsPreferentialRepository.Delete(dItem.Id);
// }
// }
// foreach (var priceItem in goodsPreferentialLsit)
// {
// var nowItem = oldList.Where(x => x.PriceDiscountType == priceItem.PriceDiscountType).FirstOrDefault();
// if (nowItem != null && nowItem.Id > 0)
// {
// priceItem.Id = nowItem.Id;
// }
// if (priceItem.Id == 0)
// {
// MallGoodsPreferentialRepository.Insert(priceItem);
// }
// else
// {
// MallGoodsPreferentialRepository.Update(priceItem);
// }
// }
// }
// }
// #endregion
if (oldList == null || !oldList.Any())
{
foreach (var item in goodsPreferentialLsit)
{
MallGoodsPreferentialRepository.Insert(item);
}
}
//原来有优惠数据
else
{
if (model.PreferentialList == null || (model.PreferentialList != null && model.PreferentialList.Count == 0))
{
MallGoodsPreferentialRepository.DeleteGoodsPreferentialRepostory(goodsId);
}
else
{
//找出差异的数据
var deleteList = oldList.Where(qitem => !goodsPreferentialLsit.Any(oldItem => qitem.PriceDiscountType == oldItem.PriceDiscountType)).ToList();
foreach (var dItem in deleteList)
{
if (dItem.Id > 0)
{
MallGoodsPreferentialRepository.Delete(dItem.Id);
}
}
foreach (var priceItem in goodsPreferentialLsit)
{
var nowItem = oldList.Where(x => x.PriceDiscountType == priceItem.PriceDiscountType).FirstOrDefault();
if (nowItem != null && nowItem.Id > 0)
{
priceItem.Id = nowItem.Id;
}
if (priceItem.Id == 0)
{
MallGoodsPreferentialRepository.Insert(priceItem);
}
else
{
MallGoodsPreferentialRepository.Update(priceItem);
}
}
}
}
#endregion
// return goodsId;
//}
return goodsId;
}
///// <summary>
///// 更新商品的售价-卖价;原价-基础收费以及优惠政策
///// </summary>
///// <param name="courseModel"></param>
///// <param name="list"></param>
///// <returns></returns>
//public bool UpdateMallGoodsPrice(RB_Course_ViewModel courseModel, List<RB_Course_Preferential_Extend> list)
//{
// bool flag = false;
/// <summary>
/// 更新商品的售价-卖价;原价-基础收费以及优惠政策
/// </summary>
/// <param name="courseModel"></param>
/// <param name="list"></param>
/// <returns></returns>
public bool UpdateMallGoodsPrice(RB_Course_ViewModel courseModel, List<RB_Course_Preferential_Extend> list)
{
bool flag = false;
// Dictionary<string, object> fileds = new Dictionary<string, object>()
// {
// {nameof(RB_Goods.SellingPrice),courseModel.SellPrice },
// {nameof(RB_Goods.OriginalPrice),courseModel.OriginalPrice },
// };
// flag = mallGoodsRepository.Update(fileds, new WhereHelper(nameof(RB_Goods.Id), courseModel.MallGoodsId));
// var oldList = MallGoodsPreferentialRepository.GetGoodsPreferentialListRepostory(new RB_Goods_Preferential_Extend() { GoodsId = courseModel.MallGoodsId });
// List<RB_Goods_Preferential_Extend> goodsPreferentialLsit = new List<RB_Goods_Preferential_Extend>();
// foreach (var item in list)
// {
// RB_Goods_Preferential_Extend goodsPreferential = new RB_Goods_Preferential_Extend()
// {
// Id = 0,
// GoodsId = courseModel.MallGoodsId,
// PreferentialTerms = item.PreferentialTerms,
// SaleCommissionType = item.SaleCommissionType,
// SaleCommissionMoney = item.SaleCommissionMoney,
// B2BCommissionType = item.B2BCommissionType,
// B2BCommissionMoney = item.B2BCommissionMoney,
// PriceDiscountType = item.PriceDiscountType,
// BuyNum = item.BuyNum,
// SendNum = item.SendNum,
// PriceType = item.PriceType,
// PriceMoney = item.PriceMoney,
// TenantId = Convert.ToInt32(Config.JHTenantId),
// MallBaseId = Convert.ToInt32(Config.JHMallBaseId),
// Status = 0,
// EduCommissionType = item.EduCommissionType,
// EduCommissionMoney = item.EduCommissionMoney
// };
// goodsPreferentialLsit.Add(goodsPreferential);
// }
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Goods.SellingPrice),courseModel.SellPrice },
{nameof(RB_Goods.OriginalPrice),courseModel.OriginalPrice },
};
flag = mallGoodsRepository.Update(fileds, new WhereHelper(nameof(RB_Goods.Id), courseModel.MallGoodsId));
var oldList = MallGoodsPreferentialRepository.GetGoodsPreferentialListRepostory(new RB_Goods_Preferential_Extend() { GoodsId = courseModel.MallGoodsId });
// if (oldList == null || !oldList.Any())
// {
// foreach (var item in goodsPreferentialLsit)
// {
List<RB_Goods_Preferential_Extend> goodsPreferentialLsit = new List<RB_Goods_Preferential_Extend>();
foreach (var item in list)
{
RB_Goods_Preferential_Extend goodsPreferential = new RB_Goods_Preferential_Extend()
{
Id = 0,
GoodsId = courseModel.MallGoodsId,
PreferentialTerms = item.PreferentialTerms,
SaleCommissionType = item.SaleCommissionType,
SaleCommissionMoney = item.SaleCommissionMoney,
B2BCommissionType = item.B2BCommissionType,
B2BCommissionMoney = item.B2BCommissionMoney,
PriceDiscountType = item.PriceDiscountType,
BuyNum = item.BuyNum,
SendNum = item.SendNum,
PriceType = item.PriceType,
PriceMoney = item.PriceMoney,
TenantId = Convert.ToInt32(Config.JHTenantId),
MallBaseId = Convert.ToInt32(Config.JHMallBaseId),
Status = 0,
EduCommissionType = item.EduCommissionType,
EduCommissionMoney = item.EduCommissionMoney
};
goodsPreferentialLsit.Add(goodsPreferential);
}
// flag = MallGoodsPreferentialRepository.Insert(item) > 0;
// }
// }
// //原来有优惠数据
// else
// {
// if (list == null || (list != null && list.Count == 0))
// {
// flag = MallGoodsPreferentialRepository.DeleteGoodsPreferentialRepostory(courseModel.MallGoodsId);
// }
// else
// {
// //找出差异的数据
// var deleteList = oldList.Where(qitem => !goodsPreferentialLsit.Any(oldItem => qitem.PriceDiscountType == oldItem.PriceDiscountType)).ToList();
// foreach (var dItem in deleteList)
// {
// if (dItem.Id > 0)
// {
// flag = MallGoodsPreferentialRepository.Delete(dItem.Id) > 0;
// }
// }
// foreach (var priceItem in goodsPreferentialLsit)
// {
// var nowItem = oldList.Where(x => x.PriceDiscountType == priceItem.PriceDiscountType).FirstOrDefault();
// if (nowItem != null && nowItem.Id > 0)
// {
// priceItem.Id = nowItem.Id;
// }
// if (priceItem.Id == 0)
// {
// flag = MallGoodsPreferentialRepository.Insert(priceItem) > 0;
// }
// else
// {
// flag = MallGoodsPreferentialRepository.Update(priceItem);
// }
// }
// }
// }
if (oldList == null || !oldList.Any())
{
foreach (var item in goodsPreferentialLsit)
{
// return flag;
//}
flag = MallGoodsPreferentialRepository.Insert(item) > 0;
}
}
//原来有优惠数据
else
{
if (list == null || (list != null && list.Count == 0))
{
flag = MallGoodsPreferentialRepository.DeleteGoodsPreferentialRepostory(courseModel.MallGoodsId);
}
else
{
//找出差异的数据
var deleteList = oldList.Where(qitem => !goodsPreferentialLsit.Any(oldItem => qitem.PriceDiscountType == oldItem.PriceDiscountType)).ToList();
foreach (var dItem in deleteList)
{
if (dItem.Id > 0)
{
flag = MallGoodsPreferentialRepository.Delete(dItem.Id) > 0;
}
}
foreach (var priceItem in goodsPreferentialLsit)
{
var nowItem = oldList.Where(x => x.PriceDiscountType == priceItem.PriceDiscountType).FirstOrDefault();
if (nowItem != null && nowItem.Id > 0)
{
priceItem.Id = nowItem.Id;
}
if (priceItem.Id == 0)
{
flag = MallGoodsPreferentialRepository.Insert(priceItem) > 0;
}
else
{
flag = MallGoodsPreferentialRepository.Update(priceItem);
}
}
}
}
return flag;
}
#endregion
}
......
......@@ -14,6 +14,7 @@ using Edu.Model.ViewModel.Contract;
using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.Grade;
using Edu.Model.ViewModel.Log;
using Edu.Model.ViewModel.Mall;
using Edu.Model.ViewModel.Reserve;
using Edu.Model.ViewModel.Sell;
using Edu.Model.ViewModel.StudyAbroad;
......@@ -24,6 +25,7 @@ using Edu.Repository.Log;
using Edu.Repository.Reserve;
using Edu.Repository.StudyAbroad;
using Edu.Repository.User;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -202,7 +204,10 @@ namespace Edu.Module.Course
/// 商品规格价格
/// </summary>
private readonly Repository.Mall.RB_Goods_SpecificationPriceRepository goods_SpecificationPriceRepository = new Repository.Mall.RB_Goods_SpecificationPriceRepository();
/// <summary>
/// 财务配置
/// </summary>
private readonly RB_Finance_ConfigRepository finance_ConfigRepository = new RB_Finance_ConfigRepository();
#region 日语培训
......@@ -834,7 +839,7 @@ namespace Edu.Module.Course
#region 更新甲鹤小程序规格对应的库存
if (flag && demodel.JoinType != OrderJoinTypeEnum.RenewOrder)//续费订单不去更新规格库存
{
// System.Threading.Tasks.Task.Run(() => UpdateClassInventoryNum(demodel));
System.Threading.Tasks.Task.Run(() => UpdateClassInventoryNum(demodel));
}
#endregion
}
......@@ -1257,7 +1262,7 @@ namespace Edu.Module.Course
#region 更新甲鹤小程序规格对应的库存
if (flag && orderModel.JoinType != OrderJoinTypeEnum.RenewOrder)//续费订单不去更新规格库存
{
// System.Threading.Tasks.Task.Run(() => UpdateCancelClassOrder(orderModel));
System.Threading.Tasks.Task.Run(() => UpdateCancelClassOrder(orderModel));
}
#endregion
}
......@@ -2842,79 +2847,457 @@ namespace Edu.Module.Course
#region 更新甲鹤小程序对应的班级招生人数
///// <summary>
///// 下单更新甲鹤小程序规格对应的班级人数
///// </summary>
///// <param name="demodel"></param>
///// <returns></returns>
//public bool UpdateClassInventoryNum(RB_Order_ViewModel demodel)
//{
// bool flag = false;
// var courseModel = courseRepository.GetEntity(demodel.CourseId).RefMapperTo<RB_Course_ViewModel>();
// if (courseModel != null && courseModel.MallGoodsId > 0)
// {
// var svlist = goods_SpecificationValueRepository.GetList(new Edu.Model.ViewModel.Mall.RB_Goods_SpecificationValue_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
// var splist = goods_SpecificationPriceRepository.GetList(new Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
// if (svlist != null && svlist.Any(x => x.ClassId == demodel.ClassId))
// {
// var svModel = svlist.Where(x => x.ClassId == demodel.ClassId).FirstOrDefault();
// if (svModel != null && svModel.Id > 0)
// {
// var spModel = splist.Where(x => x.SpecificationSort == svModel.Sort.ToString()).FirstOrDefault();
// Dictionary<string, object> keyValues = new Dictionary<string, object>() {
// { nameof(Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend.InventoryNum),spModel.InventoryNum - demodel.GuestNum}
// };
// List<WhereHelper> wheres = new List<WhereHelper>()
// {
// new WhereHelper(){
// FiledName=nameof(Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend.Id),
// FiledValue=spModel.Id,
// OperatorEnum=OperatorEnum.Equal
// }
// };
// flag = goods_SpecificationPriceRepository.Update(keyValues, wheres);
// }
// }
// }
// return flag;
//}
/// <summary>
/// 下单更新甲鹤小程序规格对应的班级人数
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool UpdateClassInventoryNum(RB_Order_ViewModel demodel)
{
bool flag = false;
var courseModel = courseRepository.GetEntity(demodel.CourseId).RefMapperTo<RB_Course_ViewModel>();
if (courseModel != null && courseModel.MallGoodsId > 0)
{
var svlist = goods_SpecificationValueRepository.GetList(new Edu.Model.ViewModel.Mall.RB_Goods_SpecificationValue_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
var splist = goods_SpecificationPriceRepository.GetList(new Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
if (svlist != null && svlist.Any(x => x.ClassId == demodel.ClassId))
{
var svModel = svlist.Where(x => x.ClassId == demodel.ClassId).FirstOrDefault();
if (svModel != null && svModel.Id > 0)
{
var spModel = splist.Where(x => x.SpecificationSort == svModel.Sort.ToString()).FirstOrDefault();
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend.InventoryNum),spModel.InventoryNum - demodel.GuestNum}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper(){
FiledName=nameof(Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend.Id),
FiledValue=spModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
flag = goods_SpecificationPriceRepository.Update(keyValues, wheres);
}
}
}
return flag;
}
///// <summary>
///// 取消更新甲鹤小程序规格对应的班级人数
///// </summary>
///// <param name="demodel"></param>
///// <returns></returns>
//public bool UpdateCancelClassOrder(RB_Order demodel)
/// <summary>
/// 取消更新甲鹤小程序规格对应的班级人数
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool UpdateCancelClassOrder(RB_Order demodel)
{
bool flag = false;
var courseModel = courseRepository.GetEntity(demodel.CourseId).RefMapperTo<RB_Course_ViewModel>();
if (courseModel != null && courseModel.MallGoodsId > 0)
{
var svlist = goods_SpecificationValueRepository.GetList(new Edu.Model.ViewModel.Mall.RB_Goods_SpecificationValue_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
var splist = goods_SpecificationPriceRepository.GetList(new Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
if (svlist != null && svlist.Any(x => x.ClassId == demodel.ClassId))
{
var svModel = svlist.Where(x => x.ClassId == demodel.ClassId).FirstOrDefault();
if (svModel != null && svModel.Id > 0)
{
var spModel = splist.Where(x => x.SpecificationSort == svModel.Sort.ToString()).FirstOrDefault();
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend.InventoryNum),spModel.InventoryNum + demodel.GuestNum}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper(){
FiledName=nameof(Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend.Id),
FiledValue=spModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
flag = goods_SpecificationPriceRepository.Update(keyValues, wheres);
}
}
}
return flag;
}
/// <summary>
/// 日语培训下单
/// </summary>
/// <param name="demodel"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public virtual bool SetBatchClassOrder(List<RB_Order_ViewModel> list, UserInfo userInfo, bool isEditOrder)
{
bool flag = false;
foreach (var demodel in list)
{
//查询班级信息
var classModel = classRepository.GetEntity(demodel.ClassId);
if (classModel == null)
{
flag = false;
return flag;
}
if (demodel.JoinType == OrderJoinTypeEnum.Normal || demodel.JoinType == OrderJoinTypeEnum.RenewOrder)
{
demodel.CourseId = classModel.CouseId;
}
//课程信息
var courseModel = courseRepository.GetEntity(demodel.CourseId);
#region 计算订单优惠信息
//获取课程优惠
var coursePreferentialList = course_PreferentialRepository.GetCoursePreferentialListRepostory(new RB_Course_Preferential_Extend()
{
CourseId = demodel.CourseId
});
//课程优惠信息
decimal disMoney = 0;//课程最大优惠金额
decimal coursePrice = courseModel.SellPrice;//课程最低单价
var coursePreferentialModel = new RB_Course_Preferential_Extend();
if (coursePreferentialList != null && coursePreferentialList.Count > 0)
{
if (demodel.GuestNum == 1)
{
coursePreferentialModel = coursePreferentialList?.Where(qitem => qitem.PriceDiscountType == CoursePriceDiscountEnum.SingleJoin)?.FirstOrDefault();
}
if (demodel.GuestNum >= 2)
{
coursePreferentialModel = coursePreferentialList?.Where(qitem => qitem.PriceDiscountType == CoursePriceDiscountEnum.DoubleJoin)?.FirstOrDefault();
}
var saleCommissionType = coursePreferentialModel?.SaleCommissionType ?? 0;
if (saleCommissionType == 0)
{
var tempMoney = (courseModel?.SellPrice ?? 0) * (coursePreferentialModel?.SaleCommissionMoney ?? 0);
disMoney = tempMoney / Convert.ToDecimal(100);
}
else
{
disMoney = coursePreferentialModel?.SaleCommissionMoney ?? 0;
}
var b2bCommissionType = coursePreferentialModel?.B2BCommissionType ?? 0;
if (b2bCommissionType == 0)
{
var tempMoney = (courseModel?.SellPrice ?? 0) * (coursePreferentialModel?.B2BCommissionMoney ?? 0);
disMoney += tempMoney / Convert.ToDecimal(100);
}
else
{
disMoney = coursePreferentialModel?.B2BCommissionMoney ?? 0;
}
var priceCommissionType = coursePreferentialModel?.PriceType ?? 0;
if (priceCommissionType == 0)
{
coursePrice = coursePrice * (100 - (coursePreferentialModel?.PriceMoney ?? 0)) / 100;
}
else
{
coursePrice -= (coursePreferentialModel?.PriceMoney ?? 0);
}
#region 记录提成信息
if (coursePreferentialModel == null)
{
coursePreferentialModel = coursePreferentialList.FirstOrDefault();
}
demodel.CommissionType = coursePreferentialModel?.SaleCommissionType ?? 0;
demodel.CommissionRate = coursePreferentialModel?.SaleCommissionMoney ?? 0;
demodel.CommissionTypeTH = coursePreferentialModel?.B2BCommissionType ?? 0;
demodel.CommissionRateTH = coursePreferentialModel?.B2BCommissionMoney ?? 0;
if (coursePreferentialModel != null)
{
demodel.CommissionRemark = "使用优惠Id:" + coursePreferentialModel.Id + " 返佣类型:" + demodel.CommissionType + " 返佣比例/金额:" + demodel.CommissionRate + " 同行返佣类型:" + demodel.CommissionTypeTH + " 同行返佣比例/金额:" + demodel.CommissionRateTH;
}
#endregion
}
if (demodel.IsLessPrice == 1 && demodel.LessPrice > 0)
{
if (coursePreferentialList != null && coursePreferentialList.Count > 0)
{
if (demodel.LessPrice > disMoney)
{
return flag;
}
}
//else
//{
// bool flag = false;
// var courseModel = courseRepository.GetEntity(demodel.CourseId).RefMapperTo<RB_Course_ViewModel>();
// if (courseModel != null && courseModel.MallGoodsId > 0)
// {
// var svlist = goods_SpecificationValueRepository.GetList(new Edu.Model.ViewModel.Mall.RB_Goods_SpecificationValue_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
// var splist = goods_SpecificationPriceRepository.GetList(new Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend() { GoodsId = courseModel.MallGoodsId, TenantId = Convert.ToInt32(Config.JHTenantId), MallBaseId = Convert.ToInt32(Config.JHMallBaseId) });
// if (svlist != null && svlist.Any(x => x.ClassId == demodel.ClassId))
// {
// var svModel = svlist.Where(x => x.ClassId == demodel.ClassId).FirstOrDefault();
// if (svModel != null && svModel.Id > 0)
// {
// var spModel = splist.Where(x => x.SpecificationSort == svModel.Sort.ToString()).FirstOrDefault();
// Dictionary<string, object> keyValues = new Dictionary<string, object>() {
// { nameof(Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend.InventoryNum),spModel.InventoryNum + demodel.GuestNum}
// };
// List<WhereHelper> wheres = new List<WhereHelper>()
// {
// new WhereHelper(){
// FiledName=nameof(Edu.Model.ViewModel.Mall.RB_Goods_SpecificationPrice_Extend.Id),
// FiledValue=spModel.Id,
// OperatorEnum=OperatorEnum.Equal
// }
// };
// flag = goods_SpecificationPriceRepository.Update(keyValues, wheres);
// }
// }
// }
// message = "此课程未配置【销售提成】信息,请通知OP在课程里面添加优惠信息!";
// return flag;
//}
}
#endregion
if (demodel.OrderSource == OrderSourceEnum.EduClient || demodel.OrderSource == OrderSourceEnum.Client)
{
if (demodel.OrderSource == OrderSourceEnum.EduClient)
{
demodel.GeneralOccupation = "";
}
else if (demodel.OrderSource == OrderSourceEnum.Client)
{
demodel.EduOccupation = "";
}
}
else
{
demodel.EduOccupation = "";
demodel.GeneralOccupation = "";
}
if (demodel.IsLessPrice == 0)
{
demodel.LessPrice = 0;
}
var orderModel = new RB_Order();
if (demodel.OrderId > 0)
{
orderModel = orderRepository.GetEntity(demodel.OrderId);
}
if (demodel.OrderId > 0)
{
int BNum = orderRepository.GetClassOrderPeopleNumRepository(demodel.ClassId.ToString()).FirstOrDefault()?.GuestNum ?? 0;
if (BNum + demodel.GuestNum - orderModel.GuestNum > classModel.ClassPersion)
{
flag = false;
// message = "人数报超" + (classModel.ClassPersion - (BNum + demodel.GuestNum - orderModel.GuestNum));
return flag;
}
}
else
{
int BNum = orderRepository.GetClassOrderPeopleNumRepository(demodel.ClassId.ToString()).FirstOrDefault()?.GuestNum ?? 0;
if (BNum + demodel.GuestNum > classModel.ClassPersion)
{
flag = false;
// message = "人数报超" + (classModel.ClassPersion - (BNum + demodel.GuestNum));
return flag;
}
}
//没有总经理修改订单权限
if (!isEditOrder)
{
if (demodel.Unit_Price < coursePrice)
{
flag = false;
// message = "成交单价不能小于最低价格";
return flag;
}
if (demodel.JoinType == OrderJoinTypeEnum.InsertClass)
{
var newPreferPrice = Math.Round(coursePrice / courseModel.ClassHours * (courseModel.ClassHours - demodel.StartClassHours) * demodel.GuestNum, 2);
if (demodel.PreferPrice != (newPreferPrice - demodel.LessPrice))
{
flag = false;
// message = "应收总额不正确";
return flag;
}
}
else if (demodel.JoinType == OrderJoinTypeEnum.TransOrder || demodel.JoinType == OrderJoinTypeEnum.SplitOrder)
{
//不验证应收
}
else
{
if (demodel.PreferPrice != (demodel.Unit_Price * demodel.GuestNum - demodel.LessPrice))
{
flag = false;
// message = "应收总额不正确";
return flag;
}
}
}
//日志信息
string LogContent = "";
//销售备注
string SaleRemark = "";
if (demodel.JoinType == OrderJoinTypeEnum.InsertClass)
{
if (Convert.ToDateTime(Common.ConvertHelper.FormatTime(demodel.EffectTime)) < Convert.ToDateTime(Common.ConvertHelper.FormatTime(DateTime.Now)))
{
demodel.EffectStatus = 1;
}
else
{
demodel.EffectStatus = 0;
}
}
else
{
demodel.EffectStatus = 1;
demodel.EffectTime = DateTime.Now;
}
if (classModel.ClassStatus == Common.Enum.Course.ClassStatusEnum.EndClass)
{
flag = false;
// message = "班级状态不正确";
return flag;
}
demodel.Class_Price = courseModel.SellPrice;
int OrderId = orderRepository.Insert(demodel);
demodel.OrderId = OrderId;
flag = OrderId > 0;
LogContent = "新增日语培训订单";
//记录订单备注
if (!string.IsNullOrEmpty(demodel.SaleRemark))
{
SaleRemark = demodel.SaleRemark;
}
#region 更新甲鹤小程序规格对应的库存
if (flag && demodel.JoinType != OrderJoinTypeEnum.RenewOrder)//续费订单不去更新规格库存
{
System.Threading.Tasks.Task.Run(() => UpdateClassInventoryNum(demodel));
}
#endregion
#region 写日志
if (flag)
{
var financeConfig = finance_ConfigRepository.GetList(new Edu.Model.ViewModel.Finance.RB_Finance_Config_ViewModel { Group_Id = demodel.Group_Id, Type = Common.Enum.Course.FinanceConfigTypeEnum.Tuition }).FirstOrDefault();
if (financeConfig == null)
{
financeConfig = new Edu.Model.ViewModel.Finance.RB_Finance_Config_ViewModel();
}
// var OriginalFee = Math.Round((Convert.ToDecimal(Config.SettlementRate) / 100) * (Convert.ToDecimal(payModel.amount.payer_total) / 100), 2, MidpointRounding.AwayFromZero);//手续费
#region 财务单据数据组装
var detailList = new List<object>
{
new
{
CostTypeId = financeConfig?.CostTypeId ?? 533,
Number = demodel.GuestNum,
OriginalMoney = Convert.ToDecimal(demodel.Income) ,
UnitPrice = Convert.ToDecimal(demodel.Income/demodel.GuestNum) ,
Remark = "甲鹤小程序用户下单自动生成财务单据"
}
};
var financeObj = new
{
IsPublic = 1,
BType = 1,//item.AccountType,
AccountId = financeConfig?.ClientID ?? 54,
WBMoney = Convert.ToDecimal(demodel.Income) ,
TradeDate = System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
AccountNumber = System.DateTime.Now.AddDays(-1).ToString("yyyyMMdd"),
TemplateId = financeConfig?.TempleteId ?? 139,
OrderSource = 17,
Remark = System.DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据",
detailList,
OriginalFee = demodel.PlatformTax,
CreateBy = userInfo.Id,
RemitterName = demodel.GuestName,
RB_Branch_Id = userInfo.School_Id,
RB_Group_Id = userInfo.Group_Id,
RB_Depart_Id = userInfo.DeptId,
RB_CreateByName = userInfo.AccountName,
RB_DepartName = userInfo.DeptName,
RB_BranchName = userInfo.SchoolName,
RB_GroupName = userInfo.GroupName,
FinanceType = 2,
GuestId = 0,
OrderId,
TCIDList = demodel.ClassId > 0 ? new List<int>() { demodel.ClassId } : new List<int>(),
};
#endregion
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
{
msg = sign,
};
string apiResult = Common.Plugin.HttpHelper.HttpPost(Config.ReadConfigKey("IncomeFinanceApi"), JsonHelper.Serialize(resultInfo), "");
JObject parmsJob = JObject.Parse(apiResult);
string resultCode = parmsJob.GetStringValue("resultCode");
int frid = parmsJob.GetInt("data", 0);
if (resultCode == "1" && frid > 0)//新增记录
{
}
//销售备注
if (!string.IsNullOrEmpty(SaleRemark))
{
order_RemarkRepository.Insert(new RB_Order_Remark()
{
Id = 0,
Content = SaleRemark,
CreateBy = demodel.CreateBy,
CreateTime = DateTime.Now,
OrderId = demodel.OrderId,
Type = 1
});
}
//订单日志
if (!string.IsNullOrEmpty(LogContent))
{
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
Type = 2,
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id,
LogContent = LogContent,
School_Id = userInfo.School_Id,
SourceId = demodel.OrderId
});
}
}
#endregion
}
return flag;
}
/// <summary>
/// 更新班级对应的商品库存
/// </summary>
/// <param name="classId"></param>
/// <returns></returns>
public bool UpdateGoodsSpecification(List<int> classId)
{
bool flag = false;
string classIds = string.Join(",", classId.Select(x => x));
var classList = classRepository.GetClassAndCourseListRepository(new RB_Class_ViewModel { Q_ClassIds = classIds });
var goodsSpecificationValueList = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend { ClassIds = classIds });
var goodsSpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
if (goodsSpecificationValueList != null && goodsSpecificationValueList.Any())
{
goodsSpecificationPriceList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend { GoodsId = goodsSpecificationValueList.FirstOrDefault()?.GoodsId });
}
if (classList != null && classList.Any() && goodsSpecificationValueList != null && goodsSpecificationValueList.Any() && goodsSpecificationValueList != null && goodsSpecificationValueList.Any())
{
foreach (var item in classList)//查找班级对应的规格
{
var valueModle = goodsSpecificationValueList.Where(x => x.ClassId == item.ClassId).FirstOrDefault();
if (valueModle != null && valueModle.Id > 0)
{
var priceModel = goodsSpecificationPriceList.Where(x => x.GoodsId == valueModle.GoodsId && x.SpecificationSort == (valueModle.Sort ?? 0).ToString()).FirstOrDefault();
if (priceModel != null && priceModel.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Goods_SpecificationPrice_Extend.InventoryNum),item.ClassPersion-item.OrderStudentCount},
};
flag = classRepository.Update(fileds, new WhereHelper(nameof(RB_Goods_SpecificationPrice_Extend.Id), priceModel.Id));
}
}
}
}
return flag;
}
#endregion
}
}
\ No newline at end of file
......@@ -118,6 +118,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_ViewModel.ClassId), query.ClassId);
}
if (!string.IsNullOrEmpty(query.Q_ClassIds))
{
builder.AppendFormat(" AND A.{0} in ({1}) ", nameof(RB_Class_ViewModel.ClassId), query.Q_ClassIds);
}
if (query.Status >= 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_ViewModel.Status), (int)query.Status);
......
......@@ -50,7 +50,10 @@ namespace Edu.Repository.Mall
{
where += $@" and {nameof(RB_Goods_SpecificationValue.GoodsId)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.ClassIds))
{
where += $@" and {nameof(RB_Goods_SpecificationValue.ClassId)} in({dmodel.ClassIds})";
}
string sql = $@"select * from RB_Goods_SpecificationValue where {where} order by Id asc";
return Get<RB_Goods_SpecificationValue_Extend>(sql).ToList();
}
......
......@@ -283,21 +283,21 @@ namespace Edu.WebApi.Controllers.Course
IsKCourse = base.ParmJObj.GetInt("IsKCourse"),
ClassHours = base.ParmJObj.GetDecimal("ClassHours")
};
//try
//{
// extModel.CategoryList = JsonHelper.DeserializeObject<List<RB_Goods_Category_Extend>>(base.ParmJObj.GetStringValue("CategoryList"));
// if (extModel.SalePlatList != null && extModel.SalePlatList.Any(x => x == 4))//有小程序的上架平台
// {
// if (extModel.CategoryList == null || !extModel.CategoryList.Any())
// {
// return ApiResult.Failed("上架小程序必须选择小程序对应的分类");
// }
// }
//}
//catch (Exception ex)
//{
//}
try
{
extModel.CategoryList = JsonHelper.DeserializeObject<List<RB_Goods_Category_Extend>>(base.ParmJObj.GetStringValue("CategoryList"));
if (extModel.SalePlatList != null && extModel.SalePlatList.Any(x => x == 4))//有小程序的上架平台
{
if (extModel.CategoryList == null || !extModel.CategoryList.Any())
{
return ApiResult.Failed("上架小程序必须选择小程序对应的分类");
}
}
}
catch (Exception ex)
{
}
extModel.CreateTime = DateTime.Now;
extModel.CreateBy = base.UserInfo.Id;
extModel.UpdateBy = base.UserInfo.Id;
......
......@@ -110,7 +110,7 @@ namespace Edu.WebApi.Controllers.Course
x.SchoolName,
UpdateTime = Common.ConvertHelper.FormatTime(x.UpdateTime),
x.OtherCourseList,
IsChaBan= IsInsertClass,
IsChaBan = IsInsertClass,
};
result.Add(obj);
}
......@@ -410,7 +410,8 @@ namespace Edu.WebApi.Controllers.Course
{
return x.CommissionRate + x.CommissionRateTH - x.LessPrice;
}
else {
else
{
return Math.Round((x.PreferPrice - x.DiscountMoney + x.LessPrice) * (x.CommissionRate + x.CommissionRateTH) / 100, 2, MidpointRounding.AwayFromZero) - x.LessPrice;
}
}
......@@ -486,13 +487,13 @@ namespace Edu.WebApi.Controllers.Course
CourseId = base.ParmJObj.GetInt("CourseId"),
StartClassHours = base.ParmJObj.GetInt("StartClassHours"),
EffectTime=base.ParmJObj.GetDateTime("EffectTime"),
UpOrderId=base.ParmJObj.GetInt("UpOrderId"),
VisitorReserveId=base.ParmJObj.GetInt("VisitorReserveId"),
JoinType= OrderJoinTypeEnum.Normal,
TargetJoinType= OrderJoinTypeEnum.Normal,
EffectTime = base.ParmJObj.GetDateTime("EffectTime"),
UpOrderId = base.ParmJObj.GetInt("UpOrderId"),
VisitorReserveId = base.ParmJObj.GetInt("VisitorReserveId"),
JoinType = OrderJoinTypeEnum.Normal,
TargetJoinType = OrderJoinTypeEnum.Normal,
};
var IsInsertClass= base.ParmJObj.GetInt("IsChaBan");
var IsInsertClass = base.ParmJObj.GetInt("IsChaBan");
if (IsInsertClass == 1)
{
demodel.JoinType = OrderJoinTypeEnum.InsertClass;
......@@ -626,7 +627,7 @@ namespace Edu.WebApi.Controllers.Course
model.OrderNature,
OrderNatureName = model.OrderNature.ToName(),
model.OldPreferPrice,
IsChaBan=model.JoinType== OrderJoinTypeEnum.InsertClass?1:0,
IsChaBan = model.JoinType == OrderJoinTypeEnum.InsertClass ? 1 : 0,
model.CourseId,
model.StartClassHours,
EffectTime = Common.ConvertHelper.FormatDate(model.EffectTime),
......@@ -692,7 +693,7 @@ namespace Edu.WebApi.Controllers.Course
model.OrderType,
model.SourceId,
OrderTypeName = Common.Plugin.EnumHelper.ToName(model.OrderType),
OpenTime=Common.ConvertHelper.FormatDate(model.OpenTime),
OpenTime = Common.ConvertHelper.FormatDate(model.OpenTime),
});
}
......@@ -1076,16 +1077,16 @@ namespace Edu.WebApi.Controllers.Course
x.CourseName,
x.StartClassHours,
x.JoinType,
JoinTypeName= x.JoinType.ToName(),
JoinTypeName = x.JoinType.ToName(),
x.TargetJoinType,
TargetJoinTypeName=x.TargetJoinType.ToName(),
TargetJoinTypeName = x.TargetJoinType.ToName(),
x.SourceOrderId,
x.SourceClassName,
x.TargetOrderId,
x.TargetClassName,
x.EffectStatus,
x.EffectStatusStr,
EffectTime=Common.ConvertHelper.FormatDate(x.EffectTime),
EffectTime = Common.ConvertHelper.FormatDate(x.EffectTime),
x.UpOrderId,
x.GuestContractNo,
x.ContractType,
......@@ -1130,8 +1131,8 @@ namespace Edu.WebApi.Controllers.Course
BirthDate = base.ParmJObj.GetDateTime("BirthDate"),
TotalHours = base.ParmJObj.GetInt("TotalHours"),
StuIcon = base.ParmJObj.GetStringValue("StuIcon"),
GuestContractNo=base.ParmJObj.GetStringValue("GuestContractNo"),
ContractType=base.ParmJObj.GetInt("ContractType"),
GuestContractNo = base.ParmJObj.GetStringValue("GuestContractNo"),
ContractType = base.ParmJObj.GetInt("ContractType"),
};
if (dmodel.OrderId <= 0)
{
......@@ -1244,9 +1245,9 @@ namespace Edu.WebApi.Controllers.Course
x.CourseId,
x.CourseName,
x.JoinType,
JoinTypeName=x.JoinType.ToName(),
JoinTypeName = x.JoinType.ToName(),
x.TargetJoinType,
TargetJoinTypeName=x.JoinType.ToName(),
TargetJoinTypeName = x.JoinType.ToName(),
x.SourceOrderId,
x.SourceClassName,
x.TargetOrderId,
......@@ -1296,7 +1297,7 @@ namespace Edu.WebApi.Controllers.Course
x.OldPreferPrice,
x.EffectStatus,
x.EffectStatusStr,
EffectTime=Common.ConvertHelper.FormatDate(x.EffectTime),
EffectTime = Common.ConvertHelper.FormatDate(x.EffectTime),
x.UpOrderId,
OpenTime = Common.ConvertHelper.FormatDate(x.OpenTime),
x.VisitorReserveId,
......@@ -1398,7 +1399,7 @@ namespace Edu.WebApi.Controllers.Course
Q_OrderBy = base.ParmJObj.GetInt("Q_OrderBy"),
PlatformTax = base.ParmJObj.GetDecimal("PlatformTax"),
EnterID = base.ParmJObj.GetInt("EnterID"),
HelpEnterId = base.ParmJObj.GetInt("HelpEnterId",0),
HelpEnterId = base.ParmJObj.GetInt("HelpEnterId", 0),
ClassNo = base.ParmJObj.GetStringValue("ClassNo")
};
demodel.Group_Id = userInfo.Group_Id;
......@@ -1415,7 +1416,7 @@ namespace Edu.WebApi.Controllers.Course
DueInMoney = orderS?.DueInMoney ?? 0,
GuestNum = orderS?.GuestNum ?? 0,
CancelNum = orderS?.CancelNum ?? 0,
CommissionMoney = (orderS?.CommissionMoney ?? 0)>0?(orderS?.CommissionMoney ?? 0):0,
CommissionMoney = (orderS?.CommissionMoney ?? 0) > 0 ? (orderS?.CommissionMoney ?? 0) : 0,
ExtraRewardMoney = orderS?.ExtraRewardMoney ?? 0
},
List = orderList?.Select(x => new
......@@ -1427,11 +1428,11 @@ namespace Edu.WebApi.Controllers.Course
x.SourceId,
x.ClassSchoolId,
x.ClassName,
OpenTime=Common.ConvertHelper.FormatDate(x.OpenTime),
OpenTime = Common.ConvertHelper.FormatDate(x.OpenTime),
x.JoinType,
JoinTypeName=x.JoinType.ToName(),
JoinTypeName = x.JoinType.ToName(),
x.TargetJoinType,
TargetJoinTypeName=x.TargetJoinType.ToName(),
TargetJoinTypeName = x.TargetJoinType.ToName(),
x.SourceOrderId,
x.SourceClassName,
x.TargetOrderId,
......@@ -1489,7 +1490,7 @@ namespace Edu.WebApi.Controllers.Course
qitem.S_ClassId,
qitem.S_ClassName,
qitem.S_JoinType,
S_JoinTypeName= qitem.S_JoinType.ToName(),
S_JoinTypeName = qitem.S_JoinType.ToName(),
qitem.S_OrderId,
qitem.T_ClassId,
qitem.T_ClassName,
......@@ -1700,12 +1701,14 @@ namespace Edu.WebApi.Controllers.Course
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetOrderHelpEnterId() {
public ApiResult SetOrderHelpEnterId()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int OrderId = parms.GetInt("OrderId", 0);
int HelpEnterId = parms.GetInt("HelpEnterId", 0);
if (OrderId <= 0) {
if (OrderId <= 0)
{
return ApiResult.ParamIsNull("请传递订单id");
}
......@@ -1714,7 +1717,8 @@ namespace Edu.WebApi.Controllers.Course
{
return ApiResult.Success();
}
else {
else
{
return ApiResult.Failed(msg);
}
}
......@@ -2167,6 +2171,74 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.Success(data: otherClassList);
}
#endregion
#region 甲鹤小程序付款的课程同步过来
/// <summary>
/// 新增修改订单
/// </summary>
/// <returns></returns>
[HttpPost]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public ApiResult SetBatchClassOrder()
{
Model.CacheModel.UserInfo userinfo = new Model.CacheModel.UserInfo();
int EnterID = base.ParmJObj.GetInt("EnterID");
List<RB_Order_ViewModel> list = JsonHelper.DeserializeObject<List<RB_Order_ViewModel>>(base.ParmJObj.GetStringValue("Order"));
list.ForEach(x => x.TargetJoinType = OrderJoinTypeEnum.Normal);
list.ForEach(x => x.JoinType = OrderJoinTypeEnum.Normal);
list.ForEach(x => x.JoinType = OrderJoinTypeEnum.Normal);
list.ForEach(x => x.OrderSource = OrderSourceEnum.MallApplet);
list.ForEach(x => x.OrderType = OrderTypeEnum.CourseOrder);
if (EnterID > 0)
{
userinfo = UserReidsCache.GetUserLoginInfo(EnterID);
list.ForEach(x => x.School_Id = userinfo.School_Id);
list.ForEach(x => x.Group_Id = userinfo.Group_Id);
list.ForEach(x => x.Dept_Id = userinfo.DeptId);
list.ForEach(x => x.CreateBy = EnterID);
list.ForEach(x => x.UpdateBy = EnterID);
}
else
{
userinfo.Group_Id = list.FirstOrDefault()?.Group_Id ?? 0;
}
list.ForEach(x => x.OrderForm = OrderFormEnum.Applet);
list.ForEach(x => x.TradeWay = TradeWayEnum.OnLine);
list.ForEach(x => x.CreateTime = DateTime.Now);
list.ForEach(x => x.UpdateTime = DateTime.Now);
list.ForEach(x => x.OrderState = OrderStateEnum.Normal);
list.ForEach(x => x.StartClassHours = 0);
var flag = false;
flag = orderModule.SetBatchClassOrder(list, userinfo, false);
return flag ? ApiResult.Success("") : ApiResult.Failed("");
}
/// <summary>
/// 系统自动取消时同步规格库存
/// </summary>
/// <returns></returns>
[HttpPost]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public ApiResult UpdateGoodsSpecification()
{
Model.CacheModel.UserInfo userinfo = new Model.CacheModel.UserInfo();
List<int> list = JsonHelper.DeserializeObject<List<int>>(base.ParmJObj.GetStringValue("Order"));
var flag = false;
flag = orderModule.UpdateGoodsSpecification(list);
return flag ? ApiResult.Success("") : ApiResult.Failed("");
}
#endregion
}
}
......@@ -93,7 +93,7 @@
//订单转班流程编号
"OrderTransClassFlowId": 5,
//订单分拆流程编号
"OrderSplitClassFlowId": 6
"OrderSplitClassFlowId": 6,
"ErpUrl": "http://localhost:8181/#",
//是否开启调课数据验证
"IsOpenChangeClassVerify":1
......
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