New file |
| | |
| | | /*********************************************************************** |
| | | * Project: baifenBinfa |
| | | * ProjectName: 百分兵法管理系统 |
| | | * Web: http://chuanyin.com |
| | | * Author: |
| | | * Email: |
| | | * CreateTime: 202408/07 |
| | | * Description: 暂无 |
| | | ***********************************************************************/ |
| | | |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Threading.Tasks; |
| | | using CoreCms.Net.Auth.HttpContextUser; |
| | | using CoreCms.Net.Caching.AutoMate.RedisCache; |
| | | using CoreCms.Net.Configuration; |
| | | using CoreCms.Net.IServices; |
| | | using CoreCms.Net.IServices.baifenbingfa; |
| | | using CoreCms.Net.Loging; |
| | | using CoreCms.Net.Model.Entities; |
| | | using CoreCms.Net.Model.Entities.Expression; |
| | | using CoreCms.Net.Model.FromBody; |
| | | using CoreCms.Net.Model.ViewModels.DTO; |
| | | using CoreCms.Net.Model.ViewModels.Excel; |
| | | using CoreCms.Net.Model.ViewModels.UI; |
| | | using CoreCms.Net.Services; |
| | | using CoreCms.Net.Utility.Extensions; |
| | | using CoreCms.Net.Utility.Helper; |
| | | using CoreCms.Net.WeChat.Service.HttpClients; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Hosting; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Newtonsoft.Json; |
| | | using NPOI.HSSF.UserModel; |
| | | using NPOI.SS.Util; |
| | | using SqlSugar; |
| | | |
| | | namespace CoreCms.Net.Web.WebApi.Controllers |
| | | { |
| | | /// <summary> |
| | | /// 订单调用接口数据 |
| | | /// </summary> |
| | | [Route("api/[controller]/[action]")] |
| | | [ApiController] |
| | | public class OrderJingXiaoshangController : ControllerBase |
| | | { |
| | | private readonly IHttpContextUser _user; |
| | | private readonly IWebHostEnvironment _webHostEnvironment; |
| | | private readonly ICoreCmsOrderServices _coreCmsOrderServices; |
| | | private readonly ICoreCmsUserServices _userServices; |
| | | private readonly ICoreCmsAreaServices _areaServices; |
| | | private readonly ICoreCmsBillAftersalesServices _aftersalesServices; |
| | | private readonly ICoreCmsBillPaymentsServices _billPaymentsServices; |
| | | private readonly ICoreCmsBillDeliveryServices _billDeliveryServices; |
| | | private readonly ICoreCmsStoreServices _storeServices; |
| | | private readonly ICoreCmsLogisticsServices _logisticsServices; |
| | | private readonly ICoreCmsPaymentsServices _paymentsServices; |
| | | private readonly ICoreCmsSettingServices _settingServices; |
| | | private readonly ICoreCmsUserWeChatInfoServices _userWeChatInfoServices; |
| | | private readonly IRedisOperationRepository _redisOperationRepository; |
| | | private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; |
| | | private readonly IWeChatShippingDeliveryServices _weChatShippingDeliveryServices; |
| | | |
| | | |
| | | private readonly ICoreCmsOrderItemServices _orderItemServices; |
| | | private readonly IBfbfComAPIService _bfbfServices; |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | public OrderJingXiaoshangController(IHttpContextUser user |
| | | , IWebHostEnvironment webHostEnvironment |
| | | , ICoreCmsOrderServices coreCmsOrderServices |
| | | , ICoreCmsUserServices userServices |
| | | , ICoreCmsAreaServices areaServices |
| | | , ICoreCmsBillAftersalesServices aftersalesServices |
| | | , ICoreCmsStoreServices storeServices |
| | | , ICoreCmsLogisticsServices logisticsServices |
| | | , ICoreCmsBillPaymentsServices billPaymentsServices |
| | | , ICoreCmsPaymentsServices paymentsServices |
| | | , ICoreCmsSettingServices settingServices |
| | | , ICoreCmsUserWeChatInfoServices userWeChatInfoServices |
| | | , IRedisOperationRepository redisOperationRepository |
| | | , ICoreCmsBillDeliveryServices billDeliveryServices |
| | | , IWeChatApiHttpClientFactory weChatApiHttpClientFactory |
| | | , ICoreCmsOrderItemServices orderItemServices |
| | | , IWeChatShippingDeliveryServices weChatShippingDeliveryServices |
| | | , IBfbfComAPIService bfbfComAPIService |
| | | ) |
| | | { |
| | | _user = user; |
| | | _webHostEnvironment = webHostEnvironment; |
| | | _coreCmsOrderServices = coreCmsOrderServices; |
| | | _userServices = userServices; |
| | | _areaServices = areaServices; |
| | | _aftersalesServices = aftersalesServices; |
| | | _storeServices = storeServices; |
| | | _logisticsServices = logisticsServices; |
| | | _billPaymentsServices = billPaymentsServices; |
| | | _paymentsServices = paymentsServices; |
| | | _settingServices = settingServices; |
| | | _userWeChatInfoServices = userWeChatInfoServices; |
| | | _redisOperationRepository = redisOperationRepository; |
| | | _billDeliveryServices = billDeliveryServices; |
| | | _weChatApiHttpClientFactory = weChatApiHttpClientFactory; |
| | | _orderItemServices = orderItemServices; |
| | | _weChatShippingDeliveryServices = weChatShippingDeliveryServices; |
| | | _bfbfServices = bfbfComAPIService; |
| | | } |
| | | |
| | | #region 获取列表============================================================ |
| | | // POST: Api/OrderJingXiao/GetPageList |
| | | /// <summary> |
| | | /// 获取列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetPageList([FromBody] GetOrderJingxiaoListPost entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | var pageCurrent = entity.page;// Request.Form["page"].FirstOrDefault().ObjectToInt(1); |
| | | var pageSize = entity.limit;// Request.Form["limit"].FirstOrDefault().ObjectToInt(30); |
| | | var where = PredicateBuilder.True<CoreCmsOrder>(); |
| | | //获取排序字段 |
| | | |
| | | //订单号 nvarchar |
| | | var orderId = entity.orderId;// Request.Form["orderId"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(orderId)) |
| | | { |
| | | where = where.And(p => p.orderId.Contains(orderId)); |
| | | } |
| | | |
| | | //订单状态 int |
| | | var status = entity.status;// Request.Form["status"].FirstOrDefault().ObjectToInt(0); |
| | | if (status > 0) |
| | | { |
| | | where = where.And(p => p.status == status); |
| | | } |
| | | //订单类型 int |
| | | var orderType = entity.orderType;// Request.Form["orderType"].FirstOrDefault().ObjectToInt(0); |
| | | if (orderType > 0) |
| | | { |
| | | where = where.And(p => p.orderType == orderType); |
| | | } |
| | | //发货状态 int |
| | | var shipStatus = entity.shipStatus;// Request.Form["shipStatus"].FirstOrDefault().ObjectToInt(0); |
| | | if (shipStatus > 0) |
| | | { |
| | | where = where.And(p => p.shipStatus == shipStatus); |
| | | } |
| | | //支付状态 int |
| | | var payStatus = entity.payStatus;//Request.Form["payStatus"].FirstOrDefault().ObjectToInt(0); |
| | | if (payStatus > 0) |
| | | { |
| | | where = where.And(p => p.payStatus == payStatus); |
| | | } |
| | | //支付方式代码 nvarchar |
| | | var paymentCode = entity.paymentCode;//Request.Form["paymentCode"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(paymentCode)) |
| | | { |
| | | where = where.And(p => p.paymentCode.Contains(paymentCode)); |
| | | } |
| | | //售后状态 int |
| | | var confirmStatus = entity.confirmStatus;//Request.Form["confirmStatus"].FirstOrDefault().ObjectToInt(0); |
| | | if (confirmStatus > 0) |
| | | { |
| | | where = where.And(p => p.confirmStatus == confirmStatus); |
| | | } |
| | | //订单来源 int |
| | | var source = entity.source;//Request.Form["source"].FirstOrDefault().ObjectToInt(0); |
| | | if (source > 0) |
| | | { |
| | | where = where.And(p => p.source == source); |
| | | } |
| | | //收货方式 int |
| | | var receiptType = entity.receiptType;//Request.Form["receiptType"].FirstOrDefault().ObjectToInt(0); |
| | | if (receiptType > 0) |
| | | { |
| | | where = where.And(p => p.receiptType == receiptType); |
| | | } |
| | | |
| | | //收货人姓名 nvarchar |
| | | var shipName = entity.shipName;//Request.Form["shipName"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(shipName)) |
| | | { |
| | | where = where.And(p => p.shipName.Contains(shipName)); |
| | | } |
| | | //收货人地址 nvarchar |
| | | var shipAddress = entity.shipAddress;//Request.Form["shipAddress"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(shipAddress)) |
| | | { |
| | | where = where.And(p => p.shipAddress.Contains(shipAddress)); |
| | | } |
| | | |
| | | //收货电话 nvarchar |
| | | var shipMobile = entity.shipMobile;//Request.Form["shipMobile"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(shipMobile)) |
| | | { |
| | | where = where.And(p => p.shipMobile.Contains(shipMobile)); |
| | | } |
| | | |
| | | //付款单号 nvarchar |
| | | var paymentId = entity.paymentId;//Request.Form["paymentId"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(paymentId)) |
| | | { |
| | | where = where.And(p => p.shipMobile.Contains(paymentId)); |
| | | } |
| | | |
| | | // datetime |
| | | var createTime = entity.createTime;//Request.Form["createTime"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(createTime)) |
| | | { |
| | | if (createTime.Contains("到")) |
| | | { |
| | | var dts = createTime.Split("到"); |
| | | var dtStart = dts[0].Trim().ObjectToDate(); |
| | | where = where.And(p => p.createTime > dtStart); |
| | | var dtEnd = dts[1].Trim().ObjectToDate(); |
| | | where = where.And(p => p.createTime < dtEnd); |
| | | } |
| | | else |
| | | { |
| | | var dt = createTime.ObjectToDate(); |
| | | where = where.And(p => p.createTime > dt); |
| | | } |
| | | } |
| | | |
| | | //商品名称 nvarchar |
| | | var goodName = entity.goodName;//Request.Form["goodName"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(goodName)) |
| | | { |
| | | var orderItems = await _orderItemServices.QueryListByClauseAsync(p => p.name.Contains(goodName), p => p.createTime, OrderByType.Desc, true); |
| | | if (orderItems.Any()) |
| | | { |
| | | var itemIds = orderItems.Select(p => p.orderId).ToList(); |
| | | where = where.And(p => itemIds.Contains(p.orderId)); |
| | | } |
| | | } |
| | | |
| | | //商品编码 nvarchar |
| | | var goodSn = entity.goodSn;//Request.Form["goodSn"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(goodSn)) |
| | | { |
| | | var orderItems = await _orderItemServices.QueryListByClauseAsync(p => p.sn.Contains(goodSn), p => p.createTime, OrderByType.Desc, true); |
| | | if (orderItems.Any()) |
| | | { |
| | | var itemIds = orderItems.Select(p => p.orderId).ToList(); |
| | | where = where.And(p => itemIds.Contains(p.orderId)); |
| | | } |
| | | } |
| | | |
| | | //订单状态 int |
| | | var orderUnifiedStatus = entity.orderUnifiedStatus;//Request.Form["orderUnifiedStatus"].FirstOrDefault().ObjectToInt(0); |
| | | if (orderUnifiedStatus > 0) |
| | | { |
| | | if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.payment) |
| | | { |
| | | //待支付 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_PAYMENT)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.delivered) |
| | | { |
| | | //待发货 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_DELIVERY)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.receive) |
| | | { |
| | | //待收货 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_RECEIPT)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.evaluated) |
| | | { |
| | | //已评价 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_COMPLETED_EVALUATE)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.noevaluat) |
| | | { |
| | | //待评价 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_EVALUATE)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.complete) |
| | | { |
| | | //已完成 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_COMPLETED)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.cancel) |
| | | { |
| | | //已取消 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_CANCEL)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.delete) |
| | | { |
| | | //已取消 |
| | | where = where.And(p => p.isdel == true); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | where = where.And(p => p.isdel == false); |
| | | } |
| | | |
| | | //经销商只能查看自己名下的订单 |
| | | where = where.And(p => p.publisherId == _user.ID); |
| | | |
| | | //获取数据 |
| | | var list = await _coreCmsOrderServices.QueryPageAsync(where, p => p.createTime, OrderByType.Desc, pageCurrent, pageSize, true); |
| | | if (list != null && list.Any()) |
| | | { |
| | | var areaCache = await _areaServices.GetCaChe(); |
| | | foreach (var item in list) |
| | | { |
| | | item.operating = _coreCmsOrderServices.GetOperating(item.orderId, item.status, item.payStatus, item.shipStatus, item.receiptType, item.isdel); |
| | | item.afterSaleStatus = ""; |
| | | if (item.aftersalesItem != null && item.aftersalesItem.Any()) |
| | | { |
| | | foreach (var sale in item.aftersalesItem) |
| | | { |
| | | item.afterSaleStatus += EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.BillAftersalesStatus>(sale.status) + "<br>"; |
| | | } |
| | | } |
| | | var areas = await _areaServices.GetAreaFullName(item.shipAreaId, areaCache); |
| | | item.shipAreaName = areas.status ? areas.data + "-" + item.shipAddress : item.shipAddress; |
| | | } |
| | | } |
| | | |
| | | //返回数据 |
| | | jm.data = list; |
| | | // jm.code = 1; |
| | | jm.status = true; |
| | | jm.count = list.TotalCount; |
| | | jm.otherData = new |
| | | { |
| | | list.HasNextPage, |
| | | list.HasPreviousPage, |
| | | list.PageIndex, |
| | | list.PageSize, |
| | | list.TotalCount, |
| | | list.TotalPages |
| | | }; |
| | | jm.msg = "数据调用成功!"; |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 首页数据============================================================ |
| | | // POST: Api/OrderJingXiao/GetIndex |
| | | /// <summary> |
| | | /// 首页数据 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetIndex() |
| | | { |
| | | //返回数据 |
| | | var jm = new WebApiCallBack { status = true }; |
| | | |
| | | //全部 |
| | | var all = await _coreCmsOrderServices.GetCountAsync(p => p.isdel == false && p.publisherId == _user.ID); |
| | | //待支付 |
| | | var paymentWhere = _coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_PAYMENT); |
| | | paymentWhere = paymentWhere.And(x => x.publisherId == _user.ID); |
| | | var payment = await _coreCmsOrderServices.GetCountAsync(paymentWhere); |
| | | //待发货 |
| | | var deliveredWhere = _coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_DELIVERY); |
| | | deliveredWhere = deliveredWhere.And(x => x.publisherId == _user.ID); |
| | | var delivered = await _coreCmsOrderServices.GetCountAsync(deliveredWhere); |
| | | //待收货 |
| | | var receiveWhere = _coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_RECEIPT); |
| | | receiveWhere = receiveWhere.And(x => x.publisherId == _user.ID); |
| | | var receive = await _coreCmsOrderServices.GetCountAsync(receiveWhere); |
| | | //已评价 |
| | | var evaluatedWhere = _coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_COMPLETED_EVALUATE); |
| | | evaluatedWhere = evaluatedWhere.And(x => x.publisherId == _user.ID); |
| | | var evaluated = await _coreCmsOrderServices.GetCountAsync(evaluatedWhere); |
| | | //待评价 |
| | | var noevaluatWhere = _coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_EVALUATE); |
| | | noevaluatWhere = noevaluatWhere.And(x => x.publisherId == _user.ID); |
| | | var noevaluat = await _coreCmsOrderServices.GetCountAsync(noevaluatWhere); |
| | | //已完成 |
| | | var completeWhere = _coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_COMPLETED); |
| | | completeWhere = completeWhere.And(x => x.publisherId == _user.ID); |
| | | var complete = await _coreCmsOrderServices.GetCountAsync(completeWhere); |
| | | //已取消 |
| | | var cancelWhere = _coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_CANCEL); |
| | | cancelWhere = cancelWhere.And(x => x.publisherId == _user.ID); |
| | | var cancel = await _coreCmsOrderServices.GetCountAsync(cancelWhere); |
| | | //删除 |
| | | var delete = await _coreCmsOrderServices.GetCountAsync(p => p.isdel == true && p.publisherId == _user.ID); |
| | | |
| | | |
| | | //订单状态说明 |
| | | var orderStatus = EnumHelper.EnumToList<GlobalEnumVars.OrderStatus>(); |
| | | //付款状态 |
| | | var payStatus = EnumHelper.EnumToList<GlobalEnumVars.OrderPayStatus>(); |
| | | //发货状态 |
| | | var shipStatus = EnumHelper.EnumToList<GlobalEnumVars.OrderShipStatus>(); |
| | | //订单来源 |
| | | var source = EnumHelper.EnumToList<GlobalEnumVars.Source>(); |
| | | //订单类型 |
| | | var orderType = EnumHelper.EnumToList<GlobalEnumVars.OrderType>(); |
| | | //订单支付方式 |
| | | var paymentCode = EnumHelper.EnumToList<GlobalEnumVars.PaymentsTypes>(); |
| | | //收货状态 |
| | | var confirmStatus = EnumHelper.EnumToList<GlobalEnumVars.OrderConfirmStatus>(); |
| | | //订单收货方式 |
| | | var receiptType = EnumHelper.EnumToList<GlobalEnumVars.OrderReceiptType>(); |
| | | |
| | | jm.data = new |
| | | { |
| | | all, |
| | | payment, |
| | | delivered, |
| | | receive, |
| | | evaluated, |
| | | noevaluat, |
| | | complete, |
| | | cancel, |
| | | delete, |
| | | orderStatus, |
| | | payStatus, |
| | | shipStatus, |
| | | orderType, |
| | | source, |
| | | paymentCode, |
| | | confirmStatus, |
| | | receiptType |
| | | }; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 编辑数据============================================================ |
| | | // POST: Api/OrderJingXiao/GetEdit |
| | | /// <summary> |
| | | /// 编辑数据 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetEdit([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var storeList = await _storeServices.QueryAsync(); |
| | | var result = await _coreCmsOrderServices.GetOrderInfoByOrderId(entity.id); |
| | | if (!result.status) |
| | | { |
| | | jm.msg = result.msg; |
| | | return jm; |
| | | } |
| | | //jm.code = 0; |
| | | jm.status = true; |
| | | jm.data = new |
| | | { |
| | | orderModel = result.data, |
| | | storeList |
| | | }; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 编辑提交============================================================ |
| | | // POST: Admins/OrderJingXiao/Edit |
| | | /// <summary> |
| | | /// 编辑提交 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoEdit([FromBody] AdminEditOrderPost entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var oldModel = await _coreCmsOrderServices.QueryByIdAsync(entity.orderId); |
| | | if (oldModel == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | //事物处理过程开始 |
| | | if (entity.editType == 1) |
| | | { |
| | | oldModel.shipName = entity.shipName; |
| | | oldModel.shipMobile = entity.shipMobile; |
| | | oldModel.shipAreaId = entity.shipAreaId; |
| | | oldModel.shipAddress = entity.shipAddress; |
| | | } |
| | | else if (entity.editType == 2) |
| | | { |
| | | oldModel.storeId = entity.storeId; |
| | | oldModel.shipName = entity.shipName; |
| | | oldModel.shipMobile = entity.shipMobile; |
| | | } |
| | | |
| | | if (oldModel.orderAmount != entity.orderAmount && entity.orderAmount > 0) |
| | | { |
| | | oldModel.orderAmount = entity.orderAmount; |
| | | } |
| | | //事物处理过程结束 |
| | | var bl = await _coreCmsOrderServices.UpdateAsync(oldModel); |
| | | //jm.code = bl ? 0 : 1; |
| | | jm.status = bl; |
| | | jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 发货============================================================ |
| | | // POST: Api/OrderJingXiao/GetShip |
| | | /// <summary> |
| | | /// 发货 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetShip([FromBody] FMArrayStringIds entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | if (entity.id.Length == 0) |
| | | { |
| | | jm.msg = "请选择需要发货的数据"; |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | |
| | | var storeList = await _storeServices.QueryAsync(); |
| | | |
| | | var logistics = await _logisticsServices.QueryListByClauseAsync(p => p.isDelete == false); |
| | | logistics.Add(new CoreCmsLogistics |
| | | { |
| | | id = int.MaxValue, |
| | | logiCode = "Distributor", |
| | | logiName = "校园代理配送", |
| | | sort = -1, |
| | | |
| | | }); |
| | | |
| | | logistics = logistics.OrderBy(x => x.sort).ToList(); |
| | | var deliveryCompany = await _weChatShippingDeliveryServices.GetCaChe(); |
| | | var result = await _coreCmsOrderServices.GetOrderShipInfo(entity.id); |
| | | if (!result.status) |
| | | { |
| | | jm.msg = result.msg; |
| | | return jm; |
| | | } |
| | | string lat = ""; |
| | | try |
| | | { |
| | | lat = (result.data as AdminOrderShipResult).Coordinate; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | lat = ""; |
| | | } |
| | | List<DistributorSort> Distributors = new List<DistributorSort>(); |
| | | if (!string.IsNullOrEmpty(lat)) |
| | | //走校园代理 |
| | | { |
| | | string[] latlist = lat.Split(','); |
| | | if (latlist.Length == 2) |
| | | { |
| | | try |
| | | { |
| | | var ProductsIds = await _bfbfServices.GetOderProductsIDs(entity.id); |
| | | Distributors = await _bfbfServices.GetDistributorsList(ProductsIds); |
| | | //Distributors = _bfbfServices.orderedDistributors(Distributors, latlist[0], latlist[1]); |
| | | |
| | | } |
| | | catch (Exception) |
| | | { |
| | | Distributors = new List<DistributorSort>(); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (storeList.Any()) |
| | | { |
| | | foreach (var store in storeList) |
| | | { |
| | | var getfullName = await _areaServices.GetAreaFullName(store.areaId); |
| | | if (getfullName.status) |
| | | { |
| | | store.allAddress = getfullName.data + store.address; |
| | | } |
| | | } |
| | | } |
| | | //jm.code = 0; |
| | | jm.status = true; |
| | | jm.msg = result.msg; |
| | | jm.data = new |
| | | { |
| | | orderModel = result.data, |
| | | deliveryCompany, |
| | | storeList, |
| | | logistics, |
| | | Distributors |
| | | }; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 发货提交============================================================ |
| | | // POST: Admins/OrderJingXiao/Edit |
| | | /// <summary> |
| | | /// 发货提交 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoShip([FromBody] AdminOrderShipPost entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | if (entity.logiCode == "Distributor") |
| | | //如果选择了校园代理发货 |
| | | { |
| | | if (entity.SendDistributionID == null && entity.SendDistributionID == 0) |
| | | { |
| | | //jm.code = 1; |
| | | jm.status = false; |
| | | jm.msg = "必须选择一个校园代理配送"; |
| | | return jm; |
| | | } |
| | | } |
| | | |
| | | |
| | | WebApiCallBack result; |
| | | if (entity.orderId.Contains(",")) |
| | | { |
| | | var ids = entity.orderId.Split(","); |
| | | result = await _coreCmsOrderServices.BatchShip(ids, entity.logiCode, entity.logiNo, entity.items, entity.shipName, entity.shipMobile, entity.shipAddress, entity.memo, entity.storeId, entity.shipAreaId, entity.deliveryCompanyId, entity.SendDistributionID); |
| | | |
| | | if (result.status) |
| | | { |
| | | var orderPaymentIds = await _billPaymentsServices.QueryListByClauseAsync(p => ids.Contains(p.sourceId) && p.paymentCode == GlobalEnumVars.PaymentsTypes.wechatpay.ToString() && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed); |
| | | if (orderPaymentIds.Any()) |
| | | { |
| | | //依次推入队列. |
| | | foreach (var item in orderPaymentIds) |
| | | { |
| | | //经销商发货不处理发货信息 是应该作为同城处理?还是不处理,需要运行时研究 |
| | | if (entity.logiCode != "Distributor") |
| | | await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayShipping, item.paymentId); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | result = await _coreCmsOrderServices.Ship(entity.orderId, entity.logiCode, entity.logiNo, entity.items, entity.shipName, entity.shipMobile, entity.shipAddress, entity.memo, entity.storeId, entity.shipAreaId, entity.deliveryCompanyId, entity.SendDistributionID); |
| | | |
| | | //微信发货信息管理API发货 |
| | | if (result.status && await _billPaymentsServices.QueryByClauseAsync(p => p.sourceId == entity.orderId && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed) is { } paymentInfo) |
| | | { |
| | | //经销商发货不处理发货信息 |
| | | if (entity.logiCode != "Distributor") |
| | | await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayShipping, paymentInfo.paymentId); |
| | | } |
| | | |
| | | } |
| | | |
| | | //jm.code = result.status ? 0 : 1; |
| | | jm.status = result.status; |
| | | jm.msg = result.msg; |
| | | jm.data = result.data; |
| | | jm.otherData = entity; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 秒发货============================================================ |
| | | // POST: Admins/OrderJingXiao/Edit |
| | | /// <summary> |
| | | /// 秒发货 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoSecondsShip([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var order = await _coreCmsOrderServices.QueryByIdAsync(entity.id); |
| | | if (order == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | |
| | | var goodItems = await _orderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id); |
| | | if (!goodItems.Any()) |
| | | { |
| | | jm.msg = "明细获取失败"; |
| | | return jm; |
| | | } |
| | | |
| | | Dictionary<int, int> items = new Dictionary<int, int>(); |
| | | |
| | | goodItems.ForEach(p => |
| | | { |
| | | items.Add(p.productId, p.nums); |
| | | }); |
| | | |
| | | var result = new WebApiCallBack(); |
| | | |
| | | if (order.receiptType == (int)GlobalEnumVars.OrderReceiptType.SelfDelivery) |
| | | { |
| | | result = await _coreCmsOrderServices.Ship(order.orderId, "shangmenziti", "无", items, order.shipName, order.shipMobile, order.shipAddress, order.memo, order.storeId, order.shipAreaId, "OTHERS"); |
| | | } |
| | | else if (order.receiptType == (int)GlobalEnumVars.OrderReceiptType.IntraCityService) |
| | | { |
| | | result = await _coreCmsOrderServices.Ship(order.orderId, "benditongcheng", "无", items, order.shipName, order.shipMobile, order.shipAddress, order.memo, order.storeId, order.shipAreaId, "OTHERS"); |
| | | } |
| | | |
| | | //微信发货信息管理API发货 |
| | | if (result.status && await _billPaymentsServices.QueryByClauseAsync(p => p.sourceId == order.orderId && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed) is { } paymentInfo) |
| | | { |
| | | await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayShipping, paymentInfo.paymentId); |
| | | } |
| | | |
| | | //jm.code = result.status ? 0 : 1; |
| | | jm.status = result.status; |
| | | jm.msg = result.msg; |
| | | jm.data = result.data; |
| | | jm.otherData = entity; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 支付============================================================ |
| | | // POST: Api/OrderJingXiao/GetPay |
| | | /// <summary> |
| | | /// 支付 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetPay([FromBody] FMArrayStringIds entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var type = entity.data.ObjectToInt(); |
| | | if (type == 0 || entity.id.Length == 0) |
| | | { |
| | | jm.msg = "请提交合法的数据"; |
| | | return jm; |
| | | } |
| | | |
| | | var result = await _billPaymentsServices.BatchFormatPaymentRel(entity.id, type, null); |
| | | if (result.status == false) |
| | | { |
| | | jm.msg = result.msg; |
| | | jm.data = result.data; |
| | | return jm; |
| | | } |
| | | //取支付方式 |
| | | var payments = await _paymentsServices.QueryListByClauseAsync(p => p.isEnable, p => p.sort, OrderByType.Asc); |
| | | //jm.code = 0; |
| | | jm.status = true; |
| | | jm.msg = "获取数据成功"; |
| | | jm.data = new |
| | | { |
| | | orderId = entity.id, |
| | | type = entity.data, |
| | | payments, |
| | | rel = result.data |
| | | }; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 提交支付============================================================ |
| | | // POST: Admins/OrderJingXiao/DoToPay |
| | | /// <summary> |
| | | /// 提交支付 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoToPay([FromBody] AdminOrderDoPayPost entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | //事物处理过程结束 |
| | | var ids = entity.orderId.Split(","); |
| | | var result = await _billPaymentsServices.ToPay(entity.orderId, entity.type, entity.paymentCode); |
| | | |
| | | //jm.code = result.status ? 0 : 1; |
| | | jm.status = result.status; |
| | | jm.msg = result.msg; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 删除数据============================================================ |
| | | // POST: Api/OrderJingXiao/DoDelete/10 |
| | | /// <summary> |
| | | /// 单选删除 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoDelete([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var model = await _coreCmsOrderServices.QueryByIdAsync(entity.id); |
| | | if (model == null) |
| | | { |
| | | jm.msg = GlobalConstVars.DataisNo; |
| | | return jm; |
| | | } |
| | | //假删除 |
| | | var bl = await _coreCmsOrderServices.UpdateAsync(p => new CoreCmsOrder() { isdel = true }, p => p.orderId == model.orderId); |
| | | //jm.code = bl ? 0 : 1; |
| | | jm.status = bl; |
| | | jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; |
| | | return jm; |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 还原订单============================================================ |
| | | // POST: Api/OrderJingXiao/DoRestore/10 |
| | | /// <summary> |
| | | /// 还原订单 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoRestore([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var model = await _coreCmsOrderServices.QueryByIdAsync(entity.id); |
| | | if (model == null) |
| | | { |
| | | jm.msg = GlobalConstVars.DataisNo; |
| | | return jm; |
| | | } |
| | | //还原 |
| | | var bl = await _coreCmsOrderServices.UpdateAsync(p => new CoreCmsOrder() { isdel = false }, p => p.orderId == model.orderId); |
| | | //jm.code = bl ? 0 : 1; |
| | | jm.status = bl; |
| | | jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; |
| | | return jm; |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 判断是否存在售后============================================================ |
| | | // POST: Api/OrderJingXiao/GetDoHaveAfterSale/10 |
| | | /// <summary> |
| | | /// 判断是否存在售后 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetDoHaveAfterSale([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | //等待售后审核的订单,不自动操作完成。 |
| | | var billAftersalesCount = await _aftersalesServices.GetCountAsync(p => p.orderId == entity.id && p.status == (int)GlobalEnumVars.BillAftersalesStatus.WaitAudit); |
| | | |
| | | bool bl = billAftersalesCount > 0; |
| | | |
| | | //jm.code = bl ? 0 : 1; |
| | | jm.status = bl; |
| | | jm.msg = "存在未处理的售后"; |
| | | |
| | | return jm; |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 完成订单============================================================ |
| | | // POST: Api/OrderJingXiao/DoComplete/10 |
| | | /// <summary> |
| | | /// 完成订单 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoComplete([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var result = await _coreCmsOrderServices.CompleteOrder(entity.id); |
| | | //jm.code = result.status ? 0 : 1; |
| | | jm.status = result.status; |
| | | jm.msg = result.msg; |
| | | jm.data = result.data; |
| | | jm.otherData = result.otherData; |
| | | |
| | | return jm; |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 预览数据============================================================ |
| | | // POST: Api/OrderJingXiao/GetDetails/10 |
| | | /// <summary> |
| | | /// 预览数据 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetDetails([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var result = await _coreCmsOrderServices.GetOrderInfoByOrderId(entity.id); |
| | | if (result == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | //jm.code = result.status ? 0 : 1; |
| | | jm.status = result.status; |
| | | jm.data = result.data; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 重打小票============================================================ |
| | | // POST: Api/OrderJingXiao/GetPrintTpl/10 |
| | | /// <summary> |
| | | /// 重打小票 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetPrintCloud([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var order = await _coreCmsOrderServices.QueryByClauseAsync(p => p.orderId == entity.id); |
| | | if (order == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | |
| | | //易联云打印机打印 |
| | | await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.OrderPrint, JsonConvert.SerializeObject(order)); |
| | | |
| | | //jm.code = 0; |
| | | jm.status = true; |
| | | jm.msg = "提交打印队列成功"; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 订单打印============================================================ |
| | | // POST: Api/OrderJingXiao/GetPrintTpl/10 |
| | | /// <summary> |
| | | /// 订单打印 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetPrintTpl([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var result = await _coreCmsOrderServices.GetOrderInfoByOrderId(entity.id); |
| | | if (result == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | //jm.code = result.status ? 0 : 1; |
| | | jm.status = result.status; |
| | | var CmsOrder = result.data as CoreCmsOrder; |
| | | if (CmsOrder == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | //剔除经销商取消的物流信息 |
| | | CmsOrder.delivery = CmsOrder.delivery.Where(x => x.logiCode != "Distributor" || (x.logiCode == "Distributor" && x.sendDistributionAccept == sendDistributionAcceptType.Accepted)).ToList(); |
| | | |
| | | |
| | | var allConfigs = await _settingServices.GetConfigDictionaries(); |
| | | |
| | | var shopName = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShopName); |
| | | var shopMobile = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShopMobile); |
| | | |
| | | jm.data = new |
| | | { |
| | | order = result.data, |
| | | shopName, |
| | | shopMobile |
| | | }; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 选择导出============================================================ |
| | | // POST: Api/OrderJingXiao/SelectExportExcel/10 |
| | | /// <summary> |
| | | /// 选择导出 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> SelectExportExcel([FromBody] FMArrayStringIds entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | if (entity.id.Length == 0) |
| | | { |
| | | jm.msg = "请选择要导出的数据"; |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | //获取数据 |
| | | var list = await _coreCmsOrderServices.QueryListAsync(p => entity.id.Contains(p.orderId), p => p.createTime, OrderByType.Desc); |
| | | if (list != null && list.Any()) |
| | | { |
| | | var areaCache = await _areaServices.GetCaChe(); |
| | | foreach (var item in list) |
| | | { |
| | | //item.operating = _coreCmsOrderServices.GetOperating(item.orderId, item.status, item.payStatus, item.shipStatus, item.isdel); |
| | | //item.afterSaleStatus = ""; |
| | | //if (item.aftersalesItem != null && item.aftersalesItem.Any()) |
| | | //{ |
| | | // foreach (var sale in item.aftersalesItem) |
| | | // { |
| | | // item.afterSaleStatus += EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.BillAftersalesStatus>(sale.status) + "<br>"; |
| | | // } |
| | | //} |
| | | var areas = await _areaServices.GetAreaFullName(item.shipAreaId, areaCache); |
| | | item.shipAreaName = areas.status ? areas.data + "-" + item.shipAddress : item.shipAddress; |
| | | } |
| | | } |
| | | |
| | | |
| | | //订单状态说明 |
| | | var orderStatusEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderStatusDescription>(); |
| | | //付款状态 |
| | | var orderPayStatusEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderPayStatus>(); |
| | | //发货状态 |
| | | var shipStatusEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderShipStatus>(); |
| | | //订单来源 |
| | | var sourceEntities = EnumHelper.EnumToList<GlobalEnumVars.Source>(); |
| | | //订单类型 |
| | | var orderTypeEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderType>(); |
| | | //订单支付方式 |
| | | var paymentsTypesEntities = EnumHelper.EnumToList<GlobalEnumVars.PaymentsTypes>(); |
| | | //收货状态 |
| | | var orderConfirmStatusEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderConfirmStatus>(); |
| | | //订单收货方式 |
| | | var orderReceiptTypeEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderReceiptType>(); |
| | | |
| | | |
| | | //获取数据 |
| | | //创建Excel文件的对象 |
| | | var book = new HSSFWorkbook(); |
| | | //添加一个sheet |
| | | var sheet1 = book.CreateSheet("Sheet1"); |
| | | |
| | | //获取list数据 |
| | | //给sheet1添加第一行的头部标题 |
| | | var row1 = sheet1.CreateRow(0); |
| | | |
| | | var items = new List<CellValueItem>(); |
| | | items.Add(new CellValueItem() { name = "序号", width = 10 }); |
| | | items.Add(new CellValueItem() { name = "订单号", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "商品总价", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "支付金额", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "订单总额", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "支付状态", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "发货状态", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "订单状态", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "订单类型", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "支付方式", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "支付时间", width = 20 }); |
| | | |
| | | items.Add(new CellValueItem() { name = "货品名称", width = 50 }); |
| | | items.Add(new CellValueItem() { name = "数量", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "单价", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "优惠", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "合计", width = 12 }); |
| | | |
| | | |
| | | items.Add(new CellValueItem() { name = "收货人姓名", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "收货电话", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "收货详细地址", width = 80 }); |
| | | |
| | | |
| | | items.Add(new CellValueItem() { name = "配送方式名称", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "配送费用", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "用户ID", width = 12 }); |
| | | |
| | | items.Add(new CellValueItem() { name = "是否收货", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "确认收货时间", width = 20 }); |
| | | |
| | | |
| | | items.Add(new CellValueItem() { name = "商品总重量", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "是否开发票", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "税号", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "发票抬头", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "使用积分", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "积分抵扣金额", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "订单优惠金额", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "商品优惠金额", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "优惠券优惠额度", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "优惠券信息", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "优惠信息", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "买家备注", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "下单IP", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "卖家备注", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "订单来源", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "是否评论", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "删除标志", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "订单时间", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "更新时间", width = 20 }); |
| | | |
| | | var headerStyle = ExcelHelper.GetHeaderStyle(book); |
| | | |
| | | for (int i = 0; i < items.Count; i++) |
| | | { |
| | | var cell = row1.CreateCell(i); |
| | | cell.SetCellValue(items[i].name); |
| | | cell.CellStyle = headerStyle; |
| | | sheet1.SetColumnWidth(i, items[i].width * 256); |
| | | } |
| | | |
| | | row1.Height = 30 * 20; |
| | | |
| | | var commonCellStyle = ExcelHelper.GetCommonStyle(book); |
| | | |
| | | |
| | | var detailsStartNumber = 0; |
| | | var listStartNumber = 0; |
| | | foreach (var order in list) |
| | | { |
| | | listStartNumber++; |
| | | //当前开始行 |
| | | var nowNumber = detailsStartNumber; |
| | | //将数据逐步写入sheet1各个行 |
| | | foreach (var t in order.items) |
| | | { |
| | | var rowTemp = sheet1.CreateRow(detailsStartNumber + 1); |
| | | |
| | | rowTemp.CreateCell(0).SetCellValue(listStartNumber); |
| | | rowTemp.CreateCell(1).SetCellValue(order.orderId); |
| | | rowTemp.CreateCell(2).SetCellValue(order.goodsAmount.ToString()); |
| | | rowTemp.CreateCell(3).SetCellValue(order.payedAmount.ToString()); |
| | | rowTemp.CreateCell(4).SetCellValue(order.orderAmount.ToString()); |
| | | |
| | | var payModel = orderPayStatusEntities.Find(p => p.value == order.payStatus); |
| | | rowTemp.CreateCell(5).SetCellValue(payModel != null ? payModel.description : ""); |
| | | |
| | | var shipStatusModel = shipStatusEntities.Find(p => p.value == order.shipStatus); |
| | | rowTemp.CreateCell(6).SetCellValue(shipStatusModel != null ? shipStatusModel.description : ""); |
| | | |
| | | var statusModel = orderStatusEntities.Find(p => p.value == order.status); |
| | | rowTemp.CreateCell(7).SetCellValue(statusModel != null ? statusModel.description : ""); |
| | | |
| | | var orderTypeModel = orderTypeEntities.Find(p => p.value == order.orderType); |
| | | rowTemp.CreateCell(8).SetCellValue(orderTypeModel != null ? orderTypeModel.description : ""); |
| | | |
| | | var paymentCodeModel = paymentsTypesEntities.Find(p => p.title == order.paymentCode); |
| | | rowTemp.CreateCell(9).SetCellValue(paymentCodeModel != null ? paymentCodeModel.description : ""); |
| | | |
| | | rowTemp.CreateCell(10).SetCellValue(order.paymentTime.ToString()); |
| | | |
| | | |
| | | rowTemp.CreateCell(11).SetCellValue(!string.IsNullOrEmpty(t.addon) ? t.name + "【" + t.goodsId + "】规格:" + t.addon : "【" + t.goodsId + "】" + t.name); |
| | | rowTemp.CreateCell(12).SetCellValue(t.nums); |
| | | rowTemp.CreateCell(13).SetCellValue(t.price + "元"); |
| | | rowTemp.CreateCell(14).SetCellValue(t.promotionAmount + "元"); |
| | | rowTemp.CreateCell(15).SetCellValue(t.amount + "元"); |
| | | |
| | | |
| | | rowTemp.CreateCell(16).SetCellValue(order.shipName); |
| | | rowTemp.CreateCell(17).SetCellValue(order.shipMobile); |
| | | rowTemp.CreateCell(18).SetCellValue(order.shipAreaName); |
| | | |
| | | rowTemp.CreateCell(19).SetCellValue(!string.IsNullOrEmpty(order.logisticsName) ? order.logisticsName : "自提配送"); |
| | | rowTemp.CreateCell(20).SetCellValue(order.costFreight.ToString()); |
| | | rowTemp.CreateCell(21).SetCellValue(order.userId.ToString()); |
| | | |
| | | var confirmStatusModel = orderConfirmStatusEntities.Find(p => p.value == order.confirmStatus); |
| | | rowTemp.CreateCell(22).SetCellValue(confirmStatusModel != null ? confirmStatusModel.description : ""); |
| | | |
| | | rowTemp.CreateCell(23).SetCellValue(order.confirmTime.ToString()); |
| | | |
| | | rowTemp.CreateCell(24).SetCellValue(order.weight.ToString()); |
| | | rowTemp.CreateCell(25).SetCellValue(order.taxType.ToString()); |
| | | rowTemp.CreateCell(26).SetCellValue(order.taxCode); |
| | | rowTemp.CreateCell(27).SetCellValue(order.taxTitle); |
| | | rowTemp.CreateCell(28).SetCellValue(order.point.ToString()); |
| | | rowTemp.CreateCell(29).SetCellValue(order.pointMoney.ToString()); |
| | | rowTemp.CreateCell(30).SetCellValue(order.orderDiscountAmount.ToString()); |
| | | rowTemp.CreateCell(31).SetCellValue(order.goodsDiscountAmount.ToString()); |
| | | rowTemp.CreateCell(32).SetCellValue(order.couponDiscountAmount.ToString()); |
| | | rowTemp.CreateCell(33).SetCellValue(order.coupon); |
| | | rowTemp.CreateCell(34).SetCellValue(order.promotionList); |
| | | rowTemp.CreateCell(35).SetCellValue(order.memo); |
| | | rowTemp.CreateCell(36).SetCellValue(order.ip); |
| | | rowTemp.CreateCell(37).SetCellValue(order.mark); |
| | | rowTemp.CreateCell(38).SetCellValue(order.source.ToString()); |
| | | rowTemp.CreateCell(39).SetCellValue(order.isComment.ToString()); |
| | | rowTemp.CreateCell(40).SetCellValue(order.isdel.ToString()); |
| | | rowTemp.CreateCell(41).SetCellValue(order.createTime.ToString()); |
| | | rowTemp.CreateCell(42).SetCellValue(order.updateTime.ToString()); |
| | | |
| | | |
| | | rowTemp.Cells.ForEach(p => |
| | | { |
| | | p.CellStyle = commonCellStyle; |
| | | }); |
| | | rowTemp.Height = 20 * 20; |
| | | |
| | | |
| | | detailsStartNumber++; |
| | | } |
| | | //合并单元格(第几行,到第几行,第几列,到第几列) |
| | | |
| | | var marId = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 }; |
| | | if (order.items.Count <= 1) continue; |
| | | foreach (var id in marId) |
| | | { |
| | | sheet1.AddMergedRegion(new CellRangeAddress(nowNumber + 1, detailsStartNumber, id, id)); |
| | | } |
| | | } |
| | | |
| | | // 写入到excel |
| | | string webRootPath = _webHostEnvironment.WebRootPath; |
| | | string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; |
| | | string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-订单导出(选择结果).xls"; |
| | | string filePath = webRootPath + tpath; |
| | | DirectoryInfo di = new DirectoryInfo(filePath); |
| | | if (!di.Exists) |
| | | { |
| | | di.Create(); |
| | | } |
| | | FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create); |
| | | book.Write(fileHssf); |
| | | fileHssf.Close(); |
| | | |
| | | //jm.code = 0; |
| | | jm.status = true; |
| | | jm.msg = GlobalConstVars.ExcelExportSuccess; |
| | | jm.data = tpath + fileName; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 查询导出============================================================ |
| | | // POST: Api/OrderJingXiao/QueryExportExcel/10 |
| | | /// <summary> |
| | | /// 查询导出 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> QueryExportExcel() |
| | | { |
| | | |
| | | var jm = new WebApiCallBack(); |
| | | var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1); |
| | | var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30); |
| | | var where = PredicateBuilder.True<CoreCmsOrder>(); |
| | | //获取排序字段 |
| | | |
| | | //订单号 nvarchar |
| | | var orderId = Request.Form["orderId"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(orderId)) |
| | | { |
| | | where = where.And(p => p.orderId.Contains(orderId)); |
| | | } |
| | | |
| | | //订单状态 int |
| | | var status = Request.Form["status"].FirstOrDefault().ObjectToInt(0); |
| | | if (status > 0) |
| | | { |
| | | where = where.And(p => p.status == status); |
| | | } |
| | | //订单类型 int |
| | | var orderType = Request.Form["orderType"].FirstOrDefault().ObjectToInt(0); |
| | | if (orderType > 0) |
| | | { |
| | | where = where.And(p => p.orderType == orderType); |
| | | } |
| | | //发货状态 int |
| | | var shipStatus = Request.Form["shipStatus"].FirstOrDefault().ObjectToInt(0); |
| | | if (shipStatus > 0) |
| | | { |
| | | where = where.And(p => p.shipStatus == shipStatus); |
| | | } |
| | | //支付状态 int |
| | | var payStatus = Request.Form["payStatus"].FirstOrDefault().ObjectToInt(0); |
| | | if (payStatus > 0) |
| | | { |
| | | where = where.And(p => p.payStatus == payStatus); |
| | | } |
| | | //支付方式代码 nvarchar |
| | | var paymentCode = Request.Form["paymentCode"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(paymentCode)) |
| | | { |
| | | where = where.And(p => p.paymentCode.Contains(paymentCode)); |
| | | } |
| | | //售后状态 int |
| | | var confirmStatus = Request.Form["confirmStatus"].FirstOrDefault().ObjectToInt(0); |
| | | if (confirmStatus > 0) |
| | | { |
| | | where = where.And(p => p.confirmStatus == confirmStatus); |
| | | } |
| | | //订单来源 int |
| | | var source = Request.Form["source"].FirstOrDefault().ObjectToInt(0); |
| | | if (source > 0) |
| | | { |
| | | where = where.And(p => p.source == source); |
| | | } |
| | | //收货方式 int |
| | | var receiptType = Request.Form["receiptType"].FirstOrDefault().ObjectToInt(0); |
| | | if (receiptType > 0) |
| | | { |
| | | where = where.And(p => p.receiptType == receiptType); |
| | | } |
| | | |
| | | //收货人姓名 nvarchar |
| | | var shipName = Request.Form["shipName"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(shipName)) |
| | | { |
| | | where = where.And(p => p.shipName.Contains(shipName)); |
| | | } |
| | | //收货人地址 nvarchar |
| | | var shipAddress = Request.Form["shipAddress"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(shipAddress)) |
| | | { |
| | | where = where.And(p => p.shipAddress.Contains(shipAddress)); |
| | | } |
| | | |
| | | //收货电话 nvarchar |
| | | var shipMobile = Request.Form["shipMobile"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(shipMobile)) |
| | | { |
| | | where = where.And(p => p.shipMobile.Contains(shipMobile)); |
| | | } |
| | | |
| | | //付款单号 nvarchar |
| | | var paymentId = Request.Form["paymentId"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(paymentId)) |
| | | { |
| | | where = where.And(p => p.shipMobile.Contains(paymentId)); |
| | | } |
| | | |
| | | // datetime |
| | | var createTime = Request.Form["createTime"].FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(createTime)) |
| | | { |
| | | if (createTime.Contains("到")) |
| | | { |
| | | var dts = createTime.Split("到"); |
| | | var dtStart = dts[0].Trim().ObjectToDate(); |
| | | where = where.And(p => p.createTime > dtStart); |
| | | var dtEnd = dts[1].Trim().ObjectToDate(); |
| | | where = where.And(p => p.createTime < dtEnd); |
| | | } |
| | | else |
| | | { |
| | | var dt = createTime.ObjectToDate(); |
| | | where = where.And(p => p.createTime > dt); |
| | | } |
| | | } |
| | | |
| | | |
| | | //订单状态 int |
| | | var orderUnifiedStatus = ObjectExtensions.ObjectToInt(Request.Form["orderUnifiedStatus"].FirstOrDefault(), 0); |
| | | if (orderUnifiedStatus > 0) |
| | | { |
| | | if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.payment) |
| | | { |
| | | //待支付 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_PAYMENT)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.delivered) |
| | | { |
| | | //待发货 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_DELIVERY)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.receive) |
| | | { |
| | | //待收货 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_RECEIPT)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.evaluated) |
| | | { |
| | | //已评价 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_COMPLETED_EVALUATE)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.noevaluat) |
| | | { |
| | | //待评价 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_PENDING_EVALUATE)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.complete) |
| | | { |
| | | //已完成 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_COMPLETED)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.cancel) |
| | | { |
| | | //已取消 |
| | | where = where.And(_coreCmsOrderServices.GetReverseStatus((int)GlobalEnumVars.OrderAllStatusType.ALL_CANCEL)); |
| | | } |
| | | else if (orderUnifiedStatus == (int)GlobalEnumVars.OrderCountType.delete) |
| | | { |
| | | //已取消 |
| | | where = where.And(p => p.isdel == true); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | where = where.And(p => p.isdel == false); |
| | | } |
| | | |
| | | //获取数据 |
| | | var list = await _coreCmsOrderServices.QueryListAsync(where, p => p.createTime, OrderByType.Desc); |
| | | if (list != null && list.Any()) |
| | | { |
| | | var areaCache = await _areaServices.GetCaChe(); |
| | | foreach (var item in list) |
| | | { |
| | | //item.operating = _coreCmsOrderServices.GetOperating(item.orderId, item.status, item.payStatus, item.shipStatus, item.isdel); |
| | | //item.afterSaleStatus = ""; |
| | | //if (item.aftersalesItem != null && item.aftersalesItem.Any()) |
| | | //{ |
| | | // foreach (var sale in item.aftersalesItem) |
| | | // { |
| | | // item.afterSaleStatus += EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.BillAftersalesStatus>(sale.status) + "<br>"; |
| | | // } |
| | | //} |
| | | var areas = await _areaServices.GetAreaFullName(item.shipAreaId, areaCache); |
| | | item.shipAreaName = areas.status ? areas.data + "-" + item.shipAddress : item.shipAddress; |
| | | } |
| | | } |
| | | |
| | | |
| | | //订单状态说明 |
| | | var orderStatusEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderStatusDescription>(); |
| | | //付款状态 |
| | | var orderPayStatusEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderPayStatus>(); |
| | | //发货状态 |
| | | var shipStatusEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderShipStatus>(); |
| | | //订单来源 |
| | | var sourceEntities = EnumHelper.EnumToList<GlobalEnumVars.Source>(); |
| | | //订单类型 |
| | | var orderTypeEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderType>(); |
| | | //订单支付方式 |
| | | var paymentsTypesEntities = EnumHelper.EnumToList<GlobalEnumVars.PaymentsTypes>(); |
| | | //收货状态 |
| | | var orderConfirmStatusEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderConfirmStatus>(); |
| | | //订单收货方式 |
| | | var orderReceiptTypeEntities = EnumHelper.EnumToList<GlobalEnumVars.OrderReceiptType>(); |
| | | |
| | | |
| | | //获取数据 |
| | | //创建Excel文件的对象 |
| | | var book = new HSSFWorkbook(); |
| | | //添加一个sheet |
| | | var sheet1 = book.CreateSheet("Sheet1"); |
| | | |
| | | //获取list数据 |
| | | //给sheet1添加第一行的头部标题 |
| | | var row1 = sheet1.CreateRow(0); |
| | | |
| | | var items = new List<CellValueItem>(); |
| | | items.Add(new CellValueItem() { name = "序号", width = 10 }); |
| | | items.Add(new CellValueItem() { name = "订单号", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "商品总价", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "支付金额", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "订单总额", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "支付状态", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "发货状态", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "订单状态", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "订单类型", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "支付方式", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "支付时间", width = 20 }); |
| | | |
| | | items.Add(new CellValueItem() { name = "货品名称", width = 50 }); |
| | | items.Add(new CellValueItem() { name = "数量", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "单价", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "优惠", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "合计", width = 12 }); |
| | | |
| | | |
| | | items.Add(new CellValueItem() { name = "收货人姓名", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "收货电话", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "收货详细地址", width = 80 }); |
| | | |
| | | |
| | | items.Add(new CellValueItem() { name = "配送方式名称", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "配送费用", width = 12 }); |
| | | items.Add(new CellValueItem() { name = "用户ID", width = 12 }); |
| | | |
| | | items.Add(new CellValueItem() { name = "是否收货", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "确认收货时间", width = 20 }); |
| | | |
| | | |
| | | items.Add(new CellValueItem() { name = "商品总重量", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "是否开发票", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "税号", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "发票抬头", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "使用积分", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "积分抵扣金额", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "订单优惠金额", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "商品优惠金额", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "优惠券优惠额度", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "优惠券信息", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "优惠信息", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "买家备注", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "下单IP", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "卖家备注", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "订单来源", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "是否评论", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "删除标志", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "订单时间", width = 20 }); |
| | | items.Add(new CellValueItem() { name = "更新时间", width = 20 }); |
| | | |
| | | var headerStyle = ExcelHelper.GetHeaderStyle(book); |
| | | |
| | | for (int i = 0; i < items.Count; i++) |
| | | { |
| | | var cell = row1.CreateCell(i); |
| | | cell.SetCellValue(items[i].name); |
| | | cell.CellStyle = headerStyle; |
| | | sheet1.SetColumnWidth(i, items[i].width * 256); |
| | | } |
| | | |
| | | row1.Height = 30 * 20; |
| | | |
| | | var commonCellStyle = ExcelHelper.GetCommonStyle(book); |
| | | |
| | | |
| | | var detailsStartNumber = 0; |
| | | var listStartNumber = 0; |
| | | foreach (var order in list) |
| | | { |
| | | listStartNumber++; |
| | | //当前开始行 |
| | | var nowNumber = detailsStartNumber; |
| | | //将数据逐步写入sheet1各个行 |
| | | foreach (var t in order.items) |
| | | { |
| | | var rowTemp = sheet1.CreateRow(detailsStartNumber + 1); |
| | | |
| | | rowTemp.CreateCell(0).SetCellValue(listStartNumber); |
| | | rowTemp.CreateCell(1).SetCellValue(order.orderId); |
| | | rowTemp.CreateCell(2).SetCellValue(order.goodsAmount.ToString()); |
| | | rowTemp.CreateCell(3).SetCellValue(order.payedAmount.ToString()); |
| | | rowTemp.CreateCell(4).SetCellValue(order.orderAmount.ToString()); |
| | | |
| | | var payModel = orderPayStatusEntities.Find(p => p.value == order.payStatus); |
| | | rowTemp.CreateCell(5).SetCellValue(payModel != null ? payModel.description : ""); |
| | | |
| | | var shipStatusModel = shipStatusEntities.Find(p => p.value == order.shipStatus); |
| | | rowTemp.CreateCell(6).SetCellValue(shipStatusModel != null ? shipStatusModel.description : ""); |
| | | |
| | | var statusModel = orderStatusEntities.Find(p => p.value == order.status); |
| | | rowTemp.CreateCell(7).SetCellValue(statusModel != null ? statusModel.description : ""); |
| | | |
| | | var orderTypeModel = orderTypeEntities.Find(p => p.value == order.orderType); |
| | | rowTemp.CreateCell(8).SetCellValue(orderTypeModel != null ? orderTypeModel.description : ""); |
| | | |
| | | var paymentCodeModel = paymentsTypesEntities.Find(p => p.title == order.paymentCode); |
| | | rowTemp.CreateCell(9).SetCellValue(paymentCodeModel != null ? paymentCodeModel.description : ""); |
| | | |
| | | rowTemp.CreateCell(10).SetCellValue(order.paymentTime.ToString()); |
| | | |
| | | |
| | | rowTemp.CreateCell(11).SetCellValue(!string.IsNullOrEmpty(t.addon) ? t.name + "【" + t.goodsId + "】规格:" + t.addon : "【" + t.goodsId + "】" + t.name); |
| | | rowTemp.CreateCell(12).SetCellValue(t.nums); |
| | | rowTemp.CreateCell(13).SetCellValue(t.price + "元"); |
| | | rowTemp.CreateCell(14).SetCellValue(t.promotionAmount + "元"); |
| | | rowTemp.CreateCell(15).SetCellValue(t.amount + "元"); |
| | | |
| | | |
| | | rowTemp.CreateCell(16).SetCellValue(order.shipName); |
| | | rowTemp.CreateCell(17).SetCellValue(order.shipMobile); |
| | | rowTemp.CreateCell(18).SetCellValue(order.shipAreaName); |
| | | |
| | | rowTemp.CreateCell(19).SetCellValue(!string.IsNullOrEmpty(order.logisticsName) ? order.logisticsName : "自提配送"); |
| | | rowTemp.CreateCell(20).SetCellValue(order.costFreight.ToString()); |
| | | rowTemp.CreateCell(21).SetCellValue(order.userId.ToString()); |
| | | |
| | | var confirmStatusModel = orderConfirmStatusEntities.Find(p => p.value == order.confirmStatus); |
| | | rowTemp.CreateCell(22).SetCellValue(confirmStatusModel != null ? confirmStatusModel.description : ""); |
| | | |
| | | rowTemp.CreateCell(23).SetCellValue(order.confirmTime.ToString()); |
| | | |
| | | rowTemp.CreateCell(24).SetCellValue(order.weight.ToString()); |
| | | rowTemp.CreateCell(25).SetCellValue(order.taxType.ToString()); |
| | | rowTemp.CreateCell(26).SetCellValue(order.taxCode); |
| | | rowTemp.CreateCell(27).SetCellValue(order.taxTitle); |
| | | rowTemp.CreateCell(28).SetCellValue(order.point.ToString()); |
| | | rowTemp.CreateCell(29).SetCellValue(order.pointMoney.ToString()); |
| | | rowTemp.CreateCell(30).SetCellValue(order.orderDiscountAmount.ToString()); |
| | | rowTemp.CreateCell(31).SetCellValue(order.goodsDiscountAmount.ToString()); |
| | | rowTemp.CreateCell(32).SetCellValue(order.couponDiscountAmount.ToString()); |
| | | rowTemp.CreateCell(33).SetCellValue(order.coupon); |
| | | rowTemp.CreateCell(34).SetCellValue(order.promotionList); |
| | | rowTemp.CreateCell(35).SetCellValue(order.memo); |
| | | rowTemp.CreateCell(36).SetCellValue(order.ip); |
| | | rowTemp.CreateCell(37).SetCellValue(order.mark); |
| | | rowTemp.CreateCell(38).SetCellValue(order.source.ToString()); |
| | | rowTemp.CreateCell(39).SetCellValue(order.isComment.ToString()); |
| | | rowTemp.CreateCell(40).SetCellValue(order.isdel.ToString()); |
| | | rowTemp.CreateCell(41).SetCellValue(order.createTime.ToString()); |
| | | rowTemp.CreateCell(42).SetCellValue(order.updateTime.ToString()); |
| | | |
| | | |
| | | rowTemp.Cells.ForEach(p => |
| | | { |
| | | p.CellStyle = commonCellStyle; |
| | | }); |
| | | rowTemp.Height = 20 * 20; |
| | | |
| | | |
| | | detailsStartNumber++; |
| | | } |
| | | //合并单元格(第几行,到第几行,第几列,到第几列) |
| | | var marId = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 }; |
| | | if (order.items.Count <= 1) continue; |
| | | foreach (var id in marId) |
| | | { |
| | | sheet1.AddMergedRegion(new CellRangeAddress(nowNumber + 1, detailsStartNumber, id, id)); |
| | | } |
| | | } |
| | | |
| | | // 写入到excel |
| | | string webRootPath = _webHostEnvironment.WebRootPath; |
| | | string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; |
| | | string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-订单导出(查询结果).xls"; |
| | | string filePath = webRootPath + tpath; |
| | | DirectoryInfo di = new DirectoryInfo(filePath); |
| | | if (!di.Exists) |
| | | { |
| | | di.Create(); |
| | | } |
| | | FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create); |
| | | book.Write(fileHssf); |
| | | fileHssf.Close(); |
| | | |
| | | //jm.code = 0; |
| | | jm.status = true; |
| | | jm.msg = GlobalConstVars.ExcelExportSuccess; |
| | | jm.data = tpath + fileName; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 设置是否开发票============================================================ |
| | | // POST: Api/OrderJingXiao/DoSettaxType/10 |
| | | /// <summary> |
| | | /// 设置是否开发票 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoSettaxType([FromBody] FMUpdateIntegerDataByIntId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var oldModel = await _coreCmsOrderServices.QueryByIdAsync(entity.id); |
| | | if (oldModel == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | oldModel.taxType = entity.data; |
| | | |
| | | var bl = await _coreCmsOrderServices.UpdateAsync(oldModel); |
| | | //jm.code = bl ? 0 : 1; |
| | | jm.status = bl; |
| | | jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 设置是否评论============================================================ |
| | | // POST: Api/OrderJingXiao/DoSetisComment/10 |
| | | /// <summary> |
| | | /// 设置是否评论 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoSetisComment([FromBody] FMUpdateBoolDataByIntId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var oldModel = await _coreCmsOrderServices.QueryByIdAsync(entity.id); |
| | | if (oldModel == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | oldModel.isComment = (bool)entity.data; |
| | | |
| | | var bl = await _coreCmsOrderServices.UpdateAsync(oldModel); |
| | | //jm.code = bl ? 0 : 1; |
| | | jm.status = bl; |
| | | jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 更新备注============================================================ |
| | | // POST: Api/OrderJingXiao/DoSetisdel/10 |
| | | /// <summary> |
| | | /// 更新备注 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DoUpdateMark([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var oldModel = await _coreCmsOrderServices.QueryByIdAsync(entity.id); |
| | | if (oldModel == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | oldModel.mark = entity.data.ToString(); |
| | | var bl = await _coreCmsOrderServices.UpdateAsync(p => new CoreCmsOrder() { mark = oldModel.mark }, p => p.orderId == oldModel.orderId); |
| | | //jm.code = bl ? 0 : 1; |
| | | jm.status = bl; |
| | | jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 取消订单============================================================ |
| | | // POST: Api/OrderJingXiao/CancelOrder/10 |
| | | /// <summary> |
| | | /// 取消订单 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> CancelOrder([FromBody] FMArrayStringIds entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | if (entity.id.Length == 0) |
| | | { |
| | | jm.msg = "请提交要取消的订单号"; |
| | | return jm; |
| | | } |
| | | |
| | | var result = await _coreCmsOrderServices.CancelOrder(entity.id); |
| | | //jm.code = result.status ? 0 : 1; |
| | | jm.status = result.status; |
| | | jm.msg = result.msg; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 批量删除订单============================================================ |
| | | // POST: Api/OrderJingXiao/DeleteOrder/10 |
| | | /// <summary> |
| | | /// 批量删除订单 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> DeleteOrder([FromBody] FMArrayStringIds entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | if (entity.id.Length == 0) |
| | | { |
| | | jm.msg = "请提交要批量删除的订单号"; |
| | | return jm; |
| | | } |
| | | |
| | | var result = await _coreCmsOrderServices.UpdateAsync(p => new CoreCmsOrder() { isdel = true }, p => entity.id.Contains(p.orderId)); |
| | | // jm.code = result ? 0 : 1; |
| | | jm.status = result; |
| | | jm.msg = result ? "删除成功" : "删除失败"; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 重新同步发货============================================================ |
| | | // POST: Api/OrderJingXiao/DeleteOrder/10 |
| | | /// <summary> |
| | | /// 重新同步发货 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> RefreshDelivery([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | if (string.IsNullOrEmpty(entity.id)) |
| | | { |
| | | jm.msg = "请提交要取消的订单号"; |
| | | return jm; |
| | | } |
| | | |
| | | var delivery = await _billDeliveryServices.QueryByClauseAsync(p => p.deliveryId == entity.id); |
| | | if (delivery == null) |
| | | { |
| | | jm.msg = "发货单获取失败"; |
| | | return jm; |
| | | } |
| | | |
| | | //jm.code = 0; |
| | | jm.status = true; |
| | | jm.msg = "提交任务成功,请核实远端状态"; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | #region 预览快递进度============================================================ |
| | | // POST: Api/OrderJingXiao/GetDetails/10 |
| | | /// <summary> |
| | | /// 预览快递进度 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Authorize] |
| | | public async Task<WebApiCallBack> GetOrderLogistics([FromBody] FMStringId entity) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | | var result = await _coreCmsOrderServices.GetOrderInfoByOrderId(entity.id); |
| | | if (result == null) |
| | | { |
| | | jm.msg = "不存在此信息"; |
| | | return jm; |
| | | } |
| | | //jm.code = result.status ? 0 : 1; |
| | | jm.status = result.status; |
| | | jm.data = result.data; |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region 后台Select三级下拉联动配合 |
| | | |
| | | /// <summary> |
| | | /// 获取大类列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public async Task<List<AreasDtoForAdminEdit>> GetAreaCheckedList([FromBody] FMIntId entity) |
| | | { |
| | | var res = new List<AreasDtoForAdminEdit>(); |
| | | |
| | | if (entity.id != 0) |
| | | { |
| | | var model3 = new AreasDtoForAdminEdit(); |
| | | model3.info = await _areaServices.QueryByIdAsync(entity.id); |
| | | if (model3.info != null && model3.info.parentId != 0) |
| | | { |
| | | model3.list = await _areaServices.QueryListByClauseAsync(p => p.parentId == model3.info.parentId); |
| | | |
| | | var model2 = new AreasDtoForAdminEdit(); |
| | | model2.info = await _areaServices.QueryByIdAsync(model3.info.parentId); |
| | | if (model2.info != null && model2.info.parentId != 0) |
| | | { |
| | | model2.list = |
| | | await _areaServices.QueryListByClauseAsync(p => p.parentId == model2.info.parentId); |
| | | |
| | | var model = new AreasDtoForAdminEdit(); |
| | | model.info = await _areaServices.QueryByIdAsync(model2.info.parentId); |
| | | if (model.info != null) |
| | | model.list = |
| | | await _areaServices.QueryListByClauseAsync(p => p.parentId == model.info.parentId); |
| | | res.Add(model); |
| | | } |
| | | else |
| | | { |
| | | //修改不可以任意选择层级的bug |
| | | model2.thisList = await _areaServices.QueryListByClauseAsync(p => p.parentId == 0); |
| | | } |
| | | |
| | | res.Add(model2); |
| | | } |
| | | else |
| | | if (model3.info != null && model3.info.parentId == 0) |
| | | { |
| | | //修改不可以任意选择层级的bug |
| | | model3.thisList = await _areaServices.QueryListByClauseAsync(p => p.parentId == 0); |
| | | } |
| | | |
| | | |
| | | res.Add(model3); |
| | | } |
| | | else |
| | | { |
| | | //修改不可以任意选择层级的bug |
| | | var model4 = new AreasDtoForAdminEdit(); |
| | | model4.list = await _areaServices.QueryListByClauseAsync(p => p.parentId == 0); |
| | | model4.info = null; |
| | | res.Add(model4); |
| | | } |
| | | |
| | | return res; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 取地区的下级列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public async Task<List<CoreCmsArea>> GetAreaChildren([FromBody] FMIntId entity) |
| | | { |
| | | var list = await _areaServices.QueryListByClauseAsync(p => p.parentId == entity.id); |
| | | return list; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |