Commit 69f66bab authored by 吴春's avatar 吴春

提交代码

parent b9b4e2d5
using Mall.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mall.Common.Enum.Goods
{
/// <summary>
/// 订单状态枚举
/// </summary>
public enum OrderStatusesRerveEnum
{
/// <summary>
/// 未付款
/// </summary>
[EnumField("未付款")]
NonPayment = 1,
/// <summary>
/// 待使用
/// </summary>
[EnumField("待使用")]
WaitReceiving = 3,
/// <summary>
/// 已使用
/// </summary>
[EnumField("已使用")]
Received = 4,
/// <summary>
/// 已完成
/// </summary>
[EnumField("已完成")]
Completed = 5,
/// <summary>
/// 待处理
/// </summary>
[EnumField("待处理")]
WaitDeal = 6,
/// <summary>
/// 已取消
/// </summary>
[EnumField("已取消")]
Cancel = 7
}
}
......@@ -349,5 +349,10 @@ namespace Mall.Model.Entity.Product
/// 使用课程卡id
/// </summary>
public int? EducationCouponId { get; set; }
/// <summary>
/// 服务人员的id
/// </summary>
public int? ServicepersonalId { get; set; }
}
}
......@@ -49,5 +49,10 @@ namespace Mall.Model.Extend.Reserve
/// 用户优惠券id
/// </summary>
public string Ids { get; set; }
/// <summary>
/// 线下服务门店id
/// </summary>
public int StoreId { get; set; }
}
}
......@@ -10,6 +10,7 @@ using Mall.Common.Plugin;
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Entity.GuideCar;
using Mall.Model.Entity.Product;
using Mall.Model.Entity.Reserve;
using Mall.Model.Entity.User;
using Mall.Model.Extend.BaseSetUp;
using Mall.Model.Extend.GuideCar;
......@@ -20,6 +21,7 @@ using Mall.Repository.BaseSetUp;
using Mall.Repository.GuideCar;
using Mall.Repository.MarketingCenter;
using Mall.Repository.Product;
using Mall.Repository.Reserve;
using Mall.Repository.User;
using Newtonsoft.Json;
using VT.FW.DB;
......@@ -212,7 +214,10 @@ namespace Mall.Module.Product
/// 门店仓储层对象
/// </summary>
private readonly RB_StoresRepository storesRepository = new RB_StoresRepository();
/// <summary>
/// 服务人员仓储层对象
/// </summary>
private readonly RB_Reserve_ServicePersonalRepository reserveServicePersonalRepository = new RB_Reserve_ServicePersonalRepository();
/// <summary>
/// 获取会员等级列表
......@@ -1150,5 +1155,209 @@ namespace Mall.Module.Product
}
#endregion
/// <summary>
/// 获取分类列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Product_Category_Extend> GetCategoryListModule(RB_Product_Category_Extend dmodel)
{
return product_CategoryRepository.GetList(dmodel);
}
/// <summary>
/// 获取后台商品列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetProductGoodsList(RB_Goods_Extend demodel, int SmallShopsId = 0)
{
var list = goodsRepository.GetList(demodel);
if (list.Any())
{
//查询分类
string ids = string.Join(",", list.Select(x => x.Id));
RB_SmallShops_Info_Extend smallModel = new RB_SmallShops_Info_Extend();
List<RB_SmallShops_Price_Extend> smallPList = new List<RB_SmallShops_Price_Extend>();
if (SmallShopsId > 0)
{
smallModel = smallShops_InfoRepository.GetEntity<RB_SmallShops_Info_Extend>(SmallShopsId);
smallPList = smallShops_PriceRepository.GetList(new RB_SmallShops_Price_Extend() { SmallShopsId = SmallShopsId, GoodsIds = ids });
}
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<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(item.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
//轮播图
}
}
}
return list;
}
#region 评论
/// <summary>
/// 获取订单明细实体
/// </summary>
/// <param name="OrderId"></param>
/// <returns></returns>
public RB_Goods_OrderDetail_Extend GetOrderDetailInfo(int OrderId)
{
return goods_OrderDetailRepository.GetEntity(OrderId).RefMapperTo<RB_Goods_OrderDetail_Extend>();
}
/// <summary>
/// 管理新增评论
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool SetReserveGoodsCommentInfo(List<RB_Goods_Comment_Extend> list)
{
RB_Goods_OrderDetail dmodel = new RB_Goods_OrderDetail();
if (list.FirstOrDefault().OrderDetailId > 0)
{
dmodel = goods_OrderDetailRepository.GetEntity(list.FirstOrDefault().OrderDetailId);
if (dmodel == null) { return false; }
if (dmodel.IsComment == 1) { return false; }
}
bool flag = goods_CommentRepository.InsertBatch(list);
if (flag)
{
if (list.FirstOrDefault().OrderDetailId > 0)
{
//更新订单商品为已评价
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods_OrderDetail.IsComment),1}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderDetail.Id),
FiledValue=list.FirstOrDefault().OrderDetailId,
OperatorEnum=OperatorEnum.Equal
}
};
goods_OrderDetailRepository.Update(keyValues, wheres);
//更新订单对应对应的商品和服务人员评分
//先查找已评论的商品信息
if (dmodel.GoodsId.HasValue && dmodel.GoodsId.Value > 0)
{
var carScoreList = goods_CommentRepository.GetAppletReserveGoodsCommentscore(dmodel.GoodsId.Value, 0, dmodel.TenantId, dmodel.MallBaseId);
decimal carScore = 0;
if (carScoreList != null && carScoreList.Any())
{
carScore = carScoreList.FirstOrDefault().TotalScore / carScoreList.FirstOrDefault().CommentNum;
}
else
{
carScore = Convert.ToDecimal(list.Where(x => x.GoodsId == dmodel.GoodsId).FirstOrDefault().CommentScore);
}
if (carScore > 0)//更新车辆的评分
{
//更新订单商品为已评价
Dictionary<string, object> keyValuesCar = new Dictionary<string, object>() {
{ nameof(RB_Goods.CourseScore),Math.Round(carScore,1, MidpointRounding.AwayFromZero)}
};
List<WhereHelper> wheresCar = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=dmodel.GoodsId,
OperatorEnum=OperatorEnum.Equal
}
};
goodsRepository.Update(keyValuesCar, wheresCar);
}
}
if (dmodel.ServicepersonalId.HasValue && dmodel.ServicepersonalId.Value > 0)
{
decimal guidScore = 0;
var guideScoreList = goods_CommentRepository.GetAppletReserveGoodsCommentscore(0, dmodel.ServicepersonalId.Value, dmodel.TenantId, dmodel.MallBaseId);
if (guideScoreList != null && guideScoreList.Any())
{
guidScore = guideScoreList.FirstOrDefault().TotalScore / guideScoreList.FirstOrDefault().CommentNum;
}
else
{
guidScore = Convert.ToDecimal(list.Where(x => x.ServicePersonalId == dmodel.ServicepersonalId).FirstOrDefault().CommentScore);
}
if (guidScore > 0)//更新车辆的评分
{
//更新订单商品为已评价
Dictionary<string, object> keyValuesCar = new Dictionary<string, object>() {
{ nameof(RB_Reserve_ServicePersonal.Score),Math.Round(guidScore,1, MidpointRounding.AwayFromZero)}
};
List<WhereHelper> wheresCar = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Reserve_ServicePersonal.ID),
FiledValue=dmodel.ServicepersonalId,
OperatorEnum=OperatorEnum.Equal
}
};
reserveServicePersonalRepository.Update(keyValuesCar, wheresCar);
}
}
}
}
return flag;
}
/// <summary>
/// 获取订单评价列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Goods_Comment_Extend> GetAppletReservePageList(int pageIndex, int pageSize, out long count, RB_Goods_Comment_Extend demodel)
{
var list = goods_CommentRepository.GetAppletReservePageList(pageIndex, pageSize, out count, demodel);
if (list.Any())
{
List<RB_Member_User_Extend> userList = new List<RB_Member_User_Extend>();
if (list.Where(x => x.UserId > 0).Any())
{
string uids = string.Join(",", list.Where(x => x.UserId > 0).Select(x => x.UserId ?? 0));
userList = member_UserRepository.GetList(new RB_Member_User_Extend() { UserIds = uids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
}
foreach (var item in list)
{
//评论图片
item.CommentImgList = new List<string>();
if (!string.IsNullOrEmpty(item.CommentImage))
{
item.CommentImgList = JsonConvert.DeserializeObject<List<string>>(item.CommentImage);
}
if (item.UserId > 0)
{
item.UserPhotoPath = userList.Where(x => x.Id == item.UserId).FirstOrDefault()?.Photo ?? "";
}
if (item.UserId == 0 && item.UserPhoto > 0)
{
item.UserPhotoPath = material_InfoRepository.GetEntity(item.UserPhoto)?.Path ?? "";
}
}
}
return list;
}
#endregion
}
}
\ No newline at end of file
......@@ -129,7 +129,7 @@ namespace Mall.Module.Reserve
}
if (model.OrderStateJson == null || model.OrderStateJson == "" || model.OrderStateJson == "[]")
{
var list = EnumHelper.GetEnumList(typeof(Common.Enum.Goods.OrderStatusEnum));
var list = EnumHelper.GetEnumList(typeof(Common.Enum.Goods.OrderStatusesRerveEnum));
model.OrderStateList = list.OrderBy(x => Convert.ToInt32(x.Value)).Select(x => new ReserveStateModel
{
Name = x.Key,
......@@ -506,11 +506,14 @@ namespace Mall.Module.Reserve
{
string Ids = string.Join(",", list.Where(x => x.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Category || x.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Product).Select(x => x.ID));
var listProduct = productRepository.GetListByDiscountCouponIds(query, Ids);
foreach (var item in list)
if (!string.IsNullOrWhiteSpace(Ids))
{
item.ProductList = new List<RB_Reserve_CouponProduct_Extend>();
item.ProductList = listProduct.Where(x => x.CouponId == item.ID).ToList();
var listProduct = productRepository.GetListByDiscountCouponIds(query, Ids);
foreach (var item in list)
{
item.ProductList = new List<RB_Reserve_CouponProduct_Extend>();
item.ProductList = listProduct.Where(x => x.CouponId == item.ID).ToList();
}
}
}
return list;
......
......@@ -87,14 +87,11 @@ where {where} order by c.Id desc";
{
where += $@" and c.{nameof(RB_Goods_Comment.Id)}={dmodel.Id}";
}
if (dmodel.CommentGrade > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.CommentGrade)}={(int)dmodel.CommentGrade}";
}
if (dmodel.GoodsId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.GoodsId)}={dmodel.GoodsId}";
}
if (dmodel.UserId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.UserId)}={dmodel.UserId}";
......@@ -179,6 +176,7 @@ where {where} ";
return Get<RB_Goods_Comment_Extend>(sql).ToList();
}
/// <summary>
/// 获取车辆评分信息
/// </summary>
......@@ -217,7 +215,7 @@ LEFT JOIN rb_guidecar_carbrand as cb on cb.ID=a.CarBrandId where {where} ";
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public List<RB_Goods_Comment_Extend> GetGuideCommentByOrderDetailId(string orderDetailIds, int tenantId, int mallBaseId)
public List<RB_Goods_Comment_Extend> GetGuideCommentByOrderDetailId(string orderDetailIds, int tenantId, int mallBaseId)
{
string where = $" 1=1 and c.{nameof(RB_Goods_Comment.Status)}=0 and c.{nameof(RB_Goods_Comment.Is_Show)}=1 and c.{nameof(RB_Goods_Comment.GuideId)}>0 ";
if (tenantId > 0)
......@@ -232,7 +230,7 @@ LEFT JOIN rb_guidecar_carbrand as cb on cb.ID=a.CarBrandId where {where} ";
{
where += $@" and c.{nameof(RB_Goods_Comment.OrderDetailId)} in ({orderDetailIds}) ";
}
string sql = $@"SELECT c.*,a.`Name` as GuideName FROM RB_Goods_Comment c LEFT JOIN rb_guidecar_guide as a on c.GuideId=a.ID where {where} ";
return Get<RB_Goods_Comment_Extend>(sql).ToList();
}
......@@ -347,11 +345,114 @@ from rb_goods_comment as c where {where} GROUP BY OrderDetailId) as t GROUP BY t
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
public RB_Goods_Comment_Extend GetGoodsCommentScore(int goodsId) {
public RB_Goods_Comment_Extend GetGoodsCommentScore(int goodsId)
{
string sql = $@"SELECT SUM(CommentScore) AS CommentScore, COUNT(0) AS CommentNum FROM rb_goods_comment WHERE Status =0 and GoodsId = {goodsId}";
return Get<RB_Goods_Comment_Extend>(sql).FirstOrDefault();
}
#region 线下服务
/// <summary>
/// 获取商品和服务人员评分信息
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public List<RB_Goods_Comment_Extend> GetAppletReserveGoodsCommentscore(int servicepersonalId, int goodsId, int tenantId, int mallBaseId)
{
string where = $" 1=1 and c.{nameof(RB_Goods_Comment.Status)}=0 ";
if (tenantId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.TenantId)}={tenantId}";
}
if (mallBaseId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.MallBaseId)}={mallBaseId}";
}
if (servicepersonalId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.ServicePersonalId)}={servicepersonalId}";
}
if (goodsId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.GoodsId)}={goodsId}";
}
string sql = $@"SELECT COUNT(0) as CommentNum,SUM(c.CommentScore) as TotalScore FROM RB_Goods_Comment c
where {where} ";
return Get<RB_Goods_Comment_Extend>(sql).ToList();
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_Comment_Extend> GetAppletReservePageList(int pageIndex, int pageSize, out long count, RB_Goods_Comment_Extend dmodel)
{
string where = $" 1=1 and c.{nameof(RB_Goods_Comment.Status)}=0 ";
if (dmodel.TenantId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.Id)}={dmodel.Id}";
}
if (dmodel.CommentGrade > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.CommentGrade)}={(int)dmodel.CommentGrade}";
}
if (dmodel.GoodsId > 0 && dmodel.ServicePersonalId > 0)
{
where += $@" and (c.{nameof(RB_Goods_Comment.GoodsId)}={dmodel.GoodsId} or c.{nameof(RB_Goods_Comment.ServicePersonalId)}={dmodel.ServicePersonalId})";
}
else if (dmodel.GoodsId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.GoodsId)}={dmodel.GoodsId}";
}
else if (dmodel.ServicePersonalId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.ServicePersonalId)}={dmodel.ServicePersonalId}";
}
if (dmodel.UserId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.UserId)}={dmodel.UserId}";
}
if (dmodel.PlatformSource > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.PlatformSource)}={(int)dmodel.PlatformSource}";
}
if (dmodel.Is_Show > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.Is_Show)}={dmodel.Is_Show}";
}
if (!string.IsNullOrEmpty(dmodel.UserName))
{
where += $@" and c.{nameof(RB_Goods_Comment.UserName)} like '%{dmodel.UserName}%'";
}
if (!string.IsNullOrEmpty(dmodel.Content))
{
where += $@" and c.{nameof(RB_Goods_Comment.Content)} like '%{dmodel.Content}%'";
}
string sql = $@"SELECT c.* FROM RB_Goods_Comment c where {where} order by c.Is_Top asc,c.Id desc";
return GetPage<RB_Goods_Comment_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
#endregion
}
}
......@@ -234,7 +234,7 @@ SELECT a.ID as MemberCouponId,a.UserId,a.HeXiao,a.UseHeXiao,b.`Name`,b.UseType,b
}
if (query.StoreId > 0)
{
where += $" AND ( a.{nameof(RB_Reserve_Coupon_Extend.StoreId)}={query.StoreId} or a.{nameof(RB_Reserve_Coupon_Extend.StoreId)}=0 ))";
where += $" AND ( a.{nameof(RB_Reserve_Coupon_Extend.StoreId)}={query.StoreId} or a.{nameof(RB_Reserve_Coupon_Extend.StoreId)}=0 )";
}
else
......
......@@ -202,7 +202,7 @@ namespace Mall.WebApi.Controllers.Reserve
#region 套餐卡
/// <summary>
/// 领劵中心
/// 套餐卡领劵中心
/// </summary>
/// <returns></returns>
[HttpPost]
......@@ -241,6 +241,26 @@ namespace Mall.WebApi.Controllers.Reserve
/// <summary>
/// 获取套餐卡详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetReserveCouponDetail()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Reserve_Coupon_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
var oldLogisticsModel = reserveModule.GetDiscountCouponList(query).FirstOrDefault();
if (oldLogisticsModel == null)
{
return ApiResult.Failed("套餐卡信息不存在");
}
return ApiResult.Success("", oldLogisticsModel);
}
/// <summary>
/// 领取套餐卡
/// </summary>
......@@ -267,26 +287,14 @@ namespace Mall.WebApi.Controllers.Reserve
{
return ApiResult.Failed("套餐卡信息不存在,请核实后再操作");
}
if (allMemberInfo.SmallShopId == 0)
{
if (oldLogisticsModel.SmallShopId > 0)
{
return ApiResult.Failed("您不属于当前店铺");
}
}
else
if (oldLogisticsModel.StoreId > 0 && oldLogisticsModel.StoreId != query.StoreId)
{
if (oldLogisticsModel.SmallShopId > 0 && oldLogisticsModel.SmallShopId != allMemberInfo.SmallShopId)
{
return ApiResult.Failed("领取套餐卡不属于当前店铺");
}
if (allMemberInfo.SmallShopId > 0 && oldLogisticsModel.SmallShopId == 0 && oldLogisticsModel.IsZanYangUse == 1)
{
return ApiResult.Failed("领取套餐卡不属于当前店铺");
}
return ApiResult.Failed("领取套餐卡不属于当前门店");
}
if (oldLogisticsModel.TotalNum != -1)//判断套餐卡剩余数量是够足够
{
if (oldLogisticsModel.TotalNum < 1)
......@@ -459,7 +467,7 @@ namespace Mall.WebApi.Controllers.Reserve
}
if (!string.IsNullOrWhiteSpace(Ids))
{
categotyList = new List<RB_Product_Category_Extend>(); //productModule.GetCategoryListModule(new Model.Extend.Product.RB_Product_Category_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, CategoryIds = Ids });
categotyList = offlineGoodsModule.GetCategoryListModule(new Model.Extend.Product.RB_Product_Category_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, CategoryIds = Ids });
}
if (categotyList == null || !categotyList.Any())
......@@ -487,7 +495,7 @@ namespace Mall.WebApi.Controllers.Reserve
if (!string.IsNullOrWhiteSpace(Ids))
{
goodsList = new List<RB_Goods_Extend>(); //productModule.GetProductGoodsList(new RB_Goods_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, GoodsIds = Ids });
goodsList = offlineGoodsModule.GetProductGoodsList(new RB_Goods_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, GoodsIds = Ids, GoodsClassify = 3 });
}
if (goodsList == null || !goodsList.Any())
{
......@@ -581,6 +589,182 @@ namespace Mall.WebApi.Controllers.Reserve
#endregion
#region 获取分销海报
/// <summary>
/// 获取服务人员分销海报
/// </summary>
/// <returns></returns>
public ApiResult GetFenXiaoPoster()
{
var userInfo = AppletUserInfo;
JObject jobj = JObject.Parse(RequestParm.msg.ToString());
var extModel = JsonConvert.DeserializeObject<RB_Reserve_FenXiaoPoster_Extend>(RequestParm.msg.ToString());
extModel.TenantId = userInfo.TenantId;
extModel.MallBaseId = userInfo.MallBaseId;
extModel.IsOpenReserve = jobj.GetInt("IsOpenReserve", 0);
var result = reserveModule.GetReserveFenXiaoPosterModule(extModel);
return ApiResult.Success(data: result);
}
#endregion
#region 评论
/// <summary>
/// 用户新增评论
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetGuideCarCommentInfo()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
List<RB_Goods_Comment_Extend> list = JsonConvert.DeserializeObject<List<RB_Goods_Comment_Extend>>(req.msg.ToString());
if (list != null && list.Any())
{
if (list.Where(x => (x.GuideId ?? 0) > 0).Count() == 0)
{
return ApiResult.ParamIsNull("请传递导游");
}
if (list.Where(x => (x.CarId ?? 0) > 0).Count() == 0)
{
return ApiResult.ParamIsNull("请传递车辆");
}
}
else
{
return ApiResult.ParamIsNull("请选择您要评论的信息");
}
foreach (var demodel in list)
{
if ((demodel.OrderDetailId ?? 0) <= 0)
{
return ApiResult.ParamIsNull("请传递订单明细OrderDetailId");
}
if ((demodel.GoodsId ?? 0) <= 0)
{
return ApiResult.ParamIsNull("请传递商品");
}
if (string.IsNullOrEmpty(demodel.Content))
{
return ApiResult.ParamIsNull("请输入评价内容");
}
demodel.CommentImage = "";
if (demodel.CommentImgList != null && demodel.CommentImgList.Any())
{
demodel.CommentImage = JsonConvert.SerializeObject(demodel.CommentImgList);
}
demodel.CommentGrade ??= Common.Enum.Goods.GoodsCommentTypeEnum.Praise;
demodel.CommentScore ??= 5;
if (demodel.CommentScore == 3 || demodel.CommentScore == 2)
{
demodel.CommentGrade = Common.Enum.Goods.GoodsCommentTypeEnum.Medium;
}
else if (demodel.CommentScore == 1)
{
demodel.CommentGrade = Common.Enum.Goods.GoodsCommentTypeEnum.Negative;
}
demodel.UserPhoto ??= 0;
demodel.Is_Top ??= 2;
demodel.Is_Show ??= 1;
demodel.Is_Anonymity ??= 2;
demodel.UserId ??= 0;
demodel.Reply ??= "";
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
demodel.UserId = userInfo.UserId;
demodel.UserName = userInfo.Name;
demodel.PlatformSource = userInfo.Source;
demodel.Status = 0;
demodel.CreateDate = DateTime.Now;
demodel.UpdateDate = DateTime.Now;
}
bool flag = offlineGoodsModule.SetReserveGoodsCommentInfo(list);
if (flag)
{
var demodel = list.FirstOrDefault();
var dmodel = offlineGoodsModule.GetOrderDetailInfo(demodel.OrderDetailId ?? 0);
if (dmodel != null && dmodel.CommentGiveIntegral > 0 && demodel.UserId > 0)
{
Model.Entity.User.RB_Member_Integral memberIntegralModel = new Model.Entity.User.RB_Member_Integral
{
UserId = demodel.UserId,
Type = Common.Enum.MarketingCenter.RecordTypeEnum.Income,
PlatformType = demodel.PlatformSource,
Integral = dmodel.CommentGiveIntegral,
Description = "评论赠送" + dmodel.CommentGiveIntegral + "积分",
TenantId = demodel.TenantId,
MallBaseId = demodel.MallBaseId,
Remarks = "评论商品" + dmodel.GoodsName + "赠送" + dmodel.CommentGiveIntegral + "积分",
CreateDate = demodel.CreateDate,
OrderId = dmodel.OrderId
};
bool integralResult = offlineGoodsModule.AddMemberIntegral(memberIntegralModel);
if (integralResult)
{
return ApiResult.CouponSuccess(ResultCode.Success, 2, "", dmodel.CommentGiveIntegral.ToString());
}
else
{
return ApiResult.CouponSuccess(ResultCode.Fail, 2, "", "");
}
}
return ApiResult.CouponSuccess(ResultCode.Fail, 2, "", "");
}
else { return ApiResult.CouponFailed(ResultCode.Fail, 2, "", ""); }
// if (flag) { return ApiResult.Success(); } else { return ApiResult.Failed(); }
}
/// <summary>
/// 获取商品评论分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public ApiResult GetAppletGoodsCommentPageList(object requestMsg)
{
var parms = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(parms.msg.ToString());
RB_Goods_Comment_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Comment_Extend>(parms.msg.ToString());
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
demodel.Is_Show = 1;
var list = offlineGoodsModule.GetAppletReservePageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.GoodsId,
x.UserId,
UserName = x.Is_Anonymity == 1 ? "匿名用户" : x.UserName,
UserPhotoPath = x.UserPhotoPath ?? "",
x.CommentGrade,
CommentGradeName = x.CommentGrade > 0 ? ((Common.Enum.Goods.GoodsCommentTypeEnum)x.CommentGrade).GetEnumName() : "",
x.CommentScore,
x.CommentImgList,
x.Content,
x.Reply,
x.GuideName,
x.CarBrandName,
x.CarColorName,
x.CarName,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
x.ServicePersonalId
});
return ApiResult.Success("", pagelist);
}
#endregion
#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