You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/application/web/controller/Merchant.php

245 lines
6.9 KiB

<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\web\controller;
use app\web\model\merchant\UserEnter;
use service\JsonService;
use service\UtilService;
use think\Request;
use think\Url;
use service\SystemConfigService;
use app\web\model\merchant\Merchant as MerchantModel;
use app\web\model\merchant\MerchantFollow;
use app\web\model\special\Special as SpecialModel;
use app\web\model\special\Lecturer;
use app\web\model\activity\EventRegistration;
use app\web\model\material\DataDownload;
use app\wap\model\user\SmsCode;
use app\web\model\topic\TestPaper;
/**
* Class Merchant
* @package app\web\controller
*/
class Merchant extends AuthController
{
/*
* 白名单
* */
public static function WhiteList()
{
return [
'index',
'lecturer_agree',
'teacher_detail',
'teacher_list',
'get_lecturer_details',
'lecturer_special_list',
'get_lecturer_list',
'lecturer_download_list',
'lecturer_event_list',
'lecturer_test_list',
];
}
/**讲师详情
* @return mixed
*/
public function index()
{
return $this->fetch();
}
/**讲师入驻协议
* @return mixed
*/
public function lecturer_agree()
{
$data['title'] = '讲师入驻协议';
$data['content'] = get_config_content('lecturer_entry');
return JsonService::successful($data);
}
/**
* 讲师详情
* @return mixed
*/
public function teacher_detail($id = 0)
{
if (!$id) return $this->failed('参数有误!');
$lecturer = Lecturer::details($id);
if (!$lecturer) return $this->failed('讲师信息无法访问!');
$this->assign(['lecturer' => $lecturer]);
return $this->fetch('teacher-detail');
}
/**
* 讲师列表
* @return mixed
*/
public function teacher_list()
{
return $this->fetch('teacher-list');
}
/**
* 讲师列表
*/
public function get_lecturer_list()
{
list($page, $limit) = UtilService::getMore([
['page', 1],
['limit', 10]
], $this->request, true);
$uid = $this->uid ? $this->uid : 0;
return JsonService::successful(Lecturer::getLecturerList($uid, $page, $limit));
}
/**
* 讲师名下课程
*/
public function lecturer_special_list()
{
list($mer_id, $page, $limit) = UtilService::postMore([
['mer_id', 0],
['page', 1],
['limit', 10]
], $this->request, true);
$list = SpecialModel::getLecturerSpecialList($mer_id, $page, $limit);
return JsonService::successful($list);
}
/**
* 讲师名下资料
*/
public function lecturer_download_list()
{
list($mer_id, $page, $limit) = UtilService::postMore([
['mer_id', 0],
['page', 1],
['limit', 10]
], $this->request, true);
$list = DataDownload::getLecturerDownloadList($mer_id, $page, $limit);
return JsonService::successful($list);
}
/**
* 讲师名下活动
*/
public function lecturer_event_list()
{
list($mer_id, $page, $limit) = UtilService::postMore([
['mer_id', 0],
['page', 1],
['limit', 10]
], $this->request, true);
$list = EventRegistration::getLecturerEventList($mer_id, $page, $limit);
return JsonService::successful($list);
}
/**
* 讲师名下试卷
*/
public function lecturer_test_list()
{
list($mer_id, $type, $page, $limit) = UtilService::postMore([
['mer_id', 0],
['type', 1],
['page', 1],
['limit', 10]
], $this->request, true);
$list = TestPaper::getMerTestPaperList($mer_id, $type, $page, $limit);
return JsonService::successful($list);
}
/**
* 讲师申请
*/
public function apply()
{
$data = UtilService::postMore([
['province', ''],
['city', ''],
['district', ''],
['address', ''],
['merchant_name', ''],
['link_tel', ''],
['code', ''],
['charter', []],
['merchant_head', ''],
['label', []],
['explain', ''],
['introduction', '']
]);
if (!$data['code']) return JsonService::fail('请输入验证码');
$code = md5('is_phone_code' . $data['code']);
if (!SmsCode::CheckCode($data['link_tel'], $code)) return JsonService::fail('验证码验证失败');
SmsCode::setCodeInvalid($data['link_tel'], $code);
$res = UserEnter::setUserEnter($data, $this->uid);
if ($res)
return JsonService::successful('提交成功!');
else
return JsonService::fail('提交失败!');
}
/**
* 检查是否提交申请
*/
public function is_apply()
{
$data = UserEnter::inspectStatus($this->uid);
return JsonService::successful($data);
}
/**
* 获得申请数据
*/
public function apply_data()
{
$apply = UserEnter::inspectUserEnter($this->uid);
return JsonService::successful($apply);
}
/**是否关注
* @param $mer_id
*/
public function is_follow($mer_id)
{
if(!$mer_id) return JsonService::fail('参数错误');
$res = MerchantFollow::isFollow($this->uid, $mer_id);
return JsonService::successful($res);
}
/**用户关注 取消关注 讲师
* @param $mer_id
* @param $is_follow 0 =取消关注 1= 关注
*/
public function user_follow($mer_id, $is_follow)
{
if(!$mer_id) return JsonService::fail('参数错误');
$res = MerchantFollow::user_merchant_follow($this->uid, $mer_id, $is_follow);
return JsonService::successful($res);
}
/**讲师关注列表
* @param int $page
* @param int $limit
*/
public function get_user_follow_list($page = 1, $limit = 20)
{
$data = MerchantFollow::get_user_merchant_follow_list($this->uid, $page, $limit);
return JsonService::successful($data);
}
}