123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277 |
- /*
- * 创客
- */
- 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.Models;
- using Library;
- using LitJson;
- using MySystemLib;
- namespace MySystem.Areas.Admin.Controllers
- {
- [Area("Admin")]
- [Route("Admin/[controller]/[action]")]
- public class UsersController : BaseController
- {
- public UsersController(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(Users data, string right, int SelfId = 0, int ParentId = 0, string MakerCode = "")
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- ViewBag.SelfId = SelfId.ToString();
- ViewBag.ParentId = ParentId.ToString();
- ViewBag.MakerCode = MakerCode;
- List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
- ViewBag.TopUsers = TopUsers;
- List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
- ViewBag.Levels = Levels;
- return View();
- }
- #endregion
- #region 根据条件查询创客列表
- /// <summary>
- /// 创客列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(Users data, string ParentMakerCode, string ParentRealName, string AuthFlagSelect, string CreateDateData, int TopUserId, string RiskFlagSelect, string MerchantTypeSelect, int? sSettleAmount, int? eSettleAmount, int? sCashFreezeAmt, int? eCashFreezeAmt, int UserId, int SelfId = 0, int ParentId = 0, int ShowFlag = 0, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("MakerCode", "1"); //创客编号
- Fields.Add("RealName", "1"); //创客名称
- Fields.Add("Mobile", "1"); //手机号
- Fields.Add("CertId", "1"); //身份证号码
- Fields.Add("SettleAmount", "3"); //结算金额
- Fields.Add("CashFreezeAmt", "3"); //冻结金额
- Fields.Add("UserLevel", "0"); //创客等级
- if (SelfId == 0 && ParentId == 0)
- {
- if (ShowFlag == 0)
- {
- Dictionary<string, object> objs = new Dictionary<string, object>();
- return Json(objs);
- }
- }
- string condition = " and Status>-1";
- string sort = "Id desc";
- //直属创客编号
- if (!string.IsNullOrEmpty(ParentMakerCode))
- {
- condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
- }
- //直属创客名称
- if (!string.IsNullOrEmpty(ParentRealName))
- {
- condition += " and ParentUserId in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
- }
- //实名状态
- if (!string.IsNullOrEmpty(AuthFlagSelect))
- {
- condition += " and AuthFlag=" + AuthFlagSelect;
- }
- //顶级创客
- if (TopUserId > 0)
- {
- condition += " and ParentNav like '," + TopUserId + ",%'";
- }
- //风控标识
- if (!string.IsNullOrEmpty(RiskFlagSelect))
- {
- condition += " and RiskFlag=" + RiskFlagSelect;
- }
- //商户创客类型
- if (!string.IsNullOrEmpty(MerchantTypeSelect))
- {
- condition += " and MerchantType=" + MerchantTypeSelect;
- }
- if (sSettleAmount != null)
- {
- condition += " and SettleAmount>=" + sSettleAmount.Value;
- }
- if (eSettleAmount != null)
- {
- condition += " and SettleAmount<=" + eSettleAmount.Value;
- }
- if (sCashFreezeAmt != null)
- {
- condition += " and CashFreezeAmt>=" + sCashFreezeAmt.Value;
- }
- if (eCashFreezeAmt != null)
- {
- condition += " and CashFreezeAmt<=" + eCashFreezeAmt.Value;
- }
- if (SelfId > 0)
- {
- Users self = db.Users.FirstOrDefault(m => m.Id == SelfId);
- if (self != null)
- {
- string ParentNav = function.CheckNull(self.ParentNav);
- condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
- sort = "ParentNav asc";
- }
- }
- if (ParentId > 0)
- {
- condition += " and ParentUserId=" + ParentId;
- }
- if (UserId > 0)
- {
- condition += " and Id=" + UserId;
- }
- 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'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- dic["AuthFlagName"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
- dic["RiskFlagName"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
- dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
- dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
- int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
- dic["ParentMakerCode"] = puser.MakerCode;
- dic["ParentRealName"] = puser.RealName;
- string ParentNav = dic["ParentNav"].ToString();
- if (!string.IsNullOrEmpty(ParentNav))
- {
- string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
- if (list.Length > 1)
- {
- int TopId = int.Parse(function.CheckInt(list[1]));
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- }
- }
- }
- return Json(obj);
- }
- #endregion
- #region 增加创客
- /// <summary>
- /// 增加或修改创客信息
- /// </summary>
- /// <returns></returns>
- public IActionResult Add(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 增加创客
- /// <summary>
- /// 增加或修改创客信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Add(Users data, string ParentMakerCode)
- {
- bool check = db.UserForMobile.Any(m => m.Mobile == data.Mobile);
- if (check)
- {
- return "手机号已存在,请重新输入";
- }
- check = db.UserForRealName.Any(m => m.RealName == data.RealName);
- if (check)
- {
- return "姓名已存在,请重新输入";
- }
- if (!string.IsNullOrEmpty(data.MakerCode))
- {
- check = db.UserForMakerCode.Any(m => m.MakerCode == data.MakerCode);
- if (check)
- {
- return "创客编码已存在,请重新输入";
- }
- }
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("RealName", data.RealName); //真实姓名
- Fields.Add("CertId", data.CertId); //身份证号
- Fields.Add("Mobile", data.Mobile); //手机号
- Fields.Add("LoginPwd", function.MD532(data.LoginPwd)); //登录密码
- Fields.Add("SettleBankCardNo", data.SettleBankCardNo); //结算银行卡号
- if (!string.IsNullOrEmpty(ParentMakerCode))
- {
- UserForMakerCode userFor = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ParentMakerCode) ?? new UserForMakerCode();
- Users puser = db.Users.FirstOrDefault(m => m.Id == userFor.UserId) ?? new Users();
- Fields.Add("ParentUserId", userFor.UserId);
- Fields.Add("ParentNav", puser.ParentNav + "," + userFor.UserId + ",");
- }
- int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("Users", Fields, 0);
- if (string.IsNullOrEmpty(ParentMakerCode))
- {
- string MakerCode = Id.ToString();
- for (int i = 0; i < 7 - Id.ToString().Length; i++)
- {
- MakerCode = "0" + MakerCode;
- }
- MakerCode = "K" + MakerCode;
- Fields = new Dictionary<string, object>();
- Fields.Add("MakerCode", MakerCode); //编号
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, Id);
- }
- db.UserDetail.Add(new UserDetail() { Id = Id });
- db.UserData.Add(new UserData() { UserId = Id });
- AddSysLog(data.Id.ToString(), "Users", "add");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 修改创客
- /// <summary>
- /// 增加或修改创客信息
- /// </summary>
- /// <returns></returns>
- public IActionResult Edit(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 修改创客
- /// <summary>
- /// 增加或修改创客信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Edit(Users data, UserDetail userdetail, UserData userdata)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("RealName", data.RealName); //真实姓名
- Fields.Add("CertId", data.CertId); //身份证号
- Fields.Add("Mobile", data.Mobile); //手机号
- Fields.Add("SettleBankName", data.SettleBankName); //结算银行名称
- Fields.Add("SettleBankCardNo", data.SettleBankCardNo); //结算银行卡号
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, data.Id);
- AddSysLog(data.Id.ToString(), "Users", "update");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 修改结算金额
- public IActionResult EditSettleAmount(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 修改结算金额
- [HttpPost]
- public string EditSettleAmount(Users data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("SettleAmount", data.SettleAmount);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, data.Id);
- AddSysLog(data.Id.ToString(), "Users", "EditSettleAmount");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 修改账户金额
- public IActionResult EditCashFreezeAmt(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 修改账户金额
- [HttpPost]
- public string EditCashFreezeAmt(Users data, string Note, int Kind)
- {
- int UserId = data.Id;
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
- if (account == null)
- {
- account = db.UserAccount.Add(new UserAccount()
- {
- Id = UserId,
- UserId = UserId,
- }).Entity;
- db.SaveChanges();
- }
- if ((Kind == 1 || Kind == 3) && data.CashFreezeAmt > account.BalanceAmount)
- {
- return "账号余额不足";
- }
- decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
- decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
- decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
- int ChangeType = 0;
- if (Kind == 1 && data.CashFreezeAmt <= account.BalanceAmount)
- {
- account.BalanceAmount -= data.CashFreezeAmt;
- account.FreezeAmount += data.CashFreezeAmt;
- ChangeType = 61;
- }
- else if (Kind == 1 && data.CashFreezeAmt > account.BalanceAmount)
- {
- return "冻结金额大于余额";
- }
- else if (Kind == 2 && data.CashFreezeAmt <= account.FreezeAmount)
- {
- account.BalanceAmount += data.CashFreezeAmt;
- account.FreezeAmount -= data.CashFreezeAmt;
- ChangeType = 62;
- }
- else if (Kind == 2 && data.CashFreezeAmt > account.FreezeAmount)
- {
- return "解冻金额大于冻结金额";
- }
- else if (Kind == 3 && data.CashFreezeAmt <= account.BalanceAmount)
- {
- account.TotalAmount -= data.CashFreezeAmt;
- account.BalanceAmount -= data.CashFreezeAmt;
- ChangeType = 63;
- }
- else if (Kind == 3 && data.CashFreezeAmt > account.BalanceAmount)
- {
- return "扣减金额大于余额";
- }
- else if (Kind == 4)
- {
- account.TotalAmount += data.CashFreezeAmt;
- account.BalanceAmount += data.CashFreezeAmt;
- ChangeType = 64;
- }
- decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
- decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
- decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
- UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
- {
- CreateDate = DateTime.Now,
- UpdateDate = DateTime.Now,
- UserId = UserId, //创客
- ChangeType = ChangeType, //变动类型
- ChangeAmount = data.CashFreezeAmt, //变更金额
- BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
- AfterTotalAmount = AfterTotalAmount, //变更后总金额
- BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
- AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
- BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
- AfterBalanceAmount = AfterBalanceAmount, //变更后余额
- Remark = Note,
- }).Entity;
- db.SaveChanges();
- RedisDbconn.Instance.Set("UserAccount:" + UserId, account);
- AddSysLog(data.Id.ToString(), "Users", "EditCashFreezeAmt");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 账户操作
- public IActionResult EditBalance(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- ViewBag.data = editData;
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == Id) ?? new UserAccount();
- ViewBag.account = account;
- return View();
- }
- #endregion
- #region 账户操作
- [HttpPost]
- public string EditBalance(UserAccount data)
- {
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == data.Id);
- if (account != null)
- {
- decimal amount = data.BalanceAmount - account.BalanceAmount;
- if (amount != 0)
- {
- account.BalanceAmount += amount;
- account.TotalAmount += amount;
- AddSysLog(data.Id.ToString(), "UserAccount", "EditBalance");
- db.SaveChanges();
- }
- }
- return "success";
- }
- #endregion
- #region 详情
- public IActionResult Detail(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- ViewBag.AuthDate = editData.AuthDate == null ? "" : editData.AuthDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
- string Age = "";
- if (!string.IsNullOrEmpty(editData.CertId))
- {
- int year = DateTime.Now.Year - int.Parse(editData.CertId.Substring(6, 4));
- Age = year.ToString();
- }
- ViewBag.Age = Age;
- ViewBag.QrCode = string.IsNullOrEmpty(editData.ReferenceQrCode) ? defaultImage : SourceHost + editData.ReferenceQrCode;
- return View();
- }
- #endregion
- #region 三/四要素验证
- public IActionResult ThreeElement(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 三/四要素验证
- [HttpPost]
- public string ThreeElement(string Name, string CertId, string CardNo, string Mobile)
- {
- return "success";
- }
- #endregion
- #region 删除创客信息
- /// <summary>
- /// 删除创客信息
- /// </summary>
- /// <returns></returns>
- public string Delete(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "del");
- 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("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 注销
- // 1、未实名创客;
- // 2、已实名创客,无开通商户;
- // 3、近7天未在商城下单过商品;
- // 4、名下无未绑定机具、机具券,无未申请的循环机;
- public string Cancel(string UserId)
- {
- Users user = db.Users.FirstOrDefault(m => m.Id == Convert.ToInt32(UserId));
- if (user != null)
- {
- if (user.AuthFlag == 1)
- {
- bool check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.BindingState == 1);
- if (check)
- {
- // return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:已实名创客,无开通商户。如有疑问,请联系客服" });
- return "注销失败,未满足条件:已实名创客,无开通商户。如有疑问,请联系客服";
- }
- DateTime checkDate = DateTime.Now.AddDays(-7);
- check = db.Orders.Any(m => m.CreateDate >= checkDate && m.Status > 0 && m.UserId == user.Id);
- if (check)
- {
- // return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:近7天未在商城下单过商品。如有疑问,请联系客服" });
- return "注销失败,未满足条件:近7天未在商城下单过商品。如有疑问,请联系客服";
- }
- check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.IsPurchase == 0);
- if (check)
- {
- // return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服" });
- return "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服";
- }
- check = db.PosCoupons.Any(m => m.UserId == user.Id && m.IsUse == 0);
- if (check)
- {
- // return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服" });
- return "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服";
- }
- }
- UserForMobile forMobile = db.UserForMobile.FirstOrDefault(m => m.Mobile == user.Mobile);
- if (forMobile != null)
- {
- db.UserForMobile.Remove(forMobile);
- }
- UserForMakerCode forCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == user.MakerCode);
- if (forCode != null)
- {
- db.UserForMakerCode.Remove(forCode);
- }
- user.Status = -1;
- user.Mobile += "d";
- user.CertId += "d";
- function.WriteLog(user.Id + "于" + DateTime.Now.ToString() + "注销账号", "创客注销日志");
- // TODO: 每月扫描一次注销的创客,把注销创客伞下创客全部挂到注销创客的上级
- // TODO: 清除token,token登录返回
- db.SaveChanges();
- }
- return "success";
- }
- #endregion
- #region 开启
- /// <summary>
- /// 开启
- /// </summary>
- /// <returns></returns>
- public string Open(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "open");
- 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("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 关闭
- /// <summary>
- /// 关闭
- /// </summary>
- /// <returns></returns>
- public string Close(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "close");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Status", 0);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 一键企业创客
- /// <summary>
- /// 一键企业创客
- /// </summary>
- /// <returns></returns>
- public string OpenEnterpriseMaker(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "OpenEnterpriseMaker");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("BusinessFlag", 1);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 关闭企业创客
- /// <summary>
- /// 关闭企业创客
- /// </summary>
- /// <returns></returns>
- public string CloseEnterpriseMaker(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "CloseEnterpriseMaker");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("BusinessFlag", 0);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 一键大盟主
- /// <summary>
- /// 一键大盟主
- /// </summary>
- /// <returns></returns>
- public string SetBigLeader(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "SetBigLeader");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("LeaderLevel", 2);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 一键小盟主
- /// <summary>
- /// 一键小盟主
- /// </summary>
- /// <returns></returns>
- public string SetSmallLeader(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "SetSmallLeader");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("LeaderLevel", 1);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 风控
- public IActionResult Risk(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 风控
- [HttpPost]
- public string Risk(Users data)
- {
- Users user = db.Users.FirstOrDefault(m => m.Id == data.Id);
- if (user != null)
- {
- user.RiskFlag = data.RiskFlag;
- user.RiskRemark = data.RiskRemark;
- db.SaveChanges();
- }
- return "success";
- }
- #endregion
- #region 解除风控
- public string UnRisk(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "UnRisk");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("RiskFlag", 0);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 重置密码
- public string ResetPwd(int Id)
- {
- string NewPwd = function.get_Random(6);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("LoginPwd", function.MD532(NewPwd));
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, Id);
- AddSysLog(Id, "Users", "ResetPwd");
- return "success|" + NewPwd;
- }
- #endregion
- #region 排序
- /// <summary>
- /// 排序
- /// </summary>
- /// <param name="Id"></param>
- public string Sort(int Id, int Sort)
- {
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("Users", Sort, Id);
- AddSysLog(Id.ToString(), "Users", "sort");
- return "success";
- }
- #endregion
- #region 导入数据
- /// <summary>
- /// 导入数据
- /// </summary>
- /// <param name="ExcelData"></param>
- public string Import(string ExcelData, int Kind = 0)
- {
- ExcelData = HttpUtility.UrlDecode(ExcelData);
- JsonData list = JsonMapper.ToObject(ExcelData);
- if (Kind == 1)
- {
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- string MakerCode = dr[0].ToString();
- string SettleAmount = dr[2].ToString();
- UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
- if (UserCode != null)
- {
- Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
- if (User != null)
- {
- User.SettleAmount = decimal.Parse(function.CheckInt(SettleAmount));
- }
- }
- }
- db.SaveChanges();
- }
- else if (Kind == 2)
- {
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- string MakerCode = dr[0].ToString();
- string CashFreezeAmt = dr[2].ToString();
- UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
- if (UserCode != null)
- {
- Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
- if (User != null)
- {
- User.CashFreezeAmt = decimal.Parse(function.CheckInt(CashFreezeAmt));
- }
- }
- }
- db.SaveChanges();
- }
- else if (Kind == 3)
- {
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- string MakerCode = dr[0].ToString();
- string RiskFlag = dr[2].ToString();
- string RiskNote = dr[3].ToString();
- UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
- if (UserCode != null)
- {
- Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
- if (User != null)
- {
- User.RiskFlag = ulong.Parse(function.CheckInt(RiskFlag));
- User.RiskRemark = RiskNote;
- }
- }
- }
- db.SaveChanges();
- }
- else if (Kind == 4)
- {
- string error = "";
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- string MakerCode = dr[0].ToString();
- string OperationAmt = dr[2].ToString();//操作金额
- string OperationType = dr[3].ToString();//操作类型
- UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
- if (UserCode != null)
- {
- Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == User.Id);
- if (account == null)
- {
- account = db.UserAccount.Add(new UserAccount()
- {
- Id = User.Id,
- UserId = User.Id,
- }).Entity;
- db.SaveChanges();
- }
- if (User != null)
- {
- decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
- decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
- decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
- int ChangeType = 0;
- if (OperationType == "1" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
- {
- account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
- account.FreezeAmount += Convert.ToDecimal(OperationAmt);
- ChangeType = 61;
- }
- else if (OperationType == "1" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
- {
- error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "冻结金额大于余额" + '|' + '\n';
- }
- else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) <= account.FreezeAmount)
- {
- account.BalanceAmount += Convert.ToDecimal(OperationAmt);
- account.FreezeAmount -= Convert.ToDecimal(OperationAmt);
- ChangeType = 62;
- }
- else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) > account.FreezeAmount)
- {
- error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "解冻金额大于冻结金额" + '|' + '\n';
- }
- else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
- {
- account.TotalAmount -= Convert.ToDecimal(OperationAmt);
- account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
- ChangeType = 63;
- }
- else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
- {
- error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "扣减金额大于余额" + '|' + '\n';
- }
- else if (OperationType == "4")
- {
- account.TotalAmount += Convert.ToDecimal(OperationAmt);
- account.BalanceAmount += Convert.ToDecimal(OperationAmt);
- ChangeType = 64;
- }
- decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
- decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
- decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
- UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
- {
- CreateDate = DateTime.Now,
- UpdateDate = DateTime.Now,
- UserId = User.Id, //创客
- ChangeType = ChangeType, //变动类型
- ChangeAmount = Convert.ToDecimal(OperationAmt), //变更金额
- BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
- AfterTotalAmount = AfterTotalAmount, //变更后总金额
- BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
- AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
- BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
- AfterBalanceAmount = AfterBalanceAmount, //变更后余额
- Remark = dr[4].ToString(),
- }).Entity;
- db.SaveChanges();
- AddSysLog(User.Id.ToString(), "Users", "ChangeCashFreezeAmts");
- db.SaveChanges();
- }
- }
- }
- db.SaveChanges();
- return "warning" + error;
- }
- AddSysLog("0", "Users", "Import");
- return "success";
- }
- #endregion
- #region 导出Excel
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportExcel(Users data, string CreateDate, string ParentMakerCode, string ParentRealName, string AuthFlagSelect, int TopUserId, string RiskFlagSelect, string MerchantTypeSelect, int SelfId = 0, int ParentId = 0)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("MakerCode", "1"); //创客编号
- Fields.Add("RealName", "1"); //创客名称
- Fields.Add("Mobile", "1"); //手机号
- Fields.Add("CertId", "1"); //身份证号码
- Fields.Add("CreateDate", "3"); //注册时间
- Fields.Add("SettleAmount", "3"); //结算金额
- Fields.Add("CashFreezeAmt", "3"); //冻结金额
- Fields.Add("UserLevel", "0"); //创客等级
- string condition = " and Status>-1";
- //直属创客编号
- if (!string.IsNullOrEmpty(ParentMakerCode))
- {
- condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
- }
- //直属创客名称
- if (!string.IsNullOrEmpty(ParentRealName))
- {
- condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
- }
- //实名状态
- if (!string.IsNullOrEmpty(AuthFlagSelect))
- {
- condition += " and AuthFlag=" + AuthFlagSelect;
- }
- //顶级创客
- if (TopUserId > 0)
- {
- condition += " and ParentNav like '," + TopUserId + ",%'";
- }
- //风控标识
- if (!string.IsNullOrEmpty(RiskFlagSelect))
- {
- condition += " and RiskFlag=" + RiskFlagSelect;
- }
- //商户创客类型
- if (!string.IsNullOrEmpty(MerchantTypeSelect))
- {
- condition += " and MerchantType=" + MerchantTypeSelect;
- }
- if (SelfId > 0)
- {
- Users self = db.Users.FirstOrDefault(m => m.Id == SelfId);
- if (self != null)
- {
- string ParentNav = function.CheckNull(self.ParentNav);
- condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
- }
- }
- if (ParentId > 0)
- {
- condition += " and ParentUserId=" + ParentId;
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "MakerCode,RealName,ParentUserId,ParentNav,UserLevel,SettleAmount,CashFreezeAmt,CertId,Mobile,MerchantType,MerchantDate,AuthFlag,RiskFlag,CreateDate", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- dic["AuthFlag"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
- dic["RiskFlag"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
- dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
- dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
- int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
- dic["ParentMakerCode"] = puser.MakerCode;
- dic["ParentRealName"] = puser.RealName;
- string ParentNav = dic["ParentNav"].ToString();
- if (!string.IsNullOrEmpty(ParentNav))
- {
- string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
- if (list.Length > 1)
- {
- int TopId = int.Parse(function.CheckInt(list[1]));
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- }
- }
- dic.Remove("ParentUserId");
- dic.Remove("ParentNav");
- }
- 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("MakerCode", "创客编号");
- ReturnFields.Add("RealName", "创客姓名");
- ReturnFields.Add("UserLevel", "创客等级");
- ReturnFields.Add("SettleAmount", "提现金额(元)");
- ReturnFields.Add("CashFreezeAmt", "冻结金额(元)");
- ReturnFields.Add("CertId", "身份证号");
- ReturnFields.Add("Mobile", "联系手机");
- ReturnFields.Add("MerchantType", "商户创客类型");
- ReturnFields.Add("MerchantDate", "成为商户创客时间");
- ReturnFields.Add("ParentMakerCode", "直属创客编号");
- ReturnFields.Add("ParentRealName", "直属创客名称");
- ReturnFields.Add("TopMakerCode", "顶级创客编号");
- ReturnFields.Add("TopRealName", "顶级创客名称");
- ReturnFields.Add("AuthFlag", "实名状态");
- ReturnFields.Add("RiskFlag", "风控状态");
- ReturnFields.Add("CreateDate", "注册时间");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "Users", "ExportExcel");
- return Json(result);
- }
- #endregion
- #region 直属创客导出Excel
- /// <summary>
- /// 直属创客导出Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportZSExcel(Users data, string MakerCode, string ParentMakerCode)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
- }
- //直属创客编号
- if (!string.IsNullOrEmpty(ParentMakerCode))
- {
- condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "Id,MakerCode,RealName,UserLevel", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- int Id = int.Parse(dic["Id"].ToString());
- Users userZS = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- dic["MakerCode"] = userZS.MakerCode;
- dic["RealName"] = userZS.RealName;
- dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
- }
- 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("Id", "Id");
- ReturnFields.Add("MakerCode", "创客编号");
- ReturnFields.Add("RealName", "创客姓名");
- ReturnFields.Add("UserLevel", "创客等级");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "Users", "ExportZSExcel");
- return Json(result);
- }
- #endregion
- #region 上级创客导出Excel
- /// <summary>
- /// 上级创客导出Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportSJExcel(Users data, string MakerCode, string ParentMakerCode)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- var query = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
- Users self = db.Users.FirstOrDefault(m => m.Id == query.UserId);
- if (self != null)
- {
- string ParentNav = function.CheckNull(self.ParentNav);
- condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
- }
- }
- //直属创客编号
- if (!string.IsNullOrEmpty(ParentMakerCode))
- {
- var query = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ParentMakerCode);
- Users self = db.Users.FirstOrDefault(m => m.Id == query.UserId);
- if (self != null)
- {
- string ParentNav = function.CheckNull(self.ParentNav);
- condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
- }
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "Id,MakerCode,RealName,UserLevel", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- int Id = int.Parse(dic["Id"].ToString());
- Users userSJ = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- dic["MakerCode"] = userSJ.MakerCode;
- dic["RealName"] = userSJ.RealName;
- dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
- }
- 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("Id", "Id");
- ReturnFields.Add("MakerCode", "创客编号");
- ReturnFields.Add("RealName", "创客姓名");
- ReturnFields.Add("UserLevel", "创客等级");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "Users", "ExportExcel");
- return Json(result);
- }
- #endregion
- #region 同步数据
- /// <summary>
- /// 同步数据
- /// </summary>
- /// <returns></returns>
- public string SycnData(int Id = 0)
- {
- var Brands = db.KqProducts.Where(m => m.Status == 1).ToList();
- foreach (var Brand in Brands)
- {
- PublicFunction.SycnMachineCount(Id, Brand.Id);
- }
- AddSysLog(Id, "Users", "SycnData");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 同步交易额
- public IActionResult SycnTradeAmount(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 同步交易额
- [HttpPost]
- public string SycnTradeAmountDo(DateTime sdate, DateTime edate, int UserId, int BrandId)
- {
- if (sdate.AddMonths(1) < edate)
- {
- return "时间间隔不能超过1个月";
- }
- if (edate >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"))
- {
- return "结束时间只能是今天之前";
- }
- string check = RedisDbconn.Instance.Get<string>("ResetUserTradeQueue:" + UserId + ":" + BrandId);
- if (!string.IsNullOrEmpty(check))
- {
- return "请稍后再试";
- }
- try
- {
- RedisDbconn.Instance.AddList("ResetUserTradeQueue", UserId + "#cut#" + sdate.ToString("yyyy-MM-dd HH:mm:ss") + "#cut#" + edate.ToString("yyyy-MM-dd HH:mm:ss") + "#cut#" + BrandId);
- RedisDbconn.Instance.Set("ResetUserTradeQueue:" + UserId + ":" + BrandId, "wait");
- RedisDbconn.Instance.SetExpire("ResetUserTradeQueue:" + UserId + ":" + BrandId, 3600);
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计创客的交易额异常");
- return "同步异常";
- }
- return "success";
- }
- #endregion
- #region 创客展业城市
- public IActionResult City(Users data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
- ViewBag.TopUsers = TopUsers;
- return View();
- }
- #endregion
- #region 根据条件查询创客展业城市
- public JsonResult CityData(Users data, string ParentMakerCode, string ParentRealName, int TopUserId, string Areas, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("MakerCode", "1"); //创客编号
- Fields.Add("RealName", "1"); //创客名称
- Fields.Add("CitySetDate", "3"); //创建时间
- Fields.Add("Areas", "2"); //省市
- string condition = " and Status>-1";
- //直属创客编号
- if (!string.IsNullOrEmpty(ParentMakerCode))
- {
- condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
- }
- //直属创客名称
- if (!string.IsNullOrEmpty(ParentRealName))
- {
- condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
- }
- //顶级创客
- if (TopUserId > 0)
- {
- condition += " and ParentNav like '," + TopUserId + ",%'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
- dic["ParentMakerCode"] = puser.MakerCode;
- dic["ParentRealName"] = puser.RealName;
- string ParentNav = dic["ParentNav"].ToString();
- if (!string.IsNullOrEmpty(ParentNav))
- {
- int TopId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- }
- }
- return Json(obj);
- }
- #endregion
- #region 导出展业城市
- public JsonResult ExportCity(Users data, string CreateDate, string ParentMakerCode, string ParentRealName, string AuthFlagSelect, int TopUserId, string RiskFlagSelect, string MerchantTypeSelect)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("MakerCode", "1"); //创客编号
- Fields.Add("RealName", "1"); //创客名称
- Fields.Add("Mobile", "1"); //手机号
- Fields.Add("CertId", "1"); //身份证号码
- Fields.Add("CreateDate", "3"); //注册时间
- Fields.Add("SettleAmount", "3"); //结算金额
- Fields.Add("CashFreezeAmt", "3"); //冻结金额
- Fields.Add("UserLevel", "0"); //创客等级
- string condition = " and Status>-1";
- //直属创客编号
- if (!string.IsNullOrEmpty(ParentMakerCode))
- {
- condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
- }
- //直属创客名称
- if (!string.IsNullOrEmpty(ParentRealName))
- {
- condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
- }
- //实名状态
- if (!string.IsNullOrEmpty(AuthFlagSelect))
- {
- condition += " and AuthFlag=" + AuthFlagSelect;
- }
- //顶级创客
- if (TopUserId > 0)
- {
- condition += " and ParentNav like '," + TopUserId + ",%'";
- }
- //风控标识
- if (!string.IsNullOrEmpty(RiskFlagSelect))
- {
- condition += " and RiskFlag=" + RiskFlagSelect;
- }
- //商户创客类型
- if (!string.IsNullOrEmpty(MerchantTypeSelect))
- {
- condition += " and MerchantType=" + MerchantTypeSelect;
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "ParentUserId,ParentNav,UserLevel,SettleAmount,CashFreezeAmt,CertId,Mobile,MerchantType,MerchantDate,AuthFlag,RiskFlag,CreateDate", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- dic["AuthFlag"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
- dic["RiskFlag"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
- dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
- dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
- int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
- dic["ParentMakerCode"] = puser.MakerCode;
- dic["ParentRealName"] = puser.RealName;
- string ParentNav = dic["ParentNav"].ToString();
- if (!string.IsNullOrEmpty(ParentNav))
- {
- int TopId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- }
- dic.Remove("ParentUserId");
- dic.Remove("ParentNav");
- }
- 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("MakerCode", "创客编号");
- ReturnFields.Add("RealName", "创客姓名");
- ReturnFields.Add("UserLevel", "创客等级");
- ReturnFields.Add("SettleAmount", "提现金额(元)");
- ReturnFields.Add("CashFreezeAmt", "冻结金额(元)");
- ReturnFields.Add("CertId", "身份证号");
- ReturnFields.Add("Mobile", "联系手机");
- ReturnFields.Add("MerchantType", "商户创客类型");
- ReturnFields.Add("MerchantDate", "成为商户创客时间");
- ReturnFields.Add("ParentMakerCode", "直属创客编号");
- ReturnFields.Add("ParentRealName", "直属创客名称");
- ReturnFields.Add("TopMakerCode", "顶级创客编号");
- ReturnFields.Add("TopRealName", "顶级创客名称");
- ReturnFields.Add("AuthFlag", "实名状态");
- ReturnFields.Add("RiskFlag", "风控状态");
- ReturnFields.Add("CreateDate", "注册时间");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "Users", "ExportExcel");
- return Json(result);
- }
- #endregion
- #region 根据条件查询直属创客交易额列表
- /// <summary>
- /// 直属创客交易额列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Children(Users data, string right, int ParentId = 0, string MakerCode = "")
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- ViewBag.ParentId = ParentId.ToString();
- ViewBag.MakerCode = MakerCode;
- List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
- ViewBag.TopUsers = TopUsers;
- List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
- ViewBag.Levels = Levels;
- List<KqProducts> Brands = db.KqProducts.OrderBy(m => m.Id).ToList();
- ViewBag.Brands = Brands;
- return View();
- }
- #endregion
- #region 根据条件查询直属创客交易额列表
- /// <summary>
- /// 直属创客交易额列表
- /// </summary>
- /// <returns></returns>
- public JsonResult ChildrenData(Users data, int BrandSelect, string MakerCode, string CreateDateData, int ParentId = 0, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- WebCMSEntities db = new WebCMSEntities();
- Fields.Add("MakerCode", "1"); //创客编号
- int BrandId = BrandSelect;
- string start = "";
- string end = "";
- string condition = " and Status>-1 and AuthFlag >0";
- string con = " and Status>-1";
- string cons = " and Status>=-1";
- string sort = "Id desc";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
- }
- if (ParentId > 0)
- {
- condition += " and ParentUserId=" + ParentId + " or Id=" + ParentId;
- }
- //时间不为空
- if (!string.IsNullOrEmpty(CreateDateData))
- {
- string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- start = datelist[0].Replace("-", "");
- end = datelist[1].Replace("-", "");
- con += " and TradeDate>='" + start + "' and TradeDate<='" + end + "'";
- cons += " and SeoKeyword >=" + start + " and SeoKeyword <=" + end;
- }
- //时间为空
- else
- {
- start = DateTime.Now.ToString("yyyyMM") + "01";
- end = DateTime.Now.AddMonths(1).ToString("yyyyMM") + "01";
- con += " and TradeDate>='" + start + "' and TradeDate<'" + end + "'";
- cons += " and SeoKeyword >=" + start + " and SeoKeyword <" + end;
- }
- if (!string.IsNullOrEmpty(BrandSelect.ToString()) && BrandId > 0)
- {
- con += " and BrandId='" + BrandId + "'";
- cons += " and BrandId='" + BrandId + "'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- int UId = int.Parse(dic["Id"].ToString());
- var Info = GetMonthTradeForBrand(UId, start, end, BrandId);
- dic["TotalAmtfc"] = Convert.ToDecimal(Info["TotalAmtfc"].ToString()) + Convert.ToDecimal(Info["YAmtfc"].ToString());
- dic["DAmtfc"] = Convert.ToDecimal(Info["DAmtfc"].ToString());
- dic["JAmtfc"] = Convert.ToDecimal(Info["JAmtfc"].ToString());
- dic["JfAmtfc"] = Convert.ToDecimal(Info["JfAmtfc"].ToString());
- dic["JCountfc"] = Convert.ToInt32(Info["JCountfc"].ToString());
- dic["YAmtfc"] = Convert.ToDecimal(Info["YAmtfc"].ToString());
- dic["TotalAmtwd"] = Convert.ToDecimal(Info["TotalAmtwd"].ToString()) + Convert.ToDecimal(Info["YAmtwd"].ToString());
- dic["DAmtwd"] = Convert.ToDecimal(Info["DAmtwd"].ToString());
- dic["JAmtwd"] = Convert.ToDecimal(Info["JAmtwd"].ToString());
- dic["JfAmtwd"] = Convert.ToDecimal(Info["JfAmtwd"].ToString());
- dic["JCountwd"] = Convert.ToInt32(Info["JCountwd"].ToString());
- dic["YAmtwd"] = Convert.ToDecimal(Info["YAmtwd"].ToString());
- dic["TotalAmtyl"] = Convert.ToDecimal(Info["TotalAmtyl"].ToString()) + Convert.ToDecimal(Info["YAmtyl"].ToString());
- dic["DAmtyl"] = Convert.ToDecimal(Info["DAmtyl"].ToString());
- dic["JAmtyl"] = Convert.ToDecimal(Info["JAmtyl"].ToString());
- dic["JfAmtyl"] = Convert.ToDecimal(Info["JfAmtyl"].ToString());
- dic["JCountyl"] = Convert.ToInt32(Info["JCountyl"].ToString());
- dic["YAmtyl"] = Convert.ToDecimal(Info["YAmtyl"].ToString());
- dic["TBCount"] = Info["TBCount"].ToString();
- dic["TACount"] = Info["TACount"].ToString();
- // dic["BCount"] = Info["BCount"].ToString();
- // dic["ACount"] = Info["ACount"].ToString();
- }
- //个人
- //扶持期
- decimal TotalAmtfc = 0;
- decimal DAmtfc = 0;
- decimal JAmtfc = 0;
- decimal JfAmtfc = 0;
- int JCountfc = 0;
- decimal YAmtfc = 0;
- //稳定期
- decimal TotalAmtwd = 0;
- decimal DAmtwd = 0;
- decimal JAmtwd = 0;
- decimal JfAmtwd = 0;
- int JCountwd = 0;
- decimal YAmtwd = 0;
- //盈利期
- decimal TotalAmtyl = 0;
- decimal DAmtyl = 0;
- decimal JAmtyl = 0;
- decimal JfAmtyl = 0;
- int JCountyl = 0;
- decimal YAmtyl = 0;
- //团队
- //扶持期
- decimal TotalAmtfc1 = 0;
- decimal DAmtfc1 = 0;
- decimal JAmtfc1 = 0;
- decimal JfAmtfc1 = 0;
- int JCountfc1 = 0;
- decimal YAmtfc1 = 0;
- //稳定期
- decimal TotalAmtwd1 = 0;
- decimal DAmtwd1 = 0;
- decimal JAmtwd1 = 0;
- decimal JfAmtwd1 = 0;
- int JCountwd1 = 0;
- decimal YAmtwd1 = 0;
- //盈利期
- decimal TotalAmtyl1 = 0;
- decimal DAmtyl1 = 0;
- decimal JAmtyl1 = 0;
- decimal JfAmtyl1 = 0;
- int JCountyl1 = 0;
- decimal YAmtyl1 = 0;
- int PBCount = 0;
- int PACount = 0;
- int TBCount = 0;
- int TACount = 0;
- Dictionary<string, object> other = new Dictionary<string, object>();
- DataTable dt = OtherMySqlConn.dtable("SELECT Sum(HelpDirectTradeAmt + HelpDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitTradeAmt - HelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpDirectTradeAmt,0)),Sum(NotHelpDirectTradeAmt + NotHelpDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitTradeAmt - NotHelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpDirectTradeAmt,0)),Sum(ProfitDirectTradeAmt + ProfitDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitTradeAmt - ProfitDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'self' and UserId =" + ParentId + "" + con);
- if (dt.Rows.Count > 0)
- {
- TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
- DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
- JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
- JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
- JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
- YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
- TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
- DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
- JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
- JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
- JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
- YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
- TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
- DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
- JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
- JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
- JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
- YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
- }
- //统计激活数(个人、团队)
- dt = OtherMySqlConn.dtable("SELECT SUM(if(SeoTitle='self',ActiveBuddyMerStatus,0)),SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= " + ParentId + "" + cons);
- if (dt.Rows.Count > 0)
- {
- PACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
- TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][1].ToString()));
- }
- DataTable dts = OtherMySqlConn.dtable("SELECT Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitTradeAmt - HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpNonDirectTradeAmt,0)),Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitTradeAmt - NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpNonDirectTradeAmt,0)),Sum(ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitTradeAmt - ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitNonDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'team' and UserId =" + ParentId + "" + con);
- if (dts.Rows.Count > 0)
- {
- TotalAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
- DAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][1].ToString()));
- JAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][2].ToString()));
- JfAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][3].ToString()));
- JCountfc1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][4].ToString()));
- YAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][5].ToString()));
- TotalAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][6].ToString()));
- DAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][7].ToString()));
- JAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][8].ToString()));
- JfAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][9].ToString()));
- JCountwd1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][10].ToString()));
- YAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][11].ToString()));
- TotalAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][12].ToString()));
- DAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][13].ToString()));
- JAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][14].ToString()));
- JfAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][15].ToString()));
- JCountyl1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][16].ToString()));
- YAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][17].ToString()));
- }
- other.Add("TotalAmtfc", TotalAmtfc);
- other.Add("DAmtfc", DAmtfc);
- other.Add("JAmtfc", JAmtfc);
- other.Add("JfAmtfc", JfAmtfc);
- other.Add("JCountfc", JCountfc);
- other.Add("YAmtfc", YAmtfc);
- other.Add("TotalAmtwd", TotalAmtwd);
- other.Add("DAmtwd", DAmtwd);
- other.Add("JAmtwd", JAmtwd);
- other.Add("JfAmtwd", JfAmtwd);
- other.Add("JCountwd", JCountwd);
- other.Add("YAmtwd", YAmtwd);
- other.Add("TotalAmtyl", TotalAmtyl);
- other.Add("DAmtyl", DAmtyl);
- other.Add("JAmtyl", JAmtyl);
- other.Add("JfAmtyl", JfAmtyl);
- other.Add("JCountyl", JCountyl);
- other.Add("YAmtyl", YAmtyl);
- other.Add("TotalAmtfc1", TotalAmtfc1);
- other.Add("DAmtfc1", DAmtfc1);
- other.Add("JAmtfc1", JAmtfc1);
- other.Add("JfAmtfc1", JfAmtfc1);
- other.Add("JCountfc1", JCountfc1);
- other.Add("YAmtfc1", YAmtfc1);
- other.Add("TotalAmtwd1", TotalAmtwd1);
- other.Add("DAmtwd1", DAmtwd1);
- other.Add("JAmtwd1", JAmtwd1);
- other.Add("JfAmtwd1", JfAmtwd1);
- other.Add("JCountwd1", JCountwd1);
- other.Add("YAmtwd1", YAmtwd1);
- other.Add("TotalAmtyl1", TotalAmtyl1);
- other.Add("DAmtyl1", DAmtyl1);
- other.Add("JAmtyl1", JAmtyl1);
- other.Add("JfAmtyl1", JfAmtyl1);
- other.Add("JCountyl1", JCountyl1);
- other.Add("YAmtyl1", YAmtyl1);
- other.Add("PBCount", PBCount);
- other.Add("PACount", PACount);
- other.Add("TBCount", TBCount);
- other.Add("TACount", TACount);
- db.Dispose();
- obj.Add("other", other);
- return Json(obj);
- }
- public Dictionary<string, object> GetMonthTradeForBrand(int UserId, string sTradeDate, string eTradeDate, int BrandId)
- {
- WebCMSEntities db = new WebCMSEntities();
- string condition = " and Status>-1";
- string cons = " and Status>=-1";
- //产品类型
- if (!string.IsNullOrEmpty(BrandId.ToString()) && BrandId > 0)
- {
- condition += " and BrandId =" + BrandId;
- cons += " and BrandId =" + BrandId;
- }
- //创客Id
- if (!string.IsNullOrEmpty(UserId.ToString()))
- {
- condition += " and UserId =" + UserId;
- }
- //开始时间
- if (!string.IsNullOrEmpty(sTradeDate) && !string.IsNullOrEmpty(eTradeDate))
- {
- condition += " and TradeDate >=" + Convert.ToInt32(sTradeDate) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
- cons += " and SeoKeyword >=" + Convert.ToInt32(sTradeDate) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
- }
- //结束时间
- else
- {
- var start = DateTime.Now.ToString("yyyyMM") + "01";
- condition += " and TradeDate >=" + Convert.ToInt32(start) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
- cons += " and SeoKeyword >=" + Convert.ToInt32(start) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
- }
- //扶持期
- decimal TotalAmtfc = 0;
- decimal DAmtfc = 0;
- decimal JAmtfc = 0;
- decimal JfAmtfc = 0;
- int JCountfc = 0;
- decimal YAmtfc = 0;
- //稳定期
- decimal TotalAmtwd = 0;
- decimal DAmtwd = 0;
- decimal JAmtwd = 0;
- decimal JfAmtwd = 0;
- int JCountwd = 0;
- decimal YAmtwd = 0;
- //盈利期
- decimal TotalAmtyl = 0;
- decimal DAmtyl = 0;
- decimal JAmtyl = 0;
- decimal JfAmtyl = 0;
- int JCountyl = 0;
- decimal YAmtyl = 0;
- int BCount = 0;
- int ACount = 0;
- int PBCount = 0;
- int PACount = 0;
- int TBCount = 0;
- int TACount = 0;
- Dictionary<string, object> obj = new Dictionary<string, object>();
- DataTable dt = OtherMySqlConn.dtable("SELECT Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitTradeAmt - HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpNonDirectTradeAmt,0)),Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitTradeAmt - NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpNonDirectTradeAmt,0)),Sum(ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitTradeAmt - ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitNonDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'team'" + condition);
- if (dt.Rows.Count > 0)
- {
- TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
- DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
- JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
- JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
- JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
- YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
- TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
- DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
- JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
- JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
- JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
- YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
- TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
- DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
- JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
- JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
- JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
- YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
- }
- //统计激活数(个人、团队)
- dt = OtherMySqlConn.dtable("SELECT SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= " + UserId + "" + cons);
- if (dt.Rows.Count > 0)
- {
- TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
- }
- obj.Add("TotalAmtfc", TotalAmtfc);
- obj.Add("DAmtfc", DAmtfc);
- obj.Add("JAmtfc", JAmtfc);
- obj.Add("JfAmtfc", JfAmtfc);
- obj.Add("JCountfc", JCountfc);
- obj.Add("YAmtfc", YAmtfc);
- obj.Add("TotalAmtwd", TotalAmtwd);
- obj.Add("DAmtwd", DAmtwd);
- obj.Add("JAmtwd", JAmtwd);
- obj.Add("JfAmtwd", JfAmtwd);
- obj.Add("JCountwd", JCountwd);
- obj.Add("YAmtwd", YAmtwd);
- obj.Add("TotalAmtyl", TotalAmtyl);
- obj.Add("DAmtyl", DAmtyl);
- obj.Add("JAmtyl", JAmtyl);
- obj.Add("JfAmtyl", JfAmtyl);
- obj.Add("JCountyl", JCountyl);
- obj.Add("YAmtyl", YAmtyl);
- obj.Add("BCount", BCount);
- obj.Add("ACount", ACount);
- obj.Add("PBCount", PBCount);
- obj.Add("PACount", PACount);
- obj.Add("TBCount", TBCount);
- obj.Add("TACount", TACount);
- db.Dispose();
- return obj;
- }
- #endregion
- #region 未实名创客列表
- /// <summary>
- /// 根据条件查询未实名创客列表
- /// </summary>
- /// <returns></returns>
- public IActionResult AuthIndex(Users data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询未实名创客列表
- /// <summary>
- /// 未实名创客列表
- /// </summary>
- /// <returns></returns>
- public JsonResult AuthIndexData(Users data, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("MakerCode", "1"); //创客编号
- string condition = " and Status>-1 and AuthFlag=0 and RealName is not null and CertId is not null and SettleBankCardNo is not null and SettleBankCardName is not null";
- string sort = "Id desc";
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- dic["AuthFlagName"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
- dic["RiskFlagName"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
- dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
- dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
- int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
- dic["ParentMakerCode"] = puser.MakerCode;
- dic["ParentRealName"] = puser.RealName;
- string ParentNav = dic["ParentNav"].ToString();
- if (!string.IsNullOrEmpty(ParentNav))
- {
- string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
- if (list.Length > 1)
- {
- int TopId = int.Parse(function.CheckInt(list[1]));
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- }
- }
- }
- return Json(obj);
- }
- #endregion
- #region 认证
- /// <summary>
- /// 认证
- /// </summary>
- /// <returns></returns>
- public string Auth(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "Users", "Auth");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("AuthFlag", 1);
- Fields.Add("AuthDate", DateTime.Now);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 修改盟主金额
- public IActionResult ChangeLeaderAmount(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 修改盟主金额
- [HttpPost]
- public string ChangeLeaderAmount(Users data, string ChangeAmount, int AmountType, string Note, int Kind)
- {
- int UserId = data.Id;
- var Amount = Convert.ToDecimal(ChangeAmount);
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
- if (account == null)
- {
- account = db.UserAccount.Add(new UserAccount()
- {
- Id = UserId,
- UserId = UserId,
- }).Entity;
- db.SaveChanges();
- }
- //盟主储蓄金
- if (AmountType == 1)
- {
- if ((Kind == 1 || Kind == 3) && Amount > account.LeaderReserve)
- {
- return "盟主储蓄金不足";
- }
- decimal BeforeLeaderReserve = account.LeaderReserve; //变更前盟主储蓄金
- decimal BeforeLeaderBalanceAmount = account.LeaderBalanceAmount; //变更前盟主可提现余额
- int ChangeType = 0;
- if (Kind == 1 && Amount <= account.LeaderReserve)
- {
- account.LeaderReserve -= Amount;
- account.TotalProfit += Amount;
- string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统冻结(盟主储蓄金)',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
- }
- else if (Kind == 1 && Amount > account.LeaderReserve)
- {
- return "冻结金额大于盟主储蓄金";
- }
- else if (Kind == 2 && Amount <= account.TotalProfit)
- {
- account.LeaderReserve += Amount;
- account.TotalProfit -= Amount;
- string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统解冻(盟主储蓄金)',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
- }
- else if (Kind == 2 && Amount > account.TotalProfit)
- {
- return "解冻金额大于冻结金额";
- }
- else if (Kind == 3 && Amount <= account.LeaderReserve)
- {
- account.LeaderReserve -= Amount;
- ChangeType = 4;
- decimal AfterLeaderReserve = account.LeaderReserve; //变更后盟主储蓄金
- decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后盟主可提现余额
- var query = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
- {
- CreateDate = DateTime.Now, //创建时间
- UserId = UserId, //创客
- Remark = "系统扣减(盟主储蓄金)",
- ChangeType = ChangeType,
- BeforeAmt = BeforeLeaderReserve,
- AfterAmt = AfterLeaderReserve,
- ChangeAmt = Amount,
- TradeDate = DateTime.Now.ToString("yyyyMMdd"),
- TradeMonth = DateTime.Now.ToString("yyyyMM"),
- }).Entity;
- db.SaveChanges();
- string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统扣减(盟主储蓄金)',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
- }
- else if (Kind == 3 && Amount > account.LeaderReserve)
- {
- return "扣减金额大于盟主储蓄金";
- }
- else if (Kind == 4)
- {
- account.LeaderReserve += Amount;
- ChangeType = 1;
- decimal AfterLeaderReserve = account.LeaderReserve; //变更后总金额
- decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后冻结金额
- var query = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
- {
- CreateDate = DateTime.Now, //创建时间
- UserId = UserId, //创客
- Remark = "系统增加(盟主储蓄金)",
- ChangeType = ChangeType,
- BeforeAmt = BeforeLeaderReserve,
- AfterAmt = AfterLeaderReserve,
- ChangeAmt = Amount,
- TradeDate = DateTime.Now.ToString("yyyyMMdd"),
- TradeMonth = DateTime.Now.ToString("yyyyMM"),
- }).Entity;
- db.SaveChanges();
- string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统增加(盟主储蓄金)',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
- }
- AddSysLog(data.Id.ToString(), "Users", "ChangeLeaderAmount");
- db.SaveChanges();
- }
- //盟主可提现余额
- if (AmountType == 2)
- {
- if ((Kind == 1 || Kind == 3) && Amount > account.LeaderBalanceAmount)
- {
- return "盟主可提现余额不足";
- }
- decimal BeforeLeaderReserve = account.LeaderReserve; //变更前盟主储蓄金
- decimal BeforeLeaderBalanceAmount = account.LeaderBalanceAmount; //变更前盟主可提现余额
- int ChangeType = 0;
- if (Kind == 1 && Amount <= account.LeaderReserve)
- {
- account.LeaderBalanceAmount -= Amount;
- account.TotalServiceProfit += Amount;
- string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统冻结(盟主可提现余额)',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
- }
- else if (Kind == 1 && Amount > account.LeaderBalanceAmount)
- {
- return "冻结金额大于盟主可提现余额";
- }
- else if (Kind == 2 && Amount <= account.TotalServiceProfit)
- {
- account.LeaderBalanceAmount += Amount;
- account.TotalServiceProfit -= Amount;
- string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统解冻(盟主可提现余额)',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
- }
- else if (Kind == 2 && Amount > account.TotalServiceProfit)
- {
- return "解冻金额大于冻结金额";
- }
- else if (Kind == 3 && Amount <= account.LeaderBalanceAmount)
- {
- account.LeaderBalanceAmount -= Amount;
- ChangeType = 6;
- decimal AfterLeaderReserve = account.LeaderReserve; //变更后总金额
- decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后冻结金额
- var query = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
- {
- CreateDate = DateTime.Now, //创建时间
- UserId = UserId, //创客
- Remark = "系统扣减(盟主可提现余额)",
- ChangeType = ChangeType,
- BeforeAmt = BeforeLeaderBalanceAmount,
- AfterAmt = AfterLeaderBalanceAmount,
- ChangeAmt = Amount,
- TradeDate = DateTime.Now.ToString("yyyyMMdd"),
- TradeMonth = DateTime.Now.ToString("yyyyMM"),
- }).Entity;
- db.SaveChanges();
- string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统扣减(盟主可提现余额)',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
- }
- else if (Kind == 3 && Amount > account.LeaderBalanceAmount)
- {
- return "扣减金额大于盟主可提现余额";
- }
- else if (Kind == 4)
- {
- account.LeaderBalanceAmount += Amount;
- ChangeType = 5;
- decimal AfterLeaderReserve = account.LeaderReserve; //变更后总金额
- decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后冻结金额
- var query = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
- {
- CreateDate = DateTime.Now, //创建时间
- UserId = UserId, //创客
- Remark = "系统增加(盟主可提现余额)",
- ChangeType = ChangeType,
- BeforeAmt = BeforeLeaderBalanceAmount,
- AfterAmt = AfterLeaderBalanceAmount,
- ChangeAmt = Amount,
- TradeDate = DateTime.Now.ToString("yyyyMMdd"),
- TradeMonth = DateTime.Now.ToString("yyyyMM"),
- }).Entity;
- db.SaveChanges();
- string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统增加(盟主可提现余额)',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
- }
- AddSysLog(data.Id.ToString(), "Users", "ChangeLeaderAmount");
- db.SaveChanges();
- }
- return "success";
- }
- #endregion
- #region 伞下创客列表
- /// <summary>
- /// 根据条件查询伞下创客列表
- /// </summary>
- /// <returns></returns>
- public IActionResult SanIndex(Users data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
- ViewBag.TopUsers = TopUsers;
- List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
- ViewBag.Levels = Levels;
- return View();
- }
- #endregion
- #region 根据条件查询伞下创客列表
- /// <summary>
- /// 伞下创客列表
- /// </summary>
- /// <returns></returns>
- public JsonResult SanIndexData(Users data, string MakerCode, string IsLeader, string IsOp, string CreateDateData, string UserYsLevel, string UserLevel, int ShowFlag = 0, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- if (ShowFlag == 0)
- {
- Dictionary<string, object> objs = new Dictionary<string, object>();
- return Json(objs);
- }
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- var userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
- if (userForMakerCode.UserId == 0)
- {
- return Json(new AppResultJson() { Status = "-1", Info = "未找到创客" + MakerCode + "关联数据", Data = "" });
- }
- var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
- if (user.Id == 0)
- {
- return Json(new AppResultJson() { Status = "-1", Info = "创客" + MakerCode + "不存在", Data = "" });
- }
- condition += " and ParentNav like '%," + user.Id + ",%'";
- }
- if (!string.IsNullOrEmpty(IsLeader))
- {
- condition += " and LeaderLevel=" + IsLeader;
- }
- if (!string.IsNullOrEmpty(UserYsLevel))
- {
- var UserIds = "";
- var Rank = int.Parse(UserYsLevel);
- var list = db.UserRankWhite.Where(m => m.Status > -1 && m.Rank == Rank).ToList();
- foreach (var item in list)
- {
- UserIds += item.UserId + ",";
- }
- UserIds = UserIds.TrimEnd(',');
- condition += " and Id IN(" + UserIds + ")";
- }
- if (!string.IsNullOrEmpty(UserLevel))
- {
- condition += " and UserLevel=" + UserLevel;
- }
- if (!string.IsNullOrEmpty(IsOp))
- {
-
- }
- 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'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- dic["AuthFlagName"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
- dic["RiskFlagName"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
- dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
- int UserId = int.Parse(dic["Id"].ToString());
- int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
- dic["ParentMakerCode"] = puser.MakerCode;
- dic["ParentRealName"] = puser.RealName;
- var userRankWhite = db.UserRankWhite.FirstOrDefault(m => m.UserId == UserId) ?? new UserRankWhite();
- dic["UserYsLevel"] = RelationClass.GetUserLevelSetInfo(userRankWhite.Rank);
- int LeaderLevel = int.Parse(dic["LeaderLevel"].ToString());
- if (LeaderLevel == 1)
- {
- dic["IsLeader"] = "小盟主";
- }
- else if (LeaderLevel == 2)
- {
- dic["IsLeader"] = "大盟主";
- }
- else
- {
- dic["IsLeader"] = "";
- }
- dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
- }
- return Json(obj);
- }
- #endregion
- }
- }
|