| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- /*
- * 直营团队提现记录
- */
- 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 UserCashRecordForBusinessController : BaseController
- {
- public UserCashRecordForBusinessController(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(UserCashRecordForBusiness data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- string Condition = "";
- Condition += "CashOrderNo:\"" + data.CashOrderNo + "\",";
- Condition += "TradeType:\"" + data.TradeType + "\",";
- if (!string.IsNullOrEmpty(Condition))
- {
- Condition = Condition.TrimEnd(',');
- Condition = ", where: {" + Condition + "}";
- }
- ViewBag.Condition = Condition;
- return View();
- }
- #endregion
- #region 根据条件查询提现记录列表
- /// <summary>
- /// 提现记录列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(UserCashRecordForBusiness data, string MakerCode, string RealName, string StatusSelect, string QueryCountSelect, string CreateDateData, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("CashOrderNo", "1"); //提现单号
- Fields.Add("TradeType", "0"); //交易类型
- string condition = " and Status>-1 and TradeType<3";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
- }
- //创客名称
- if (!string.IsNullOrEmpty(RealName))
- {
- condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
- }
- //提现状态
- if (!string.IsNullOrEmpty(StatusSelect))
- {
- condition += " and Status=" + StatusSelect;
- }
- if (!string.IsNullOrEmpty(data.CashOrderNo))
- {
- condition += " and CashOrderNo='" + data.CashOrderNo + "'";
- }
- if (data.TradeType > 0)
- {
- condition += " and TradeType=" + data.TradeType;
- }
- //提交到代付状态
- if (!string.IsNullOrEmpty(QueryCountSelect))
- {
- if(QueryCountSelect == "0")
- {
- condition += " and QueryCount=" + QueryCountSelect;
- }
- else
- {
- condition += " and QueryCount>0";
- }
- }
- if (!string.IsNullOrEmpty(CreateDateData))
- {
- string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
- var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
- var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
- var check = db.UserCashRecord.Any(m => m.CreateDate >= start && m.TradeType < 3);
- var checks = db.UserCashRecord.Any(m => m.CreateDate <= end && m.TradeType < 3);
- if (check)
- {
- var sId = db.UserCashRecord.Where(m => m.CreateDate >= start && m.TradeType < 3).Min(m => m.Id);
- condition += " and Id >=" + sId;
- }
- if (checks)
- {
- var eId = db.UserCashRecord.Where(m => m.CreateDate <= end && m.TradeType < 3).Max(m => m.Id);
- condition += " and Id <=" + eId;
- }
- }
- else
- {
- var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
- var check = db.UserCashRecord.Any(m => m.CreateDate >= start && m.TradeType < 3);
- if (check)
- {
- var minId = db.UserCashRecord.Where(m => m.CreateDate >= start && m.TradeType < 3).Min(m => m.Id);
- var Info = function.ReadInstance("/WritePage/UserCashRecord/UserCashRecordForBusiness.txt");
- if (string.IsNullOrEmpty(Info.ToString()))
- {
- function.WritePage("/WritePage/UserCashRecord/", "UserCashRecordForBusiness.txt", minId.ToString());
- condition += " and Id >=" + minId;
- }
- else if (minId != int.Parse(Info))
- {
- function.WritePage("/WritePage/UserCashRecord/", "UserCashRecordForBusiness.txt", minId.ToString());
- condition += " and Id >=" + minId;
- }
- else
- {
- condition += " and Id >=" + Convert.ToInt32(Info);
- }
- }
- else
- {
- condition += " and Id =0";
- }
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserCashRecordForBusiness", 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(dic["UserId"].ToString());
- Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["MakerCode"] = user.MakerCode;
- dic["RealName"] = user.RealName;
- dic["TradeType"] = RelationClassForConst.GetTradeTypeInfo(int.Parse(dic["TradeType"].ToString()));
- int Status = int.Parse(dic["Status"].ToString());
- if (Status == 0) dic["StatusName"] = "处理中";
- if (Status == 1) dic["StatusName"] = "成功";
- if (Status == 2) dic["StatusName"] = "失败";
- int QueryCount = int.Parse(dic["QueryCount"].ToString());
- if (QueryCount == 0) dic["LockName"] = "待提交";
- if (QueryCount > 0) dic["LockName"] = "已提交";
- }
- 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(UserCashRecordForBusiness data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Remark", data.Remark); //备注
- Fields.Add("SeoTitle", data.SeoTitle);
- Fields.Add("SeoKeyword", data.SeoKeyword);
- Fields.Add("SeoDescription", data.SeoDescription);
- int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("UserCashRecordForBusiness", Fields, 0);
- AddSysLog(data.Id.ToString(), "UserCashRecordForBusiness", "add");
- db.SaveChanges();
- return "success";
- }
- #endregion
- }
- }
|