lcl 9 місяців тому
батько
коміт
1b43eaa646

+ 14 - 10
AppStart/GetHaoDaFTPInfoService.cs

@@ -198,7 +198,7 @@ namespace MySystem
 
                             //推送MQ给创业帮
                             var merchantAddInfo = mpdb2.MerchantAddInfo.FirstOrDefault(m => m.MchtNo == MerNo) ?? new MpMainModels2.MerchantAddInfo();
-                            if (merchantAddInfo.BrandId == 1)
+                            if (merchantAddInfo.BrandId == 1 && !string.IsNullOrEmpty(merchantAddInfo.CybMakerCode))
                             {
                                 SortedList<string, string> obj = new SortedList<string, string>();
                                 obj.Add("create_time", ActDateString);
@@ -384,15 +384,19 @@ namespace MySystem
                                     //推送MQ给创业帮
                                     if (merchantAddInfo.BrandId == 1)
                                     {
-                                        SortedList<string, string> obj = new SortedList<string, string>();
-                                        obj.Add("create_time", TradeDate);
-                                        obj.Add("sn", BaseNo);
-                                        obj.Add("pay_money", TradeAmount);
-                                        obj.Add("pay_mode", PayMode.ToString());
-                                        obj.Add("order_no", OrderNo);
-                                        obj.Add("merch_no", merchantAddInfo.MchtNo);
-                                        obj.Add("maker_code", merchantAddInfo.CybMakerCode);
-                                        PushHelper.Instance.Do(obj);
+                                        if(!string.IsNullOrEmpty(merchantAddInfo.CybMakerCode))
+                                        {
+                                            SortedList<string, string> obj = new SortedList<string, string>();
+                                            obj.Add("create_time", TradeDate);
+                                            obj.Add("sn", BaseNo);
+                                            obj.Add("pay_money", TradeAmount);
+                                            obj.Add("pay_mode", PayMode.ToString());
+                                            obj.Add("order_no", OrderNo);
+                                            obj.Add("merch_no", merchantAddInfo.MchtNo);
+                                            obj.Add("maker_code", merchantAddInfo.CybMakerCode);
+                                            PushHelper.Instance.Do(obj);
+                                        }
+                                        OrderMessageHelper.SendOrderMsg(query);
                                     }
                                 }
                             }

+ 235 - 0
AppStart/MpRedisDbconn.cs

@@ -0,0 +1,235 @@
+using System.Collections.Generic;
+using Library;
+using System.Linq;
+
+namespace MySystem
+{
+    public class MpRedisDbconn
+    {
+        public readonly static MpRedisDbconn Instance = new MpRedisDbconn();
+        public static CSRedis.CSRedisClient csredis;
+        private MpRedisDbconn()
+        {
+        }
+
+        #region 设置单个字段
+        public bool Set(string key, object value)
+        {
+            return csredis.Set(key, value);
+            // return false;
+        }
+        #endregion
+
+        #region 整数累加
+        public long AddInt(string key, long value = 1)
+        {
+            return csredis.IncrBy(key, value);
+            // return 0;
+        }
+        #endregion
+
+        #region 数字累加
+        public decimal AddNumber(string key, decimal value = 1)
+        {
+            return csredis.IncrByFloat(key, value);
+            // return 0;
+        }
+        #endregion
+
+        #region 获取单个字段
+        public T Get<T>(string key)
+        {
+            return csredis.Get<T>(key);
+        }
+        #endregion
+
+        #region 设置散列字段
+        public bool HSet(string key, string field, object value)
+        {
+            return csredis.HSet(key, field, value);
+            // return false;
+        }
+        #endregion
+
+        #region 散列整数累加
+        public long HAddInt(string key, string field, long value = 1)
+        {
+            return csredis.HIncrBy(key, field, value);
+            // return 0;
+        }
+        #endregion
+
+        #region 散列数字累加
+        public decimal HAddNumber(string key, string field, decimal value = 1)
+        {
+            return csredis.HIncrByFloat(key, field, value);
+            // return 0;
+        }
+        #endregion
+
+        #region 获取散列元素
+        public T HGet<T>(string key, string field)
+        {
+            return csredis.HGet<T>(key, field);
+        }
+        #endregion
+
+        #region 获取散列所有元素
+        public Dictionary<string, T> HGetAll<T>(string key)
+        {
+            return csredis.HGetAll<T>(key);
+        }
+        #endregion
+
+        #region 添加列表对象
+        public long AddList(string key, object value)
+        {
+            return csredis.LPush(key, value);
+            // return 0;
+        }
+        public long AddRightList(string key, object value)
+        {
+            return csredis.RPush(key, value);
+            // return 0;
+        }
+        public long AddList(string key, object[] value)
+        {
+            return csredis.LPush(key, value);
+            // return 0;
+        }
+        public T RPop<T>(string key)
+        {
+            return csredis.RPop<T>(key);
+        }
+        #endregion
+
+        #region 添加集合对象
+        public long SAdd(string key, object value)
+        {
+            return csredis.SAdd(key, value);
+            // return 0;
+        }
+        public long SAdd(string key, object[] value)
+        {
+            return csredis.SAdd(key, value);
+            // return 0;
+        }
+        #endregion
+
+        #region 获取集合对象
+        public T[] SGetList<T>(string key)
+        {
+            return csredis.SMembers<T>(key);
+        }
+        #endregion
+
+        #region 修改列表对象
+        public bool SetList(string key, int index, object value)
+        {
+            long itemindex = csredis.LLen(key) - index - 1;
+            return csredis.LSet(key, itemindex, value);
+            // return false;
+        }
+        #endregion
+
+        #region 获取列表
+        public List<T> GetList<T>(string key, int pageNum = 1, int pageSize = 10)
+        {
+            int start = (pageNum - 1) * pageSize;
+            int end = start + pageSize - 1;
+            T[] list = csredis.LRange<T>(key, start, end);
+            return list.ToList();
+        }
+        #endregion
+
+        #region 删除列表元素
+        public void DelList<T>(string key, T item)
+        {
+            List<T> oldlist = GetList<T>(key, 1, 10000000);
+            oldlist.Remove(item);
+            Clear(key);
+            AddList(key, oldlist.ToArray());
+        }
+        #endregion
+
+        #region 添加排序列表对象
+        public long AddSort(string key, object value, decimal score)
+        {
+            return csredis.ZAdd(key, (score, value));
+            // return 0;
+        }
+        #endregion
+
+        #region 获取排序列表
+        public List<T> GetSort<T>(string key, int pageNum = 1, int pageSize = 10)
+        {
+            int start = (pageNum - 1) * pageSize;
+            int end = start + pageSize;
+            string[] list = csredis.ZRangeByScore(key, start, end);
+            List<T> lists = new List<T>();
+            foreach (string record in list)
+            { 
+                lists.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<T>(record));
+            }
+            return lists;
+        }
+        public List<T> GetSortDesc<T>(string key, int pageNum = 1, int pageSize = 10)
+        {
+            int start = (pageNum - 1) * pageSize;
+            int end = start + pageSize;
+            string[] list = csredis.ZRevRangeByScore(key, start, end);
+            List<T> lists = new List<T>();
+            foreach (string record in list)
+            { 
+                lists.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<T>(record));
+            }
+            return lists;
+        }
+        #endregion
+
+        public bool Remove(string key, long start, long end)
+        {
+            return csredis.LTrim(key, start, end);
+        }
+
+        public bool RemoveTop(string key, long count)
+        {
+            return RedisDbconn.Instance.Remove(key, count, RedisDbconn.Instance.Count(key) - 1);;
+        }
+
+        public long Count(string key)
+        {
+            return csredis.LLen(key);
+        }
+
+        public void Clear(string pattern)
+        {
+            string[] keys = csredis.Keys(pattern);
+            csredis.Del(keys);
+        }
+
+        public string[] GetKeys(string pattern)
+        { 
+            string[] keys = csredis.Keys(pattern);
+            return keys;
+        }
+
+        public void SetExpire(string key, int expire)
+        { 
+            csredis.Expire(key, expire); //秒为单位
+        }
+
+        #region 判断Key是否存在
+
+        public bool CheckKey(string key)
+        {
+            if (csredis.Exists(key))
+            {
+                return true;
+            }
+            return false;
+        }
+
+        #endregion
+    }
+}

+ 22 - 0
AppStart/OrderMessage.cs

@@ -0,0 +1,22 @@
+using System;
+namespace MySystem
+{
+    public class OrderMessage
+    {
+        public int brandId { get; set; } //品牌/通道(0直联,1银联,2好哒)
+        public int status { get; set; } //订单状态(0待支付,1已支付)
+        public DateTime createDate { get; set; } //创建时间
+        public DateTime payDate { get; set; } //支付时间
+        public string hdOrderNo { get; set; } //好哒订单号
+        public string tradeNo { get; set; } //支付宝微信平台交易号
+        public string snNo { get; set; } //码牌SN
+        public decimal payMoney { get; set; } //支付金额
+        public int payMode { get; set; } //支付方式(1支付宝,2微信)
+        public string orderNo { get; set; } //订单号
+        public int consumerId { get; set; } //消费者Id
+        public int merchantId { get; set; } //商户Id
+        public int isAct { get; set; } //活动标识(1活动,0非活动)
+        public int userId { get; set; } //创客Id
+        public decimal merchantActualAmount { get; set; } //商家实收金额
+    }
+}

+ 1 - 0
Startup.cs

@@ -87,6 +87,7 @@ namespace MySystem
 
             MySystemLib.SystemPublicFuction.appcheck = "success";
             RedisDbconn.csredis = new CSRedis.CSRedisClient(Configuration["Setting:RedisConnStr"]);
+            MpRedisDbconn.csredis = new CSRedis.CSRedisClient(Configuration["Setting:MpRedisConnStr"]);
         }
 
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

+ 36 - 0
Util/OrderMessageHelper.cs

@@ -0,0 +1,36 @@
+using System;
+using MySystem.MpMainModels2;
+using System.Linq;
+
+namespace MySystem
+{
+    public class OrderMessageHelper
+    {
+        public static void SendOrderMsg(ConsumerOrders order)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
+            OrderMessage msg = new OrderMessage()
+            {
+                brandId = merchant.BrandId + 1, //品牌/通道(0直联,1银联,2好哒)
+                status = order.Status, //订单状态(0待支付,1已支付)
+                createDate = order.CreateDate.Value, //创建时间
+                payDate = order.UpdateDate.Value, //支付时间
+                hdOrderNo = order.SeoTitle, //好哒订单号
+                tradeNo = order.SeoKeyword, //支付宝微信平台交易号
+                snNo = order.SnNo, //码牌SN
+                payMoney = order.PayMoney, //支付金额
+                payMode = order.PayMode, //支付方式(1支付宝,2微信)
+                orderNo = order.OrderNo, //订单号
+                consumerId = order.ConsumerId, //消费者Id
+                merchantId = order.MerchantId, //商户Id
+                isAct = (int)order.IsAct, //活动标识(1活动,0非活动)
+                userId = order.UserId, //创客Id
+                merchantActualAmount = order.MerchantActualAmount, //商家实收金额
+            };
+            db.Dispose();
+
+            MpRedisDbconn.Instance.AddList("MpOrderQueue", Newtonsoft.Json.JsonConvert.SerializeObject(msg));
+        }
+    }
+}

+ 1 - 0
appsettings.Development.json

@@ -22,6 +22,7 @@
     "MpSqlConnStr2": "server=47.109.31.237;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer2;charset=utf8;",
     "RdsStatSqlConnStr": "server=47.108.62.166;port=3306;user=root;password=HDlNs1ZpG5iR9D9I;database=KxsStatServer;charset=utf8;",
     "RedisConnStr": "47.108.62.166:6379,password=klm@redis,DefaultDatabase=1,poolsize=500,preheat=50,asyncPipeline=true",
+    "MpRedisConnStr": "47.109.31.237:6379,password=klm@redis,DefaultDatabase=5,poolsize=500,preheat=50,asyncPipeline=true",
     "IOSAppVersion": "1.0.0",
     "AndroidAppVersion": "1.0.0",
     "OSSKey": "iL9dWgBunZRwGbHQ",