public function submissions() { $this->all = M('submission')->where(array('contest_id' => C('CONTESTID'), 'user_id' => $_SESSION['uid']))->select(); $this->notcomplete = M('submission')->where(array('contest_id' => C('CONTESTID'), 'user_id' => $_SESSION['uid'], 'iscomplete' => 0))->select(); $this->notpaied = M('submission')->where(array('contest_id' => C('CONTESTID'), 'user_id' => $_SESSION['uid'], 'ispaied' => 0))->select(); $this->notsubmitted = M('submission')->where(array('contest_id' => C('CONTESTID'), 'user_id' => $_SESSION['uid'], 'issubmitted' => 0))->select(); $promotions = M('promotion')->where(array('contest_id' => C('CONTESTID'), 'user_id' => $_SESSION['uid'], 'ispaied' => 1))->order('timestamp desc')->select(); $names = ['双页年鉴展示', '专题报道', '媒体推广', '微信传播', '3D展示', '实物展示', '增订奖杯&奖状', '增订年鉴']; for ($i = 0; $i < count($promotions); $i++) { $tmp = ''; $promotions[$i]['promotion'] = explode(',', $promotions[$i]['promotion']); if ($promotions[$i]['promotion'][0] == '1a') { $tmp = translate_return('A 基础推广服务'); } elseif ($promotions[$i]['promotion'][0] == '1b') { $tmp = translate_return('B 展示推广服务'); } elseif ($promotions[$i]['promotion'][0] == '1c') { $tmp = translate_return('C 闪耀推广服务'); } elseif ($promotions[$i]['promotion'][0] == '1d') { $tmp = translate_return('D 成功推广服务'); } for ($j = 1; $j < count($promotions[$i]['promotion']); $j++) { if ($promotions[$i]['promotion'][$j] != 0) { if ($promotions[$i]['promotion'][$j] == 1) { $tmp .= ' ' . translate_return($names[$j - 1]); } else { $tmp .= ' ' . translate_return($names[$j - 1]) . 'x' . $promotions[$i]['promotion'][$j]; } } } $promotions[$i]['promotion'] = $tmp; $tmp_sub = M('submission')->where(array('id' => $promotions[$i]['submission_id']))->find(); $promotions[$i]['titlec'] = $tmp_sub['titlec']; $promotions[$i]['titlee'] = $tmp_sub['titlee']; } $this->promotions = $promotions; $this->display(); }
public function pay_by_code() { $invitation = M('invitation')->where(array('contest_id' => C('CONTESTID'), 'code' => I('code')))->find(); if (!$invitation) { echo json_encode(array('result' => 'error', 'error' => translate_return('邀请码无效'))); } else { if ($invitation['remain'] == 0) { echo json_encode(array('result' => 'error', 'error' => translate_return('邀请码次数已用尽'))); } else { $tmp = $invitation['submissions']; if ($tmp == '') { $tmp = I('submission_id'); } else { $tmp = $tmp . ',' . I('submission_id'); } M('invitation')->where(array('contest_id' => C('CONTESTID'), 'code' => I('code')))->setDec('remain'); M('invitation')->where(array('contest_id' => C('CONTESTID'), 'code' => I('code')))->save(array('submissions' => $tmp)); M('submission')->where(array('contest_id' => C('CONTESTID'), 'id' => I('submission_id'), 'user_id' => $_SESSION['uid']))->save(array('ispaied' => 1, 'pay_confirm' => 0, 'invitation' => $invitation['name'])); echo json_encode(array('result' => 'ok')); } } }
public function promotion() { $promotions = M('promotion')->where(array('contest_id' => C('CONTESTID')))->order('ispaied desc, timestamp desc')->select(); $names = ['双页年鉴展示', '专题报道', '媒体推广', '微信传播', '3D展示', '实物展示', '增订奖杯&奖状', '增订年鉴']; for ($i = 0; $i < count($promotions); $i++) { $tmp = ''; $promotions[$i]['promotion'] = explode(',', $promotions[$i]['promotion']); if ($promotions[$i]['promotion'][0] == '1a') { $tmp = translate_return('A 基础推广服务'); } elseif ($promotions[$i]['promotion'][0] == '1b') { $tmp = translate_return('B 展示推广服务'); } elseif ($promotions[$i]['promotion'][0] == '1c') { $tmp = translate_return('C 闪耀推广服务'); } elseif ($promotions[$i]['promotion'][0] == '1d') { $tmp = translate_return('D 成功推广服务'); } for ($j = 1; $j < count($promotions[$i]['promotion']); $j++) { if ($promotions[$i]['promotion'][$j] != 0) { if ($promotions[$i]['promotion'][$j] == 1) { $tmp .= ' ' . $names[$j - 1]; } else { $tmp .= ' ' . $names[$j - 1] . 'x' . $promotions[$i]['promotion'][$j]; } } } $promotions[$i]['promotion'] = $tmp; $tmp_sub = M('submission')->where(array('id' => $promotions[$i]['submission_id']))->find(); $promotions[$i]['titlec'] = $tmp_sub['titlec']; $promotions[$i]['titlee'] = $tmp_sub['titlee']; $promotions[$i]['email'] = $tmp_sub['email']; } $this->promotions = $promotions; $this->count_paid = M('promotion')->where(array('contest_id' => C('CONTESTID'), 'ispaied' => 1))->count(); $this->count_offline = M('promotion')->where(array('contest_id' => C('CONTESTID'), 'ispaied' => 1, 'offline' => 1))->count(); $this->count_unpaid = M('promotion')->where(array('contest_id' => C('CONTESTID'), 'ispaied' => 0))->count(); // $this->count_unpaid = count($this->count_unpaid); layout('admin'); $this->display(); }