Pārlūkot izejas kodu

激活返还运营中心额度

lichunlei 2 gadi atpakaļ
vecāks
revīzija
ae6869f035

+ 1 - 1
AppStart/Helper/AlipayPayBack2Service.cs

@@ -829,7 +829,7 @@ namespace MySystem
 
 
         //操作运营中心额度
-        public void OperateAmountChange(OpModels.WebCMSEntities db, Orders order, int UserId, decimal Money, int OperateType, string Remark = "储备金购买")
+        public void OperateAmountChange(OpModels.WebCMSEntities db, Orders order, int UserId, decimal Money, int OperateType, string Remark = "")
         {
             OpModels.UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
             if (account == null)

+ 83 - 0
AppStart/Helper/Operate/SetDepositPostService.cs

@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using LitJson;
+using System.Linq;
+using System.Data;
+using System.Threading;
+using MySystem.OpModels;
+
+namespace MySystem
+{
+    public class OperateAmountService
+    {
+        public readonly static OperateAmountService Instance = new OperateAmountService();
+        private OperateAmountService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(dosomething);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void dosomething()
+        {
+            while (true)
+            {
+                string data = RedisDbconn.Instance.RPop<string>("OperateAmountQueue");
+                if (!string.IsNullOrEmpty(data))
+                {
+                    try
+                    {
+                        WebCMSEntities db = new WebCMSEntities();
+                        function.WriteLog(DateTime.Now.ToString() + "\r\n" + data + "\r\n\r\n", "运营中心返额度日志");
+                        JsonData jsonObj = JsonMapper.ToObject(data);
+                        int UserId = int.Parse(function.CheckInt(jsonObj["UserId"].ToString())); //运营中心所属人创客Id
+                        int DataId = int.Parse(function.CheckInt(jsonObj["DataId"].ToString())); //机具Id或机具券Id
+                        int Kind = int.Parse(function.CheckInt(jsonObj["Kind"].ToString())); //1-机具,2-机具券
+                        decimal Amount = decimal.Parse(function.CheckNum(jsonObj["Amount"].ToString()));
+                        
+                        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 BeforeAmount = account.ValidAmount; //变更前总金额
+                        account.ValidAmount += Amount;
+                        decimal AfterAmount = account.ValidAmount; //变更后总金额
+                        AmountRecord add = db.AmountRecord.Add(new AmountRecord()
+                        {
+                            CreateDate = DateTime.Now,
+                            UpdateDate = DateTime.Now,
+                            OperateType = 1,
+                            AfterAmount = AfterAmount,
+                            BeforeAmount = BeforeAmount,
+                            UseAmount = Amount,
+                            UserId = UserId,
+                            ApplyId = DataId,
+                            SeoDescription = Kind == 1 ? "机具激活返还" : "机具券兑换返还",
+                        }).Entity;
+                        db.SaveChanges();
+
+                        db.Dispose();
+                    }
+                    catch (Exception ex)
+                    {
+                        function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "运营中心返额度异常");
+                    }
+                }
+                else
+                {
+                    Thread.Sleep(5000);
+                }
+            }
+        }
+    }
+}

+ 6 - 0
AppStart/Helper/SycnSpServer/SycnSpTradeService.cs

@@ -291,6 +291,12 @@ namespace MySystem
                                                 // 推荐王逻辑(激活)
                                                 string SendData = "{\"Kind\":\"3\",\"Data\":{\"UserId\":\"" + pos.BuyUserId + "\",\"PosId\":\"" + pos.Id + "\",\"TradeMonth\":\"" + DateTime.Now.ToString("yyyyMM") + "\"}}";
                                                 RedisDbconn.Instance.AddList("RecommendActStatQueue", SendData);
+
+                                                // 激活返还运营中心额度
+                                                decimal OperateAmount = 200;
+                                                if(pos.BrandId == 3 || pos.BrandId == 5 || pos.BrandId == 9) OperateAmount = 300;
+                                                string OperateData = "{\"UserId\":\"" + pos.OpId + "\",\"DataId\":\"" + pos.Id + "\",\"Kind\":\"1\",\"Amount\":\"" + OperateAmount + "\"}";
+                                                RedisDbconn.Instance.AddList("OperateAmountQueue", OperateData);
                                             }
                                             //发放大盟主奖励
                                             if(pos.LeaderUserId > 0)