소스 검색

添加天谕音响和云音响播放接口,云音响未通

lcl 1 년 전
부모
커밋
b8981f153d

+ 15 - 1
AppStart/Helper/AlipayPayBackService.cs

@@ -74,7 +74,21 @@ namespace MySystem
                     {
                         order.QueryCount = 1;
                     }
-                    db.SaveChanges();                            
+                    db.SaveChanges();
+
+                    //语音播报
+                    PosMachines machine = db.PosMachines.FirstOrDefault(m => m.PosSn == order.SnNo);
+                    if(machine != null)
+                    {
+                        if(machine.BrandId == 2)
+                        {
+                            TianYuVoiceHelper.Instance.doSomething(DateTime.Now.ToString("yyyyMMddHHmmssfff"), machine.Detail, order.PayMoney.ToString("f2"));
+                        }
+                        else if(machine.BrandId == 3)
+                        {
+                            MqLinksHelper.Instance.doSomething(machine.Detail, order.PayMoney.ToString("f2"));
+                        }
+                    }
                 }
             }
             db.Dispose();

+ 53 - 0
AppStart/Helper/MqLinksHelper.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Threading;
+using System.Linq;
+using System.Data;
+using Library;
+using MySystem.Models;
+using LitJson;
+using System.Collections.Generic;
+using System.Security.Cryptography;
+
+namespace MySystem
+{
+    public class MqLinksHelper
+    {
+        public readonly static MqLinksHelper Instance = new MqLinksHelper();
+        private MqLinksHelper()
+        {
+        }
+
+        string reqUrl = "http://cs.mqlinks.com/txmsgpush";
+
+        public string doSomething(string DeviceId, string Amount)
+        {
+            string result = "";
+            try
+            {
+                Dictionary<string, object> data = new Dictionary<string, object>();
+                data.Add("cmd", "voice");
+                data.Add("msg", "来客吧收款" + Amount + "元");
+                data.Add("msgid", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
+                Dictionary<string, object> map = new Dictionary<string, object>();
+                map.Add("sbx_id", DeviceId);
+                map.Add("agent_id", data);
+                result = post(map);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "云音响播报异常");
+            }
+            return result;
+        }
+
+        private string post(Dictionary<string, object> data)
+        {
+            string req = Newtonsoft.Json.JsonConvert.SerializeObject(data);
+            function.WriteLog("请求地址:" + reqUrl, "云音响播报日志");
+            function.WriteLog("请求参数:" + req, "云音响播报日志");
+            string result = function.PostWebRequest(reqUrl, req, "application/json");
+            function.WriteLog("响应数据:" + result, "云音响播报日志");
+            return result;
+        }
+    }
+}

+ 53 - 42
AppStart/Helper/TianYuVoiceHelper.cs

@@ -17,53 +17,64 @@ namespace MySystem
         {
         }
 
-        string accesskeyld = "IOT_ACCOUNT_TEST_CSYH";
-        string accesskeySecret = "AtR4g5sa24fdy6GII3hts75_CSYH";
-        string reqUrl = "https://voicetest.tysmartpos.com/api/bank/pushmsg";
+        // string accesskeyld = "IOT_ACCOUNT_TEST_CSYH";
+        // string accesskeySecret = "AtR4g5sa24fdy6GII3hts75_CSYH";
+        // string reqUrl = "https://voicetest.tysmartpos.com/api/bank/pushmsg";
 
-        public void Start()//启动
-        {
-            Thread thread = new Thread(listen);
-            thread.IsBackground = true;
-            thread.Start();
-        }
+        string accesskeyld = "IOT_ACCOUNT_PROD_W966HG08MCOXHNT2";
+        string accesskeySecret = "F2jzl8vGkm0fMeDLyYo40wEbzdaiTX2ywj3YNgszJHAbVbcAYIJL9bzzS9lVPPL6";
+        string reqUrl = "https://voice.tysmartpos.com/api/bank/pushmsg";
+
+        // public void Start()//启动
+        // {
+        //     Thread thread = new Thread(listen);
+        //     thread.IsBackground = true;
+        //     thread.Start();
+        // }
 
-        public void listen()
+        // public void listen()
+        // {
+        //     while (true)
+        //     {
+        //         string content = RedisDbconn.Instance.RPop<string>("TianYuVoiceQueue");
+        //         if (!string.IsNullOrEmpty(content))
+        //         {
+        //             try
+        //             {
+        //                 doSomething(content);
+        //                 Thread.Sleep(10);
+        //             }
+        //             catch (Exception ex)
+        //             {
+        //                 LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "天喻云喇叭异常");
+        //             }
+        //         }
+        //         else
+        //         {
+        //             Thread.Sleep(1000);
+        //         }
+        //     }
+        // }
+
+        public string doSomething(string OrderNo, string DeviceId, string Amount)
         {
-            while (true)
+            string result = "";
+            try
             {
-                string content = RedisDbconn.Instance.RPop<string>("TianYuVoiceQueue");
-                if (!string.IsNullOrEmpty(content))
-                {
-                    try
-                    {
-                        doSomething(content);
-                        Thread.Sleep(10);
-                    }
-                    catch (Exception ex)
-                    {
-                        LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "天喻云喇叭异常");
-                    }
-                }
-                else
-                {
-                    Thread.Sleep(1000);
-                }
+                SortedList<string, string> data = new SortedList<string, string>();
+                data.Add("accessKeyId", accesskeyld); //由本公司统一提供给客户的唯一识别码(同accessKeyId)
+                data.Add("requestId", OrderNo); //请求标识,用于唯一标识当前请求
+                data.Add("timestamp", function.GetCurTimestamp().ToString()); //请求时间戳,格式如:1593532800000
+                data.Add("deviceId", DeviceId); //设备编号
+                data.Add("content", "来客吧收款" + Amount + "元"); //(终端直接播报内容,支持 tts 设备可以直接播报汉字语音,不支持 tts 的设备要分开传 requestData、payType)
+                // data.Add("requestData", "0.01"); //播报金额((只送金额,单位:元)
+                // data.Add("payType", "01"); //播报类型:  01-XX银行收款成功    02-支付宝收款成功  03-微信收款成功 10-取消支付
+                result = post(data);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "天喻云喇叭异常");
             }
-        }
-
-        public string doSomething(string content)
-        {
-            JsonData jsonObj = JsonMapper.ToObject(content);
-            SortedList<string, string> data = new SortedList<string, string>();
-            data.Add("accessKeyId", accesskeyld); //由本公司统一提供给客户的唯一识别码(同accessKeyId)
-            data.Add("requestId", jsonObj["OrderNo"].ToString()); //请求标识,用于唯一标识当前请求
-            data.Add("timestamp", function.GetCurTimestamp().ToString()); //请求时间戳,格式如:1593532800000
-            data.Add("deviceId", jsonObj["DeviceId"].ToString()); //设备编号
-            data.Add("content", "来客吧收款" + jsonObj["Amount"].ToString() + "元"); //(终端直接播报内容,支持 tts 设备可以直接播报汉字语音,不支持 tts 的设备要分开传 requestData、payType)
-            // data.Add("requestData", "0.01"); //播报金额((只送金额,单位:元)
-            // data.Add("payType", "01"); //播报类型:  01-XX银行收款成功    02-支付宝收款成功  03-微信收款成功 10-取消支付
-            string result = post(data);
             return result;
         }
 

+ 15 - 1
AppStart/Helper/WeChatPayBackService.cs

@@ -86,7 +86,21 @@ namespace MySystem
                             {
                                 order.QueryCount = 1;
                             }
-                            db.SaveChanges();                            
+                            db.SaveChanges();
+
+                            //语音播报
+                            PosMachines machine = db.PosMachines.FirstOrDefault(m => m.PosSn == order.SnNo);
+                            if(machine != null)
+                            {
+                                if(machine.BrandId == 2)
+                                {
+                                    TianYuVoiceHelper.Instance.doSomething(DateTime.Now.ToString("yyyyMMddHHmmssfff"), machine.Detail, order.PayMoney.ToString("f2"));
+                                }
+                                else if(machine.BrandId == 3)
+                                {
+                                    MqLinksHelper.Instance.doSomething(machine.Detail, order.PayMoney.ToString("f2"));
+                                }
+                            }
                         }
                     }
                     db.Dispose();

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
Controllers/HomeController.cs


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.