PottingMobileServicesEditor.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using simplejson;
  5. using UnityEngine;
  6. public class PottingMobileServicesEditor : PottingMobileServicesBase
  7. {
  8. static PottingMobileServicesEditor()
  9. {
  10. InitManager();
  11. }
  12. /**
  13. * 获取服务器配置
  14. * appver:如果不需要根据版本判断可以串0
  15. * lastver:每次全新获取传0
  16. *
  17. * @param appVer
  18. * @param lastVer
  19. */
  20. public static void _configSync(string appVer, int lastVer)
  21. {
  22. YouLoftServices.ServerConfig((i, s) =>
  23. {
  24. PottingMobileServicesManger.Instance.ConfigSync(GETJsonString(i,s));
  25. });
  26. }
  27. /**
  28. * 渠道下单接口,根据不同渠道需要的数据不同
  29. * 返回的数据结构不同,前端需要根据情况解析
  30. *
  31. * @param channel 渠道
  32. * @param goodsid 商品ID
  33. */
  34. public static void _channelPayOrder(int channel, string goodsid)
  35. {
  36. YouLoftServices._channelPayOrder(channel,goodsid, (i, s) =>
  37. {
  38. PottingMobileServicesManger.Instance.ChannelpayOrder(GETJsonString(i,s));
  39. });
  40. }
  41. /**
  42. * 获取当前游戏,渠道的最新版本
  43. * 返回结果无加密
  44. *
  45. * @param channel 渠道
  46. */
  47. public static void _channelPayGetAppVersion(int channel)
  48. {
  49. YouLoftServices.GameServerVersion(channel, (i, s) =>
  50. {
  51. PottingMobileServicesManger.Instance.ChannelpayGetAppVersion(GETJsonString(i,s));
  52. });
  53. }
  54. /**
  55. * 兑换码兑换接口
  56. *
  57. * @param redeemcode 兑换码
  58. */
  59. public static void _dedeemConsume(string redeemcode)
  60. {
  61. YouLoftServices.RedemptionCode(redeemcode, (i, s) =>
  62. {
  63. PottingMobileServicesManger.Instance.DedeemConsume(GETJsonString(i,s));
  64. });
  65. }
  66. /**
  67. * 登录接口
  68. *
  69. * @param id 设备ID 或者第三方登录平台的ID
  70. * @param type 登录类型
  71. * @param name 用户昵称
  72. * @param icon 用户头像链接
  73. */
  74. public static void _userLogin(string id, int type, string name, string icon)
  75. {
  76. YouLoftServices.Login(id,type,name,icon, (i, s) =>
  77. {
  78. PottingMobileServicesManger.Instance.UserLogin(GETJsonString(i,s));
  79. });
  80. }
  81. /**
  82. * 获取(提交)存档到服务器
  83. * 1.每次启动游戏优先获取存档
  84. * 2.当有需要更新的存档时提交服务器
  85. * 提交存档时服务器会默认覆盖以前的存档不会做其他判断
  86. * 请求需要签名,返回数据有加密
  87. *
  88. * @param archive
  89. * @param archiveVersion
  90. */
  91. public static void _userSync(string archive, int archiveVersion)
  92. {
  93. YouLoftServices.CommitArchive(archive,archiveVersion, (i, s) =>
  94. {
  95. PottingMobileServicesManger.Instance.UserSync(GETJsonString(i,s));
  96. });
  97. }
  98. /**
  99. * 心跳检测,判断当前客户端登陆是否有效
  100. * 请求需要签名,返回数据无加密
  101. */
  102. public static void _userHeartbeat()
  103. {
  104. YouLoftServices._userHeartbeat((i, s) =>
  105. {
  106. PottingMobileServicesManger.Instance.UserHeartbeat(GETJsonString(i,s));
  107. });
  108. }
  109. /**
  110. * 用户下订接口,下单成功之后返回支付链接
  111. * -跳转支付页面
  112. *
  113. * @param goodsid 商品ID
  114. */
  115. public static void _userOrder(string goodsid, string activityid)
  116. {
  117. YouLoftServices.RequestOrder(goodsid,activityid, (code, starUrl,endUrl,orderid) =>
  118. {
  119. if (code==1)
  120. {
  121. code = 200;
  122. }
  123. if (code==2)
  124. {
  125. code = 4000;
  126. }
  127. var jsonData = new JSONObject
  128. {
  129. ["code"] = code,
  130. ["data"] =starUrl,
  131. ["returnAppLink"] =endUrl,
  132. ["orderid"] =orderid
  133. };
  134. PottingMobileServicesManger.Instance.UserOrder(jsonData.ToString());
  135. });
  136. }
  137. /**
  138. * 恢复购买,查看已完成的所有订单,以及消耗状态
  139. * 请求需要签名,返回结果有加密
  140. */
  141. public static void _userResumepurchase()
  142. {
  143. YouLoftServices.ResumeOrder((i, s) =>
  144. {
  145. PottingMobileServicesManger.Instance.UserResumepurchase(GETJsonString(i,s));
  146. });
  147. }
  148. /**
  149. * 订单消耗
  150. * 请求需要签名,返回结果有加密
  151. *
  152. * @param goodsid 商品ID
  153. * @param orderId 订单ID
  154. */
  155. public static void _userConsume(string goodsid, string orderId)
  156. {
  157. YouLoftServices.ConsumeOrder(goodsid,orderId, (i, s) =>
  158. {
  159. PottingMobileServicesManger.Instance.UserConsume(GETJsonString(i,s));
  160. });
  161. }
  162. /**
  163. * 查询单个订单的状态
  164. * 用来处理非消耗性商品,判断订单是否支付完成
  165. * 返回结果有加密
  166. *
  167. * @param goodsid 商品ID
  168. * @param orderId 订单ID
  169. */
  170. public static void _userQueryOrder(string goodsid, string orderId)
  171. {
  172. YouLoftServices._userQueryOrder(goodsid,orderId, (i, s) =>
  173. {
  174. PottingMobileServicesManger.Instance.UserQueryOrder(GETJsonString(i,s));
  175. });
  176. }
  177. /**
  178. * 提交用户分数
  179. * 返回用户排行榜信息,返回结果无加密
  180. *
  181. * @param score 名次
  182. * @param info 排名信息
  183. * @param rankingid 排名ID
  184. */
  185. public static void _userUploadScore(int score, string info, string rankingid)
  186. {
  187. YouLoftServices.UploadScore(rankingid,score,info,(b)=>
  188. {
  189. int code = b? 200 : 4000;
  190. var jsonData = new JSONObject
  191. {
  192. ["code"] = code,
  193. ["data"] =b
  194. };
  195. PottingMobileServicesManger.Instance.UserUploadScore(jsonData.ToString());
  196. });
  197. }
  198. /**
  199. * 获取用户自己的排名
  200. *
  201. * @param rankingid 排行榜ID
  202. */
  203. public static void _userGetUserRank(string rankingid)
  204. {
  205. YouLoftServices._userGetUserRank(rankingid, (i, s) =>
  206. {
  207. PottingMobileServicesManger.Instance.GetActivitiesWithChannel(GETJsonString(i,s));
  208. });
  209. }
  210. /// <summary>
  211. /// 获取活动
  212. /// </summary>
  213. /// <param name="channel">渠道</param>
  214. /// <param name="language">语言</param>
  215. public static void _getActivitiesWithChannel(string channel, string language)
  216. {
  217. YouLoftServices.ActivityBy(channel, language, (i, s) =>
  218. {
  219. PottingMobileServicesManger.Instance.GetActivitiesWithChannel(GETJsonString(i,s));
  220. });
  221. }
  222. /// <summary>
  223. /// 获取公告
  224. /// </summary>
  225. /// <param name="channel">渠道</param>
  226. /// <param name="version">版本</param>
  227. /// <param name="language">语言</param>
  228. public static void _getGameAnoncementsWithChannel(string channel, string version, string language)
  229. {
  230. YouLoftServices.AnnouncementBy(channel, version,language, (i, s) =>
  231. {
  232. PottingMobileServicesManger.Instance.GameAnoncementsWithChannel(GETJsonString(i,s));
  233. });
  234. }
  235. /// <summary>
  236. /// 根据渠道兑换码兑换接口
  237. /// </summary>
  238. /// <param name="redeemCode">兑换码</param>
  239. /// <param name="channel">渠道</param>
  240. public static void _redeemConsume(string redeemCode, string channel)
  241. {
  242. YouLoftServices._redeemConsume(redeemCode,channel, (i, s) =>
  243. {
  244. PottingMobileServicesManger.Instance.RedeemConsume(GETJsonString(i,s));
  245. });
  246. }
  247. /// <summary>
  248. /// 根据渠道兑换码兑换接口,需要用户登录
  249. /// </summary>
  250. /// <param name="redeemCode"></param>
  251. /// <param name="channel"></param>
  252. public static void _redeemUserConsume(string redeemCode, string channel,string clientId)
  253. {
  254. YouLoftServices._redeemUserConsume(redeemCode,channel, (i, s) =>
  255. {
  256. PottingMobileServicesManger.Instance.RedeemUserConsume(GETJsonString(i,s));
  257. });
  258. }
  259. public static void _FeedBackSubmit(string msg, string connect, string docInfo)
  260. {
  261. YouLoftServices.Feedback(msg,connect,"","","", "",(i,s) =>
  262. {
  263. PottingMobileServicesManger.Instance.feedBackSubmitComplected(GETJsonString(i,s));
  264. });
  265. }
  266. /// <summary>
  267. /// 上报关键数据
  268. /// </summary>
  269. /// <param name="lable"></param>
  270. public static void _GameInfoUpload (Dictionary<string, string> lable) {
  271. }
  272. /// <summary>
  273. /// 上报付费
  274. /// </summary>
  275. public static void _PayrecordSubmit()
  276. {
  277. }
  278. public static string GETJsonString(int code,string data )
  279. {
  280. if (code==1)
  281. {
  282. code = 200;
  283. }
  284. if (code==2)
  285. {
  286. code = 4000;
  287. }
  288. var jsonData = new JSONObject
  289. {
  290. ["code"] = code,
  291. ["data"] =data
  292. };
  293. Debug.Log(jsonData.ToString());
  294. return jsonData.ToString();
  295. }
  296. /// <summary>
  297. /// 获取服务器信息
  298. /// </summary>
  299. public static void _Serverinfo()
  300. {
  301. }
  302. }