Browse Source

数据推送修复

lcl 6 months ago
parent
commit
ee3f0da9c2

BIN
.DS_Store


+ 101 - 17
AppStart/Helper/PosPushDataNewHelper.cs

@@ -22,9 +22,9 @@ namespace MySystem
                 dataContent.Add("id_card", mer.SeoKeyword); //商户身份证
                 dataContent.Add("mer_name", mer.MerName); //商户姓名
                 dataContent.Add("mer_mobile", mer.MerMobile); //商户手机号
-                dataContent.Add("request_id", mer.CreateTime.Value.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); //流水号
+                dataContent.Add("request_id", getRequestId(mer.Id, "bind")); //流水号
                 dataContent.Add("bind_time", mer.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
-                dataContent.Add("brand", mer.ProductType); //品牌
+                dataContent.Add("brand", int.Parse(function.CheckInt(mer.ProductType))); //品牌
                 Push("bind", dataContent);
             }
             catch (Exception ex)
@@ -42,9 +42,9 @@ namespace MySystem
                 dataContent.Add("id_card", mer.LegalIdCard); //商户身份证
                 dataContent.Add("mer_name", mer.MerName); //商户姓名
                 dataContent.Add("mer_mobile", ""); //商户手机号
-                dataContent.Add("request_id", mer.CreateTime.Value.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); //流水号
+                dataContent.Add("request_id", getRequestId(mer.Id, "merchant")); //流水号
                 dataContent.Add("bind_time", mer.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
-                dataContent.Add("brand", mer.ProductType); //品牌
+                dataContent.Add("brand", int.Parse(function.CheckInt(mer.ProductType))); //品牌
                 Push("bind", dataContent);
             }
             catch (Exception ex)
@@ -61,9 +61,9 @@ namespace MySystem
                 Dictionary<string, object> dataContent = new Dictionary<string, object>();
                 dataContent.Add("pos_sn", mer.MerSnNo); //机具sn
                 dataContent.Add("mer_no", mer.MerNo); //商户号
-                dataContent.Add("request_id", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); //流水号
+                dataContent.Add("request_id", getRequestId(mer.Id, "unbind")); //流水号
                 dataContent.Add("un_bind_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
-                dataContent.Add("brand", mer.ProductType); //品牌
+                dataContent.Add("brand", int.Parse(function.CheckInt(mer.ProductType))); //品牌
                 Push("un_bind", dataContent);
             }
             catch (Exception ex)
@@ -78,12 +78,12 @@ namespace MySystem
             try
             {
                 Dictionary<string, object> dataContent = new Dictionary<string, object>();
-                dataContent.Add("request_id", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); //流水号
+                dataContent.Add("request_id", getRequestId(mer.Id, "changebind")); //流水号
                 dataContent.Add("mer_no", mer.MerNo); //商户号
                 dataContent.Add("source_pos_sn", mer.MerSnNo); //来源机具sn
-                dataContent.Add("source_brand", mer.ProductType); //来源品牌
+                dataContent.Add("source_brand", int.Parse(function.CheckInt(mer.ProductType))); //来源品牌
                 dataContent.Add("to_pos_sn", mer.MerNewSnNo); //兑换机具sn
-                dataContent.Add("to_brand", mer.ProductType); //兑换品牌
+                dataContent.Add("to_brand", int.Parse(function.CheckInt(mer.ProductType))); //兑换品牌
                 dataContent.Add("change_bind_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //换绑时间
                 Push("change_bind", dataContent);
             }
@@ -101,10 +101,10 @@ namespace MySystem
                 Dictionary<string, object> dataContent = new Dictionary<string, object>();
                 dataContent.Add("pos_sn", act.SnNo); //机具sn
                 dataContent.Add("mer_no", act.MerNo); //商户号
-                dataContent.Add("request_id", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); //流水号
+                dataContent.Add("request_id", getRequestId(act.Id, "deposit")); //流水号
                 dataContent.Add("deposit_amount", act.SeoTitle); //押金金额
                 dataContent.Add("trade_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间
-                dataContent.Add("brand", act.ProductType); //品牌
+                dataContent.Add("brand", int.Parse(function.CheckInt(act.ProductType))); //品牌
                 Push("deposit", dataContent);
             }
             catch (Exception ex)
@@ -119,10 +119,10 @@ namespace MySystem
                 Dictionary<string, object> dataContent = new Dictionary<string, object>();
                 dataContent.Add("pos_sn", trade.TradeSnNo); //机具sn
                 dataContent.Add("mer_no", trade.MerNo); //商户号
-                dataContent.Add("request_id", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); //流水号
+                dataContent.Add("request_id", getRequestId(trade.Id, "deposit1")); //流水号
                 dataContent.Add("deposit_amount", trade.TradeAmount); //押金金额
                 dataContent.Add("trade_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间
-                dataContent.Add("brand", trade.ProductType); //品牌
+                dataContent.Add("brand", int.Parse(function.CheckInt(trade.ProductType))); //品牌
                 Push("deposit", dataContent);
             }
             catch (Exception ex)
@@ -139,9 +139,9 @@ namespace MySystem
                 Dictionary<string, object> dataContent = new Dictionary<string, object>();
                 dataContent.Add("pos_sn", act.SnNo); //机具sn
                 dataContent.Add("mobile", act.MerMobile); //商户号
-                dataContent.Add("request_id", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); //流水号
+                dataContent.Add("request_id", getRequestId(act.Id, "active")); //流水号
                 dataContent.Add("activation_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //激活时间
-                dataContent.Add("brand", act.ProductType); //品牌
+                dataContent.Add("brand", int.Parse(function.CheckInt(act.ProductType))); //品牌
                 Push("active", dataContent);
             }
             catch (Exception ex)
@@ -156,29 +156,104 @@ namespace MySystem
             try
             {
                 int QrPayFlag = 0;
+                int BankCardType = 1;
                 if (trade.ProductType == "1")
                 {
                     if (trade.TradeType == "02") QrPayFlag = 1;
+                    BankCardType = int.Parse(trade.BankCardType);
                 }
                 else if (trade.ProductType == "2")
                 {
                     if (trade.TradeType == "CLOUD_PAY") QrPayFlag = 1;
+                    if (trade.TradeType == "CREDIT_BY_CARD")
+                    {
+                        BankCardType = 1;
+                    }
+                    else
+                    {
+                        BankCardType = 0;
+                    }
                 }
                 else if (trade.ProductType == "4")
                 {
                     if (trade.TradeType == "200") QrPayFlag = 1;
+                    if (trade.BankCardType == "100")
+                    {
+                        BankCardType = 1;
+                    }
+                    else if (trade.BankCardType == "200")
+                    {
+                        BankCardType = 0;
+                    }
+                }
+                else if (trade.ProductType == "6")
+                {
+                    if (trade.BankCardType == "02" || trade.BankCardType == "12")
+                    {
+                        BankCardType = 1;
+                    }
+                    else
+                    {
+                        BankCardType = 0;
+                    }
+                }
+                else if (trade.ProductType == "7")
+                {
+                    if (trade.BankCardType == "OA" || trade.BankCardType == "CC" || trade.BankCardType == "SCC")
+                    {
+                        BankCardType = 1;
+                    }
+                    else
+                    {
+                        BankCardType = 0;
+                    }
                 }
                 else if (trade.ProductType == "8" || trade.ProductType == "9")
                 {
                     if (trade.TradeType == "200") QrPayFlag = 1;
+                    if (trade.BankCardType == "100")
+                    {
+                        BankCardType = 1;
+                    }
+                    else if (trade.BankCardType == "200")
+                    {
+                        BankCardType = 0;
+                    }
                 }
                 else if (trade.ProductType == "10" || trade.ProductType == "11")
                 {
                     if (trade.TradeType == "F010") QrPayFlag = 1;
+                    if (trade.BankCardType == "01")
+                    {
+                        BankCardType = 1;
+                    }
+                    else if (trade.BankCardType == "00")
+                    {
+                        BankCardType = 0;
+                    }
                 }
                 else if (trade.ProductType == "12") //盒易付
                 {
                     if (trade.Field3 == "1") QrPayFlag = 1;
+                    if (trade.BankCardType == "C")
+                    {
+                        BankCardType = 1;
+                    }
+                    else if (trade.BankCardType == "D")
+                    {
+                        BankCardType = 0;
+                    }
+                }
+                else if (trade.ProductType == "15")
+                {
+                    if (trade.BankCardType == "02")
+                    {
+                        BankCardType = 1;
+                    }
+                    else
+                    {
+                        BankCardType = 0;
+                    }
                 }
                 Dictionary<string, object> dataContent = new Dictionary<string, object>();
                 dataContent.Add("pos_sn", trade.TradeSnNo); //机具sn
@@ -186,8 +261,8 @@ namespace MySystem
                 dataContent.Add("request_id", trade.TradeSerialNo); //流水号
                 dataContent.Add("trade_amount", trade.TradeAmount); //交易金额
                 dataContent.Add("trade_time", trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间
-                dataContent.Add("brand", trade.ProductType); //品牌
-                dataContent.Add("card_type", trade.BankCardType); //卡类型
+                dataContent.Add("brand", int.Parse(function.CheckInt(trade.ProductType))); //品牌
+                dataContent.Add("card_type", BankCardType); //卡类型
                 dataContent.Add("qr_pay_flag", QrPayFlag); //云闪付标记
                 Push("trade", dataContent);
             }
@@ -204,5 +279,14 @@ namespace MySystem
             data.Add("data_content", dataContent);
             RedisDbconn.Instance.AddList("KxsPosDataQueue", Newtonsoft.Json.JsonConvert.SerializeObject(data));
         }
+
+        public static string getRequestId(int id, string type)
+        {
+            if(id > 0)
+            {
+                return function.MD5_32(id.ToString() + type);
+            }
+            return DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
+        }
     }
 }

+ 7 - 5
AppStart/Helper/SycnSpServer/SycnSpActiveService.cs

@@ -268,18 +268,20 @@ namespace MySystem
                                 edit.Status = 2;
                             }
                         }
-                        pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == act.SnNo && m.ActivationState == 1);
-                        if (pos != null)
+                        else
                         {
-                            //发放奖励MQ
-                            PrizeSetHelper.Do("1", pos.PosSn);
-
                             ActivateRecord edit = spdb.ActivateRecord.FirstOrDefault(m => m.Id == act.Id);
                             if (edit != null)
                             {
                                 edit.Status = 2;
                             }
                         }
+                        pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == act.SnNo && m.ActivationState == 1);
+                        if (pos != null)
+                        {
+                            //发放奖励MQ
+                            PrizeSetHelper.Do("1", pos.PosSn);
+                        }
                     }
                     spdb.SaveChanges();
                     spdb.Dispose();

+ 9 - 0
AppStart/Helper/SycnSpServer/SycnSpMerchantService.cs

@@ -268,6 +268,15 @@ namespace MySystem
                                 }
                                 tran.Commit();
                             }
+                            else
+                            {
+                                Merchants edit = spdb.Merchants.FirstOrDefault(m => m.Id == Mer.Id);
+                                if (edit != null)
+                                {
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
+                                }
+                            }
                         }
                         catch (Exception ex)
                         {

+ 30 - 25
AppStart/Helper/SycnSpServer/SycnSpTradeWifiService.cs

@@ -35,6 +35,27 @@ namespace MySystem
                     IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && m.ProductType == "23" && m.CreateDate >= start && m.Status == 1).OrderBy(m => m.CreateDate).Take(20);
                     foreach (TradeRecord trade in trades.ToList())
                     {
+                        //推送数据给java
+                        PosPushDataHelper.Trade(new PxcModels.TradeRecord()
+                        {
+                            CreateDate = trade.CreateDate,
+                            UpdateDate = trade.UpdateDate,
+                            RecordNo = trade.TradeSerialNo, //单号
+                            MerNo = trade.MerNo, //渠道商户编号
+                            MerHelpFlag = 1,
+                            HelpMonthCount = 0, //扶持第几个月
+                            SnNo = trade.TradeSnNo, //渠道SN号
+                            TradeSerialNo = trade.ChannelSerial, //交易流水号
+                            TradeAmount = trade.TradeAmount, //交易金额
+                            BrandId = int.Parse(trade.ProductType), //品牌
+                            Remark = trade.Remark, //备注
+                            ActStatus = 1,
+                            CreateMan = trade.AgentNo,
+                            UpdateMan = trade.BankCardType,
+                            SeoKeyword = trade.SerEntryMode,
+                            SeoDescription = trade.TradeType,
+                            TradeDate = trade.CreateDate,
+                        });
                         bool check = db.SpOrderNos.Any(m => m.OrderNo == trade.TradeSerialNo);
                         if (!check && trade.SerEntryMode != "1")
                         {
@@ -54,31 +75,6 @@ namespace MySystem
                                     BrandId = pos.BrandId, //品牌
                                     Remark = trade.Remark, //备注
                                 }).Entity;
-
-                                //推送数据给java
-                                PosPushDataHelper.Trade(new PxcModels.TradeRecord()
-                                {
-                                    CreateDate = trade.CreateDate,
-                                    UpdateDate = trade.UpdateDate,
-                                    RecordNo = trade.TradeSerialNo, //单号
-                                    UserId = pos.UserId, //创客
-                                    MerchantId = pos.BindMerchantId, //商户
-                                    MerNo = trade.MerNo, //渠道商户编号
-                                    MerHelpFlag = 1,
-                                    HelpMonthCount = 0, //扶持第几个月
-                                    SnNo = trade.TradeSnNo, //渠道SN号
-                                    TradeSerialNo = trade.ChannelSerial, //交易流水号
-                                    TradeAmount = TradeAmount, //交易金额
-                                    BrandId = pos.BrandId, //品牌
-                                    Remark = trade.Remark, //备注
-                                    MerUserId = pos.UserId, //商户直属创客M
-                                    ActStatus = 1,
-                                    CreateMan = trade.AgentNo,
-                                    UpdateMan = trade.BankCardType,
-                                    SeoKeyword = trade.SerEntryMode,
-                                    SeoDescription = trade.TradeType,
-                                    TradeDate = pos.BindingTime,
-                                });
                             }
                             db.SpOrderNos.Add(new PxcModels.SpOrderNos()
                             {
@@ -199,6 +195,15 @@ namespace MySystem
                                 spdb.SaveChanges();
                             }
                         }
+                        else
+                        {
+                            TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
+                            if (edit != null)
+                            {
+                                edit.Status = 2;
+                                spdb.SaveChanges();
+                            }
+                        }
                     }           
                     spdb.Dispose();
                     db.Dispose();