78 lines
3.1 KiB
PHP
78 lines
3.1 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Market_sytopic_enroll_model extends HD_Model
|
|
{
|
|
private $table_name = 'lc_market_sytopic_enroll';
|
|
|
|
const ENROLL_DEAL_NO = 0; // 报名不处理
|
|
const ENROLL_DEAL_PUSH_CLUE = 1; // 提交狸车线索池
|
|
const ENROLL_DEAL_PUSH_CUSTOMER = 2; // 提交狸车客户池
|
|
|
|
const STATUS_PENDING = 0; //待处理
|
|
const STATUS_SHOP = 1; //已到店
|
|
const STATUS_SUCCESS = 2; //已成交
|
|
const STATUS_INVALID = 3; //无效
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct($this->table_name, 'default');
|
|
}
|
|
|
|
//专题报名
|
|
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');
|
|
$topicUser = $this->topic_user_model->get(['id' => $topicUserId]);
|
|
$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' => '您的信息已收到,无需重复操作'];
|
|
}
|
|
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'),
|
|
'createTime' => date('Y-m-d H:i:s'),
|
|
'enrollDeal' => $org ? $org['enrollDeal'] : self::ENROLL_DEAL_NO,
|
|
];
|
|
$optionRow['id'] && $data['moduleOptionId'] = $optionRow['id'];
|
|
$optionRow['moduleId'] && $data['moduleId'] = $optionRow['moduleId'];
|
|
$res = $this->add($data);
|
|
if (!$res) {
|
|
return ['code' => 0, 'msg' => '提交失败'];
|
|
}
|
|
if (is_numeric($res)) { //数据同步到空间站
|
|
$this->load->library('market/sytopic_enroll_entity');
|
|
$this->sytopic_enroll_entity->synEnroll($res);
|
|
}
|
|
return ['code' => 1, 'msg' => '保存成功'];
|
|
}
|
|
|
|
public function statusCn()
|
|
{
|
|
$statusArray = [
|
|
self::STATUS_PENDING => '邀约中',
|
|
self::STATUS_SHOP => '已到店',
|
|
self::STATUS_SUCCESS => '已成交',
|
|
self::STATUS_INVALID => '战败'
|
|
];
|
|
return $statusArray;
|
|
}
|
|
} |