lcl пре 1 година
родитељ
комит
25186e4b77

BIN
AppStart/.DS_Store


BIN
AppStart/Alipay/.DS_Store


BIN
AppStart/Redis/.DS_Store


BIN
Areas/Api/.DS_Store


BIN
Areas/Api/Controllers/.DS_Store


BIN
Areas/Api/Controllers/v1/.DS_Store


+ 138 - 0
Areas/Api/Controllers/v1/MainServer/BusinessController.cs

@@ -0,0 +1,138 @@
+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;
+using System.Data;
+
+namespace MySystem.Areas.Api.Controllers.v1
+{
+    [Area("Api")]
+    [Route("/v1/[controller]/[action]")]
+    public class BusinessController : BaseController
+    {
+        public BusinessController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
+        {
+        }
+
+        #region 经营数据-经营数据记录(月)
+        // [Authorize]
+        public JsonResult BussinessRecordForMonth(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            List<Dictionary<string, object>> dataList = BussinessRecordForMonthDo(value);
+            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
+        }
+        private List<Dictionary<string, object>> BussinessRecordForMonthDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
+            string TradeMonth = data["TradeMonth"].ToString(); //月份
+            int pageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
+            int pageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
+
+            var dataList = BusinessUtil.BussinessRecordForMonth(MerchantId, TradeMonth, pageSize, pageNum);
+            return dataList;
+        }
+        #endregion
+
+
+
+        #region 经营数据-经营数据记录(半年)
+        // [Authorize]
+        public JsonResult BussinessRecordForHalfYear(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            List<Dictionary<string, object>> dataList = BussinessRecordForHalfYearDo(value);
+            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
+        }
+        private List<Dictionary<string, object>> BussinessRecordForHalfYearDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
+            int pageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
+            int pageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
+
+            var dataList = BusinessUtil.BussinessRecordForHalfYear(MerchantId, pageSize, pageNum);
+            return dataList;
+        }
+        #endregion
+
+
+
+        #region 经营数据-经营数据记录-经营详情列表
+        // [Authorize]
+        public JsonResult DayDetailList(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            List<Dictionary<string, object>> dataList = DayDetailListDo(value);
+            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
+        }
+        private List<Dictionary<string, object>> DayDetailListDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
+            string TradeDate = data["TradeDate"].ToString(); //日期
+            int pageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
+            int pageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
+            string condition = " and Status>=1";
+            if (!string.IsNullOrEmpty(data["MerchantId"].ToString()))
+            {
+                condition += " and MerchantId=" + MerchantId;
+            }
+            if (!string.IsNullOrEmpty(data["TradeDate"].ToString()))
+            {
+                var start = TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2) + " 00:00:00";
+                var end = TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2) + " 23:59:59";
+                condition += " and CreateDate>='" + start + "' and CreateDate<='" + end + "'";
+            }
+
+            var dataList = BusinessUtil.DayDetailList(condition, pageSize, pageNum);
+            return dataList;
+        }
+        #endregion
+
+
+
+        #region 经营数据-经营数据记录-交易详情
+        // [Authorize]
+        public JsonResult OrderDetail(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            Dictionary<string, object> dataList = OrderDetailDo(value);
+            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
+        }
+        private Dictionary<string, object> OrderDetailDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
+            int OrderId = int.Parse(function.CheckInt(data["OrderId"].ToString())); //订单Id
+            string condition = " and Status>=1";
+            if (!string.IsNullOrEmpty(data["OrderId"].ToString()))
+            {
+                condition += " and OrderId=" + OrderId;
+            }
+            if (!string.IsNullOrEmpty(data["MerchantId"].ToString()))
+            {
+                condition += " and MerchantId=" + MerchantId;
+            }
+
+            var obj = BusinessUtil.OrderDetail(condition);
+            return obj;
+        }
+        #endregion
+
+
+    }
+}

+ 41 - 0
Areas/Api/Controllers/v1/MainServer/ConsumerOrdersController.cs

@@ -98,6 +98,47 @@ namespace MySystem.Areas.Api.Controllers.v1
 
 
 
+        #region 商户-经营数据-按月
+        [Authorize]
+        public JsonResult BussinessRecordForMonth(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            List<Dictionary<string, object>> dataList = BussinessRecordForMonthDo(value);
+            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
+        }
+        public List<Dictionary<string, object>> BussinessRecordForMonthDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户
+            string Month = data["Month"].ToString(); //月份
+            int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
+            int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
+            List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
+            DataTable dt = MerchantAmountSummary.Instance.GetTradeListByDate(MerchantId, Month, PageNum, PageSize);
+            foreach (DataRow dr in dt.Rows)
+            {
+                string TradeDate = dr["TradeDate"].ToString();
+                Dictionary<string, object> curData = new Dictionary<string, object>();
+                curData.Add("Date", TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2)); //日期
+                curData.Add("TotalAmount", dr[5].ToString()); //营收金额
+                curData.Add("TotalActual", dr[3].ToString()); //实收金额
+                curData.Add("WeChatAmount", dr[2].ToString()); //微信实收
+                curData.Add("AlipayAmount", dr[1].ToString()); //支付宝实收
+                curData.Add("OrderCount", dr[4].ToString()); //订单数
+                curData.Add("AddCount", 0); //新增会员
+                dataList.Add(curData);
+            }
+            return dataList;
+        }
+        #endregion
+
+
+
+        
+
+
+
         #region 商户-订单列表
         [Authorize]
         public JsonResult ForMer(string value)

+ 5 - 2
Areas/Api/Controllers/v1/MainServer/MerchantInfoController.cs

@@ -443,7 +443,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                 curData.Add("Name", subdata.Name); //名称
                 curData.Add("Id", subdata.Id); //Id
                 curData.Add("CreateDate", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //CreateDate
-                curData.Add("Status", GetStatusName(AddInfo.Status)); //Status
+                curData.Add("Status", AddInfo.Status); //Status
                 curData.Add("MainType", AddInfo.SubjectType); //主体类型
                 dataList.Add(curData);
             }
@@ -564,6 +564,7 @@ namespace MySystem.Areas.Api.Controllers.v1
 
         #region 商户-主界面统计数据
         [Authorize]
+        [Route("/v1/workspace/indexstat")]
         public JsonResult IndexStat(string value)
         {
             value = DesDecrypt(value);
@@ -576,7 +577,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             JsonData data = JsonMapper.ToObject(value);
             string TimeType = data["TimeType"].ToString(); //时间范围
             Dictionary<string, object> Obj = new Dictionary<string, object>();
-            int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
+            int Id = int.Parse(function.CheckInt(data["MerchantId"].ToString()));
             decimal TotalAmount = 0;
             decimal TotalOrder = 0;
             int TotalUser = 0;
@@ -607,6 +608,8 @@ namespace MySystem.Areas.Api.Controllers.v1
             Obj.Add("TotalOrder", TotalOrder); //累计订单
             Obj.Add("TotalUser", TotalUser); //会员数
             Obj.Add("TotalActual", TotalActual); //实收总额
+            Obj.Add("AllocationAmount", 0); //未分配活动金额 // TODO:需要统计
+
             return Obj;
         }
         #endregion

+ 2 - 0
Config/Base.cs

@@ -12,8 +12,10 @@ namespace AppConfig
         public static string defaultImage = Library.ConfigurationManager.AppSettings["Host"].ToString() + "/skin/app/default/static/images/default.jpg";
         
         public static string SqlConnStr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
+        public static string StatConnRds = Library.ConfigurationManager.AppSettings["StatSqlConnStr"].ToString();
         #region 数据库结构
         public static Dictionary<string, Dictionary<string, string>> mainTables = new Dictionary<string, Dictionary<string, string>>();
+        public static Dictionary<string, Dictionary<string, string>> statTables = new Dictionary<string, Dictionary<string, string>>();
         public static Dictionary<string, Dictionary<string, string>> bsTables = new Dictionary<string, Dictionary<string, string>>();
 
         #endregion

+ 159 - 0
Services/MerchantTradeSummaryService.cs

@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MySystem.MainModels;
+using Library;
+using LitJson;
+using System.Data;
+
+namespace MySystem
+{
+    public class MerchantTradeSummaryService
+    {
+        string _conn = "";
+        public MerchantTradeSummaryService()
+        {
+            _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
+        }
+
+        /// <summary>
+        /// 查询列表
+        /// </summary>
+        /// <param name="fields">查询条件(单个字段)</param>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <param name="page">页码</param>
+        /// <param name="limit">每页条数</param>
+        /// <returns></returns>
+        public List<Dictionary<string, object>> List(List<FieldItem> fields, string condition, string TradeMonth, int page = 1, int limit = 30, string orderby = "Id desc")
+        {
+            Dictionary<string, object> obj = new DbService(AppConfig.Base.statTables, _conn).IndexData("MerchantTradeSummary" + TradeMonth, fields, orderby, "0", page, limit, condition);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            return diclist;
+        }
+        public List<Dictionary<string, object>> List2(List<FieldItem> fields, string condition, string TradeMonth, int page = 1, int limit = 30, string orderby = "Id desc")
+        {
+            Dictionary<string, object> obj = new DbService(AppConfig.Base.statTables, AppConfig.Base.StatConnRds).IndexData("MerchantTradeSummaryList" + TradeMonth, fields, orderby, "0", page, limit, condition);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            return diclist;
+        }
+
+        /// <summary>
+        /// 查询一条记录
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <returns></returns>
+        public MerchantTradeSummary Query(int MerchantId, string TradeDate)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantTradeSummary editData = db.MerchantTradeSummary.FirstOrDefault(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate) ?? new MerchantTradeSummary();
+            db.Dispose();
+            return editData;
+        }
+        public Dictionary<string, string> Sum(string field, string condition)
+        {
+            Dictionary<string, string> result = new Dictionary<string, string>();
+            string sumString = "";
+            string[] fieldlist = field.Split(',');
+            foreach(string f in fieldlist)
+            {
+                sumString += "sum(" + f + ") " + f + ",";
+            }
+            sumString = sumString.TrimEnd(',');
+            DataTable dt = CustomerSqlConn.dtable("select " + sumString + " from MerchantTradeSummary where 1=1" + condition, _conn);
+            if(dt.Rows.Count > 0)
+            {
+                foreach(string f in fieldlist)
+                {
+                    result.Add(f, function.CheckNum(dt.Rows[0][f].ToString()));
+                }
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 添加数据
+        /// </summary>
+        /// <param name="Fields">要设置的字段</param>
+        /// <returns></returns>
+        public int Add(Dictionary<string, object> Fields)
+        {
+            return new DbService(AppConfig.Base.statTables, _conn).Add("MerchantTradeSummary", Fields, 0);
+        }
+
+        /// <summary>
+        /// 修改数据
+        /// </summary>
+        /// <param name="Fields">要设置的字段</param>
+        /// <param name="Id">主键Id</param>
+        public void Edit(Dictionary<string, object> Fields, int Id)
+        {
+            new DbService(AppConfig.Base.statTables, _conn).Edit("MerchantTradeSummary", Fields, Id);
+        }
+
+        /// <summary>
+        /// 删除数据
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        public void Delete(int Id)
+        {
+            new DbService(AppConfig.Base.statTables, _conn).Delete("MerchantTradeSummary", Id);
+        }
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <param name="Sort">排序序号</param>
+        public void Sort(int Id, int Sort)
+        {
+            new DbService(AppConfig.Base.statTables, _conn).Sort("MerchantTradeSummary", Sort, Id);
+        }
+
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData">json数据</param>
+        public void Import(string ExcelData)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            JsonData list = JsonMapper.ToObject(ExcelData);
+            for (int i = 1; i < list.Count;i++ )
+            {
+                JsonData dr = list[i];
+                
+                db.MerchantTradeSummary.Add(new MerchantTradeSummary()
+                {
+                    CreateDate = DateTime.Now,
+                    UpdateDate = DateTime.Now,
+                    
+                });
+                db.SaveChanges();
+            }
+            db.Dispose();
+        }
+
+        /// <summary>
+        /// 导出excel表格
+        /// </summary>
+        /// <param name="fields">查询条件(单个字段)</param>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <returns></returns>
+        public Dictionary<string, object> ExportExcel(List<FieldItem> fields, string condition, string orderby = "Id desc")
+        {
+            Dictionary<string, object> obj = new DbService(AppConfig.Base.statTables, _conn).IndexData("MerchantTradeSummary", fields, orderby, "0", 1, 20000, condition, "Id", false);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            foreach (Dictionary<string, object> dic in diclist)
+            {
+            }
+
+            Dictionary<string, object> result = new Dictionary<string, object>();
+            result.Add("Status", "1");
+            result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
+            result.Add("Obj", diclist);
+            Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
+
+            result.Add("Fields", ReturnFields);
+            return result;
+        }
+    }
+}

+ 24 - 0
Startup.cs

@@ -152,6 +152,7 @@ namespace MySystem
 
             
             InitMain();
+            InitStat();
             InitBs();
 
         }
@@ -179,6 +180,29 @@ namespace MySystem
             AppConfig.Base.mainTables = tables;
         }
 
+        private void InitStat()
+        {
+            Dictionary<string, Dictionary<string, string>> tables = new Dictionary<string, Dictionary<string, string>>();
+            string connstr = Configuration["Setting:StatSqlConnStr"];
+            System.Data.DataTable tablecollection = Library.CustomerSqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = 'QrCodePlateStatServer'", connstr);
+            foreach (System.Data.DataRow subtable in tablecollection.Rows)
+            {
+                Dictionary<string, string> Columns = new Dictionary<string, string>();
+                System.Data.DataTable columncollection = Library.CustomerSqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = 'QrCodePlateStatServer' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'", connstr);
+                foreach (System.Data.DataRow column in columncollection.Rows)
+                {
+                    string datatype = column["DATA_TYPE"].ToString();
+                    if (datatype == "decimal")
+                    {
+                        datatype = "numeric";
+                    }
+                    Columns.Add(column["COLUMN_NAME"].ToString(), datatype);
+                }
+                tables.Add(subtable["TABLE_NAME"].ToString(), Columns);
+            }
+            AppConfig.Base.statTables = tables;
+        }
+
         private void InitBs()
         {
             Dictionary<string, Dictionary<string, string>> tables = new Dictionary<string, Dictionary<string, string>>();

+ 139 - 0
Util/BusinessUtil.cs

@@ -0,0 +1,139 @@
+using MySystem.MainModels;
+using Library;
+using System.Collections.Generic;
+using System;
+
+namespace MySystem
+{
+    /// <summary>
+    /// 经营数据工具类
+    /// </summary>
+    public class BusinessUtil
+    {
+        
+        #region 经营数据记录(月)
+        /// <summary>
+        /// 经营数据记录(月)
+        /// </summary>
+        /// <param name="MerchantId">商户Id</param>
+        /// <param name="TradeMonth">月份</param>
+        /// <param name="pageSize">条数</param>
+        /// <param name="pageNum">页数</param>
+        /// <returns></returns>
+        public static List<Dictionary<string, object>> BussinessRecordForMonth(int MerchantId, string TradeMonth, int pageSize, int pageNum)
+        {
+            List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
+            List<Dictionary<string, object>> source = new MerchantTradeSummaryService().List2(new List<FieldItem>(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize);
+            // var infos = UserTradeDbconn.GetDateTradeList(MerchantId,TradeMonth);
+            foreach (Dictionary<string, object> subdata in source)
+            {
+                Dictionary<string, object> curData = new Dictionary<string, object>();
+                curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
+                curData.Add("TotalAmount", subdata["TotalAmount"].ToString()); //营业总金额
+                curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
+                curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
+                curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
+                curData.Add("WeChatInFactAmount", subdata["WeChatInFactAmount"].ToString()); //微信实收
+                curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
+                curData.Add("OrderCount", subdata["OrderCount"].ToString()); //订单数
+                dataList.Add(curData);
+            }
+            return dataList;
+        }
+        #endregion
+
+
+        #region 经营数据记录(半年)
+        /// <summary>
+        /// 经营数据记录(半年)
+        /// </summary>
+        /// <param name="MerchantId">商户Id</param>
+        /// <param name="pageSize">条数</param>
+        /// <param name="pageNum">页数</param>
+        /// <returns></returns>
+        public static List<Dictionary<string, object>> BussinessRecordForHalfYear(int MerchantId, int pageSize, int pageNum)
+        {
+            List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
+            List<Dictionary<string, object>> source = UserTradeDbconn.Instance.GetMonthTradeList(MerchantId, "TradeAmount,InFactAmount,ActAmount,NonActAmount,WeChatInFactAmount,AliPayInFactAmount,OderCount");
+            foreach (Dictionary<string, object> subdata in source)
+            {
+                Dictionary<string, object> curData = new Dictionary<string, object>();
+                curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
+                curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
+                curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
+                curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
+                curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
+                curData.Add("WeChatInFactAmount", subdata["WeChatInFactAmount"].ToString()); //微信实收
+                curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
+                curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
+                dataList.Add(curData);
+            }
+            return dataList;
+        }
+        #endregion
+
+
+        #region 经营详情列表
+        /// <summary>
+        /// 经营详情列表
+        /// </summary>
+        /// <param name="condition">查询条件</param>
+        /// <param name="pageSize">条数</param>
+        /// <param name="pageNum">页数</param>
+        /// <returns></returns>
+        public static List<Dictionary<string, object>> DayDetailList(string condition, int pageSize, int pageNum)
+        {
+            List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
+            List<Dictionary<string, object>> source = new ConsumerOrdersService().List(new List<FieldItem>(), condition, pageNum, pageSize);
+            foreach (Dictionary<string, object> subdata in source)
+            {
+                Dictionary<string, object> curData = new Dictionary<string, object>();
+                curData.Add("Id", subdata["Id"].ToString()); //订单Id
+                curData.Add("TradeDate", "支付时间" + " " + DateTime.Parse(subdata["CreateDate"].ToString()).ToString("HH:mm:ss")); //日期
+                curData.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 支付宝 2 微信)
+                curData.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
+                curData.Add("PayMoney", "+" + subdata["PayMoney"].ToString()); //订单金额
+                dataList.Add(curData);
+            }
+            return dataList;
+        }
+        #endregion
+
+
+        #region 交易详情
+        /// <summary>
+        /// 交易详情
+        /// </summary>
+        /// <param name="condition">查询条件</param>
+        /// <returns></returns>
+        public static Dictionary<string, object> OrderDetail(string condition)
+        {
+            Dictionary<string, object> obj = new Dictionary<string, object>();
+            List<Dictionary<string, object>> source = new ConsumerOrdersService().List(new List<FieldItem>(), condition, 1, 999);
+            foreach (Dictionary<string, object> subdata in source)
+            {
+                obj.Add("TradeDate", DateTime.Parse(subdata["CreateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //日期
+                obj.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 微信 2 支付宝)
+                obj.Add("PayMoney", subdata["PayMoney"].ToString()); //是否活动(1 是 0 否)
+                obj.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
+                obj.Add("OrderNo", subdata["OrderNo"].ToString()); //订单号
+                Dictionary<string, object> cdata = new Dictionary<string, object>();
+                List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
+                List<Dictionary<string, object>> dics = new ConsumerProfitService().List(new List<FieldItem>(), " and OrderId=" + int.Parse(subdata["Id"].ToString()) + "", 1, 999);
+                foreach (Dictionary<string, object> dic in dics)
+                {
+                    var CreateDate = DateTime.Parse(subdata["CreateDate"].ToString());
+                    var TradeDate = CreateDate.Month + "月" + CreateDate.Day + "日" + " " + CreateDate.ToString("HH:mm");
+                    cdata.Add("ProfitDate", TradeDate); //分红时间
+                    cdata.Add("ProfitAmount", "+" + dic["GetMoney"].ToString()); //分红金额
+                    dataList.Add(cdata);
+                }
+                obj.Add("ProfitTotalAmount", new ConsumerProfitService().Sum(" and OrderId=" + int.Parse(subdata["Id"].ToString()) + "", "GetMoney") + "(元)"); //分红总金额
+                obj.Add("ProfitList", dataList); //订单分红记录列表
+            }
+            return obj;
+        }
+        #endregion
+
+    }
+}

+ 102 - 0
Util/UserTradeDbconn.cs

@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using System.Data;
+
+namespace MySystem
+{
+    public class UserTradeDbconn
+    {
+        public readonly static UserTradeDbconn Instance = new UserTradeDbconn();
+        public UserTradeDbconn()
+        { }
+
+        /// <summary>
+        /// 获取交易统计数据
+        /// </summary>
+        /// <param name="MerchantId">商户Id</param>
+        /// <param name="TradeDate">日期/月份(yyyyMMdd或yyyyMM)</param>
+        /// <param name="fields">字段(多个用逗号隔开)</param>
+        /// <returns></returns>
+        public Dictionary<string, object> GetTrade(int MerchantId, string TradeDate, string fields)
+        {
+            Dictionary<string, object> AmtList = new Dictionary<string, object>();
+            string fieldList = "";
+            foreach(string field in fields.Split(','))
+            {
+                fieldList += "sum(" + fieldList + ") " + fieldList + ",";
+            }
+            DataTable dt = CustomerSqlConn.dtable("select " + fieldList.TrimEnd(',') + " from MerchantTradeSummary" + TradeDate + " where MerchantId=" + MerchantId + " and ", AppConfig.Base.StatConnRds);
+            if(dt.Rows.Count > 0)
+            {
+                foreach(string field in fields.Split(','))
+                {
+                    AmtList.Add(field, dt.Rows[0][0].ToString());
+                }
+            }
+            return AmtList;
+        }
+
+        /// <summary>
+        /// 获取交易统计列表
+        /// </summary>
+        /// <param name="MerchantId">商户Id</param>
+        /// <param name="TradeMonth">月份(yyyyMM)</param>
+        /// <param name="fields">字段(多个用逗号隔开)</param>
+        /// <returns></returns>
+        public List<Dictionary<string, object>> GetDateTradeList(int MerchantId, string TradeMonth, string fields)
+        {
+            List<Dictionary<string, object>> AmtList = new List<Dictionary<string, object>>();
+            DataTable dt = CustomerSqlConn.dtable("select " + fields + " from MerchantTradeSummary" + TradeMonth + " where MerchantId=" + MerchantId + " and Trade", AppConfig.Base.StatConnRds);
+            if(dt.Rows.Count > 0)
+            {
+                Dictionary<string, object> Item = new Dictionary<string, object>();
+                foreach(string field in fields.Split(','))
+                {
+                    Item.Add(field, dt.Rows[0][0].ToString());
+                }
+                AmtList.Add(Item);
+            }
+            return AmtList;
+        }
+
+        /// <summary>
+        /// 获取交易统计列表
+        /// </summary>
+        /// <param name="MerchantId">商户Id</param>
+        /// <param name="TradeMonth">月份(yyyyMM)</param>
+        /// <param name="fields">字段(多个用逗号隔开)</param>
+        /// <returns></returns>
+        public List<Dictionary<string, object>> GetMonthTradeList(int MerchantId, string fields)
+        {
+            List<Dictionary<string, object>> AmtList = new List<Dictionary<string, object>>();
+            string fieldList = "";
+            foreach(string field in fields.Split(','))
+            {
+                fieldList += "sum(" + field + ") " + field + ",";
+            }
+            for(int i = 0; i < 6; i ++)
+            {
+                Dictionary<string, object> Item = new Dictionary<string, object>();
+                Item.Add("TradeDate", DateTime.Now.AddMonths(-i).ToString("yyyy-MM"));
+                DataTable dt = CustomerSqlConn.dtable("select " + fieldList.TrimEnd(',') + " from MerchantTradeSummary" + DateTime.Now.AddMonths(-i).ToString("yyyyMM") + " where MerchantId=" + MerchantId + "", AppConfig.Base.StatConnRds);
+                if(dt.Rows.Count > 0)
+                {
+                    foreach(string field in fields.Split(','))
+                    {
+                        Item.Add(field, function.CheckNum(dt.Rows[0][0].ToString()));
+                    }
+                }
+                else
+                {
+                    foreach(string field in fields.Split(','))
+                    {
+                        Item.Add(field, "0");
+                    }
+                }
+                AmtList.Add(Item);
+            }
+            return AmtList;
+        }
+    }
+}

+ 1 - 0
appsettings.Development.json

@@ -20,6 +20,7 @@
     "MiniSqlConnStr": "server=47.109.31.237;port=3306;user=MiniProgram;password=sxqHokkreqE6HnUg;database=MiniProgram;charset=utf8;",
     "SqlConnStr": "server=47.109.31.237;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer;charset=utf8;",
     "SqlConnStr2": "server=47.109.31.237;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer2;charset=utf8;",
+    "StatSqlConnStr": "server=47.109.31.237;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateStatServer;charset=utf8;",
     "BsSqlConnStr": "server=47.109.31.237;port=3306;user=QrCodePlateBsServer;password=ld5Px33wvhyEz44P;database=QrCodePlateBsServer;charset=utf8;",
     "RedisConnStr": "47.109.31.237:6379,password=klm@redis,DefaultDatabase=4,poolsize=500,preheat=50,asyncPipeline=true",
     "IOSAppVersion": "1.0.0",

+ 1 - 0
appsettings.json

@@ -19,6 +19,7 @@
     "KxsSqlConnStr": "server=47.108.231.170;port=3306;user=KxsMain;password=mzeqjriUWore0dwT;database=KxsMainServer;charset=utf8;Max Pool Size=512",
     "MiniSqlConnStr": "server=47.109.31.237;port=3306;user=MiniProgram;password=sxqHokkreqE6HnUg;database=MiniProgram;charset=utf8;",
     "SqlConnStr": "server=rm-2vc27k81v217qs1t55o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer;charset=utf8;",
+    "StatSqlConnStr": "server=rm-2vc27k81v217qs1t55o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateStatServer;charset=utf8;",
     "SqlConnStr2": "server=rm-2vc27k81v217qs1t55o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer2;charset=utf8;",
     "BsSqlConnStr": "server=rm-2vc27k81v217qs1t55o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=QrCodePlateBsServer;password=ld5Px33wvhyEz44P;database=QrCodePlateBsServer;charset=utf8;",
     "RedisConnStr": "redis:6379,password=kxsmp@2023,DefaultDatabase=0,poolsize=500,preheat=50,asyncPipeline=true",