Преглед изворни кода

Merge branch '盟主可提余额' into develop

lichunlei пре 2 година
родитељ
комит
5ff2e38e04
1 измењених фајлова са 43 додато и 3 уклоњено
  1. 43 3
      AppStart/Helper/AlipayPayBack2Service.cs

+ 43 - 3
AppStart/Helper/AlipayPayBack2Service.cs

@@ -209,6 +209,13 @@ namespace MySystem
                                             //返回到余额
                                             // OpAccount(db, order, order.UserId, order.TotalPrice / pro.ProductCount, pro.ProductCount);
                                         }
+                                        else
+                                        {
+                                            //扣减备用金
+                                            OpReserve(db, order, order.UserId, order.TotalPrice, 2, 0, "商城购机");
+                                            //返回到余额
+                                            OpLeaderAccount(db, order, order.UserId, order.TotalPrice / pro.ProductCount, pro.ProductCount);
+                                        }
                                     }
                                     //获得100元奖励
                                     OpAccount(db, order, order.UserId, 100, pro.ProductCount);
@@ -254,7 +261,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 +337,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;
                                         }
                                         //如果是大盟主,则标记大盟主标签
@@ -355,7 +362,6 @@ namespace MySystem
                         function.WriteLog("\r\n\r\n", "推荐下单奖励监控日志");
                     }
 
-
                     //推荐王
                     if(pro.ProductId == 29)
                     {
@@ -477,6 +483,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);