| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- /*
- * 创客账户变动记录
- */
- 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
- }
- }
|