Beispiel #1
0
 public function respond()
 {
     global $_W;
     $message = $this->message;
     $from = $this->message['from'];
     $rid = $this->rule;
     $reply = pdo_fetch("SELECT * FROM " . tablename("kim_sign_reply") . " WHERE rid=:rid", array(":rid" => $rid));
     if (intval($reply['type']) == 1) {
         $news = array("title" => $reply['title'], "picurl" => $_W['attachurl'] . trim($reply['image_url'], '/'), "url" => $this->buildSiteUrl($this->createMobileUrl("sign")), "description" => $reply['description']);
         return $this->respNews($news);
     }
     $settings = getModulesSettings($this->modulename);
     $uid = getUserIdByOpenId($from);
     $login_url = $this->buildSiteUrl(url('mc'));
     if ($uid <= 0) {
         return $this->respText("请先登录后再签到! <a href='{$login_url}'>登录</a>");
     }
     list($bool, $code) = doSign($from, $settings);
     $board_url = $this->buildSiteUrl($this->createMobileUrl('LeaderBoard'));
     $my_url = $this->buildSiteUrl($this->createMobileUrl('MyPrize'));
     if (!$bool) {
         $hour = round(intval(24 / $settings['times']));
         $message = sprintf("每天可以签到%s次,每隔%s小时可签到一次", $settings['times'], $hour);
         if ($code == 'over_number') {
             return $this->respText($message . "\n\n/::d签到排行: <a href='{$board_url}'>查看</a>\n/:showlove我的奖品 <a href='{$my_url}'>查看</a>");
         }
         if ($code == 'over_time') {
             return $this->respText($reply['overtime']);
         }
     } else {
         $result = $code;
         //抽奖
         $prize_cls = new Prize();
         list($code, $message, $prize) = $prize_cls->lottery($uid, $settings['prize_group']);
         if ($code && !empty($prize)) {
             //中奖
             $result .= "\n\n /:gift有意外惊喜 %s";
             $prize_url = $this->buildSiteUrl($this->createMobileUrl('Prize', array('record_id' => $prize['record_id'])));
             $result = sprintf($result, "<a href='{$prize_url}'>查看</a>");
         } else {
             //未中奖
             $result .= "\n\n /:break很遗憾与奖品擦肩而过!";
         }
         return $this->respText("/:circle签到成功!\n" . $result . "\n\n/::d签到排行 <a href='{$board_url}'>查看</a>\n/:showlove我的奖品 <a href='{$my_url}'>查看</a>");
     }
 }
Beispiel #2
0
 public function doWebPrizes()
 {
     global $_GPC, $_W, $ptr_title;
     checklogin();
     load()->func('tpl');
     $op = $_GPC['op'];
     $group_id = intval($_GPC['group_id']);
     $settings = getModulesSettings($this->modulename);
     if ($group_id <= 0) {
         $group_id = $settings['prize_group'];
     }
     $_GPC['group_id'] = $group_id;
     $ops = array('display', 'edit', 'delete', 'test', 'record');
     $op = in_array($op, $ops) ? $op : 'display';
     $cls = new Prize();
     $ptr_title = '奖品例表';
     //ajax 按钮
     if ($_W['ispost'] && $_W['isajax']) {
         if (!empty($_GPC['fieldmap']) && $_GPC['fieldmap'] == 'status' && $cls->change()) {
             exit('success');
         } elseif (!empty($_GPC['fieldmap']) && $_GPC['fieldmap'] == 'release' && $cls->release()) {
             exit('success');
         }
         exit('操作失败');
     }
     if ($op == 'delete') {
         if ($cls->delete()) {
             message('删除成功!', $this->createWebUrl('Prizes'));
         }
     } elseif ($op == 'edit') {
         list($code, $groups) = $cls->groups();
         $id = $_GPC['id'];
         $_W['page']['title'] = intval($id) > 0 ? '奖品编辑 - 主要业务模块 - 签到' : '奖品添加 - 主要业务模块 - 签到';
         $ptr_title = intval($id) > 0 ? '奖品编辑' : '奖品添加';
         list($code, $message, $prize) = $cls->edit();
         if (!$code) {
             message($message);
         }
         if (intval($id) > 0 && empty($prize)) {
             message('奖品不存在.', $this->createWebUrl('Prizes', array('group_id' => $group_id)));
         }
         if ($code && !empty($message)) {
             message($message, $this->createWebUrl('Prizes', array('group_id' => $group_id)));
         }
     } elseif ($op == 'test') {
         $cls->test_lottery(1, $settings['prize_group']);
     } elseif ($op == 'record') {
         $prize = $cls->findPrize();
     }
     if (checksubmit('import')) {
         $cls->import();
     }
     //导入奖品
     list($list, $total, $pager) = $cls->_list();
     //未领
     include $this->template('prizes');
 }
Beispiel #3
0
<?php

/**
 * Kim签到模块定义
 */
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$_W['page']['title'] = "签到领红包啦";
//检查是否登录
checkauth();
$settings = getModulesSettings($this->modulename);
$times = intval($settings['times']) <= 0 ? 1 : intval($settings['times']);
$today_sign = getUserTodaySign($_W['member']['uid'], $times);
//今天签到数据
if (checksubmit('sign')) {
    list($qd_code, $qd_message) = doWebSign($settings);
    if ($qd_code === 1) {
        //签到成功
        //抽奖
        $prize_cls = new Prize();
        list($code, $message, $prize) = $prize_cls->lottery($_W['member']['uid'], $settings['prize_group']);
        if ($code && !empty($prize) && !empty($prize['code']) && intval($prize['record_id']) > 0) {
            //中奖
            $prize_item = array("prize_url" => $this->createMobileUrl('Prize', array('record_id' => $prize['record_id'])), "prize_name" => $prize['prize_name'], "code" => $prize['code']);
            unset($prize);
        }
    }
    $result = array("code" => $qd_code, "title" => $qd_code === 1 ? "签到成功!" : "签到失败", "message" => $qd_message, "prize" => $prize_item);
    header('Content-Type:text/json; charset=utf-8');
    exit(json_encode($result));
}