| | |
| | | using CoreCms.Net.Model.Entities.Order; |
| | | using CoreCms.Net.Services; |
| | | using System.Threading; |
| | | using MathNet.Numerics.Distributions; |
| | | using CoreCms.Net.Model.ViewModels.DTO; |
| | | using CoreCms.Net.Auth.HttpContextUser; |
| | | using MathNet.Numerics; |
| | | using Org.BouncyCastle.Asn1.Cmp; |
| | | using static CoreCms.Net.Configuration.GlobalEnumVars; |
| | | using static SKIT.FlurlHttpClient.Wechat.Api.Models.CardCreateRequest.Types.MembershipCard.Types.Base.Types; |
| | | using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinExpressDeliveryOpenMessageGetDeliveryListResponse.Types; |
| | | using System.Threading.Channels; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace CoreCms.Net.Web.Admin.Controllers |
| | | { |
| | |
| | | private readonly ICoreCmsPlanOrderItemServices _planOrderItemServices; |
| | | private readonly ICoreCmsSettingServices _coreCmsSettingServices; |
| | | private readonly SemaphoreSlim _semaphore; |
| | | private readonly IHttpContextUser _user; |
| | | private readonly ICoreCmsPlanOrderServices _planOrderServices; |
| | | private readonly ICoreCmsAreaServices _areaServices; |
| | | private readonly ICoreCmsOrderServices _orderServices; |
| | | private readonly ICoreCmsOrderItemServices _orderItemServices; |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | ,ICoreCmsPlanOrderServices CoreCmsPlanOrderServices |
| | | , ICoreCmsPlanOrderItemServices planOrderItemServices |
| | | , ICoreCmsSettingServices coreCmsSettingServices |
| | | , IHttpContextUser user |
| | | , ICoreCmsPlanOrderServices planOrderServices |
| | | , ICoreCmsAreaServices areaServices |
| | | , ICoreCmsOrderServices orderServices |
| | | , ICoreCmsOrderItemServices orderItemServices |
| | | ) |
| | | { |
| | | _webHostEnvironment = webHostEnvironment; |
| | | _CoreCmsPlanOrderServices = CoreCmsPlanOrderServices; |
| | | _planOrderItemServices = planOrderItemServices; |
| | | _coreCmsSettingServices = coreCmsSettingServices; |
| | | _user = user; |
| | | _planOrderServices = planOrderServices; |
| | | _areaServices = areaServices; |
| | | _orderServices = orderServices; |
| | | _orderItemServices = orderItemServices; |
| | | |
| | | } |
| | | |
| | | #region 获取列表============================================================ |
| | |
| | | { |
| | | where = where.And(p => p.orderId.Contains(orderId)); |
| | | } |
| | | //调整订单金额 decimal |
| | | var orderAmount = Request.Form["orderAmount"].FirstOrDefault().ObjectToDecimal(0); |
| | | //市 varchar |
| | | var shi = Request.Form["shi"].FirstOrDefault().ObjectToInt(0); |
| | | if (shi>0) |
| | | { |
| | | where = where.And(p => p.shiId == shi); |
| | | } |
| | | //区县 varchar |
| | | var quxian = Request.Form["quxian"].FirstOrDefault().ObjectToInt(0); ; |
| | | if (quxian>0) |
| | | { |
| | | where = where.And(p => p.quxianId == quxian); |
| | | } |
| | | //收货地址 varchar |
| | | var shouhuoAddress = Request.Form["shouhuoAddress"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(shouhuoAddress)) |
| | | { |
| | | where = where.And(p => p.shouhuoAddress.Contains(shouhuoAddress)); |
| | | } |
| | | //调整订单金额 decimal |
| | | var orderAmount = Request.Form["orderAmount"].FirstOrDefault().ObjectToDecimal(0); |
| | | if (orderAmount > 0) |
| | | { |
| | | where = where.And(p => p.orderAmount == orderAmount); |
| | |
| | | { |
| | | //获取相关状态描述说明转换 |
| | | order.statusText = EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.PlanOrderTiJiao>(order.status); |
| | | |
| | | order.keYongAmount = order.keYongAmount - order.huaFeiAmount; |
| | | } |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Description("首页数据")] |
| | | public AdminUiCallBack GetIndex() |
| | | public async Task<AdminUiCallBack> GetIndex() |
| | | { |
| | | //返回数据 |
| | | var jm = new AdminUiCallBack { code = 0 }; |
| | | |
| | | var shi = await _areaServices.QueryListByClauseAsync(p=>p.parentId == 510000); |
| | | |
| | | jm.data = shi; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | #region 选择省============================================================ |
| | | // POST: Api/CoreCmsPlanOrder/GetIndex |
| | | /// <summary> |
| | | /// 选择市 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Description("选择省")] |
| | | [AllowAnonymous] |
| | | public async Task<AdminUiCallBack> GetCityId(int shengid = 0) |
| | | { |
| | | //返回数据 |
| | | var jm = new AdminUiCallBack { code = 0 }; |
| | | |
| | | var shi = await _areaServices.QueryListByClauseAsync(p => p.parentId == shengid); |
| | | |
| | | jm.data = shi; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 选择市============================================================ |
| | | // POST: Api/CoreCmsPlanOrder/GetIndex |
| | | /// <summary> |
| | | /// 选择市 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Description("选择市")] |
| | | [AllowAnonymous] |
| | | public async Task<AdminUiCallBack> GetAreaId(int cityid = 0) |
| | | { |
| | | //返回数据 |
| | | var jm = new AdminUiCallBack { code = 0 }; |
| | | |
| | | var shi = await _areaServices.QueryListByClauseAsync(p => p.parentId == cityid); |
| | | |
| | | jm.data = shi; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Description("编辑数据")] |
| | | public async Task<AdminUiCallBack> GetEdit([FromBody]FMIntId entity) |
| | | public async Task<AdminUiCallBack> GetEdit([FromBody]FMStringId entity) |
| | | { |
| | | var jm = new AdminUiCallBack(); |
| | | |
| | |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | //获取相关状态描述说明转换 |
| | | model.statusText = EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.PlanOrderTiJiao>(model.status); |
| | | model.keYongAmount = model.keYongAmount - model.huaFeiAmount; |
| | | |
| | | var modelItem1 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && p.isOld == true, p => p.specification, OrderByType.Asc); |
| | | |
| | | var modelItem2 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && p.isOld == false, p => p.specification, OrderByType.Asc); |
| | | |
| | | foreach (var coreCmsPlanOrderItem in modelItem1) |
| | | { |
| | | var coreCmsPlanOrderItem1 = modelItem2.Where(p => p.name == coreCmsPlanOrderItem.name && p.specification == coreCmsPlanOrderItem.specification).FirstOrDefault(); |
| | | if (coreCmsPlanOrderItem1 != null) |
| | | { |
| | | coreCmsPlanOrderItem.idnew = coreCmsPlanOrderItem1.id; |
| | | coreCmsPlanOrderItem.numsnew = coreCmsPlanOrderItem1.nums; |
| | | coreCmsPlanOrderItem.amountnew = coreCmsPlanOrderItem1.amount; |
| | | } |
| | | } |
| | | |
| | | jm.data = new |
| | | { |
| | | model, |
| | | modelItem1 |
| | | }; |
| | | jm.code = 0; |
| | | jm.data = model; |
| | | // jm.data = model; |
| | | |
| | | return jm; |
| | | } |
| | |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Description("编辑提交")] |
| | | public async Task<AdminUiCallBack> DoEdit([FromBody]CoreCmsPlanOrder entity) |
| | | public async Task<AdminUiCallBack> DoEdit([FromBody] CreateOrder entity) |
| | | { |
| | | var jm = await _CoreCmsPlanOrderServices.UpdateAsync(entity); |
| | | var jm = new AdminUiCallBack(); |
| | | |
| | | |
| | | |
| | | try |
| | | { |
| | | |
| | | |
| | | if (entity.itemIdarray ==null || entity.itemIdarray.Length==0) |
| | | { |
| | | jm.data = 10000; |
| | | jm.msg = GlobalErrorCodeVars.Code10000; |
| | | return jm; |
| | | } |
| | | string itemIds = string.Join(",", entity.itemIdarray); |
| | | |
| | | string itemNums = string.Join(",", entity.itemNumarray); |
| | | |
| | | |
| | | // jm = await _CoreCmsPlanOrderServices.UpdateAsync(new CoreCmsPlanOrder()); |
| | | var jms = await _planOrderServices.ToUpdate(entity.orderId, _user.ID, _user.Name, 2, itemIds, itemNums,"shi"); |
| | | if (jms.status) |
| | | { |
| | | jm.code = 0; |
| | | jm.data = jms.data; |
| | | jm.msg = "修改成功"; |
| | | } |
| | | else |
| | | { |
| | | jm.code = 1; |
| | | jm.data = jms.data; |
| | | jm.msg = jms.otherData.ToString(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | jm.msg = "数据处理异常"; |
| | | jm.otherData = e; |
| | | } |
| | | |
| | | |
| | | return jm; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | #endregion |
| | | |
| | |
| | | jm.msg = GlobalConstVars.DataisNo; |
| | | return jm; |
| | | } |
| | | jm = await _CoreCmsPlanOrderServices.DeleteByIdAsync(entity.id); |
| | | jm = await _CoreCmsPlanOrderServices.DeleteByIdAsync(entity.id , _user.Name); |
| | | |
| | | return jm; |
| | | } |
| | | |
| | | // POST: Api/CoreCmsPlanOrder/DoDelete/10 |
| | | /// <summary> |
| | | /// 单选删除 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Description("单选删除")] |
| | | public async Task<AdminUiCallBack> DoDeletedel([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new AdminUiCallBack(); |
| | | |
| | | var model = await _CoreCmsPlanOrderServices.QueryByIdAsync(entity.id); |
| | | if (model == null) |
| | | { |
| | | jm.msg = GlobalConstVars.DataisNo; |
| | | return jm; |
| | | } |
| | | |
| | | var bl = await _CoreCmsPlanOrderServices.DeleteByIdAsync(entity.id); |
| | | jm.code = bl ? 0 : 1; |
| | | jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; |
| | | return jm; |
| | | } |
| | | #endregion |
| | |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Description("批量删除")] |
| | | public async Task<AdminUiCallBack> DoBatchDelete([FromBody]FMArrayIntIds entity) |
| | | public async Task<AdminUiCallBack> DoBatchDelete([FromBody]FMArrayStringIds entity) |
| | | { |
| | | var jm = await _CoreCmsPlanOrderServices.DeleteByIdsAsync(entity.id); |
| | | var jm = await _CoreCmsPlanOrderServices.DeleteByIdsAsync(entity.id, _user.Name); |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | // POST: Api/CoreCmsPlanOrder/DoBatchDelete/10,11,20 |
| | | /// <summary> |
| | | /// 批量删除 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Description("批量删除")] |
| | | public async Task<AdminUiCallBack> DoBatchDeletedel([FromBody] FMArrayStringIds entity) |
| | | { |
| | | var jm = new AdminUiCallBack(); |
| | | |
| | | var bl = await _CoreCmsPlanOrderServices.DeleteByIdsAsync(entity.id); |
| | | jm.code = bl ? 0 : 1; |
| | | jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; |
| | | |
| | | return jm; |
| | | } |
| | | |
| | |
| | | } |
| | | //获取相关状态描述说明转换 |
| | | model.statusText = EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.PlanOrderTiJiao>(model.status); |
| | | model.keYongAmount = model.keYongAmount - model.huaFeiAmount; |
| | | |
| | | |
| | | var modelItem = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id, p => p.specification, OrderByType.Asc); |
| | | var modelItem1 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && p.isOld == true, p => p.specification, OrderByType.Asc); |
| | | |
| | | var modelItem2 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && p.isOld == false, p => p.specification, OrderByType.Asc); |
| | | |
| | | |
| | | foreach(var coreCmsPlanOrderItem in modelItem1) |
| | | { |
| | | var coreCmsPlanOrderItem1 = modelItem2.Where(p => p.name == coreCmsPlanOrderItem.name && p.specification == coreCmsPlanOrderItem.specification).FirstOrDefault(); |
| | | if (coreCmsPlanOrderItem1 != null) |
| | | { |
| | | coreCmsPlanOrderItem.idnew = coreCmsPlanOrderItem1.id; |
| | | coreCmsPlanOrderItem.numsnew = coreCmsPlanOrderItem1.nums; |
| | | coreCmsPlanOrderItem.amountnew = coreCmsPlanOrderItem1.amount; |
| | | } |
| | | } |
| | | var coreCmsOrderItems = new List<CoreCmsOrderItem>(); |
| | | //查询用计划订单积分购买的订单 |
| | | var coreCmsOrders = await _orderServices.QueryListByClauseAsync(p => p.planorderId == model.orderId && p.isdel == false); |
| | | if(coreCmsOrders!=null && coreCmsOrders.Count > 0) |
| | | { |
| | | var orderids = new List<string>(); |
| | | foreach(var coreCmsOrder in coreCmsOrders) |
| | | { |
| | | orderids.Add(coreCmsOrder.orderId); |
| | | } |
| | | coreCmsOrderItems = await _orderItemServices.QueryListByClauseAsync(p => orderids.Contains(p.orderId)); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | jm.data = new |
| | | { |
| | | model, |
| | | modelItem, |
| | | modelItem1 , |
| | | coreCmsOrderItems |
| | | }; |
| | | jm.code = 0; |
| | | //jm.data = model; |