function reply($dataArr, $keywordArr = array()) { $this->config = getAddonConfig('Chat'); // 获取后台插件的配置参数 $content = $this->_tuling($dataArr['Content']); if ($content) { exit; } // 先尝试小九机器人 目前已不可用 if (empty($content)) { // $content = $this->_xiaojo ( $dataArr ['Content'] ); } // 再尝试小黄鸡 if (empty($content)) { $content = $this->_simsim($dataArr['Content']); } // TODO 此处可继续增加其它API接口 // 最后只能随机回复了 if (empty($content)) { $content = $this->_rand(); } // 增加积分,每隔5分钟才加一次,5分钟内只记一次积分 add_credit('chat', 300); $res = $this->replyText($content); return $res; }
function index() { add_credit('weisite', 86400); if (file_exists(ONETHINK_ADDON_PATH . 'WeiSite/View/default/pigcms/Index_' . $this->config['template_index'] . '.html')) { $this->pigcms_index(); $this->display(ONETHINK_ADDON_PATH . 'WeiSite/View/default/pigcms/Index_' . $this->config['template_index'] . '.html'); } else { $map['token'] = get_token(); $map['is_show'] = 1; $map['pid'] = 0; // 获取一级分类 // 幻灯片 $slideshow = M('weisite_slideshow')->where($map)->order('sort asc, id desc')->select(); foreach ($slideshow as &$vo) { $vo['img'] = get_cover_url($vo['img']); } $this->assign('slideshow', $slideshow); // dump($slideshow); // 分类 $category = M('weisite_category')->where($map)->order('sort asc, id desc')->select(); foreach ($category as &$vo) { $vo['icon'] = get_cover_url($vo['icon']); empty($vo['url']) && ($vo['url'] = addons_url('WeiSite://WeiSite/lists', array('cate_id' => $vo['id']))); } $this->assign('category', $category); $map2['token'] = $map['token']; $public_info = get_token_appinfo($map2['token']); $this->assign('publicid', $public_info['id']); $this->assign('manager_id', $this->mid); $this->_footer(); $this->display(ONETHINK_ADDON_PATH . 'WeiSite/View/default/TemplateIndex/' . $this->config['template_index'] . '/index.html'); } }
function reply($dataArr, $keywordArr = array()) { $map['id'] = $keywordArr['aim_id']; $param['token'] = get_token(); $param['openid'] = get_openid(); if ($keywordArr['extra_text'] == 'custom_reply_mult') { // 多图文回复 $mult = M('custom_reply_mult')->where($map)->find(); $map_news['id'] = array('in', $mult['mult_ids']); $list = M('custom_reply_news')->where($map_news)->select(); foreach ($list as $k => $info) { if ($k > 8) { continue; } $articles[] = array('Title' => $info['title'], 'Description' => $info['intro'], 'PicUrl' => get_cover_url($info['cover']), 'Url' => $this->_getNewsUrl($info, $param)); } $res = $this->replyNews($articles); } elseif ($keywordArr['extra_text'] == 'custom_reply_news') { // 单条图文回复 $info = M('custom_reply_news')->where($map)->find(); // 组装微信需要的图文数据,格式是固定的 $articles[0] = array('Title' => $info['title'], 'Description' => $info['intro'], 'PicUrl' => get_cover_url($info['cover']), 'Url' => $this->_getNewsUrl($info, $param)); $res = $this->replyNews($articles); } else { // 增加积分 add_credit('custom_reply', 300); // 文本回复 $info = M('custom_reply_text')->where($map)->find(); $contetn = replace_url(htmlspecialchars_decode($info['content'])); $this->replyText($contetn); } }
public function unsubscribe($dataArr) { // 增加积分 add_credit('unsubscribe'); //取消关注时的操作 D('Common/Follow')->unsubscribeFollow($dataArr['FromUserName']); }
function suggest() { $config = getAddonConfig('Suggestions'); $this->assign($config); // dump ( $config ); $map['id'] = $data['uid'] = $this->mid; $user = get_followinfo($this->mid); $this->assign('user', $user); if (IS_POST) { // 保存用户信息 $nickname = I('nickname'); if ($config['need_nickname'] && !empty($nickname)) { $data['nickname'] = $nickname; } $mobile = I('mobile'); if ($config['need_mobile'] && !empty($mobile)) { $data['mobile'] = $mobile; } // 保存内容 $data['cTime'] = time(); $data['content'] = I('content'); $data['token'] = get_token(); $res = M('suggestions')->add($data); if ($res) { // 增加积分 add_credit('suggestions'); $this->success('增加成功,谢谢您的反馈'); } else { $this->error('增加失败,请稍后再试'); } } else { $this->display(); } }
function receive() { $info = D('Invite')->getInfo(I('id')); $this->assign('info', $info); $this->deal($info); $detail_url = addons_url('Invite://Wap/detail', array('id' => $info['id'], 'invite_uid' => $this->mid, 'token' => get_token())); $map['uid'] = $this->mid; $map['invite_id'] = $info['id']; $recode = M('invite_user')->where($map)->find(); if ($recode) { redirect($detail_url); } // 优惠券是否领取 完或者到期 $data = M('coupon')->find($info['coupon_id']); if ($data['start_time'] > NOW_TIME) { // $url = addons_url ( 'WeiSite://WeiSite/lists' ); $url = addons_url('Invite://Wap/lists'); $this->error('本次微邀约还没开始,下次再来吧。', $url); } if ($data['num'] <= $data['collect_count'] || $data['end_time'] > 0 && $data['end_time'] < NOW_TIME) { // $url = addons_url ( 'WeiSite://WeiSite/lists' ); $url = addons_url('Invite://Wap/lists'); $this->error('本次微邀约已经结束,下一次再来吧。', $url); } // 减少经历值 $user = get_mult_userinfo($this->mid); //dump($user);die(); if ($info['experience'] > $user['experience']) { $url = addons_url('Invite://Wap/lists'); $this->error('你的经历值不足', $url); } // 增加领取记录 $map['invite_num'] = 0; M('invite_user')->add($map); $credit['experience'] = 0 - $info['experience']; $credit['score'] = 0; add_credit('invite', 5, $credit); // 发放优惠券 $data['sn'] = uniqid(); $data['uid'] = $this->mid; $data['cTime'] = time(); $data['addon'] = 'Coupon'; $data['target_id'] = $info['coupon_id']; $data['can_use'] = 0; $data['prize_id'] = 0; $data['prize_title'] = ''; unset($data['id']); // dump ( $data ); $res = D('Common/SnCode')->delayAdd($data); if ($res) { // 更新获取数 // M ( "coupon" )->where ( 'id=' . $info ['coupon_id'] )->setInc ( "collect_count" ); M("invite")->where('id=' . $info['id'])->setInc("receive_num"); } else { $this->error('优惠券发送失败'); } redirect($detail_url); }
public function unsubscribe($data) { // 直接删除用户 //$map1 ['openid'] = $data ['FromUserName']; //$map1 ['token'] = get_token (); //$map2 ['uid'] = D ( 'public_follow' )->where ( $map1 )->getField ( 'uid' ); //M ( 'public_follow' )->where ( $map1 )->delete (); //M ( 'user' )->where ( $map2 )->delete (); //M ( 'credit_data' )->where ( $map2 )->delete (); //取消专注改变用户状态 D('Common/Follow')->set_subscribe($data['FromUserName'], 0); session('mid', null); // 积分处理 add_credit('unsubscribe'); }
function reply($dataArr, $keywordArr = array()) { $this->config = getAddonConfig('Chat'); // 获取后台插件的配置参数 $content = $this->_tuling($dataArr['Content']); if ($content) { exit; } // 最后只能随机回复了 if (empty($content)) { $content = $this->_rand(); } // 增加积分,每隔5分钟才加一次,5分钟内只记一次积分 add_credit('chat', 300); $res = $this->replyText($content); return $res; }
public function suggest() { $config = getAddonConfig('Suggestions'); if (IS_AJAX) { // 保存用户信息 $nickname = I('nickname'); if ($config['need_nickname'] && !empty($nickname)) { $data['nickname'] = $nickname; } $mobile = I('mobile'); if ($config['need_mobile'] && !empty($mobile)) { $data['mobile'] = $mobile; } // 保存内容 $data['cTime'] = time(); $data['content'] = I('content'); $data['token'] = get_token(); $res = M('suggestions')->add($data); if ($res) { // 增加积分 add_credit('suggestions'); $data['status'] = 1; $data['info'] = '反馈成功,感谢您的支持~'; //$this->success ( '增加成功,谢谢您的反馈' ); $openid = getOpenidByUid($config['admin_id']); $kf_data['touser'] = $openid; $kf_data['msgtype'] = 'text'; $kf_data['text']['content'] = "新的反馈内容:" . $data['content']; //replyText(json_encode($kf_data)); sendCustomMessage($kf_data); } else { $data['status'] = 0; $data['info'] = '反馈失败,请重新提交反馈内容~'; //$this->error ( '增加失败,请稍后再试' ); } $this->ajaxReturn($data); } else { $this->assign($config); // dump ( $config ); $user = getUserInfo(get_mid()); $this->assign('user', $user); $this->display(); } }
function reply($dataArr, $keywordArr = array()) { $config = getAddonConfig('Wecome'); // 获取后台插件的配置参数 if ($dataArr['Content'] == 'subscribe') { $info = D('Common/Follow')->init_follow($dataArr['FromUserName']); // 增加积分 session('mid', $info['id']); add_credit('subscribe'); // 其中token和openid这两个参数一定要传,否则程序不知道是哪个微信用户进入了系统 $param['token'] = get_token(); $param['openid'] = get_openid(); $sreach = array('[follow]', '[website]', '[token]', '[openid]'); $replace = array(addons_url('UserCenter://Wap/bind', $param), addons_url('WeiSite://WeiSite/index', $param), $param['token'], $param['openid']); $config['description'] = str_replace($sreach, $replace, $config['description']); switch ($config['type']) { case '3': $articles[0] = array('Title' => $config['title'], 'Description' => $config['description'], 'PicUrl' => get_cover_url($config['pic_url']), 'Url' => str_replace($sreach, $replace, $config['url'])); $res = $this->replyNews($articles); break; case '2': return false; break; default: $res = $this->replyText($config['description']); } } elseif ($dataArr['Content'] == 'unsubscribe') { // 增加积分 add_credit('unsubscribe'); } elseif ($dataArr['Content'] == 'scan') { $map['scene_id'] = $dataArr['EventKey']; $map['token'] = get_token(); $qr = M('qr_code')->where($map)->find(); if ($qr['addon'] == 'UserCenter') { // 设置用户分组 $group = D('Home/AuthGroup')->move_group($GLOBALS['mid'], $qr['aim_id']); $this->replyText('您已加入' . $group['title']); } } }
function reply($dataArr, $keywordArr = array()) { $map['id'] = $keywordArr['aim_id']; $param['token'] = get_token(); $param['openid'] = get_openid(); if ($data['Content'] == 'location') { $latitude = $dataArr['Location_X']; $longitude = $dataArr['Location_Y']; $pos = file_get_contents('http://lbs.juhe.cn/api/getaddressbylngb?lngx=' . $latitude . '&lngy=' . $longitude); $pos_ar = json_decode($pos, true); $this->replyText(htmlspecialchars_decode($pos_ar['row']['result']['formatted_address'])); } elseif ($keywordArr['extra_text'] == 'custom_reply_mult') { // 多图文回复 $mult = M('custom_reply_mult')->where($map)->find(); $map_news['id'] = array('in', $mult['mult_ids']); $list = M('custom_reply_news')->where($map_news)->select(); foreach ($list as $k => $info) { if ($k > 8) { continue; } $articles[] = array('Title' => $info['title'], 'Description' => $info['intro'], 'PicUrl' => get_cover_url($info['cover']), 'Url' => $this->_getNewsUrl($info, $param)); } $res = $this->replyNews($articles); } elseif ($keywordArr['extra_text'] == 'custom_reply_news') { // 单条图文回复 $info = M('custom_reply_news')->where($map)->find(); // 组装微信需要的图文数据,格式是固定的 $articles[0] = array('Title' => $info['title'], 'Description' => $info['intro'], 'PicUrl' => get_cover_url($info['cover']), 'Url' => $this->_getNewsUrl($info, $param)); $res = $this->replyNews($articles); } else { // 增加积分 add_credit('custom_reply', 300); // 文本回复 $info = M('custom_reply_text')->where($map)->find(); $contetn = replace_url(htmlspecialchars_decode($info['content'])); $this->replyText($contetn); } }
function reply($dataArr, $keywordArr = array()) { $map['id'] = $keywordArr['aim_id']; $param['token'] = get_token(); $param['openid'] = get_openid(); if ($keywordArr['extra_text'] == 'custom_reply_mult') { // 多图文回复 $mult = M('custom_reply_mult')->where($map)->find(); $map_news['id'] = array('in', $mult['mult_ids']); $list = M('custom_reply_news')->where($map_news)->select(); foreach ($list as $k => $info) { if ($k > 8) { continue; } $param['id'] = $info['id']; $url = addons_url('CustomReply://CustomReply/detail', $param); $articles[] = array('Title' => $info['title'], 'Description' => $info['intro'], 'PicUrl' => get_cover_url($info['cover']), 'Url' => $url); } $res = $this->replyNews($articles); } elseif ($keywordArr['extra_text'] == 'custom_reply_news') { // 单条图文回复 $info = M('custom_reply_news')->where($map)->find(); // 组装用户在微信里点击图文的时跳转URL // 其中token和openid这两个参数一定要传,否则程序不知道是哪个微信用户进入了系统 $param['id'] = $info['id']; $url = addons_url('CustomReply://CustomReply/detail', $param); // 组装微信需要的图文数据,格式是固定的 $articles[0] = array('Title' => $info['title'], 'Description' => $info['intro'], 'PicUrl' => get_cover_url($info['cover']), 'Url' => $url); $res = $this->replyNews($articles); } else { // 增加积分 add_credit('custom_reply', 300); // 文本回复 $info = M('custom_reply_text')->where($map)->find(); $this->replyText(htmlspecialchars_decode($info['content'])); } }
function index() { $map['token'] = get_token(); $map['is_show'] = 1; // 幻灯片 $slideshow = M('weisite_slideshow')->where($map)->order('sort asc, id desc')->select(); foreach ($slideshow as &$vo) { $vo['img'] = get_cover_url($vo['img']); } $this->assign('slideshow', $slideshow); // dump($slideshow); // 分类 $category = M('weisite_category')->where($map)->order('sort asc, id desc')->select(); foreach ($category as &$vo) { $vo['icon'] = get_cover_url($vo['icon']); empty($vo['url']) && ($vo['url'] = addons_url('WeiSite://WeiSite/lists', array('cate_id' => $vo['id']))); } $this->assign('category', $category); // dump($category); // 增加积分 add_credit('weisite', 86400); $this->_footer(); $this->display(ONETHINK_ADDON_PATH . 'WeiSite/View/default/TemplateIndex/' . $this->config['template_index'] . '/index.html'); }
function join() { $token = get_token(); $opts_ids = array_filter(I('post.optArr')); $vote_id = intval($_POST["vote_id"]); // 检查ID是否合法 if (empty($vote_id) || 0 == $vote_id) { $this->error("错误的投票ID"); } if ($this->_is_overtime($vote_id)) { $this->error("该投票已过期"); } if ($this->_is_join($vote_id, $this->mid, $token)) { $this->error("您已经投过,请不要重复投"); } if (empty($_POST['optArr'])) { $this->error("请先选择投票项"); } // 如果没投过,就添加 $data["user_id"] = $this->mid; $data["vote_id"] = $vote_id; $data["token"] = $token; $data["options"] = implode(',', $opts_ids); $data["cTime"] = time(); $addid = M("vote_log")->add($data); // 投票选项信息的num+1 foreach ($opts_ids as $v) { $v = intval($v); $res = M("vote_option")->where('id=' . $v)->setInc("opt_count"); } // 投票信息的vote_count+1 $res = M("vote")->where('id=' . $vote_id)->setInc("vote_count"); // 增加积分 add_credit('vote'); // 连续投票 $next_id = M("vote")->where('id=' . $vote_id)->getField("next_id"); if (!empty($next_id)) { $vote_id = $next_id; } redirect(U('show', 'id=' . $vote_id)); }
function detail() { $map['id'] = I('get.id', 0, 'intval'); $info = M('custom_reply_news')->where($map)->find(); $this->assign('info', $info); M('custom_reply_news')->where($map)->setInc('view_count'); // 增加积分 add_credit('custom_reply', 300); $this->display(); }
function finish() { $survey_id = I('survey_id', 0, 'intval'); // $map ['token'] = get_token (); // $info = M ( 'survey' )->where ( $map )->find (); $info = D('Survey')->getSurveyInfo($survey_id); $this->assign('info', $info); // 增加积分 add_credit('survey'); $this->display(); }
function finish() { // 增加积分 add_credit('exam'); $this->show('finish'); }
public function unsubscribe() { // 增加积分 add_credit('unsubscribe'); }
function _api_set_follow_credit() { $res['status'] = 0; $data['experience'] = I('experience', 0, 'intval'); $data['score'] = I('score', 0, 'intval'); $map['openid'] = I('openid'); $data['uid'] = M('public_follow')->where($map)->getField('uid'); if ($data['uid']) { $res['msg'] = 'openid error'; return $res; } $from = I('from'); empty($from) && ($from = '_api_set_follow_credit'); add_credit($from, $data); return array('status' => 1, 'msg' => '操作成功'); }
function join() { $token = get_token(); $opts_ids = array_filter(I('post.optArr')); $vote_id = intval($_POST["vote_id"]); // 检查ID是否合法 if (empty($vote_id) || 0 == $vote_id) { $this->error("错误的投票ID"); } if ($this->_is_overtime($vote_id)) { $this->error("请在指定的时间内投票"); } if ($this->_is_join($vote_id, $this->mid, $token)) { $this->error("您已经投过,请不要重复投"); } if (empty($_POST['optArr'])) { $this->error("请先选择投票项"); } // 如果没投过,就添加 $data["user_id"] = $this->mid; $data["vote_id"] = $vote_id; $data["token"] = $token; $data["options"] = implode(',', $opts_ids); $data["cTime"] = time(); $addid = M("vote_log")->add($data); D('VoteLog')->getFollowLog($this->mid, $vote_id, true); // 更新投票数 D('VoteOption')->updateOptCount($vote_id, $opts_ids); // 投票信息的vote_count+1 // $res = M ( "vote" )->where ( 'id=' . $vote_id )->setInc ( "vote_count" ); $vote = D('Vote'); $voteinfo = $vote->getInfo($vote_id); $up['vote_count'] = $voteinfo['vote_count'] + 1; $vote->update($vote_id, $up); // 增加积分 add_credit('vote'); // 连续投票(投票表里没有next_id字段) // $next_id = M ( "vote" )->where ( 'id=' . $vote_id )->getField ( "next_id" ); // if (! empty ( $next_id )) { // $vote_id = $next_id; // } redirect(U('show', 'id=' . $vote_id)); }
private function getResult($jplist, $xydzp_id, $openid, $token) { $row = $this->is_Maxjoin($xydzp_id, $openid, $token); // dump($row); if ($row != 0) { $arr = array(); // 按概率计算 foreach ($jplist as $key => $val) { // 每个奖品的概率 $arr[] = $val['gailv'] * 10; } shuffle($arr); // dump ( $arr ); $rid = $this->getRand($arr); // 根据概率获取奖项id // dump ( $rid ); $res = $jplist[$rid]; // 中奖项 $num = $row - 1; // 用户抽奖次数减1 // 是否第一次参加 // $list = M ( "xydzp_userlog" )->where ( "xydzp_id=$xydzp_id AND uid='$openid' " )->find (); $list = D('XydzpUserlog')->getUserlogInfo($openid, $xydzp_id); if ($list["id"] > 0) { // M ( "xydzp_userlog" )->where ( array ( // 'xydzp_id' => $res ['xydzp_id'], // 'uid' => $openid // ) )->data ( array ( // 'num' => $list ["num"] + 1, // 'cjdate' => time () // ) )->save (); $data['num'] = $list["num"] + 1; $data['cjdate'] = time(); D('XydzpUserlog')->updateLog($openid, $xydzp_id, $data); } else { M("xydzp_userlog")->add(array('uid' => $openid, 'xydzp_id' => $xydzp_id, 'cjdate' => time(), 'num' => 1)); D('XydzpUserlog')->getUserlogInfo($openid, $xydzp_id, true); } $result['type'] = 2; $result['jptype'] = $res['jptype']; // dump ( $res ); // exit (); if ($res['jptype'] != 2) { if ($res['kcnum'] == 0) { $result['type'] = 1; } else { // 保存用户的中奖信息(排除谢谢惠顾) // 用户抽取的那个奖项库存减1 // M ( "xydzp_option" )->where ( 'id=' . $res ['xydzp_option_id'] )->setField ( 'num', $res ['kcnum'] - 1 ); $optnum['num'] = $res['kcnum'] - 1; D('XydzpOption')->updateOptionNum($res['xydzp_option_id'], $optnum); M("xydzp_log")->add(array('xydzp_id' => $xydzp_id, 'uid' => $openid, 'xydzp_option_id' => $res['xydzp_option_id'], 'zjdate' => time(), 'state' => 0)); D('XydzpLog')->getXydzpLogs($xydzp_id, true); } } else { $result['type'] = 6; } $result['num'] = $num; // 计算中奖角度的位置 $result['angle'] = 360 - 360 / sizeof($jplist) / 2 - 360 / sizeof($jplist) * $rid - 90; $result['angle'] == 0 && ($result['angle'] = 360); $result['card_url'] = ''; if ($res['jptype'] == 3) { // 谢谢参与 $result['praisename'] = '恭喜获得卡券一份'; $result['card_url'] = $res['card_url']; } elseif ($res['jptype'] == 2) { // 谢谢参与 $result['praisename'] = '很抱歉,没有抽中,也许抽的姿势不对,换个姿势再试一次吧!'; } elseif ($res['jptype'] == 1) { // 优惠券奖励 $result['praisename'] = '恭喜获得' . $res["title"] . '奖品,已加入你的空间'; // 发放优惠券 $data['sn'] = uniqid(); $data['uid'] = $this->mid; $data['cTime'] = time(); $data['addon'] = 'Coupon'; $data['target_id'] = $res['coupon_id']; $data['can_use'] = 1; // dump ( $data ); M('sn_code')->add($data); // M ( "coupon" )->where ( 'id=' . $res ['coupon_id'] )->setInc ( "collect_count" ); D('Addons://Coupon/Coupon')->updateCollectCount($res['coupon_id']); } elseif ($res['jptype'] == 0) { // 经历值奖励 $result['praisename'] = '恭喜获得' . $res["title"] . '奖品,经历值增加' . $res['experience'] . '分'; $credit['experience'] = $res['experience']; $credit['score'] = 0; add_credit('xydzp_prize', 5, $credit); } } else { $result['type'] = 0; $result['num'] = $num; // 计算中奖角度的位置 $result['angle'] = -90; $result['praisename'] = ""; } return $this->json($result); }
function detail() { $id = I('get.id', 0, 'intval'); $info = D('Addons://CustomReply/CustomReply')->getInfo($id); $this->assign('info', $info); D('Common/Count')->set('custom_reply_news', $id, 'view_count'); // 增加积分 add_credit('custom_reply', 300); $this->display(); }
function detail() { vendor('jssdk'); $jssdk = new \JSSDK(); $signPackage = $jssdk->GetSignPackage(); //dump($signPackage);exit(); $this->assign('signPackage', $signPackage); $map['id'] = I('get.id', 0, 'intval'); $info = M('custom_reply_news')->where($map)->find(); $this->assign('info', $info); M('custom_reply_news')->where($map)->setInc('view_count'); // 增加积分 add_credit('custom_reply', 300); $this->display(); }
function index() { // 增加积分 add_credit('shop', 86400); echo diyPage('微商店'); }
function set_sn_code() { $data['sn'] = uniqid(); $data['uid'] = $this->mid; $data['cTime'] = time(); $data['addon'] = 'Scratch'; $data['target_id'] = I('id'); $data['token'] = get_token(); $data['prize_id'] = $prize_id = I('prize_id'); $title = ''; if (!empty($prize_id)) { // $title = M ( 'prize' )->where ( $map )->getField ( 'title' ); $prize = D('Prize')->getPrizeInfo($prize_id); $title = $prize['title']; $title || ($title = ''); } $data['prize_title'] = $title; // dump ( $data ); $res = M('sn_code')->add($data); D('SnCode')->getSnCodes($data['target_id'], $data['addon'], true); if ($res) { // 更新获取数 $scratch = D('Scratch')->getScratchInfo($data['target_id']); $s['collect_count'] = $scratch['collect_count'] + 1; // M ( "scratch" )->where ( 'id=' . $data ['target_id'] )->setInc ( "collect_count" ); D('Scratch')->updateCount($data['target_id'], $s); // 扣除积分 $data = D('Scratch')->getScratchInfo($data['target_id']); if (!empty($data['credit_bug'])) { $credit['score'] = $data['credit_bug']; $credit['experience'] = 0; add_credit('scratch_credit_bug', 5, $credit); } } echo $res; }
function import() { $model = $this->getModel('import'); if (IS_POST) { $column = array('A' => 'uid', 'B' => 'credit_title', 'C' => 'score', 'D' => 'cTime'); $attach_id = I('attach', 0); $dateCol = array('D'); $res = importFormExcel($attach_id, $column, $dateCol); if ($res['status'] == 0) { $this->error($res['data']); } $total = count($res['data']); $uidStr = ''; foreach ($res['data'] as $vo) { $uidStr .= $vo['uid'] . ','; if (empty($vo['credit_title'])) { $vo['credit_title'] = '手动导入'; } if (empty($vo['cTime'])) { $vo['cTime'] = time(); } else { $vo['cTime'] = strtotime($vo['cTime']); } add_credit('auto_add', 0, $vo); } $msg = "共导入" . $total . "条记录"; // dump($arr); // $msg = trim ( $msg, ', ' ); // dump($msg);exit; $this->success($msg, U('lists', array('uid' => $uidStr))); } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); $this->assign('post_url', U('import')); $this->assign('import_template', 'score_import.xls'); $this->display('Addons/import'); } }
function index() { $this->model = $this->getModel('forms_value'); $this->forms_id = I('forms_id', 0); $id = I('id'); $forms = M('forms')->find($this->forms_id); $forms['cover'] = !empty($forms['cover']) ? get_cover_url($forms['cover']) : ADDON_PUBLIC_PATH . '/background.png'; $forms['intro'] = str_replace(chr(10), '<br/>', $forms['intro']); $this->assign('forms', $forms); if (!empty($id)) { $act = 'save'; $data = M(get_table_name($this->model['id']))->find($id); $data || $this->error('数据不存在!'); // dump($data); $value = unserialize(htmlspecialchars_decode($data['value'])); // dump ( $value ); unset($data['value']); $data = array_merge($data, $value); $this->assign('data', $data); // dump($data); } else { $act = 'add'; if ($this->mid != 0 && $this->mid != '-1') { $map['uid'] = $this->mid; $map['forms_id'] = $this->forms_id; $data = M(get_table_name($this->model['id']))->where($map)->find(); if ($data && $forms['jump_url']) { // redirect ( $forms ['jump_url'] ); } } } // dump ( $forms ); $map['forms_id'] = $this->forms_id; $map['token'] = get_token(); $fields = M('forms_attribute')->where($map)->order('sort asc, id asc')->select(); if (IS_POST) { foreach ($fields as $vo) { $error_tip = !empty($vo['error_info']) ? $vo['error_info'] : '请正确输入' . $vo['title'] . '的值'; $value = $_POST[$vo['name']]; if ($vo['is_must'] && !isset($value) || !empty($vo['validate_rule']) && !M()->regex($value, $vo['validate_rule'])) { $this->error($error_tip); exit; } $post[$vo['name']] = $vo['type'] == 'datetime' ? strtotime($_POST[$vo['name']]) : $_POST[$vo['name']]; unset($_POST[$vo['name']]); } $_POST['value'] = serialize($post); $act == 'add' && ($_POST['uid'] = $this->mid); // dump($_POST);exit; $Model = D(parse_name(get_table_name($this->model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $this->model['id'], $fields); if ($Model->create() && ($res = $Model->{$act}())) { // 增加积分 add_credit('forms'); $param['forms_id'] = $this->forms_id; $param['id'] = $act == 'add' ? $res : $id; $param['model'] = $this->model['id']; $url = empty($forms['jump_url']) ? U('index', $param) : $forms['jump_url']; $tip = !empty($forms['finish_tip']) ? $forms['finish_tip'] : '提交成功,谢谢参与'; $this->success($tip, $url, 5); } else { $this->error($Model->getError()); } exit; } $fields[] = array('is_show' => 4, 'name' => 'forms_id', 'value' => $this->forms_id); $this->assign('fields', $fields); $this->display(); }
function save_zjInfo($gameId, $awardId, $uid) { $res['other'] = 0; $data['draw_id'] = $gameId; $data['token'] = get_token(); $data['aim_table'] = 'lottery_games'; $data['zjtime'] = time(); $data['num'] = 1; $data['follow_id'] = $uid; $data['award_id'] = $awardId; $awardInfo = D('Addons://Draw/Award')->getInfo($awardId); switch ($awardInfo['award_type']) { case 0: $data['state'] = 1; $data['djtime'] = time(); //虚拟物品,积分奖励 $credit['score'] = $awardInfo['score']; $credit['title'] = '抽奖游戏活动'; $credit['uid'] = $uid; add_credit('lottery_games', 0, $credit); break; case 1: //实物 $data['state'] = 0; $res['other'] = 1; $str = time(); $rand = rand(1000, 9999); $str .= $rand; $data['scan_code'] = $str; break; case 2: $data['state'] = 1; $data['djtime'] = time(); $res1 = D('Addons://Coupon/Coupon')->sendCoupon($awardInfo['coupon_id'], $this->mid); $res['sn_id'] = $res1; $res['other'] = 2; //优惠券 break; case 3: $data['state'] = 1; $data['djtime'] = time(); $res['other']; $res1 = D('Addons://ShopCoupon/Coupon')->sendCoupon($awardInfo['coupon_id'], $this->mid); $res['sn_id'] = $res1; //代金券 break; case 4: $data['state'] = 1; // $data['djtime']=time(); $map1['uid'] = $uid; $map1['token'] = get_token(); $cardMember = M('card_member')->where($map1)->field('id,recharge')->find(); if ($cardMember) { //直接加入会员卡 $save['recharge'] = $cardMember['recharge'] + $awardInfo['money']; M('card_member')->where($map1)->save($save); } else { //没有会员卡, $res['other'] = 4; } //返现 break; } $res['id'] = M('lucky_follow')->add($data); return $res; }
function finish() { $test_id = intval($_REQUEST['test_id']); $this->assign('event_url', event_url('微测试', $test_id)); // dump ( $event_url ); // 增加积分 add_credit('test'); $this->show('finish'); }
function set_sn_code() { $data['sn'] = uniqid(); $data['uid'] = $this->mid; $data['cTime'] = time(); $data['addon'] = 'Scratch'; $data['target_id'] = I('id'); $data['prize_id'] = $map['id'] = I('prize_id'); $title = ''; if (!empty($map['id'])) { $title = M('prize')->where($map)->getField('title'); $title || ($title = ''); } $data['prize_title'] = $title; // dump ( $data ); $res = M('sn_code')->add($data); if ($res) { // 扣除积分 $data = M('scratch')->find($data['target_id']); if (!empty($data['credit_bug'])) { $credit['score'] = $data['credit_bug']; $credit['experience'] = 0; add_credit('scratch_credit_bug', 5, $credit); } } echo $res; }