PosMachinesTwoController.cs 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. /*
  2. * 机具库
  3. */
  4. using System;
  5. using System.Web;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Data;
  10. using System.Threading.Tasks;
  11. using Microsoft.AspNetCore.Mvc;
  12. using Microsoft.AspNetCore.Http;
  13. using Microsoft.Extensions.Logging;
  14. using Microsoft.Extensions.Options;
  15. using MySystem.Models;
  16. using Library;
  17. using LitJson;
  18. using MySystemLib;
  19. namespace MySystem.Areas.Admin.Controllers
  20. {
  21. [Area("Admin")]
  22. [Route("Admin/[controller]/[action]")]
  23. public class PosMachinesTwoController : BaseController
  24. {
  25. public PosMachinesTwoController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  26. {
  27. OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  28. }
  29. #region 机具库列表
  30. /// <summary>
  31. /// 根据条件查询机具库列表
  32. /// </summary>
  33. /// <returns></returns>
  34. public IActionResult Index(PosMachinesTwo data, string right)
  35. {
  36. ViewBag.RightInfo = RightInfo;
  37. ViewBag.right = right;
  38. return View();
  39. }
  40. #endregion
  41. #region 根据条件查询机具库列表
  42. /// <summary>
  43. /// 机具库列表
  44. /// </summary>
  45. /// <returns></returns>
  46. 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)
  47. {
  48. Dictionary<string, string> Fields = new Dictionary<string, string>();
  49. Fields.Add("PosSn", "1"); //SN编号
  50. Fields.Add("BrandId", "0"); //品牌
  51. if (ShowFlag == 0)
  52. {
  53. Dictionary<string, object> objs = new Dictionary<string, object>();
  54. Dictionary<string, object> others = new Dictionary<string, object>();
  55. others.Add("TotalCount", 0);
  56. others.Add("KysCount99", 0);
  57. others.Add("KssCount99", 0);
  58. others.Add("KssCoun198", 0);
  59. others.Add("KssCount298", 0);
  60. objs.Add("other", others);
  61. return Json(objs);
  62. }
  63. string condition = " and Status>-1";
  64. //是否仓库机
  65. if (!string.IsNullOrEmpty(IsStoreSelect))
  66. {
  67. if (int.Parse(IsStoreSelect) > 0)
  68. {
  69. condition += " and UserId=0 and BuyUserId=0";
  70. }
  71. }
  72. //绑定状态
  73. if (!string.IsNullOrEmpty(BindingStateSelect))
  74. {
  75. condition += " and BindingState=" + BindingStateSelect;
  76. }
  77. //激活状态
  78. if (!string.IsNullOrEmpty(ActivationStateSelect))
  79. {
  80. condition += " and ActivationState=" + ActivationStateSelect;
  81. }
  82. //所属创客编号
  83. if (!string.IsNullOrEmpty(UserIdMakerCode))
  84. {
  85. condition += " and BuyUserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  86. }
  87. //所属创客真实姓名
  88. if (!string.IsNullOrEmpty(UserIdRealName))
  89. {
  90. condition += " and BuyUserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
  91. }
  92. //所属仓库编号
  93. if (!string.IsNullOrEmpty(StoreIdCode))
  94. {
  95. condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdCode + "')";
  96. }
  97. //所属仓库名称
  98. if (!string.IsNullOrEmpty(StoreIdName))
  99. {
  100. condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
  101. }
  102. //运营中心编号
  103. if (!string.IsNullOrEmpty(OpCode))
  104. {
  105. var sysUser = opdb.SysAdmin.FirstOrDefault(m => m.OpCode == OpCode) ?? new OpModels.SysAdmin();
  106. if (sysUser.Id > 0)
  107. {
  108. condition += " and OpId=" + sysUser.UserId;
  109. }
  110. }
  111. //品牌
  112. if (!string.IsNullOrEmpty(BrandId))
  113. {
  114. condition += " and BrandId =" + BrandId;
  115. }
  116. if (!string.IsNullOrEmpty(ActivationDateData))
  117. {
  118. string[] datelist = ActivationDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  119. string start = datelist[0];
  120. string end = datelist[1];
  121. condition += " and ActivationTime>='" + start + " 00:00:00' and ActivationTime<='" + end + " 23:59:59'";
  122. }
  123. if (!string.IsNullOrEmpty(BindingDateData))
  124. {
  125. string[] datelist = BindingDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  126. string start = datelist[0];
  127. string end = datelist[1];
  128. condition += " and BindingTime>='" + start + " 00:00:00' and BindingTime<='" + end + " 23:59:59'";
  129. }
  130. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", Fields, "Id desc", "0", page, limit, condition);
  131. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  132. foreach (Dictionary<string, object> dic in diclist)
  133. {
  134. //绑定状态
  135. int BindingState = int.Parse(dic["BindingState"].ToString());
  136. if (BindingState == 0) dic["BindingState"] = "未绑定";
  137. if (BindingState == 1) dic["BindingState"] = "已绑定";
  138. //激活状态
  139. int ActivationState = int.Parse(dic["ActivationState"].ToString());
  140. if (ActivationState == 0) dic["ActivationState"] = "未激活";
  141. if (ActivationState == 1) dic["ActivationState"] = "已激活";
  142. //所属创客
  143. int BuyUserId = int.Parse(function.CheckInt(dic["BuyUserId"].ToString()));
  144. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == BuyUserId) ?? new Users();
  145. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  146. dic["UserIdRealName"] = userid_Users.RealName;
  147. dic.Remove("BuyUserId");
  148. //所属仓库
  149. int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
  150. StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
  151. dic["StoreIdCode"] = storeid_StoreHouse.StoreNo;
  152. dic["StoreIdName"] = storeid_StoreHouse.StoreName;
  153. dic.Remove("StoreId");
  154. //产品类型
  155. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  156. //参加活动
  157. dic["ActivityList"] = RelationClass.GetProfitObjectsActivesList(dic["ActivityList"].ToString());
  158. //绑定商户
  159. int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
  160. PosMerchantInfo bindmerchantid_MerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new PosMerchantInfo();
  161. dic["BindMerchantIdMerchantNo"] = bindmerchantid_MerchantInfo.MerchantNo;
  162. dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.MerchantName;
  163. dic.Remove("BindMerchantId");
  164. //机具类型
  165. int PosSnType = int.Parse(dic["PosSnType"].ToString());
  166. if (PosSnType == 0) dic["PosSnType"] = "兑换机具";
  167. if (PosSnType == 1) dic["PosSnType"] = "循环机具";
  168. //设备类型
  169. string DeviceType = dic["DeviceType"].ToString();
  170. if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
  171. if (DeviceType == "KssSignPos") dic["DeviceType"] = "快闪刷电签POS";
  172. if (DeviceType == "") dic["DeviceType"] = "";
  173. //盟主信息
  174. int LeaderUserId = int.Parse(function.CheckInt(dic["LeaderUserId"].ToString()));
  175. if (LeaderUserId != 0)
  176. {
  177. Users users = db.Users.FirstOrDefault(m => m.Id == LeaderUserId) ?? new Users();
  178. dic["UserInfo"] = users.MakerCode + "_" + users.RealName;
  179. }
  180. //是否为第一台机具
  181. int IsFirst = int.Parse(dic["IsFirst"].ToString());
  182. if (IsFirst == 0) dic["IsFirst"] = "否";
  183. if (IsFirst == 1) dic["IsFirst"] = "是";
  184. //循环开始时间
  185. // if (!string.IsNullOrEmpty(dic["RecycEndDate"].ToString()))
  186. // {
  187. // // var RecycStartDate = Convert.ToDateTime(dic["RecycEndDate"].ToString()).AddDays(-360).ToString("yyyy-MM-dd HH:mm:ss");
  188. // // dic["RecycStartDate"] = RecycStartDate;
  189. // string PosSn = dic["PosSn"].ToString();
  190. // bool op = db.StoreChangeHistory.Any(m => m.SnNo == PosSn && m.TransType == 2);
  191. // if(op)
  192. // {
  193. // StoreChangeHistory item = db.StoreChangeHistory.FirstOrDefault(m => m.SnNo == PosSn && m.TransType == 2) ?? new StoreChangeHistory();
  194. // dic["RecycStartDate"] = item.ToDate == null ? "" : item.ToDate.Value.ToString("yyyy-MM-dd");
  195. // }
  196. // }
  197. //实际押金
  198. string SeoKeyword = dic["SeoKeyword"].ToString();
  199. if (SeoKeyword.Length > 2)
  200. {
  201. SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
  202. }
  203. dic["SeoKeyword"] = SeoKeyword;
  204. //设置押金
  205. string PrizeParams = dic["PrizeParams"].ToString();
  206. dic["PrizeParams"] = PrizeParams;
  207. //所属运营中心
  208. int OpId = int.Parse(dic["OpId"].ToString());
  209. if (OpId != 0)
  210. {
  211. var sys = opdb.SysAdmin.FirstOrDefault(m => m.QueryCount > 0 && m.UserId == OpId) ?? new OpModels.SysAdmin();
  212. dic["OpCode"] = sys.OpCode;
  213. }
  214. }
  215. Dictionary<string, object> other = new Dictionary<string, object>();
  216. int TotalCount = 0;//总机具数
  217. DataTable dt = OtherMySqlConn.dtable("select count(0) from PosMachinesTwo where 1=1" + condition);
  218. if (dt.Rows.Count > 0)
  219. {
  220. TotalCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
  221. }
  222. // dt = OtherMySqlConn.dtable("select sum(TotalPrice) from Orders where PayStatus=1" + condition);
  223. // if (dt.Rows.Count > 0)
  224. // {
  225. // FailAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
  226. // }
  227. other.Add("TotalCount", TotalCount);
  228. other.Add("KysCount99", 0);
  229. other.Add("KssCount99", 0);
  230. other.Add("KssCoun198", 0);
  231. other.Add("KssCount298", 0);
  232. obj.Add("other", other);
  233. return Json(obj);
  234. }
  235. #endregion
  236. #region 增加机具库
  237. /// <summary>
  238. /// 增加或修改机具库信息
  239. /// </summary>
  240. /// <returns></returns>
  241. public IActionResult Add(string right)
  242. {
  243. ViewBag.RightInfo = RightInfo;
  244. ViewBag.right = right;
  245. return View();
  246. }
  247. #endregion
  248. #region 增加机具库
  249. /// <summary>
  250. /// 增加或修改机具库信息
  251. /// </summary>
  252. /// <returns></returns>
  253. [HttpPost]
  254. public string Add(PosMachinesTwo data)
  255. {
  256. Dictionary<string, object> Fields = new Dictionary<string, object>();
  257. Fields.Add("SeoTitle", data.SeoTitle);
  258. Fields.Add("SeoKeyword", data.SeoKeyword);
  259. Fields.Add("SeoDescription", data.SeoDescription);
  260. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("PosMachinesTwo", Fields, 0);
  261. AddSysLog(data.Id.ToString(), "PosMachinesTwo", "add");
  262. db.SaveChanges();
  263. return "success";
  264. }
  265. #endregion
  266. #region 修改机具库
  267. /// <summary>
  268. /// 增加或修改机具库信息
  269. /// </summary>
  270. /// <returns></returns>
  271. public IActionResult Edit(string right, int Id = 0)
  272. {
  273. ViewBag.RightInfo = RightInfo;
  274. ViewBag.right = right;
  275. PosMachinesTwo editData = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Id) ?? new PosMachinesTwo();
  276. ViewBag.data = editData;
  277. return View();
  278. }
  279. #endregion
  280. #region 修改机具库
  281. /// <summary>
  282. /// 增加或修改机具库信息
  283. /// </summary>
  284. /// <returns></returns>
  285. [HttpPost]
  286. public string Edit(PosMachinesTwo data)
  287. {
  288. Dictionary<string, object> Fields = new Dictionary<string, object>();
  289. Fields.Add("PosSnType", data.PosSnType);
  290. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, data.Id);
  291. AddSysLog(data.Id.ToString(), "PosMachinesTwo", "update");
  292. db.SaveChanges();
  293. return "success";
  294. }
  295. #endregion
  296. #region 未使用机具归位总仓
  297. /// <summary>
  298. /// 未使用机具归位总仓
  299. /// </summary>
  300. /// <returns></returns>
  301. public IActionResult Home(string right, int Id = 0)
  302. {
  303. ViewBag.RightInfo = RightInfo;
  304. ViewBag.right = right;
  305. PosMachinesTwo editData = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Id) ?? new PosMachinesTwo();
  306. ViewBag.data = editData;
  307. return View();
  308. }
  309. #endregion
  310. #region 未使用机具归位总仓
  311. /// <summary>
  312. /// 未使用机具归位总仓
  313. /// </summary>
  314. /// <returns></returns>
  315. [HttpPost]
  316. public string Home(PosMachinesTwo data)
  317. {
  318. Dictionary<string, object> Fields = new Dictionary<string, object>();
  319. Fields.Add("SeoTitle", "");
  320. Fields.Add("SeoKeyword", "");
  321. Fields.Add("PosSnType", 0);
  322. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, data.Id);
  323. AddSysLog(data.Id.ToString(), "PosMachinesTwo", "home");
  324. db.SaveChanges();
  325. return "success";
  326. }
  327. #endregion
  328. #region 删除机具库信息
  329. /// <summary>
  330. /// 删除机具库信息
  331. /// </summary>
  332. /// <returns></returns>
  333. public string Delete(string Id)
  334. {
  335. string[] idlist = Id.Split(new char[] { ',' });
  336. AddSysLog(Id, "PosMachinesTwo", "del");
  337. foreach (string subid in idlist)
  338. {
  339. int id = int.Parse(subid);
  340. Dictionary<string, object> Fields = new Dictionary<string, object>();
  341. Fields.Add("Status", -1);
  342. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, id);
  343. }
  344. db.SaveChanges();
  345. return "success";
  346. }
  347. #endregion
  348. #region 开启
  349. /// <summary>
  350. /// 开启
  351. /// </summary>
  352. /// <returns></returns>
  353. public string Open(string Id)
  354. {
  355. string[] idlist = Id.Split(new char[] { ',' });
  356. AddSysLog(Id, "PosMachinesTwo", "open");
  357. foreach (string subid in idlist)
  358. {
  359. int id = int.Parse(subid);
  360. Dictionary<string, object> Fields = new Dictionary<string, object>();
  361. Fields.Add("Status", 1);
  362. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, id);
  363. }
  364. db.SaveChanges();
  365. return "success";
  366. }
  367. #endregion
  368. #region 关闭
  369. /// <summary>
  370. /// 关闭
  371. /// </summary>
  372. /// <returns></returns>
  373. public string Close(string Id)
  374. {
  375. string[] idlist = Id.Split(new char[] { ',' });
  376. AddSysLog(Id, "PosMachinesTwo", "close");
  377. foreach (string subid in idlist)
  378. {
  379. int id = int.Parse(subid);
  380. Dictionary<string, object> Fields = new Dictionary<string, object>();
  381. Fields.Add("Status", 0);
  382. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMachinesTwo", Fields, id);
  383. }
  384. db.SaveChanges();
  385. return "success";
  386. }
  387. #endregion
  388. #region 排序
  389. /// <summary>
  390. /// 排序
  391. /// </summary>
  392. /// <param name="Id"></param>
  393. public string Sort(int Id, int Sort)
  394. {
  395. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("PosMachinesTwo", Sort, Id);
  396. AddSysLog(Id.ToString(), "PosMachinesTwo", "sort");
  397. return "success";
  398. }
  399. #endregion
  400. #region 导入数据
  401. /// <summary>
  402. /// 导入数据
  403. /// </summary>
  404. /// <param name="ExcelData"></param>
  405. public string Import(string ExcelData, int Kind = 0)
  406. {
  407. ExcelData = HttpUtility.UrlDecode(ExcelData);
  408. JsonData list = JsonMapper.ToObject(ExcelData);
  409. if (Kind == 1)
  410. {
  411. string error = "";
  412. List<string> PosSnList = new List<string>();
  413. for (int i = 1; i < list.Count; i++)
  414. {
  415. JsonData dr = list[i];
  416. string itemJson = dr.ToJson();
  417. string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
  418. string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
  419. string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
  420. string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
  421. string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
  422. string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
  423. UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  424. var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
  425. MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
  426. var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
  427. if (posInfo == null)
  428. {
  429. error += "以下操作失败" + PosSn + ',' + "未找到该品牌的机具" + '\n';
  430. }
  431. else if (PosSnList.Contains(PosSn))
  432. {
  433. error += "以下操作失败" + PosSn + ',' + "该机具号重复" + '\n';
  434. }
  435. else if (!string.IsNullOrEmpty(error))
  436. {
  437. return "Warning|" + error;
  438. }
  439. else
  440. {
  441. PosSnList.Add(PosSn);
  442. }
  443. }
  444. for (int i = 1; i < list.Count; i++)
  445. {
  446. JsonData dr = list[i];
  447. string itemJson = dr.ToJson();
  448. string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
  449. string BrandId = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
  450. string MakerCode = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
  451. string StoreNo = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
  452. string No = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
  453. string Remark = itemJson.Contains("\"F\"") ? dr["F"].ToString() : "";
  454. decimal amount = 0;
  455. UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  456. var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
  457. var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new UserAccount();
  458. var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == Convert.ToInt32(BrandId)) ?? new KqProducts();
  459. if (brandInfo.Name.Contains("电签"))
  460. {
  461. amount = 200;
  462. }
  463. if (brandInfo.Name.Contains("大POS"))
  464. {
  465. amount = 300;
  466. }
  467. userAccount.ValidAmount += amount;
  468. string text = string.Format("导入机具驳回仓库,UserId: '" + user.Id + "',BeforeChangeAmount:'" + userAccount.ValidAmount + "',AfterChangeAmount:'" + userAccount.ValidAmount + amount + "',ChangeAmount:'" + amount + "',Time'" + DateTime.Now + "'");
  469. function.WriteLog(text, "机具驳回仓库");//机具驳回仓库日志
  470. db.SaveChanges();
  471. MachineForSnNo machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
  472. var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId && m.BrandId == Convert.ToInt32(BrandId) && m.UserId == user.Id && m.BindingState == 0);
  473. if (posInfo != null)
  474. {
  475. var storehouse = db.StoreHouse.FirstOrDefault(m => m.Id == posInfo.StoreId);
  476. StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
  477. {
  478. CreateDate = DateTime.Now,
  479. CreateMan = SysUserName,
  480. StoreId = storehouse.Id, //出货 仓库
  481. BrandId = Convert.ToInt32(BrandId), //产品类型
  482. ProductName = RelationClass.GetKqProductBrandInfo(Convert.ToInt32(BrandId)), //产品名称
  483. BizBatchNo = No, //业务批次号
  484. TransType = 1, //交易类型
  485. SnNo = PosSn, //SN编号
  486. StockOpDirect = 1, //库存操作方向
  487. SnStatus = 1, //SN状态
  488. DeviceVendor = posInfo.DeviceName, //设备厂商
  489. DeviceModel = posInfo.DeviceKind, //设备型号
  490. DeviceType = posInfo.DeviceType, //设备类型
  491. SourceStoreId = posInfo.SourceStoreId, //源仓库编号
  492. BrandType = posInfo.DeviceType, //品牌类型
  493. }).Entity;
  494. db.StoreChangeHistory.Add(new StoreChangeHistory()
  495. {
  496. CreateDate = DateTime.Now,
  497. UserId = user.Id, //创客
  498. BrandId = Convert.ToInt32(BrandId), //产品类型
  499. ChangeRecordNo = "JJBH" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), //变更记录单号
  500. SeoTitle = "机具驳回仓库",
  501. BizBatchNo = No, //业务批次号
  502. SnNo = PosSn, //SN编号
  503. });
  504. StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
  505. {
  506. CreateDate = DateTime.Now,
  507. StoreId = posInfo.StoreId, //仓库
  508. BrandId = Convert.ToInt32(BrandId), //产品类型
  509. OpStoreNum = 1, //操作库存数
  510. OpSymbol = "+", //操作符
  511. BeforeTotalNum = storehouse.TotalNum, //操作前总库存数
  512. AfterTotalNum = storehouse.TotalNum + 1, //操作后总库存数
  513. BeforeLaveNum = storehouse.LaveNum, //操作前剩余库存数
  514. AfterLaveNum = storehouse.LaveNum + 1, //操作后剩余库存数
  515. BeforeOutNum = storehouse.OutNum, //操作前出库数
  516. AfterOutNum = storehouse.OutNum - 1, //操作后出库数
  517. }).Entity;
  518. }
  519. }
  520. db.SaveChanges();
  521. }
  522. AddSysLog("0", "MachinesRejectStore", "Import");
  523. return "success";
  524. }
  525. #endregion
  526. #region 导入金控入库时间数据
  527. /// <summary>
  528. /// 导入金控入库时间数据
  529. /// </summary>
  530. /// <param name="ImportCreateData"></param>
  531. public string ImportCreateData(string ExcelData)
  532. {
  533. ExcelData = HttpUtility.UrlDecode(ExcelData);
  534. JsonData list = JsonMapper.ToObject(ExcelData);
  535. string error = "";
  536. string info = "";
  537. var brandInfo = db.KqProducts.ToList();
  538. for (int i = 1; i < list.Count; i++)
  539. {
  540. JsonData dr = list[i];
  541. string itemJson = dr.ToJson();
  542. string PosSn = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
  543. string CreateDate = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
  544. var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn && m.Status > -1) ?? new PosMachinesTwo();
  545. if (pos.Id > 0)
  546. {
  547. var brandName = brandInfo.FirstOrDefault(m => m.Id == pos.BrandId);
  548. if (brandName.Name.StartsWith("金控"))
  549. {
  550. info += "机具Sn:" + PosSn + "原入库时间:" + pos.CreateDate + "新入库时间:" + CreateDate;
  551. pos.CreateDate = DateTime.Parse(CreateDate);
  552. }
  553. else
  554. {
  555. error += "以下操作失败" + PosSn + ',' + "该机具号品牌不符合修改规则" + '\n';
  556. }
  557. }
  558. else
  559. {
  560. error += "以下操作失败" + PosSn + ',' + "该机具号不存在" + '\n';
  561. }
  562. }
  563. if (!string.IsNullOrEmpty(error))
  564. {
  565. return "Warning|" + error;
  566. }
  567. else
  568. {
  569. db.SaveChanges();
  570. string text = string.Format("导入金控入库时间数据: '" + info + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
  571. function.WriteLog(text, "导入金控入库时间数据");
  572. AddSysLog("0", "ImportCreateData", "Import");
  573. return "success";
  574. }
  575. }
  576. #endregion
  577. #region 导出Excel
  578. /// <summary>
  579. /// 导出Excel
  580. /// </summary>
  581. /// <returns></returns>
  582. public JsonResult ExportExcel(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName)
  583. {
  584. Dictionary<string, string> Fields = new Dictionary<string, string>();
  585. Fields.Add("PosSn", "1"); //SN编号
  586. Fields.Add("BrandId", "0"); //品牌
  587. string condition = " and Status>-1";
  588. //绑定状态
  589. if (!string.IsNullOrEmpty(BindingStateSelect))
  590. {
  591. condition += " and BindingState=" + BindingStateSelect;
  592. }
  593. //激活状态
  594. if (!string.IsNullOrEmpty(ActivationStateSelect))
  595. {
  596. condition += " and ActivationState=" + ActivationStateSelect;
  597. }
  598. //所属创客编号
  599. if (!string.IsNullOrEmpty(UserIdMakerCode))
  600. {
  601. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  602. }
  603. //所属创客真实姓名
  604. if (!string.IsNullOrEmpty(UserIdRealName))
  605. {
  606. condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
  607. }
  608. //所属仓库编号
  609. if (!string.IsNullOrEmpty(StoreIdCode))
  610. {
  611. condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdCode + "')";
  612. }
  613. //所属仓库名称
  614. if (!string.IsNullOrEmpty(StoreIdName))
  615. {
  616. condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
  617. }
  618. 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", false);
  619. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  620. foreach (Dictionary<string, object> dic in diclist)
  621. {
  622. //绑定状态
  623. int BindingState = int.Parse(dic["BindingState"].ToString());
  624. if (BindingState == 0) dic["BindingState"] = "未绑定";
  625. if (BindingState == 1) dic["BindingState"] = "已绑定";
  626. //绑定时间
  627. if (!string.IsNullOrEmpty(dic["BindingTime"].ToString()))
  628. {
  629. DateTime BindingTime = Convert.ToDateTime(dic["BindingTime"].ToString());
  630. }
  631. //激活状态
  632. int ActivationState = int.Parse(dic["ActivationState"].ToString());
  633. if (ActivationState == 0) dic["ActivationState"] = "未激活";
  634. if (ActivationState == 1) dic["ActivationState"] = "已激活";
  635. //激活时间
  636. if (!string.IsNullOrEmpty(dic["ActivationTime"].ToString()))
  637. {
  638. DateTime ActivationTime = Convert.ToDateTime(dic["ActivationTime"].ToString());
  639. }
  640. //划拨时间
  641. if (!string.IsNullOrEmpty(dic["TransferTime"].ToString()))
  642. {
  643. DateTime TransferTime = Convert.ToDateTime(dic["TransferTime"].ToString());
  644. }
  645. //所属创客
  646. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  647. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  648. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  649. dic["UserIdRealName"] = userid_Users.RealName;
  650. dic.Remove("UserId");
  651. //所属仓库
  652. int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
  653. StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
  654. dic["StoreIdCode"] = storeid_StoreHouse.StoreNo;
  655. dic["StoreIdName"] = storeid_StoreHouse.StoreName;
  656. dic.Remove("StoreId");
  657. //产品类型
  658. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  659. //参加活动
  660. // dic["ActivityList"] = RelationClass.GetProfitObjectsActivesList(dic["ActivityList"].ToString());
  661. //绑定商户
  662. int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
  663. PosMerchantInfo bindmerchantid_MerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new PosMerchantInfo();
  664. dic["BindMerchantIdMerchantNo"] = bindmerchantid_MerchantInfo.MerchantNo;
  665. dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.MerchantName;
  666. dic.Remove("BindMerchantId");
  667. //机具类型
  668. int PosSnType = int.Parse(dic["PosSnType"].ToString());
  669. if (PosSnType == 0) dic["PosSnType"] = "兑换机具";
  670. if (PosSnType == 1) dic["PosSnType"] = "循环机具";
  671. // //设备类型
  672. // string DeviceType = dic["DeviceType"].ToString();
  673. // if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
  674. // if (DeviceType == "KssSignPos") dic["DeviceType"] = "快闪刷电签POS";
  675. // if (DeviceType == "") dic["DeviceType"] = "";
  676. }
  677. Dictionary<string, object> result = new Dictionary<string, object>();
  678. result.Add("Status", "1");
  679. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  680. result.Add("Obj", diclist);
  681. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  682. ReturnFields.Add("UserIdMakerCode", "创客编号");
  683. ReturnFields.Add("UserIdRealName", "创客姓名");
  684. ReturnFields.Add("StoreIdCode", "仓库编号");
  685. ReturnFields.Add("StoreIdName", "仓库名称");
  686. ReturnFields.Add("BrandId", "产品类型");
  687. ReturnFields.Add("PosSn", "SN编号");
  688. ReturnFields.Add("PosSnType", "SN类型");
  689. // ReturnFields.Add("ActivityList", "参加活动");
  690. ReturnFields.Add("BindMerchantIdMerchantNo", "绑定商户编号");
  691. ReturnFields.Add("BindMerchantIdMerchantName", "绑定商户姓名");
  692. ReturnFields.Add("DeviceType", "设备类型");
  693. ReturnFields.Add("BindingState", "绑定状态");
  694. ReturnFields.Add("BindingTime", "绑定时间");
  695. ReturnFields.Add("ActivationState", "激活状态");
  696. ReturnFields.Add("ActivationTime", "激活时间");
  697. ReturnFields.Add("TransferTime", "划拨时间");
  698. result.Add("Fields", ReturnFields);
  699. AddSysLog("0", "PosMachinesTwo", "ExportExcel");
  700. return Json(result);
  701. }
  702. #endregion
  703. #region 过期机具扣费列表
  704. /// <summary>
  705. /// 根据条件查询过期机具扣费列表
  706. /// </summary>
  707. /// <returns></returns>
  708. public IActionResult Indexs(PosMachinesTwo data, string right)
  709. {
  710. ViewBag.RightInfo = RightInfo;
  711. ViewBag.right = right;
  712. return View();
  713. }
  714. #endregion
  715. #region 根据条件查询过期机具扣费列表
  716. /// <summary>
  717. /// 过期机具扣费列表
  718. /// </summary>
  719. /// <returns></returns>
  720. 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)
  721. {
  722. Dictionary<string, string> Fields = new Dictionary<string, string>();
  723. if (ShowFlag == 0)
  724. {
  725. Dictionary<string, object> objs = new Dictionary<string, object>();
  726. Dictionary<string, object> others = new Dictionary<string, object>();
  727. others.Add("TotalCount", 0);
  728. others.Add("AmountYks", 0);
  729. others.Add("AmountDks", 0);
  730. objs.Add("other", others);
  731. return Json(objs);
  732. }
  733. decimal AmountYks = 0;//已扣
  734. decimal AmountDks = 0;//待扣
  735. var time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  736. string condition = " and Status>-1 and RecycEndDate<'" + time + "' and ScanQrTrade>0 and ScanQrTrade<999 and BindingState=0";
  737. //所属创客编号
  738. if (!string.IsNullOrEmpty(UserIdMakerCode))
  739. {
  740. condition += " and BuyUserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  741. }
  742. //仓库所属创客编号
  743. if (!string.IsNullOrEmpty(StoreMakerCode))
  744. {
  745. var userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == StoreMakerCode) ?? new UserForMakerCode();
  746. var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
  747. var store = db.StoreHouse.Where(m => m.UserId == user.Id && m.Status > -1).ToList();
  748. var storeIds = "";
  749. foreach (var item in store)
  750. {
  751. storeIds += item.Id + ",";
  752. }
  753. storeIds = storeIds.TrimEnd(',');
  754. condition += " and StoreId in (" + storeIds + ")";
  755. }
  756. //品牌
  757. if (!string.IsNullOrEmpty(BrandId))
  758. {
  759. condition += " and BrandId =" + BrandId;
  760. }
  761. if (!string.IsNullOrEmpty(PosSn))
  762. {
  763. condition += " and PosSn =" + PosSn + "";
  764. }
  765. // if (!string.IsNullOrEmpty(AmountYk))
  766. // {
  767. // condition += " and BrandId =" + BrandId;
  768. // }
  769. // if (!string.IsNullOrEmpty(Amountk))
  770. // {
  771. // condition += " and BrandId =" + BrandId;
  772. // }
  773. // if (!string.IsNullOrEmpty(AmountDk))
  774. // {
  775. // condition += " and BrandId =" + BrandId;
  776. // }
  777. if (!string.IsNullOrEmpty(RecycEndDateData))
  778. {
  779. string[] datelist = RecycEndDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  780. string start = datelist[0];
  781. string end = datelist[1];
  782. condition += " and RecycEndDate>='" + start + " 00:00:00' and RecycEndDate<='" + end + " 23:59:59'";
  783. }
  784. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", Fields, "Id desc", "0", page, limit, condition);
  785. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  786. foreach (Dictionary<string, object> dic in diclist)
  787. {
  788. //绑定状态
  789. int BindingState = int.Parse(dic["BindingState"].ToString());
  790. if (BindingState == 0) dic["BindingState"] = "未绑定";
  791. if (BindingState == 1) dic["BindingState"] = "已绑定";
  792. //激活状态
  793. int ActivationState = int.Parse(dic["ActivationState"].ToString());
  794. if (ActivationState == 0) dic["ActivationState"] = "未激活";
  795. if (ActivationState == 1) dic["ActivationState"] = "已激活";
  796. //所属创客
  797. int BuyUserId = int.Parse(function.CheckInt(dic["BuyUserId"].ToString()));
  798. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == BuyUserId) ?? new Users();
  799. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  800. dic["UserIdRealName"] = userid_Users.RealName;
  801. dic.Remove("BuyUserId");
  802. //所属仓库
  803. int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
  804. StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
  805. dic["StoreIdCode"] = storeid_StoreHouse.StoreNo;
  806. dic["StoreIdName"] = storeid_StoreHouse.StoreName;
  807. dic.Remove("StoreId");
  808. //产品类型
  809. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  810. decimal ScanQrTrade = decimal.Parse(dic["ScanQrTrade"].ToString());
  811. var brandInfo = dic["BrandId"].ToString();
  812. decimal amount = 0;
  813. if (brandInfo.Contains("电签"))
  814. {
  815. amount = 200;
  816. }
  817. if (brandInfo.Contains("大POS"))
  818. {
  819. amount = 300;
  820. }
  821. if (ScanQrTrade > 0 && ScanQrTrade < 999)
  822. {
  823. dic["AmountYk"] = amount;
  824. dic["Amountk"] = ScanQrTrade;
  825. dic["AmountDk"] = amount - ScanQrTrade;
  826. // AmountYks += ScanQrTrade;
  827. // AmountDks += amount - ScanQrTrade;
  828. }
  829. if (ScanQrTrade == 999)
  830. {
  831. dic["AmountYk"] = amount;
  832. dic["Amountk"] = amount;
  833. dic["AmountDk"] = 0;
  834. // AmountYks += amount;
  835. }
  836. //参加活动
  837. dic["ActivityList"] = RelationClass.GetProfitObjectsActivesList(dic["ActivityList"].ToString());
  838. //绑定商户
  839. int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
  840. PosMerchantInfo bindmerchantid_MerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new PosMerchantInfo();
  841. dic["BindMerchantIdMerchantNo"] = bindmerchantid_MerchantInfo.MerchantNo;
  842. dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.MerchantName;
  843. dic.Remove("BindMerchantId");
  844. //机具类型
  845. int PosSnType = int.Parse(dic["PosSnType"].ToString());
  846. if (PosSnType == 0) dic["PosSnType"] = "兑换机具";
  847. if (PosSnType == 1) dic["PosSnType"] = "循环机具";
  848. //设备类型
  849. string DeviceType = dic["DeviceType"].ToString();
  850. if (DeviceType == "KysSignPos") dic["DeviceType"] = "快益刷电签POS";
  851. if (DeviceType == "KssSignPos") dic["DeviceType"] = "快闪刷电签POS";
  852. if (DeviceType == "") dic["DeviceType"] = "";
  853. //盟主信息
  854. int LeaderUserId = int.Parse(function.CheckInt(dic["LeaderUserId"].ToString()));
  855. if (LeaderUserId != 0)
  856. {
  857. Users users = db.Users.FirstOrDefault(m => m.Id == LeaderUserId) ?? new Users();
  858. dic["UserInfo"] = users.MakerCode + "_" + users.RealName;
  859. }
  860. //是否为第一台机具
  861. int IsFirst = int.Parse(dic["IsFirst"].ToString());
  862. if (IsFirst == 0) dic["IsFirst"] = "否";
  863. if (IsFirst == 1) dic["IsFirst"] = "是";
  864. //循环开始时间
  865. // if (!string.IsNullOrEmpty(dic["RecycEndDate"].ToString()))
  866. // {
  867. // // var RecycStartDate = Convert.ToDateTime(dic["RecycEndDate"].ToString()).AddDays(-360).ToString("yyyy-MM-dd HH:mm:ss");
  868. // // dic["RecycStartDate"] = RecycStartDate;
  869. // string PosSn = dic["PosSn"].ToString();
  870. // bool op = db.StoreChangeHistory.Any(m => m.SnNo == PosSn && m.TransType == 2);
  871. // if(op)
  872. // {
  873. // StoreChangeHistory item = db.StoreChangeHistory.FirstOrDefault(m => m.SnNo == PosSn && m.TransType == 2) ?? new StoreChangeHistory();
  874. // dic["RecycStartDate"] = item.ToDate == null ? "" : item.ToDate.Value.ToString("yyyy-MM-dd");
  875. // }
  876. // }
  877. //实际押金
  878. string SeoKeyword = dic["SeoKeyword"].ToString();
  879. if (SeoKeyword.Length > 2)
  880. {
  881. SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
  882. }
  883. dic["SeoKeyword"] = SeoKeyword;
  884. //设置押金
  885. string PrizeParams = dic["PrizeParams"].ToString();
  886. dic["PrizeParams"] = PrizeParams;
  887. //所属运营中心
  888. int OpId = int.Parse(dic["OpId"].ToString());
  889. if (OpId != 0)
  890. {
  891. var sys = opdb.SysAdmin.FirstOrDefault(m => m.QueryCount > 0 && m.UserId == OpId) ?? new OpModels.SysAdmin();
  892. dic["OpCode"] = sys.OpCode;
  893. }
  894. }
  895. Dictionary<string, object> other = new Dictionary<string, object>();
  896. int TotalCount = 0;//总机具数
  897. DataTable dt = OtherMySqlConn.dtable("select count(0) from PosMachinesTwo where 1=1" + condition);
  898. if (dt.Rows.Count > 0)
  899. {
  900. TotalCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
  901. }
  902. DataTable dts = OtherMySqlConn.dtable("select Id from PosMachinesTwo where 1=1" + condition);
  903. var Ids = "";
  904. foreach (DataRow item in dts.Rows)
  905. {
  906. Ids += item["Id"].ToString() + ",";
  907. }
  908. var Id = "," + Ids;
  909. var pos = db.PosMachinesTwo.Where(m => Id.Contains("," + m.Id + ",")).ToList();
  910. string[] strids = Ids.TrimEnd(',').Split(',');
  911. foreach (var items in strids)
  912. {
  913. int posId = int.Parse(items);
  914. var posInfo = pos.FirstOrDefault(m => m.Id == posId) ?? new PosMachinesTwo();
  915. decimal ScanQrTrade = decimal.Parse(posInfo.ScanQrTrade.ToString());
  916. var brandInfo = RelationClass.GetKqProductBrandInfo(int.Parse(posInfo.BrandId.ToString()));
  917. decimal amount = 0;
  918. if (brandInfo.Contains("电签"))
  919. {
  920. amount = 200;
  921. }
  922. if (brandInfo.Contains("大POS"))
  923. {
  924. amount = 300;
  925. }
  926. if (ScanQrTrade > 0 && ScanQrTrade < 999)
  927. {
  928. AmountYks += ScanQrTrade;
  929. AmountDks += amount - ScanQrTrade;
  930. }
  931. if (ScanQrTrade == 999)
  932. {
  933. AmountYks += amount;
  934. }
  935. }
  936. other.Add("TotalCount", TotalCount);
  937. other.Add("AmountYks", AmountYks);
  938. other.Add("AmountDks", AmountDks);
  939. obj.Add("other", other);
  940. return Json(obj);
  941. }
  942. #endregion
  943. }
  944. }