186 lines
8.4 KiB
PHP
186 lines
8.4 KiB
PHP
<?php
|
|
defined('WXAPP_ITEMS') OR exit('No direct script access allowed');
|
|
ini_set('display_errors', 'On');
|
|
error_reporting(E_ERROR);
|
|
|
|
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
|
|
|
/**
|
|
* Notes:专题
|
|
* Created on: 2021/10/9 15:16
|
|
* Created by: dengbw
|
|
*/
|
|
class Topic extends Wxapp
|
|
{
|
|
|
|
function __construct($inputs, $app_key)
|
|
{
|
|
parent::__construct($inputs, $app_key);
|
|
$this->login_white = '';//
|
|
$this->check_status = array();//用户状态校验
|
|
$this->check_mobile = array();//需要手机号
|
|
$this->check_headimg = array();//授权微信信息
|
|
$this->majia_white = array('get');//超级管理员披上马甲可操作权限
|
|
$this->load->model('app/material/Material_template_model', 'mdTemplate');
|
|
$this->load->model('app/material/Material_biz_model', 'mdMaterialBiz');
|
|
$this->load->model('app/material/Material_biz_statistics_model', 'mdBizStatistics');
|
|
$this->app_id == 1 && $this->app_id = 2;//获取狸车宝数据
|
|
}
|
|
|
|
/**
|
|
* Notes:专题首页
|
|
* Created on: 2021/10/12 11:47
|
|
* Created by: dengbw
|
|
* @return array
|
|
* @throws Exception
|
|
*/
|
|
protected function get()
|
|
{
|
|
$id = intval($this->input_param('id'));
|
|
$biz_id = intval($this->input_param('biz_id'));
|
|
$re = $this->mdTemplate->get(array('id' => $id, 'status' => 1));
|
|
if (!$re || empty($re)) {
|
|
throw new Hd_exception('专题不存在', API_CODE_FAIL);
|
|
}
|
|
$biz_info = ['pop' => 0];
|
|
if ($biz_id) {
|
|
$re_biz = $this->mdMaterialBiz->get(array('app_id' => $this->app_id, 't_id' => $id, 'biz_id' => $biz_id));
|
|
if (!$re_biz || empty($re_biz)) {
|
|
throw new Hd_exception('门店还未创建专题', API_CODE_FAIL);
|
|
}
|
|
//加店铺专题浏览
|
|
$where_s = ['app_id' => $this->app_id, 'biz_id' => $biz_id, 't_id' => $id, 'day' => date('Y-m-d')];
|
|
$re_s = $this->mdBizStatistics->get($where_s);
|
|
$key = "material_biz_browse_num_{$this->myuid}_{$this->app_id}_{$biz_id}_{$id}";
|
|
if ($re_s) {
|
|
if (!$this->app_redis->get($key)) {
|
|
$this->mdBizStatistics->update(['browse_num = browse_num+1' => null], $where_s);
|
|
$this->app_redis->save($key, 1, 24 * 3600);//有效期1天
|
|
}
|
|
} else {
|
|
$where_s['browse_num'] = 1;
|
|
$this->mdBizStatistics->add($where_s);
|
|
$this->app_redis->save($key, 1, 24 * 3600);//有效期1天
|
|
}
|
|
|
|
}
|
|
$lists = array();
|
|
if ($re['json_data']) {
|
|
$json_data = json_decode($re['json_data'], true);
|
|
if ($json_data['biz_pop']) {//授权弹窗
|
|
$biz_info['pop'] = $json_data['biz_pop'];
|
|
$biz_info['biz_name'] = '';
|
|
$biz_info['headimg'] = 'https://qs.haodian.cn/wechat_app/liche/common/dark-logo2.jpg';
|
|
$biz_info['pop_content'] = '您好,欢迎您访问狸车。授权手机号后将给您提供最新的新能源汽车资讯和优惠活动哦~';
|
|
if ($biz_id) {
|
|
$this->load->model("biz/biz_model", 'mdBiz');
|
|
$re_biz = $this->mdBiz->get(array('id' => $biz_id, 'status' => 1));
|
|
if ($re_biz) {
|
|
$biz_info['biz_name'] = $re_biz['biz_name'];
|
|
$re_biz['headimg'] && $biz_info['headimg'] = build_qiniu_image_url($re_biz['headimg']);
|
|
}
|
|
}
|
|
}
|
|
foreach ($json_data['lists'] as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['title'] = $value['title'];
|
|
if ($re['type'] == 1) {
|
|
$setValue['video_type'] = intval($value['video_type']);
|
|
if ($value['video_type'] == 1) {
|
|
$setValue['video'] = $value['video'] ? build_qiniu_image_url($value['video'], 0, 0, 'video') : '';
|
|
$setValue['video_cover'] = $value['video'] ? $value['video'] . '?vframe/jpg/offset/1' : '';
|
|
$setValue['width'] = $value['width'] ? $value['width'] : 16;
|
|
$setValue['height'] = $value['height'] ? $value['height'] : 9;
|
|
} else {
|
|
$setValue['img'] = $value['img'] ? build_qiniu_image_url($value['img']) : '';
|
|
$setValue['link'] = $value['link'];
|
|
}
|
|
} else {
|
|
$setValue['img'] = $value['img'] ? build_qiniu_image_url($value['img']) : '';
|
|
$setValue['link'] = $value['link'];
|
|
}
|
|
$lists[] = $setValue;
|
|
}
|
|
}
|
|
$this->data['id'] = $id;
|
|
$this->data['type'] = $re['type'];
|
|
$this->data['sign_up'] = 1;
|
|
$this->data['lists'] = $lists;
|
|
$this->data['biz_info'] = $biz_info;
|
|
return $this->data;
|
|
}
|
|
|
|
/**
|
|
* Notes:专题预约报名
|
|
* Created on: 2021/11/23 17:16
|
|
* Created by: dengbw
|
|
* @throws Hd_exception
|
|
*/
|
|
protected function put()
|
|
{
|
|
$this->load->model('sys/sys_area_model');
|
|
$this->load->model('receiver/receiver_clues_model', 'clues_model');
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->library('receiver/clues_entity');
|
|
$recommend_id = intval($this->input_param('cf_uid')); //来源用户id 分销
|
|
$biz_id = intval($this->input_param('biz_id'));
|
|
$t_id = intval($this->input_param('t_id'));
|
|
$city_id = $this->input_param('city_id');
|
|
$lat = $this->input_param('lat');
|
|
$lng = $this->input_param('lng');
|
|
$cf_id = 1;
|
|
$brand_id = 0;
|
|
$recommend_id && $cf_id = 8;
|
|
$city_id && $city_row = $this->sys_area_model->get(['county_id' => $city_id], 'id,county_id,city_id');
|
|
$re_t = $this->mdTemplate->get(['id' => $t_id]);
|
|
if ($re_t && $re_t['brand_ids']) {
|
|
$brand_ids = implode(',', $re_t['brand_ids']);
|
|
$brand_id = count($brand_ids) >= 2 ? $brand_ids[1] : $re_t['brand_ids'];
|
|
}
|
|
$brand_id == 3 && $brand_id = 0;//狸车品牌时设为0
|
|
$row = $this->clues_model->get(['mobile' => $this->session['mobile']]);
|
|
if ($row) {
|
|
$update = ['en_time' => date('Y-m-d H:i:s')];
|
|
$brand_id && $update['brand_id'] = $brand_id;
|
|
$this->clues_model->update($update, ['id' => $row['id']]);
|
|
//增加日志
|
|
$uname = $this->session['nickname'] ? $this->session['nickname'] : '用户';
|
|
$cf_title = $this->clues_entity->cf_title($cf_id);
|
|
$log_msg = '用户报名';
|
|
$cf_title && $log_msg = "用户通过【{$cf_title}】报名";
|
|
$this->clues_entity->add_log($row['id'], $this->session['uid'], $uname, $log_msg);
|
|
//throw new Exception('预约成功,不需要重复报名', API_CODE_FAIL);
|
|
throw new Hd_exception('预约报名成功了!', API_CODE_SUCCESS);
|
|
}
|
|
$jsondata['info'] = ['biz_id' => $biz_id ? $biz_id : ''];
|
|
$t_id && $jsondata['info']['t_id'] = $t_id;
|
|
$add_data = [
|
|
'name' => $this->session['nickname'],
|
|
'mobile' => $this->session['mobile'],
|
|
'cf_uid' => $this->session['uid'],
|
|
'cf_id' => $cf_id,
|
|
'app_id' => $this->app_id,
|
|
'if_driver' => 1,
|
|
'cf_platform' => 'wxapp',
|
|
'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
|
|
'en_time' => date('Y-m-d H:i:s'),
|
|
'c_time' => time()
|
|
];
|
|
$recommend_id && $add_data['recommend_id'] = $recommend_id;
|
|
$brand_id && $add_data['brand_id'] = $brand_id;
|
|
$city_row && $add_data['city_id'] = $city_row['city_id'];
|
|
$city_row && $add_data['county_id'] = $city_row['county_id'];
|
|
$lat && $add_data['lat'] = $lat;
|
|
$lng && $add_data['lng'] = $lng;
|
|
$id = $this->clues_model->add($add_data);
|
|
if ($id) {
|
|
$uname = $this->session['nickname'] ? $this->session['nickname'] : '用户';
|
|
$cf_title = $this->clues_entity->cf_title($cf_id);
|
|
$log_msg = '用户报名';
|
|
$cf_title && $log_msg = "用户通过【{$cf_title}】报名";
|
|
$this->clues_entity->add_log($id, $this->session['uid'], $uname, $log_msg);
|
|
}
|
|
throw new Hd_exception('预约报名成功!', API_CODE_SUCCESS);
|
|
}
|
|
}
|