Ver Fonte

Merge branch 'feat-lcl-盒易付POS通道切换' of kxs-end/main-server into release-mainserver

lichunlei há 1 ano atrás
pai
commit
717b9f39ce

+ 4 - 0
AppStart/Helper/AlipayPayBack2Service.cs

@@ -72,6 +72,7 @@ namespace MySystem
                             order.SendStatus = 1;
                             order.SendDate = DateTime.Now;
                             db.SaveChanges();
+                            Utils.Instance.SendMqOrder(order);
                         }
                     }
                 }
@@ -89,6 +90,9 @@ namespace MySystem
                 order.PayDate = DateTime.Now;
                 order.PayStatus = 1;
                 db.SaveChanges();
+
+                Utils.Instance.SendMqOrder(order);
+
                 if(order.ParentOrderId > 0)
                 {
                     int total = db.Orders.Count(m => m.ParentOrderId == order.ParentOrderId);

+ 59 - 0
AppStart/Helper/LeaderApplyCouponsHelper.cs

@@ -172,6 +172,65 @@ namespace MySystem
             opdb.Dispose();
         }
 
+        public void addprize(int Id)
+        { 
+            WebCMSEntities db = new WebCMSEntities();
+            OpModels.WebCMSEntities opdb = new OpModels.WebCMSEntities();
+            var query = db.LeaderReserveRecord.FirstOrDefault(m => m.Id == Id && m.Remark == "兑换机具券");
+            if(query != null)
+            {
+                JsonData ApplyList = JsonMapper.ToObject(query.SeoTitle);
+                UserRankItem orderUser = PosCouponPrizeService.Instance.GetUserLevel(query.UserId);
+                string ParentNav = orderUser.ParentNav + "," + orderUser.Id + ",";
+                string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                Array.Reverse(ParentNavList);
+                int index = 0;
+                bool BigLeaderFlag = false; //大盟主标记
+                decimal BuyPrize = 0; //购机奖励
+                foreach(string ParentId in ParentNavList)
+                {
+                    UserRankItem parentUser = PosCouponPrizeService.Instance.GetUserLevel(int.Parse(ParentId));
+                    index += 1;
+
+                    if(parentUser.OperateLevel > 0)
+                    {
+                        int groupCount = 0;
+                        for (int i = 0; i < ApplyList.Count; i++)
+                        {
+                            int num = Convert.ToInt32(ApplyList[i]["Num"].ToString());
+                            int Kind = Convert.ToInt32(ApplyList[i]["Type"].ToString());
+                            if(Kind == 1)
+                            {
+                                groupCount += num / 3;
+                            }
+                            else
+                            {
+                                groupCount += num / 2;
+                            }
+                        }
+                        if(PosCouponPrizeService.Instance.CheckOpReserve(opdb, groupCount, parentUser.Id))
+                        {
+                            //购机奖
+                            decimal CurBuyPrize = GetBuyPrize(parentUser);
+                            decimal GetPrize = CurBuyPrize - BuyPrize;
+                            int Kind = 0;
+                            if(query.Remark == "兑换机具券")
+                            {
+                                Kind = 101;
+                            }
+                            if(GetPrize > 0 && !db.UserAccountRecord.Any(m => m.QueryCount == Id && m.ChangeType == 128)) 
+                            {
+                                PosCouponPrizeService.Instance.OpAccount(db, Id, parentUser.Id, GetPrize, groupCount, 128, Kind);
+                            }
+                            BuyPrize = CurBuyPrize;
+                        }
+                    }
+                }
+            }
+            db.Dispose();
+            opdb.Dispose();
+        }
+
         /// <summary>
         /// 获取购机奖金额
         /// </summary>

+ 45 - 29
AppStart/PosChannelHelper.cs

@@ -47,39 +47,55 @@ public class PosChannelHelper
 
     public void DoSomething(WebCMSEntities db)
     {
-        List<PosChannelSetRecord> list = db.PosChannelSetRecord.Where(m => m.Status == 0).ToList();
-        foreach(PosChannelSetRecord sub in list)
+        List<PosChannelSet> mains = db.PosChannelSet.Where(m => m.Status == 0).ToList();
+        foreach(PosChannelSet main in mains)
         {
-            string jsonString = QueryTermAcqInfo(sub.PosSn);
-            JsonData jsonData = JsonMapper.ToObject(jsonString);
-            if(jsonData["resultCode"].ToString() == "1")
+            int PassCount = 0;
+            string PosSnList = "";
+            List<PosChannelSetRecord> list = db.PosChannelSetRecord.Where(m => m.RecordId == main.Id).ToList();
+            foreach(PosChannelSetRecord sub in list)
             {
-                // string acqInstId = jsonData["data"]["acqInstId"].ToString();
-                // if(sub.ChannelNo == acqInstId)
-                // {
-                    PosChannelSetRecord edit = db.PosChannelSetRecord.FirstOrDefault(m => m.Id == sub.Id);
-                    if(edit != null)
-                    {
-                        edit.Status = 1;
-                        db.SaveChanges();
-                        PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == edit.PosId) ?? new PosMachinesTwo();
-                        Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
-                        string ChannelName = "";
-                        if(sub.ChannelNo == "48130000") ChannelName = "环讯";
-                        if(sub.ChannelNo == "48310000") ChannelName = "易生";
-                        if(sub.ChannelNo == "48330000") ChannelName = "海科";
-                        if(sub.ChannelNo == "48470000") ChannelName = "中付";
-                        RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                string jsonString = QueryTermAcqInfo(sub.PosSn);
+                JsonData jsonData = JsonMapper.ToObject(jsonString);
+                if(jsonData["resultCode"].ToString() == "1")
+                {
+                    // string acqInstId = jsonData["data"]["acqInstId"].ToString();
+                    // if(sub.ChannelNo == acqInstId)
+                    // {
+                        PosChannelSetRecord edit = db.PosChannelSetRecord.FirstOrDefault(m => m.Id == sub.Id);
+                        if(edit != null)
                         {
-                            UserId = pos.BuyUserId, //创客
-                            Title = "机具通道变更通知", //标题
-                            Content = "<div class='f16' style='padding:12px 16px;'>尊敬的" + user.RealName + "盟主您好:<br/><br/><div class='f14' style='text-indent:2em;'>您名下的机具" + pos.PosSn + ",通道已更改为" + ChannelName + ",请知悉!</ div> </ div>", //内容
-                            CreateDate = DateTime.Now,
-                        }));
-                    }
-                // }
+                            edit.Status = 1;
+                            db.SaveChanges();
+                            PosSnList += edit.PosSn + ",";
+                            PassCount += 1;
+                        }
+                    // }
+                }
             }
-        }  
+            if(PassCount >= list.Count)
+            {
+                PosChannelSet edit = db.PosChannelSet.FirstOrDefault(m => m.Id == main.Id);
+                if(edit != null)
+                {
+                    edit.Status = 1;
+                    db.SaveChanges();
+                    Users user = db.Users.FirstOrDefault(m => m.Id == edit.UserId) ?? new Users();
+                    string ChannelName = "";
+                    if(edit.ChannelNo == "48130000") ChannelName = "环讯";
+                    if(edit.ChannelNo == "48310000") ChannelName = "易生";
+                    if(edit.ChannelNo == "48330000") ChannelName = "海科";
+                    if(edit.ChannelNo == "48470000") ChannelName = "中付";
+                    RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                    {
+                        UserId = edit.UserId, //创客
+                        Title = "机具通道变更通知", //标题
+                        Content = "<div class='f16' style='padding:12px 16px;'>尊敬的" + user.RealName + "盟主您好:<br/><br/><div class='f14' style='text-indent:2em;'>您名下的机具" + PosSnList.TrimEnd(',') + ",通道已更改为" + ChannelName + ",请知悉!</ div> </ div>", //内容
+                        CreateDate = DateTime.Now,
+                    }));
+                }
+            }
+        }
     }
 
 

+ 75 - 0
AppStart/Tables/MqOrder.cs

@@ -0,0 +1,75 @@
+using System;
+namespace MySystem
+{
+    public class MqOrder
+    {
+        //订单Id
+        public int id { get; set; }
+
+        //订单状态(0待付款,1已付款,2已完成,3已发货,4已退款)
+        public int status { get; set; }
+
+        //创建时间
+        public DateTime? createDate { get; set; }
+
+        //发货的机具券码
+        public string snNos { get; set; }
+
+        //备注
+        public string remark { get; set; }
+
+        //购买数量
+        public int buyCount { get; set; }
+
+        //支付状态
+        public int payStatus { get; set; }
+
+        //商品id
+        public int productId { get; set; }
+
+        //发货状态
+        public int sendStatus { get; set; }
+
+        //提货方式(1邮寄到付,2上门自提)
+        public int deliveryType { get; set; }
+
+        //退款状态
+        public int refundStatus { get; set; }
+
+        //支付方式(1支付宝,3余额,4储蓄金)
+        public int payMode { get; set; }
+
+        //发货时间
+        public DateTime? sendDate { get; set; }
+
+        //支付时间
+        public DateTime? payDate { get; set; }
+
+        //邮政编码
+        public string postalCode { get; set; }
+
+        //详细地址
+        public string address { get; set; }
+
+        //所在省市区
+        public string areas { get; set; }
+
+        //支付总金额
+        public decimal totalPrice { get; set; }
+
+        //联系手机号
+        public string mobile { get; set; }
+
+        //联系人姓名
+        public string realName { get; set; }
+
+        //订单号
+        public string orderNo { get; set; }
+
+        //创客Id
+        public int userId { get; set; }
+
+        //父级订单Id(拆单用)
+        public int parentOrderId { get; set; }
+    }
+}

+ 13 - 0
Controllers/HomeController.cs

@@ -471,5 +471,18 @@ namespace MySystem.Controllers
             }
             return "ok";
         }
+    
+    
+        public string addprize3()
+        {
+            List<int> ids = new List<int>();
+            foreach(int id in ids)
+            {
+                LeaderApplyCouponsHelper.Instance.addprize(id);
+            }
+            return "ok";
+        }
+    
+    
     }
 }

+ 19 - 0
PxcModels/PosChannelSet.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.PxcModels
+{
+    public partial class PosChannelSet
+    {
+        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 int SnCount { get; set; }
+        public int BrandId { get; set; }
+        public string ChannelNo { get; set; }
+        public int UserId { get; set; }
+    }
+}

+ 1 - 0
PxcModels/PosChannelSetRecord.cs

@@ -15,5 +15,6 @@ namespace MySystem.PxcModels
         public string MerNo { get; set; }
         public string PosSn { get; set; }
         public int BrandId { get; set; }
+        public int RecordId { get; set; }
     }
 }

+ 54 - 4
PxcModels/WebCMSEntities.cs

@@ -141,6 +141,7 @@ namespace MySystem.PxcModels
         public virtual DbSet<Orders> Orders { get; set; }
         public virtual DbSet<PageInfo> PageInfo { get; set; }
         public virtual DbSet<PageUpdateInfo> PageUpdateInfo { get; set; }
+        public virtual DbSet<PosChannelSet> PosChannelSet { get; set; }
         public virtual DbSet<PosChannelSetRecord> PosChannelSetRecord { get; set; }
         public virtual DbSet<PosCouponForUser> PosCouponForUser { get; set; }
         public virtual DbSet<PosCouponOrders> PosCouponOrders { get; set; }
@@ -9814,12 +9815,61 @@ namespace MySystem.PxcModels
                 entity.Property(e => e.Version).HasColumnType("int(11)");
             });
 
+            modelBuilder.Entity<PosChannelSet>(entity =>
+            {
+                entity.HasComment("机具通道修改记录");
+
+                entity.Property(e => e.Id).HasColumnType("int(11)");
+
+                entity.Property(e => e.BrandId)
+                    .HasColumnType("int(11)")
+                    .HasComment("品牌");
+
+                entity.Property(e => e.ChannelNo)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("通道编号")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.CreateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("创建时间");
+
+                entity.Property(e => e.SnCount)
+                    .HasColumnType("int(11)")
+                    .HasComment("机具数");
+
+                entity.Property(e => e.Sort)
+                    .HasColumnType("int(11)")
+                    .HasComment("排序序号");
+
+                entity.Property(e => e.Status)
+                    .HasColumnType("int(11)")
+                    .HasComment("状态");
+
+                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<PosChannelSetRecord>(entity =>
             {
                 entity.HasComment("机具通道修改记录");
 
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
+                entity.Property(e => e.BrandId)
+                    .HasColumnType("int(11)")
+                    .HasComment("品牌");
+
                 entity.Property(e => e.ChannelNo)
                     .HasColumnType("varchar(50)")
                     .HasComment("通道编号")
@@ -9850,6 +9900,10 @@ namespace MySystem.PxcModels
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.RecordId)
+                    .HasColumnType("int(11)")
+                    .HasComment("记录Id");
+
                 entity.Property(e => e.Status)
                     .HasColumnType("int(11)")
                     .HasComment("状态");
@@ -9857,10 +9911,6 @@ namespace MySystem.PxcModels
                 entity.Property(e => e.UpdateDate)
                     .HasColumnType("datetime")
                     .HasComment("修改时间");
-
-                entity.Property(e => e.BrandId)
-                    .HasColumnType("int(11)")
-                    .HasComment("品牌");
             });
 
             modelBuilder.Entity<PosCouponForUser>(entity =>

+ 39 - 0
Util/Utils.cs

@@ -285,5 +285,44 @@ namespace MySystem
             function.WriteLog("3\n\n", "运营中心额度变更测试");
         }
         #endregion
+    
+
+        #region 推送订单信息
+
+        public void SendMqOrder(Orders order)
+        {
+            RedisDbconn.Instance.AddList("KxsOrderQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MqOrder()
+            {
+                id = order.Id,
+                status = order.Status,
+                createDate = order.CreateDate,
+                snNos = order.SnNos,
+                remark = order.Remark,
+                buyCount = order.BuyCount,
+                payStatus = order.PayStatus,
+                productId = order.ProductId,
+                sendStatus = order.SendStatus,
+                deliveryType = order.DeliveryType,
+                refundStatus = order.RefundStatus,
+                payMode = order.PayMode,
+                sendDate = order.SendDate,
+                payDate = order.PayDate,
+                postalCode = order.PostalCode,
+                address = order.Address,
+                areas = order.Areas,
+                totalPrice = order.TotalPrice,
+                mobile = order.Mobile,
+                realName = order.RealName,
+                orderNo = order.OrderNo,
+                userId = order.UserId,
+                parentOrderId = order.ParentOrderId,
+            }));
+        }
+
+        #endregion 
+    
+    
+    
+    
     }
 }