Пример #1
0
 /**
  * 订单成功后的操作,如送分、送票等
  * 
  * @param integer $order_id
  */
 static function order_success_after($order_id)
 {
     if (empty($order_id)) {
         return false;
     }
     $oinfo = D()->get_one("SELECT `user_id`,`player_id`,`goods_type`,`goods_amount` FROM {order_info} WHERE `order_id`=%d", $order_id);
     //送花/吻等付费操作
     if (!empty($oinfo)) {
         Node::action($oinfo['goods_type'], $oinfo['player_id'], $oinfo['user_id'], $oinfo['goods_amount']);
     }
 }
Пример #2
0
 /**
  * 投票操作
  *
  * @param Request $request
  * @param Response $response
  */
 function vote(Request $request, Response $response)
 {
     if ($request->is_post()) {
         //提交数据
         $player_id = $request->post('player_id', 0);
         $token = $request->post('token', '');
         $res = ['flag' => 'FAIL', 'msg' => ''];
         if (empty($player_id)) {
             $res['msg'] = 'player_id empty';
             $response->sendJSON($res);
         }
         $uid = $GLOBALS['user']->uid;
         if (empty($uid)) {
             $res['msg'] = '您没登录,请先在微信端登录';
             $response->sendJSON($res);
         }
         $maybe_spam = $request->is_token_post() ? 0 : 1;
         $ret = Node::action('vote', $player_id, $uid, 1, FALSE, FALSE, ['maybe_spam' => $maybe_spam]);
         if ($ret >= 0) {
             $time_from = 0;
             $vote_field = 'votecnt';
             $player_info = Match_Model::getPlayerInfo($player_id);
             if ($player_info['stage'] > 0) {
                 $time_from = Node::getMatchStageTime($player_info['match_id']);
                 $vote_field = Node::getVoteFiled($player_info['stage']);
             }
             //返回当前player总投票数(包括flower加权)
             $votedcnt = $player_info[$vote_field];
             //返回当前player投票数
             $votedcnt_single = Node::getActionNum($player_id, 'vote', $time_from);
             $res['flag'] = 'SUC';
             $res['msg'] = "投票成功!";
             $res['votedcnt'] = $votedcnt;
             $res['votedcnt_single'] = $votedcnt_single;
             if ($ret > 0) {
                 $res['msg'] .= "您今天还可以投<em style=\"color:red\">{$ret}</em>票!";
             } else {
                 //您已投票成功!请关注大赛微信公众平台帐号:FEOfeel,随时关注比赛动态
                 $res['msg'] .= '您今天的票数已用完,明天再来,还可以给女神<em style="color:red">送花</em>或为其他女神投票哦~';
             }
             $response->sendJSON($res);
         } else {
             if (-11 == $ret) {
                 $res['msg'] = '票数已用完,明天再来,还可以给女神<em style="color:red">送花</em>或为其他女神投票哦~';
             } elseif (-12 == $ret) {
                 $res['msg'] = '连续投票时间间隔要在2小时以上';
             } elseif (-13 == $ret) {
                 $res['msg'] = '投票太频繁,请稍后再试';
             } elseif (-14 == $ret) {
                 $res['msg'] = '本次大赛投票已截止,感谢您的关注';
             } else {
                 $res['msg'] = '发生未知错误';
             }
             $response->sendJSON($res);
         }
     }
 }
Пример #3
0
<?php

if ($_GET['page'] == 'content/delete-page' && is_numeric($_POST['id'])) {
    $type = Content::getType($_POST['id']);
    $res = Node::action('delete', $type, array($_POST['id']));
    if ($res !== false) {
        echo Message::success(__('admin', 'page-delete-success'));
        exit;
    }
    var_dump($res);
    exit;
}
Пример #4
0
 /**
  * action 'player_edit'
  * @param Request $request
  * @param Response $response
  */
 public function player_edit(Request $request, Response $response)
 {
     if ($request->is_post()) {
         $ret = ['flag' => 'ERR', 'msg' => ''];
         $player_id = $request->post('player_id', 0);
         $truename = $request->post('truename', '');
         $mobile = $request->post('mobile', '');
         $weixin = $request->post('weixin', '');
         $idcard = $request->post('idcard', '');
         $video = $request->post('video', '');
         $province = $request->post('province', 0);
         $city = $request->post('city', 0);
         $inc_vote = $request->post('inc_vote', 0);
         $inc_flower = $request->post('inc_flower', 0);
         $cover_pic_id = $request->post('cover_pic_id', 0);
         $imgs = $request->post('imgs', []);
         $player_info = Member_Model::getPlayerInfo($player_id);
         if (empty($player_info)) {
             $ret['msg'] = '参赛者不存在';
             $response->sendJSON($ret);
         }
         $uid = 10000;
         //10000 为系统管理员帐号
         $ret['flag'] = 'SUC';
         $ret['msg'] = '更新成功';
         $data = ['cover_pic_id' => $cover_pic_id];
         if ('' != $truename) {
             $data['truename'] = $truename;
         }
         if ('' != $mobile) {
             $data['mobile'] = $mobile;
         }
         if ('' != $weixin) {
             $data['weixin'] = $weixin;
         }
         if ('' != $idcard && strlen($idcard) <= 18) {
             $data['idcard'] = $idcard;
         }
         if ('' != $video && preg_match('/^http(s?):\\/\\//', $video)) {
             $data['video'] = $video;
         }
         //将省份、城市平均成: "40:北京"这样的结构
         if ($province) {
             $loc = Member_Model::getLocationName($province);
             if ($loc) {
                 $province = $province . ':' . $loc;
             }
         } else {
             $province = '';
         }
         if ($city) {
             $loc = Member_Model::getLocationName($city);
             if ($loc) {
                 $city = $city . ':' . $loc;
             }
         } else {
             $city = '';
         }
         $data['province'] = $province;
         $data['city'] = $city;
         //更新pic_cover_id
         D()->update("player", $data, ['player_id' => $player_id]);
         //更新图片
         if (!empty($imgs) && is_array($imgs)) {
             //! 务必检查严格
             $imgs_idstr = implode(',', $imgs);
             $existed_rids = D()->from("player_gallery")->where("`rid` IN(%s)", $imgs_idstr)->select("`rid`")->fetch_column('rid');
             if (!empty($existed_rids)) {
                 //! 务必检查严格,否则容易出现丢失图片数据
                 //先将原有的记录的player_id设为0
                 D()->query("UPDATE `{player_gallery}` SET `old_player_id`=`player_id`,`player_id`=0 WHERE `player_id`=%d", $player_id);
                 //紧接着重新关联新的记录
                 D()->query("UPDATE `{player_gallery}` SET `player_id`=%d,`old_player_id`=%d WHERE `rid` IN(%s)", $player_id, $player_id, $imgs_idstr);
                 //更新排序
                 $o = 1;
                 foreach ($imgs as $rid) {
                     D()->query("UPDATE `{player_gallery}` SET `sortorder`=%d WHERE `rid`=%d", $o, $rid);
                     $o++;
                 }
             }
         }
         if ($inc_vote) {
             $action_id = Node::action('vote', $player_id, $uid, $inc_vote, TRUE, FALSE, ['from' => 'admin']);
             $ret['msg'] .= ',增加了' . $inc_vote . '票';
         }
         if ($inc_flower) {
             $action_id = Node::action('flower', $player_id, $uid, $inc_flower);
             $ret['msg'] .= ',增加了' . $inc_flower . '花';
         }
         $response->sendJSON($ret);
     } else {
         // GET request
         $this->_nav_second = 'player';
         $this->v->set_tplname('mod_member_player_edit');
         // Player Info
         $player_id = $request->arg(2);
         $player_id = intval($player_id);
         $is_edit = $player_id ? TRUE : FALSE;
         $player_info = $is_edit ? Member_Model::getPlayerInfo($player_id) : [];
         $player_gallery = [];
         if (!empty($player_info)) {
             $player_gallery = Member_Model::getPlayerGalleryAll($player_info['player_id'], $player_info['cover_pic_id']);
             if (!empty($player_info['province'])) {
                 $player_info['province'] = preg_replace('/(:.*)$/', '', $player_info['province']);
             }
             if (!empty($player_info['city'])) {
                 $player_info['city'] = preg_replace('/(:.*)$/', '', $player_info['city']);
             }
         }
         $province = Member_Model::getProvinces();
         $this->v->assign('province', $province);
         $this->v->assign('player_info', $player_info)->assign('player_gallery', $player_gallery)->assign('is_edit', $is_edit);
         $response->send($this->v);
     }
 }
Пример #5
0
 public static function nodeDisplay($action, $type, $row)
 {
     return Node::action($action, $type, array($row));
 }