| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- /*
- * 盟主兑换机具券
- */
- using System;
- using System.Web;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- 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 LeaderReserveRecordController : BaseController
- {
- public LeaderReserveRecordController(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(LeaderReserveRecord data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询盟主兑换机具券列表
- /// <summary>
- /// 根据条件查询盟主兑换机具券列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(LeaderReserveRecord data, string UserIdMakerCode, string SourceMakerCode, string RemarkSelect, string CreateDateData, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("SeoKeyword", "1"); //订单编号
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(UserIdMakerCode))
- {
- condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
- }
- //购券创客
- if (!string.IsNullOrEmpty(SourceMakerCode))
- {
- condition += " and SourceUserId in (select UserId from UserForMakerCode where MakerCode='" + SourceMakerCode + "')";
- }
- //变动类型
- if (!string.IsNullOrEmpty(RemarkSelect))
- {
- condition += " and Remark='" + RemarkSelect + "'";
- }
- //创建时间
- if (!string.IsNullOrEmpty(CreateDateData))
- {
- string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("LeaderReserveRecord", Fields, "Id desc", "0", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //创客
- int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
- Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- UserAccount userAccount = db.UserAccount.FirstOrDefault(m => m.Id == UserId) ?? new UserAccount();
- dic["LeaderBalanceAmount"] = userAccount.LeaderBalanceAmount;
- dic["UserIdMakerCode"] = userid_Users.MakerCode;
- dic["UserIdRealName"] = userid_Users.RealName;
- dic.Remove("UserId");
- //购券创客
- int SourceUserId = int.Parse(function.CheckInt(dic["SourceUserId"].ToString()));
- if (SourceUserId > 0)
- {
- Users sourceUser = db.Users.FirstOrDefault(m => m.Id == SourceUserId) ?? new Users();
- dic["SourceMakerCode"] = sourceUser.MakerCode;
- dic.Remove("SourceUserId");
- }
- // else
- // {
- // int OrderId = int.Parse(function.CheckInt(dic["OrderId"].ToString()));
- // var order = db.Orders.FirstOrDefault(m => m.Id == OrderId) ?? new Orders();
- // Users sourceUser = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
- // dic["SourceMakerCode"] = sourceUser.MakerCode;
- // dic.Remove("OrderId");
- // }
- // //购券创客
- // int SourceUserId = int.Parse(function.CheckInt(dic["SourceUserId"].ToString()));
- // Users sourceUser = db.Users.FirstOrDefault(m => m.Id == SourceUserId) ?? new Users();
- // dic["SourceMakerCode"] = sourceUser.MakerCode;
- // dic.Remove("SourceUserId");
- // //订单来源创客
- // int OrderId = int.Parse(function.CheckInt(dic["OrderId"].ToString()));
- // var order = db.Orders.FirstOrDefault(m => m.Id == OrderId) ?? new Orders();
- // Users sourceOrderUser = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
- // dic["SourceOrderMakerCode"] = sourceOrderUser.MakerCode;
- // dic.Remove("OrderId");
- //订单信息
- JsonData ApplyList = JsonMapper.ToObject(dic["SeoTitle"].ToString());//申请数据
- dic["dPosCoupons"] = "";
- dic["bPosCoupons"] = "";
- if (!string.IsNullOrEmpty(dic["SeoTitle"].ToString()))
- {
- for (int i = 0; i < ApplyList.Count; i++)
- {
- int num = Convert.ToInt32(ApplyList[i]["Num"].ToString());
- int type = Convert.ToInt32(ApplyList[i]["Type"].ToString());
- if (type == 1)
- {
- dic["dPosCoupons"] = num + "张";
- }
- else
- {
- dic["bPosCoupons"] = num + "张";
- }
- }
- }
- }
- return Json(obj);
- }
- #endregion
- }
- }
|