SoftSDKInstance.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace LoyalSoftSDK
  5. {
  6. public class SoftSDKInstance
  7. {
  8. private static SoftSDKInstance instance;
  9. public static SoftSDKInstance GetInstance()
  10. {
  11. if(instance==null)
  12. {
  13. instance = new SoftSDKInstance();
  14. }
  15. return instance;
  16. }
  17. public delegate void SoftCallBackHandler(string datat);
  18. public SoftCallBackHandler OnCallBackHandler;
  19. public const int PayPlugCode = 2;
  20. // public const string payWx = "http://120.26.46.141/official/pay/wxpay/pay.php";
  21. // public const string payZfb = "http://120.26.46.141/official/pay/alipay/pay.php";
  22. // public const string payWx = "115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php";
  23. // public const string payZfb = "115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php";
  24. /// <summary>
  25. /// 是否外网, true:外网地址, false:内网地址(192.168.10.xx).
  26. /// </summary>
  27. public readonly static eNetType netType = eNetType.Online_dev;
  28. public readonly static string payWx = netType switch
  29. {
  30. eNetType.Online => "https://ylsjtt.game7000.com/ylsj2019/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php",
  31. _=> "https://ylsjtt.game7000.com/ylsj2019_dev/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php",
  32. };
  33. public readonly static string payZfb = netType switch
  34. {
  35. eNetType.Online => "https://ylsjtt.game7000.com/ylsj2019/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php",
  36. _ => "https://ylsjtt.game7000.com/ylsj2019_dev/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php"
  37. };
  38. // public readonly static string payWx =GlobalConfig.netType == eNetType.
  39. // }// = "";// "https://ylsjtt.game7000.com/ylsj2019/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php";//"115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php";
  40. // public const string payZfb = "";//"https://ylsjtt.game7000.com/ylsj2019/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php";//"115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php";
  41. // public const string payWxdev = "https://ylsjtt.game7000.com/ylsj2019_dev/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php";//"115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php";
  42. //public const string payZfbdev = "https://ylsjtt.game7000.com/ylsj2019_dev/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php";//"115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php";
  43. public void InitSDK(string appId)
  44. {
  45. if (appId.Equals("test"))
  46. {
  47. UIFormManager.GetInstance().InitCanvas();
  48. Dictionary<string, string> data = new Dictionary<string, string>();
  49. data.Add("action", "Init");
  50. data.Add("title", "初始化");
  51. //UIFormManager.GetInstance().ShowUIForm("TestPanel", null, data);
  52. }
  53. else
  54. {
  55. Dictionary<string, object> backData = new Dictionary<string, object>();
  56. if (UIFormManager.GetInstance().InitCanvas())
  57. {
  58. backData.Add("action", "initSuccees");
  59. backData.Add("data", "loyal");
  60. backData.Add("msg", "初始化成功");
  61. }
  62. else
  63. {
  64. backData.Add("action", "initFail");
  65. backData.Add("data", "loyal");
  66. backData.Add("msg", "初始化失败");
  67. }
  68. SendCallBackMsg(MiniJSON.Json.Serialize(backData));
  69. }
  70. }
  71. public void LoginSDK(bool autoLogin)
  72. {
  73. Dictionary<string, string> data = new Dictionary<string, string>();
  74. data.Add("action", "star");
  75. data.Add("autoLogin", autoLogin.ToString());
  76. UIFormManager.GetInstance().ShowUIForm("LoginPanel",null, data);
  77. }
  78. public void LogOutSDK()
  79. {
  80. if (UserManager.GetInstance().GetCurUser() == null) return;
  81. UserManager.GetInstance().SetSaveUserData(UserManager.GetInstance().GetCurUser().Account,"", UserManager.GetInstance().GetSaveUser().lastLoginTime);
  82. UserManager.GetInstance().ClearCurUser();
  83. UIFormManager.GetInstance().CloseUIForm("FloatPanel");
  84. Dictionary<string, object> backData = new Dictionary<string, object>();
  85. backData.Add("action", "logoutSuccees");
  86. backData.Add("data", "");
  87. backData.Add("msg", "登出成功");
  88. SendCallBackMsg(MiniJSON.Json.Serialize(backData));
  89. }
  90. public void ExitGame()
  91. {
  92. UIFormManager.GetInstance().OnEscape();
  93. // UIFormManager.GetInstance().ShowUIForm("ExitGamePanel", null, null);
  94. }
  95. public void SubmitData()
  96. {
  97. }
  98. public void Pay(string product_id, string product_name,string product_count,string product_price, string party_id, string party_name,
  99. string amount,string zoneid,string callbackInfo,string ageRange )
  100. {
  101. Debug.Log("install pay");
  102. Dictionary<string, string> data = new Dictionary<string, string>();
  103. data.Add("action", "pay");
  104. data.Add("product_id", product_id);
  105. data.Add("product_name", product_name);
  106. data.Add("product_count", product_count);
  107. data.Add("product_price", product_price);
  108. data.Add("party_id", party_id);
  109. data.Add("party_name", party_name);
  110. data.Add("ageRange ", ageRange);
  111. data.Add("amount", amount);
  112. data.Add("zoneid", zoneid);
  113. data.Add("callbackInfo", callbackInfo);
  114. if (!GlobalConfig.is_SandBox)
  115. {
  116. UIFormManager.GetInstance().ShowUIForm("PayPanel", null, data);
  117. }
  118. else
  119. {
  120. List<KeyValuePair<string, string>> listdata=new List<KeyValuePair<string, string>> ();
  121. //listdata.Add(new KeyValuePair<string, string>("action", "pay"));
  122. //listdata.Add(new KeyValuePair<string, string>("product_id", product_id));
  123. //listdata.Add(new KeyValuePair<string, string>("product_name", product_name));
  124. //listdata.Add(new KeyValuePair<string, string>("product_count", product_count));
  125. //listdata.Add(new KeyValuePair<string, string>("product_price", product_price));
  126. //listdata.Add(new KeyValuePair<string, string>("party_id", party_id));
  127. //listdata.Add(new KeyValuePair<string, string>("party_name", party_name));
  128. //listdata.Add(new KeyValuePair<string, string>("ageRange ", ageRange));
  129. //listdata.Add(new KeyValuePair<string, string>("amount", amount));
  130. //listdata.Add(new KeyValuePair<string, string>("zoneid", zoneid));
  131. //listdata.Add(new KeyValuePair<string, string>("callbackInfo", callbackInfo));
  132. //listdata.Add(new KeyValuePair<string, string>("accountId", UserProxy.Instance.player.uid));
  133. //listdata.Add(new KeyValuePair<string, string>("channel","soft"));
  134. listdata.Add(new KeyValuePair<string, string>("accountId", UserProxy.Instance.player.uid));
  135. listdata.Add(new KeyValuePair<string, string>("amount", amount));
  136. listdata.Add(new KeyValuePair<string, string>("channel", "soft"));
  137. listdata.Add(new KeyValuePair<string, string>("callbackInfo", callbackInfo));
  138. listdata.Add(new KeyValuePair<string, string>("zoneid", zoneid));
  139. listdata.Add(new KeyValuePair<string, string>("product_id", product_id));
  140. listdata.Add(new KeyValuePair<string, string>("product_name", product_name));
  141. listdata.Add(new KeyValuePair<string, string>("product_count", product_count));
  142. listdata.Add(new KeyValuePair<string, string>("product_price", product_price));
  143. listdata.Add(new KeyValuePair<string, string>("party_id", party_id));
  144. listdata.Add(new KeyValuePair<string, string>("party_name", party_name));
  145. listdata.Add(new KeyValuePair<string, string>("ageRange", "18"));
  146. FakePay(listdata);
  147. }
  148. }
  149. public void SetCallBack(SoftCallBackHandler callback)
  150. {
  151. OnCallBackHandler = callback;
  152. }
  153. public void SendCallBackMsg(string datat)
  154. {
  155. if(OnCallBackHandler!=null)
  156. {
  157. OnCallBackHandler.Invoke(datat);
  158. }
  159. }
  160. public void GetSoftPayBack(string jsonData)
  161. {
  162. Dictionary<string, string> data = new Dictionary<string, string>();
  163. data.Add("action", "paySult");
  164. UIFormManager.GetInstance().ShowUIForm("PayPanel", null, data);
  165. }
  166. public void SendtoPayPanl(string jsonData)
  167. {
  168. if(UIFormManager.GetInstance().paypanl==null)
  169. {
  170. Debug.LogError("确认打开过支付界面吗?");
  171. return;
  172. }
  173. UIFormManager.GetInstance().paypanl.GetPayResults(jsonData);
  174. }
  175. public void FakePay(List<KeyValuePair<string, string>> data)
  176. {
  177. ///测试待修改.这里要加.
  178. ///测试待修改.这里要加.
  179. ShopProxy.Instance.ImitateBuy(data, (s) =>
  180. {
  181. PayProxy.Instance.PayDeliverGoods(long.Parse(s.cpOrderId), (lst) =>
  182. {
  183. if (lst.Count > 0)
  184. {
  185. PanelHelper.Instance.ShowPanel("UI_ShopPrizesPanel", (panel) =>
  186. {
  187. PanelHelper.Instance.ClosePanel("UI_WaitingForPaySuccessWindow");
  188. UI_ShopPrizesPanel shopPrize = panel.GetComponent<UI_ShopPrizesPanel>();
  189. shopPrize.Init();
  190. shopPrize.Show(lst);
  191. });
  192. }
  193. else
  194. {
  195. PanelHelper.Instance.ClosePanel("UI_WaitingForPaySuccessWindow");
  196. UI_CueDialog.Instance().Open("交易完成");
  197. }
  198. Debug.Log("交易完成");
  199. });
  200. });
  201. }
  202. }
  203. }