From 5c2713ae3144554964e06249a22db677e4da88be Mon Sep 17 00:00:00 2001 From: lcc Date: Thu, 8 Aug 2024 16:36:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=97=A8=E5=BA=97=E5=92=8C?= =?UTF-8?q?=E8=BD=AE=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/libraries/SsApi.php | 52 +++- .../market/Market_sytopic_module_model.php | 6 +- .../Market_sytopic_module_option_model.php | 24 ++ .../controllers/h5/market/sytopic/Welcome.php | 16 ++ home/views/h5/market/sytopic/index.php | 241 +++++++++--------- 5 files changed, 216 insertions(+), 123 deletions(-) diff --git a/common/libraries/SsApi.php b/common/libraries/SsApi.php index 19d36242..f4de20c9 100644 --- a/common/libraries/SsApi.php +++ b/common/libraries/SsApi.php @@ -4,8 +4,9 @@ defined('BASEPATH') or exit('No direct script access allowed'); class SsApi { const CF_PLATFORM = "SYSTOPIC"; - const CLUES_METHOD = 'openApi/clues'; - const STATUS_METHOD = 'openApi/status'; + const CLUES_METHOD = 'openApi/clues'; //提交线索 + const STATUS_METHOD = 'openApi/status'; //获取报名状态 + const BIZ_METHOD = 'openApi/biz'; //门店信息 private $app_id = '1c156bb57cd6984a'; private $sign_key = '71fd71173b776766a2ae1209d9a2c2ed'; private $api_url = 'https://api.haodian.cn/hd/app/'; //空间站报名数据接口 @@ -75,8 +76,8 @@ class SsApi public function getStatus($out_ids) { - if(is_array($out_ids)){ - $out_ids = implode(',',$out_ids); + if (is_array($out_ids)) { + $out_ids = implode(',', $out_ids); } $data = [ 'out_ids' => $out_ids, @@ -112,6 +113,49 @@ class SsApi } } + public function getBiz($biz_id, $cache = true) + { + $cacheKey = "SYTSTOPIC_SSAPI_BIZ_{$biz_id}"; + $redis = &load_cache(); + if ($cache) { + $bizInfo = $redis->get($cacheKey); + if ($bizInfo) { + return ['code' => 1, 'msg' => 'success', 'data' => $bizInfo]; + } + } + //数据缓存 + $data = [ + 'biz_id' => $biz_id, + 'nonce_str' => random_string('alpha'), + 'app_id' => $this->app_id, + ]; + $data['sign'] = $this->sign($data); + $client = new GuzzleHttp\Client(); + $options = [ + \GuzzleHttp\RequestOptions::HEADERS => ['Content-Type' => 'application/json'], + ]; + $url = $this->api_url . self::BIZ_METHOD.'?'.http_build_query($data); + try { + debug_log("[info]#请求地址:" . $url, $this->log_path); + $response = $client->get($url, $options); + debug_log("[info]#返回信息:" . $response->getBody(), $this->log_path); + if ($response->getStatusCode() != 200) { + debug_log("[error]#" . $response->getStatusCode(), $this->log_path); + return ['code' => 0, 'msg' => '网络错误:' . $response->getStatusCode()]; + } + $reqInfo = json_decode($response->getBody(), true); + if (!$reqInfo || $reqInfo['code'] != 200) { + $msg = $reqInfo ? $reqInfo['msg'] : ''; + return ['code' => 0, 'msg' => '请求失败:' . $msg]; + } + $redis->save($cacheKey, $reqInfo['data'], 60 * 60); + return ['code' => 1, 'msg' => 'success', 'data' => $reqInfo['data']]; + } catch (Exception $e) { + debug_log("[error]#" . $e->getMessage(), $this->log_path); + return ['code' => 0, 'msg' => $e->getMessage()]; + } + } + private function sign($param) { unset($param['sign']); diff --git a/common/models/market/Market_sytopic_module_model.php b/common/models/market/Market_sytopic_module_model.php index a4218696..a53b3833 100644 --- a/common/models/market/Market_sytopic_module_model.php +++ b/common/models/market/Market_sytopic_module_model.php @@ -11,6 +11,7 @@ class Market_sytopic_module_model extends HD_Model const TYPE_GRID = 4; //网格排列表 const TYPE_HORIZONTAL = 5; // 横排 const TYPE_ARTICLE = 6; // 文章 + const TYPE_ENROLL_BANNER = 7; // 报名轮播图 const TYPE_ARRAY = [ // self::TYPE_BANNER => '主图', @@ -19,6 +20,7 @@ class Market_sytopic_module_model extends HD_Model self::TYPE_HORIZONTAL => '横排报名', self::TYPE_SWIPER_BANNER => '轮播图', self::TYPE_ARTICLE => '富文本', + self::TYPE_ENROLL_BANNER => '横排轮播图', ]; public function __construct() @@ -28,8 +30,8 @@ class Market_sytopic_module_model extends HD_Model public function getTopicModelIds($topicId) { - $where = ['topicId' => $topicId, 'status' => 0]; - $modelList = $this->map('id','type',$where, 'sort desc,type asc', 1, 100, 'id,type'); + $where = ['topicId' => $topicId, 'status' => 0, 'type!=' => self::TYPE_ENROLL_BANNER]; + $modelList = $this->map('id', 'type', $where, 'sort desc,type asc', 1, 100, 'id,type'); return $modelList ?: []; } diff --git a/common/models/market/Market_sytopic_module_option_model.php b/common/models/market/Market_sytopic_module_option_model.php index 343df6e6..bd2a1f7f 100644 --- a/common/models/market/Market_sytopic_module_option_model.php +++ b/common/models/market/Market_sytopic_module_option_model.php @@ -28,6 +28,30 @@ class Market_sytopic_module_option_model extends HD_Model return $lists; } + /** + * 获取头部轮播 + * @param $topicId + * @return array + */ + public function getTypeEnrollBannerList($topicId) + { + $this->load->model('market/market_sytopic_module_model'); + $moduleModel = new Market_sytopic_module_model(); + $modelList = $moduleModel->select(['type'=>$moduleModel::TYPE_ENROLL_BANNER],'','','','id'); + $lists = []; + if ($modelList) { + $modelIdsStr = implode(',', array_column($modelList,'id')); + $where = ['topicId' => $topicId, 'status' => 0, "moduleId in ({$modelIdsStr})" => null]; + $modelOptionsList = $this->select($where, "FIELD (moduleId,{$modelIdsStr})", 1, 100); + foreach ($modelOptionsList as $item) { + $lists[] = [ + 'banner' => $item['banner'] ? build_qiniu_image_url($item['banner']) : '' + ]; + } + } + return $lists; + } + //格式化数据 private function formItem($type, $item) { diff --git a/home/controllers/h5/market/sytopic/Welcome.php b/home/controllers/h5/market/sytopic/Welcome.php index a98e455d..65eef223 100644 --- a/home/controllers/h5/market/sytopic/Welcome.php +++ b/home/controllers/h5/market/sytopic/Welcome.php @@ -13,7 +13,9 @@ class Welcome extends Wx parent::__construct(); $this->load->model('market/Market_sytopic_module_option_model', 'module_option_model'); $this->load->model('market/Market_sytopic_enroll_model', 'sytopic_enroll_model'); + $this->load->model('market/market_sylive_organization_model','organization_model'); $this->load->library('qiniu'); + $this->load->library("ssApi"); $this->skey = $this->input->get_post('skey'); $param = $this->myencryption->base64url_decode($this->skey); $this->a_id = intval($param[self::SIGN_TOP_KEY]);//活动id @@ -38,11 +40,25 @@ class Welcome extends Wx 'isAdmin' => $this->user_model->checkTopicIsAdmin($this->uid, $this->a_id), 'channelName' => $channelRow ? $channelRow['uname'] : '', 'channelHeadImg' => $channelRow['headimg'] ?: 'https://img.liche.cn/liche/market/202407/p_e1065373f27937f69142c28ce975a398.png', + 'channelTel' => $channelRow ? $channelRow['mobile'] : '', 'banner' => $jsonData['banner'] ? build_qiniu_image_url($jsonData['banner']) : '', 'bgColor' => $jsonData['bg_color'] ?: '', ]; $moduleLists = $this->module_option_model->getTopicModelOptionsList($this->a_id); $this->data['modules'] = array_values($moduleLists); + $this->data['logoList'] = $this->module_option_model->getTypeEnrollBannerList($this->a_id); + //获取门店信息 + $orgRow = $this->organization_model->get(['organizationId'=>$row['organizationId']]); + $ssBizId = (int)$orgRow['comments']; + $biz = []; + if($ssBizId){ + $ssApi = new SsApi(); + $req = $ssApi->getBiz($ssBizId); + if($req['code']){ + $biz = $req['data']; + } + } + $info['biz'] = $biz; $this->data['info'] = $info; //获取配置信息 $wx_info = $this->share_info([], $row);//微信分享 diff --git a/home/views/h5/market/sytopic/index.php b/home/views/h5/market/sytopic/index.php index 4433115f..7e0bd7b0 100644 --- a/home/views/h5/market/sytopic/index.php +++ b/home/views/h5/market/sytopic/index.php @@ -1,4 +1,4 @@ - +
@@ -56,63 +56,72 @@
-
-
- - - 张三1领取了51000元大礼包 - 张三1领取了51000元大礼包 - 张三1领取了51000元大礼包 - - -
-
-
-
-

汽车之家空间站·厦门站官方

-
- -
-
-
-

营业时间:08:00-20:00

-
-

福建省厦门市湖里区翔远福建省厦门市湖里区翔远

- +
+
+
+
+

+ {{info.biz.biz_name}} + 官方 +

+
+ +
+
+
+
+

{{info.biz.address}}

+ +
+
+
+ +
-
-
- -
-
-
-
- - -
- +
+ + + +
+ +
+
- -
+