123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- 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 UserAccountController : BaseController
- {
- public UserAccountController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- }
- #region 创客-我的-账户信息
- [Authorize]
- public JsonResult MyAccount(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = MyAccountDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- public Dictionary<string, object> MyAccountDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- UserAccount query = UserAccountDbconn.Instance.Get(UserId) ?? new UserAccount();
- Obj.Add("TotalAmount", query.TotalAmount);
- Obj.Add("BalanceAmount", query.BalanceAmount);
- Obj.Add("ToChargeAmount", query.ToChargeAmount);
- Obj.Add("WithdrawAmount", query.WithdrawAmount);
- Obj.Add("LeaderReserve", query.LeaderReserve);
- Obj.Add("WithdrawFlag", query.QueryCount);
- Obj.Add("SmallStoreDeposit", query.SmallStoreDeposit);
- return Obj;
- }
- #endregion
- #region 创客-首页-统计数据
- [Authorize]
- public JsonResult MyStatData(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = MyStatDataDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- public Dictionary<string, object> MyStatDataDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
- string TradeMonth = DateTime.Now.ToString("yyyyMM");
-
-
-
-
- return Obj;
- }
- #endregion
- #region 创客-首页-仓库管理-申请机具-我的额度
- [Authorize]
- public JsonResult MyAmount(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = MyAmountDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- public Dictionary<string, object> MyAmountDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- List<Dictionary<string, object>> listStoreHouse = new List<Dictionary<string, object>>();
- UserAccount query = maindb.UserAccount.FirstOrDefault(m => m.Id == UserId) ?? new UserAccount();
- var check = maindb.StoreHouseAmountPromiss.Any(m => m.ToUserId == UserId);
- decimal amount = 0;
- if (check)
- {
- amount = maindb.StoreHouseAmountPromiss.Where(m => m.Status == 1 && m.ToUserId == UserId).Sum(m => m.PromissAmount);
- }
- Obj.Add("Amount", query.ValidAmount);
- Obj.Add("TotalAmount", query.FixedAmount + query.TempAmount + query.TempAmountForBalance);
- Obj.Add("FixedAmount", query.FixedAmount);
- Obj.Add("TempAmount", query.TempAmount + query.TempAmountForBalance);
- Obj.Add("LeaderBalanceAmount", amount);
- var a = query.ValidAmount - amount;
- if (query.ValidAmount - amount >= query.TempAmount + query.TempAmountForBalance)
- {
- Obj.Add("OkTempAmount", query.TempAmount + query.TempAmountForBalance);
- Obj.Add("cardLeast", query.TempAmount);
- Obj.Add("balanceLeast", query.TempAmountForBalance);
- }
- else if (query.ValidAmount - amount <= 0)
- {
- Obj.Add("OkTempAmount", 0);
- Obj.Add("cardLeast", 0);
- Obj.Add("balanceLeast", 0);
- }
- else if (0 < query.ValidAmount - amount && query.ValidAmount - amount < query.TempAmount + query.TempAmountForBalance)
- {
- Obj.Add("OkTempAmount", query.ValidAmount - amount);
- if (query.ValidAmount - amount <= query.TempAmount)
- {
- Obj.Add("cardLeast", query.ValidAmount - amount);
- }
- if (query.ValidAmount - amount > query.TempAmount)
- {
- Obj.Add("cardLeast", query.TempAmount);
- }
- if ( query.ValidAmount - amount <= query.TempAmountForBalance)
- {
- Obj.Add("balanceLeast", query.ValidAmount - amount);
- }
- if ( query.ValidAmount - amount > query.TempAmountForBalance)
- {
- Obj.Add("balanceLeast", query.TempAmountForBalance);
- }
- }
- return Obj;
- }
- #endregion
- #region 检查签名是否合法,合法返回1,不合法返回提示信息
-
-
-
-
-
-
- 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
- }
- }
|