Commit 137c635d authored by 吴春's avatar 吴春

提交代码

parent fedbd32b
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 EducationOrderStatusEnum
{
/// <summary>
/// 未付款
/// </summary>
[EnumField("未付款")]
NonPayment = 1,
/// <summary>
/// 已完成
/// </summary>
[EnumField("已完成")]
Completed = 5,
/// <summary>
/// 已取消
/// </summary>
[EnumField("已取消")]
Cancel = 7
}
}
......@@ -29,7 +29,10 @@ namespace Mall.Module.Education
/// 教师仓储
/// </summary>
private readonly RB_Education_TeacherRepository educationTeacherRepository = new RB_Education_TeacherRepository();
/// <summary>
/// 小程序
/// </summary>
private readonly RB_MiniProgramRepository miniProgramRepository = new RB_MiniProgramRepository();
private readonly RB_Education_CouponRepository discountCouponRepository = new RB_Education_CouponRepository();
private readonly RB_Education_CouponProductRepository productRepository = new RB_Education_CouponProductRepository();
......@@ -2481,5 +2484,128 @@ namespace Mall.Module.Education
}
#endregion
#region 我的订单
/// <summary>
/// 小程序我的订单列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Goods_Order_Extend> GetAppletGoodsMyOrderPageList(int pageIndex, int pageSize, out long count, RB_Goods_Order_Extend demodel)
{
var list = goods_OrderRepository.GetEducationOrderPageList(pageIndex, pageSize, out count, demodel);
if (list.Any())
{
//查询订单明细
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, OrderIds = string.Join(",", list.Select(x => x.OrderId)) });
foreach (var item in dlist)
{
item.CoverImagePath = item.CoverImage;
}
foreach (var item in list)
{
item.DetailList = dlist.Where(x => x.OrderId == item.OrderId).ToList();
}
}
return list;
}
/// <summary>
/// 获取我的订单详情
/// </summary>
/// <param name="orderId"></param>
/// <param name="userId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public Common.API.ApiResult GetAppletMyOrderInfo(int orderId, int userId, int tenantId, int mallBaseId)
{
var model = goods_OrderRepository.GetEntity(orderId).RefMapperTo<RB_Goods_Order_Extend>();
if (model == null || model.UserId != userId)
{
return Common.API.ApiResult.Failed("订单信息不存在,请核实后再试");
}
//查询订单明细
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderId });
if (dlist.Any())
{
string orderDetailIds = string.Join(",", dlist.Select(x => x.Id));
foreach (var item in dlist)
{
item.CoverImagePath = item.CoverImage;
item.IsApplyForAfterSale = 2;
if (item.PresentFXGrade > 0)
{
model.PresentFXGrade = 1;
}
}
}
model.DetailList = dlist;
//是否可以申请售后
model.IsCanApplyForAfterSale = 2;
//获取订阅消息
var miniModel = miniProgramRepository.GetListRepository(new RB_MiniProgram_Extend { TenantId = model.TenantId, MallBaseId = model.MallBaseId }).FirstOrDefault();
List<string> template_message_list = new List<string>();
if (miniModel != null)
{
if (!string.IsNullOrWhiteSpace(miniModel.RefundTpl))
{
template_message_list.Add(miniModel.RefundTpl);
}
if (!string.IsNullOrWhiteSpace(miniModel.OrderCancelTpl))
{
template_message_list.Add(miniModel.OrderCancelTpl);
}
}
return Common.API.ApiResult.Success("", new
{
template_message_list,
model.OrderId,
model.OrderNo,
model.OrderStatus,
OrderStatusName = model.OrderStatus.GetEnumName(),
CreateDate = model.CreateDate.HasValue ? model.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
CancelTime = model.CancelTime.HasValue ? model.CancelTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
model.PaymentWay,
PaymentWayName = model.PaymentWay.GetEnumName(),
model.DeliveryMethod,
DeliveryMethodName = model.DeliveryMethod.GetEnumName(),
model.PreferPrice,
model.Income,
model.CouponMoney,
model.FreightMoney,
model.Consignee,
model.Mobile,
DetailList = model.DetailList.Select(x => new
{
DetailId = x.Id,
x.GoodsId,
x.GoodsName,
x.CoverImagePath,
SpecificationList = JsonConvert.DeserializeObject<List<string>>(x.Specification),
x.Number,
x.Final_Price,
x.IsComment,
x.IsApplyForAfterSale,
x.FreeShippingRemarks
}),
model.IsApplyForCancel,
model.RejectRemark,
model.IsCanApplyForAfterSale,
model.PresentFXGrade,
model.BuyerMessage
});
}
#endregion
}
}
......@@ -1847,5 +1847,124 @@ GROUP BY o.OrderId,od.GoodsId
return Get<RB_Goods_Order_Extend>(sql).ToList();
}
#endregion
#region 教育订单
/// <summary>
/// 获取订单分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_Order_Extend> GetEducationOrderPageList(int pageIndex, int pageSize, out long count, RB_Goods_Order_Extend dmodel)
{
var parameters = new DynamicParameters();
string where = $" 1=1 and o.{nameof(RB_Goods_Order.Status)}=0 and o.{nameof(RB_Goods_Order.OrderClassify)}=2";
if (dmodel.TenantId > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.OrderId > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.OrderId)}={dmodel.OrderId}";
}
if (dmodel.OrderSource > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.OrderSource)}={(int)dmodel.OrderSource}";
}
if (dmodel.OrderType > 0)
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.OrderType)}={dmodel.OrderType}";
}
if (dmodel.DeliveryMethod > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.DeliveryMethod)}={(int)dmodel.DeliveryMethod}";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and o.{nameof(RB_Goods_Order.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and o.{nameof(RB_Goods_Order.CreateDate)} <='{dmodel.EndTime} 23:59:59'";
}
if (dmodel.OrderStatus > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.OrderStatus)}={(int)dmodel.OrderStatus}";
}
if (dmodel.IsNotSelectCancel == 1)
{
where += $@" and o.{nameof(RB_Goods_Order.OrderStatus)} <> {(int)OrderStatusEnum.Cancel}";
where += $@" and o.{nameof(RB_Goods_Order.Recycled)} =2";
}
if (!string.IsNullOrEmpty(dmodel.OrderStatusIds))
{
where += $@" and o.{nameof(RB_Goods_Order.OrderStatus)} in({dmodel.OrderStatusIds})";
}
if (!string.IsNullOrEmpty(dmodel.OrderNo))
{
where += $@" and o.{nameof(RB_Goods_Order.OrderNo)} like @OrderNo ";
parameters.Add("OrderNo", "%" + dmodel.OrderNo.Trim() + "%");
}
if (!string.IsNullOrEmpty(dmodel.MerchantsNo))
{
where += $@" and o.{nameof(RB_Goods_Order.MerchantsNo)} like @MerchantsNo ";
parameters.Add("MerchantsNo", "%" + dmodel.MerchantsNo.Trim() + "%");
}
if (!string.IsNullOrEmpty(dmodel.UserName))
{
where += $@" and u.{nameof(RB_Member_User.Name)} like @UserName ";
parameters.Add("UserName", "%" + dmodel.UserName.Trim() + "%");
}
if (dmodel.UserId > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.UserId)}={(int)dmodel.UserId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsName))
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.GoodsName)} like '%{dmodel.GoodsName}%'";
}
if (!string.IsNullOrEmpty(dmodel.Consignee))
{
where += $@" and o.{nameof(RB_Goods_Order.Consignee)} like '%{dmodel.Consignee}%'";
}
if (!string.IsNullOrEmpty(dmodel.Mobile))
{
where += $@" and o.{nameof(RB_Goods_Order.Mobile)} like '%{dmodel.Mobile}%'";
}
if (!string.IsNullOrEmpty(dmodel.ProductCode))
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.ProductCode)} like '%{dmodel.ProductCode}%'";
}
if (!string.IsNullOrEmpty(dmodel.AnchorName))
{
where += $@" and o.{nameof(RB_Goods_Order.AnchorName)} like '%{dmodel.AnchorName}%'";
}
if (dmodel.Recycled > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.Recycled)}={(int)dmodel.Recycled}";
}
if (dmodel.SmallShopsId.HasValue && dmodel.SmallShopsId > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.SmallShopsId)}={dmodel.SmallShopsId}";
}
if (dmodel.IsSelectPayMoney == 1)
{
where += $@" and o.{nameof(RB_Goods_Order.PaymentTime)} IS NOT NULL";
}
string sql = $@"SELECT o.*,u.Name as UserName,sshop.`Name` as SmallShopsName FROM rb_goods_order o
INNER JOIN rb_goods_orderdetail od on o.OrderId=od.OrderId
INNER JOIN rb_member_user u on o.UserId=u.Id
LEFT JOIN rb_smallshops_info as sshop on o.SmallShopsId=sshop.Id
where {where} group by o.OrderId order by o.CreateDate desc";
return GetPage<RB_Goods_Order_Extend>(pageIndex, pageSize, out count, sql, parameters).ToList();
}
#endregion
}
}
......@@ -31,6 +31,7 @@ namespace Mall.WebApi.Controllers.Education
private readonly EducationModule educationModule = new EducationModule();
private Module.User.UserModule UserModule = new Module.User.UserModule();
private Module.Product.ProductModule productModule = new Module.Product.ProductModule();
private readonly Module.User.MiniProgramModule programModule = new Module.User.MiniProgramModule();
#region 课程卡
/// <summary>
......@@ -471,7 +472,127 @@ namespace Mall.WebApi.Controllers.Education
}
#endregion
#region 我的订单
/// <summary>
/// 获取订单状态枚举
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult EducationOrderStatusEnumList()
{
var list = EnumHelper.GetEnumList(typeof(Common.Enum.Goods.EducationOrderStatusEnum));
return ApiResult.Success("", list.OrderBy(x => Convert.ToInt32(x.Value)).Select(x => new
{
Name = x.Key,
Id = Convert.ToInt32(x.Value)
}));
}
/// <summary>
/// 我的订单分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGoodsEducationOrderPageList()
{
var parms = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(parms.msg.ToString());
RB_Goods_Order_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Order_Extend>(parms.msg.ToString());
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
demodel.UserId = userInfo.UserId;
demodel.Recycled = 2;
var list = educationModule.GetAppletGoodsMyOrderPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
//获取订阅消息
var miniModel = programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId });
List<string> template_message_list = new List<string>();
if (miniModel != null)
{
if (!string.IsNullOrWhiteSpace(miniModel.RefundTpl))
{
template_message_list.Add(miniModel.RefundTpl);
}
if (!string.IsNullOrWhiteSpace(miniModel.OrderCancelTpl))
{
template_message_list.Add(miniModel.OrderCancelTpl);
}
}
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
template_message_list,
x.OrderId,
x.OrderNo,
x.DeliveryMethod,
x.Income,
x.FreightMoney,
x.CouponMoney,
x.PaymentWay,
PaymentWayName = x.PaymentWay.GetEnumName(),
DetailList = x.DetailList.Select(y => new
{
y.Id,
y.GoodsId,
y.CoverImagePath,
y.OrderType,
OrderTypeName = y.OrderType.GetEnumName(),
y.GoodsName,
y.SpecificationSort,
SpecificationList = JsonConvert.DeserializeObject<List<string>>(y.Specification),
y.ProductCode,
y.Final_Price,
y.Unit_Price,
y.Number,
y.UseDay,
y.IsSpell,
y.CarNumber,
y.LineName,
y.IsComment,
TripSTime = y.TripSTime.HasValue ? y.TripSTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
TripETime = y.TripETime.HasValue ? y.TripETime.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
}),
x.OrderStatus,
OrderStatusName = ((Common.Enum.Goods.EducationOrderStatusEnum)x.OrderStatus).GetEnumName(),
x.TenantId,
x.MallBaseId,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取我的订单详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGuidecarOrderOrderInfo()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parms = JObject.Parse(req.msg.ToString());
int OrderId = parms.GetInt("OrderId", 0);
//HK2020-08-08新增
if (parms.GetInt("NewUserId") > 0)
{
userInfo.UserId = parms.GetInt("NewUserId");
}
if (OrderId <= 0)
{
return ApiResult.ParamIsNull();
}
return educationModule.GetAppletMyOrderInfo(OrderId, userInfo.UserId, userInfo.TenantId, userInfo.MallBaseId);
}
#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