| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?php
- namespace app\api\controller;
- use app\common\logic\LdysPay;
- use think\Cache;
- use think\Config;
- use think\Controller;
- /**
- * 第三方平台处理
- */
- class ThreePlatform extends Api
- {
- public function _initialize(){
- $this->isApiDebug = true;
- }
- // 微信授权
- public function getWxAuthCode(){
- $code = input('post.code');
- if(!$code){
- return json_encode(["code" => 100, "message" => "缺少必要请求参数!", "data" => ""]);
- }
- $config = Config::get('wxmp_config');
- $result = get_http_response('https://api.weixin.qq.com/sns/jscode2session', http_build_query([
- 'appid' => $config['app_id'],
- 'secret' => $config['secret'],
- 'js_code' => $code,
- 'grant_type' => 'authorization_code',
- ]), 'get');
- if(!$result){
- return json_encode(["code" => 100, "message" => "授权失败!", "data" => '']);
- }
- $result = json_decode($result, true);
- return json_encode(["code" => 200, "message" => "success", "data" => ['openid' => $result['openid']]]);
- }
- // 订单详情
- public function getOrderInfo(){
- $order_id = input('order_id');
- $is_debug = input('is_debug', 0);
- if ($is_debug == 1) {
- $orderId = makeOrderid('Test_WL');
- $data = [
- 'title' => '产品指南购买',
- 'amount' => 0.1,
- 'game_id' => 10,
- 'order_id' => $orderId,
- ];
- Cache::store('redis')->set('ldzf_order:'.$orderId, json_encode($data), 300);
- $this->jsonResult(['orderInfo' => $data], 200, 'success');
- }
- if (!$order_id) {
- $this->jsonResult([], 100, '缺少必要参数:order_id');
- }
- $result = (new LdysPay())->queryOrder($order_id);
- if ($result['error'] == true) {
- $this->jsonResult([], 100, '订单不存在或参数有误!');
- }
- $payData = $result['data'];
- $this->jsonResult(['orderInfo' => $payData], 200, 'success');
- }
- // 获取联动支付订单
- public function getPay()
- {
- $open_id = input('open_id');
- $order_id = input('order_id');
- $pay_type = input('pay_type');
- $is_debug = input('is_debug', 0);
- if (!$open_id) {
- $this->jsonResult([], 100, '缺少必要参数:open_id');
- }
- if (!$order_id) {
- $this->jsonResult([], 100, '缺少必要参数:order_id');
- }
- if (!$pay_type) {
- $this->jsonResult([], 100, '缺少必要参数:pay_type');
- }
- if ($is_debug == 1) {
- $payData = [
- 'title' => '测试产品',
- 'amount' => 0.1,
- ];
- } else {
- $result = (new LdysPay())->queryOrder($order_id);
- if ($result['error'] == true) {
- $this->jsonResult([], 100, '订单不存在或参数有误!');
- }
- $payData = $result['data'];
- }
- $payData['open_id'] = $open_id;
- $payData['order_id'] = $order_id;
- $result = (new LdysPay())->getWxmpPay($pay_type, $payData);
- if ($result['code'] == 110) {
- $this->jsonResult([], 110, $result['msg']);
- }
- if ($result['code'] != 200) {
- $this->jsonResult([], 100, $result['msg']);
- }
- // $payData['amount'] = formatFenToYuan($payData['amount']);
- unset($payData['open_id']);
- $this->jsonResult(['payInfo' => $result['data']], 200, 'success');
- }
- public function getWxH5Pay()
- {
- }
- // 文章列表
- public function getArticleList()
- {
- $list = [
- [
- "id" => 101,
- "title" => "关于我们",
- "source" => "祈点",
- "read_num" => 198,
- "is_top" => true,
- ], [
- "id" => 102,
- "title" => "祈点信息技术有限责任公司",
- "source" => "祈点",
- "read_num" => 66,
- "is_top" => false,
- ]
- ];
- $banner_list = [
- // [
- // "img" => "http://devsdkapi.".QM_DOMAIN_URL."/static/mp_static/1715311006322.jpg",
- // "title" => "师出鬼谷《秦时明月沧海》手游人物介绍之剑圣盖聂"
- // ], [
- // "img" => "http://devsdkapi.".QM_DOMAIN_URL."/static/mp_static/1715309868736.jpg",
- // "title" => "千里挥戈,霸王降临!《秦时明月沧海》手游项羽介绍"
- // ], [
- // "img" => "http://devsdkapi.".QM_DOMAIN_URL."/static/mp_static/1715311040373.jpg",
- // "title" => "记小本本《我的御剑日记》手游睚眦角色爆料"
- // ]
- ];
- $this->jsonResult(['list' => $list, 'banner_list' => $banner_list], 200, 'success');
- }
- // 文章详情
- public function getArticleInfo()
- {
- $id = input('id');
- if (!$id) {
- $this->jsonResult([], 100, '缺少必要参数:id');
- }
- $list = [
- 101 => [
- "title" => "关于我们",
- "source" => "祈点",
- "time" => "2024-04-15",
- "read_num" => 198,
- "body" => '<p>线上通用产品:</p><p>- SDK 接入。</p><p>- 数据统计汇总。</p><p>技术服务产品:</p><p>​<br>- 技术输出。</p><p>- 支付生态输出。</p><p><br></p><p>行业应用产品:</p><p>- SDK 接入平台。</p><p>- CPS SDK 平台。</p>'
- ],
- 102 => [
- "title" => "祈点信息技术有限责任公司",
- "source" => "祈点",
- "time" => "2024-04-15",
- "read_num" => 68,
- "body" => '<p><span style="color: rgb(34, 34, 34); font-family: 微软雅黑; text-wrap: wrap; background-color: rgb(244, 244, 244);">祈点信息技术有限责任公司,公司坐落于银湖创新中心,是富阳区招商引资重点企业。公司主要从事互联网相关,集研发、运营、销售、互联网增值业务为一体的综合性互动娱乐企业。公司先后发行了《侠影双剑》 、 《大魔法时代》、《圣剑英灵传》、《唐门六道》、《破碎黎明2》等游戏。</span>​</p>'
- ],
- ];
- $info = $list[$id];
- $this->jsonResult(['info' => $info], 200, 'success');
- }
-
- // 巨量引擎开放平台
- public function oceanengine()
- {
- $input = input();
- $data = json_encode($input);
- log_message('## ThreePlatform@oceanengine:' . $data, 'log', LOG_PATH . 'threePlatform/');
- }
- }
|