249 lines
10 KiB
C#
249 lines
10 KiB
C#
using Core.Web.App_Start;
|
|
using Core.Web.WebHelper;
|
|
using CRM.Core.BLL;
|
|
using CRM.Core.BLL.Base;
|
|
using CRM.Core.BLL.Util;
|
|
using CRM.Core.BLL.Wx;
|
|
using CRM.Core.Common.Layui;
|
|
using CRM.Core.DTO;
|
|
using CRM.Core.Model.Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
|
|
namespace Core.Web.Controllers
|
|
{
|
|
public class OrderDepositController : BaseController
|
|
{
|
|
WX_SzzyOrderDeposit_BL _orderDeposit = new WX_SzzyOrderDeposit_BL();
|
|
WX_SzzyOrderPay_BL _orderPay = new WX_SzzyOrderPay_BL();
|
|
Wx_SzzyOrderPayUseLog_BL _payuseLog = new Wx_SzzyOrderPayUseLog_BL();
|
|
WX_SzzyOrderRefund_BL _refundBL = new WX_SzzyOrderRefund_BL();
|
|
CACHE_BL cache_BL = new CACHE_BL();
|
|
Bas_CompanyVirtual_BL _companyvirtual = new Bas_CompanyVirtual_BL();
|
|
|
|
[AuthorizeRedirect(RightsConfig.CONST_订金管理, ToolBarConfig.CONST_NotButton, true)]
|
|
[HttpGet]
|
|
public ActionResult Index()
|
|
{
|
|
ViewBag.rightCode = RightsConfig.CONST_订金管理;
|
|
ViewBag.companyList = cache_BL.GetCompanyVirtual();
|
|
|
|
return View();
|
|
}
|
|
[AuthorizeRedirect(RightsConfig.CONST_订金管理, ToolBarConfig.CONST_NotButton, false)]
|
|
[HttpPost]
|
|
public JsonResult Index(Laypage pager, string columns, int? id, string resId, decimal? auditStatus, string payno, string companyCode, int? payType, DateTime? sTime, DateTime? eTime, string useStatus, string channel)
|
|
{
|
|
var where = PredicateExtensionses.True<WX_SzzyOrderDeposit>();
|
|
if (id.HasValue)
|
|
where = where.And(p => p.id == id.Value);
|
|
if (!string.IsNullOrEmpty(resId))
|
|
where = where.And(p => p.resid == resId);
|
|
if (!string.IsNullOrWhiteSpace(payno))
|
|
where = where.And(p => p.payno == payno);
|
|
if (auditStatus.HasValue)
|
|
where = where.And(p => p.auditstatus == auditStatus);
|
|
if (!string.IsNullOrEmpty(companyCode))
|
|
where = where.And(p => p.companycode == companyCode);
|
|
if (payType.HasValue)
|
|
where = where.And(p => p.paytype == payType);
|
|
if (sTime.HasValue)
|
|
where = where.And(p => p.paydate >= sTime.Value);
|
|
if (eTime.HasValue)
|
|
{
|
|
var endtime = eTime.Value.AddDays(1);
|
|
where = where.And(p => p.paydate < endtime);
|
|
}
|
|
if (!string.IsNullOrEmpty(useStatus))
|
|
{
|
|
if (useStatus.Contains(','))
|
|
{
|
|
var arr = useStatus.Split(',').Select(int.Parse);
|
|
where = where.And(p => arr.Contains(p.isuse));
|
|
}
|
|
else
|
|
{
|
|
var isUse = int.Parse(useStatus);
|
|
where = where.And(p => p.isuse == isUse);
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(channel))
|
|
{
|
|
var arr0 = channel.Split('|');
|
|
if (arr0.Length > 1)
|
|
{
|
|
var whereOr = PredicateExtensionses.False<WX_SzzyOrderDeposit>();
|
|
foreach (var item in arr0)
|
|
{
|
|
var a = item.Split(',');
|
|
var min = Convert.ToInt32(a[0]);
|
|
var max = Convert.ToInt32(a[1]);
|
|
whereOr = whereOr.Or(m => m.channel >= min && m.channel <= max);
|
|
}
|
|
where = where.And(whereOr);
|
|
//where = where.And(m => m.channel >= 1100 && m.channel <= 1100 || m.channel >= 26600 && m.channel <= 26699);
|
|
}
|
|
else
|
|
{
|
|
var arr = channel.Split(',');
|
|
var min = Convert.ToInt32(arr[0]);
|
|
var max = Convert.ToInt32(arr[1]);
|
|
where = where.And(m => m.channel >= min && m.channel <= max);
|
|
}
|
|
|
|
}
|
|
where = where.And(p => p.isdelete != 1);
|
|
var list = _orderDeposit.GetList(where, p => p.ctime, pager).ToList();
|
|
//var sumList = _orderDeposit.GetList(where, p => p.id, new Laypage() { page = 1, limit = int.MaxValue });
|
|
var payprice = _orderDeposit.Sum(where, m => m.payprice) ?? 0;
|
|
var useprice = _orderDeposit.Sum(where, m => m.useprice) ?? 0;
|
|
var lastprice = _orderDeposit.Sum(where, m => m.lastprice) ?? 0;
|
|
//var sumInfo = new WX_SzzyOrderDeposit()
|
|
//{
|
|
// payprice = sumList.Sum(p => p.payprice)
|
|
//};
|
|
//list.Add(sumInfo);
|
|
|
|
var companys = _companyvirtual.GetList();
|
|
foreach (var item in list)
|
|
{
|
|
foreach (var company in companys)
|
|
{
|
|
var channels = company.Channel.Split('|');
|
|
foreach (var subchannel in channels)
|
|
{
|
|
var subch = subchannel.Split(',');
|
|
var min = int.Parse(subch[0].ToString());
|
|
var max = int.Parse(subch[1].ToString());
|
|
|
|
if (item.channel.Value >= min && item.channel.Value <= max)
|
|
{
|
|
item.deptcode = company.CompanyName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var data = new LayuiData<WX_SzzyOrderDeposit>()
|
|
{
|
|
msg = "数据加载成功!",
|
|
count = pager.count,
|
|
code = 0,
|
|
data = list,
|
|
totalRow = new { payprice = payprice, useprice = useprice, lastprice = lastprice }
|
|
};
|
|
return Json(data, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(RightsConfig.CONST_订金管理, ToolBarConfig.CONST_Other1, true)]
|
|
public ActionResult Audit(int id)
|
|
{
|
|
var deposit = _orderDeposit.Get(p => p.id == id);
|
|
//var model = new OrderRefundDto
|
|
//{
|
|
// orderid = deposit.id,
|
|
// refundprice = deposit.payprice
|
|
//};
|
|
return View(deposit);
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_订金管理, ToolBarConfig.CONST_Other1, false)]
|
|
public JsonResult Audit(WX_SzzyOrderDeposit orderDepositDto)
|
|
{
|
|
try
|
|
{
|
|
//var orderPayNo = _orderPay.Get(p => p.payno == orderDepositDto.payno && p.auditstatus == 1);
|
|
//if (orderPayNo != null)
|
|
//{
|
|
// return Json(new retMsg { result = false, retcode = 10 }, JsonRequestBehavior.AllowGet);
|
|
//}
|
|
|
|
var orderDeposit = _orderDeposit.Get(p => p.payno == orderDepositDto.payno && p.auditstatus == 1);
|
|
if (orderDeposit != null)
|
|
{
|
|
return Json(new retMsg { result = false, retcode = 10 }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
retMsg ret = _orderDeposit.Audit(orderDepositDto, int.Parse(UserId.ToString()), UserName);
|
|
return Json(ret, JsonRequestBehavior.AllowGet);
|
|
//return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
return Json(new retMsg { result = false, retcode = 0, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_订金管理, ToolBarConfig.CONST_Other1, false)]
|
|
public JsonResult Reject(int id, int status, string rejectremark)
|
|
{
|
|
var retmsg = _orderDeposit.Reject(id, status, rejectremark, int.Parse(UserId.ToString()), UserName);
|
|
return Json(retmsg, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_订金管理, ToolBarConfig.CONST_Other2, false)]
|
|
public JsonResult Delete(int id)
|
|
{
|
|
var retmsg = _orderDeposit.Delete(id);
|
|
return Json(retmsg, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 取消使用
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="status"></param>
|
|
/// <param name="rejectremark"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_订金管理, ToolBarConfig.CONST_Other3, false)]
|
|
public JsonResult CancelUse(int id)
|
|
{
|
|
var retmsg = _orderDeposit.Reject(id, 0, "取消使用", int.Parse(UserId.ToString()), UserName);
|
|
return Json(retmsg, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 金额使用历史
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[AuthorizeRedirect(RightsConfig.CONST_客户资金信息, ToolBarConfig.CONST_NotButton, true)]
|
|
public ActionResult UsePayLog(string resid, string usetype)
|
|
{
|
|
if (string.IsNullOrEmpty(usetype))
|
|
{
|
|
usetype = "[1][2][3][4][5][6][7][8][9][10]";//如果没有数据,就全部显示
|
|
}
|
|
ViewBag.Resid = resid;
|
|
ViewBag.usetype = usetype;
|
|
if (string.IsNullOrWhiteSpace(resid))
|
|
{
|
|
ViewBag.DepositList = new List<WX_SzzyOrderDeposit>();
|
|
ViewBag.AllDepositList = new List<WX_SzzyOrderDeposit>();
|
|
ViewBag.PayUseList = new List<Wx_SzzyOrderPayUseLog>();
|
|
}
|
|
else
|
|
{
|
|
usetype = usetype.Replace("][", "|").Replace("[", "").Replace("]", "");
|
|
int[] usetypes = usetype.Split('|').Select(m => Convert.ToInt32(m)).ToArray();
|
|
var DepositList = _orderDeposit.GetList(m => m.resid == resid && (m.isdelete == 0 || m.isdelete == null) && m.auditstatus == 1);
|
|
var AllDepositList = _orderDeposit.GetList(m => m.resid == resid);
|
|
var List = _payuseLog.GetList(m => m.resid == resid && usetypes.Contains(m.usetype));
|
|
|
|
ViewBag.refList = _refundBL.GetListByResid(resid);
|
|
ViewBag.DepositList = DepositList;
|
|
ViewBag.AllDepositList = AllDepositList;
|
|
ViewBag.PayUseList = List;
|
|
}
|
|
return View();
|
|
}
|
|
}
|
|
} |