| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806 |
- /*
- * 创客
- */
- 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(',');
- var topUserInfo = new Users();
- if (list.Length > 1)
- {
- topUserInfo = db.Users.FirstOrDefault(m => m.Id == int.Parse(list[1])) ?? new Users();
- }
- else
- {
- topUserInfo = db.Users.FirstOrDefault(m => m.Id == int.Parse(list[0])) ?? new Users();
- }
- dic["TopMakerCode"] = topUserInfo.MakerCode;
- dic["TopRealName"] = topUserInfo.RealName;
- }
- }
- return Json(obj);
- }
- #endregion
- #region 创客列表
- /// <summary>
- /// 根据条件查询创客列表
- /// </summary>
- /// <returns></returns>
- public IActionResult CancleUsers(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 CancleUsersData(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"); //创客等级
- 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 string ResetSmallPosCount(string Id)
- {
- DataTable dt = OtherMySqlConn.dtable("update SmallStoreHouse s set TotalNum=(select count(Id) from PreSendStockDetail where ToUserId=s.UserId and ApplyFlag=0 and Status>-1 and Status<2),LaveNum=10-(select count(Id) from PreSendStockDetail where ToUserId=s.UserId and ApplyFlag=0 and Status>-1 and Status<2) where UserId=" + Id);
- string text = string.Format("重置小分仓机具数,UserId: '" + Id + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "重置小分仓机具数");
- 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.创客名下无分仓及运营中心
- // 满足以上全部条件的用户可申请注销,申请后用户二次填写确认填写信息(姓名、手机号、身份证号)即可完成注销
- 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 "注销失败,未满足条件:已实名创客,无开通商户。如有疑问,请联系客服";
- // }
- // DateTime checkDate = DateTime.Now.AddDays(-7);
- // check = db.Orders.Any(m => m.CreateDate >= checkDate && m.Status > 0 && m.UserId == user.Id);
- // if (check)
- // {
- // return "注销失败,未满足条件:近7天未在商城下单过商品。如有疑问,请联系客服";
- // }
- // check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.IsPurchase == 0);
- // if (check)
- // {
- // return "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服";
- // }
- // check = db.PosCoupons.Any(m => m.UserId == user.Id && m.IsUse == 0);
- // if (check)
- // {
- // return "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服";
- // }
- bool check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.BindingState == 0);
- if (check)
- {
- return "注销失败,未满足条件:名下存在未绑定机具。如有疑问,请联系客服";
- }
- check = db.MachineApply.Any(m => m.Status == 0 && m.UserId == user.Id);
- if (check)
- {
- return "注销失败,未满足条件:名下存在未完成的机具循环兑换订单。如有疑问,请联系客服";
- }
- check = db.PreSendStockDetail.Any(m => m.Status == 1 && m.AuthFlag == 0 && m.ToUserId == user.Id);
- if (check)
- {
- return "注销失败,未满足条件:名下存在预发机。如有疑问,请联系客服";
- }
- if (user.UserType == 1)
- {
- return "注销失败,未满足条件:名下存在运营中心。如有疑问,请联系客服";
- }
- check = db.StoreHouse.Any(m => m.Status == 1 && m.UserId == user.Id);
- if (check)
- {
- return "注销失败,未满足条件:名下存在分仓。如有疑问,请联系客服";
- }
- UserForMobile forMobile = db.UserForMobile.FirstOrDefault(m => m.Mobile == user.Mobile);
- if (forMobile != null)
- {
- db.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";
- user.LogOutDate = DateTime.Now;
- }
- else
- {
- 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";
- user.LogOutDate = DateTime.Now;
- }
- 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();
- }
- //个人
- //扶持期
- 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 SettleBankName 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))
- {
- var UserIds = "";
- DataTable dt = CustomerSqlConn.dtable("SELECT UserId FROM SysAdmin WHERE Status>-1 and Sort>0 and QueryCount>0 and AdminName!='admin'", OpConn);
- foreach (DataRow item in dt.Rows)
- {
- UserIds += item["UserId"].ToString() + ",";
- }
- UserIds = UserIds.TrimEnd(',');
- if (IsOp == "1")
- {
- condition += " and Id IN(" + UserIds + ")";
- }
- if (IsOp == "2")
- {
- condition += " and Id NOT IN(" + UserIds + ")";
- }
- }
- 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"] = "";
- }
- var sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.Status > -1 && m.Sort > 0 && m.QueryCount > 0 && m.AdminName != "admin" && m.UserId == UserId) ?? new OpModels.SysAdmin();
- if (sysAdmin.Id > 0)
- {
- dic["IsOp"] = sysAdmin.OpCode;
- }
- else
- {
- dic["IsOp"] = "";
- }
- dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
- }
- return Json(obj);
- }
- #endregion
- #region 重置小分仓额度
- /// <summary>
- /// 重置小分仓额度
- /// </summary>
- /// <returns></returns>
- public string SycnAmountData(int Id = 0)
- {
- if (Id > 0)
- {
- var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == Id) ?? new UserAccount();
- RedisDbconn.Instance.AddList("ResetSmallStoreByUserIdQueue", userAccount.Id);
- }
- AddSysLog(Id, "UserAccount", "SycnAmountData");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 批量查询创客信息
- public IActionResult BatchSeeUserInfo(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 批量查询创客信息
- public JsonResult BatchSeeUserInfoDo(string PosSns, string MerNos, int page = 1, int limit = 30)
- {
- var error = "";
- //实际押金
- Dictionary<string, object> errorInfo = new Dictionary<string, object>();
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- if (string.IsNullOrEmpty(PosSns) && string.IsNullOrEmpty(MerNos))
- {
- Dictionary<string, object> objs = new Dictionary<string, object>();
- return Json(objs);
- }
- else if (!string.IsNullOrEmpty(PosSns) && !string.IsNullOrEmpty(MerNos))
- {
- Dictionary<string, object> objs = new Dictionary<string, object>();
- return Json(objs);
- }
- else
- {
- if (!string.IsNullOrEmpty(PosSns))
- {
- string[] PosSnsList = PosSns.Replace("\r", "").Replace("\n", ",").Replace(" ", ",").Split(',');
- foreach (string PosSn in PosSnsList)
- {
- string SeoKeyword = "0";
- Dictionary<string, object> data = new Dictionary<string, object>();
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
- if (pos.Id > 0)
- {
- // error += "机具" + PosSn + "不存在" + '\n';
- // }
- // else
- // {
- var TopMakerCode = ""; //顶级创客编号
- var TopRealName = ""; //顶级创客名称
- var SecondMakerCode = ""; //次顶级创客编号
- var SecondRealName = ""; //次顶级创客姓名
- var ThirdMakerCode = ""; //次次顶级创客编号
- var ThirdRealName = ""; //次次顶级创客姓名
- var mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new PosMerchantInfo();
- var brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
- // if (brand.Id > 0 && brand.SingleDepositApi == 0 && !string.IsNullOrEmpty(SeoKeyword))
- if (brand.Id > 0 && brand.NoticeMoneyUnit == 2 && !string.IsNullOrEmpty(pos.SeoKeyword))
- {
- SeoKeyword = (decimal.Parse(pos.SeoKeyword) / 100).ToString();
- }
- else
- {
- SeoKeyword = pos.SeoKeyword;
- }
- var user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
- var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == user.Id) ?? new UserAccount();
- if (!string.IsNullOrEmpty(user.ParentNav))
- {
- string[] ParentNavList = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
- var topUserInfo = new Users();
- var secondUserInfo = new Users();
- var thirdUserInfo = new Users();
- if (ParentNavList.Length > 1)
- {
- topUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[1]))) ?? new Users();
- if (ParentNavList.Length > 2)
- {
- secondUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[2]))) ?? new Users();
- if (ParentNavList.Length > 3)
- {
- thirdUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[3]))) ?? new Users();
- }
- }
- }
- else
- {
- topUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[0]))) ?? new Users();
- }
- TopMakerCode = topUserInfo.MakerCode; //顶级创客编号
- TopRealName = topUserInfo.RealName; //顶级创客名称
- SecondMakerCode = secondUserInfo.MakerCode; //次顶级创客编号
- SecondRealName = secondUserInfo.RealName; //次顶级创客姓名
- ThirdMakerCode = thirdUserInfo.MakerCode; //次次顶级创客编号
- ThirdRealName = thirdUserInfo.RealName; //次次顶级创客姓名
- }
- data["BrandName"] = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId).Name; //机具类型
- data["BindingTime"] = pos.BindingTime == null ? "" : pos.BindingTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //绑定时间
- data["ActivationTime"] = pos.ActivationTime == null ? "" : pos.ActivationTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //激活时间
- data["MerchantName"] = mer.MerchantName; //商户姓名
- // data["MerchantName"] = mer.MerchantName + " " + mer.MerRealName; //商户姓名/真实姓名
- data["PosSn"] = pos.PosSn; //机具Sn
- data["MerNo"] = mer.KqMerNo; //商户编号
- data["PosFee"] = SeoKeyword; //服务费
- data["userInfo"] = user.Id > 0 ? user.MakerCode + "_" + user.RealName : ""; //创客信息
- // data["MakerCode"] = user.MakerCode; //创客编号
- // data["RealName"] = user.RealName; //创客姓名
- data["Mobile"] = user.Mobile; //创客手机号
- data["Balance"] = userAccount.BalanceAmount; //创客账户余额
- data["TopMakerCode"] = TopMakerCode; //顶级创客编号
- data["TopRealName"] = TopRealName; //顶级创客名称
- data["SecondMakerCode"] = SecondMakerCode; //次顶级创客编号
- data["SecondRealName"] = SecondRealName; //次顶级创客姓名
- data["ThirdMakerCode"] = ThirdMakerCode; //次次顶级创客编号
- data["ThirdRealName"] = ThirdRealName; //次次顶级创客姓名
- dataList.Add(data);
- }
- }
- }
- if (!string.IsNullOrEmpty(MerNos))
- {
- string[] MerNosList = MerNos.Replace("\r", "").Replace("\n", ",").Replace(" ", ",").Split(',');
- foreach (string MerNo in MerNosList)
- {
- string SeoKeyword = "0";
- Dictionary<string, object> data = new Dictionary<string, object>();
- var mer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo) ?? new PosMerchantInfo();
- if (mer.Id > 0)
- {
- // error += "商户" + MerNo + "不存在" + '\n';
- // }
- // else
- // {
- var TopMakerCode = ""; //顶级创客编号
- var TopRealName = ""; //顶级创客名称
- var SecondMakerCode = ""; //次顶级创客编号
- var SecondRealName = ""; //次顶级创客姓名
- var ThirdMakerCode = ""; //次次顶级创客编号
- var ThirdRealName = ""; //次次顶级创客姓名
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == mer.KqSnNo) ?? new PosMachinesTwo();
- var brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
- // if (brand.Id > 0 && brand.SingleDepositApi == 0 && !string.IsNullOrEmpty(SeoKeyword))
- if (brand.Id > 0 && brand.NoticeMoneyUnit == 2 && !string.IsNullOrEmpty(pos.SeoKeyword))
- {
- SeoKeyword = (decimal.Parse(pos.SeoKeyword) / 100).ToString();
- }
- else
- {
- SeoKeyword = pos.SeoKeyword;
- }
- var user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
- var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == user.Id) ?? new UserAccount();
- if (!string.IsNullOrEmpty(user.ParentNav))
- {
- string[] ParentNavList = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
- var topUserInfo = new Users();
- var secondUserInfo = new Users();
- var thirdUserInfo = new Users();
- if (ParentNavList.Length > 1)
- {
- topUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[1]))) ?? new Users();
- if (ParentNavList.Length > 2)
- {
- secondUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[2]))) ?? new Users();
- if (ParentNavList.Length > 3)
- {
- thirdUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[3]))) ?? new Users();
- }
- }
- }
- else
- {
- topUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[0]))) ?? new Users();
- }
- TopMakerCode = topUserInfo.MakerCode; //顶级创客编号
- TopRealName = topUserInfo.RealName; //顶级创客名称
- SecondMakerCode = secondUserInfo.MakerCode; //次顶级创客编号
- SecondRealName = secondUserInfo.RealName; //次顶级创客姓名
- ThirdMakerCode = thirdUserInfo.MakerCode; //次次顶级创客编号
- ThirdRealName = thirdUserInfo.RealName; //次次顶级创客姓名
- }
- data["BrandName"] = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId).Name; //机具类型
- data["BindingTime"] = pos.BindingTime == null ? "" : pos.BindingTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //绑定时间
- data["ActivationTime"] = pos.ActivationTime == null ? "" : pos.ActivationTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //激活时间
- data["MerchantName"] = mer.MerchantName; //商户姓名
- // data["MerchantName"] = mer.MerchantName + " " + mer.MerRealName; //商户姓名/真实姓名
- data["PosSn"] = pos.PosSn; //机具Sn
- data["MerNo"] = mer.KqMerNo; //商户编号
- data["PosFee"] = SeoKeyword; //服务费
- data["userInfo"] = user.Id > 0 ? user.MakerCode + "_" + user.RealName : ""; //创客信息
- // data["MakerCode"] = user.MakerCode; //创客编号
- // data["RealName"] = user.RealName; //创客姓名
- data["Mobile"] = user.Mobile; //创客手机号
- data["Balance"] = userAccount.BalanceAmount; //创客账户余额
- data["TopMakerCode"] = TopMakerCode; //顶级创客编号
- data["TopRealName"] = TopRealName; //顶级创客名称
- data["SecondMakerCode"] = SecondMakerCode; //次顶级创客编号
- data["SecondRealName"] = SecondRealName; //次顶级创客姓名
- data["ThirdMakerCode"] = ThirdMakerCode; //次次顶级创客编号
- data["ThirdRealName"] = ThirdRealName; //次次顶级创客姓名
- dataList.Add(data);
- }
- }
- }
- }
- Dictionary<string, object> obj = new Dictionary<string, object>();
- obj.Add("code", 0);
- obj.Add("msg", "");
- obj.Add("count", dataList.Count);
- obj.Add("data", dataList);
- return Json(obj);
- }
- #endregion
- #region 批量查询创客信息快捷导出Excel
- public IActionResult ExportBatchSeeUserInfoExcel(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- [HttpPost]
- public string ExportBatchSeeUserInfoExcelDo(string PosSns, string MerNos)
- {
- var sql = "";
- if (string.IsNullOrEmpty(PosSns) && string.IsNullOrEmpty(MerNos))
- {
- return "请输入查询内容";
- }
- else if (!string.IsNullOrEmpty(PosSns) && !string.IsNullOrEmpty(MerNos))
- {
- return "不能同时输入机具Sn和商户编号";
- }
- else
- {
- if (!string.IsNullOrEmpty(PosSns))
- {
- var posIds = "";
- string[] PosSnsList = PosSns.Replace("\r", "").Replace("\n", ",").Replace(" ", ",").Split(',');
- foreach (string PosSn in PosSnsList)
- {
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
- posIds += pos.Id + ",";
- }
- posIds = posIds.TrimEnd(',');
- sql = "SELECT i.BrandName '机具类型',i.PosSn '机具SN',j.KqMerNo '商编',j.MerchantName '商户名称',(CASE WHEN i.posfee IS NULL THEN 0 ELSE i.posfee END) '服务费',DATE_FORMAT(i.BindingTime,'%Y-%m-%d %H:%i:%s') '绑定时间',DATE_FORMAT(i.ActivationTime,'%Y-%m-%d %H:%i:%s') '激活时间',i.userInfo '创客信息',i.Mobile '创客手机号',i.BalanceAmount '创客账户余额',i.topMakerCode '顶级创客编号',i.topRealname '顶级姓名',i.secondMakerCode '次顶级创客编号',i.secondRealname '次顶级姓名',i.thirdMakerCode '次次顶级创客编号',i.thirdRealname '次次顶级姓名' FROM(SELECT g.*,h.MakerCode thirdMakerCode,h.Realname thirdRealname FROM (SELECT e.*,f.MakerCode secondMakerCode,f.Realname secondRealname FROM(SELECT c.*,d.MakerCode topMakerCode,d.Realname topRealname FROM(SELECT a.*,c1.NAME BrandName,(CASE WHEN a.BrandId not in(2,7,10,11) THEN ROUND(CAST(a.SeoKeyword AS DECIMAL)/100, 2) ELSE a.SeoKeyword end) posfee,b.Id useId,CONCAT(b.MakerCode,'_',b.RealName) userInfo,b.Mobile,c2.BalanceAmount,b.RealName uRealName, SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',4),',',-1) topId,SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',6),',',-1) secondId,SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',8),',',-1) thirdId FROM PosMachinesTwo a LEFT JOIN Users b ON a.BuyUserId=b.Id LEFT JOIN UserAccount c2 ON a.BuyUserId=c2.Id LEFT JOIN KqProducts c1 ON a.BrandId=c1.Id WHERE a.Id in(" + posIds + "))c LEFT JOIN Users d ON c.topId=d.Id) e LEFT JOIN Users f ON e.secondId=f.Id) g LEFT JOIN Users h ON g.thirdId=h.Id) i LEFT JOIN PosMerchantInfo j ON i.BindMerchantId=j.Id";
- }
- if (!string.IsNullOrEmpty(MerNos))
- {
- var merIds = "";
- string[] MerNosList = MerNos.Replace("\r", "").Replace("\n", ",").Replace(" ", ",").Split(',');
- foreach (string MerNo in MerNosList)
- {
- var mer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo) ?? new PosMerchantInfo();
- merIds += mer.Id + ",";
- }
- merIds = merIds.TrimEnd(',');
- sql = "SELECT i.BrandName '机具类型',i.KqSnNo '机具SN',i.KqMerNo '商编',i.MerchantName '商户名称',(CASE WHEN i.SeoKeyword IS NULL THEN 0 ELSE i.SeoKeyword END) '服务费',DATE_FORMAT(i.BindingTime,'%Y-%m-%d %H:%i:%s') '绑定时间',DATE_FORMAT(i.ActivationTime,'%Y-%m-%d %H:%i:%s') '激活时间',i.userInfo '创客信息',i.Mobile '创客手机号',i.BalanceAmount '创客账户余额',i.topMakerCode '顶级创客编号',i.topRealname '顶级姓名',i.secondMakerCode '次顶级创客编号',i.secondRealname '次顶级姓名',j.MakerCode '次次顶级创客编号',j.Realname '次次顶级姓名' FROM(SELECT g.*,h.MakerCode secondMakerCode,h.Realname secondRealname FROM(SELECT e.*,f.MakerCode topMakerCode,f.RealName topRealName FROM(SELECT c.*,CONCAT(d.MakerCode,'_',d.RealName) userInfo,d.Mobile,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',4),',',-1) topId,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',6),',',-1) secondId,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',8),',',-1) thirdId FROM(SELECT a.KqMerNo,a.KqSnNo,a.MerchantName,(CASE WHEN b.BrandId not in(2,7,10,11) THEN ROUND(CAST(b.SeoKeyword AS DECIMAL)/100, 2) ELSE b.SeoKeyword end) SeoKeyword,b.BindingTime,b.ActivationTime,b.BuyUserId,c1.Name BrandName,c2.BalanceAmount FROM PosMerchantInfo a LEFT JOIN PosMachinesTwo b ON a.KqSnNo=b.PosSn LEFT JOIN UserAccount c2 ON b.BuyUserId=c2.Id LEFT JOIN KqProducts c1 ON b.BrandId=c1.Id WHERE a.Id in(" + merIds + "))c LEFT JOIN Users d ON c.BuyUserId=d.Id) e LEFT JOIN Users f ON e.topId=f.Id) g LEFT JOIN Users h ON g.secondId=h.Id) i LEFT JOIN Users j ON i.thirdId=j.Id";
- }
- }
- var sysAdmin = bsdb.SysAdmin.FirstOrDefault(m => m.AdminName == SysUserName && m.Status > -1);
- var FileName = "批量查询创客信息" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- string SendData = "{\"Operater\":\"" + sysAdmin.Id + "\",\"SqlString\":\"" + sql + "\",\"FileName\":\"" + FileName + "\",\"MaxCount\":\"0\"}";
- RedisDbconn.Instance.AddList("ExportQueue", SendData);
- return "success";
- }
- #endregion
- #region 注销时间提前
- public string SetLogoutDate(int Id)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("LogOutDate", DateTime.Now.AddDays(-31));
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, Id);
- AddSysLog(Id, "Users", "SetLogoutDate");
- return "success";
- }
- #endregion
- }
- }
|