本文整理匯總了PHP中CommonModel::get_product_trans方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommonModel::get_product_trans方法的具體用法?PHP CommonModel::get_product_trans怎麽用?PHP CommonModel::get_product_trans使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CommonModel
的用法示例。
在下文中一共展示了CommonModel::get_product_trans方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: place_in
/**
* 測試報名
* @param int $exam 期次id
* @param int $place 場次id, 多個ID用英文逗號分隔開
* @param int $p_id 產品id
* @return json 成功/失敗
*/
public function place_in()
{
$exam = intval($this->input->post('exam'));
$place = $this->input->post('place');
$uid = $this->session->userdata('uid');
$p_id = intval($this->input->post('p_id'));
$force = intval($this->input->post('force'));
$b_pushcourse = intval($this->input->post('b_pushcourse'));
if (!Validate::isJoinedIntStr($place)) {
output_json(CODE_ERROR, '報名失敗,考場不正確');
}
// 檢查是否存在該學生
$account = StudentModel::get_student($uid, 'account,account_status');
if (!count($account['account'])) {
output_json(CODE_ERROR, '報名失敗,不存在該學生.');
} else {
if ($account['account_status']) {
output_json(CODE_ERROR, '報名失敗,學生帳號已被凍結');
}
}
if (CommonModel::get_product_trans($p_id, $uid, $place, $exam)) {
output_json(CODE_ERROR, '報名失敗,已報名該產品');
}
$res = CommonModel::get_product_list($p_id);
if (!$res) {
output_json(CODE_ERROR, '報名失敗,產品不存在');
} else {
$price = $b_pushcourse ? $res['p_price_pushcourse'] : $res['p_price'];
$pc_id = $res['pc_id'];
}
$account = $account['account'];
$account1 = $account - $price;
if ($account1 < 0) {
output_json(CODE_ERROR, '帳號餘額不足');
}
$inserts = array();
$error = array();
$code = CODE_ERROR;
$place_id_arr = array_unique(explode(',', $place));
$place_id_arr2 = array();
foreach ($place_id_arr as $place_id) {
if ($place_id) {
$query = $this->db->select('p.*,e.exam_name,e.exam_id,e.exam_pid,e.grade_id')->from('exam_place p')->join('exam e', 'p.exam_pid=e.exam_id')->where(array('p.place_id' => $place_id))->get();
$place = $query->row_array();
} else {
continue;
}
if (empty($place)) {
$error[] = "考場[{$place_id}]信息不存在";
//output_json(CODE_ERROR, '考場信息不存在');
continue;
}
$ids = $uid;
// 控製考場隻能在未開始考試操作
$no_start = ExamPlaceModel::place_is_no_start($place_id);
if (!$no_start) {
$error[] = "考場[{$place_id}]正確考試或已結束,無法報名";
continue;
//output_json(CODE_ERROR, '該考場正在考試或已結束,無法做此操作');
}
// $ids = my_intval($ids);
// $school_id = (int)$this -> input ->post('school_id');
// 該考場所考到的學科
$subject_ids = array();
$query = $this->db->select('subject_id')->from('exam_place_subject')->where(array('place_id' => $place['place_id']))->get();
$subjects = $query->result_array();
$subject_ids = array();
foreach ($subjects as $subject) {
$subject_ids[] = $subject['subject_id'];
}
$subject_ids = count($subject_ids) ? implode(',', $subject_ids) : '""';
$place['start_time'] = $place['start_time'] + 1;
$place['end_time'] = $place['end_time'] - 1;
if ($force == 0) {
$sql = "SELECT count(u.uid) FROM rd_student u\n WHERE u.grade_id={$place['grade_id']} AND u.is_delete=0 AND u.uid ={$ids}";
$query = Fn::db()->fetchOne($sql);
if ($query == 0) {
$error[] = "考場[{$place_id}]您的年級不符合要求";
$code = -2;
continue;
//output_json('-2', '你的年級不符合要求');
}
}
$not_exists_sql = <<<EOT
SELECT uid
FROM rd_exam_place_student ps, rd_exam_place p, rd_exam e
WHERE e.exam_isfree = 0
AND ps.place_id = p.place_id
AND p.place_index = {$place['place_index']}
AND ps.uid = u.uid
AND p.exam_pid = e.exam_id
AND
(
//.........這裏部分代碼省略.........