ThreePlatform.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\logic\LdysPay;
  4. use think\Cache;
  5. use think\Config;
  6. use think\Controller;
  7. /**
  8. * 第三方平台处理
  9. */
  10. class ThreePlatform extends Api
  11. {
  12. public function _initialize(){
  13. $this->isApiDebug = true;
  14. }
  15. // 微信授权
  16. public function getWxAuthCode(){
  17. $code = input('post.code');
  18. if(!$code){
  19. return json_encode(["code" => 100, "message" => "缺少必要请求参数!", "data" => ""]);
  20. }
  21. $config = Config::get('wxmp_config');
  22. $result = get_http_response('https://api.weixin.qq.com/sns/jscode2session', http_build_query([
  23. 'appid' => $config['app_id'],
  24. 'secret' => $config['secret'],
  25. 'js_code' => $code,
  26. 'grant_type' => 'authorization_code',
  27. ]), 'get');
  28. if(!$result){
  29. return json_encode(["code" => 100, "message" => "授权失败!", "data" => '']);
  30. }
  31. $result = json_decode($result, true);
  32. return json_encode(["code" => 200, "message" => "success", "data" => ['openid' => $result['openid']]]);
  33. }
  34. // 订单详情
  35. public function getOrderInfo(){
  36. $order_id = input('order_id');
  37. $is_debug = input('is_debug', 0);
  38. if ($is_debug == 1) {
  39. $orderId = makeOrderid('Test_WL');
  40. $data = [
  41. 'title' => '产品指南购买',
  42. 'amount' => 0.1,
  43. 'game_id' => 10,
  44. 'order_id' => $orderId,
  45. ];
  46. Cache::store('redis')->set('ldzf_order:'.$orderId, json_encode($data), 300);
  47. $this->jsonResult(['orderInfo' => $data], 200, 'success');
  48. }
  49. if (!$order_id) {
  50. $this->jsonResult([], 100, '缺少必要参数:order_id');
  51. }
  52. $result = (new LdysPay())->queryOrder($order_id);
  53. if ($result['error'] == true) {
  54. $this->jsonResult([], 100, '订单不存在或参数有误!');
  55. }
  56. $payData = $result['data'];
  57. $this->jsonResult(['orderInfo' => $payData], 200, 'success');
  58. }
  59. // 获取联动支付订单
  60. public function getPay()
  61. {
  62. $open_id = input('open_id');
  63. $order_id = input('order_id');
  64. $pay_type = input('pay_type');
  65. $is_debug = input('is_debug', 0);
  66. if (!$open_id) {
  67. $this->jsonResult([], 100, '缺少必要参数:open_id');
  68. }
  69. if (!$order_id) {
  70. $this->jsonResult([], 100, '缺少必要参数:order_id');
  71. }
  72. if (!$pay_type) {
  73. $this->jsonResult([], 100, '缺少必要参数:pay_type');
  74. }
  75. if ($is_debug == 1) {
  76. $payData = [
  77. 'title' => '测试产品',
  78. 'amount' => 0.1,
  79. ];
  80. } else {
  81. $result = (new LdysPay())->queryOrder($order_id);
  82. if ($result['error'] == true) {
  83. $this->jsonResult([], 100, '订单不存在或参数有误!');
  84. }
  85. $payData = $result['data'];
  86. }
  87. $payData['open_id'] = $open_id;
  88. $payData['order_id'] = $order_id;
  89. $result = (new LdysPay())->getWxmpPay($pay_type, $payData);
  90. if ($result['code'] == 110) {
  91. $this->jsonResult([], 110, $result['msg']);
  92. }
  93. if ($result['code'] != 200) {
  94. $this->jsonResult([], 100, $result['msg']);
  95. }
  96. // $payData['amount'] = formatFenToYuan($payData['amount']);
  97. unset($payData['open_id']);
  98. $this->jsonResult(['payInfo' => $result['data']], 200, 'success');
  99. }
  100. public function getWxH5Pay()
  101. {
  102. }
  103. // 文章列表
  104. public function getArticleList()
  105. {
  106. $list = [
  107. [
  108. "id" => 101,
  109. "title" => "关于我们",
  110. "source" => "祈点",
  111. "read_num" => 198,
  112. "is_top" => true,
  113. ], [
  114. "id" => 102,
  115. "title" => "祈点信息技术有限责任公司",
  116. "source" => "祈点",
  117. "read_num" => 66,
  118. "is_top" => false,
  119. ]
  120. ];
  121. $banner_list = [
  122. // [
  123. // "img" => "http://devsdkapi.".QM_DOMAIN_URL."/static/mp_static/1715311006322.jpg",
  124. // "title" => "师出鬼谷《秦时明月沧海》手游人物介绍之剑圣盖聂"
  125. // ], [
  126. // "img" => "http://devsdkapi.".QM_DOMAIN_URL."/static/mp_static/1715309868736.jpg",
  127. // "title" => "千里挥戈,霸王降临!《秦时明月沧海》手游项羽介绍"
  128. // ], [
  129. // "img" => "http://devsdkapi.".QM_DOMAIN_URL."/static/mp_static/1715311040373.jpg",
  130. // "title" => "记小本本《我的御剑日记》手游睚眦角色爆料"
  131. // ]
  132. ];
  133. $this->jsonResult(['list' => $list, 'banner_list' => $banner_list], 200, 'success');
  134. }
  135. // 文章详情
  136. public function getArticleInfo()
  137. {
  138. $id = input('id');
  139. if (!$id) {
  140. $this->jsonResult([], 100, '缺少必要参数:id');
  141. }
  142. $list = [
  143. 101 => [
  144. "title" => "关于我们",
  145. "source" => "祈点",
  146. "time" => "2024-04-15",
  147. "read_num" => 198,
  148. "body" => '<p>线上通用产品:</p><p>- SDK 接入。</p><p>- 数据统计汇总。</p><p>技术服务产品:</p><p>&ZeroWidthSpace;<br>- 技术输出。</p><p>- 支付生态输出。</p><p><br></p><p>行业应用产品:</p><p>- SDK 接入平台。</p><p>- CPS SDK 平台。</p>'
  149. ],
  150. 102 => [
  151. "title" => "祈点信息技术有限责任公司",
  152. "source" => "祈点",
  153. "time" => "2024-04-15",
  154. "read_num" => 68,
  155. "body" => '<p><span style="color: rgb(34, 34, 34); font-family: 微软雅黑; text-wrap: wrap; background-color: rgb(244, 244, 244);">祈点信息技术有限责任公司,公司坐落于银湖创新中心,是富阳区招商引资重点企业。公司主要从事互联网相关,集研发、运营、销售、互联网增值业务为一体的综合性互动娱乐企业。公司先后发行了《侠影双剑》&nbsp;、&nbsp;《大魔法时代》、《圣剑英灵传》、《唐门六道》、《破碎黎明2》等游戏。</span>&ZeroWidthSpace;</p>'
  156. ],
  157. ];
  158. $info = $list[$id];
  159. $this->jsonResult(['info' => $info], 200, 'success');
  160. }
  161. // 巨量引擎开放平台
  162. public function oceanengine()
  163. {
  164. $input = input();
  165. $data = json_encode($input);
  166. log_message('## ThreePlatform@oceanengine:' . $data, 'log', LOG_PATH . 'threePlatform/');
  167. }
  168. }