| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250 |
- /*
- * 商户
- */
- 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 System.Text.RegularExpressions;
- using MySystemLib;
- namespace MySystem.Areas.Admin.Controllers
- {
- [Area("Admin")]
- [Route("Admin/[controller]/[action]")]
- public class PosMerchantInfoListController : BaseController
- {
- public PosMerchantInfoListController(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(PosMerchantInfo data, string right, string BrandId)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- ViewBag.BrandId = BrandId;
- return View();
- }
- #endregion
- #region 根据条件查询商户列表
- /// <summary>
- /// 商户列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(PosMerchantInfo data, string MerIdcardNo, string MerchantName, string PhoneNo, string PosSn, 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(MerIdcardNo))
- {
- var IdCardf = MerIdcardNo.Substring(0, 6);
- var IdCardb = MerIdcardNo.Substring(MerIdcardNo.Length - 4);
- condition += " and LEFT(MerIdcardNo,6)=" + IdCardf + " AND RIGHT(MerIdcardNo,4)=" + IdCardb + "";
- }
- //商户姓名
- if (!string.IsNullOrEmpty(MerchantName))
- {
- condition += " and MerchantName like '%" + MerchantName + "%'";
- }
- //手机号
- if (!string.IsNullOrEmpty(PhoneNo))
- {
- var PhoneNof = PhoneNo.Substring(0, 3);
- var PhoneNob = PhoneNo.Substring(PhoneNo.Length - 4);
- condition += " and LEFT(MerchantMobile,3)=" + PhoneNof + " AND RIGHT(MerchantMobile,4)=" + PhoneNob + "";
- }
- //机具号
- if (!string.IsNullOrEmpty(PosSn))
- {
- condition += " and KqSnNo='" + PosSn + "'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //直属创客
- int UserId = int.Parse(dic["UserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["MakerCode"] = puser.MakerCode;
- dic["RealName"] = puser.RealName;
- //顶级创客
- int TopUserId = int.Parse(dic["TopUserId"].ToString());
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- //商户创客
- int MerUserId = int.Parse(dic["MerUserId"].ToString());
- Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
- dic["MerMakerCode"] = muser.MakerCode;
- dic["MerRealName"] = muser.RealName;
- //申请创客
- int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
- Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
- dic["SnApplyMakerCode"] = snuser.MakerCode;
- dic["SnApplyRealName"] = snuser.RealName;
- //SN仓库
- int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
- StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
- dic["StoreNo"] = store.StoreNo;
- dic["StoreName"] = store.StoreName;
- //机具类型
- int SnType = int.Parse(dic["SnType"].ToString());
- if (SnType == 0) dic["SnType"] = "兑换机具";
- if (SnType == 1) dic["SnType"] = "循环机具";
- //返利资格
- dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
- //激活类型
- int ActType = int.Parse(dic["ActType"].ToString());
- if (ActType == 0) dic["ActType"] = "正常激活";
- if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
- if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
- if (ActType == 3) dic["ActType"] = "循环机划拨激活";
- //商户状态
- int MerStatus = int.Parse(dic["MerStatus"].ToString());
- if (MerStatus == 0) dic["MerStatus"] = "正常";
- if (MerStatus == 1) dic["MerStatus"] = "冻结";
- if (MerStatus == 2) dic["MerStatus"] = "关闭";
- //商户激活状态
- int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
- if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
- if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
- if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
- //商户创客类型
- int MerUserType = int.Parse(dic["MerUserType"].ToString());
- if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
- if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
- }
- return Json(obj);
- }
- #endregion
- #region 人工已退商户列表
- /// <summary>
- /// 根据条件人工已退商户列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Indexrg(PosMerchantInfo data, string right, string BrandId)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- ViewBag.BrandId = BrandId;
- return View();
- }
- #endregion
- #region 根据条件查询人工已退商户列表
- /// <summary>
- /// 人工已退商户列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexrgData(PosMerchantInfo data, string KqMerNo, string MerIdcardNo, string MerchantName, string PhoneNo, string PosSn, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- // Fields.Add("KqMerNo", "1"); //商户编号
- string condition = " and Status>-1 and StandardStatus=-2";
- //身份证号
- if (!string.IsNullOrEmpty(MerIdcardNo))
- {
- var IdCardf = MerIdcardNo.Substring(0, 6);
- var IdCardb = MerIdcardNo.Substring(MerIdcardNo.Length - 4);
- condition += " and LEFT(MerIdcardNo,6)=" + IdCardf + " AND RIGHT(MerIdcardNo,4)=" + IdCardb + "";
- }
- //商户姓名
- if (!string.IsNullOrEmpty(MerchantName))
- {
- condition += " and MerchantName like '%" + MerchantName + "%'";
- }
- //商户编号
- if (!string.IsNullOrEmpty(KqMerNo))
- {
- condition += " and KqMerNo='" + KqMerNo + "'";
- }
- //机具号
- if (!string.IsNullOrEmpty(PosSn))
- {
- condition += " and KqSnNo='" + PosSn + "'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "KqRegTime DESC", "0", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //直属创客
- int UserId = int.Parse(dic["UserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["MakerCode"] = puser.MakerCode;
- dic["RealName"] = puser.RealName;
- //顶级创客
- int TopUserId = int.Parse(dic["TopUserId"].ToString());
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- //商户创客
- int MerUserId = int.Parse(dic["MerUserId"].ToString());
- Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
- dic["MerMakerCode"] = muser.MakerCode;
- dic["MerRealName"] = muser.RealName;
- //申请创客
- int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
- Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
- dic["SnApplyMakerCode"] = snuser.MakerCode;
- dic["SnApplyRealName"] = snuser.RealName;
- //SN仓库
- int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
- StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
- dic["StoreNo"] = store.StoreNo;
- dic["StoreName"] = store.StoreName;
- //机具类型
- int SnType = int.Parse(dic["SnType"].ToString());
- if (SnType == 0) dic["SnType"] = "兑换机具";
- if (SnType == 1) dic["SnType"] = "循环机具";
- //返利资格
- dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
- //激活类型
- int ActType = int.Parse(dic["ActType"].ToString());
- if (ActType == 0) dic["ActType"] = "正常激活";
- if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
- if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
- if (ActType == 3) dic["ActType"] = "循环机划拨激活";
- //商户状态
- int MerStatus = int.Parse(dic["MerStatus"].ToString());
- if (MerStatus == 0) dic["MerStatus"] = "正常";
- if (MerStatus == 1) dic["MerStatus"] = "冻结";
- if (MerStatus == 2) dic["MerStatus"] = "关闭";
- //商户激活状态
- int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
- if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
- if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
- if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
- //商户创客类型
- int MerUserType = int.Parse(dic["MerUserType"].ToString());
- if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
- if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
- var KqSnNo = dic["KqSnNo"].ToString();
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == KqSnNo) ?? new PosMachinesTwo();
- //实际押金
- string SeoKeyword = pos.SeoKeyword;
- 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(SeoKeyword))
- {
- SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
- }
- dic["SeoKeyword"] = SeoKeyword;
- //设置押金
- string PrizeParams = "0";
- if (!string.IsNullOrEmpty(pos.PrizeParams))
- {
- PrizeParams = pos.PrizeParams.ToString();
- }
- dic["PrizeParams"] = PrizeParams;
- }
- Dictionary<string, object> other = new Dictionary<string, object>();
- decimal ReturnAmount = 0.00M;//服务费总金额
- decimal ReturnAmounts = 0.00M;//退还总金额
- DataTable dt = OtherMySqlConn.dtable("SELECT SUM(Remark) FROM PosMerchantInfo WHERE 1=1" + condition);
- if (dt.Rows.Count > 0)
- {
- ReturnAmounts = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
- }
- DataTable dts = OtherMySqlConn.dtable("SELECT KqSnNo FROM PosMerchantInfo WHERE 1=1" + condition);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow item in dts.Rows)
- {
- string KqSnNo = item["KqSnNo"].ToString();
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == KqSnNo) ?? new PosMachinesTwo();
- var brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
- if (!string.IsNullOrEmpty(pos.SeoKeyword))
- {
- // if (brand.Id > 0 && brand.SingleDepositApi == 0 && !string.IsNullOrEmpty(pos.SeoKeyword))
- if (brand.Id > 0 && brand.NoticeMoneyUnit == 2 && !string.IsNullOrEmpty(pos.SeoKeyword))
- {
- ReturnAmount += (decimal.Parse(pos.SeoKeyword) / 100);
- }
- else
- {
- ReturnAmount += decimal.Parse(pos.SeoKeyword);
- }
- }
- }
- }
- other.Add("ReturnAmount", ReturnAmount.ToString("f2"));
- other.Add("ReturnAmounts", ReturnAmounts.ToString("f2"));
- obj.Add("other", other);
- return Json(obj);
- }
- #endregion
- #region 导出人工已退商户Excel
- /// <summary>
- /// 导出人工已退商户Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportrgExcel(PosMerchantInfo data, string MerIdcardNo, string MerchantName, string PhoneNo, string PosSn)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("KqMerNo", "1"); //商户编号
- string condition = " and Status>-1 and StandardStatus=-2";
- //身份证号
- if (!string.IsNullOrEmpty(MerIdcardNo))
- {
- var IdCardf = MerIdcardNo.Substring(0, 6);
- var IdCardb = MerIdcardNo.Substring(MerIdcardNo.Length - 4);
- condition += " and LEFT(MerIdcardNo,6)=" + IdCardf + " AND RIGHT(MerIdcardNo,4)=" + IdCardb + "";
- }
- //商户姓名
- if (!string.IsNullOrEmpty(MerchantName))
- {
- condition += " and MerchantName like '%" + MerchantName + "%'";
- }
- //手机号
- if (!string.IsNullOrEmpty(PhoneNo))
- {
- var PhoneNof = PhoneNo.Substring(0, 3);
- var PhoneNob = PhoneNo.Substring(PhoneNo.Length - 4);
- condition += " and LEFT(MerchantMobile,3)=" + PhoneNof + " AND RIGHT(MerchantMobile,4)=" + PhoneNob + "";
- }
- //机具号
- if (!string.IsNullOrEmpty(PosSn))
- {
- condition += " and KqSnNo='" + PosSn + "'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", 1, 20000, condition, "MerchantName,Remark,KqMerNo,KqSnNo,UserId,KqRegTime", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- var KqSnNo = dic["KqSnNo"].ToString();
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == KqSnNo) ?? new PosMachinesTwo();
- var brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
- dic["BrandName"] = brand.Name;
- int UserId = int.Parse(dic["UserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["MakerCode"] = puser.MakerCode;
- dic["RealName"] = puser.RealName;
- dic.Remove("UserId");
- //实际押金
- string SeoKeyword = pos.SeoKeyword;
- // if (brand.Id > 0 && brand.SingleDepositApi == 0 && !string.IsNullOrEmpty(SeoKeyword))
- if (brand.Id > 0 && brand.NoticeMoneyUnit == 2 && !string.IsNullOrEmpty(SeoKeyword))
- {
- SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
- }
- dic["SeoKeyword"] = SeoKeyword;
- }
- 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("KqMerNo", "商户编号");
- ReturnFields.Add("MerchantName", "商户名称");
- ReturnFields.Add("BrandName", "机具品牌");
- ReturnFields.Add("KqSnNo", "机具SN");
- ReturnFields.Add("KqRegTime", "退还时间");
- ReturnFields.Add("SeoKeyword", "服务费金额");
- ReturnFields.Add("Remark", "已退还金额");
- ReturnFields.Add("MakerCode", "创客编号");
- ReturnFields.Add("RealName", "创客姓名");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "PosMerchantInfo", "ExportrgExcel");
- return Json(result);
- }
- #endregion
- #region 达标商户列表
- /// <summary>
- /// 达标商户列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Indexs(PosMerchantInfo data, string right, string BrandId)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- ViewBag.BrandId = BrandId;
- return View();
- }
- #endregion
- #region 根据条件查询达标商户列表
- /// <summary>
- /// 根据条件查询达标商户列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexsData(PosMerchantInfo data, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("MerchantMobile", "1"); //商户手机号
- Fields.Add("KqSnNo", "1"); //快钱SN号
- Fields.Add("MerIdcardNo", "1"); //身份证号
- string condition = " and Status>-1 and StandardStatus=4 and StandardMonths=10";
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //直属创客
- int UserId = int.Parse(dic["UserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["MakerCode"] = puser.MakerCode;
- dic["RealName"] = puser.RealName;
- //顶级创客
- int TopUserId = int.Parse(dic["TopUserId"].ToString());
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- //商户创客
- int MerUserId = int.Parse(dic["MerUserId"].ToString());
- Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
- dic["MerMakerCode"] = muser.MakerCode;
- dic["MerRealName"] = muser.RealName;
- //申请创客
- int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
- Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
- dic["SnApplyMakerCode"] = snuser.MakerCode;
- dic["SnApplyRealName"] = snuser.RealName;
- //SN仓库
- int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
- StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
- dic["StoreNo"] = store.StoreNo;
- dic["StoreName"] = store.StoreName;
- //机具类型
- int SnType = int.Parse(dic["SnType"].ToString());
- if (SnType == 0) dic["SnType"] = "兑换机具";
- if (SnType == 1) dic["SnType"] = "循环机具";
- //返利资格
- dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
- //激活类型
- int ActType = int.Parse(dic["ActType"].ToString());
- if (ActType == 0) dic["ActType"] = "正常激活";
- if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
- if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
- if (ActType == 3) dic["ActType"] = "循环机划拨激活";
- //商户状态
- int MerStatus = int.Parse(dic["MerStatus"].ToString());
- if (MerStatus == 0) dic["MerStatus"] = "正常";
- if (MerStatus == 1) dic["MerStatus"] = "冻结";
- if (MerStatus == 2) dic["MerStatus"] = "关闭";
- //商户激活状态
- int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
- if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
- if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
- if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
- //商户创客类型
- int MerUserType = int.Parse(dic["MerUserType"].ToString());
- if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
- if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
- }
- return Json(obj);
- }
- #endregion
- #region 首台达标商户列表
- /// <summary>
- /// 首台达标商户列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Indexfs(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询首台达标商户列表
- /// <summary>
- /// 根据条件查询首台达标商户列表
- /// </summary>
- /// <returns></returns>
- public IActionResult IndexfsData(string MerchantMobile, string KqSnNo, string MerIdcardNo, int page = 1, int limit = 30)
- {
- string condition = "";
- if (!string.IsNullOrEmpty(MerchantMobile))
- {
- condition += " and b.MerchantMobile like '%" + MerchantMobile + "%'";
- }
- if (!string.IsNullOrEmpty(KqSnNo))
- {
- condition += " and b.KqSnNo like '%" + KqSnNo + "%'";
- }
- if (!string.IsNullOrEmpty(MerIdcardNo))
- {
- condition += " and b.MerIdcardNo like '%" + MerIdcardNo + "%'";
- }
- var amount = 0.00M;
- List<Dictionary<string, object>> diclist = new List<Dictionary<string, object>>();
- DataTable dt = OtherMySqlConn.dtable("SELECT a.BrandId,a.PosSn,a.BindMerchantId,a.SeoKeyword,b.KqMerNo,b.MerIdcardNo,b.MerchantName,b.MerchantMobile FROM PosMachinesTwo a,PosMerchantInfo b WHERE a.`Status`>-1 AND a.SeoKeyword!='' AND a.SeoKeyword!='0' AND a.SeoKeyword IS NOT NULL AND a.FirstFlag=1 AND b.StandardMonths=10 AND b.StandardStatus=4 AND a.BindMerchantId=b.Id " + condition);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- var BindMerchantId = item["BindMerchantId"].ToString();
- var BrandId = int.Parse(item["BrandId"].ToString());
- var PosSn = item["PosSn"].ToString();
- var SeoKeyword = item["SeoKeyword"].ToString();
- var brand = db.KqProducts.FirstOrDefault(m => m.Id == BrandId) ?? new KqProducts();
- // if (brand.Id > 0 && brand.SingleDepositApi == 0 && !string.IsNullOrEmpty(SeoKeyword))
- if (brand.Id > 0 && brand.NoticeMoneyUnit == 2 && !string.IsNullOrEmpty(SeoKeyword))
- {
- SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
- }
- amount += decimal.Parse(SeoKeyword);
- var KqMerNo = item["KqMerNo"].ToString();
- var IdcardNo = item["MerIdcardNo"].ToString();
- var MerchantName = item["MerchantName"].ToString();
- var Mobile = item["MerchantMobile"].ToString();
- Dictionary<string, object> datas = new Dictionary<string, object>();
- datas.Add("Id", BindMerchantId);
- datas.Add("PosSn", PosSn);
- datas.Add("SeoKeyword", SeoKeyword);
- datas.Add("KqMerNo", KqMerNo);
- datas.Add("IdcardNo", IdcardNo);
- datas.Add("MerchantName", MerchantName);
- datas.Add("MerchantMobile", Mobile);
- diclist.Add(datas);
- }
- }
- Dictionary<string, object> obj = new Dictionary<string, object>();
- Dictionary<string, object> other = new Dictionary<string, object>();
- var ReturnAmount = amount;
- var fReturnAmount = amount * 0.92M;
- other.Add("ReturnAmount", ReturnAmount.ToString("f2"));
- other.Add("fReturnAmount", fReturnAmount.ToString("f2"));
- obj.Add("other", other);
- obj.Add("code", 0);
- obj.Add("msg", "");
- obj.Add("count", diclist.Count);
- obj.Add("data", diclist);
- return Json(obj);
- }
- #endregion
- #region 非首台达标商户列表
- /// <summary>
- /// 非首台达标商户列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Indexnfs(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询非首台达标商户列表
- /// <summary>
- /// 根据条件查询非首台达标商户列表
- /// </summary>
- /// <returns></returns>
- public IActionResult IndexnfsData(string MerchantMobile, string KqSnNo, string MerIdcardNo, int page = 1, int limit = 30)
- {
- string condition = "";
- if (!string.IsNullOrEmpty(MerchantMobile))
- {
- condition += " and b.MerchantMobile like '%" + MerchantMobile + "%'";
- }
- if (!string.IsNullOrEmpty(KqSnNo))
- {
- condition += " and b.KqSnNo like '%" + KqSnNo + "%'";
- }
- if (!string.IsNullOrEmpty(MerIdcardNo))
- {
- condition += " and b.MerIdcardNo like '%" + MerIdcardNo + "%'";
- }
- var amount = 0.00M;
- List<Dictionary<string, object>> diclist = new List<Dictionary<string, object>>();
- DataTable dt = OtherMySqlConn.dtable("SELECT a.BrandId,a.PosSn,a.BindMerchantId,a.SeoKeyword,b.KqMerNo,b.MerIdcardNo,b.MerchantName,b.MerchantMobile FROM PosMachinesTwo a,PosMerchantInfo b WHERE a.`Status`>-1 AND a.SeoKeyword!='' AND a.SeoKeyword!='0' AND a.SeoKeyword IS NOT NULL AND a.FirstFlag=0 AND b.StandardMonths=10 AND b.StandardStatus=4 AND a.BindMerchantId=b.Id " + condition);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- var BindMerchantId = item["BindMerchantId"].ToString();
- var BrandId = int.Parse(item["BrandId"].ToString());
- var PosSn = item["PosSn"].ToString();
- var SeoKeyword = item["SeoKeyword"].ToString();
- var brand = db.KqProducts.FirstOrDefault(m => m.Id == BrandId) ?? new KqProducts();
- // if (brand.Id > 0 && brand.SingleDepositApi == 0 && !string.IsNullOrEmpty(SeoKeyword))
- if (brand.Id > 0 && brand.NoticeMoneyUnit == 2 && !string.IsNullOrEmpty(SeoKeyword))
- {
- SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
- }
- amount += decimal.Parse(SeoKeyword);
- var KqMerNo = item["KqMerNo"].ToString();
- var IdcardNo = item["MerIdcardNo"].ToString();
- var MerchantName = item["MerchantName"].ToString();
- var Mobile = item["MerchantMobile"].ToString();
- Dictionary<string, object> datas = new Dictionary<string, object>();
- datas.Add("Id", BindMerchantId);
- datas.Add("PosSn", PosSn);
- datas.Add("SeoKeyword", SeoKeyword);
- datas.Add("KqMerNo", KqMerNo);
- datas.Add("IdcardNo", IdcardNo);
- datas.Add("MerchantName", MerchantName);
- datas.Add("MerchantMobile", Mobile);
- diclist.Add(datas);
- }
- }
- Dictionary<string, object> obj = new Dictionary<string, object>();
- Dictionary<string, object> other = new Dictionary<string, object>();
- var ReturnAmount = amount;
- var fReturnAmount = amount * 0.92M;
- other.Add("ReturnAmount", ReturnAmount.ToString("f2"));
- other.Add("fReturnAmount", fReturnAmount.ToString("f2"));
- obj.Add("other", other);
- obj.Add("code", 0);
- obj.Add("msg", "");
- obj.Add("count", diclist.Count);
- obj.Add("data", diclist);
- return Json(obj);
- }
- #endregion
- #region 批量通过
- /// <summary>
- /// 批量通过
- /// </summary>
- /// <returns></returns>
- public string BatchSetting(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "PosMerchantInfo", "BatchSetting");
- var Ids = "";//商户Id
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Ids += id + ",";
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("StandardStatus", 101);//设置为可退押状态
- Fields.Add("MatchTime", DateTime.Now);//设置入口开放时间
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMerchantInfo", Fields, id);
- }
- string text = string.Format("商户押金退还批量通过,商户Id: '" + Ids.TrimEnd(',') + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "商户押金退还批量通过");
- db.SaveChanges();
- return "success";
- }
- #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(PosMerchantInfo data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("SeoTitle", data.SeoTitle);
- Fields.Add("SeoKeyword", data.SeoKeyword);
- Fields.Add("SeoDescription", data.SeoDescription);
- int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("PosMerchantInfo", Fields, 0);
- AddSysLog(data.Id.ToString(), "PosMerchantInfo", "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;
- PosMerchantInfo editData = db.PosMerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new PosMerchantInfo();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 修改商户
- /// <summary>
- /// 增加或修改商户信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Edit(PosMerchantInfo data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("SeoTitle", data.SeoTitle);
- Fields.Add("SeoKeyword", data.SeoKeyword);
- Fields.Add("SeoDescription", data.SeoDescription);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMerchantInfo", Fields, data.Id);
- AddSysLog(data.Id.ToString(), "PosMerchantInfo", "update");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 删除商户信息
- /// <summary>
- /// 删除商户信息
- /// </summary>
- /// <returns></returns>
- public string Delete(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "PosMerchantInfo", "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("PosMerchantInfo", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 开启
- /// <summary>
- /// 开启
- /// </summary>
- /// <returns></returns>
- public string Open(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "PosMerchantInfo", "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("PosMerchantInfo", 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, "PosMerchantInfo", "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("PosMerchantInfo", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 排序
- /// <summary>
- /// 排序
- /// </summary>
- /// <param name="Id"></param>
- public string Sort(int Id, int Sort)
- {
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("PosMerchantInfo", Sort, Id);
- AddSysLog(Id.ToString(), "PosMerchantInfo", "sort");
- return "success";
- }
- #endregion
- #region 导入数据
- /// <summary>
- /// 导入数据
- /// </summary>
- /// <param name="ExcelData"></param>
- public string Import(string ExcelData)
- {
- ExcelData = HttpUtility.UrlDecode(ExcelData);
- JsonData list = JsonMapper.ToObject(ExcelData);
- var Ids = "";
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- string KqMerNo = dr[0].ToString(); // 商户编号
- string Amount = dr[1].ToString(); // 已退金额
- string KqRegTime = dr[2].ToString(); // 退还时间
- var posMerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == KqMerNo) ?? new PosMerchantInfo();
- posMerchantInfo.StandardStatus = -2;
- posMerchantInfo.Remark = Amount;
- posMerchantInfo.KqRegTime = DateTime.Parse(KqRegTime);
- Ids += posMerchantInfo.Id + "_" + Amount + ",";
- db.SaveChanges();
- }
- AddSysLog("0", "PosMerchantInfo", "Import");
- string text = string.Format("导入人工已退,商户Id: '" + Ids.TrimEnd(',') + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "导入人工已退");
- return "success";
- }
- #endregion
- #region 导出Excel
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportExcel(PosMerchantInfo data, string MakerCode, string RealName, string MerMakerCode, string StoreNo, string StoreName, string MerStatusSelect, string ActiveStatusSelect, string ActTypeSelect, string MerUserTypeSelect)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("BrandId", "1");
- Fields.Add("MerchantNo", "1"); //商户编号
- Fields.Add("MerchantName", "1"); //商户姓名
- Fields.Add("MerchantMobile", "1"); //商户手机号
- Fields.Add("KqMerNo", "1"); //快钱商户编码
- Fields.Add("KqSnNo", "1"); //快钱SN号
- Fields.Add("KqRegTime", "3"); //渠道注册时间
- Fields.Add("TopUserId", "0"); //顶级创客
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
- }
- //创客名称
- if (!string.IsNullOrEmpty(RealName))
- {
- condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
- }
- //商户创客编号
- if (!string.IsNullOrEmpty(MerMakerCode))
- {
- condition += " and MerUserId in (select UserId from UserForMakerCode where MakerCode='" + MerMakerCode + "')";
- }
- //仓库编号
- if (!string.IsNullOrEmpty(StoreNo))
- {
- condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
- }
- //仓库名称
- if (!string.IsNullOrEmpty(RealName))
- {
- condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreName + "')";
- }
- //商户状态
- if (!string.IsNullOrEmpty(MerStatusSelect))
- {
- condition += " and MerStatus=" + MerStatusSelect;
- }
- //商户激活状态
- if (!string.IsNullOrEmpty(ActiveStatusSelect))
- {
- condition += " and ActiveStatus=" + ActiveStatusSelect;
- }
- //激活类型
- if (!string.IsNullOrEmpty(ActTypeSelect))
- {
- condition += " and ActType=" + ActTypeSelect;
- }
- //商户创客类型
- if (!string.IsNullOrEmpty(MerUserTypeSelect))
- {
- condition += " and MerUserType=" + MerUserTypeSelect;
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", 1, 20000, condition, "MerchantNo,MerchantName,MerchantMobile,KqMerNo,KqSnNo,MerStatus,ActiveStatus,UserId,MerUserId,SnType,SnApplyUserId,KqRegTime,ActType,SnStoreId,TopUserId,MerUserType,RebateQual", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //直属创客
- int UserId = int.Parse(dic["UserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["MakerCode"] = puser.MakerCode;
- dic["RealName"] = puser.RealName;
- //顶级创客
- int TopUserId = int.Parse(dic["TopUserId"].ToString());
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
- //商户创客
- int MerUserId = int.Parse(dic["MerUserId"].ToString());
- Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
- dic["MerMakerCode"] = muser.MakerCode;
- dic["MerRealName"] = muser.RealName;
- //申请创客
- int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
- Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
- dic["SnApplyMakerCode"] = snuser.MakerCode;
- dic["SnApplyRealName"] = snuser.RealName;
- //SN仓库
- int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
- StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
- dic["StoreNo"] = store.StoreNo;
- dic["StoreName"] = store.StoreName;
- //机具类型
- int SnType = int.Parse(dic["SnType"].ToString());
- if (SnType == 0) dic["SnType"] = "兑换机具";
- if (SnType == 1) dic["SnType"] = "循环机具";
- //返利资格
- dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
- //激活类型
- int ActType = int.Parse(dic["ActType"].ToString());
- if (ActType == 0) dic["ActType"] = "正常激活";
- if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
- if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
- if (ActType == 3) dic["ActType"] = "循环机划拨激活";
- //商户状态
- int MerStatus = int.Parse(dic["MerStatus"].ToString());
- if (MerStatus == 0) dic["MerStatus"] = "正常";
- if (MerStatus == 1) dic["MerStatus"] = "冻结";
- if (MerStatus == 2) dic["MerStatus"] = "关闭";
- //商户激活状态
- int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
- if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
- if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
- if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
- //商户创客类型
- int MerUserType = int.Parse(dic["MerUserType"].ToString());
- if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
- if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
- dic.Remove("UserId");
- dic.Remove("TopUserId");
- dic.Remove("MerUserId");
- dic.Remove("SnApplyUserId");
- dic.Remove("SnStoreId");
- }
- 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("MerchantNo", "商户编号");
- ReturnFields.Add("MerchantName", "商户名称");
- ReturnFields.Add("MerchantMobile", "商户手机号");
- ReturnFields.Add("KqMerNo", "快钱商户编码");
- ReturnFields.Add("KqSnNo", "快钱SN号");
- ReturnFields.Add("SnType", "机具类型");
- ReturnFields.Add("RebateQual", "返利资格");
- ReturnFields.Add("ActType", "激活类型");
- ReturnFields.Add("MerStatus", "商户状态");
- ReturnFields.Add("ActiveStatus", "商户激活状态");
- ReturnFields.Add("MerMakerCode", "商户创客编码");
- ReturnFields.Add("MerRealName", "商户创客名称");
- ReturnFields.Add("MerUserType", "商户创客类型");
- ReturnFields.Add("MakerCode", "直属创客编号");
- ReturnFields.Add("RealName", "直属创客姓名");
- ReturnFields.Add("TopMakerCode", "顶级创客编码");
- ReturnFields.Add("TopRealName", "顶级创客名称");
- ReturnFields.Add("StoreNo", "SN仓库编号");
- ReturnFields.Add("StoreName", "SN仓库名称");
- ReturnFields.Add("SnApplyMakerCode", "申请创客编号");
- ReturnFields.Add("SnApplyRealName", "申请创客姓名");
- ReturnFields.Add("KqRegTime", "注册时间");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "PosMerchantInfo", "ExportExcel");
- return Json(result);
- }
- #endregion
- #region 首台机具查询
- /// <summary>
- /// 根据条件查询首台机具查询
- /// </summary>
- /// <returns></returns>
- public IActionResult FirstPosIndex(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询首台机具查询
- /// <summary>
- /// 首台机具查询
- /// </summary>
- /// <returns></returns>
- public JsonResult FirstPosIndexData(string PosSn, int page = 1, int limit = 30)
- {
- string conn = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- if (!string.IsNullOrEmpty(PosSn))
- {
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.Status > -1 && m.PosSn == PosSn) ?? new PosMachinesTwo();
- if (pos.BindMerchantId > 0)
- {
- var mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new PosMerchantInfo();
- if (mer.Id > 0 && !string.IsNullOrEmpty(mer.MerIdcardNo))
- {
- string MerchantName = Regex.Replace(mer.MerchantName, @"\d|\W|[A-Za-z]", "");
- // var posMerchants = db.PosMerchantInfo.Where(m => m.MerIdcardNo.ToUpper().StartsWith(mer.MerIdcardNo.ToUpper().Substring(0, 6)) && m.MerIdcardNo.ToUpper().EndsWith(mer.MerIdcardNo.ToUpper().Substring(mer.MerIdcardNo.Length - 4, 4)) && m.MerchantName.Contains(MerchantName)).ToList();
- var posMerchants = db.PosMerchantInfo.Where(m => m.MerchantName.Contains(MerchantName)).ToList();
- foreach (var item in posMerchants)
- {
- Dictionary<string, object> curData = new Dictionary<string, object>();
- var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == item.KqSnNo) ?? new PosMachinesTwo();
- int IsFirst = int.Parse(posInfo.FirstFlag.ToString());
- var IsFirstName = "";
- if (IsFirst == 1) IsFirstName = "首台";
- if (IsFirst == 0) IsFirstName = "非首台";
- curData.Add("PosSn", posInfo.PosSn); //机具Sn
- curData.Add("MerchantName", item.MerchantName); //商户名称
- curData.Add("MerchantMobile", item.MerchantMobile); //商户手机号
- curData.Add("MerIdcardNo", item.MerIdcardNo); //商户身份证号
- curData.Add("IsFirstName", posInfo.FirstFlag == 1 ? "首台" : "非首台"); //是否首台(服务费领取)
- curData.Add("PosIsFirstName", posInfo.IsFirst == 1 ? "首台" : "非首台"); //是否首台(机具奖励发放)
- curData.Add("IsFirst", posInfo.FirstFlag);
- curData.Add("PosIsFirst", posInfo.IsFirst);
- curData.Add("BindingTime", string.IsNullOrEmpty(posInfo.BindingTime.ToString()) ? "" : Convert.ToDateTime(posInfo.BindingTime).ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
- curData.Add("ActivationTime", string.IsNullOrEmpty(posInfo.ActivationTime.ToString()) ? "" : Convert.ToDateTime(posInfo.ActivationTime).ToString("yyyy-MM-dd HH:mm:ss")); //激活时间
- dataList.Add(curData);
- }
- }
- }
- }
- 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 设置为首台机具
- /// <summary>
- /// 设置为首台机具
- /// </summary>
- /// <returns></returns>
- public string SetFirstPos(string PosSn)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- var mer = db.PosMerchantInfo.FirstOrDefault(m => m.KqSnNo == PosSn) ?? new PosMerchantInfo();
- string MerchantName = Regex.Replace(mer.MerchantName, @"\d|\W|[A-Za-z]", "");
- var posMerchants = db.PosMerchantInfo.Where(m => m.MerIdcardNo.ToUpper().StartsWith(mer.MerIdcardNo.ToUpper().Substring(0, 6)) && m.MerIdcardNo.ToUpper().EndsWith(mer.MerIdcardNo.ToUpper().Substring(mer.MerIdcardNo.Length - 4, 4)) && m.MerchantName.Contains(MerchantName) && m.KqSnNo != PosSn).ToList();
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
- var thisdate = pos.BindingTime;
- var otherdate = pos.BindingTime;
- if (posMerchants.Count > 0)
- {
- var flag = 0;
- foreach (var item in posMerchants)
- {
- var changeFlag = 0;
- Dictionary<string, object> curData = new Dictionary<string, object>();
- var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == item.KqSnNo) ?? new PosMachinesTwo();
- otherdate = posInfo.BindingTime;
- if (thisdate <= otherdate)
- {
- changeFlag = 1;
- posInfo.FirstFlag = 0;
- flag = changeFlag;
- }
- else
- {
- return "不符合设置条件";
- }
- }
- if (flag == 1)
- {
- AddSysLog(PosSn, "PosMachinesTwo", "SetFirstPos");
- pos.FirstFlag = 1;
- }
- }
- else
- {
- AddSysLog(PosSn, "PosMachinesTwo", "SetFirstPos");
- pos.FirstFlag = 1;
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 同步交易额
- public IActionResult SycnTradeAmount(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- PosMerchantInfo editData = db.PosMerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new PosMerchantInfo();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 同步交易额
- [HttpPost]
- public string SycnTradeAmountDo(DateTime sdate, DateTime edate, int MerchantId)
- {
- 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>("ResetMerchantTradeQueue:" + MerchantId);
- if (!string.IsNullOrEmpty(check))
- {
- return "请稍后再试";
- }
- try
- {
- RedisDbconn.Instance.AddList("ResetMerchantTradeQueue", MerchantId + "#cut#" + sdate.ToString("yyyy-MM-dd HH:mm:ss") + "#cut#" + edate.ToString("yyyy-MM-dd HH:mm:ss"));
- RedisDbconn.Instance.Set("ResetMerchantTradeQueue:" + MerchantId, "wait");
- RedisDbconn.Instance.SetExpire("ResetMerchantTradeQueue:" + MerchantId, 3600);
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计商户的交易额异常");
- return "同步异常";
- }
- return "success";
- }
- #endregion
- }
- }
|