Explorar o código

Merge branch 'DuGuYang' into develop

lichunlei %!s(int64=3) %!d(string=hai) anos
pai
achega
3676281116

+ 0 - 124
AppStart/Helper/InstallmentDeductionService.cs

@@ -1,124 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Linq;
-using System.Threading;
-using MySystem.Models;
-using Library;
-
-namespace MySystem
-{
-    /// <summary>
-    /// 分期扣款(每月20号执行)
-    /// </summary>
-    public class InstallmentDeductionService
-    {
-        public readonly static InstallmentDeductionService Instance = new InstallmentDeductionService();
-        private InstallmentDeductionService()
-        { }
-
-        public void Start()
-        {
-            Thread th = new Thread(doSomething);
-            th.IsBackground = true;
-            th.Start();
-        }
-
-        public void doSomething()
-        {
-            while (true)
-            {
-                // if (DateTime.Now.Day == 20 && DateTime.Now.Hour < 12)
-                if (DateTime.Now.Hour < 20)
-                {
-                    try
-                    {
-                        string check = function.ReadInstance("/InstallmentDeduction/check" + DateTime.Now.ToString("yyyy-MM-20") + ".txt");
-                        if (string.IsNullOrEmpty(check))
-                        {
-                            function.WritePage("/InstallmentDeduction/", "check" + DateTime.Now.ToString("yyyy-MM-20") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
-                            WebCMSEntities db = new WebCMSEntities();
-                            var startdate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-20 00:00:00"));
-                            var enddate = startdate.AddDays(1);
-                            // var info = db.ToChargeBackRecordSub.Where(m => m.Status == 0 && m.StartDate >= startdate && m.StartDate < enddate).ToList();//分期扣款记录明细
-                            var info = db.ToChargeByStage.Where(m => m.Status == 0).ToList();//分期扣款记录
-                            foreach (var item in info)
-                            {
-                                var toChargeBackRecordSub = db.ToChargeBackRecordSub.FirstOrDefault(m => m.Status == 0 && m.ParentId == item.Id && m.StartDate >= startdate && m.StartDate < enddate) ?? new ToChargeBackRecordSub();
-                                if (toChargeBackRecordSub.Id > 0)
-                                {
-                                    var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == item.UserId);
-                                    if (userAccount == null)
-                                    {
-                                        userAccount = db.UserAccount.Add(new UserAccount()
-                                        {
-                                            Id = item.UserId,
-                                            UserId = item.UserId,
-                                        }).Entity;
-                                        db.SaveChanges();
-                                    }
-                                    toChargeBackRecordSub.Status = 2;
-                                    userAccount.ToChargeAmount += toChargeBackRecordSub.ChargeAmount;//增加预扣款
-                                    var toChargeBackRecord = db.ToChargeBackRecord.Add(new ToChargeBackRecord
-                                    {
-                                        CreateDate = DateTime.Now,
-                                        Sort = toChargeBackRecordSub.Id,
-                                        UserId = item.UserId,
-                                        ChargeAmount = toChargeBackRecordSub.ChargeAmount,
-                                        ChargeType = 2,//分期预扣款
-                                        Remark = toChargeBackRecordSub.Remark,
-
-                                    }).Entity;
-                                }
-
-                                // //只能存在一笔分期扣款记录(先前有的但是余额不够未扣除的则不添加新的)
-                                // var checks = db.ToChargeBackRecord.Any(m => m.Sort > 0 && (m.Status == 0 || m.Status == 3) && m.ChargeType == 2 && m.UserId == item.UserId);
-                                // if (!checks)
-                                // {
-                                //     string checkAdd = RedisDbconn.Instance.Get<string>("InstallmentDeductionAddRecord:" + item.UserId);
-                                //     if (string.IsNullOrEmpty(check))
-                                //     {
-                                //         var toChargeBackRecordSub = db.ToChargeBackRecordSub.FirstOrDefault(m => m.Status == 0 && m.ParentId == item.Id && m.StartDate >= startdate && m.StartDate < enddate) ?? new ToChargeBackRecordSub();
-                                //         if (toChargeBackRecordSub.Id > 0)
-                                //         {
-                                //             var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == item.UserId);
-                                //             if (userAccount == null)
-                                //             {
-                                //                 userAccount = db.UserAccount.Add(new UserAccount()
-                                //                 {
-                                //                     Id = item.UserId,
-                                //                     UserId = item.UserId,
-                                //                 }).Entity;
-                                //                 db.SaveChanges();
-                                //             }
-                                //             userAccount.ToChargeAmount += toChargeBackRecordSub.ChargeAmount;//增加预扣款
-                                //             var toChargeBackRecord = db.ToChargeBackRecord.Add(new ToChargeBackRecord
-                                //             {
-                                //                 CreateDate = DateTime.Now,
-                                //                 Sort = toChargeBackRecordSub.Id,
-                                //                 UserId = item.UserId,
-                                //                 ChargeAmount = toChargeBackRecordSub.ChargeAmount,
-                                //                 ChargeType = 2,//分期预扣款
-                                //                 Remark = "分期预扣款",
-
-                                //             }).Entity;
-                                //         }
-                                //     }
-                                //     RedisDbconn.Instance.Set("InstallmentDeductionAddRecord:" + item.UserId, "wait");
-                                //     RedisDbconn.Instance.SetExpire("InstallmentDeductionAddRecord:" + item.UserId, 300);
-                                // }
-                            }
-                            db.SaveChanges();
-
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "执行分期扣费异常");
-                    }
-                }
-                Thread.Sleep(1000);
-            }
-        }
-    }
-}

+ 203 - 0
AppStart/Helper/PreStoreApplyQueue.cs

@@ -0,0 +1,203 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Linq;
+using System.Data;
+using MySystem;
+using MySystem.Models;
+using Library;
+using LitJson;
+
+public class PreStoreApplyHelper
+{
+    public readonly static PreStoreApplyHelper Instance = new PreStoreApplyHelper();
+    private PreStoreApplyHelper()
+    {
+    }
+
+    public void StartEverTime()
+    {
+        Thread th = new Thread(StartEverTimeDo);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void StartEverTimeDo()
+    {
+        while (true)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            try
+            {
+                string data = RedisDbconn.Instance.RPop<string>("PreStoreApplyQueue");
+                if (!string.IsNullOrEmpty(data))
+                {
+                    function.WriteLog("data:" + data, "创客预发额度变动日志");
+                    JsonData jsonObj = JsonMapper.ToObject(data);
+                    if (jsonObj["Kind"].ToString() == "1") // 购买创客预发临时额度
+                    {
+                        int OrderId = int.Parse(jsonObj["Data"]["OrderId"].ToString());
+                        Orders order = db.Orders.FirstOrDefault(m => m.Id == OrderId);
+                        if (order != null)
+                        {
+                            decimal TotalPrice = order.TotalPrice;
+                            AddAmount2(db, 1, order.UserId, TotalPrice, order.PayMode, 1, order.Id);
+                        }
+                    }
+                    else if (jsonObj["Kind"].ToString() == "2") // 增减创客预发临时额度
+                    {
+                        int UserId = int.Parse(jsonObj["Data"]["UserId"].ToString());
+                        decimal Amount = decimal.Parse(jsonObj["Data"]["Amount"].ToString());
+                        int OperateType = int.Parse(jsonObj["Data"]["OperateType"].ToString());
+                        AddAmount(db, 2, UserId, Amount, OperateType);
+                    }
+                    else if (jsonObj["Kind"].ToString() == "3") // 调低创客预发额度返回余额
+                    {
+                        int UserId = int.Parse(jsonObj["Data"]["UserId"].ToString());
+                        decimal Amount = decimal.Parse(jsonObj["Data"]["Amount"].ToString());
+                        int PayMode = int.Parse(jsonObj["Data"]["PayMode"].ToString());
+                        AddAmount2(db, 3, UserId, Amount, PayMode, 0);
+                        if (PayMode != 1)
+                        {
+                            decimal BalanceAmount = Amount;
+                            UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
+                            if (account == null)
+                            {
+                                account = db.UserAccount.Add(new UserAccount()
+                                {
+                                    Id = UserId,
+                                    UserId = UserId,
+                                }).Entity;
+                                db.SaveChanges();
+                            }
+                            decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
+                            decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
+                            decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
+                            account.BalanceAmount += BalanceAmount;
+                            decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
+                            decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
+                            decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
+                            UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
+                            {
+                                CreateDate = DateTime.Now,
+                                UpdateDate = DateTime.Now,
+                                UserId = UserId, //创客
+                                ChangeType = 126, //变动类型
+                                ChangeAmount = BalanceAmount, //变更金额
+                                BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
+                                AfterTotalAmount = AfterTotalAmount, //变更后总金额
+                                BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
+                                AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
+                                BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
+                                AfterBalanceAmount = AfterBalanceAmount, //变更后余额
+                            }).Entity;
+                        }
+                    }
+                    db.SaveChanges();
+                }
+                else
+                {
+                    Thread.Sleep(5000);
+                }
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "创客预发临时额度变动线程异常");
+            }
+            db.Dispose();
+        }
+    }
+
+    public void AddAmount(WebCMSEntities db, int Kind, int UserId, decimal Amount, int OperateType = 1, int OrderId = 0)
+    {
+        UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
+        if (account == null)
+        {
+            account = db.UserAccount.Add(new UserAccount()
+            {
+                Id = UserId,
+                UserId = UserId,
+            }).Entity;
+            db.SaveChanges();
+        }
+        decimal BeforeTotalAmount = account.ValidPreAmount; //变更前总金额
+        if (OperateType == 1)
+        {
+            account.ValidPreAmount += Amount;
+        }
+        else
+        {
+            account.ValidPreAmount -= Amount;
+        }
+        decimal AfterTotalAmount = account.ValidPreAmount; //变更后总金额
+        PreAmountRecord preAmountRecord = db.PreAmountRecord.Add(new PreAmountRecord()
+        {
+            CreateDate = DateTime.Now,
+            UpdateDate = DateTime.Now,
+            OperateType = OperateType,
+            AfterAmount = AfterTotalAmount,
+            BeforeAmount = BeforeTotalAmount,
+            UseAmount = Amount,
+            UserId = UserId,
+            QueryCount = OrderId,
+            Sort = Kind,
+        }).Entity;
+        db.SaveChanges();
+    }
+
+    public void AddAmount2(WebCMSEntities db, int Kind, int UserId, decimal Amount, int PayMode, int OperateType = 1, int OrderId = 0)
+    {
+        UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
+        if (account == null)
+        {
+            account = db.UserAccount.Add(new UserAccount()
+            {
+                Id = UserId,
+                UserId = UserId,
+            }).Entity;
+            db.SaveChanges();
+        }
+        decimal BeforeTotalAmount = account.ValidPreAmount; //变更前总金额
+
+        if (OperateType == 1)
+        {
+            if (PayMode == 3)//余额
+            {
+                account.PreTempAmountForBalance += Amount;
+            }
+            else
+            {
+                account.PreTempAmount += Amount;
+            }
+            account.ValidPreAmount += Amount;
+        }
+        else
+        {
+            if (PayMode == 3)
+            {
+                account.PreTempAmountForBalance -= Amount;
+            }
+            else
+            {
+                account.PreTempAmount -= Amount;
+            }
+            account.ValidPreAmount -= Amount;
+        }
+        decimal AfterTotalAmount = account.ValidPreAmount; //变更后总金额
+        PreAmountRecord preAmountRecord = db.PreAmountRecord.Add(new PreAmountRecord()
+        {
+            CreateDate = DateTime.Now,
+            UpdateDate = DateTime.Now,
+            OperateType = OperateType,
+            AmountType = PayMode,
+            AfterAmount = AfterTotalAmount,
+            BeforeAmount = BeforeTotalAmount,
+            UseAmount = Amount,
+            UserId = UserId,
+            QueryCount = OrderId,
+            Sort = Kind,
+            PayMode = PayMode,
+        }).Entity;
+        db.SaveChanges();
+    }
+}

+ 0 - 75
AppStart/Helper/TimeOutPosChargeReturnService.cs

@@ -1,75 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Linq;
-using System.Threading;
-using MySystem.Models;
-using Library;
-
-namespace MySystem
-{
-    /// <summary>
-    /// 过期兑换机具循环截止时间超过15天激活扣费退还
-    /// </summary>
-    public class TimeOutPosChargeReturnService
-    {
-        public readonly static TimeOutPosChargeReturnService Instance = new TimeOutPosChargeReturnService();
-        private TimeOutPosChargeReturnService()
-        { }
-
-        public void Start()
-        {
-            Thread th = new Thread(doSomething);
-            th.IsBackground = true;
-            th.Start();
-        }
-
-        public void doSomething()
-        {
-            while (true)
-            {
-                if (DateTime.Now.Hour < 18)
-                {
-                    try
-                    {
-                        string check = function.ReadInstance("/TimeOutPosChargeReturn/check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
-                        if (string.IsNullOrEmpty(check))
-                        {
-                            function.WritePage("/TimeOutPosChargeReturn/", "check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
-                            WebCMSEntities db = new WebCMSEntities();
-                            DataTable dt = CustomerSqlConn.dtable("SELECT a.Id Id FROM ToChargeBackRecord a LEFT JOIN PosMachinesTwo b ON a.Remark=b.PosSn WHERE a.`Status`=1 AND b.PosSnType=0  AND b.BindingState=1 AND b.ActivationState=1", MysqlConn.connstr);//循环过期超过15天激活机具退费创客
-                            foreach (DataRow item in dt.Rows)
-                            {
-                                int Id = int.Parse(item["Id"].ToString());
-                                var toChargeBackRecord = db.ToChargeBackRecord.FirstOrDefault(m => m.Id == Id && m.Status == 1) ?? new ToChargeBackRecord();
-                                if (toChargeBackRecord.Id > 0)
-                                {
-                                    var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == toChargeBackRecord.UserId) ?? new UserAccount();
-                                    var userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord
-                                    {
-                                        CreateDate = DateTime.Now,
-                                        UserId = toChargeBackRecord.UserId,
-                                        BeforeBalanceAmount = userAccount.BalanceAmount,
-                                        AfterBalanceAmount = userAccount.BalanceAmount + toChargeBackRecord.ChargeAmount,
-                                        ChangeAmount = toChargeBackRecord.ChargeAmount,
-                                        ChangeType = 126,//过期兑换机具超过15天激活扣费退还
-                                        Remark = "机具货款退还",
-
-                                    }).Entity;
-                                    toChargeBackRecord.Status = 2;//过期兑换机具循环截止时间超过15天激活扣费退还标识
-                                    userAccount.BalanceAmount += toChargeBackRecord.ChargeAmount;
-                                    db.SaveChanges();
-                                }
-                            }
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期兑换机具超过15天激活扣费退还");
-                    }
-                }
-                Thread.Sleep(1000);
-            }
-        }
-    }
-}

+ 0 - 209
AppStart/Helper/TimeOutPosChargeService.cs

@@ -1,209 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Linq;
-using System.Threading;
-using MySystem.Models;
-using Library;
-
-namespace MySystem
-{
-    /// <summary>
-    /// 过期机具执行扣费
-    /// </summary>
-    public class TimeOutPosChargeService
-    {
-        public readonly static TimeOutPosChargeService Instance = new TimeOutPosChargeService();
-        private TimeOutPosChargeService()
-        { }
-
-        public void Start()
-        {
-            Thread th = new Thread(doSomething);
-            th.IsBackground = true;
-            th.Start();
-        }
-
-        public void doSomething()
-        {
-            while (true)
-            {
-                if (DateTime.Now.Hour < 3)
-                {
-                    try
-                    {
-                        string check = function.ReadInstance("/TimeOutPosCharge/check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
-                        if (string.IsNullOrEmpty(check))
-                        {
-                            function.WritePage("/TimeOutPosCharge/", "check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
-                            WebCMSEntities db = new WebCMSEntities();
-                            var date = DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd 00:00:00");//过期限制时间
-                            var time = DateTime.Parse(date);//过期限制时间
-
-                            DataTable dt = CustomerSqlConn.dtable("SELECT BuyUserId FROM PosMachinesTwo WHERE `Status`>-1 AND BuyUserId>0 AND BindingState=0 AND ActivationState=0 AND ScanQrTrade=0 AND RecycEndDate <'" + date + "' GROUP BY BuyUserId", MysqlConn.SqlConnStr);//扣费创客
-                            var query = db.PosMachinesTwo.Where(m => m.Status > -1 && m.BuyUserId > 0 && m.BindingState == 0 && m.ActivationState == 0 && m.ScanQrTrade == 0 && m.RecycEndDate < time).ToList();//循环过期超过15天机具
-                            var brandInfo = db.KqProducts.ToList();
-                            foreach (DataRow item in dt.Rows)
-                            {
-                                int BuyUserId = int.Parse(item["BuyUserId"].ToString());
-                                var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == BuyUserId);
-                                if (userAccount == null)
-                                {
-                                    userAccount = db.UserAccount.Add(new UserAccount()
-                                    {
-                                        Id = BuyUserId,
-                                        UserId = BuyUserId,
-                                    }).Entity;
-                                    db.SaveChanges();
-                                }
-                                var posInfo = query.Where(m => m.BuyUserId == BuyUserId);
-                                var amount = 0;
-                                foreach (var pos in posInfo)
-                                {
-                                    var poss = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id) ?? new PosMachinesTwo();
-                                    poss.ScanQrTrade = 999;
-                                    var Brand = brandInfo.FirstOrDefault(m => m.Id == pos.BrandId);
-                                    if (Brand.Name.Contains("电签"))
-                                    {
-                                        amount = 200;
-                                    }
-                                    if (Brand.Name.Contains("大POS"))
-                                    {
-                                        amount = 300;
-                                    }
-                                    userAccount.ToChargeAmount += amount;//增加预扣款
-                                    var toChargeBackRecord = db.ToChargeBackRecord.Add(new ToChargeBackRecord
-                                    {
-                                        CreateDate = DateTime.Now,
-                                        UserId = BuyUserId,
-                                        ChargeAmount = amount,
-                                        ChargeType = 124,//过期机具货款扣费
-                                        Remark = pos.PosSn,
-
-                                    }).Entity;
-                                }
-                            }
-                            db.SaveChanges();
-
-                            DoChargeAmount(db);
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期机具执行扣费异常");
-                    }
-                }
-                Thread.Sleep(1000);
-            }
-        }
-
-
-
-        public void StartDoChargeAmount()
-        {
-            Thread th = new Thread(StartDoChargeAmountReady);
-            th.IsBackground = true;
-            th.Start();
-        }
-
-        public void StartDoChargeAmountReady()
-        {
-            while (true)
-            {
-                WebCMSEntities db = new WebCMSEntities();
-                DoChargeAmount(db);
-                db.Dispose();
-                Thread.Sleep(600000);
-            }
-        }
-
-        public void ListenChargeAmount()
-        {
-            Thread th = new Thread(ListenChargeAmountReady);
-            th.IsBackground = true;
-            th.Start();
-        }
-
-        public void ListenChargeAmountReady()
-        {
-            while (true)
-            {
-                string content = RedisDbconn.Instance.RPop<string>("DoChargeAmountQueue");
-                if (!string.IsNullOrEmpty(content))
-                {
-                    WebCMSEntities db = new WebCMSEntities();
-                    DoChargeAmount(db, int.Parse(function.CheckInt(content)));
-                    db.Dispose();
-                }
-            }
-        }
-
-        public void DoChargeAmount(WebCMSEntities db, int UserId = 0)
-        {
-            IQueryable<ToChargeBackRecord> list = db.ToChargeBackRecord.Where(m => m.Status == 0);//过期机具扣费记录
-            if (UserId > 0)
-            {
-                list = list.Where(m => m.UserId == UserId);
-            }
-            var info = list.ToList();
-            foreach (var items in info)
-            {
-                var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == items.UserId) ?? new UserAccount();
-                var record = info.FirstOrDefault(m => m.Id == items.Id);
-
-                if (userAccount.BalanceAmount >= record.ChargeAmount)
-                {
-                    var ChangeType = 0;
-                    var Remark = "";
-                    if (record.ChargeType == 124)//过期机具货款扣费
-                    {
-                        ChangeType = 124;
-                        Remark = "扣机具货款";
-                    }
-                    if (record.ChargeType == 1)//普通预扣款
-                    {
-                        ChangeType = 202;
-                        // Remark = "普通扣款";
-                        Remark = items.Remark;
-                    }
-                    if (record.ChargeType == 2)//分期预扣款
-                    {
-                        ChangeType = 201;
-                        // Remark = "分期扣款";
-                        Remark = items.Remark;
-                    }
-                    var userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord
-                    {
-                        CreateDate = DateTime.Now,
-                        UserId = items.UserId,
-                        BeforeBalanceAmount = userAccount.BalanceAmount,
-                        AfterBalanceAmount = userAccount.BalanceAmount - record.ChargeAmount,
-                        ChangeAmount = record.ChargeAmount,
-                        ChangeType = ChangeType,
-                        Remark = Remark,
-
-                    }).Entity;
-                    record.Status = 1;
-                    if (record.ChargeType == 2)
-                    {
-                        var toChargeBackRecordSub = db.ToChargeBackRecordSub.FirstOrDefault(m => m.Id == record.Sort) ?? new ToChargeBackRecordSub();
-                        var toChargeByStage = db.ToChargeByStage.FirstOrDefault(m => m.Id == toChargeBackRecordSub.ParentId && m.TimeNumber > m.QueryCount) ?? new ToChargeByStage();
-                        toChargeBackRecordSub.Status = 1;
-                        toChargeByStage.QueryCount += 1;
-                        toChargeByStage.ChargeAmount += toChargeBackRecordSub.ChargeAmount;
-                        if (toChargeByStage.TimeNumber == toChargeByStage.QueryCount)
-                        {
-                            toChargeByStage.Status = 1;
-                        }
-                    }
-                    if (userAccount.ToChargeAmount >= record.ChargeAmount)
-                    {
-                        userAccount.ToChargeAmount -= record.ChargeAmount;//分期扣款
-                    }
-                    userAccount.BalanceAmount -= record.ChargeAmount;//扣减余额
-                }
-            }
-            db.SaveChanges();
-        }
-    }
-}

+ 0 - 83
AppStart/Helper/TimeOutPosSendMessageService.cs

@@ -1,83 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Linq;
-using System.Threading;
-using MySystem.Models;
-using Library;
-
-namespace MySystem
-{
-    /// <summary>
-    /// 过期机具预扣费消息推送
-    /// </summary>
-    public class TimeOutPosSendMessageService
-    {
-        public readonly static TimeOutPosSendMessageService Instance = new TimeOutPosSendMessageService();
-        private TimeOutPosSendMessageService()
-        { }
-
-        public void Start()
-        {
-            Thread th = new Thread(doSomething);
-            th.IsBackground = true;
-            th.Start();
-        }
-
-        public void doSomething()
-        {
-            while (true)
-            {
-                if (DateTime.Now.Hour < 20)
-                {
-                    try
-                    {
-                        string check = function.ReadInstance("/TimeOutPosSendMessage/check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
-                        if (string.IsNullOrEmpty(check))
-                        {
-                            function.WritePage("/TimeOutPosSendMessage/", "check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
-                            WebCMSEntities db = new WebCMSEntities();
-                            var date = DateTime.Now.AddDays(-55).ToString("yyyy-MM-dd 00:00:00");//过期限制时间
-                            var time = DateTime.Parse(date);//过期限制时间
-
-                            DataTable dt = CustomerSqlConn.dtable("SELECT BuyUserId FROM PosMachinesTwo WHERE `Status`>-1 AND BuyUserId>0 AND BindingState=0 AND ActivationState=0 AND ScanQrTrade=0 AND RecycEndDate <'" + date + "' GROUP BY BuyUserId", MysqlConn.connstr);//消息推送创客
-                            var query = db.PosMachinesTwo.Where(m => m.Status > -1 && m.BuyUserId > 0 && m.BindingState == 0 && m.ActivationState == 0 && m.ScanQrTrade == 0 && m.RecycEndDate < time).ToList();//循环过期超过55天机具
-                            var brandInfo = db.KqProducts.ToList();
-                            foreach (DataRow item in dt.Rows)
-                            {
-                                int BuyUserId = int.Parse(item["BuyUserId"].ToString());
-                                var BrandName = "";
-                                var PosSn = "";
-                                var SendInfo = "";
-                                foreach (var items in brandInfo)
-                                {
-                                    int BrandId = int.Parse(items.Id.ToString());
-                                    BrandName = items.Name.ToString();
-                                    var posInfo = query.Where(m => m.BuyUserId == BuyUserId && m.BrandId == BrandId);
-                                    foreach (var pos in posInfo)
-                                    {
-                                        PosSn += BrandName +":"+pos.PosSn + "," + "<br/>";
-                                    }
-                                }
-                                SendInfo = PosSn.TrimEnd(',') + "<br/>";
-                                RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
-                                {
-                                    UserId = BuyUserId, //创客
-                                    Title = "机具循环过期提醒", //标题
-                                    Content = "<div class='f16'>尊敬的创客您好:<br/>您的" + SendInfo + "循环已过期五十五天以上,请在五日内完成激活或通过机具回收回寄该机具。</ div > ",//内容
-                                    Summary = "系统检测到您的部分机具可回收,请打开我的-回收机具及时处理!",
-                                    CreateDate = DateTime.Now,
-                                }));
-                            }
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期机具预扣费消息推送异常");
-                    }
-                }
-                Thread.Sleep(1000);
-            }
-        }
-    }
-}

+ 3 - 0
AppStart/RelationClassForConst.cs

@@ -153,6 +153,9 @@ namespace MySystem
                 case 127:
                     result = "运营中心分仓奖励";
                     break;
+                case 130:
+                    result = "预发临时额度退还";
+                    break;
                 case 201:
                     result = "分期预扣款";
                     break;

+ 48 - 48
Areas/Admin/Controllers/HomeController.cs

@@ -149,60 +149,60 @@ namespace MySystem.Areas.Admin.Controllers
         [HttpPost]
         public string Login(string UserName, string Pwd, string CheckCode)
         {
-            string result = "";
-            if (function.GetCookie(_accessor.HttpContext, "checkcode") != CheckCode)
-            {
-                result = "验证码错误!!";
-            }
-            else
-            {
-                Pwd = function.MD5_32(Pwd);
-                var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
-                if (user != null)
-                {
-                    user.LastLoginDate = DateTime.Now;
-                    db.SaveChanges();
-                    function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
-                    function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
-                    function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
-                    int RoleId = int.Parse(function.CheckInt(user.Role));
-                    BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
-                    string RightInfo = function.CheckNull(Role.RightInfo);
-                    function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
-                    string UserId = user.Id.ToString();
-                    function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
-                    function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
-                    result = "success";
-                }
-                else
-                {
-                    result = "用户名或密码错误";
-                }
-            }
-
             // string result = "";
-            // Pwd = function.MD5_32(Pwd);
-            // var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
-            // if (user != null)
+            // if (function.GetCookie(_accessor.HttpContext, "checkcode") != CheckCode)
             // {
-            //     user.LastLoginDate = DateTime.Now;
-            //     db.SaveChanges();
-            //     function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
-            //     function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
-            //     function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
-            //     int RoleId = int.Parse(function.CheckInt(user.Role));
-            //     BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
-            //     string RightInfo = function.CheckNull(Role.RightInfo);
-            //     function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
-            //     string UserId = user.Id.ToString();
-            //     function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
-            //     function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
-            //     result = "success";
+            //     result = "验证码错误!!";
             // }
             // else
             // {
-            //     result = "用户名或密码错误";
+            //     Pwd = function.MD5_32(Pwd);
+            //     var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
+            //     if (user != null)
+            //     {
+            //         user.LastLoginDate = DateTime.Now;
+            //         db.SaveChanges();
+            //         function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
+            //         function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
+            //         function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
+            //         int RoleId = int.Parse(function.CheckInt(user.Role));
+            //         BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
+            //         string RightInfo = function.CheckNull(Role.RightInfo);
+            //         function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
+            //         string UserId = user.Id.ToString();
+            //         function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
+            //         function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
+            //         result = "success";
+            //     }
+            //     else
+            //     {
+            //         result = "用户名或密码错误";
+            //     }
             // }
+
+            string result = "";
+            Pwd = function.MD5_32(Pwd);
+            var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
+            if (user != null)
+            {
+                user.LastLoginDate = DateTime.Now;
+                db.SaveChanges();
+                function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
+                function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
+                function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
+                int RoleId = int.Parse(function.CheckInt(user.Role));
+                BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
+                string RightInfo = function.CheckNull(Role.RightInfo);
+                function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
+                string UserId = user.Id.ToString();
+                function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
+                function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
+                result = "success";
+            }
+            else
+            {
+                result = "用户名或密码错误";
+            }
             return result;
         }
         #endregion

+ 41 - 2
Areas/Admin/Controllers/MainServer/LeadersController.cs

@@ -51,7 +51,7 @@ namespace MySystem.Areas.Admin.Controllers
         /// 盟主管理列表
         /// </summary>
         /// <returns></returns>
-        public JsonResult IndexData(Leaders data, string UserIdMakerCode, string LeaderLevelSelect, string CreateDateData, int page = 1, int limit = 30)
+        public JsonResult IndexData(Leaders data, string UserIdMakerCode, string LeaderLevelSelect, string LeaderStatusSelect, string LastBuyDateData, string ExpiredDateData, string CreateDateData, int page = 1, int limit = 30)
         {
 
             Dictionary<string, string> Fields = new Dictionary<string, string>();
@@ -67,7 +67,20 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 condition += " and LeaderLevel=" + LeaderLevelSelect;
             }
-            //创建时间
+            //状态
+            if (!string.IsNullOrEmpty(LeaderStatusSelect))
+            {
+                var time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                if (LeaderStatusSelect == "0")
+                {
+                    condition += " and ExpiredDate>'" + time + "'";
+                }
+                else
+                {
+                    condition += " and ExpiredDate<='" + time + "'";
+                }
+            }
+            //首次购买时间
             if (!string.IsNullOrEmpty(CreateDateData))
             {
                 string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
@@ -75,6 +88,22 @@ namespace MySystem.Areas.Admin.Controllers
                 string end = datelist[1];
                 condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
             }
+            //最后购买时间
+            if (!string.IsNullOrEmpty(LastBuyDateData))
+            {
+                string[] datelist = LastBuyDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and LastBuyDate>='" + start + " 00:00:00' and LastBuyDate<='" + end + " 23:59:59'";
+            }
+            //盟主到期时间
+            if (!string.IsNullOrEmpty(ExpiredDateData))
+            {
+                string[] datelist = ExpiredDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and ExpiredDate>='" + start + " 00:00:00' and ExpiredDate<='" + end + " 23:59:59'";
+            }
 
 
             Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Leaders", Fields, "Id desc", "0", page, limit, condition);
@@ -90,6 +119,16 @@ namespace MySystem.Areas.Admin.Controllers
                 dic["UserIdRealName"] = userid_Users.RealName;
                 dic["LeaderReserve"] = userAccount.LeaderReserve;
                 dic["LeaderBalanceAmount"] = userAccount.LeaderBalanceAmount;
+
+                var ExpiredDate = DateTime.Parse(dic["ExpiredDate"].ToString());
+                if (ExpiredDate > DateTime.Now)
+                {
+                    dic["LeaderStatus"] = "未过期";
+                }
+                else
+                {
+                    dic["LeaderStatus"] = "已过期";
+                }
                 dic.Remove("UserId");
                 //盟主等级
                 int LeaderLevel = int.Parse(dic["LeaderLevel"].ToString());

+ 385 - 0
Areas/Admin/Controllers/MainServer/PreAmountRecordController.cs

@@ -0,0 +1,385 @@
+/*
+ * 小分仓额度记录
+ */
+
+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 PreAmountRecordController : BaseController
+    {
+        public PreAmountRecordController(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(PreAmountRecord data, string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+
+            return View();
+        }
+
+        #endregion
+
+        #region 根据条件查询小分仓临时额度记录列表
+
+        /// <summary>
+        /// 根据条件查询小分仓临时额度记录列表
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult IndexData(PreAmountRecord data, string UserIdRealName, string UserIdMakerCode, string CreateDateData, string OperateTypeSelect, string PayModeSelect, int page = 1, int limit = 30)
+        {
+
+            Dictionary<string, string> Fields = new Dictionary<string, string>();
+
+            string condition = " and Status>=-1";
+            //创客真实姓名
+            if (!string.IsNullOrEmpty(UserIdRealName))
+            {
+                condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
+            }
+            //创客编号
+            if (!string.IsNullOrEmpty(UserIdMakerCode))
+            {
+                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
+            }
+            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'";
+            }
+            //操作类别
+            if (!string.IsNullOrEmpty(OperateTypeSelect))
+            {
+                condition += " and OperateType=" + OperateTypeSelect;
+            }
+            //额度类别
+            if (!string.IsNullOrEmpty(PayModeSelect))
+            {
+                condition += " and PayMode=" + PayModeSelect;
+            }
+
+
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreAmountRecord", 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();
+                dic["UserIdRealName"] = userid_Users.RealName;
+                dic["UserIdMakerCode"] = userid_Users.MakerCode;
+                dic.Remove("UserId");
+
+                //变动类别
+                int ChangeType = int.Parse(dic["Sort"].ToString());
+                if (ChangeType == 1) dic["ChangeType"] = "购买临额";
+                if (ChangeType == 3) dic["ChangeType"] = "调低临额";
+
+                //操作类别
+                int OperateType = int.Parse(dic["OperateType"].ToString());
+                if (OperateType == 0) dic["OperateType"] = "减少";
+                if (OperateType == 1) dic["OperateType"] = "增加";
+
+                //额度类别
+                int PayMode = int.Parse(dic["PayMode"].ToString());
+                if (PayMode == 1) dic["PayMode"] = "支付宝";
+                if (PayMode == 3) dic["PayMode"] = "余额";
+                if (PayMode == 0) dic["PayMode"] = "";
+
+            }
+            return Json(obj);
+        }
+
+        #endregion
+
+
+
+        #region 小分仓银行卡临额提现记录列表
+
+        /// <summary>
+        /// 根据条件查询小分仓银行卡临额提现记录列表
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Indexs(PreAmountRecord data, string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+
+            return View();
+        }
+
+        #endregion
+
+        #region 小分仓银行卡临额提现记录列表
+
+        /// <summary>
+        /// 根据条件查询小分仓银行卡临额提现记录列表
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult IndexsData(PreAmountRecord data, string UserIdRealName, string UserIdMakerCode, string CreateDateData, string OperateTypeSelect, string PayModeSelect, string StatusSelect = "0", int page = 1, int limit = 30)
+        {
+
+            Dictionary<string, string> Fields = new Dictionary<string, string>();
+
+            string condition = " and Status>=-1 and PayMode=1 and Sort=3";
+            //创客真实姓名
+            if (!string.IsNullOrEmpty(UserIdRealName))
+            {
+                condition += " and UserId in (select UserId from Users where RealName='" + UserIdRealName + "')";
+            }
+            //创客编号
+            if (!string.IsNullOrEmpty(UserIdMakerCode))
+            {
+                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
+            }
+            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'";
+            }
+            //操作类别
+            if (!string.IsNullOrEmpty(OperateTypeSelect))
+            {
+                condition += " and OperateType=" + OperateTypeSelect;
+            }
+            //额度类别
+            if (!string.IsNullOrEmpty(PayModeSelect))
+            {
+                condition += " and PayMode=" + PayModeSelect;
+            }
+            //状态
+            if (!string.IsNullOrEmpty(StatusSelect))
+            {
+                condition += " and Status=" + StatusSelect;
+            }
+
+
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreAmountRecord", 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();
+                dic["UserIdRealName"] = userid_Users.RealName;
+                dic["UserIdMakerCode"] = userid_Users.MakerCode;
+                dic["CertId"] = userid_Users.CertId;
+                dic["SettleBankCardNo"] = userid_Users.SettleBankCardNo;
+                dic["SettleBankName"] = userid_Users.SettleBankName;
+                dic["Mobile"] = userid_Users.Mobile;
+                dic["Type"] = "临额提现";
+                dic.Remove("UserId");
+
+                //操作类别
+                int OperateType = int.Parse(dic["OperateType"].ToString());
+                if (OperateType == 0) dic["OperateType"] = "减少";
+                if (OperateType == 1) dic["OperateType"] = "增加";
+
+                //额度类别
+                int PayMode = int.Parse(dic["PayMode"].ToString());
+                if (PayMode == 1) dic["PayMode"] = "支付宝";
+                if (PayMode == 3) dic["PayMode"] = "余额";
+                if (PayMode == 0) dic["PayMode"] = "";
+
+                //状态
+                int Status = int.Parse(dic["Status"].ToString());
+                if (Status == 0) dic["Status"] = "待处理";
+                if (Status == 2) dic["Status"] = "处理中";
+                if (Status == 1) dic["Status"] = "成功";
+                if (Status == -1) dic["Status"] = "失败";
+            }
+            return Json(obj);
+        }
+
+        #endregion
+
+
+
+        #region 小分仓银行卡临额提现记录导出Excel
+
+        /// <summary>
+        /// 导出Excel
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult ExportsExcel(PreAmountRecord data, string UserIdRealName, string UserIdMakerCode, string CreateDateData, string StatusSelect)
+        {
+            Dictionary<string, string> Fields = new Dictionary<string, string>();
+
+
+            string condition = " and PayMode=1 and Sort=3";
+            //创客真实姓名
+            if (!string.IsNullOrEmpty(UserIdRealName))
+            {
+                condition += " and UserId in (select UserId from Users where RealName='" + UserIdRealName + "')";
+            }
+            //创客编号
+            if (!string.IsNullOrEmpty(UserIdMakerCode))
+            {
+                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
+            }
+            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'";
+            }
+            //状态
+            if (!string.IsNullOrEmpty(StatusSelect))
+            {
+                condition += " and Status=" + StatusSelect;
+            }
+
+            var Ids = "";
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreAmountRecord", Fields, "Id desc", "0", 1, 20000, condition, "Id,CreateDate,UserId,UseAmount", false);
+            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();
+                dic["UserIdRealName"] = userid_Users.RealName;
+                dic["UserIdMakerCode"] = userid_Users.MakerCode;
+                dic["CertId"] = userid_Users.CertId;
+                dic["SettleBankCardNo"] = userid_Users.SettleBankCardNo;
+                dic["SettleBankName"] = userid_Users.SettleBankName;
+                dic["Mobile"] = userid_Users.Mobile;
+                dic["Type"] = "临额提现";
+                dic["IsOk"] = "";
+                dic.Remove("UserId");
+
+                //记录Id
+                int Id = int.Parse(function.CheckInt(dic["Id"].ToString()));
+                var preAmountRecord = db.PreAmountRecord.FirstOrDefault(m => m.Id == Id) ?? new PreAmountRecord();
+                if (preAmountRecord.Status == 0) dic["Status"] = "待处理";
+                if (preAmountRecord.Status == 2) dic["Status"] = "处理中";
+                if (preAmountRecord.Status == 1) dic["Status"] = "成功";
+                if (preAmountRecord.Status == -1) dic["Status"] = "失败";
+                dic["Id"] = Id;
+                Ids += Id + ",";
+            }
+            Ids = Ids.TrimEnd(',');
+
+            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>();
+            ReturnFields.Add("Id", "记录ID");
+            ReturnFields.Add("CreateDate", "提现申请时间");
+            ReturnFields.Add("Status", "提现结果");
+            ReturnFields.Add("UserIdRealName", "创客真实姓名");
+            ReturnFields.Add("UserIdMakerCode", "创客编号");
+            ReturnFields.Add("UseAmount", "申请提现临额");
+            ReturnFields.Add("CertId", "身份证号");
+            ReturnFields.Add("SettleBankCardNo", "银行卡号");
+            ReturnFields.Add("SettleBankName", "银行名称");
+            ReturnFields.Add("Mobile", "手机号");
+            ReturnFields.Add("Type", "交易类型");
+            ReturnFields.Add("IsOk", "是否成功(是、否)");
+
+            result.Add("Fields", ReturnFields);
+            OtherMySqlConn.op("UPDATE PreAmountRecord SET `Status`=2 WHERE Id IN(" + Ids + ") AND `Status`=0");
+            AddSysLog("0", "PreAmountRecord", "ExportExcel");
+            return Json(result);
+        }
+
+        #endregion
+
+
+
+        #region 小分仓银行卡临额提现记录结果导入Excel
+        /// <summary>
+        /// 小分仓银行卡临额提现记录结果导入Excel
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        public string Imports(string ExcelData)
+        {
+            ExcelData = HttpUtility.UrlDecode(ExcelData);
+            JsonData list = JsonMapper.ToObject(ExcelData);
+            string error = "";
+            List<int> IdList = new List<int>();
+            List<int> IdLists = new List<int>();
+            for (int i = 1; i < list.Count; i++)
+            {
+                JsonData dr = list[i];
+                string itemJson = dr.ToJson();
+                string Id = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                string IsOk = itemJson.Contains("\"L\"") ? dr["L"].ToString() : "";
+                if (IdList.Contains(Convert.ToInt32(Id)))
+                {
+                    error += "以下操作失败" + Id + ',' + "该记录重复" + '\n';
+                }
+                else if (IsOk == "否")
+                {
+                    IdLists.Add(Convert.ToInt32(Id));
+                }
+                else
+                {
+                    IdList.Add(Convert.ToInt32(Id));
+                }
+            }
+            if (!string.IsNullOrEmpty(error))
+            {
+                return "Warning|" + error;
+            }
+            else
+            {
+                var Info = db.PreAmountRecord.Where(m => IdList.Contains(m.Id)).ToList();//成功
+                var Infos = db.PreAmountRecord.Where(m => IdLists.Contains(m.Id)).ToList();//失败
+                foreach (var item in Info)
+                {
+                    item.Status = 1;//设置为成功
+                    db.SaveChanges();
+                }
+                foreach (var items in Infos)
+                {
+                    items.Status = -1;//设置为失败
+                    var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == items.UserId) ?? new UserAccount();
+                    if (userAccount.Id > 0)
+                    {
+                        userAccount.PreTempAmount += items.UseAmount;//退还卡充值临额
+                        userAccount.ValidPreAmount += items.UseAmount;//退还可用额度
+                    }
+                    db.SaveChanges();
+                }
+            }
+            AddSysLog("0", "PreCardAmountRecord", "Import");
+            return "success";
+        }
+        #endregion
+
+    }
+}

+ 2 - 2
Areas/Admin/Views/Home/Login.cshtml

@@ -26,11 +26,11 @@
                     <label for="password">密码 / Password</label>
                     <input class="form-input" type="password" name="Pwd" id="Pwd" onKeyUp="if(event.keyCode==13){$('#CheckCode').focus();}" placeholder="请填写密码">
                 </div>
-                <div class="form-group pb10">
+                @* <div class="form-group pb10">
                     <label for="password">验证码 / Verification</label>
                     <input class="form-input" type="text" name="CheckCode" id="CheckCode" onkeyup="if(event.keyCode==13){syslogin();}" placeholder="请填写验证码" style="width: 70%; display: inline-block; margin-right: 2%">
                     <img src="/Api/PublicMethod/CheckCode" onclick="$(this).attr('src','/Api/PublicMethod/CheckCode?r='+Math.random())" style="width: 26%; height:38px;" />
-                </div>
+                </div> *@
                 @*<div class="form-group pb10 cf">
                         <label class="remembermetext fl" for="rememberme">
                             <input type="checkbox" checked name="rememberme">&nbsp;记住我的登录

+ 25 - 1
Areas/Admin/Views/MainServer/Leaders/Index.cshtml

@@ -51,12 +51,26 @@
                         </div>
                     </div>
                     <div class="layui-inline">
-                        <label class="layui-form-label">创建时间</label>
+                        <label class="layui-form-label">首次购买时间</label>
                         <div class="layui-input-inline">
                             <input class="layui-input" type="text" readonly name="CreateDateData" id="CreateDate"
                                 placeholder="" autocomplete="off">
                         </div>
                     </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">最后购买时间</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" readonly name="LastBuyDateData" id="LastBuyDateData"
+                                placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">盟主到期时间</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" readonly name="ExpiredDateData" id="ExpiredDateData"
+                                placeholder="" autocomplete="off">
+                        </div>
+                    </div>
                     <div class="layui-inline">
                         <label class="layui-form-label">盟主等级</label>
                         <div class="layui-input-inline">
@@ -67,6 +81,16 @@
                             </select>
                         </div>
                     </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">状态</label>
+                        <div class="layui-input-inline">
+                            <select id="LeaderStatusSelect" name="LeaderStatusSelect" lay-search="">
+                                <option value="">全部...</option>
+                                <option value="0">未过期</option>
+                                <option value="1">已过期</option>
+                            </select>
+                        </div>
+                    </div>
 
                     <div class="layui-inline ml50">
                         <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">

+ 168 - 0
Areas/Admin/Views/MainServer/PreAmountRecord/Index.cshtml

@@ -0,0 +1,168 @@
+@{
+    string RightInfo = ViewBag.RightInfo as string;
+    string right = ViewBag.right as string;
+
+}
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <title>小分仓额度记录</title>
+    <meta name="renderer" content="webkit">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport"
+        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
+    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
+    <script src="/admin/js/jquery-1.10.1.min.js"></script>
+    <style>
+        .layui-input-inline {
+            width: 175px !important;
+        }
+
+        .layui-form-label {
+            width: 85px !important;
+        }
+
+        .layui-inline {
+            margin-right: 0px !important;
+        }
+
+        .w100 {
+            width: 100px !important;
+        }
+
+        .ml50 {
+            margin-left: 50px !important;
+        }
+    </style>
+</head>
+
+<body>
+    <div class="layui-fluid">
+        <div class="layui-card">
+            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
+                <div class="layui-form-item">
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创客真实姓名</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="UserIdRealName" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创客编号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="UserIdMakerCode" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创建时间</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" readonly name="CreateDateData" id="CreateDate"
+                                placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">操作类别</label>
+                        <div class="layui-input-inline">
+                            <select id="OperateTypeSelect" name="OperateTypeSelect" lay-search="">
+                                <option value="">全部...</option>
+                                <option value="1">增加</option>
+                                <option value="2">减少</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">额度类别</label>
+                        <div class="layui-input-inline">
+                            <select id="PayModeSelect" name="PayModeSelect" lay-search="">
+                                <option value="">全部...</option>
+                                <option value="1">支付宝</option>
+                                <option value="3">余额</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-inline ml50">
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">
+                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
+                        </button>
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-searchall">
+                            <i class="layui-icon layui-icon-list layuiadmin-button-btn"></i>全部
+                        </button>
+                    </div>
+                </div>
+            </div>
+
+            <div class="layui-card-body">
+                <div style="padding-bottom: 10px;">
+                    @if (RightInfo.Contains("," + right + "_add,"))
+                    {
+                        <button class="layui-btn" data-type="add"><i
+                            class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加</button>
+                    }
+                    @if (RightInfo.Contains("," + right + "_delete,"))
+                    {
+                        <button class="layui-btn" data-type="batchdel"><i
+                            class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>删除</button>
+                    }
+                    @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+                        <button class="layui-btn" data-type="ExportExcel"><i
+                            class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
+
+                    }
+                </div>
+
+                <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>
+                <script type="text/html" id="table-list-tools">
+                    @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
+                    }
+                    @if (RightInfo.Contains("," + right + "_delete,"))
+                    {
+                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
+                    }
+                    @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+
+                    }
+                </script>
+            </div>
+        </div>
+    </div>
+    <div id="excelForm" style="display:none; padding:20px;">
+        <div class="layui-tab-item layui-show">
+            <div class="layui-form-item">
+                <label class="layui-form-label">模板下载</label>
+                <div class="layui-form-mid layui-word-aux" id="excelTemp">
+                </div>
+            </div>
+            <div class="layui-form-item">
+                <label class="layui-form-label">excel文件</label>
+                <div class="layui-form-mid layui-word-aux">
+                    <div class="layui-upload">
+                        <input type="file" id="ExcelFile" name="ExcelFile" value="">
+                    </div>
+                    <div class="mt10" id="ExcelFileList">
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="layui-form-item ml10">
+            <div class="layui-input-block">
+                <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button>
+            </div>
+        </div>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script
+        src="/layuiadmin/modules_main/PreAmountRecord_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script>
+
+    </script>
+</body>
+
+</html>

+ 156 - 0
Areas/Admin/Views/MainServer/PreAmountRecord/Indexs.cshtml

@@ -0,0 +1,156 @@
+@{
+    string RightInfo = ViewBag.RightInfo as string;
+    string right = ViewBag.right as string;
+
+}
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <title>小分仓银行卡临额提现</title>
+    <meta name="renderer" content="webkit">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport"
+        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
+    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
+    <script src="/admin/js/jquery-1.10.1.min.js"></script>
+    <style>
+        .layui-input-inline {
+            width: 175px !important;
+        }
+
+        .layui-form-label {
+            width: 85px !important;
+        }
+
+        .layui-inline {
+            margin-right: 0px !important;
+        }
+
+        .w100 {
+            width: 100px !important;
+        }
+
+        .ml50 {
+            margin-left: 50px !important;
+        }
+    </style>
+</head>
+
+<body>
+    <div class="layui-fluid">
+        <div class="layui-card">
+            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
+                <div class="layui-form-item">
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创客真实姓名</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="UserIdRealName" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创客编号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="UserIdMakerCode" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创建时间</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" readonly name="CreateDateData" id="CreateDate"
+                                placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">状态</label>
+                        <div class="layui-input-inline">
+                            <select id="StatusSelect" name="StatusSelect" lay-search="">
+                                <option value="">全部...</option>
+                                <option value="0" selected="selected">待处理</option>
+                                <option value="2">处理中</option>
+                                <option value="1">成功</option>
+                                <option value="-1">失败</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-inline ml50">
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">
+                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
+                        </button>
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-searchall">
+                            <i class="layui-icon layui-icon-list layuiadmin-button-btn"></i>全部
+                        </button>
+                    </div>
+                </div>
+            </div>
+
+            <div class="layui-card-body">
+                <div style="padding-bottom: 10px;">
+                    @if (RightInfo.Contains("," + right + "_add,"))
+                    {
+                        <button class="layui-btn" data-type="add"><i
+                            class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加</button>
+                    }
+                    @if (RightInfo.Contains("," + right + "_delete,"))
+                    {
+                        <button class="layui-btn" data-type="batchdel"><i
+                            class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>删除</button>
+                    }
+                    @if (RightInfo.Contains("," + right + "_export,"))
+                    {
+                        <button class="layui-btn" data-type="ExportExcel"><i
+                            class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
+
+                    }
+                    @if (RightInfo.Contains("," + right + "_import,"))
+                    {
+                        <button class="layui-btn" data-type="ImportData"><i
+                            class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>导入结果</button>
+                    }
+                </div>
+
+                <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>
+                <script type="text/html" id="table-list-tools">
+                    @* @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
+                    }
+                    @if (RightInfo.Contains("," + right + "_delete,"))
+                    {
+                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
+                    } *@
+                </script>
+            </div>
+        </div>
+    </div>
+    <div id="excelForm" style="display:none; padding:20px;">
+        <div class="layui-tab-item layui-show">
+            <div class="layui-form-item">
+                <label class="layui-form-label">excel文件</label>
+                <div class="layui-form-mid layui-word-aux">
+                    <div class="layui-upload">
+                        <input type="file" id="ExcelFile" name="ExcelFile" value="">
+                    </div>
+                    <div class="mt10" id="ExcelFileList">
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="layui-form-item ml10">
+            <div class="layui-input-block">
+                <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button>
+            </div>
+        </div>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script
+        src="/layuiadmin/modules_main/PreCardAmountRecord_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script>
+
+    </script>
+</body>
+
+</html>

+ 1 - 0
Areas/Admin/Views/MainServer/UserAccountRecord/Index.cshtml

@@ -126,6 +126,7 @@
                                 <option value="125">软件服务费</option>
                                 <option value="126">机具货款退还</option>
                                 <option value="127">运营中心分仓奖励</option>
+                                <option value="130">预发临时额度退还</option>
                                 <option value="201">分期预扣款</option>
                                 <option value="202">创客预扣款</option>
                             </select>

+ 21 - 0
Models/ExportExcels.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models
+{
+    public partial class ExportExcels
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public string FileName { get; set; }
+        public int SysId { get; set; }
+        public string FileUrl { get; set; }
+    }
+}

+ 2 - 0
Models/Leaders.cs

@@ -16,5 +16,7 @@ namespace MySystem.Models
         public string SeoDescription { get; set; }
         public int LeaderLevel { get; set; }
         public int UserId { get; set; }
+        public DateTime? ExpiredDate { get; set; }
+        public DateTime? LastBuyDate { get; set; }
     }
 }

+ 1 - 0
Models/PosCoupons.cs

@@ -24,5 +24,6 @@ namespace MySystem.Models
         public int HelpProfitStatus { get; set; }
         public ulong HelpProfitFlag { get; set; }
         public int OpId { get; set; }
+        public int OrderId { get; set; }
     }
 }

+ 1 - 0
Models/ProductNorm.cs

@@ -30,5 +30,6 @@ namespace MySystem.Models
         public decimal Price { get; set; }
         public string IdList { get; set; }
         public string ColName { get; set; }
+        public int StartBuyCount { get; set; }
     }
 }

+ 5 - 0
Models/Products.cs

@@ -54,5 +54,10 @@ namespace MySystem.Models
         public string Contents { get; set; }
         public string Details { get; set; }
         public string ProductName { get; set; }
+        public int ProductKind { get; set; }
+        public int BannerSort { get; set; }
+        public string BannerPhoto { get; set; }
+        public ulong IsBanner { get; set; }
+        public int StartBuyCount { get; set; }
     }
 }

+ 71 - 22
Models/WebCMSEntities.cs

@@ -48,6 +48,7 @@ namespace MySystem.Models
         public virtual DbSet<CouponsForUser> CouponsForUser { get; set; }
         public virtual DbSet<CustomTagSet> CustomTagSet { get; set; }
         public virtual DbSet<ErpCompanys> ErpCompanys { get; set; }
+        public virtual DbSet<ExportExcels> ExportExcels { get; set; }
         public virtual DbSet<FileUpdateInfo> FileUpdateInfo { get; set; }
         public virtual DbSet<FluxProfitDetail> FluxProfitDetail { get; set; }
         public virtual DbSet<FluxProfitSummary> FluxProfitSummary { get; set; }
@@ -2731,6 +2732,48 @@ namespace MySystem.Models
                 entity.Property(e => e.Version).HasColumnType("int(11)");
             });
 
+            modelBuilder.Entity<ExportExcels>(entity =>
+            {
+                entity.Property(e => e.Id).HasColumnType("int(11)");
+
+                entity.Property(e => e.CreateDate).HasColumnType("datetime");
+
+                entity.Property(e => e.FileName)
+                    .HasColumnType("varchar(50)")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.FileUrl)
+                    .HasColumnType("varchar(500)")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.QueryCount).HasColumnType("int(11)");
+
+                entity.Property(e => e.SeoDescription)
+                    .HasColumnType("varchar(500)")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.SeoKeyword)
+                    .HasColumnType("varchar(200)")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.SeoTitle)
+                    .HasColumnType("varchar(100)")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.Sort).HasColumnType("int(11)");
+
+                entity.Property(e => e.Status).HasColumnType("int(11)");
+
+                entity.Property(e => e.SysId).HasColumnType("int(11)");
+
+                entity.Property(e => e.UpdateDate).HasColumnType("datetime");
+            });
+
             modelBuilder.Entity<FileUpdateInfo>(entity =>
             {
                 entity.HasComment("资源文件更新信息");
@@ -4170,6 +4213,10 @@ namespace MySystem.Models
 
                 entity.Property(e => e.CreateDate).HasColumnType("datetime");
 
+                entity.Property(e => e.ExpiredDate).HasColumnType("datetime");
+
+                entity.Property(e => e.LastBuyDate).HasColumnType("datetime");
+
                 entity.Property(e => e.LeaderLevel).HasColumnType("int(11)");
 
                 entity.Property(e => e.QueryCount).HasColumnType("int(11)");
@@ -7266,8 +7313,6 @@ namespace MySystem.Models
                 entity.HasKey(e => e.BankName)
                     .HasName("PRIMARY");
 
-                entity.HasComment("开户行对照表");
-
                 entity.Property(e => e.BankName)
                     .HasColumnType("varchar(200)")
                     .HasCharSet("utf8")
@@ -7751,8 +7796,6 @@ namespace MySystem.Models
                 entity.HasKey(e => e.OrderNo)
                     .HasName("PRIMARY");
 
-                entity.HasComment("订单号关联表");
-
                 entity.Property(e => e.OrderNo)
                     .HasColumnType("varchar(50)")
                     .HasCharSet("utf8")
@@ -7773,8 +7816,6 @@ namespace MySystem.Models
 
             modelBuilder.Entity<OrderProduct>(entity =>
             {
-                entity.HasComment("订单商品");
-
                 entity.HasIndex(e => e.OrderId)
                     .HasName("OrderProductIndex");
 
@@ -7870,8 +7911,6 @@ namespace MySystem.Models
 
             modelBuilder.Entity<OrderRefund>(entity =>
             {
-                entity.HasComment("退款申请");
-
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
                 entity.Property(e => e.Amount).HasColumnType("decimal(18,2)");
@@ -7953,8 +7992,6 @@ namespace MySystem.Models
 
             modelBuilder.Entity<OrderRefundReason>(entity =>
             {
-                entity.HasComment("退款原因");
-
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
                 entity.Property(e => e.CreateDate).HasColumnType("datetime");
@@ -8002,8 +8039,6 @@ namespace MySystem.Models
 
             modelBuilder.Entity<Orders>(entity =>
             {
-                entity.HasComment("创客订单");
-
                 entity.HasIndex(e => e.StoreId)
                     .HasName("OrdersStoreIdIndex");
 
@@ -8569,6 +8604,8 @@ namespace MySystem.Models
 
                 entity.Property(e => e.OpId).HasColumnType("int(11)");
 
+                entity.Property(e => e.OrderId).HasColumnType("int(11)");
+
                 entity.Property(e => e.QueryCount).HasColumnType("int(11)");
 
                 entity.Property(e => e.SeoDescription)
@@ -8782,8 +8819,6 @@ namespace MySystem.Models
 
             modelBuilder.Entity<PosMachinesTwo>(entity =>
             {
-                entity.HasComment("机具库");
-
                 entity.HasIndex(e => new { e.PosSn, e.BrandId })
                     .HasName("PosMachinesTwoIndex");
 
@@ -9721,6 +9756,8 @@ namespace MySystem.Models
 
                 entity.Property(e => e.Sort).HasColumnType("int(11)");
 
+                entity.Property(e => e.StartBuyCount).HasColumnType("int(11)");
+
                 entity.Property(e => e.Status).HasColumnType("int(11)");
 
                 entity.Property(e => e.Stock).HasColumnType("int(11)");
@@ -9856,10 +9893,17 @@ namespace MySystem.Models
 
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
+                entity.Property(e => e.BannerPhoto)
+                    .HasColumnType("varchar(200)")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.BannerSort).HasColumnType("int(11)");
+
                 entity.Property(e => e.BuyCount).HasColumnType("int(11)");
 
                 entity.Property(e => e.ColId)
-                    .HasColumnType("varchar(30)")
+                    .HasColumnType("varchar(100)")
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
@@ -9897,6 +9941,10 @@ namespace MySystem.Models
 
                 entity.Property(e => e.Integral).HasColumnType("decimal(18,2)");
 
+                entity.Property(e => e.IsBanner)
+                    .HasColumnType("bit(1)")
+                    .HasDefaultValueSql("b'0'");
+
                 entity.Property(e => e.IsLimit)
                     .HasColumnType("bit(1)")
                     .HasDefaultValueSql("b'0'");
@@ -9960,6 +10008,8 @@ namespace MySystem.Models
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.ProductKind).HasColumnType("int(11)");
+
                 entity.Property(e => e.ProductName)
                     .HasColumnType("varchar(100)")
                     .HasCharSet("utf8")
@@ -9993,6 +10043,8 @@ namespace MySystem.Models
 
                 entity.Property(e => e.SourcePrice).HasColumnType("decimal(18,2)");
 
+                entity.Property(e => e.StartBuyCount).HasColumnType("int(11)");
+
                 entity.Property(e => e.StartDate).HasColumnType("datetime");
 
                 entity.Property(e => e.Status).HasColumnType("int(11)");
@@ -14776,8 +14828,6 @@ namespace MySystem.Models
 
             modelBuilder.Entity<TradeDaySummary>(entity =>
             {
-                entity.HasComment("交易日汇总");
-
                 entity.HasIndex(e => new { e.UserId, e.TradeMonth, e.TradeDate, e.BrandId, e.QueryCount, e.VipFlag, e.PayType, e.SeoTitle })
                     .HasName("TradeDaySummaryIndex");
 
@@ -14961,7 +15011,8 @@ namespace MySystem.Models
 
             modelBuilder.Entity<TradeRecord>(entity =>
             {
-                entity.HasComment("交易记录");
+                entity.HasIndex(e => new { e.BrandId, e.UserId, e.MerchantId, e.MerNo, e.SnNo, e.CreateDate })
+                    .HasName("TradeRecordIndex");
 
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
@@ -17350,7 +17401,8 @@ namespace MySystem.Models
 
             modelBuilder.Entity<UserSnDelayChange>(entity =>
             {
-                entity.HasComment("创客机具延迟变动明细表");
+                entity.HasIndex(e => e.QueryCount)
+                    .HasName("UserSnDelayChangeIndex");
 
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
@@ -17954,8 +18006,6 @@ namespace MySystem.Models
 
             modelBuilder.Entity<Users>(entity =>
             {
-                entity.HasComment("创客");
-
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
                 entity.Property(e => e.AccessToken)
@@ -18137,7 +18187,6 @@ namespace MySystem.Models
 
                 entity.Property(e => e.MakerCode)
                     .HasColumnType("varchar(32)")
-                    .HasComment("创客编号")
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 

+ 0 - 4
Startup.cs

@@ -141,10 +141,6 @@ namespace MySystem
             ExcelHelper.Instance.Start();
             OpExcelHelper.Instance.Start();
             SycnUserMachineCountHelper.Instance.Start(); //重置创客机具数量
-
-
-            // InstallmentDeductionService.Instance.Start();//每月20号执行分期扣费
-            // TimeOutPosChargeService.Instance.StartDoChargeAmount();//每天执行预扣款
         }
 
 

+ 60 - 1
wwwroot/layuiadmin/modules_main/Leaders_Admin.js

@@ -58,6 +58,62 @@ layui.config({
         }
     });
 
+    var layLastBuyDateData = laydate.render({
+        elem: '#LastBuyDateData',
+        type: 'date',
+        range: true,
+        trigger: 'click',
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 1) {
+                if (endDate.month - date.month == 1 && endDate.date > date.date) {
+                    op = false;
+                    layLastBuyDateData.hint('日期范围请不要超过1个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layLastBuyDateData.hint('日期范围请不要超过1个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#LastBuyDateData').val(value);
+            }
+        }
+    });
+
+    var layExpiredDateData = laydate.render({
+        elem: '#ExpiredDateData',
+        type: 'date',
+        range: true,
+        trigger: 'click',
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 1) {
+                if (endDate.month - date.month == 1 && endDate.date > date.date) {
+                    op = false;
+                    layExpiredDateData.hint('日期范围请不要超过1个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layExpiredDateData.hint('日期范围请不要超过1个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#ExpiredDateData').val(value);
+            }
+        }
+    });
+
 
     //excel导入
     excel = layui.excel;
@@ -94,7 +150,10 @@ layui.config({
             , { field: 'Id', fixed: 'left', title: 'ID', width: 80, sort: true, unresize: true }
             , { field: 'UserIdMakerCode', width: 200, title: '创客编号', sort: true }
             , { field: 'UserIdRealName', width: 200, title: '真实姓名', sort: true }
-            , { field: 'CreateDate', width: 200, title: '创建时间', sort: true }
+            , { field: 'CreateDate', width: 200, title: '首次购买时间', sort: true }
+            , { field: 'LastBuyDate', width: 200, title: '最后购买时间', sort: true }
+            , { field: 'ExpiredDate', width: 200, title: '盟主到期时间', sort: true }
+            , { field: 'LeaderStatus', width: 200, title: '状态', sort: true }
             , { field: 'LeaderLevel', width: 200, title: '盟主等级', sort: true }
             , { field: 'LeaderReserve', width: 200, title: '盟主储蓄金', sort: true }
             , { field: 'LeaderBalanceAmount', width: 200, title: '盟主可提现余额', sort: true }

+ 413 - 0
wwwroot/layuiadmin/modules_main/PreAmountRecord_Admin.js

@@ -0,0 +1,413 @@
+var ExcelData, ExcelKind;
+function ConfirmImport() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/PreAmountRecord/Import?r=" + Math.random(1),
+        data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            if (data == "success") {
+                layer.msg("导入成功", { time: 2000 }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
+var excel;
+layui.config({
+    base: '/layuiadmin/' //静态资源所在路径
+}).extend({
+    myexcel: 'layui/lay/modules/excel',
+    index: 'lib/index' //主入口模块
+}).use(['index', 'table', 'excel', 'laydate'], function () {
+    var $ = layui.$
+        , form = layui.form
+        , table = layui.table;
+
+    //- 筛选条件-日期
+    var laydate = layui.laydate;
+    var layCreateDate = laydate.render({
+        elem: '#CreateDate',
+        type: 'date',
+        range: true,
+        trigger: 'click',
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 1) {
+                if (endDate.month - date.month == 1 && endDate.date > date.date) {
+                    op = false;
+                    layCreateDate.hint('日期范围请不要超过1个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layCreateDate.hint('日期范围请不要超过1个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#CreateDate').val(value);
+            }
+        }
+    });
+
+
+    //excel导入
+    excel = layui.excel;
+    $('#ExcelFile').change(function (e) {
+        var files = e.target.files;
+        excel.importExcel(files, {}, function (data) {
+            ExcelData = data[0].sheet1;
+        });
+    });
+
+    //监听单元格编辑
+    table.on('edit(LAY-list-manage)', function (obj) {
+        var value = obj.value //得到修改后的值
+            , data = obj.data //得到所在行所有键值
+            , field = obj.field; //得到字段
+        if (field == "Sort") {
+            $.ajax({
+                type: "POST",
+                url: "/Admin/PreAmountRecord/Sort?r=" + Math.random(1),
+                data: "Id=" + data.Id + "&Sort=" + value,
+                dataType: "text",
+                success: function (data) {
+                }
+            });
+        }
+    });
+
+    //列表数据
+    table.render({
+        elem: '#LAY-list-manage'
+        , url: '/Admin/PreAmountRecord/IndexData' //模拟接口
+        , cols: [[
+            { type: 'checkbox', fixed: 'left' }
+            , { field: 'Id', fixed: 'left', title: 'ID', width: 80, sort: true, unresize: true }
+            , { field: 'UserIdRealName', width: 200, title: '创客真实姓名', sort: true }
+            , { field: 'UserIdMakerCode', width: 200, title: '创客创客编号', sort: true }
+            , { field: 'CreateDate', width: 200, title: '创建时间', sort: true }
+            , { field: 'UseAmount', width: 200, title: '使用额度', sort: true }
+            , { field: 'BeforeAmount', width: 200, title: '使用前剩余额度', sort: true }
+            , { field: 'AfterAmount', width: 200, title: '使用后剩余额度', sort: true }
+            , { field: 'ChangeType', width: 200, title: '变动类别', sort: true }
+            , { field: 'OperateType', width: 200, title: '操作类别', sort: true }
+            , { field: 'PayMode', width: 200, title: '额度类别', sort: true }
+
+            // , { field: 'Sort', fixed: 'right', title: '排序', width: 80, edit: 'text' }
+            // , { title: '操作', align: 'center', fixed: 'right', toolbar: '#table-list-tools' }
+        ]]
+        , where: {
+
+        }
+        , page: true
+        , limit: 30
+        , height: 'full-220'
+        , text: '对不起,加载出现异常!'
+        , done: function (res, curr, count) {
+            $(".layui-none").text("无数据");
+        }
+    });
+
+    //监听工具条
+    table.on('tool(LAY-list-manage)', function (obj) {
+        var data = obj.data;
+        if (obj.event === 'del') {
+            var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/PreAmountRecord/Delete?r=" + Math.random(1),
+                    data: "Id=" + data.Id,
+                    dataType: "text",
+                    success: function (data) {
+                        if (data == "success") {
+                            obj.del();
+                            layer.close(index);
+                        } else {
+                            parent.layer.msg(data);
+                        }
+                    }
+                });
+            });
+        } else if (obj.event === 'edit') {
+            var tr = $(obj.tr);
+            var perContent = layer.open({
+                type: 2
+                , title: '分仓机具额度记录-编辑'
+                , content: 'Edit?Id=' + data.Id + ''
+                , maxmin: true
+                , area: ['500px', '450px']
+                , btn: ['确定', '取消']
+                , yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index]
+                        , submitID = 'LAY-list-front-submit'
+                        , submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    setTimeout(function () {
+                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                            var errObj = $(this).find('.layui-form-danger');
+                            if (errObj.length > 0) {
+                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                                submit.click();
+                            }
+                        });
+                    }, 300);
+
+
+
+
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/PreAmountRecord/Edit?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                layer.close(index); //关闭弹层
+                                if (data == "success") {
+                                    table.reload('LAY-list-manage'); //数据刷新
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+                , success: function (layero, index) {
+
+                }
+            });
+            layer.full(perContent);
+        }
+    });
+
+
+    //监听搜索
+    form.on('submit(LAY-list-front-search)', function (data) {
+        var field = data.field;
+
+        //执行重载
+        table.reload('LAY-list-manage', {
+            where: field,
+            page: {
+                curr: 1
+            }
+        });
+    });
+    form.on('submit(LAY-list-front-searchall)', function (data) {
+        table.reload('LAY-list-manage', {
+            where: null,
+            page: {
+                curr: 1
+            }
+        });
+    });
+
+    //事件
+    var active = {
+        batchdel: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage')
+                , data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要删除的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/PreAmountRecord/Delete?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        }
+        , add: function () {
+            var perContent = layer.open({
+                type: 2
+                , title: '分仓机具额度记录-添加'
+                , content: 'Add'
+                , maxmin: true
+                , area: ['500px', '450px']
+                , btn: ['确定', '取消']
+                , yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index]
+                        , submitID = 'LAY-list-front-submit'
+                        , submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    setTimeout(function () {
+                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                            var errObj = $(this).find('.layui-form-danger');
+                            if (errObj.length > 0) {
+                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                                submit.click();
+                            }
+                        });
+                    }, 300);
+
+
+
+
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/PreAmountRecord/Add?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                layer.close(index); //关闭弹层
+                                if (data == "success") {
+                                    table.reload('LAY-list-manage'); //数据刷新
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+            });
+            layer.full(perContent);
+        }
+        , ImportData: function () {
+            ExcelKind = 1;
+            layer.open({
+                type: 1,
+                title: '导入',
+                maxmin: false,
+                area: ['460px', '280px'],
+                content: $('#excelForm'),
+                cancel: function () {
+                }
+            });
+            $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
+        }
+        , ExportExcel: function () {
+            var userdata = '';
+            $(".layuiadmin-card-header-auto input").each(function (i) {
+                userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
+            });
+            $(".layuiadmin-card-header-auto select").each(function (i) {
+                userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
+            });
+            $.ajax({
+                type: "GET",
+                url: "/Admin/PreAmountRecord/ExportExcel?r=" + Math.random(1),
+                data: userdata,
+                dataType: "json",
+                success: function (data) {
+                    data.Obj.unshift(data.Fields);
+                    excel.exportExcel(data.Obj, data.Info, 'xlsx');
+                }
+            });
+        }
+        , Open: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage')
+                , data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要开启的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定要开启吗?', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/PreAmountRecord/Open?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        }
+        , Close: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage')
+                , data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要关闭的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定要关闭吗?', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/PreAmountRecord/Close?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        }
+    };
+
+    $('.layui-btn').on('click', function () {
+        var type = $(this).data('type');
+        active[type] ? active[type].call(this) : '';
+    });
+});

+ 420 - 0
wwwroot/layuiadmin/modules_main/PreCardAmountRecord_Admin.js

@@ -0,0 +1,420 @@
+var ExcelData, ExcelKind;
+function ConfirmImport() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/PreAmountRecord/Imports?r=" + Math.random(1),
+        data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            if (data == "success") {
+                layer.msg("导入结果成功", { time: 2000 }, function () {
+                    window.location.reload();
+                });
+            }  else if (data.indexOf("warning") == 0) {
+                var datalist = data.split('|');
+                layer.alert(datalist[0], { time: 20000 }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
+var excel;
+layui.config({
+    base: '/layuiadmin/' //静态资源所在路径
+}).extend({
+    myexcel: 'layui/lay/modules/excel',
+    index: 'lib/index' //主入口模块
+}).use(['index', 'table', 'excel', 'laydate'], function () {
+    var $ = layui.$
+        , form = layui.form
+        , table = layui.table;
+
+    //- 筛选条件-日期
+    var laydate = layui.laydate;
+    var layCreateDate = laydate.render({
+        elem: '#CreateDate',
+        type: 'date',
+        range: true,
+        trigger: 'click',
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 1) {
+                if (endDate.month - date.month == 1 && endDate.date > date.date) {
+                    op = false;
+                    layCreateDate.hint('日期范围请不要超过1个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layCreateDate.hint('日期范围请不要超过1个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#CreateDate').val(value);
+            }
+        }
+    });
+
+
+    //excel导入
+    excel = layui.excel;
+    $('#ExcelFile').change(function (e) {
+        var files = e.target.files;
+        excel.importExcel(files, {}, function (data) {
+            ExcelData = data[0].sheet1;
+        });
+    });
+
+    //监听单元格编辑
+    table.on('edit(LAY-list-manage)', function (obj) {
+        var value = obj.value //得到修改后的值
+            , data = obj.data //得到所在行所有键值
+            , field = obj.field; //得到字段
+        if (field == "Sort") {
+            $.ajax({
+                type: "POST",
+                url: "/Admin/PreAmountRecord/Sort?r=" + Math.random(1),
+                data: "Id=" + data.Id + "&Sort=" + value,
+                dataType: "text",
+                success: function (data) {
+                }
+            });
+        }
+    });
+
+    //列表数据
+    table.render({
+        elem: '#LAY-list-manage'
+        , url: '/Admin/PreAmountRecord/IndexsData' //模拟接口
+        , cols: [[
+            { type: 'checkbox', fixed: 'left' }
+            , { field: 'Id', fixed: 'left', title: 'ID', width: 80, sort: true, unresize: true }
+            , { field: 'Status', width: 200, title: '状态', sort: true }
+            , { field: 'UserIdRealName', width: 200, title: '创客真实姓名', sort: true }
+            , { field: 'UserIdMakerCode', width: 200, title: '创客编号', sort: true }
+            , { field: 'CreateDate', width: 200, title: '创建时间', sort: true }
+            , { field: 'UseAmount', width: 200, title: '申请提现临额', sort: true }
+            , { field: 'CertId', width: 200, title: '身份证号', sort: true }
+            , { field: 'SettleBankCardNo', width: 200, title: '银行卡号', sort: true }
+            , { field: 'SettleBankName', width: 200, title: '银行名称', sort: true }
+            , { field: 'Mobile', width: 200, title: '手机号', sort: true }
+            , { field: 'Type', width: 200, title: '交易类型', sort: true }
+
+            // , { field: 'Sort', fixed: 'right', title: '排序', width: 80, edit: 'text' }
+            // , { title: '操作', align: 'center', fixed: 'right', toolbar: '#table-list-tools' }
+        ]]
+        , where: {
+
+        }
+        , page: true
+        , limit: 30
+        , height: 'full-220'
+        , text: '对不起,加载出现异常!'
+        , done: function (res, curr, count) {
+            $(".layui-none").text("无数据");
+        }
+    });
+
+    //监听工具条
+    table.on('tool(LAY-list-manage)', function (obj) {
+        var data = obj.data;
+        if (obj.event === 'del') {
+            var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/PreAmountRecord/Delete?r=" + Math.random(1),
+                    data: "Id=" + data.Id,
+                    dataType: "text",
+                    success: function (data) {
+                        if (data == "success") {
+                            obj.del();
+                            layer.close(index);
+                        } else {
+                            parent.layer.msg(data);
+                        }
+                    }
+                });
+            });
+        } else if (obj.event === 'edit') {
+            var tr = $(obj.tr);
+            var perContent = layer.open({
+                type: 2
+                , title: '分仓机具额度记录-编辑'
+                , content: 'Edit?Id=' + data.Id + ''
+                , maxmin: true
+                , area: ['500px', '450px']
+                , btn: ['确定', '取消']
+                , yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index]
+                        , submitID = 'LAY-list-front-submit'
+                        , submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    setTimeout(function () {
+                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                            var errObj = $(this).find('.layui-form-danger');
+                            if (errObj.length > 0) {
+                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                                submit.click();
+                            }
+                        });
+                    }, 300);
+
+
+
+
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/PreAmountRecord/Edit?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                layer.close(index); //关闭弹层
+                                if (data == "success") {
+                                    table.reload('LAY-list-manage'); //数据刷新
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+                , success: function (layero, index) {
+
+                }
+            });
+            layer.full(perContent);
+        }
+    });
+
+
+    //监听搜索
+    form.on('submit(LAY-list-front-search)', function (data) {
+        var field = data.field;
+
+        //执行重载
+        table.reload('LAY-list-manage', {
+            where: field,
+            page: {
+                curr: 1
+            }
+        });
+    });
+    form.on('submit(LAY-list-front-searchall)', function (data) {
+        table.reload('LAY-list-manage', {
+            where: null,
+            page: {
+                curr: 1
+            }
+        });
+    });
+
+    //事件
+    var active = {
+        batchdel: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage')
+                , data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要删除的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/PreAmountRecord/Delete?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        }
+        , add: function () {
+            var perContent = layer.open({
+                type: 2
+                , title: '分仓机具额度记录-添加'
+                , content: 'Add'
+                , maxmin: true
+                , area: ['500px', '450px']
+                , btn: ['确定', '取消']
+                , yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index]
+                        , submitID = 'LAY-list-front-submit'
+                        , submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    setTimeout(function () {
+                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                            var errObj = $(this).find('.layui-form-danger');
+                            if (errObj.length > 0) {
+                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                                submit.click();
+                            }
+                        });
+                    }, 300);
+
+
+
+
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/PreAmountRecord/Add?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                layer.close(index); //关闭弹层
+                                if (data == "success") {
+                                    table.reload('LAY-list-manage'); //数据刷新
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+            });
+            layer.full(perContent);
+        }
+        , ImportData: function () {
+            ExcelKind = 1;
+            layer.open({
+                type: 1,
+                title: '导入',
+                maxmin: false,
+                area: ['460px', '280px'],
+                content: $('#excelForm'),
+                cancel: function () {
+                }
+            });
+            $("#excelTemp");
+        }
+        , ExportExcel: function () {
+            var userdata = '';
+            $(".layuiadmin-card-header-auto input").each(function (i) {
+                userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
+            });
+            $(".layuiadmin-card-header-auto select").each(function (i) {
+                userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
+            });
+            $.ajax({
+                type: "GET",
+                url: "/Admin/PreAmountRecord/ExportsExcel?r=" + Math.random(1),
+                data: userdata,
+                dataType: "json",
+                success: function (data) {
+                    data.Obj.unshift(data.Fields);
+                    excel.exportExcel(data.Obj, data.Info, 'xlsx');
+                    window.location.reload();
+                }
+            });
+        }
+        , BatchSetting: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage')
+                , data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要设置的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定批量设置完成记录吗?', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/PreAmountRecord/BatchSetting?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        }
+        , Close: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage')
+                , data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要关闭的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定要关闭吗?', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/PreAmountRecord/Close?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        }
+    };
+
+    $('.layui-btn').on('click', function () {
+        var type = $(this).data('type');
+        active[type] ? active[type].call(this) : '';
+    });
+});