TG.WXCRM.V4/WEB/Controllers/WeiXin/InvoiceController.cs

185 lines
6.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using CRM.Core.DTO;
using CRM.Core.DTO.Res;
using Newtonsoft.Json;
using Ninject;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using WX.CRM.BLL.Base;
using WX.CRM.BLL.Util;
using WX.CRM.BLL.Wx;
using WX.CRM.Common;
using WX.CRM.Model.Entity;
using WX.CRM.Model.Enum;
using WX.CRM.Model.QueryMap;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.WeiXin
{
public class InvoiceController : BaseController
{
[Inject]
public CACHE_BL _cache { get; set; }
[Inject]
public IBAS_BUSINESSLINE_Q _businessLine_q { get; set; }
[HttpGet]
[AuthorizeRedirect(Roles = InitRights.CONST_发票列表)]
public ActionResult Index()
{
ToolBar tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights., userRightId);
tool.AllowButton(toolbtn);
ViewBag.ToolBar = tool;
//var webUrl = _cache.GetValue_Parameter("Core_ZxdCoreUrl");
var apiUrl = _cache.GetValue_Parameter("Core_ZxdService_Api");
var myBusinessLine = _businessLine_q.GetBusineeLine(UserId);
var deptList = _cache.GetList_BusinessLines().ToList();
var selectList = new List<SelectListItem>();
foreach (var item in deptList)
{
if (myBusinessLine != null && myBusinessLine.BUSINESSID == item.BUSINESSID)
{
var ch = GetChannel(item.BUSINESSID);
selectList.Add(new SelectListItem() { Text = item.BUSINESSNAME, Value = ch, Selected = true });
}
else
{
var ch = GetChannel(item.BUSINESSID);
selectList.Add(new SelectListItem() { Text = item.BUSINESSNAME, Value = ch });
}
}
ViewBag.DeptList = selectList;
//ViewBag.WebUrl = webUrl;
ViewBag.ApiUrl = apiUrl;
return View();
}
[HttpGet]
public ActionResult Add()
{
var webUrl = _cache.GetValue_Parameter("Core_ZxdCoreUrl");
var apiUrl = _cache.GetValue_Parameter("Core_ZxdService_Api");
var myBusinessLine = _businessLine_q.GetBusineeLine(UserId);
var deptList = _cache.GetList_BusinessLines().ToList();
var selectList = new List<SelectListItem>();
foreach (var item in deptList)
{
if (myBusinessLine != null && myBusinessLine.BUSINESSID == item.BUSINESSID)
{
var ch = GetChannel(item.BUSINESSID);
selectList.Add(new SelectListItem() { Text = item.BUSINESSNAME, Value = ch, Selected = true });
}
else
{
var ch = GetChannel(item.BUSINESSID);
selectList.Add(new SelectListItem() { Text = item.BUSINESSNAME, Value = ch });
}
}
ViewBag.DeptList = selectList;
ViewBag.Eid = Eid;
ViewBag.UserName = UserName;
ViewBag.WebUrl = webUrl;
ViewBag.ApiUrl = apiUrl;
return View();
}
[HttpGet]
public ActionResult Detail()
{
//var webUrl = _cache.GetValue_Parameter("Core_ZxdCoreUrl");
var apiUrl = _cache.GetValue_Parameter("Core_ZxdService_Api");
//ViewBag.WebUrl = webUrl;
ViewBag.ApiUrl = apiUrl;
return View();
}
//public JsonResult Upload(string resid, string title)
//{
// var url = "http://localhost:55047/InvoiceService.svc/UploadFile";
// HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
// request.Method = "POST";
// request.Headers.Add("FileName", title);
// request.Headers.Add("SavePath", resid);
// //如果需要POST数据
// if (Request.Files.Count > 0)
// {
// var fileStream = Request.Files[0].InputStream;
// byte[] data = null;
// byte[] buffer = new byte[16 * 1024];
// using (MemoryStream ms = new MemoryStream())
// {
// int read;
// while ((read = fileStream.Read(buffer, 0, buffer.Length)) > 0)
// {
// ms.Write(buffer, 0, read);
// }
// data = ms.ToArray();
// }
// using (Stream stream = request.GetRequestStream())
// {
// stream.Write(data, 0, data.Length);
// }
// }
// else
// {
// //没有参数的时候必须加上这句这个是HTTP POST要求必须带参数不然就需要说明长度是0
// request.ContentLength = 0;
// }
// using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
// {
// StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
// string result = reader.ReadToEnd();
// LogHelper.Info(result);
// var retmessage = WebHelper.JsonHelper.JsonDivertToObj<retMsg>(result);
// if (retmessage.result)
// {
// return Json(new { result = true, url = retmessage.retmsg }, JsonRequestBehavior.AllowGet);
// }
// else
// {
// return Json(new { result = false }, JsonRequestBehavior.AllowGet);
// }
// }
//}
private string GetChannel(decimal businessid)
{
var businessChannel = _cache.GetList_BusinessChannels();
businessChannel = businessChannel.Where(p => p.BUSINESSID == businessid).ToList();
var ch = string.Empty;
foreach (var channel in businessChannel)
{
ch += channel.MINCHANNEL.ToString() + "," + channel.MAXCHANNEL.ToString() + "|";
}
if (ch.Length > 0)
ch = ch.Remove(ch.Length - 1);
return ch;
}
}
}