Explorar o código

补录队列调整

lcl hai 9 meses
pai
achega
e063200896
Modificáronse 1 ficheiros con 137 adicións e 2 borrados
  1. 137 2
      AppStart/GetHaoDaFTPInfoService.cs

+ 137 - 2
AppStart/GetHaoDaFTPInfoService.cs

@@ -78,10 +78,10 @@ namespace MySystem
         {
             while (true)
             {
-                string content = RedisDbconn.Instance.RPop<string>("ListenDepositDataQueue");
+                string content = RedisDbconn.Instance.RPop<string>("ListenDepositDataQueue2");
                 if (!string.IsNullOrEmpty(content))
                 {
-                    GetDepositData(content);
+                    GetDepositData2(content);
                     Thread.Sleep(2000);
                 }
                 else
@@ -228,6 +228,141 @@ namespace MySystem
             }
         }
 
+        public void GetDepositData2(string Date)
+        {
+            // 要下载的文件路径
+            string filePath = "/haoda-deposit/deposit_" + Date + ".csv";
+            
+            try
+            {
+                // 创建FtpWebRequest对象
+                FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpServerAddress + filePath);
+                request.Method = WebRequestMethods.Ftp.DownloadFile;
+                request.Credentials = new NetworkCredential(ftpUser, ftpPassword);
+
+                // 使用WebResponse获取响应
+                FtpWebResponse response = (FtpWebResponse)request.GetResponse();
+
+                // 打开数据流
+                Stream responseStream = response.GetResponseStream();
+                StreamReader reader = new StreamReader(responseStream);
+                // 读取数据
+                string fileContents = reader.ReadToEnd();
+                if (!string.IsNullOrEmpty(fileContents))
+                {
+                    WebCMSEntities db = new WebCMSEntities();
+                    MpMainModels2.WebCMSEntities mpdb2 = new MpMainModels2.WebCMSEntities();
+                    var DataInfo = fileContents.TrimEnd('\n').Split('\n', 2);
+                    if(DataInfo.Length > 1)
+                    {
+                        var DataList = DataInfo[1].Split('\n');
+                        foreach (var DataListItem in DataList)
+                        {
+                            var DataListInfo = DataListItem.Split(',');
+
+                            string SnNo = DataListInfo[0]; //sn
+                            string MerNo = DataListInfo[1]; //商户编号
+                            string PosKind = DataListInfo[2]; //机具型号
+                            string ActDate = DataListInfo[3]; //激活时间
+                            string Deposit = DataListInfo[4]; //押金金额
+                            string PrizeAmt = DataListInfo[5]; //奖励金额
+                            string PrizeDate = DataListInfo[6]; //奖励发放时间
+                            string Name = DataListInfo[7]; //发放人姓名
+
+                            string ActDateString = ActDate.Substring(0, 4) + "-" + ActDate.Substring(4, 2) + "-" + ActDate.Substring(6, 2);
+                            string PrizeDateString = "";
+                            if(PrizeDate == "None")
+                            {
+                                PrizeDate = Date;
+                            }
+                            else
+                            {
+                                PrizeDateString = PrizeDate.Substring(0, 4) + "-" + PrizeDate.Substring(4, 2) + "-" + PrizeDate.Substring(6, 2);
+                            }
+
+                            string ProductType = "0";
+                            if(PosKind == "好哒语音王Y512") ProductType = "18";
+                            if(PosKind == "4G收款王M820") ProductType = "19";
+                            if(PosKind == "4G收款王M826") ProductType = "20";
+                            if(PosKind == "好哒S312") ProductType = "21";
+
+                            db.BindRecord.Add(new BindRecord()
+                            {
+                                CreateDate = DateTime.Now,
+                                UpdateTime = DateTime.Now, //机具绑定、解绑时间
+                                CreateTime = DateTime.Now, //商户操作时间
+                                MerSnNo = SnNo, //序列号
+                                MerNo = MerNo, //商户编号
+                                MerName = Name,
+                                SeoTitle = PrizeAmt,
+                                SeoKeyword = ActDateString,
+                                ProductType = ProductType,
+                                Field1 = Deposit,
+                                Field2 = PrizeDate,
+                                Status = 1,
+                            });
+
+                            db.Merchants.Add(new Merchants()
+                            {
+                                SnNo = SnNo,
+                                CreateTime = DateTime.Now,
+                                UpdateTime = DateTime.Now,
+                                AgentName = Name,
+                                MerRealName = Name,
+                                MerNo = MerNo,
+                                MerName = Name,
+                                ProductType = ProductType,
+                                Status = 1,
+                            });
+                            db.SaveChanges();
+
+                            Thread.Sleep(1000);
+
+                            db.ActivateRecord.Add(new ActivateRecord()
+                            {
+                                SnNo = SnNo,
+                                CreateDate = DateTime.Now,
+                                SeoTitle = Deposit,
+                                ActivateDate = DateTime.Now,
+                                AgentNo = MerNo,
+                                MerRealName = Name,
+                                MerNo = MerNo,
+                                MerName = Name,
+                                ProductType = ProductType,
+                                ChannelSerial = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8),
+                                Status = 1,
+                            });
+                            db.SaveChanges();
+
+                            //推送MQ给创业帮
+                            var merchantAddInfo = mpdb2.MerchantAddInfo.FirstOrDefault(m => m.MchtNo == MerNo) ?? new MpMainModels2.MerchantAddInfo();
+                            if (merchantAddInfo.BrandId == 1 && !string.IsNullOrEmpty(merchantAddInfo.CybMakerCode))
+                            {
+                                SortedList<string, string> obj = new SortedList<string, string>();
+                                obj.Add("create_time", ActDateString);
+                                obj.Add("sn", SnNo);
+                                obj.Add("deposit", Deposit);
+                                obj.Add("merch_no", merchantAddInfo.MchtNo);
+                                obj.Add("maker_code", merchantAddInfo.CybMakerCode);
+                                PushHelper.Instance.Do(obj, "cashNotify");
+                            }
+                        }
+                    }
+                    db.Dispose();
+                    mpdb2.Dispose();
+                }
+
+                // 关闭响应
+                reader.Dispose();
+                responseStream.Dispose();
+                response.Close();
+            }
+            catch (WebException ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "获取好哒FTP文件数据异常");
+            }
+        }
+