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

跨品牌换机 坏机换新 划拨创客机具 处理wifi预扣款

lcl пре 1 година
родитељ
комит
cffa1723ec
1 измењених фајлова са 82 додато и 0 уклоњено
  1. 82 0
      Areas/Admin/Controllers/MainServer/SysToolsController.cs

+ 82 - 0
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -2410,6 +2410,17 @@ namespace MySystem.Areas.Admin.Controllers
 
                     //同步商户交易额
                     RedisDbconn.Instance.AddList("SycnMerchantTradeQueue", "{\"OldPosId\":\"" + oldpos.LastMerchantId + "\",\"NewPosId\":\"" + newpos.LastMerchantId + "\"}");
+
+                    //更换同类型wifi产品,需更新wifi预扣款SN信息
+                    if(Utils.Instance.IsWifi(oldpos.BrandId))
+                    {
+                        ToChargeBackRecord toCharge = db.ToChargeBackRecord.FirstOrDefault(m => m.UserId == newpos.BuyUserId && m.Remark == "WIFI超时未激活扣款" && m.Field1 == oldpos.PosSn && m.Status != 1);
+                        if(toCharge != null)
+                        {
+                            toCharge.Field1 = newpos.PosSn;
+                            db.SaveChanges();
+                        }
+                    }
                 }
             }
             //仓库坏机换新
@@ -2680,6 +2691,17 @@ namespace MySystem.Areas.Admin.Controllers
 
                     //同步商户交易额
                     RedisDbconn.Instance.AddList("SycnMerchantTradeQueue", "{\"OldPosId\":\"" + oldpos.LastMerchantId + "\",\"NewPosId\":\"" + newpos.LastMerchantId + "\"}");
+
+                    //更换同类型wifi产品,需更新wifi预扣款SN信息
+                    if(Utils.Instance.IsWifi(oldpos.BrandId))
+                    {
+                        ToChargeBackRecord toCharge = db.ToChargeBackRecord.FirstOrDefault(m => m.UserId == newpos.BuyUserId && m.Remark == "WIFI超时未激活扣款" && m.Field1 == oldpos.PosSn && m.Status != 1);
+                        if(toCharge != null)
+                        {
+                            toCharge.Field1 = newpos.PosSn;
+                            db.SaveChanges();
+                        }
+                    }
                 }
             }
             foreach (string sub in opData)
@@ -3023,6 +3045,59 @@ namespace MySystem.Areas.Admin.Controllers
 
                 //同步商户交易额
                 RedisDbconn.Instance.AddList("SycnMerchantTradeQueue", "{\"OldPosId\":\"" + oldpos.LastMerchantId + "\",\"NewPosId\":\"" + newpos.LastMerchantId + "\"}");
+
+                //处理wifi预扣款
+                if(Utils.Instance.IsWifi(oldpos.BrandId))
+                {
+                    ToChargeBackRecord toCharge = db.ToChargeBackRecord.FirstOrDefault(m => m.UserId == newpos.BuyUserId && m.Remark == "WIFI超时未激活扣款" && m.Field1 == oldpos.PosSn);
+                    if(toCharge != null)
+                    {
+                        if(!Utils.Instance.IsWifi(newpos.BrandId))
+                        {
+                            RedisDbconn.Instance.AddList("WifiWithholdBackQueue", "{\"UserId\":\"" + oldpos.BuyUserId + "\",\"SnNo\":\"" + oldpos.PosSn + "\"}");
+                        }
+                        else
+                        {
+                            decimal ChargeAmount = 0;
+                            if(newpos.BrandId == 23) ChargeAmount = 30;
+                            if(newpos.BrandId == 24) ChargeAmount = 120;
+                            if(newpos.BrandId == 25) ChargeAmount = 200;
+                            if(newpos.BrandId == 26) ChargeAmount = 750;
+                            toCharge.Field1 = newpos.PosSn;
+                            if(oldpos.BrandId != newpos.BrandId && (toCharge.Status == 0 || toCharge.Status == 3))
+                            {
+                                toCharge.ChargeAmount = ChargeAmount;
+                            }
+                            else if(toCharge.Status == 1)
+                            {
+                                RedisDbconn.Instance.AddList("WifiWithholdBackQueue", "{\"UserId\":\"" + oldpos.BuyUserId + "\",\"SnNo\":\"" + oldpos.PosSn + "\"}");
+
+                                bool check = db.ToChargeBackRecord.Any(m => m.SeoDescription.Contains(newpos.PosSn) && (m.Status == 3 || m.Status == 0));
+                                if(!check)
+                                {
+                                    db.ToChargeBackRecord.Add(new ToChargeBackRecord
+                                    {
+                                        CreateDate = DateTime.Now,
+                                        SeoTitle = "系统",
+                                        SeoDescription = "WIFI超时未激活扣款",
+                                        Remark = "WIFI超时未激活扣款",
+                                        ChargeType = 1,
+                                        ChargeAmount = ChargeAmount,
+                                        UserId = newpos.BuyUserId,
+                                        Field1 = newpos.PosSn,
+                                    });
+                                    //增加账户预扣总额
+                                    UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == newpos.BuyUserId);
+                                    if (account != null)
+                                    {
+                                        account.ToChargeAmount += ChargeAmount;
+                                    }
+                                }
+                            }
+                            db.SaveChanges();
+                        }
+                    }
+                }
             }
             foreach (string sub in opData)
             {
@@ -4850,6 +4925,7 @@ namespace MySystem.Areas.Admin.Controllers
                 foreach (int SnId in SnIds)
                 {
                     var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnId) ?? new PosMachinesTwo();
+                    int SourceBuyUserId = posInfo.BuyUserId;
                     if (posInfo.UserId == 0 || posInfo.BuyUserId == posInfo.UserId)
                     {
                         posInfo.BuyUserId = tUserId.Id;
@@ -4909,6 +4985,12 @@ namespace MySystem.Areas.Admin.Controllers
                         BrandType = posInfo.DeviceType, //品牌类型
                         SeoKeyword = Note,
                     }).Entity;
+
+                    //处理wifi预扣款
+                    if(Utils.Instance.IsWifi(posInfo.BrandId))
+                    {
+                        RedisDbconn.Instance.AddList("WifiWithholdBackQueue", "{\"UserId\":\"" + SourceBuyUserId + "\",\"SnNo\":\"" + posInfo.PosSn + "\"}");
+                    }
                 }
                 var query = SnIds + ";" + FromMakerCode + ";" + ToMakerCode;
                 function.WriteLog(DateTime.Now.ToString() + ":请求参数," + query + ":" + SysUserName + "-" + SysRealName, "划拨创客机具");