123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using Microsoft.AspNetCore.Authorization;
- using System.Web;
- using MySystem.MainModels;
- using LitJson;
- using Library;
- namespace MySystem.Areas.Api.Controllers.v1
- {
- [Area("Api")]
- [Route("Api/v1/[controller]/[action]")]
- public class LisController : BaseController
- {
- public LisController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- }
- #region 立刷-获取押金列表
- [Authorize]
- public JsonResult GetDepositList(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> dataList = GetDepositListDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
- }
- public List<Dictionary<string, object>> GetDepositListDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- Dictionary<string, object> row = new Dictionary<string, object>();
- row.Add("Id", "0");
- row.Add("Name", "押0");
- dataList.Add(row);
- row = new Dictionary<string, object>();
- row.Add("Id", "99");
- row.Add("Name", "押99");
- dataList.Add(row);
- row = new Dictionary<string, object>();
- row.Add("Id", "199");
- row.Add("Name", "押199");
- dataList.Add(row);
- row = new Dictionary<string, object>();
- row.Add("Id", "249");
- row.Add("Name", "押249");
- dataList.Add(row);
- return dataList;
- }
- #endregion
- #region 立刷-设置押金
- [Authorize]
- public JsonResult SetDeposit(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
- string SnIds = data["SnIds"].ToString(); //机具Id列表
- string check = RedisDbconn.Instance.Get<string>("SetLisDepositWait:" + UserId);
- if (!string.IsNullOrEmpty(check))
- {
- return Json(new AppResultJson() { Status = "-1", Info = "操作频繁,请稍后再试" });
- }
- RedisDbconn.Instance.Set("SetLisDepositWait:" + UserId, SnIds);
- RedisDbconn.Instance.SetExpire("SetLisDepositWait:" + UserId, 120);
- string DepositId = data["DepositId"].ToString(); //押金Id
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- string[] SnIdList = SnIds.Split(',');
- foreach (string SnId in SnIdList)
- {
- int SnIdNum = int.Parse(SnId);
- PosMachinesTwo pos = maindb.PosMachinesTwo.FirstOrDefault(m => m.Id == SnIdNum && m.UserId == UserId && m.BindingState == 0 && (string.IsNullOrEmpty(m.SeoKeyword) || m.SeoKeyword == "0"));
- if (pos == null)
- {
- return Json(new AppResultJson() { Status = "-1", Info = "机具" + pos.PosSn + "已设置押金,请勿重复设置" });
- }
- function.WriteLog(DateTime.Now.ToString() + ":请求参数," + pos.PosSn + ":" + DepositId, "立刷-设置押金-返回报文");
- string content = PublicImportDataService.Instance.SetLiSDeposit(pos.PosSn, int.Parse(DepositId));
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "立刷-设置押金-返回报文");
- JsonData jsonObj = JsonMapper.ToObject(content);
- if (jsonObj["ret_code"].ToString() != "00")
- {
- return Json(new AppResultJson() { Status = "-1", Info = jsonObj["ret_msg"].ToString() });
- }
- function.WriteLog(DateTime.Now.ToString() + "\n" + content, "立刷-设置押金-返回报文");
- var BeforeDeposit = 0;
- if (string.IsNullOrEmpty(pos.PrizeParams))
- {
- if (RelationClass.GetKqProductBrandInfo(pos.BrandId) == "立刷云电签")
- {
- BeforeDeposit = 249;
- }
- else
- {
- BeforeDeposit = 299;
- }
- }
- else
- {
- BeforeDeposit = int.Parse(pos.PrizeParams);
- }
- pos.PrizeParams = DepositId;
- maindb.SaveChanges();
- //设置押金添加记录
- PublicFunction.MerchantDepositSet(pos.BrandId, UserId, SnIdNum, pos.PosSn, BeforeDeposit, decimal.Parse(pos.PrizeParams), content);
- }
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- #endregion
- #region 检查签名是否合法,合法返回1,不合法返回提示信息
- /// <summary>
- /// 检查签名是否合法,合法返回1,不合法返回提示信息
- /// </summary>
- /// <param name="value">请求的参数(json字符串)</param>
- /// <param name="signField">要签名的字段</param>
- /// <returns></returns>
- private string CheckSign(string value, string[] signField)
- {
- JsonData json = JsonMapper.ToObject(value);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- for (int i = 0; i < signField.Length; i++)
- {
- dic.Add(signField[i], json[signField[i]].ToString());
- }
- string sign = json["sign"].ToString(); //客户端签名字符串
- return new Sign().sign(dic, sign);
- }
- #endregion
- }
- }
|