ci = &get_instance(); $this->ci->load->model('market/market_sylive_organization_model'); $this->ci->load->model('market/market_sytopic_enroll_model', 'sytopic_enroll_model'); $this->ci->load->model('market/Market_sytopic_model', 'topic_model'); $this->ci->load->model('market/Market_sytopic_module_option_model', 'module_option_model'); $this->ci->load->model('market/Market_sytopic_module_model', 'module_model'); $this->ci->load->library('ssApi'); } /** * 同步专题报名数据 * @param $enrollId 报名id * @return array */ public function synEnroll($enrollId) { $enrollModel = new Market_sytopic_enroll_model(); debug_log("[info]# 报名id:" . $enrollId, $this->log_file); $enrollRow = $this->ci->sytopic_enroll_model->get(['id' => $enrollId]); $topicRow = $organizationRow = ''; $enrollRow && $topicRow = $this->ci->topic_model->get(['id' => $enrollRow['topicId']]); $topicRow && $organizationRow = $this->ci->market_sylive_organization_model->get(['organizationId' => $topicRow['organizationId']]); if (!$enrollRow) { debug_log("[error]# 报名数据不存在.", $this->log_file); return ['code' => 0, 'msg' => '报名数据不存在']; } if (!$topicRow) { debug_log("[error]# 专题不存在.", $this->log_file); return ['code' => 0, 'msg' => '专题不存在']; } if (!$organizationRow) { debug_log("[error]# 机构不存在.", $this->log_file); return ['code' => 0, 'msg' => '机构不存在']; } $enrollDeal = (int)$enrollRow['enrollDeal']; $ssApi = new SsApi(); if ($enrollDeal === $enrollModel::ENROLL_DEAL_NO) { debug_log("[info]# 不需要处理.", $this->log_file); return ['code' => 0, 'msg' => '无需处理']; } else { //同步到客户 debug_log("[info]# 同步到空间站.", $this->log_file); $to_customers = 0; if ($enrollDeal == $enrollModel::ENROLL_DEAL_PUSH_CUSTOMER) { $to_customers = 1; } $modelOptionRow = $this->ci->module_option_model->get(['id' => $enrollRow['moduleOptionId']]); $modelRow = $this->ci->module_model->get(['id' => $enrollRow['moduleId']]); if ($modelOptionRow || $modelRow) { $remark = "用户通过 " .$topicRow['title']."-" .$modelRow['title']; $modelOptionRow && $remark .= "-" . $modelOptionRow['title']; $remark .= " 留资"; } else { $remark = '用户通过 ' . $topicRow['title'] . ' 留资'; } $res = $ssApi->postClues($enrollId, $enrollRow['name'], $enrollRow['mobile'], $enrollRow['enTime'], $remark, $to_customers, (int)$organizationRow['comments']); debug_log("[info]# 接口请求结果:" . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file); return $res; } } public function __get($name) { if ('_model' === substr($name, -6)) { return $this->ci->$name; } elseif ('load' == $name) { return $this->ci->load; } return null; } }