| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193 |
- /*
- * 机具库
- */
- 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 PosMachinesTwoController : BaseController
- {
- public PosMachinesTwoController(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(PosMachinesTwo data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询机具库列表
- /// <summary>
- /// 机具库列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName, string BrandId, string ActivationDateData, string BindingDateData, string IsStoreSelect, string OpCode, int ShowFlag = 0, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("PosSn", "1"); //SN编号
- Fields.Add("BrandId", "0"); //品牌
- if (ShowFlag == 0)
- {
- Dictionary<string, object> objs = new Dictionary<string, object>();
- Dictionary<string, object> others = new Dictionary<string, object>();
- others.Add("TotalCount", 0);
- others.Add("KysCount99", 0);
- others.Add("KssCount99", 0);
- others.Add("KssCoun198", 0);
- others.Add("KssCount298", 0);
- objs.Add("other", others);
- return Json(objs);
- }
- string condition = " and Status>-1";
- //是否仓库机
- if (!string.IsNullOrEmpty(IsStoreSelect))
- {
- if (int.Parse(IsStoreSelect) > 0)
- {
- condition += " and UserId=0 and BuyUserId=0";
- }
- }
- //绑定状态
- if (!string.IsNullOrEmpty(BindingStateSelect))
- {
- condition += " and BindingState=" + BindingStateSelect;
- }
- //激活状态
- if (!string.IsNullOrEmpty(ActivationStateSelect))
- {
- condition += " and ActivationState=" + ActivationStateSelect;
- }
- //所属创客编号
- if (!string.IsNullOrEmpty(UserIdMakerCode))
- {
- condition += " and BuyUserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
- }
- //所属创客真实姓名
- if (!string.IsNullOrEmpty(UserIdRealName))
- {
- condition += " and BuyUserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
- }
- //所属仓库编号
- if (!string.IsNullOrEmpty(StoreIdCode))
- {
- condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdCode + "')";
- }
- //所属仓库名称
- if (!string.IsNullOrEmpty(StoreIdName))
- {
- condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
- }
- //运营中心编号
- if (!string.IsNullOrEmpty(OpCode))
- {
- var sysUser = opdb.SysAdmin.FirstOrDefault(m => m.OpCode == OpCode) ?? new OpModels.SysAdmin();
- if (sysUser.Id > 0)
- {
- condition += " and OpId=" + sysUser.UserId;
- }
- }
- //品牌
- if (!string.IsNullOrEmpty(BrandId))
- {
- condition += " and BrandId =" + BrandId;
- }
- if (!string.IsNullOrEmpty(ActivationDateData))
- {
- string[] datelist = ActivationDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and ActivationTime>='" + start + " 00:00:00' and ActivationTime<='" + end + " 23:59:59'";
- }
- if (!string.IsNullOrEmpty(BindingDateData))
- {
- string[] datelist = BindingDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and BindingTime>='" + start + " 00:00:00' and BindingTime<='" + end + " 23:59:59'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", 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 BindingState = int.Parse(dic["BindingState"].ToString());
- if (BindingState == 0) dic["BindingState"] = "未绑定";
- if (BindingState == 1) dic["BindingState"] = "已绑定";
- //激活状态
- int ActivationState = int.Parse(dic["ActivationState"].ToString());
- if (ActivationState == 0) dic["ActivationState"] = "未激活";
- if (ActivationState == 1) dic["ActivationState"] = "已激活";
- //所属创客
- int BuyUserId = int.Parse(function.CheckInt(dic["BuyUserId"].ToString()));
- Users userid_Users = db.Users.FirstOrDefault(m => m.Id == BuyUserId) ?? new Users();
- dic["UserIdMakerCode"] = userid_Users.MakerCode;
- dic["UserIdRealName"] = userid_Users.RealName;
- dic.Remove("BuyUserId");
- //所属仓库
- int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
- StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
- dic["StoreIdCode"] = storeid_StoreHouse.StoreNo;
- dic["StoreIdName"] = storeid_StoreHouse.StoreName;
- dic.Remove("StoreId");
- //产品类型
- dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
- //参加活动
- dic["ActivityList"] = RelationClass.GetProfitObjectsActivesList(dic["ActivityList"].ToString());
- //绑定商户
- int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
- PosMerchantInfo bindmerchantid_MerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new PosMerchantInfo();
- dic["BindMerchantIdMerchantNo"] = bindmerchantid_MerchantInfo.MerchantNo;
- dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.MerchantName;
- dic.Remove("BindMerchantId");
- //机具类型
- int PosSnType = int.Parse(dic["PosSnType"].ToString());
- if (PosSnType == 0) dic["PosSnType"] = "兑换机具";
- if (PosSnType == 1) dic["PosSnType"] = "循环机具";
- //设备类型
- string DeviceType = dic["DeviceType"].ToString();
- if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
- if (DeviceType == "KssSignPos") dic["DeviceType"] = "快闪刷电签POS";
- if (DeviceType == "") dic["DeviceType"] = "";
- //盟主信息
- int LeaderUserId = int.Parse(function.CheckInt(dic["LeaderUserId"].ToString()));
- if (LeaderUserId != 0)
- {
- Users users = db.Users.FirstOrDefault(m => m.Id == LeaderUserId) ?? new Users();
- dic["UserInfo"] = users.MakerCode + "_" + users.RealName;
- }
- //是否为第一台机具
- int IsFirst = int.Parse(dic["IsFirst"].ToString());
- if (IsFirst == 0) dic["IsFirst"] = "否";
- if (IsFirst == 1) dic["IsFirst"] = "是";
- //循环开始时间
- // if (!string.IsNullOrEmpty(dic["RecycEndDate"].ToString()))
- // {
- // // var RecycStartDate = Convert.ToDateTime(dic["RecycEndDate"].ToString()).AddDays(-360).ToString("yyyy-MM-dd HH:mm:ss");
- // // dic["RecycStartDate"] = RecycStartDate;
- // string PosSn = dic["PosSn"].ToString();
- // bool op = db.StoreChangeHistory.Any(m => m.SnNo == PosSn && m.TransType == 2);
- // if(op)
- // {
- // StoreChangeHistory item = db.StoreChangeHistory.FirstOrDefault(m => m.SnNo == PosSn && m.TransType == 2) ?? new StoreChangeHistory();
- // dic["RecycStartDate"] = item.ToDate == null ? "" : item.ToDate.Value.ToString("yyyy-MM-dd");
- // }
- // }
- //实际押金
- string SeoKeyword = dic["SeoKeyword"].ToString();
- if (SeoKeyword.Length > 2)
- {
- SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
- }
- dic["SeoKeyword"] = SeoKeyword;
- //设置押金
- string PrizeParams = dic["PrizeParams"].ToString();
- dic["PrizeParams"] = PrizeParams;
- //所属运营中心
- int OpId = int.Parse(dic["OpId"].ToString());
- if (OpId != 0)
- {
- var sys = opdb.SysAdmin.FirstOrDefault(m => m.QueryCount > 0 && m.UserId == OpId) ?? new OpModels.SysAdmin();
- dic["OpCode"] = sys.OpCode;
- }
- }
- Dictionary<string, object> other = new Dictionary<string, object>();
- int TotalCount = 0;//总机具数
- DataTable dt = OtherMySqlConn.dtable("select count(0) from PosMachinesTwo where 1=1" + condition);
- if (dt.Rows.Count > 0)
- {
- TotalCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
- }
- // dt = OtherMySqlConn.dtable("select sum(TotalPrice) from Orders where PayStatus=1" + condition);
- // if (dt.Rows.Count > 0)
- // {
- // FailAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
- // }
- other.Add("TotalCount", TotalCount);
- other.Add("KysCount99", 0);
- other.Add("KssCount99", 0);
- other.Add("KssCoun198", 0);
- other.Add("KssCount298", 0);
- obj.Add("other", other);
- 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(PosMachinesTwo 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("PosMachinesTwo", Fields, 0);
- AddSysLog(data.Id.ToString(), "PosMachinesTwo", "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;
- PosMachinesTwo editData = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Id) ?? new PosMachinesTwo();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 修改机具库
- /// <summary>
- /// 增加或修改机具库信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Edit(PosMachinesTwo data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("PosSnType", data.PosSnType);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, data.Id);
- AddSysLog(data.Id.ToString(), "PosMachinesTwo", "update");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 未使用机具归位总仓
- /// <summary>
- /// 未使用机具归位总仓
- /// </summary>
- /// <returns></returns>
- public IActionResult Home(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- PosMachinesTwo editData = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Id) ?? new PosMachinesTwo();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 未使用机具归位总仓
- /// <summary>
- /// 未使用机具归位总仓
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Home(PosMachinesTwo data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("SeoTitle", "");
- Fields.Add("SeoKeyword", "");
- Fields.Add("PosSnType", 0);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, data.Id);
- AddSysLog(data.Id.ToString(), "PosMachinesTwo", "home");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 删除机具库信息
- /// <summary>
- /// 删除机具库信息
- /// </summary>
- /// <returns></returns>
- public string Delete(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "PosMachinesTwo", "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("PosMachinesTwo", 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, "PosMachinesTwo", "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("PosMachinesTwo", 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, "PosMachinesTwo", "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("PosMachinesTwo", 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("PosMachinesTwo", Sort, Id);
- AddSysLog(Id.ToString(), "PosMachinesTwo", "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)
- // {
- // string error = "";
- // List<string> PosSnList = new List<string>();
- // for (int i = 1; i < list.Count; i++)
- // {
- // JsonData dr = list[i];
- // string itemJson = dr.ToJson();
- // string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
- // string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
- // string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
- // string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
- // string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
- // string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
- // UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
- // var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
- // MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
- // var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
- // if (posInfo == null)
- // {
- // error += "以下操作失败" + PosSn + ',' + "未找到该品牌的机具" + '\n';
- // }
- // else if (PosSnList.Contains(PosSn))
- // {
- // error += "以下操作失败" + PosSn + ',' + "该机具号重复" + '\n';
- // }
- // else if (!string.IsNullOrEmpty(error))
- // {
- // return "Warning|" + error;
- // }
- // else
- // {
- // PosSnList.Add(PosSn);
- // }
- // }
- // for (int i = 1; i < list.Count; i++)
- // {
- // JsonData dr = list[i];
- // string itemJson = dr.ToJson();
- // string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
- // string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
- // string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
- // string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
- // string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
- // string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
- // decimal amount = 0;
- // UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
- // var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
- // var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new UserAccount();
- // var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == Convert.ToInt32(BrandId)) ?? new KqProducts();
- // if (brandInfo.Name.Contains("电签"))
- // {
- // amount = 200;
- // }
- // if (brandInfo.Name.Contains("大POS"))
- // {
- // amount = 300;
- // }
- // userAccount.ValidAmount += amount;
- // string text = string.Format("导入机具驳回仓库,UserId: '" + user.Id + "',BeforeChangeAmount:'" + userAccount.ValidAmount + "',AfterChangeAmount:'" + userAccount.ValidAmount + amount + "',ChangeAmount:'" + amount + "',Time'" + DateTime.Now + "'");
- // function.WriteLog(text, "机具驳回仓库");//机具驳回仓库日志
- // db.SaveChanges();
- // MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
- // var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
- // if (posInfo != null)
- // {
- // var storehouse = db.StoreHouse.FirstOrDefault(m => m.Id == posInfo.StoreId);
- // StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
- // {
- // CreateDate = DateTime.Now,
- // CreateMan = SysUserName,
- // StoreId = storehouse.Id, //出货 仓库
- // BrandId = Convert.ToInt32(BrandId), //产品类型
- // ProductName = RelationClass.GetKqProductBrandInfo(Convert.ToInt32(BrandId)), //产品名称
- // BizBatchNo = No, //业务批次号
- // TransType = 1, //交易类型
- // SnNo = PosSn, //SN编号
- // StockOpDirect = 1, //库存操作方向
- // SnStatus = 1, //SN状态
- // DeviceVendor = posInfo.DeviceName, //设备厂商
- // DeviceModel = posInfo.DeviceKind, //设备型号
- // DeviceType = posInfo.DeviceType, //设备类型
- // SourceStoreId = posInfo.SourceStoreId, //源仓库编号
- // BrandType = posInfo.DeviceType, //品牌类型
- // }).Entity;
- // db.StoreChangeHistory.Add(new StoreChangeHistory()
- // {
- // CreateDate = DateTime.Now,
- // UserId = user.Id, //创客
- // BrandId = Convert.ToInt32(BrandId), //产品类型
- // ChangeRecordNo = "JJBH" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), //变更记录单号
- // SeoTitle = "机具驳回仓库",
- // BizBatchNo = No, //业务批次号
- // SnNo = PosSn, //SN编号
- // });
- // StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
- // {
- // CreateDate = DateTime.Now,
- // StoreId = posInfo.StoreId, //仓库
- // BrandId = Convert.ToInt32(BrandId), //产品类型
- // OpStoreNum = 1, //操作库存数
- // OpSymbol = "+", //操作符
- // BeforeTotalNum = storehouse.TotalNum, //操作前总库存数
- // AfterTotalNum = storehouse.TotalNum + 1, //操作后总库存数
- // BeforeLaveNum = storehouse.LaveNum, //操作前剩余库存数
- // AfterLaveNum = storehouse.LaveNum + 1, //操作后剩余库存数
- // BeforeOutNum = storehouse.OutNum, //操作前出库数
- // AfterOutNum = storehouse.OutNum - 1, //操作后出库数
- // }).Entity;
- // }
- // }
- // db.SaveChanges();
- // }
- // AddSysLog("0", "MachinesRejectStore", "Import");
- // return "success";
- // }
- // #endregion
- #region 导入金控入库时间数据
- /// <summary>
- /// 导入金控入库时间数据
- /// </summary>
- /// <param name="ImportCreateData"></param>
- public string ImportCreateData(string ExcelData)
- {
- ExcelData = HttpUtility.UrlDecode(ExcelData);
- JsonData list = JsonMapper.ToObject(ExcelData);
- string error = "";
- string info = "";
- var brandInfo = db.KqProducts.ToList();
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- string itemJson = dr.ToJson();
- string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
- string CreateDate = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
- if (pos.Id > 0)
- {
- var brandName = brandInfo.FirstOrDefault(m => m.Id == pos.BrandId);
- if (brandName.Name.StartsWith("金控"))
- {
- info += "机具Sn:" + PosSn + "原入库时间:" + pos.CreateDate + "新入库时间:" + CreateDate;
- pos.CreateDate = DateTime.Parse(CreateDate);
- }
- else
- {
- error += "以下操作失败" + PosSn + ',' + "该机具号品牌不符合修改规则" + '\n';
- }
- }
- else
- {
- error += "以下操作失败" + PosSn + ',' + "该机具号不存在" + '\n';
- }
- }
- if (!string.IsNullOrEmpty(error))
- {
- return "Warning|" + error;
- }
- else
- {
- db.SaveChanges();
- string text = string.Format("导入金控入库时间数据: '" + info + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
- function.WriteLog(text, "导入金控入库时间数据");
- AddSysLog("0", "ImportCreateData", "Import");
- return "success";
- }
- }
- #endregion
- #region 导入数据
- public IActionResult Import(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- /// <summary>
- /// 导入数据
- /// </summary>
- /// <param name="ExcelData"></param>
- [HttpPost]
- public string ImportPost(string ExcelPath)
- {
- string key = function.MD5_16(Guid.NewGuid().ToString());
- RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#ImportJKCreateData#cut#" + key + "#cut#" + SysUserName);
- return "success|" + key;
- }
- public string CheckImport(string key)
- {
- string result = RedisDbconn.Instance.Get<string>("CheckImport:" + key);
- if (!string.IsNullOrEmpty(result))
- {
- string[] datalist = result.Split('|');
- if (datalist[0] == "success")
- {
- return result;
- }
- return datalist[0];
- }
- return "0";
- }
- public Dictionary<string, object> CheckImportV2(string key)
- {
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- string result = RedisDbconn.Instance.Get<string>("CheckImport:" + key);
- if (!string.IsNullOrEmpty(result))
- {
- string[] datalist = result.Split('|');
- if (datalist[0] == "success")
- {
- List<string> errList = RedisDbconn.Instance.GetList<string>("ErrList" + key);
- if (errList.Count > 0)
- {
- Obj.Add("status", 2);
- Obj.Add("errList", errList);
- }
- else
- {
- Obj.Add("status", 1);
- Obj.Add("data", result);
- }
- return Obj;
- }
- Obj.Add("status", 0);
- Obj.Add("data", datalist[0]);
- return Obj;
- }
- Obj.Add("status", -1);
- Obj.Add("data", "执行中...");
- return Obj;
- }
- #endregion
- #region 导出Excel
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportExcel(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName, string BrandId, string ActivationDateData, string BindingDateData, string IsStoreSelect, string OpCode)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("PosSn", "1"); //SN编号
- Fields.Add("BrandId", "0"); //品牌
- string condition = " and Status>-1";
- //是否仓库机
- if (!string.IsNullOrEmpty(IsStoreSelect))
- {
- if (int.Parse(IsStoreSelect) > 0)
- {
- condition += " and UserId=0 and BuyUserId=0";
- }
- }
- //绑定状态
- if (!string.IsNullOrEmpty(BindingStateSelect))
- {
- condition += " and BindingState=" + BindingStateSelect;
- }
- //激活状态
- if (!string.IsNullOrEmpty(ActivationStateSelect))
- {
- condition += " and ActivationState=" + ActivationStateSelect;
- }
- //所属创客编号
- if (!string.IsNullOrEmpty(UserIdMakerCode))
- {
- condition += " and BuyUserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
- }
- //所属创客真实姓名
- if (!string.IsNullOrEmpty(UserIdRealName))
- {
- condition += " and BuyUserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
- }
- //所属仓库编号
- if (!string.IsNullOrEmpty(StoreIdCode))
- {
- condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdCode + "')";
- }
- //所属仓库名称
- if (!string.IsNullOrEmpty(StoreIdName))
- {
- condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
- }
- //运营中心编号
- if (!string.IsNullOrEmpty(OpCode))
- {
- var sysUser = opdb.SysAdmin.FirstOrDefault(m => m.OpCode == OpCode) ?? new OpModels.SysAdmin();
- if (sysUser.Id > 0)
- {
- condition += " and OpId=" + sysUser.UserId;
- }
- }
- //品牌
- if (!string.IsNullOrEmpty(BrandId))
- {
- condition += " and BrandId =" + BrandId;
- }
- if (!string.IsNullOrEmpty(ActivationDateData))
- {
- string[] datelist = ActivationDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and ActivationTime>='" + start + " 00:00:00' and ActivationTime<='" + end + " 23:59:59'";
- }
- if (!string.IsNullOrEmpty(BindingDateData))
- {
- string[] datelist = BindingDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and BindingTime>='" + start + " 00:00:00' and BindingTime<='" + end + " 23:59:59'";
- }
- // //绑定状态
- // if (!string.IsNullOrEmpty(BindingStateSelect))
- // {
- // condition += " and BindingState=" + BindingStateSelect;
- // }
- // //激活状态
- // if (!string.IsNullOrEmpty(ActivationStateSelect))
- // {
- // condition += " and ActivationState=" + ActivationStateSelect;
- // }
- // //所属创客编号
- // if (!string.IsNullOrEmpty(UserIdMakerCode))
- // {
- // condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
- // }
- // //所属创客真实姓名
- // if (!string.IsNullOrEmpty(UserIdRealName))
- // {
- // condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
- // }
- // //所属仓库编号
- // if (!string.IsNullOrEmpty(StoreIdCode))
- // {
- // condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdCode + "')";
- // }
- // //所属仓库名称
- // if (!string.IsNullOrEmpty(StoreIdName))
- // {
- // condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
- // }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", Fields, "Id desc", "0", 1, 20000, condition, "BindingState,ActivationState,UserId,StoreId,PosSn,BrandId,ActivityList,BindMerchantId,PosSnType,DeviceType,BindingTime,ActivationTime,TransferTime,OpId", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //绑定状态
- int BindingState = int.Parse(dic["BindingState"].ToString());
- if (BindingState == 0) dic["BindingState"] = "未绑定";
- if (BindingState == 1) dic["BindingState"] = "已绑定";
- //绑定时间
- if (!string.IsNullOrEmpty(dic["BindingTime"].ToString()))
- {
- DateTime BindingTime = Convert.ToDateTime(dic["BindingTime"].ToString());
- }
- //激活状态
- int ActivationState = int.Parse(dic["ActivationState"].ToString());
- if (ActivationState == 0) dic["ActivationState"] = "未激活";
- if (ActivationState == 1) dic["ActivationState"] = "已激活";
- //激活时间
- if (!string.IsNullOrEmpty(dic["ActivationTime"].ToString()))
- {
- DateTime ActivationTime = Convert.ToDateTime(dic["ActivationTime"].ToString());
- }
- //划拨时间
- if (!string.IsNullOrEmpty(dic["TransferTime"].ToString()))
- {
- DateTime TransferTime = Convert.ToDateTime(dic["TransferTime"].ToString());
- }
- //所属创客
- int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
- Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["UserIdMakerCode"] = userid_Users.MakerCode;
- dic["UserIdRealName"] = userid_Users.RealName;
- dic.Remove("UserId");
- //所属仓库
- int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
- StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
- dic["StoreIdCode"] = storeid_StoreHouse.StoreNo;
- dic["StoreIdName"] = storeid_StoreHouse.StoreName;
- dic.Remove("StoreId");
- //产品类型
- dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
- //参加活动
- // dic["ActivityList"] = RelationClass.GetProfitObjectsActivesList(dic["ActivityList"].ToString());
- //绑定商户
- int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
- PosMerchantInfo bindmerchantid_MerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new PosMerchantInfo();
- dic["BindMerchantIdMerchantNo"] = bindmerchantid_MerchantInfo.MerchantNo;
- dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.MerchantName;
- dic.Remove("BindMerchantId");
- //机具类型
- int PosSnType = int.Parse(dic["PosSnType"].ToString());
- if (PosSnType == 0) dic["PosSnType"] = "兑换机具";
- if (PosSnType == 1) dic["PosSnType"] = "循环机具";
- //所属运营中心
- int OpId = int.Parse(dic["OpId"].ToString());
- if (OpId != 0)
- {
- var sys = opdb.SysAdmin.FirstOrDefault(m => m.QueryCount > 0 && m.UserId == OpId) ?? new OpModels.SysAdmin();
- dic["OpCode"] = sys.OpCode;
- }
- // //设备类型
- // string DeviceType = dic["DeviceType"].ToString();
- // if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
- // if (DeviceType == "KssSignPos") dic["DeviceType"] = "快闪刷电签POS";
- // if (DeviceType == "") dic["DeviceType"] = "";
- }
- Dictionary<string, object> result = new Dictionary<string, object>();
- result.Add("Status", "1");
- result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
- result.Add("Obj", diclist);
- Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
- ReturnFields.Add("UserIdMakerCode", "创客编号");
- ReturnFields.Add("UserIdRealName", "创客姓名");
- ReturnFields.Add("StoreIdCode", "仓库编号");
- ReturnFields.Add("StoreIdName", "仓库名称");
- ReturnFields.Add("BrandId", "产品类型");
- ReturnFields.Add("PosSn", "SN编号");
- ReturnFields.Add("PosSnType", "SN类型");
- // ReturnFields.Add("ActivityList", "参加活动");
- ReturnFields.Add("BindMerchantIdMerchantNo", "绑定商户编号");
- ReturnFields.Add("BindMerchantIdMerchantName", "绑定商户姓名");
- ReturnFields.Add("DeviceType", "设备类型");
- ReturnFields.Add("BindingState", "绑定状态");
- ReturnFields.Add("BindingTime", "绑定时间");
- ReturnFields.Add("ActivationState", "激活状态");
- ReturnFields.Add("ActivationTime", "激活时间");
- ReturnFields.Add("TransferTime", "划拨时间");
- ReturnFields.Add("OpCode", "所属运营中心");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "PosMachinesTwo", "ExportExcel");
- return Json(result);
- }
- #endregion
- #region 过期机具扣费列表
- /// <summary>
- /// 根据条件查询过期机具扣费列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Indexs(PosMachinesTwo data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询过期机具扣费列表
- /// <summary>
- /// 过期机具扣费列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexsData(PosMachinesTwo data, string PosSn, string UserIdMakerCode, string StoreMakerCode, string BrandId, string RecycEndDateData, string AmountYk, string Amountk, string AmountDk, 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>();
- Dictionary<string, object> others = new Dictionary<string, object>();
- others.Add("TotalCount", 0);
- others.Add("AmountYks", 0);
- others.Add("AmountDks", 0);
- objs.Add("other", others);
- return Json(objs);
- }
- decimal AmountYks = 0;//已扣
- decimal AmountDks = 0;//待扣
- var time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- string condition = " and Status>-1 and RecycEndDate<'" + time + "' and ScanQrTrade>0 and ScanQrTrade<999 and BindingState=0";
- //所属创客编号
- if (!string.IsNullOrEmpty(UserIdMakerCode))
- {
- condition += " and BuyUserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
- }
- //仓库所属创客编号
- if (!string.IsNullOrEmpty(StoreMakerCode))
- {
- var userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == StoreMakerCode) ?? new UserForMakerCode();
- var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
- var store = db.StoreHouse.Where(m => m.UserId == user.Id && m.Status > -1).ToList();
- var storeIds = "";
- foreach (var item in store)
- {
- storeIds += item.Id + ",";
- }
- storeIds = storeIds.TrimEnd(',');
- condition += " and StoreId in (" + storeIds + ")";
- }
- //品牌
- if (!string.IsNullOrEmpty(BrandId))
- {
- condition += " and BrandId =" + BrandId;
- }
- if (!string.IsNullOrEmpty(PosSn))
- {
- condition += " and PosSn =" + PosSn + "";
- }
- // if (!string.IsNullOrEmpty(AmountYk))
- // {
- // condition += " and BrandId =" + BrandId;
- // }
- // if (!string.IsNullOrEmpty(Amountk))
- // {
- // condition += " and BrandId =" + BrandId;
- // }
- // if (!string.IsNullOrEmpty(AmountDk))
- // {
- // condition += " and BrandId =" + BrandId;
- // }
- if (!string.IsNullOrEmpty(RecycEndDateData))
- {
- string[] datelist = RecycEndDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and RecycEndDate>='" + start + " 00:00:00' and RecycEndDate<='" + end + " 23:59:59'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", 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 BindingState = int.Parse(dic["BindingState"].ToString());
- if (BindingState == 0) dic["BindingState"] = "未绑定";
- if (BindingState == 1) dic["BindingState"] = "已绑定";
- //激活状态
- int ActivationState = int.Parse(dic["ActivationState"].ToString());
- if (ActivationState == 0) dic["ActivationState"] = "未激活";
- if (ActivationState == 1) dic["ActivationState"] = "已激活";
- //所属创客
- int BuyUserId = int.Parse(function.CheckInt(dic["BuyUserId"].ToString()));
- Users userid_Users = db.Users.FirstOrDefault(m => m.Id == BuyUserId) ?? new Users();
- dic["UserIdMakerCode"] = userid_Users.MakerCode;
- dic["UserIdRealName"] = userid_Users.RealName;
- dic.Remove("BuyUserId");
- //所属仓库
- int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
- StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
- dic["StoreIdCode"] = storeid_StoreHouse.StoreNo;
- dic["StoreIdName"] = storeid_StoreHouse.StoreName;
- dic.Remove("StoreId");
- //产品类型
- dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
- decimal ScanQrTrade = decimal.Parse(dic["ScanQrTrade"].ToString());
- var brandInfo = dic["BrandId"].ToString();
- decimal amount = 0;
- if (brandInfo.Contains("电签"))
- {
- amount = 200;
- }
- if (brandInfo.Contains("大POS"))
- {
- amount = 300;
- }
- if (ScanQrTrade > 0 && ScanQrTrade < 999)
- {
- dic["AmountYk"] = amount;
- dic["Amountk"] = ScanQrTrade;
- dic["AmountDk"] = amount - ScanQrTrade;
- // AmountYks += ScanQrTrade;
- // AmountDks += amount - ScanQrTrade;
- }
- if (ScanQrTrade == 999)
- {
- dic["AmountYk"] = amount;
- dic["Amountk"] = amount;
- dic["AmountDk"] = 0;
- // AmountYks += amount;
- }
- //参加活动
- dic["ActivityList"] = RelationClass.GetProfitObjectsActivesList(dic["ActivityList"].ToString());
- //绑定商户
- int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
- PosMerchantInfo bindmerchantid_MerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new PosMerchantInfo();
- dic["BindMerchantIdMerchantNo"] = bindmerchantid_MerchantInfo.MerchantNo;
- dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.MerchantName;
- dic.Remove("BindMerchantId");
- //机具类型
- int PosSnType = int.Parse(dic["PosSnType"].ToString());
- if (PosSnType == 0) dic["PosSnType"] = "兑换机具";
- if (PosSnType == 1) dic["PosSnType"] = "循环机具";
- //设备类型
- string DeviceType = dic["DeviceType"].ToString();
- if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
- if (DeviceType == "KssSignPos") dic["DeviceType"] = "快闪刷电签POS";
- if (DeviceType == "") dic["DeviceType"] = "";
- //盟主信息
- int LeaderUserId = int.Parse(function.CheckInt(dic["LeaderUserId"].ToString()));
- if (LeaderUserId != 0)
- {
- Users users = db.Users.FirstOrDefault(m => m.Id == LeaderUserId) ?? new Users();
- dic["UserInfo"] = users.MakerCode + "_" + users.RealName;
- }
- //是否为第一台机具
- int IsFirst = int.Parse(dic["IsFirst"].ToString());
- if (IsFirst == 0) dic["IsFirst"] = "否";
- if (IsFirst == 1) dic["IsFirst"] = "是";
- //循环开始时间
- // if (!string.IsNullOrEmpty(dic["RecycEndDate"].ToString()))
- // {
- // // var RecycStartDate = Convert.ToDateTime(dic["RecycEndDate"].ToString()).AddDays(-360).ToString("yyyy-MM-dd HH:mm:ss");
- // // dic["RecycStartDate"] = RecycStartDate;
- // string PosSn = dic["PosSn"].ToString();
- // bool op = db.StoreChangeHistory.Any(m => m.SnNo == PosSn && m.TransType == 2);
- // if(op)
- // {
- // StoreChangeHistory item = db.StoreChangeHistory.FirstOrDefault(m => m.SnNo == PosSn && m.TransType == 2) ?? new StoreChangeHistory();
- // dic["RecycStartDate"] = item.ToDate == null ? "" : item.ToDate.Value.ToString("yyyy-MM-dd");
- // }
- // }
- //实际押金
- string SeoKeyword = dic["SeoKeyword"].ToString();
- if (SeoKeyword.Length > 2)
- {
- SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
- }
- dic["SeoKeyword"] = SeoKeyword;
- //设置押金
- string PrizeParams = dic["PrizeParams"].ToString();
- dic["PrizeParams"] = PrizeParams;
- //所属运营中心
- int OpId = int.Parse(dic["OpId"].ToString());
- if (OpId != 0)
- {
- var sys = opdb.SysAdmin.FirstOrDefault(m => m.QueryCount > 0 && m.UserId == OpId) ?? new OpModels.SysAdmin();
- dic["OpCode"] = sys.OpCode;
- }
- }
- Dictionary<string, object> other = new Dictionary<string, object>();
- int TotalCount = 0;//总机具数
- DataTable dt = OtherMySqlConn.dtable("select count(0) from PosMachinesTwo where 1=1" + condition);
- if (dt.Rows.Count > 0)
- {
- TotalCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
- }
- DataTable dts = OtherMySqlConn.dtable("select Id from PosMachinesTwo where 1=1" + condition);
- var Ids = "";
- foreach (DataRow item in dts.Rows)
- {
- Ids += item["Id"].ToString() + ",";
- }
- var Id = "," + Ids;
- var pos = db.PosMachinesTwo.Where(m => Id.Contains("," + m.Id + ",")).ToList();
- string[] strids = Ids.TrimEnd(',').Split(',');
- foreach (var items in strids)
- {
- int posId = int.Parse(items);
- var posInfo = pos.FirstOrDefault(m => m.Id == posId) ?? new PosMachinesTwo();
- decimal ScanQrTrade = decimal.Parse(posInfo.ScanQrTrade.ToString());
- var brandInfo = RelationClass.GetKqProductBrandInfo(int.Parse(posInfo.BrandId.ToString()));
- decimal amount = 0;
- if (brandInfo.Contains("电签"))
- {
- amount = 200;
- }
- if (brandInfo.Contains("大POS"))
- {
- amount = 300;
- }
- if (ScanQrTrade > 0 && ScanQrTrade < 999)
- {
- AmountYks += ScanQrTrade;
- AmountDks += amount - ScanQrTrade;
- }
- if (ScanQrTrade == 999)
- {
- AmountYks += amount;
- }
- }
- other.Add("TotalCount", TotalCount);
- other.Add("AmountYks", AmountYks);
- other.Add("AmountDks", AmountDks);
- obj.Add("other", other);
- return Json(obj);
- }
- #endregion
- }
- }
|