| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- /*
- * 创客账户变动记录
- */
- using System;
- using System.Web;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Data;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using MySystem.OpModels;
- using Library;
- using LitJson;
- using MySystemLib;
- namespace MySystem.Areas.Admin.Controllers
- {
- [Area("Admin")]
- [Route("Admin/[controller]/[action]")]
- public class AmountRecordOperateController : BaseController
- {
- public AmountRecordOperateController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- OtherMySqlConn.connstr = ConfigurationManager.AppSettings["OpSqlConnStr"].ToString();
- }
- // #region 运营中心额度变动明细记录列表
- // /// <summary>
- // /// 根据条件查询运营中心额度变动明细记录列表
- // /// </summary>
- // /// <returns></returns>
- // public IActionResult Index(AmountRecord data, string right, int UserId = 0)
- // {
- // ViewBag.RightInfo = RightInfo;
- // ViewBag.right = right;
- // return View();
- // }
- // #endregion
- // #region 根据条件查询运营中心额度变动明细记录列表
- // /// <summary>
- // /// 运营中心额度变动明细记录列表
- // /// </summary>
- // /// <returns></returns>
- // public JsonResult IndexData(AmountRecord data, string MakerCode, string OpCode, string CreateDateData, int page = 1, int limit = 30)
- // {
- // Dictionary<string, string> Fields = new Dictionary<string, string>();
- // string condition = " and Status>-1";
- // //创客编号
- // if (!string.IsNullOrEmpty(MakerCode))
- // {
- // var user = db.Users.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new Models.Users();
- // condition += " and UserId=" + user.Id;
- // }
- // //运营中心编号
- // if (!string.IsNullOrEmpty(OpCode))
- // {
- // condition += " and UserId in (select UserId from SysAdmin where OpCode='" + OpCode + "')";
- // }
- // if (!string.IsNullOrEmpty(CreateDateData))
- // {
- // string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- // // string start = datelist[0];
- // // string end = datelist[1];
- // // condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
- // var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
- // var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
- // var check = opdb.AmountRecord.Any(m => m.CreateDate >= start);
- // var checks = opdb.AmountRecord.Any(m => m.CreateDate <= end);
- // if (check)
- // {
- // var sId = opdb.AmountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
- // condition += " and Id >=" + sId;
- // }
- // if (checks)
- // {
- // var eId = opdb.AmountRecord.Where(m => m.CreateDate <= end).Max(m => m.Id);
- // condition += " and Id <=" + eId;
- // }
- // }
- // else
- // {
- // var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
- // var check = opdb.AmountRecord.Any(m => m.CreateDate >= start);
- // if (check)
- // {
- // var minId = opdb.AmountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
- // var Info = function.ReadInstance("/WritePage/AmountRecordOperate/AmountRecordOperate.txt");
- // if (string.IsNullOrEmpty(Info.ToString()))
- // {
- // function.WritePage("/WritePage/AmountRecordOperate/", "AmountRecordOperate.txt", minId.ToString());
- // condition += " and Id >=" + minId;
- // }
- // else if (minId != int.Parse(Info))
- // {
- // function.WritePage("/WritePage/AmountRecordOperate/", "AmountRecordOperate.txt", minId.ToString());
- // condition += " and Id >=" + minId;
- // }
- // else
- // {
- // condition += " and Id >=" + Convert.ToInt32(Info);
- // }
- // }
- // else
- // {
- // condition += " and Id =0";
- // }
- // }
- // Dictionary<string, object> obj = new AdminContentByConn(_accessor.HttpContext, PublicFunction.OpTables, OpConn).IndexData("AmountRecord", Fields, "Id desc", "0", page, limit, condition);
- // List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- // foreach (Dictionary<string, object> dic in diclist)
- // {
- // int UserId = int.Parse(dic["UserId"].ToString());
- // SysAdmin sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.UserId == UserId) ?? new SysAdmin();
- // dic["OpCode"] = sysAdmin.OpCode;
- // dic["MakerCode"] = sysAdmin.MakerCode;
- // dic["MakerName"] = sysAdmin.MakerName;
- // dic["SourceInfo"] = "";
- // if (int.Parse(dic["QueryCount"].ToString()) > 0)
- // {
- // var Id = int.Parse(dic["QueryCount"].ToString());
- // var orderInfo = db.Orders.FirstOrDefault(m => m.Id == Id) ?? new Models.Orders();
- // var userInfo = db.Users.FirstOrDefault(m => m.Id == orderInfo.UserId) ?? new Models.Users();
- // dic["SourceInfo"] = userInfo.MakerCode + "<br />" + userInfo.RealName;
- // }
- // int OperateType = int.Parse(dic["OperateType"].ToString());
- // dic["OperateTypeName"] = "";
- // if (OperateType == 1) dic["OperateTypeName"] = "收入";
- // if (OperateType == 2) dic["OperateTypeName"] = "支出";
- // }
- // return Json(obj);
- // }
- // #endregion
- #region 运营中心额度变动明细记录列表v2
- /// <summary>
- /// 根据条件查询运营中心额度变动明细记录列表v2
- /// </summary>
- /// <returns></returns>
- public IActionResult Index(AmountRecordNew data, string right, int UserId = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询运营中心额度变动明细记录列表v2
- /// <summary>
- /// 运营中心额度变动明细记录列表v2
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(AmountRecordNew data, string MakerCode, string OpCode, string CreateDateData, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- var user = db.Users.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new Models.Users();
- condition += " and UserId=" + user.Id;
- }
- //运营中心编号
- if (!string.IsNullOrEmpty(OpCode))
- {
- condition += " and UserId in (select UserId from SysAdmin where OpCode='" + OpCode + "')";
- }
- if (!string.IsNullOrEmpty(CreateDateData))
- {
- string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- // string start = datelist[0];
- // string end = datelist[1];
- // condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
- var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
- var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
- var check = opdb.AmountRecordNew.Any(m => m.CreateDate >= start);
- var checks = opdb.AmountRecordNew.Any(m => m.CreateDate <= end);
- if (check)
- {
- var sId = opdb.AmountRecordNew.Where(m => m.CreateDate >= start).Min(m => m.Id);
- condition += " and Id >=" + sId;
- }
- if (checks)
- {
- var eId = opdb.AmountRecordNew.Where(m => m.CreateDate <= end).Max(m => m.Id);
- condition += " and Id <=" + eId;
- }
- }
- else
- {
- var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
- var check = opdb.AmountRecordNew.Any(m => m.CreateDate >= start);
- if (check)
- {
- var minId = opdb.AmountRecordNew.Where(m => m.CreateDate >= start).Min(m => m.Id);
- var Info = function.ReadInstance("/WritePage/AmountRecordOperateNew/AmountRecordOperateNew.txt");
- if (string.IsNullOrEmpty(Info.ToString()))
- {
- function.WritePage("/WritePage/AmountRecordOperateNew/", "AmountRecordOperateNew.txt", minId.ToString());
- condition += " and Id >=" + minId;
- }
- else if (minId != int.Parse(Info))
- {
- function.WritePage("/WritePage/AmountRecordOperateNew/", "AmountRecordOperateNew.txt", minId.ToString());
- condition += " and Id >=" + minId;
- }
- else
- {
- condition += " and Id >=" + Convert.ToInt32(Info);
- }
- }
- else
- {
- condition += " and Id =0";
- }
- }
- Dictionary<string, object> obj = new AdminContentByConn(_accessor.HttpContext, PublicFunction.OpTables, OpConn).IndexData("AmountRecordNew", Fields, "Id desc", "0", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- int UserId = int.Parse(dic["UserId"].ToString());
- SysAdmin sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.UserId == UserId) ?? new SysAdmin();
- dic["OpCode"] = sysAdmin.OpCode;
- dic["MakerCode"] = sysAdmin.MakerCode;
- dic["MakerName"] = sysAdmin.MakerName;
- var DataType = int.Parse(dic["DataType"].ToString());//来源类型,区分表(1订单,2机具,3申请记录,4购买运营中心,5预扣款 6兑换大盟主)
- var Id = int.Parse(dic["DataId"].ToString());//来源Id,表的主键Id
- var SourceInfo = "";
- if (DataType > 0 && Id > 0)
- {
- var SourceUserId = 0;
- if (DataType == 1)
- {
- var orderInfo = db.Orders.FirstOrDefault(m => m.Id == Id) ?? new Models.Orders();
- SourceUserId = orderInfo.UserId;
- }
- if (DataType == 2)
- {
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Id) ?? new Models.PosMachinesTwo();
- SourceUserId = pos.BuyUserId;
- }
- if (DataType == 3)
- {
- var storeMachineApply = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id) ?? new Models.StoreMachineApply();
- SourceUserId = storeMachineApply.UserId;
- }
- if (DataType == 4)
- {
- var sysAdminInfo = opdb.SysAdmin.FirstOrDefault(m => m.Id == Id) ?? new SysAdmin();
- SourceUserId = sysAdminInfo.UserId;
- }
- if (DataType == 5)
- {
- var toChargeBackRecord = db.ToChargeBackRecord.FirstOrDefault(m => m.Id == Id) ?? new Models.ToChargeBackRecord();
- SourceUserId = toChargeBackRecord.UserId;
- }
- if (DataType == 6)
- {
- var userExchangeLeaderRecord = db.UserExchangeLeaderRecord.FirstOrDefault(m => m.Id == Id) ?? new Models.UserExchangeLeaderRecord();
- SourceUserId = userExchangeLeaderRecord.UserId;
- }
- var userInfo = db.Users.FirstOrDefault(m => m.Id == SourceUserId) ?? new Models.Users();
- SourceInfo = userInfo.MakerCode + "_" + userInfo.RealName;
- }
- dic["SourceInfo"] = SourceInfo;
- int OperateType = int.Parse(dic["OperateType"].ToString());
- dic["OperateTypeName"] = "";
- if (OperateType == 1) dic["OperateTypeName"] = "收入";
- if (OperateType == 2) dic["OperateTypeName"] = "支出";
- }
- return Json(obj);
- }
- #endregion
- }
- }
|