ソースを参照

Merge branch 'feature-dgy-收支明细区分未使用额度和可提现额度' into feature-dgy-后台测试

DuGuYang 2 年 前
コミット
cdf5c5b449

+ 178 - 81
Areas/Admin/Controllers/MainServer/StoreHouseController.cs

@@ -553,43 +553,52 @@ namespace MySystem.Areas.Admin.Controllers
                     userAccountOld.TempAmountForBalance = 0;
                     if (sto.OpId > 0)
                     {
-                        var amount = opdb.UserAccount.FirstOrDefault(m => m.UserId == sto.OpId) ?? new OpModels.UserAccount();
-                        if (newdeposit > olddeposit)
+                        var UseAmount = 0.00M;
+                        var OperateType = 0;
+                        if (newdeposit >= olddeposit)
                         {
-                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
-                            {
-                                Version = 3,//1 未使用额度 2 可提现额度 3 关联分仓额度
-                                CreateDate = DateTime.Now,
-                                UserId = sto.OpId,
-                                SeoDescription = "分仓押金变更",
-                                OperateType = 1,
-                                UseAmount = newdeposit - olddeposit,
-                                BeforeAmount = amount.ValidAmount,
-                                AfterAmount = amount.ValidAmount + newdeposit - olddeposit,
-                                AfterTotalAmt = amount.TotalAmt,
-                                AfterValidForGetAmount = amount.ValidForGetAmount,
-                                AfterValidAmount = amount.ValidAmount + newdeposit - olddeposit,
-                            }).Entity;
+                            UseAmount = newdeposit - olddeposit;
+                            OperateType = 1;
                         }
                         if (newdeposit < olddeposit)
                         {
-                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                            UseAmount = olddeposit - newdeposit;
+                            OperateType = 2;
+                        }
+                        if (UseAmount > 0)
+                        {
+                            var amount = opdb.UserAccount.FirstOrDefault(m => m.UserId == sto.OpId) ?? new OpModels.UserAccount();
+                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord()
                             {
                                 Version = 3,//1 未使用额度 2 可提现额度 3 关联分仓额度
                                 CreateDate = DateTime.Now,
                                 UserId = sto.OpId,
                                 SeoDescription = "分仓押金变更",
-                                OperateType = 2,
-                                UseAmount = olddeposit - newdeposit,
+                                OperateType = OperateType,
+                                UseAmount = UseAmount,
                                 BeforeAmount = amount.ValidAmount,
-                                AfterAmount = amount.ValidAmount + newdeposit - olddeposit,
+                                AfterAmount = amount.ValidAmount + UseAmount,
                                 AfterTotalAmt = amount.TotalAmt,
                                 AfterValidForGetAmount = amount.ValidForGetAmount,
-                                AfterValidAmount = amount.ValidAmount + newdeposit - olddeposit
+                                AfterValidAmount = amount.ValidAmount + UseAmount,
+                            }).Entity;
+
+                            var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                            {
+                                AmountType = 3,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                CreateDate = DateTime.Now,
+                                Title = "分仓押金变更",
+                                UserId = sto.OpId, //运营中心Id
+                                                   // Operater = SysUserName + "-" + SysRealName,
+                                BeforeAmount = amount.ValidAmount,//使用前剩余额度
+                                AfterAmount = amount.ValidAmount + UseAmount,//使用后剩余额度
+                                ChangeAmount = UseAmount,//操作金额
+                                OperateType = OperateType,//操作类别
                             }).Entity;
+
+                            amount.ValidAmount -= sto.Deposit;
+                            amount.ValidAmount += data.Deposit;
                         }
-                        amount.ValidAmount -= sto.Deposit;
-                        amount.ValidAmount += data.Deposit;
                     }
                     var oldUserInfo = db.Users.FirstOrDefault(m => m.Id == sto.UserId) ?? new Users();
                     var newUserInfo = db.Users.FirstOrDefault(m => m.Id == user.UserId) ?? new Users();
@@ -628,43 +637,52 @@ namespace MySystem.Areas.Admin.Controllers
                 userAccount.StoreDeposit = data.Deposit;
                 if (sto.OpId > 0)
                 {
-                    var amount = opdb.UserAccount.FirstOrDefault(m => m.UserId == sto.OpId) ?? new OpModels.UserAccount();
-                    if (newdeposit > olddeposit)
+                    var UseAmount = 0.00M;
+                    var OperateType = 0;
+                    if (newdeposit >= olddeposit)
                     {
-                        var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
-                        {
-                            Version = 3,//1 未使用额度 2 可提现额度 3 关联分仓额度
-                            CreateDate = DateTime.Now,
-                            UserId = sto.OpId,
-                            SeoDescription = "分仓押金变更",
-                            OperateType = 1,
-                            UseAmount = newdeposit - olddeposit,
-                            BeforeAmount = amount.ValidAmount,
-                            AfterAmount = amount.ValidAmount + newdeposit - olddeposit,
-                            AfterTotalAmt = amount.TotalAmt,
-                            AfterValidForGetAmount = amount.ValidForGetAmount,
-                            AfterValidAmount = amount.ValidAmount + newdeposit - olddeposit
-                        }).Entity;
+                        UseAmount = newdeposit - olddeposit;
+                        OperateType = 1;
                     }
                     if (newdeposit < olddeposit)
                     {
-                        var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                        UseAmount = olddeposit - newdeposit;
+                        OperateType = 2;
+                    }
+                    if (UseAmount > 0)
+                    {
+                        var amount = opdb.UserAccount.FirstOrDefault(m => m.UserId == sto.OpId) ?? new OpModels.UserAccount();
+                        var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord()
                         {
                             Version = 3,//1 未使用额度 2 可提现额度 3 关联分仓额度
                             CreateDate = DateTime.Now,
                             UserId = sto.OpId,
                             SeoDescription = "分仓押金变更",
-                            OperateType = 2,
-                            UseAmount = olddeposit - newdeposit,
+                            OperateType = OperateType,
+                            UseAmount = UseAmount,
                             BeforeAmount = amount.ValidAmount,
-                            AfterAmount = amount.ValidAmount + newdeposit - olddeposit,
+                            AfterAmount = amount.ValidAmount + UseAmount,
                             AfterTotalAmt = amount.TotalAmt,
                             AfterValidForGetAmount = amount.ValidForGetAmount,
-                            AfterValidAmount = amount.ValidAmount + newdeposit - olddeposit
+                            AfterValidAmount = amount.ValidAmount + UseAmount,
                         }).Entity;
+
+                        var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                        {
+                            AmountType = 3,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                            CreateDate = DateTime.Now,
+                            Title = "分仓押金变更",
+                            UserId = sto.OpId, //运营中心Id
+                                               // Operater = SysUserName + "-" + SysRealName,
+                            BeforeAmount = amount.ValidAmount,//使用前剩余额度
+                            AfterAmount = amount.ValidAmount + UseAmount,//使用后剩余额度
+                            ChangeAmount = UseAmount,//操作金额
+                            OperateType = OperateType,//操作类别
+                        }).Entity;
+
+                        amount.ValidAmount -= sto.Deposit;
+                        amount.ValidAmount += data.Deposit;
                     }
-                    amount.ValidAmount -= sto.Deposit;
-                    amount.ValidAmount += data.Deposit;
                 }
                 foreach (var item in store)
                 {
@@ -2030,6 +2048,9 @@ namespace MySystem.Areas.Admin.Controllers
                     userAmount.ValidAmount += deposit;
                     opdb.SaveChanges();
                     decimal toAmount = userAmount.ValidAmount + userAmount.TotalAmt + userAmount.ValidForGetAmount;//新的总金额
+                    decimal ValidAmount = 0.00M;//关联分仓额度
+                    decimal TotalAmt = 0.00M; //未使用额度
+                    decimal ValidForGetAmount = 0.00M; //可提现额度
                     if (toAmount >= tamount)
                     {
                         foreach (var item in idlist)
@@ -2059,6 +2080,7 @@ namespace MySystem.Areas.Admin.Controllers
                                         posInfo.OpId = sysAdmin.UserId;
                                         if (userAmount.ValidAmount - amount >= 0)
                                         {
+                                            ValidAmount += amount;
                                             userAmount.ValidAmount -= amount;
                                             posInfo.OpReserve3 += amount; //关联分仓额度
                                             posInfo.OpReserve1 = 0; //未使用额度
@@ -2069,6 +2091,7 @@ namespace MySystem.Areas.Admin.Controllers
                                         {
                                             if (userAmount.TotalAmt - amount >= 0)
                                             {
+                                                TotalAmt += amount - userAmount.ValidAmount;
                                                 userAmount.TotalAmt -= amount - userAmount.ValidAmount;
                                                 posInfo.OpReserve3 = userAmount.ValidAmount;
                                                 posInfo.OpReserve1 = amount - userAmount.ValidAmount;
@@ -2079,6 +2102,7 @@ namespace MySystem.Areas.Admin.Controllers
                                             {
                                                 if (userAmount.ValidForGetAmount - amount >= 0)
                                                 {
+                                                    ValidForGetAmount += amount - userAmount.TotalAmt;
                                                     userAmount.ValidForGetAmount -= amount - userAmount.TotalAmt;
                                                     posInfo.OpReserve3 = 0;
                                                     posInfo.OpReserve1 = userAmount.TotalAmt;
@@ -2127,31 +2151,27 @@ namespace MySystem.Areas.Admin.Controllers
                         }
                         if (IsOk == "1")
                         {
-                            if (deposit > tamount)
+                            var OperateType = 0;
+                            var Amount = 0.00M;
+                            if (deposit >= tamount)
                             {
-                                var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
-                                {
-                                    CreateDate = DateTime.Now,
-                                    UserId = sysAdmin.UserId,
-                                    SeoDescription = "关联分仓",
-                                    OperateType = 1,
-                                    UseAmount = deposit - tamount,
-                                    BeforeAmount = TotalAmount,
-                                    AfterAmount = TotalAmount + deposit - tamount,
-                                    AfterTotalAmt = userAmount.TotalAmt,
-                                    AfterValidForGetAmount = userAmount.ValidForGetAmount,
-                                    AfterValidAmount = userAmount.ValidAmount,
-                                }).Entity;
+                                OperateType = 1;
+                                Amount = deposit - tamount;
                             }
                             if (deposit < tamount)
+                            {
+                                OperateType = 2;
+                                Amount = tamount - deposit;
+                            }
+                            if (Amount > 0)
                             {
                                 var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
                                 {
                                     CreateDate = DateTime.Now,
                                     UserId = sysAdmin.UserId,
                                     SeoDescription = "关联分仓",
-                                    OperateType = 2,
-                                    UseAmount = tamount - deposit,
+                                    OperateType = OperateType,
+                                    UseAmount = Amount,
                                     BeforeAmount = TotalAmount,
                                     AfterAmount = TotalAmount + deposit - tamount,
                                     AfterTotalAmt = userAmount.TotalAmt,
@@ -2159,6 +2179,46 @@ namespace MySystem.Areas.Admin.Controllers
                                     AfterValidAmount = userAmount.ValidAmount,
                                 }).Entity;
                             }
+
+                            for (int i = 1; i <= 3; i++)
+                            {
+                                var UseAmount = 0.00M;
+                                var BeforeAmount = 0.00M;
+                                var AfterAmount = 0.00M;
+                                if (i == 1)
+                                {
+                                    UseAmount = TotalAmt;
+                                    BeforeAmount = userAmount.TotalAmt + UseAmount;
+                                    AfterAmount = userAmount.TotalAmt;
+                                }
+                                if (i == 2)
+                                {
+                                    UseAmount = ValidForGetAmount;
+                                    BeforeAmount = userAmount.ValidForGetAmount + UseAmount;
+                                    AfterAmount = userAmount.ValidForGetAmount;
+                                }
+                                if (i == 3)
+                                {
+                                    UseAmount = ValidAmount;
+                                    BeforeAmount = userAmount.ValidAmount + UseAmount;
+                                    AfterAmount = userAmount.ValidAmount;
+                                }
+                                if (i > 0 && UseAmount > 0)
+                                {
+                                    var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                                    {
+                                        AmountType = i,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                        CreateDate = DateTime.Now,
+                                        Title = "关联分仓",
+                                        UserId = sysAdmin.UserId, //运营中心Id
+                                        Operater = SysUserName + "-" + SysRealName,
+                                        BeforeAmount = BeforeAmount,//使用前剩余额度
+                                        AfterAmount = AfterAmount,//使用后剩余额度
+                                        ChangeAmount = UseAmount,//操作金额
+                                        OperateType = OperateType,//操作类别
+                                    }).Entity;
+                                }
+                            }
                             opdb.SaveChanges();
                         }
                         sysAdmin.StoreCount += idlist.Count();//添加关联分仓数
@@ -2262,9 +2322,9 @@ namespace MySystem.Areas.Admin.Controllers
                     var amount = 0;
                     var tamount = 0;
                     decimal deposit = 0;
-                    decimal ValidAmount = 0;
-                    decimal TotalAmt = 0;
-                    decimal ValidForGetAmount = 0;
+                    decimal ValidAmount = 0.00M;//关联分仓额度
+                    decimal TotalAmt = 0.00M; //未使用额度
+                    decimal ValidForGetAmount = 0.00M; //可提现额度
                     var pCount = 0;
                     var userIds = "";
                     string error = "";
@@ -2353,31 +2413,28 @@ namespace MySystem.Areas.Admin.Controllers
 
                         sysAdmin.StoreCount -= idlist.Count();//减少关联分仓数
                         sysAdmin.TotalMachineCount -= pCount;//减少关联分仓机具数
-                        if (deposit > tamount)
+
+                        var OperateType = 0;
+                        var Amount = 0.00M;
+                        if (deposit >= tamount)
                         {
-                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
-                            {
-                                CreateDate = DateTime.Now,
-                                UserId = sysAdmin.UserId,
-                                SeoDescription = "取消关联分仓",
-                                OperateType = 2,
-                                UseAmount = deposit - tamount,
-                                BeforeAmount = TotalAmount,
-                                AfterAmount = TotalAmount - deposit + tamount,
-                                AfterTotalAmt = userAmount.TotalAmt,
-                                AfterValidForGetAmount = userAmount.ValidForGetAmount,
-                                AfterValidAmount = userAmount.ValidAmount,
-                            }).Entity;
+                            OperateType = 1;
+                            Amount = deposit - tamount;
                         }
                         if (deposit < tamount)
+                        {
+                            OperateType = 2;
+                            Amount = tamount - deposit;
+                        }
+                        if (Amount > 0)
                         {
                             var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
                             {
                                 CreateDate = DateTime.Now,
                                 UserId = sysAdmin.UserId,
                                 SeoDescription = "取消关联分仓",
-                                OperateType = 1,
-                                UseAmount = tamount - deposit,
+                                OperateType = OperateType,
+                                UseAmount = Amount,
                                 BeforeAmount = TotalAmount,
                                 AfterAmount = TotalAmount - deposit + tamount,
                                 AfterTotalAmt = userAmount.TotalAmt,
@@ -2385,6 +2442,46 @@ namespace MySystem.Areas.Admin.Controllers
                                 AfterValidAmount = userAmount.ValidAmount,
                             }).Entity;
                         }
+
+                        for (int i = 1; i <= 3; i++)
+                        {
+                            var UseAmount = 0.00M;
+                            var BeforeAmount = 0.00M;
+                            var AfterAmount = 0.00M;
+                            if (i == 1)
+                            {
+                                UseAmount = TotalAmt;
+                                BeforeAmount = userAmount.TotalAmt - UseAmount;
+                                AfterAmount = userAmount.TotalAmt;
+                            }
+                            if (i == 2)
+                            {
+                                UseAmount = ValidForGetAmount;
+                                BeforeAmount = userAmount.ValidForGetAmount - UseAmount;
+                                AfterAmount = userAmount.ValidForGetAmount;
+                            }
+                            if (i == 3)
+                            {
+                                UseAmount = ValidAmount;
+                                BeforeAmount = userAmount.ValidAmount - UseAmount;
+                                AfterAmount = userAmount.ValidAmount;
+                            }
+                            if (i > 0 && UseAmount > 0)
+                            {
+                                var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                                {
+                                    AmountType = i,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                    CreateDate = DateTime.Now,
+                                    Title = "取消关联分仓",
+                                    UserId = sysAdmin.UserId, //运营中心Id
+                                    Operater = SysUserName + "-" + SysRealName,
+                                    BeforeAmount = BeforeAmount,//使用前剩余额度
+                                    AfterAmount = AfterAmount,//使用后剩余额度
+                                    ChangeAmount = UseAmount,//操作金额
+                                    OperateType = OperateType,//操作类别
+                                }).Entity;
+                            }
+                        }
                         opdb.SaveChanges();
                     }
                     else

+ 277 - 60
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -1667,20 +1667,62 @@ namespace MySystem.Areas.Admin.Controllers
                         opUserAccount.ValidAmount += oldpos.OpReserve3;
                         opUserAccount.ValidForGetAmount += oldpos.OpReserve2;
                         opUserAccount.TotalAmt += oldpos.OpReserve1;
+                        if (oldpos.OpReserve1 > 0 || oldpos.OpReserve2 > 0 || oldpos.OpReserve3 > 0)
+                        {
+                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                            {
+                                CreateDate = DateTime.Now,
+                                UserId = oldpos.OpId,
+                                SeoDescription = "机具换绑",
+                                OperateType = 1,
+                                UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
+                                BeforeAmount = TotalAmount,
+                                AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
+                                AfterTotalAmt = opUserAccount.TotalAmt,
+                                AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
+                                AfterValidAmount = opUserAccount.ValidAmount,
+                            }).Entity;
+                        }
 
-                        var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                        for (int a = 1; a <= 3; a++)
                         {
-                            CreateDate = DateTime.Now,
-                            UserId = oldpos.OpId,
-                            SeoDescription = "机具换绑",
-                            OperateType = 1,
-                            UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
-                            BeforeAmount = TotalAmount,
-                            AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
-                            AfterTotalAmt = opUserAccount.TotalAmt,
-                            AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
-                            AfterValidAmount = opUserAccount.ValidAmount,
-                        }).Entity;
+                            var UseAmount = 0.00M;
+                            var BeforeAmount = 0.00M;
+                            var AfterAmount = 0.00M;
+                            if (a == 1)
+                            {
+                                UseAmount = oldpos.OpReserve1;
+                                BeforeAmount = opUserAccount.TotalAmt - UseAmount;
+                                AfterAmount = opUserAccount.TotalAmt;
+                            }
+                            if (a == 2)
+                            {
+                                UseAmount = oldpos.OpReserve2;
+                                BeforeAmount = opUserAccount.ValidForGetAmount - UseAmount;
+                                AfterAmount = opUserAccount.ValidForGetAmount;
+                            }
+                            if (a == 3)
+                            {
+                                UseAmount = oldpos.OpReserve3;
+                                BeforeAmount = opUserAccount.ValidAmount - UseAmount;
+                                AfterAmount = opUserAccount.ValidAmount;
+                            }
+                            if (a > 0 && UseAmount > 0)
+                            {
+                                var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                                {
+                                    AmountType = a,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                    CreateDate = DateTime.Now,
+                                    Title = "机具换绑",
+                                    UserId = oldpos.OpId, //运营中心Id
+                                    Operater = SysUserName + "-" + SysRealName,
+                                    BeforeAmount = BeforeAmount,//使用前剩余额度
+                                    AfterAmount = AfterAmount,//使用后剩余额度
+                                    ChangeAmount = UseAmount,//操作金额
+                                    OperateType = 1,//操作类别
+                                }).Entity;
+                            }
+                        }
 
                         oldpos.OpReserve1 = 0;
                         oldpos.OpReserve2 = 0;
@@ -1696,19 +1738,62 @@ namespace MySystem.Areas.Admin.Controllers
                             opUserAccount.ValidForGetAmount += newpos.OpReserve2;
                             opUserAccount.TotalAmt += newpos.OpReserve1;
 
-                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                            if (newpos.OpReserve1 > 0 || newpos.OpReserve2 > 0 || newpos.OpReserve3 > 0)
                             {
-                                CreateDate = DateTime.Now,
-                                UserId = newpos.OpId,
-                                SeoDescription = "机具换绑",
-                                OperateType = 1,
-                                UseAmount = newpos.OpReserve3 + newpos.OpReserve2 + newpos.OpReserve1,
-                                BeforeAmount = TotalAmount,
-                                AfterAmount = TotalAmount + newpos.OpReserve3 + newpos.OpReserve2 + newpos.OpReserve1,
-                                AfterTotalAmt = opUserAccount.TotalAmt,
-                                AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
-                                AfterValidAmount = opUserAccount.ValidAmount,
-                            }).Entity;
+                                var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                                {
+                                    CreateDate = DateTime.Now,
+                                    UserId = newpos.OpId,
+                                    SeoDescription = "机具换绑",
+                                    OperateType = 1,
+                                    UseAmount = newpos.OpReserve3 + newpos.OpReserve2 + newpos.OpReserve1,
+                                    BeforeAmount = TotalAmount,
+                                    AfterAmount = TotalAmount + newpos.OpReserve3 + newpos.OpReserve2 + newpos.OpReserve1,
+                                    AfterTotalAmt = opUserAccount.TotalAmt,
+                                    AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
+                                    AfterValidAmount = opUserAccount.ValidAmount,
+                                }).Entity;
+                            }
+
+                            for (int a = 1; a <= 3; a++)
+                            {
+                                var UseAmount = 0.00M;
+                                var BeforeAmount = 0.00M;
+                                var AfterAmount = 0.00M;
+                                if (a == 1)
+                                {
+                                    UseAmount = oldpos.OpReserve1;
+                                    BeforeAmount = opUserAccount.TotalAmt - UseAmount;
+                                    AfterAmount = opUserAccount.TotalAmt;
+                                }
+                                if (a == 2)
+                                {
+                                    UseAmount = oldpos.OpReserve2;
+                                    BeforeAmount = opUserAccount.ValidForGetAmount - UseAmount;
+                                    AfterAmount = opUserAccount.ValidForGetAmount;
+                                }
+                                if (a == 3)
+                                {
+                                    UseAmount = oldpos.OpReserve1;
+                                    BeforeAmount = opUserAccount.ValidAmount - UseAmount;
+                                    AfterAmount = opUserAccount.ValidAmount;
+                                }
+                                if (a > 0 && UseAmount > 0)
+                                {
+                                    var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                                    {
+                                        AmountType = a,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                        CreateDate = DateTime.Now,
+                                        Title = "机具换绑",
+                                        UserId = newpos.OpId, //运营中心Id
+                                        Operater = SysUserName + "-" + SysRealName,
+                                        BeforeAmount = BeforeAmount,//使用前剩余额度
+                                        AfterAmount = AfterAmount,//使用后剩余额度
+                                        ChangeAmount = UseAmount,//操作金额
+                                        OperateType = 1,//操作类别
+                                    }).Entity;
+                                }
+                            }
 
                             newpos.OpReserve1 = 0;
                             newpos.OpReserve2 = 0;
@@ -1928,24 +2013,68 @@ namespace MySystem.Areas.Admin.Controllers
                         if (newpos.OpId > 0)
                         {
                             var opUserAccount = opdb.UserAccount.FirstOrDefault(m => m.Sort > 0 && m.Id == oldpos.OpId && m.UserId == oldpos.OpId) ?? new OpModels.UserAccount();
+
+                            for (int a = 1; a <= 3; a++)
+                            {
+                                var UseAmount = 0.00M;
+                                var BeforeAmount = 0.00M;
+                                var AfterAmount = 0.00M;
+                                if (a == 1)
+                                {
+                                    UseAmount = oldpos.OpReserve1;
+                                    BeforeAmount = opUserAccount.TotalAmt;
+                                    AfterAmount = opUserAccount.TotalAmt + UseAmount;
+                                }
+                                if (a == 2)
+                                {
+                                    UseAmount = oldpos.OpReserve2;
+                                    BeforeAmount = opUserAccount.ValidForGetAmount;
+                                    AfterAmount = opUserAccount.ValidForGetAmount + UseAmount;
+                                }
+                                if (a == 3)
+                                {
+                                    UseAmount = oldpos.OpReserve1;
+                                    BeforeAmount = opUserAccount.ValidAmount;
+                                    AfterAmount = opUserAccount.ValidAmount + UseAmount;
+                                }
+                                if (a > 0 && UseAmount > 0)
+                                {
+                                    var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                                    {
+                                        AmountType = a,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                        CreateDate = DateTime.Now,
+                                        Title = "机具换绑",
+                                        UserId = newpos.OpId, //运营中心Id
+                                                              // Operater = SysUserName + "-" + SysRealName,
+                                        BeforeAmount = BeforeAmount,//使用前剩余额度
+                                        AfterAmount = AfterAmount,//使用后剩余额度
+                                        ChangeAmount = UseAmount,//操作金额
+                                        OperateType = 1,//操作类别
+                                    }).Entity;
+                                }
+                            }
+
                             decimal TotalAmount = opUserAccount.ValidAmount + opUserAccount.TotalAmt + opUserAccount.ValidForGetAmount;//旧的总金额
                             opUserAccount.ValidAmount += oldpos.OpReserve3;
                             opUserAccount.ValidForGetAmount += oldpos.OpReserve2;
                             opUserAccount.TotalAmt += oldpos.OpReserve1;
 
-                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                            if (oldpos.OpReserve1 > 0 || oldpos.OpReserve2 > 0 || oldpos.OpReserve3 > 0)
                             {
-                                CreateDate = DateTime.Now,
-                                UserId = oldpos.OpId,
-                                SeoDescription = "坏机换新",
-                                OperateType = 1,
-                                UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
-                                BeforeAmount = TotalAmount,
-                                AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
-                                AfterTotalAmt = opUserAccount.TotalAmt,
-                                AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
-                                AfterValidAmount = opUserAccount.ValidAmount,
-                            }).Entity;
+                                var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                                {
+                                    CreateDate = DateTime.Now,
+                                    UserId = oldpos.OpId,
+                                    SeoDescription = "坏机换新",
+                                    OperateType = 1,
+                                    UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
+                                    BeforeAmount = TotalAmount,
+                                    AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
+                                    AfterTotalAmt = opUserAccount.TotalAmt,
+                                    AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
+                                    AfterValidAmount = opUserAccount.ValidAmount,
+                                }).Entity;
+                            }
                         }
                         if (newpos.OpId == 0)
                         {
@@ -2190,24 +2319,68 @@ namespace MySystem.Areas.Admin.Controllers
                         if (newpos.OpId > 0)
                         {
                             var opUserAccount = opdb.UserAccount.FirstOrDefault(m => m.Sort > 0 && m.Id == oldpos.OpId && m.UserId == oldpos.OpId) ?? new OpModels.UserAccount();
+
+                            for (int a = 1; a <= 3; a++)
+                            {
+                                var UseAmount = 0.00M;
+                                var BeforeAmount = 0.00M;
+                                var AfterAmount = 0.00M;
+                                if (a == 1)
+                                {
+                                    UseAmount = oldpos.OpReserve1;
+                                    BeforeAmount = opUserAccount.TotalAmt;
+                                    AfterAmount = opUserAccount.TotalAmt + UseAmount;
+                                }
+                                if (a == 2)
+                                {
+                                    UseAmount = oldpos.OpReserve2;
+                                    BeforeAmount = opUserAccount.ValidForGetAmount;
+                                    AfterAmount = opUserAccount.ValidForGetAmount + UseAmount;
+                                }
+                                if (a == 3)
+                                {
+                                    UseAmount = oldpos.OpReserve1;
+                                    BeforeAmount = opUserAccount.ValidAmount;
+                                    AfterAmount = opUserAccount.ValidAmount + UseAmount;
+                                }
+                                if (a > 0 && UseAmount > 0)
+                                {
+                                    var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                                    {
+                                        AmountType = a,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                        CreateDate = DateTime.Now,
+                                        Title = "机具换绑",
+                                        UserId = newpos.OpId, //运营中心Id
+                                        Operater = SysUserName + "-" + SysRealName,
+                                        BeforeAmount = BeforeAmount,//使用前剩余额度
+                                        AfterAmount = AfterAmount,//使用后剩余额度
+                                        ChangeAmount = UseAmount,//操作金额
+                                        OperateType = 1,//操作类别
+                                    }).Entity;
+                                }
+                            }
+
                             decimal TotalAmount = opUserAccount.ValidAmount + opUserAccount.TotalAmt + opUserAccount.ValidForGetAmount;//旧的总金额
                             opUserAccount.ValidAmount += oldpos.OpReserve3;
                             opUserAccount.ValidForGetAmount += oldpos.OpReserve2;
                             opUserAccount.TotalAmt += oldpos.OpReserve1;
 
-                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                            if (oldpos.OpReserve1 > 0 || oldpos.OpReserve2 > 0 || oldpos.OpReserve3 > 0)
                             {
-                                CreateDate = DateTime.Now,
-                                UserId = oldpos.OpId,
-                                SeoDescription = "坏机换新",
-                                OperateType = 1,
-                                UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
-                                BeforeAmount = TotalAmount,
-                                AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
-                                AfterTotalAmt = opUserAccount.TotalAmt,
-                                AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
-                                AfterValidAmount = opUserAccount.ValidAmount,
-                            }).Entity;
+                                var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                                {
+                                    CreateDate = DateTime.Now,
+                                    UserId = oldpos.OpId,
+                                    SeoDescription = "坏机换新",
+                                    OperateType = 1,
+                                    UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
+                                    BeforeAmount = TotalAmount,
+                                    AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
+                                    AfterTotalAmt = opUserAccount.TotalAmt,
+                                    AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
+                                    AfterValidAmount = opUserAccount.ValidAmount,
+                                }).Entity;
+                            }
                         }
                         if (newpos.OpId == 0)
                         {
@@ -2441,24 +2614,68 @@ namespace MySystem.Areas.Admin.Controllers
                     if (newpos.OpId > 0)
                     {
                         var opUserAccount = opdb.UserAccount.FirstOrDefault(m => m.Sort > 0 && m.Id == oldpos.OpId && m.UserId == oldpos.OpId) ?? new OpModels.UserAccount();
+
+                        for (int a = 1; a <= 3; a++)
+                        {
+                            var UseAmount = 0.00M;
+                            var BeforeAmount = 0.00M;
+                            var AfterAmount = 0.00M;
+                            if (a == 1)
+                            {
+                                UseAmount = oldpos.OpReserve1;
+                                BeforeAmount = opUserAccount.TotalAmt;
+                                AfterAmount = opUserAccount.TotalAmt + UseAmount;
+                            }
+                            if (a == 2)
+                            {
+                                UseAmount = oldpos.OpReserve2;
+                                BeforeAmount = opUserAccount.ValidForGetAmount;
+                                AfterAmount = opUserAccount.ValidForGetAmount + UseAmount;
+                            }
+                            if (a == 3)
+                            {
+                                UseAmount = oldpos.OpReserve1;
+                                BeforeAmount = opUserAccount.ValidAmount;
+                                AfterAmount = opUserAccount.ValidAmount + UseAmount;
+                            }
+                            if (a > 0 && UseAmount > 0)
+                            {
+                                var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                                {
+                                    AmountType = a,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                    CreateDate = DateTime.Now,
+                                    Title = "机具换绑",
+                                    UserId = newpos.OpId, //运营中心Id
+                                    Operater = SysUserName + "-" + SysRealName,
+                                    BeforeAmount = BeforeAmount,//使用前剩余额度
+                                    AfterAmount = AfterAmount,//使用后剩余额度
+                                    ChangeAmount = UseAmount,//操作金额
+                                    OperateType = 1,//操作类别
+                                }).Entity;
+                            }
+                        }
+
                         decimal TotalAmount = opUserAccount.ValidAmount + opUserAccount.TotalAmt + opUserAccount.ValidForGetAmount;//旧的总金额
                         opUserAccount.ValidAmount += oldpos.OpReserve3;
                         opUserAccount.ValidForGetAmount += oldpos.OpReserve2;
                         opUserAccount.TotalAmt += oldpos.OpReserve1;
 
-                        var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                        if (oldpos.OpReserve1 > 0 || oldpos.OpReserve2 > 0 || oldpos.OpReserve3 > 0)
                         {
-                            CreateDate = DateTime.Now,
-                            UserId = oldpos.OpId,
-                            SeoDescription = "创客跨品牌换机",
-                            OperateType = 1,
-                            UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
-                            BeforeAmount = TotalAmount,
-                            AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
-                            AfterTotalAmt = opUserAccount.TotalAmt,
-                            AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
-                            AfterValidAmount = opUserAccount.ValidAmount,
-                        }).Entity;
+                            var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
+                            {
+                                CreateDate = DateTime.Now,
+                                UserId = oldpos.OpId,
+                                SeoDescription = "创客跨品牌换机",
+                                OperateType = 1,
+                                UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
+                                BeforeAmount = TotalAmount,
+                                AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
+                                AfterTotalAmt = opUserAccount.TotalAmt,
+                                AfterValidForGetAmount = opUserAccount.ValidForGetAmount,
+                                AfterValidAmount = opUserAccount.ValidAmount,
+                            }).Entity;
+                        }
                     }
                     if (newpos.OpId == 0)
                     {

+ 41 - 1
Areas/Admin/Controllers/OperateServer/StoreMachineApplyOperateController.cs

@@ -411,6 +411,46 @@ namespace MySystem.Areas.Admin.Controllers
                         ApplyId = query.Id,
                     }).Entity;
 
+                    for (int a = 1; a <= 3; a++)
+                    {
+                        var UseAmount = 0.00M;
+                        var BeforeAmount = 0.00M;
+                        var AfterAmount = 0.00M;
+                        if (a == 1)
+                        {
+                            UseAmount = TotalAmt;
+                            BeforeAmount = users.TotalAmt + UseAmount;
+                            AfterAmount = users.TotalAmt;
+                        }
+                        if (a == 2)
+                        {
+                            UseAmount = ValidForGetAmount;
+                            BeforeAmount = users.ValidForGetAmount + UseAmount;
+                            AfterAmount = users.ValidForGetAmount;
+                        }
+                        if (a == 3)
+                        {
+                            UseAmount = ValidAmount;
+                            BeforeAmount = users.ValidAmount + UseAmount;
+                            AfterAmount = users.ValidAmount;
+                        }
+                        if (a > 0 && UseAmount > 0)
+                        {
+                            var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                            {
+                                AmountType = a,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                                CreateDate = DateTime.Now,
+                                Title = "机具申请驳回",
+                                UserId = query.UserId, //运营中心Id
+                                Operater = SysUserName + "-" + SysRealName,
+                                BeforeAmount = BeforeAmount,//使用前剩余额度
+                                AfterAmount = AfterAmount,//使用后剩余额度
+                                ChangeAmount = UseAmount,//操作金额
+                                OperateType = 1,//操作类别
+                            }).Entity;
+                        }
+                    }
+
                     users.ValidAmount += ValidAmount;
                     users.TotalAmt += TotalAmt;
                     users.ValidForGetAmount += ValidForGetAmount;
@@ -636,7 +676,7 @@ namespace MySystem.Areas.Admin.Controllers
 
                 var kqProducts = db.KqProducts.FirstOrDefault(m => m.Id == BrandId) ?? new Models.KqProducts();
                 FromStoreId = kqProducts.MainStoreId;
-                
+
                 CheckSendInfo items = checksendInfos.FirstOrDefault(m => m.BrandId == BrandId);
                 if (items == null)
                 {

+ 70 - 36
Areas/Admin/Controllers/OperateServer/SysAdminOperateController.cs

@@ -602,6 +602,7 @@ namespace MySystem.Areas.Admin.Controllers
             decimal BeforeAmount = account.TotalAmt + account.ValidAmount + account.ValidForGetAmount; //变更前总金额
 
             int OperateType = 0;
+            var bAmount = account.ValidForGetAmount;
             var description = "";
             if (Kind == 1)
             {
@@ -619,25 +620,41 @@ namespace MySystem.Areas.Admin.Controllers
             }
             decimal AfterAmount = account.TotalAmt + account.ValidAmount + account.ValidForGetAmount; //变更后总金额
 
-            AmountRecord amountRecord = opdb.AmountRecord.Add(new AmountRecord()
+            if (OperateType > 0 && decimal.Parse(OperationAmount) > 0)
             {
-                Version = 1,//1 未使用额度 2 可提现额度 3 关联分仓额度
-                CreateDate = DateTime.Now,
-                SeoKeyword = Note,
-                SeoDescription = description,
-                UserId = sysAdmin.UserId, //运营中心Id
-                CreateMan = SysUserName + "-" + SysRealName,
-                UseAmount = decimal.Parse(OperationAmount),//操作金额
-                BeforeAmount = BeforeAmount,//使用前剩余额度
-                AfterAmount = AfterAmount,//使用后剩余额度
-                AfterTotalAmt = account.TotalAmt,
-                AfterValidForGetAmount = account.ValidForGetAmount,
-                AfterValidAmount = account.ValidAmount,
-                OperateType = OperateType,//操作类别
-            }).Entity;
-            opdb.SaveChanges();
-            AddSysLog(data.Id.ToString(), "SysAdmin", "EditAmt");
-            opdb.SaveChanges();
+                AmountRecord amountRecord = opdb.AmountRecord.Add(new AmountRecord()
+                {
+                    Version = 1,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                    CreateDate = DateTime.Now,
+                    SeoKeyword = Note,
+                    SeoDescription = description,
+                    UserId = sysAdmin.UserId, //运营中心Id
+                    CreateMan = SysUserName + "-" + SysRealName,
+                    UseAmount = decimal.Parse(OperationAmount),//操作金额
+                    BeforeAmount = BeforeAmount,//使用前剩余额度
+                    AfterAmount = AfterAmount,//使用后剩余额度
+                    AfterTotalAmt = account.TotalAmt,
+                    AfterValidForGetAmount = account.ValidForGetAmount,
+                    AfterValidAmount = account.ValidAmount,
+                    OperateType = OperateType,//操作类别
+                }).Entity;
+
+                AmountChangeRecord amountChangeRecord = opdb.AmountChangeRecord.Add(new AmountChangeRecord()
+                {
+                    AmountType = 1,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                    CreateDate = DateTime.Now,
+                    Title = description,
+                    Remark = Note,
+                    UserId = sysAdmin.UserId, //运营中心Id
+                    Operater = SysUserName + "-" + SysRealName,
+                    BeforeAmount = bAmount,//使用前剩余额度
+                    AfterAmount = account.TotalAmt,//使用后剩余额度
+                    ChangeAmount = decimal.Parse(OperationAmount),//操作金额
+                    OperateType = OperateType,//操作类别
+                }).Entity;
+                opdb.SaveChanges();
+                AddSysLog(data.Id.ToString(), "SysAdmin", "EditAmt");
+            }
             return "success";
         }
 
@@ -670,6 +687,7 @@ namespace MySystem.Areas.Admin.Controllers
             }
             decimal BeforeAmount = account.TotalAmt + account.ValidAmount + account.ValidForGetAmount; //变更前总金额
             int OperateType = 0;
+            var bAmount = account.ValidForGetAmount;
             var description = "";
             if (Kind == 1 && decimal.Parse(OperationAmount) <= account.ValidForGetAmount)
             {
@@ -688,25 +706,41 @@ namespace MySystem.Areas.Admin.Controllers
                 description = "系统增加";
             }
             decimal AfterAmount = account.TotalAmt + account.ValidAmount + account.ValidForGetAmount; //变更后总金额
-            AmountRecord amountRecord = opdb.AmountRecord.Add(new AmountRecord()
+            if (OperateType > 0 && decimal.Parse(OperationAmount) > 0)
             {
-                Version = 2,//1 未使用额度 2 可提现额度 3 关联分仓额度
-                CreateDate = DateTime.Now,
-                SeoKeyword = Note,
-                SeoDescription = description,
-                UserId = sysAdmin.UserId, //运营中心Id
-                CreateMan = SysUserName + "-" + SysRealName,
-                UseAmount = decimal.Parse(OperationAmount),//操作金额
-                BeforeAmount = BeforeAmount,//使用前剩余额度
-                AfterAmount = AfterAmount,//使用后剩余额度
-                AfterTotalAmt = account.TotalAmt,
-                AfterValidForGetAmount = account.ValidForGetAmount,
-                AfterValidAmount = account.ValidAmount,
-                OperateType = OperateType,//操作类别
-            }).Entity;
-            opdb.SaveChanges();
-            AddSysLog(data.Id.ToString(), "SysAdmin", "EditBalance");
-            opdb.SaveChanges();
+                AmountRecord amountRecord = opdb.AmountRecord.Add(new AmountRecord()
+                {
+                    Version = 2,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                    CreateDate = DateTime.Now,
+                    SeoKeyword = Note,
+                    SeoDescription = description,
+                    UserId = sysAdmin.UserId, //运营中心Id
+                    CreateMan = SysUserName + "-" + SysRealName,
+                    UseAmount = decimal.Parse(OperationAmount),//操作金额
+                    BeforeAmount = BeforeAmount,//使用前剩余额度
+                    AfterAmount = AfterAmount,//使用后剩余额度
+                    AfterTotalAmt = account.TotalAmt,
+                    AfterValidForGetAmount = account.ValidForGetAmount,
+                    AfterValidAmount = account.ValidAmount,
+                    OperateType = OperateType,//操作类别
+                }).Entity;
+
+                AmountChangeRecord amountChangeRecord = opdb.AmountChangeRecord.Add(new AmountChangeRecord()
+                {
+                    AmountType = 2,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                    CreateDate = DateTime.Now,
+                    Title = description,
+                    Remark = Note,
+                    UserId = sysAdmin.UserId, //运营中心Id
+                    Operater = SysUserName + "-" + SysRealName,
+                    BeforeAmount = bAmount,//使用前剩余额度
+                    AfterAmount = account.ValidForGetAmount,//使用后剩余额度
+                    ChangeAmount = decimal.Parse(OperationAmount),//操作金额
+                    OperateType = OperateType,//操作类别
+                }).Entity;
+                AddSysLog(data.Id.ToString(), "SysAdmin", "EditBalance");
+                opdb.SaveChanges();
+            }
             return "success";
         }
 

+ 13 - 0
Areas/Admin/Controllers/OperateServer/UserCashRecordOperateController.cs

@@ -551,6 +551,19 @@ namespace MySystem.Areas.Admin.Controllers
                         AfterValidAmount = account.ValidAmount,
                         OperateType = 1,
                     });
+
+                    var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                    {
+                        AmountType = 2,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                        CreateDate = DateTime.Now,
+                        Title = "机具申请驳回",
+                        UserId = edit.UserId, //运营中心Id
+                        Operater = SysUserName + "-" + SysRealName,
+                        BeforeAmount = account.ValidForGetAmount - TradeAmount,//使用前剩余额度
+                        AfterAmount = account.ValidForGetAmount,//使用后剩余额度
+                        ChangeAmount = TradeAmount,//操作金额
+                        OperateType = 1,//操作类别
+                    }).Entity;
                     opdb.SaveChanges();
                 }
 

+ 13 - 0
Areas/Admin/Controllers/OperateServer/UserCashRecordOperatesController.cs

@@ -608,6 +608,19 @@ namespace MySystem.Areas.Admin.Controllers
                         AfterValidForGetAmount = account.ValidForGetAmount,
                         AfterValidAmount = account.ValidAmount,
                     });
+
+                    var amountChangeRecord = opdb.AmountChangeRecord.Add(new OpModels.AmountChangeRecord()
+                    {
+                        AmountType = 2,//1 未使用额度 2 可提现额度 3 关联分仓额度
+                        CreateDate = DateTime.Now,
+                        Title = "机具申请驳回",
+                        UserId = edit.UserId, //运营中心Id
+                        Operater = SysUserName + "-" + SysRealName,
+                        BeforeAmount = account.ValidForGetAmount - TradeAmount,//使用前剩余额度
+                        AfterAmount = account.ValidForGetAmount,//使用后剩余额度
+                        ChangeAmount = TradeAmount,//操作金额
+                        OperateType = 1,//操作类别
+                    }).Entity;
                     opdb.SaveChanges();
                 }
 

+ 24 - 0
OpModels/AmountChangeRecord.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.OpModels
+{
+    public partial class AmountChangeRecord
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string Remark { get; set; }
+        public string Title { get; set; }
+        public int OperateType { get; set; }
+        public decimal ChangeAmount { get; set; }
+        public decimal AfterAmount { get; set; }
+        public decimal BeforeAmount { get; set; }
+        public int AmountType { get; set; }
+        public int UserId { get; set; }
+        public string Operater { get; set; }
+    }
+}

+ 70 - 0
OpModels/WebCMSEntities.cs

@@ -18,6 +18,7 @@ namespace MySystem.OpModels
         public virtual DbSet<ActMerDaySummary> ActMerDaySummary { get; set; }
         public virtual DbSet<ActMerMonthSummary> ActMerMonthSummary { get; set; }
         public virtual DbSet<Advertisment> Advertisment { get; set; }
+        public virtual DbSet<AmountChangeRecord> AmountChangeRecord { get; set; }
         public virtual DbSet<AmountRecord> AmountRecord { get; set; }
         public virtual DbSet<Col> Col { get; set; }
         public virtual DbSet<MachineApplyOpRecord> MachineApplyOpRecord { get; set; }
@@ -243,6 +244,75 @@ namespace MySystem.OpModels
                 entity.Property(e => e.Version).HasColumnType("int(11)");
             });
 
+            modelBuilder.Entity<AmountChangeRecord>(entity =>
+            {
+                entity.HasComment("合伙人额度变动记录表");
+
+                entity.Property(e => e.Id).HasColumnType("int(11)");
+
+                entity.Property(e => e.AfterAmount)
+                    .HasColumnType("decimal(18,2)")
+                    .HasComment("变更后金额");
+
+                entity.Property(e => e.AmountType)
+                    .HasColumnType("int(11)")
+                    .HasComment("额度类型");
+
+                entity.Property(e => e.BeforeAmount)
+                    .HasColumnType("decimal(18,2)")
+                    .HasComment("变更前金额");
+
+                entity.Property(e => e.ChangeAmount)
+                    .HasColumnType("decimal(18,2)")
+                    .HasComment("变更金额");
+
+                entity.Property(e => e.CreateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("创建时间");
+
+                entity.Property(e => e.OperateType)
+                    .HasColumnType("int(11)")
+                    .HasComment("变动类型");
+
+                entity.Property(e => e.Operater)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("操作人")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.Remark)
+                    .HasColumnType("varchar(100)")
+                    .HasComment("备注")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.Sort)
+                    .HasColumnType("int(11)")
+                    .HasComment("排序序号");
+
+                entity.Property(e => e.Status)
+                    .HasColumnType("int(11)")
+                    .HasComment("状态");
+
+                entity.Property(e => e.Title)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("变动分类标题")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.UpdateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("修改时间");
+
+                entity.Property(e => e.UserId)
+                    .HasColumnType("int(11)")
+                    .HasComment("创客Id");
+
+                entity.Property(e => e.Version)
+                    .HasColumnType("int(11)")
+                    .HasComment("版本号");
+            });
+
             modelBuilder.Entity<AmountRecord>(entity =>
             {
                 entity.Property(e => e.Id).HasColumnType("int(11)");