Sfoglia il codice sorgente

操作盟主可提现余额更换表

lichunlei 2 anni fa
parent
commit
09d10ab275
1 ha cambiato i file con 36 aggiunte e 2 eliminazioni
  1. 36 2
      AppStart/Helper/AlipayPayBack2Service.cs

+ 36 - 2
AppStart/Helper/AlipayPayBack2Service.cs

@@ -254,7 +254,7 @@ namespace MySystem
                                                     //扣减备用金
                                                     OpReserve(db, order, puser.Id, order.TotalPrice, 2, order.UserId, "购机奖励");
                                                     //返回到余额
-                                                    OpAccount(db, order, puser.Id, order.TotalPrice / pro.ProductCount, pro.ProductCount);
+                                                    OpLeaderAccount(db, order, puser.Id, order.TotalPrice / pro.ProductCount, pro.ProductCount);
                                                 }
                                                 PUserId = 0;
                                             }
@@ -330,7 +330,7 @@ namespace MySystem
                                             //扣减备用金
                                             OpReserve(db, order, puser.Id, order.TotalPrice, 2, order.UserId, "购机奖励");
                                             //返回到余额
-                                            OpAccount(db, order, puser.Id, order.TotalPrice / pro.ProductCount, pro.ProductCount);
+                                            OpLeaderAccount(db, order, puser.Id, order.TotalPrice / pro.ProductCount, pro.ProductCount);
                                             leaderFlag = puser.LeaderLevel;
                                         }
                                         //如果是大盟主,则标记大盟主标签
@@ -477,6 +477,40 @@ namespace MySystem
             }).Entity;
             db.SaveChanges();
         }
+        //操作盟主可提现余额
+        public void OpLeaderAccount(WebCMSEntities db, Orders order, int UserId, decimal Money, int Count = 1)
+        {
+            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();
+            }
+            int ChangeType = 0;
+            if(Money == 600)
+            {
+                ChangeType = 117;
+            }
+            decimal BeforeLeaderBalanceAmount = account.LeaderBalanceAmount; //变更前余额
+            account.LeaderBalanceAmount += Money * Count;
+            decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后余额
+            LeaderAccountRecord leaderAccountRecord = db.LeaderAccountRecord.Add(new LeaderAccountRecord()
+            {
+                CreateDate = DateTime.Now,
+                UpdateDate = DateTime.Now,
+                UserId = UserId, //创客
+                ChangeType = ChangeType, //变动类型
+                ChangeAmount = Money * Count, //变更金额
+                BeforeBalanceAmount = BeforeLeaderBalanceAmount, //变更前余额
+                AfterBalanceAmount = AfterLeaderBalanceAmount, //变更后余额
+                QueryCount = order.Id,
+            }).Entity;
+            db.SaveChanges();
+        }
         public void DirectPrize(WebCMSEntities db, int OrderId, int UserId, int Count = 1)
         {
             UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);