387 lines
15 KiB
C#
387 lines
15 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web.Mvc;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.IBLL.Base;
|
||
using WX.CRM.IBLL.Util;
|
||
using WX.CRM.Model.Entity;
|
||
using WX.CRM.WEB.ViewModel.Level2;
|
||
using WX.CRM.WebHelper;
|
||
|
||
namespace WX.CRM.WEB.Controllers.Level2
|
||
{
|
||
public class L2OrderPayListController : BaseController
|
||
{
|
||
List<Soft_OrderWebPayList> orderDetail;
|
||
private List<L2_SOFT_PRODUCT> softProducts;//产品大类List
|
||
private List<L2_SOFT_BIGPRODUCT> softBigProducts;//产品小类List
|
||
|
||
[Ninject.Inject]
|
||
public IBAS_PARAMETER_Q _parameter_Q { get; set; }
|
||
[Ninject.Inject]
|
||
public ICACHE_Q cache { get; set; }
|
||
|
||
|
||
// GET: /Leve2Order/
|
||
|
||
#region 首页
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_L2支付列表)]
|
||
public ActionResult Index(int protype)
|
||
{
|
||
#region toolbar工具栏
|
||
ToolBar tool = new ToolBar();
|
||
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.L2支付列表, userRightId);
|
||
tool.AllowButton(toolbtn);
|
||
tool.AllowButton("Other1");
|
||
tool.AddOtherButton("Other1", "导出", "icon-export", "BtnExportAll_Click", true);
|
||
ViewBag.ToolBar = tool;
|
||
#endregion
|
||
|
||
#region gridtable 表格
|
||
|
||
var pager = new Pager() { page = 1, rows = 20 };
|
||
var tableId = "tablist";
|
||
var tab = new Table(tableId);
|
||
tab.AddHeadCol("orderid", "10%", "订单号 ", true);
|
||
tab.AddHeadCol("pcusername", "10%", "Pc用户名 ");
|
||
tab.AddHeadCol("username", "10%", "手机App用户名 ", true);
|
||
tab.AddHeadCol("bigproductcode", "10%", "产品大类");
|
||
tab.AddHeadCol("productcode", "10%", "产品小类");
|
||
tab.AddHeadCol("WEBPAYID", "10%", "支付流水号 ");
|
||
tab.AddHeadCol("PAYTOTAL", "10%", "支付金额", true);
|
||
tab.AddHeadCol("PAYTYPE", "10%", "支付方式", true);
|
||
tab.AddHeadCol("CTIME", "10%", "支付时间");
|
||
tab.AddHeadCol("PAYMEMO", "10%", "支付备注");
|
||
tab.AddHeadRow();
|
||
ViewBag.gridTable = tab.GetTable() + Pagination.GetPage(pager, tableId, "10,20,30");
|
||
|
||
#endregion
|
||
|
||
#region ViewBag页面传值
|
||
|
||
#region 下拉列表
|
||
string BigProductcode = "";
|
||
string SProductcode = "";
|
||
BAS_PARAMETER model = new BAS_PARAMETER();
|
||
if (protype == 1)
|
||
{
|
||
model = _parameter_Q.GetModel_Patameter("Level2ProductSelect");
|
||
}
|
||
if (protype == 2)
|
||
{
|
||
model = _parameter_Q.GetModel_Patameter("ZXProductSelect");
|
||
}
|
||
|
||
if (model != null)
|
||
{
|
||
BigProductcode = model.map_PARAVALUE.Split('#')[0];
|
||
SProductcode = model.map_PARAVALUE.Split('#')[1];
|
||
}
|
||
List<SelectListItem> bplist = new List<SelectListItem>();
|
||
bplist = plistToListItem(BigProductcode, protype);
|
||
List<SelectListItem> splist = new List<SelectListItem>();
|
||
splist = splistToListItem(bplist, SProductcode);
|
||
ViewBag.bplist = bplist;
|
||
ViewBag.splist = splist;
|
||
ViewBag.protype = protype;
|
||
#endregion
|
||
|
||
#endregion
|
||
return View();
|
||
}
|
||
|
||
#region 获取类型listitem
|
||
//获取大类listitem
|
||
public List<SelectListItem> plistToListItem(string BigProductcode, int type)
|
||
{
|
||
softBigProducts = cache.GetBigProductList();
|
||
softBigProducts = softBigProducts.Where(p => p.GROUPID == type).ToList();
|
||
List<SelectListItem> bplist = new List<SelectListItem>();
|
||
for (int i = 0; i < softBigProducts.Count(); i++)
|
||
{
|
||
SelectListItem item = new SelectListItem();
|
||
item.Text = softBigProducts[i].PRODUCTNAME;
|
||
item.Value = softBigProducts[i].PRODUCTCODE.ToString();
|
||
bplist.Add(item);
|
||
}
|
||
if (bplist.Count > 0)
|
||
{
|
||
if (BigProductcode != "")
|
||
{
|
||
for (int i = 0; i < bplist.Count(); i++)
|
||
{
|
||
if (bplist[i].Value == BigProductcode)
|
||
{
|
||
bplist[i].Selected = true;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
bplist[0].Selected = true;
|
||
}
|
||
}
|
||
bplist.Add(new SelectListItem() { Text = "所有", Value = "-1" });
|
||
return bplist;
|
||
|
||
}
|
||
//获取小类listitem
|
||
public List<SelectListItem> splistToListItem(List<SelectListItem> bplist, string SProductcode)
|
||
{
|
||
string bpcode = "";
|
||
for (int i = 0; i < bplist.Count; i++)
|
||
{
|
||
if (bplist[i].Selected)
|
||
{
|
||
bpcode = bplist[i].Value;
|
||
}
|
||
}
|
||
softBigProducts = cache.GetBigProductList();
|
||
softProducts = cache.GetSProductList();
|
||
|
||
L2_SOFT_BIGPRODUCT bmodel = softBigProducts.Where(p => p.PRODUCTCODE == bpcode).FirstOrDefault();
|
||
|
||
softProducts = softProducts.Where(p => p.BIGPRODUCTID == bmodel.PRODUCTID).ToList();
|
||
List<SelectListItem> splist = new List<SelectListItem>();
|
||
|
||
for (int i = 0; i < softProducts.Count(); i++)
|
||
{
|
||
SelectListItem item = new SelectListItem();
|
||
item.Text = softProducts[i].PRODUCTNAME;
|
||
item.Value = softProducts[i].PRODUCTCODE.ToString();
|
||
splist.Add(item);
|
||
}
|
||
if (splist.Count > 0)
|
||
{
|
||
if (SProductcode != "")
|
||
{
|
||
for (int i = 0; i < splist.Count(); i++)
|
||
{
|
||
if (splist[i].Value == SProductcode)
|
||
{
|
||
splist[i].Selected = true;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
splist[0].Selected = true;
|
||
}
|
||
}
|
||
return splist;
|
||
}
|
||
#endregion
|
||
#endregion
|
||
|
||
#region 导出
|
||
[AuthorizeToolBar(InitRights.CONST_L2支付列表, InitToolBar.CONST_Other1)]
|
||
public FileResult ListExport()
|
||
{
|
||
int total = 0;
|
||
string msg = "";
|
||
string checkedFilds = PageRequest.GetQueryString("checkedFilds");
|
||
string checkedTitles = PageRequest.GetQueryString("checkedTitles");
|
||
string ctime = Request.QueryString["ctime"];
|
||
string etime = Request.QueryString["etime"];
|
||
string _productbigtype = Request.QueryString["productbigtype"];
|
||
string _productsmalltype = Request.QueryString["productsmalltype"];
|
||
string _userName = Request.QueryString["userName"];
|
||
string _OrderId = Request.QueryString["OrderId"];
|
||
string _payNO = Request.Form["PayNo"];
|
||
string _paytype = Request.Form["paytype"];
|
||
|
||
if (_productbigtype == "-1")
|
||
{
|
||
_productbigtype = "";
|
||
}
|
||
if (_productsmalltype == "-1" || _productsmalltype == "null")
|
||
{
|
||
_productsmalltype = "";
|
||
}
|
||
|
||
Soft_CRMOrderModel crmmodel = new Soft_CRMOrderModel("", _productbigtype, _productsmalltype, _userName, _OrderId, _paytype, ctime, etime, "", "", "", _payNO, 1, int.MaxValue);
|
||
|
||
//获取订单列表
|
||
List<Soft_OrderWebPayList> list = crmmodel.GetOderPayList(out msg, out total);
|
||
foreach (Soft_OrderWebPayList item in list)
|
||
{
|
||
item.USERNAME = PhoneHelper.FormatPhoneUserName(item.USERNAME);
|
||
item.PcUserName = PhoneHelper.FormatPhoneUserName(item.USERNAME);
|
||
}
|
||
return File(ExcelHelper.ExportListModelToExcel<Soft_OrderWebPayList>(list, "支付列表", 10000, checkedFilds, checkedTitles, DataFormart), "application/ms-excel", PageRequest.GetDlownLoadName("支付列表.xls"));
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 列表
|
||
[HttpPost]
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_L2支付列表)]
|
||
public JsonResult GetHtmlList(Pager pager, string columns)
|
||
{
|
||
int total = 0;
|
||
string msg = "";
|
||
string ctime = Request.Form["ctime"];
|
||
string etime = Request.Form["etime"];
|
||
string _productbigtype = Request.Form["productbigtype"];
|
||
string _productsmalltype = Request.Form["productsmalltype"];
|
||
string _userName = Request.Form["userName"];
|
||
string _OrderId = Request.Form["OrderId"];
|
||
string _payNO = Request.Form["PayNo"];
|
||
string _paytype = Request.Form["paytype"];
|
||
|
||
string _protype = Request.Form["protype"];
|
||
|
||
if (_productbigtype == "-1")
|
||
{
|
||
if (_protype != null)
|
||
{
|
||
softBigProducts = cache.GetBigProductList();
|
||
softBigProducts = softBigProducts.Where(p => p.GROUPID == Convert.ToDecimal(_protype)).ToList();
|
||
_productbigtype = "";
|
||
foreach (L2_SOFT_BIGPRODUCT item in softBigProducts)
|
||
{
|
||
_productbigtype += item.PRODUCTCODE + ",";
|
||
}
|
||
_productbigtype = _productbigtype.Substring(0, _productbigtype.Length - 1);
|
||
}
|
||
|
||
}
|
||
if (_productsmalltype == "-1" || _productsmalltype == "null")
|
||
{
|
||
_productsmalltype = "";
|
||
}
|
||
|
||
Soft_CRMOrderModel crmmodel = new Soft_CRMOrderModel("", _productbigtype, _productsmalltype, _userName, _OrderId, _paytype, ctime, etime, "", "", "", _payNO, pager.page, pager.rows);
|
||
//获取支付列表
|
||
orderDetail = crmmodel.GetOderPayList(out msg, out total);
|
||
var list = orderDetail.AsQueryable();
|
||
pager.totalRows = total;
|
||
var table = new Table(columns, true);
|
||
table.gridPager = pager;
|
||
|
||
foreach (var model in list)
|
||
{
|
||
table.AddCol(model.ORDERID);//订单号
|
||
table.AddCol(PhoneHelper.FormatPhoneUserName(model.PcUserName));//pc用户名
|
||
table.AddCol(PhoneHelper.FormatPhoneUserName(model.USERNAME));//app用户名
|
||
table.AddCol(GetBigProductName(model.BIGPRODUCTCODE));//大类代码
|
||
table.AddCol(GetProductName(model.PRODUCTCODE));//子类代码
|
||
table.AddCol(model.WEBPAYID);//支付流水号
|
||
table.AddCol(model.PAYTOTAL);//支付金额
|
||
table.AddCol(GetPayType(model.PAYTYPE.ToString()));//支付方式
|
||
table.AddCol(model.CTIME);//开通时间
|
||
table.AddCol(model.PAYMEMO);//支付备注
|
||
table.AddRow();
|
||
}
|
||
var json = new
|
||
{
|
||
totalPages = pager.totalPages,
|
||
totalRows = pager.totalRows,
|
||
rowsList = table.GetRows()
|
||
};
|
||
return Json(json, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
#region 方法
|
||
|
||
/// <summary>
|
||
/// 当大类改变时
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
public JsonResult JsonProType(string code)
|
||
{
|
||
|
||
if (code == "-1")
|
||
{
|
||
List<SelectListItem> list = new List<SelectListItem>();
|
||
list.Add(new SelectListItem() { Text = "所有", Selected = true, Value = "-1" });
|
||
return Json(list, JsonRequestBehavior.AllowGet);
|
||
}
|
||
else
|
||
{
|
||
L2_SOFT_BIGPRODUCT softbigpro = cache.GetBigProductList().Where(p => p.PRODUCTCODE == code).FirstOrDefault();
|
||
softProducts = cache.GetSProductList();
|
||
var list = softProducts.Where(m => m.BIGPRODUCTID == softbigpro.PRODUCTID).Select(item => new SelectListItem() { Text = item.PRODUCTNAME, Value = item.PRODUCTCODE.ToString(), Selected = true }).ToList();
|
||
return Json(list, JsonRequestBehavior.AllowGet);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 支付方式
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
/// <returns></returns>
|
||
public string GetPayType(string type)
|
||
{
|
||
//1、支付宝;2、财富通;3、银行转账;4、网银支付;5.微信支付;6.支付宝网银;7.银联;10、公司赠送
|
||
string result = "";
|
||
switch (type)
|
||
{
|
||
case "1": result = "支付宝"; break;
|
||
case "2": result = "财付通"; break;
|
||
case "3": result = "银行转账"; break;
|
||
case "4": result = "网银支付"; break;
|
||
case "5": result = "微信支付"; break;
|
||
case "6": result = "支付宝银联"; break;
|
||
case "7": result = "银联"; break;
|
||
case "10": result = "公司赠送"; break;
|
||
default: result = "无法识别"; break;
|
||
};
|
||
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 产品大类名
|
||
/// </summary>
|
||
/// <param name="productCode">产品大类代码</param>
|
||
/// <returns></returns>
|
||
protected string GetBigProductName(string productCode)
|
||
{
|
||
if (!string.IsNullOrEmpty(productCode))
|
||
{
|
||
var model = cache.GetBigProductList().Where(p => p.PRODUCTCODE.Trim() == productCode.Trim()).FirstOrDefault();
|
||
return model == null ? productCode : model.PRODUCTNAME;
|
||
}
|
||
return productCode;
|
||
}
|
||
/// <summary>
|
||
/// 产品子类名
|
||
/// </summary>
|
||
/// <param name="productCode">产品子类代码</param>
|
||
/// <returns></returns>
|
||
protected string GetProductName(string productCode)
|
||
{
|
||
if (!string.IsNullOrEmpty(productCode))
|
||
{
|
||
List<L2_SOFT_PRODUCT> list = cache.GetSProductList();
|
||
L2_SOFT_PRODUCT model = list.Where(p => p.PRODUCTCODE.Trim() == productCode.Trim()).FirstOrDefault();
|
||
return model == null ? productCode : model.PRODUCTNAME;
|
||
}
|
||
return productCode;
|
||
}
|
||
|
||
public string DataFormart(string key, object value)
|
||
{
|
||
string formartValue = string.Empty;
|
||
switch (key)
|
||
{
|
||
case "PAYTYPE":
|
||
formartValue = GetPayType(value.ToString()); break;
|
||
case "BIGPRODUCTCODE": formartValue = GetBigProductName(Convert.ToString(value)); break;
|
||
case "PRODUCTCODE": formartValue = GetProductName(Convert.ToString(value)); break;
|
||
default: formartValue = string.Format("{0}", value); break;
|
||
}
|
||
return formartValue;
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
}
|