| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- /*
- * 机具费率报警
- */
- using System;
- using System.Web;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using MySystem.Models;
- using Library;
- using LitJson;
- using MySystemLib;
- namespace MySystem.Areas.Admin.Controllers
- {
- [Area("Admin")]
- [Route("Admin/[controller]/[action]")]
- public class PosFeeWarningRecordController : BaseController
- {
- public PosFeeWarningRecordController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
- }
- #region 机具费率报警列表
- /// <summary>
- /// 根据条件查询机具费率报警列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Index(PosFeeWarningRecord data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- List<KqProducts> BrandList = db.KqProducts.ToList();
- ViewBag.BrandList = BrandList;
- return View();
- }
- #endregion
- #region 根据条件查询机具费率报警列表
- /// <summary>
- /// 机具费率报警列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(PosFeeWarningRecord data, string DoStatus, string CreateDateData, string UpdateDateData, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- string condition = "";
- if (!string.IsNullOrEmpty(data.PosSn))
- {
- condition += " and PosSn like '%" + data.PosSn + "%'";
- }
- if (data.BrandId > 0)
- {
- condition += " and BrandId=" + data.BrandId;
- }
- //状态
- if (!string.IsNullOrEmpty(DoStatus))
- {
- condition += " and Status=" + DoStatus;
- }
- //创建时间
- 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'";
- }
- //同步时间
- if (!string.IsNullOrEmpty(UpdateDateData))
- {
- string[] datelist = UpdateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and UpdateDate>='" + start + " 00:00:00' and UpdateDate<='" + end + " 23:59:59'";
- }
- List<KqProducts> BrandList = db.KqProducts.ToList();
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosFeeWarningRecord", 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 BrandId = int.Parse(dic["BrandId"].ToString());
- KqProducts Brand = BrandList.FirstOrDefault(m => m.Id == BrandId) ?? new KqProducts();
- dic["BrandName"] = Brand.Name;
-
- int PosId = int.Parse(dic["PosId"].ToString());
- PosMachinesTwo Pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == PosId) ?? new PosMachinesTwo();
- PosMerchantInfo Merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == Pos.BindMerchantId) ?? new PosMerchantInfo();
- dic["MerNo"] = Merchant.KqMerNo;
- //状态
- int Status = int.Parse(dic["Status"].ToString());
- if (Status == 1) dic["Status"] = "已同步";
- if (Status == 0) dic["Status"] = "未同步";
- }
- return Json(obj);
- }
- #endregion
- #region 同步
- /// <summary>
- /// 同步
- /// </summary>
- /// <returns></returns>
- public string Sycn(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "PosFeeWarningRecord", "Sycn");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Status", 1);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosFeeWarningRecord", Fields, id);
- RedisDbconn.Instance.AddList("FeeRateAlignmentQueue", Id);
- }
- return "success";
- }
- #endregion
- #region 导入数据
- public IActionResult ImportTrade(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- List<KqProducts> BrandList = db.KqProducts.OrderBy(m => m.Id).ToList();
- ViewBag.BrandList = BrandList;
- return View();
- }
- /// <summary>
- /// 导入数据
- /// </summary>
- /// <param name="ExcelData"></param>
- [HttpPost]
- public string ImportTradePost(string ExcelPath, string BrandId)
- {
- RedisDbconn.Instance.AddList("ExcelCheckFee", ExcelPath + "#cut#" + BrandId + "#cut#" + SysUserName);
- AddSysLog(ExcelPath, "ImportTrade", "ImportTradePost");
- return "success";
- }
-
- #endregion
- #region 导出Excel
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportExcel(PosFeeWarningRecord data, string UserIdMakerCode, string LeaderLevelSelect, string PosFeeWarningRecordtatusSelect, string LastBuyDateData, string ExpiredDateData, string CreateDateData)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(UserIdMakerCode))
- {
- condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
- }
- //盟主等级
- if (!string.IsNullOrEmpty(LeaderLevelSelect))
- {
- condition += " and LeaderLevel=" + LeaderLevelSelect;
- }
- //状态
- if (!string.IsNullOrEmpty(PosFeeWarningRecordtatusSelect))
- {
- var time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- if (PosFeeWarningRecordtatusSelect == "0")
- {
- condition += " and ExpiredDate>'" + time + "'";
- }
- else
- {
- condition += " and ExpiredDate<='" + time + "'";
- }
- }
- //首次购买时间
- 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'";
- }
- //最后购买时间
- if (!string.IsNullOrEmpty(LastBuyDateData))
- {
- string[] datelist = LastBuyDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and LastBuyDate>='" + start + " 00:00:00' and LastBuyDate<='" + end + " 23:59:59'";
- }
- //盟主到期时间
- if (!string.IsNullOrEmpty(ExpiredDateData))
- {
- string[] datelist = ExpiredDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and ExpiredDate>='" + start + " 00:00:00' and ExpiredDate<='" + end + " 23:59:59'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosFeeWarningRecord", Fields, "Id desc", "0", 1, 20000, condition, "UserId,LeaderLevel,CreateDate", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //创客
- int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
- Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["UserIdMakerCode"] = userid_Users.MakerCode;
- dic["UserIdRealName"] = userid_Users.RealName;
- dic.Remove("UserId");
- //盟主等级
- int LeaderLevel = int.Parse(dic["LeaderLevel"].ToString());
- if (LeaderLevel == 1) dic["LeaderLevel"] = "小盟主";
- if (LeaderLevel == 2) dic["LeaderLevel"] = "大盟主";
- if (LeaderLevel == 0) dic["LeaderLevel"] = "";
- }
- Dictionary<string, object> result = new Dictionary<string, object>();
- result.Add("Status", "1");
- result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
- result.Add("Obj", diclist);
- Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
- ReturnFields.Add("UserIdMakerCode", "创客创客编号");
- ReturnFields.Add("UserIdRealName", "创客真实姓名");
- ReturnFields.Add("LeaderLevel", "盟主等级");
- ReturnFields.Add("CreateDate", "创建时间");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "PosFeeWarningRecord", "ExportExcel");
- return Json(result);
- }
- #endregion
- }
- }
|