/// <summary> /// /// </summary> /// <param name="orderNo"></param> /// <param name="templateId"></param> /// <param name="pageIndex"></param> /// <returns></returns> public ActionResult GetPrintContent(string orderNo, string templateId, int pageIndex) { ShipTypeTemplateEntity template = _templateBLL.GetTemplate(templateId); var order = _orderBll.Repository().FindEntity("OrderNo", orderNo); var orderItems = _orderBll.GetOrderItemList(orderNo); if (order != null && orderItems.Count > 0) { string content = template.TemplateContent; var merchant = _merchantBLL.Repository().FindEntity("MerchantId", order.MerchantId); var warehouse = _warehouseBLL.Repository().FindEntity("WarehouseId", order.WarehouseId); content = content.Replace("发件人姓名", merchant.FullName); content = content.Replace("发件人电话", merchant.Phone); content = content.Replace("发件人手机号", merchant.Phone); content = content.Replace("发件人-省", merchant.Province); content = content.Replace("发件人-市", merchant.City); content = content.Replace("发件人-区", merchant.County); content = content.Replace("发件人地址", warehouse.Address); content = content.Replace("发件人邮编", warehouse.PostalCode); content = content.Replace("收件人姓名", order.ReceiveContact); content = content.Replace("收件人电话", order.ReceivePhone); content = content.Replace("收件人手机号", order.ReceiveCellPhone); content = content.Replace("收件人-省", order.Province); content = content.Replace("收件人-市", order.City); content = content.Replace("收件人-区", order.County); content = content.Replace("收件人地址", order.ReceiveAddress); content = content.Replace("收件人邮编", order.ReceiveZip); content = content.Replace("订单编号", order.OrderNo); content = content.Replace("派件备注", order.Remark); content = content.Replace("店铺名称", merchant.FullName); if (order.OrderDate.HasValue) { content = content.Replace("发货日期", order.OrderDate.Value.ToString("yyyy-MM-dd")); } else { } template.TemplateContent = content; if (pageIndex > 0) { Match match = Regex.Match(template.TemplateContent, @"LODOP\.PRINT_INITA.+?\);\r\n"); if (match.Success) { template.TemplateContent = template.TemplateContent.Replace(match.Groups[0].Value, ""); } match = Regex.Match(template.TemplateContent, @"LODOP\.SET_PRINT_PAGESIZE.+?\);\r\n"); if (match.Success) { template.TemplateContent = template.TemplateContent.Replace(match.Groups[0].Value, ""); } } } return(Content(template.ToJson())); }