修改专题模块

This commit is contained in:
lcc
2024-08-09 16:21:30 +08:00
parent 20193665a0
commit 783be76230
6 changed files with 125 additions and 123 deletions
@@ -19,25 +19,32 @@ class Market_sytopic_enroll_model extends HD_Model
}
//专题报名
public function enroll($id, $topicUserId, $name, $mobile)
public function enroll($topicId, $moduleOptionId, $topicUserId, $name, $mobile)
{
$this->load->model('market/Market_sytopic_user_model', 'topic_user_model');
$this->load->model('market/market_sytopic_module_option_model');
$this->load->model('market/market_sylive_organization_model');
$this->load->model('market/market_sytopic_model', 'topic_model');
$optionRow = $this->market_sytopic_module_option_model->get(['id' => $id]);
$topicUser = $this->topic_user_model->get(['id' => $topicUserId]);
$row = $this->get(['status' => 0, 'moduleOptionId' => $id, 'userId' => $topicUser['userId']]);
$where = ['status' => 0, 'topicId' => $topicId, 'userId' => $topicUser['userId'], 'moduleOptionId' => 0];
if ($moduleOptionId) {
$where['moduleOptionId'] = $moduleOptionId;
}
$row = $this->get($where);
if ($row) {
// $this->update(['name' => $name, 'mobile' => $mobile], ['id' => $row['id']]);
return ['code' => 0, 'msg' => '您的信息已收到,无需重复操作'];
}
$topic = $this->topic_model->get(['id' => $optionRow['topicId']]);
if ($moduleOptionId) {
$optionRow = $this->market_sytopic_module_option_model->get(['id' => $moduleOptionId]);
}
$topic = $this->topic_model->get(['id' => $topicId]);
$org = $this->market_sylive_organization_model->get(['organizationId' => $topic['organizationId']]);
$data = [
'topicUserId' => $topicUserId,
'userId' => $topicUser['userId'],
'channelId' => $topicUser['channelId'],
'topicId' => $topicId,
'name' => $name,
'mobile' => $mobile,
'enTime' => date('Y-m-d H:i:s'),
@@ -45,7 +52,6 @@ class Market_sytopic_enroll_model extends HD_Model
'enrollDeal' => $org ? $org['enrollDeal'] : self::ENROLL_DEAL_NO,
];
$optionRow['id'] && $data['moduleOptionId'] = $optionRow['id'];
$optionRow['topicId'] && $data['topicId'] = $optionRow['topicId'];
$optionRow['moduleId'] && $data['moduleId'] = $optionRow['moduleId'];
$res = $this->add($data);
if (!$res) {
@@ -12,6 +12,7 @@ class Market_sytopic_module_model extends HD_Model
const TYPE_HORIZONTAL = 5; // 横排
const TYPE_ARTICLE = 6; // 文章
const TYPE_ENROLL_BANNER = 7; // 报名轮播图
const TYPE_ENROLL_GIFT = 8; // 礼品模块
const TYPE_ARRAY = [
// self::TYPE_BANNER => '主图',
@@ -21,6 +22,7 @@ class Market_sytopic_module_model extends HD_Model
self::TYPE_SWIPER_BANNER => '轮播图',
self::TYPE_ARTICLE => '富文本',
self::TYPE_ENROLL_BANNER => '横排轮播图',
self::TYPE_ENROLL_GIFT => '礼品',
];
public function __construct()
@@ -37,10 +37,10 @@ class Market_sytopic_module_option_model extends HD_Model
{
$this->load->model('market/market_sytopic_module_model');
$moduleModel = new Market_sytopic_module_model();
$modelList = $moduleModel->select(['type'=>$moduleModel::TYPE_ENROLL_BANNER],'','','','id');
$modelList = $moduleModel->select(['type' => $moduleModel::TYPE_ENROLL_BANNER], '', '', '', 'id');
$lists = [];
if ($modelList) {
$modelIdsStr = implode(',', array_column($modelList,'id'));
$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) {
@@ -110,6 +110,20 @@ class Market_sytopic_module_option_model extends HD_Model
$data['introduction'] = $item['introduction'];
$data['createTime'] = $item['createTime'];
break;
case Market_sytopic_module_model::TYPE_ENROLL_GIFT://礼品模块
$enroll = true; //是否可报名
if ($item['enrollEndTime'] != '0000-00-00 00:00:00') {
$enrollEndTime = $item['enrollEndTime'];
if (strtotime($item['enrollEndTime']) - time() <= 0) {
$data['btnText'] = '已结束';
$enroll = false;
}
} else {
$enrollEndTime = '';
}
$data['enrollEndTime'] = $enrollEndTime;
$data['enroll'] = $enroll;
break;
default:
$data['introduction'] = strip_tags($item['introduction']);
}