Forráskód Böngészése

对接支付宝音响接口

lcl 1 éve
szülő
commit
33d1af9f94

BIN
AppStart/.DS_Store


BIN
AppStart/Alipay/.DS_Store


+ 61 - 5
AppStart/Alipay/AliIotFunction.cs

@@ -32,9 +32,9 @@ namespace MySystem
             AlipayMerchantIndirectIotBindRequest  request = new AlipayMerchantIndirectIotBindRequest() ;
             request.BizContent="{" +
             "  \"smid\":\"" + Smid + "\"," +
-            "  \"mode\":\"ALIYUN\"," +
-            "  \"device_id\":\"" + DeviceId + "\"" +
-            // "  \"supplier_id\":\"2022043454334\"" +
+            "  \"mode\":\"SDK\"," +
+            "  \"device_id\":\"" + DeviceId + "\"," +
+            "  \"supplier_id\":\"202208101504455785\"" +
             "}";
             function.WriteLog(request.BizContent, "间连iot设备和间连商户绑定");
 
@@ -54,8 +54,64 @@ namespace MySystem
 
         #endregion
 
+        #region 间连iot设备和间连商户解绑
+        public string IotUnBind(string Smid, string DeviceId)
+        {            
+            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
+            AlipayMerchantIndirectIotUnbindRequest  request= new AlipayMerchantIndirectIotUnbindRequest() ;
+            request.BizContent="{" +
+            "  \"smid\":\"" + Smid + "\"," +
+            "  \"mode\":\"SDK\"," +
+            "  \"device_id\":\"" + DeviceId + "\"," +
+            "  \"supplier_id\":\"202208101504455785\"" +
+            "}";
+            function.WriteLog(request.BizContent, "间连iot设备和间连商户解绑");
+
+            string result = "";
+            try
+            {
+                AlipayMerchantIndirectIotUnbindResponse response=client.Execute(request);
+                result = response.Body;
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(ex.ToString(), "间连iot设备和间连商户解绑异常");
+                result = "";
+            }
+            return result;
+        }
+
+        #endregion
+
+        #region 查询设备基础信息
+        public string IotDeviceQuery(string Sn)
+        {
+            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
+            AlipayCommerceIotDeviceBaseinfoQueryRequest  request= new AlipayCommerceIotDeviceBaseinfoQueryRequest() ;
+            request.BizContent="{" +
+            "  \"sn\":\"" + Sn + "\"," +
+            "  \"supplier_id\":\"202208101504455785\"" +
+            "}";
+            function.WriteLog(request.BizContent, "查询设备基础信息");
+
+            string result = "";
+            try
+            {
+                AlipayCommerceIotDeviceBaseinfoQueryResponse response=client.Execute(request);
+                result = response.Body;
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(ex.ToString(), "查询设备基础信息异常");
+                result = "";
+            }
+            return result;
+        }
+
+        #endregion
+
         #region 到账播报
-        public string IotTradeVoice(string BizTid, string Smid, string Amount, string TradeType = "ALIPAY_TRADE")
+        public string IotTradeVoice(string BizTid, string Smid, string TradeNo, string Amount, string TradeType = "ALIPAY_TRADE")
         {
             IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
             AlipayCommerceIotDeviceTradevoiceSendRequest  request= new AlipayCommerceIotDeviceTradevoiceSendRequest() ;
@@ -63,7 +119,7 @@ namespace MySystem
             "  \"biz_tid\":\"" + BizTid + "\"," +
             "  \"smid\":\"" + Smid + "\"," +
             "  \"trade_type\":\"" + TradeType + "\"," +
-            // "  \"trade_id\":\"5404dd23186a-4e62967a3bf0458cd3f4\"," +
+            "  \"trade_id\":\"" + TradeNo + "\"," +
             "  \"amount\":\"" + Amount + "\"" +
             // "  \"msg_id\":\"202108020001101043\"" +
             "}";

+ 123 - 0
AppStart/Alipay/Request/AlipayCommerceIotDeviceBaseinfoQueryRequest.cs

@@ -0,0 +1,123 @@
+using System;
+using Aop.Api.Domain;
+using System.Collections.Generic;
+using Aop.Api.Response;
+
+namespace Aop.Api.Request
+{
+    /// <summary>
+    /// AOP API: alipay.commerce.iot.device.baseinfo.query
+    /// </summary>
+    public class AlipayCommerceIotDeviceBaseinfoQueryRequest : IAopRequest<AlipayCommerceIotDeviceBaseinfoQueryResponse>
+    {
+        /// <summary>
+        /// 查询设备基础信息
+        /// </summary>
+        public string BizContent { get; set; }
+
+        #region IAopRequest Members
+        private bool  needEncrypt=false;
+        private string apiVersion = "1.0";
+	    private string terminalType;
+	    private string terminalInfo;
+        private string prodCode;
+	    private string notifyUrl;
+        private string returnUrl;
+	    private AopObject bizModel;
+        private Dictionary<string, string> udfParams; //add user-defined text parameters
+
+		public void SetNeedEncrypt(bool needEncrypt){
+             this.needEncrypt=needEncrypt;
+        }
+
+        public bool GetNeedEncrypt(){
+
+            return this.needEncrypt;
+        }
+
+		public void SetNotifyUrl(string notifyUrl){
+            this.notifyUrl = notifyUrl;
+        }
+
+        public string GetNotifyUrl(){
+            return this.notifyUrl;
+        }
+
+        public void SetReturnUrl(string returnUrl){
+            this.returnUrl = returnUrl;
+        }
+
+        public string GetReturnUrl(){
+            return this.returnUrl;
+        }
+
+        public void SetTerminalType(String terminalType){
+			this.terminalType=terminalType;
+		}
+
+    	public string GetTerminalType(){
+    		return this.terminalType;
+    	}
+
+    	public void SetTerminalInfo(String terminalInfo){
+    		this.terminalInfo=terminalInfo;
+    	}
+
+    	public string GetTerminalInfo(){
+    		return this.terminalInfo;
+    	}
+
+        public void SetProdCode(String prodCode){
+            this.prodCode=prodCode;
+        }
+
+        public string GetProdCode(){
+            return this.prodCode;
+        }
+
+        public string GetApiName()
+        {
+            return "alipay.commerce.iot.device.baseinfo.query";
+        }
+
+        public void SetApiVersion(string apiVersion){
+            this.apiVersion=apiVersion;
+        }
+
+        public string GetApiVersion(){
+            return this.apiVersion;
+        }
+
+        public void PutOtherTextParam(string key, string value) 
+        {
+            if(this.udfParams == null) 
+            {
+                this.udfParams = new Dictionary<string, string>();
+            }
+            this.udfParams.Add(key, value);
+        }
+
+        public IDictionary<string, string> GetParameters()
+        {
+            AopDictionary parameters = new AopDictionary();
+            parameters.Add("biz_content", this.BizContent);
+            if(udfParams != null) 
+            {
+                parameters.AddAll(this.udfParams);
+            }
+            return parameters;
+        }
+
+		public AopObject GetBizModel()
+        {
+            return this.bizModel;
+        }
+
+        public void SetBizModel(AopObject bizModel)
+        {
+            this.bizModel = bizModel;
+        }
+
+        #endregion
+    }
+}

+ 123 - 0
AppStart/Alipay/Request/AlipayMerchantIndirectIotUnbindRequest.cs

@@ -0,0 +1,123 @@
+using System;
+using Aop.Api.Domain;
+using System.Collections.Generic;
+using Aop.Api.Response;
+
+namespace Aop.Api.Request
+{
+    /// <summary>
+    /// AOP API: alipay.merchant.indirect.iot.unbind
+    /// </summary>
+    public class AlipayMerchantIndirectIotUnbindRequest : IAopRequest<AlipayMerchantIndirectIotUnbindResponse>
+    {
+        /// <summary>
+        /// 间连iot设备和间连商户解绑
+        /// </summary>
+        public string BizContent { get; set; }
+
+        #region IAopRequest Members
+        private bool  needEncrypt=false;
+        private string apiVersion = "1.0";
+	    private string terminalType;
+	    private string terminalInfo;
+        private string prodCode;
+	    private string notifyUrl;
+        private string returnUrl;
+	    private AopObject bizModel;
+        private Dictionary<string, string> udfParams; //add user-defined text parameters
+
+		public void SetNeedEncrypt(bool needEncrypt){
+             this.needEncrypt=needEncrypt;
+        }
+
+        public bool GetNeedEncrypt(){
+
+            return this.needEncrypt;
+        }
+
+		public void SetNotifyUrl(string notifyUrl){
+            this.notifyUrl = notifyUrl;
+        }
+
+        public string GetNotifyUrl(){
+            return this.notifyUrl;
+        }
+
+        public void SetReturnUrl(string returnUrl){
+            this.returnUrl = returnUrl;
+        }
+
+        public string GetReturnUrl(){
+            return this.returnUrl;
+        }
+
+        public void SetTerminalType(String terminalType){
+			this.terminalType=terminalType;
+		}
+
+    	public string GetTerminalType(){
+    		return this.terminalType;
+    	}
+
+    	public void SetTerminalInfo(String terminalInfo){
+    		this.terminalInfo=terminalInfo;
+    	}
+
+    	public string GetTerminalInfo(){
+    		return this.terminalInfo;
+    	}
+
+        public void SetProdCode(String prodCode){
+            this.prodCode=prodCode;
+        }
+
+        public string GetProdCode(){
+            return this.prodCode;
+        }
+
+        public string GetApiName()
+        {
+            return "alipay.merchant.indirect.iot.unbind";
+        }
+
+        public void SetApiVersion(string apiVersion){
+            this.apiVersion=apiVersion;
+        }
+
+        public string GetApiVersion(){
+            return this.apiVersion;
+        }
+
+        public void PutOtherTextParam(string key, string value) 
+        {
+            if(this.udfParams == null) 
+            {
+                this.udfParams = new Dictionary<string, string>();
+            }
+            this.udfParams.Add(key, value);
+        }
+
+        public IDictionary<string, string> GetParameters()
+        {
+            AopDictionary parameters = new AopDictionary();
+            parameters.Add("biz_content", this.BizContent);
+            if(udfParams != null) 
+            {
+                parameters.AddAll(this.udfParams);
+            }
+            return parameters;
+        }
+
+		public AopObject GetBizModel()
+        {
+            return this.bizModel;
+        }
+
+        public void SetBizModel(AopObject bizModel)
+        {
+            this.bizModel = bizModel;
+        }
+
+        #endregion
+    }
+}

+ 17 - 0
AppStart/Alipay/Response/AlipayCommerceIotDeviceBaseinfoQueryResponse.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Xml.Serialization;
+
+namespace Aop.Api.Response
+{
+    /// <summary>
+    /// AlipayCommerceIotDeviceBaseinfoQueryResponse.
+    /// </summary>
+    public class AlipayCommerceIotDeviceBaseinfoQueryResponse : AopResponse
+    {
+        /// <summary>
+        /// 设备ID,biztid
+        /// </summary>
+        [XmlElement("device_id")]
+        public string DeviceId { get; set; }
+    }
+}

+ 12 - 0
AppStart/Alipay/Response/AlipayMerchantIndirectIotUnbindResponse.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Xml.Serialization;
+
+namespace Aop.Api.Response
+{
+    /// <summary>
+    /// AlipayMerchantIndirectIotUnbindResponse.
+    /// </summary>
+    public class AlipayMerchantIndirectIotUnbindResponse : AopResponse
+    {
+    }
+}

+ 8 - 4
Controllers/HomeController.cs

@@ -147,12 +147,16 @@ namespace MySystem.Controllers
 
         public string test1()
         {
-            WebCMSEntities db = new WebCMSEntities();
-            MerchantAddInfo info = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 2) ?? new MerchantAddInfo();
+            // WebCMSEntities db = new WebCMSEntities();
+            // MerchantAddInfo info = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 2) ?? new MerchantAddInfo();
             // string result = WeChatFunctionForHD.Instance.MerchantApply(info);
             // string result = AlipayFunctionForHD.Instance.AuthOrderCreate(info, info.AlipayAuthToken);
-            string result = AlipayFunctionForHD.Instance.AuthOrderQuery("202308011033330180");
-            db.Dispose();
+            // string result = AlipayFunctionForHD.Instance.AuthOrderQuery("202308011033330180");
+            // db.Dispose();
+            // string result = AliIotFunction.Instance.IotBind("2088720723136476", "018271007948");
+            // string result = AliIotFunction.Instance.IotUnBind("2088720723136476", "018271007948");
+            string result = AliIotFunction.Instance.IotDeviceQuery("018271007948");
+            // string result = AliIotFunction.Instance.IotTradeVoice("018271007948", "2088720723136476", "50230823A01389941461", "3.00", "OTHER");
             return result;
             //{"alipay_merchant_indirect_authorder_create_response":{"code":"10000","msg":"Success","order_no":"202308011033330180","order_status":"AUDITING"},"sign":"FINNZ7lw92Igku4KfNp5+ETLLyBKgR0faoGU4mceiiAwe85jbslbwAuxqgewGxmrPys7iGkwTNkgK7D7mx+sjF1mHtPXBszb1WAeD5kF764/qQ7r1ziXI252D8+qN/GfUxtnaR1mFRHbXpeh9z3Hjiey0xtThPCRZO63rgNICa9oJ/kRTQ5AZpn1Ih+hWaSFVDHDhBTBJ/j1uzs4PedrVZqqUUXtFf+o0XI0mctdHjaXomSr5bx9wsc8asEveXDSP4s1JksqJy0Gi0x/Oqc9aq03eV1cwO+Hk5YMwML9Rm+mZDUrIDwUK5gsioM0wGVqJy19o2O2wAecOYtCFRNXnA=="}
 

+ 4 - 4
Startup.cs

@@ -189,10 +189,10 @@ namespace MySystem
             // {
             //     ProfitHelper.Instance.StartListenProfit();
             // }
-            HaoDaExtHelper.Instance.StartWeChat();
-            HaoDaExtHelper.Instance.StartAlipay();
-            HaoDaExtQueryHelper.Instance.StartWeChat();
-            HaoDaExtQueryHelper.Instance.StartAlipay();
+            // HaoDaExtHelper.Instance.StartWeChat();
+            // HaoDaExtHelper.Instance.StartAlipay();
+            // HaoDaExtQueryHelper.Instance.StartWeChat();
+            // HaoDaExtQueryHelper.Instance.StartAlipay();
             //必须打开的