/**
  * 为了成长付出的代价
  */
 public function doPay($starttime, $currency)
 {
     $tdTime = Pw::getTdtime();
     $set_a = array();
     Wind::import('EXT:signature.service.dm.App_Signature_dm');
     $dm = new App_Signature_dm($this->info['uid']);
     if (!$starttime) {
         $set_a = array($tdTime, $this->money);
     } elseif (!$this->money || strpos($this->groups, ',' . $this->info['groupid'] . ',') === false) {
         $dm->setStartTime(0);
         $this->_userDs()->editUser($dm, PwUser::FETCH_DATA);
     } else {
         $days = floor(($tdTime - $starttime) / 86400);
         $cost = $days * $this->money;
         $cost < 0 && ($cost = 0);
         if ($currency >= $cost) {
             $set_a = array($tdTime, $cost);
         } else {
             $cost = $currency - $currency % $this->money;
             $cost < 0 && ($cost = 0);
             $set_a = array(0, $cost);
         }
     }
     if ($set_a) {
         /* @var $creditBo PwCreditBo */
         $creditBo = PwCreditBo::getInstance();
         $creditBo->set($this->info['uid'], $this->moneyType, -$set_a[1]);
         $dm->setStartTime($set_a[0]);
         $this->_userDs()->editUser($dm, PwUser::FETCH_DATA);
     }
     return true;
 }
 public function afterRegister($userDm)
 {
     if ($this->bp->config['type'] != 2) {
         return false;
     }
     /* @var $inviteDs PwInviteCode */
     $inviteDs = Wekit::load('invite.PwInviteCode');
     if ($this->inviteInfo['created_userid']) {
         $codeDm = new PwInviteCodeDm();
         $codeDm->setInvitedUid($userDm->uid)->setModifiedTime(Pw::getTime())->setIfused(1)->setCode($this->code);
         //别人赠送的邀请码
         $inviteDs->updateCode($codeDm);
         $creditType = $this->bp->config['invite.reward.credit.type'];
         $creditNum = $this->bp->config['invite.reward.credit.num'];
         //邀请人获得加奖励
         //[积分日志] 成功邀请好友积分奖励
         /* @var $creditBo PwCreditBo */
         $creditBo = PwCreditBo::getInstance();
         $creditBo->addLog('invite_reward', array($creditType => $creditNum), new PwUserBo($this->inviteInfo['created_userid']), array('friend' => $userDm->getField('username')));
         $creditBo->set($this->inviteInfo['created_userid'], $creditType, $creditNum);
         //邀请成功相互关注 被邀请者关注邀请者
         /* @var $attention PwAttentionService */
         $attention = Wekit::load('attention.srv.PwAttentionService');
         $attention->addFollow($userDm->uid, $this->inviteInfo['created_userid']);
         //			$attention->addFollow($this->inviteInfo['created_userid'], $userDm->uid);
     } else {
         $codeDm = new PwInviteCodeDm();
         $codeDm->setInvitedUid($userDm->uid)->setIfused(1)->setModifiedTime(Pw::getTime())->setCreateUid($userDm->uid)->setCode($this->code);
         //自己购买的邀请码
         $inviteDs->updateCode($codeDm);
     }
     return true;
 }
 public function run()
 {
     /* @var $userGroup PwUserGroups */
     $userGroup = Wekit::load('usergroup.PwUserGroups');
     $groups = $userGroup->getAllGroups();
     $groupTypes = $userGroup->getTypeNames();
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $pwCreditBo PwCreditBo */
     $pwCreditBo = PwCreditBo::getInstance();
     $config = Wekit::C()->getValues('register');
     if (!$config['active.field']) {
         $config['active.field'] = array();
     }
     $wconfig = WindidApi::C('reg');
     $config['security.username.min'] = $wconfig['security.username.min'];
     $config['security.username.max'] = $wconfig['security.username.max'];
     $config['security.password.min'] = $wconfig['security.password.min'];
     $config['security.password.max'] = $wconfig['security.password.max'];
     $config['security.password'] = $wconfig['security.password'];
     $config['security.ban.username'] = $wconfig['security.ban.username'];
     $this->setOutput($config, 'config');
     $this->setOutput($pwCreditBo->cType, 'credits');
     $this->setOutput($groups, 'groups');
     $this->setOutput($groupTypes, 'groupTypes');
 }
 public function creditAction()
 {
     $this->setCurrentTab('credit');
     $creditType = PwCreditBo::getInstance()->cType;
     $config = $this->_getReplyRewardConfigService()->getReplyRewardCreditType();
     $this->setOutput($creditType, 'creditType');
     $this->setOutput($config, 'config');
 }
 public function run()
 {
     $config = Wekit::C()->getValues('site');
     Wind::import('SRV:credit.bo.PwCreditBo');
     $transfer = Wekit::C('credit', 'transfer');
     $this->setOutput(PwCreditBo::getInstance(), 'creditBo');
     $this->setOutput($config, 'config');
 }
 public function run()
 {
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $pwCreditBo PwCreditBo */
     $pwCreditBo = PwCreditBo::getInstance();
     $this->setOutput($pwCreditBo, 'credit');
     $this->setTemplate('reward.reward_credit');
 }
 /**
  * 喜欢增加策略
  * Enter description here ...
  * @param PwUserBo $userBo
  * @param int $typeid
  * @param int $fromid
  */
 public function addLike(PwUserBo $userBo, $typeid, $fromid = 0)
 {
     $uid = $userBo->uid;
     $likeDs = $this->_getLikeContentDs();
     list($beLikeUid, $isspecial, $count, $fid, $extend) = $this->_getSourceInfo($typeid, $fromid);
     if ($beLikeUid == $uid) {
         return new PwError('BBS:like.fail.myself.post');
     }
     $time = Pw::getTime();
     //判断是否存在喜欢内容
     $info = $likeDs->getInfoByTypeidFromid($typeid, $fromid);
     $likeid = isset($info['likeid']) ? (int) $info['likeid'] : 0;
     Wind::import('SRV:like.dm.PwLikeDm');
     $dm = new PwLikeDm();
     $dm->setTypeid($typeid)->setFromid($fromid)->setIsspecial($isspecial);
     if ($likeid < 1) {
         $likeid = $likeDs->addInfo($dm);
     }
     //判断是否喜欢过
     $logInfo = $this->_getLikeLogDs()->getInfoByUidLikeid($uid, $likeid);
     if ($logInfo) {
         return new PwError('BBS:like.fail.already.liked');
     }
     //写入喜欢记录
     Wind::import('SRV:like.dm.PwLikeLogDm');
     $logDm = new PwLikeLogDm();
     $logDm->setUid($uid)->setLikeid($likeid)->setCreatedTime($time);
     $logid = $this->_getLikeLogDs()->addInfo($logDm);
     if ($logid < 1) {
         return new PwError('BBS:like.fail');
     }
     //更新喜欢内容
     $count++;
     $this->_updateLikeCount($typeid, $fromid, $count);
     $likeDs->updateUsers($likeid, $uid);
     //写入用户喜欢统计
     Wind::import('SRV:user.dm.PwUserInfoDm');
     $likeNumber = isset($userBo->info['likes']) ? intval($userBo->info['likes']) : 0;
     $likeNumber++;
     $infoDm = new PwUserInfoDm($uid);
     $infoDm->setLikes($likeNumber);
     $userDs = Wekit::load('user.PwUser');
     $userDs->editUser($infoDm, PwUser::FETCH_DATA);
     //用户积分
     Wind::import('SRV:forum.bo.PwForumBo');
     $forumBo = new PwForumBo($fid);
     Wind::import('SRV:credit.bo.PwCreditBo');
     $credit = PwCreditBo::getInstance();
     $credit->operate('belike', new PwUserBo($beLikeUid), true, array('forumname' => $userBo->username), $forumBo->getCreditSet('belike'));
     $credit->execute();
     //喜欢挂勾
     $dm->setBeLikeUid($beLikeUid);
     //$this->_getHook()->runDo('addLike', $userBo, $dm);
     PwSimpleHook::getInstance('PwLikeService_addLike')->runDo($userBo, $dm);
     //喜欢后续操作 如果不需要排行,return true
     $this->setLikeBrand($likeid, $count, $typeid, $fromid);
     return array('likeCount' => $likeNumber, 'extend' => $extend);
 }
 public function gainReward($uid, $reward, $taskname)
 {
     $num = $reward['num'];
     list($id) = explode('-', $reward['value'], 2);
     /* @var $creditBo PwCreditBo */
     $creditBo = PwCreditBo::getInstance();
     $creditBo->addLog('task_reward', array($id => $reward['num']), Wekit::getLoginUser(), array('taskname' => $taskname));
     return $creditBo->sets($uid, array($id => $reward['num']));
 }
 public function creditAction()
 {
     $service = $this->_loadConfigService();
     $config = $service->getValues('site');
     Wind::import('SRV:credit.bo.PwCreditBo');
     $creditType = PwCreditBo::getInstance()->cType;
     $this->setOutput($config, 'config');
     $this->setOutput($creditType, 'creditType');
 }
 public function run($ids)
 {
     if ($this->record) {
         foreach ($this->record as $key => $value) {
             $dm = new PwUserInfoDm($key);
             $dm->addPostnum(-$value);
             Wekit::load('user.PwUser')->editUser($dm, PwUser::FETCH_DATA);
         }
         PwCreditBo::getInstance()->execute();
     }
 }
Exemple #11
0
 public function beforeAction($handlerAdapter)
 {
     parent::beforeAction($handlerAdapter);
     if ($this->loginUser->uid < 1) {
         $this->showError('USER:user.not.login');
     }
     $this->config = $this->_getconfigDs()->getValues('site');
     $this->_creditBo = PwCreditBo::getInstance();
     // 是否开启
     if (!$this->config['punch.open']) {
         $this->showError('SPCAE:punch.not.open');
     }
 }
 /**
  * 自动禁止设置
  */
 public function autoAction()
 {
     $config = Wekit::C()->getValues('site');
     $default = array('autoForbidden.open' => 0, 'autoForbidden.condition' => array('autoForbidden.credit' => 0, 'autoForbidden.num' => 0), 'autoForbidden.day' => 0, 'autoForbidden.type' => array(), 'autoForbidden.reason' => '');
     $this->setOutput(array_merge($default, $config), 'config');
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $pwCreditBo PwCreditBo */
     $pwCreditBo = PwCreditBo::getInstance();
     $this->setOutput($pwCreditBo, 'creditBo');
     $banService = $this->_getService();
     $this->setOutput($this->_getBanDayType(), 'dayTypes');
     $this->setOutput($banService->getBanType(), 'types');
 }
 public function run()
 {
     $config = Wekit::C('site');
     $this->setOutput(array('isopen' => $config['app.signature.isopen'], 'money' => $config['app.signature.money'], 'moneytype' => $config['app.signature.moneytype'], 'groups' => $config['app.signature.groups']));
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $pwCreditBo PwCreditBo */
     $pwCreditBo = PwCreditBo::getInstance();
     $this->setOutput($pwCreditBo->cType, 'credit');
     $userGroup = Wekit::load('usergroup.PwUserGroups');
     $groups = $userGroup->getAllGroups();
     $groupTypes = $userGroup->getTypeNames();
     $this->setOutput($groups, 'usergroups');
     $this->setOutput($groupTypes, 'groupTypes');
 }
 public function setCredit($uid, $ctype, $point, $appName)
 {
     Wind::import('SRV:credit.dm.PwCreditDm');
     $dm = new PwCreditDm($uid);
     $dm->addCredit($ctype, $point);
     $result = $this->_loadPwUserDS()->updateCredit($dm);
     if (!$result) {
         Wind::import('SRV:user.bo.PwUserBo');
         $user = new PwUserBo($uid);
         PwCreditBo::getInstance()->addLog('app_default', array($ctype => $point), $user, array('appname' => $appName));
         PwCreditBo::getInstance()->execute();
         return $this->buildResponse(0, $point);
     }
     return $this->buildResponse(-1, '设置积分失败');
 }
 /**
  * update the user info about thread 
  * 
  * @param  array $ids [description]
  * @return boid
  */
 public function run($ids)
 {
     if ($this->recode) {
         foreach ($this->recode as $key => $value) {
             $dm = new PwUserInfoDm($key);
             $dm->addPostnum(-$value['postnum']);
             if ($value['digest']) {
                 $dm->addDigest(-$value['digest']);
             }
             Wekit::load('user.PwUser')->editUser($dm, PwUser::FETCH_DATA);
         }
         if ($this->operatorCredit) {
             PwCreditBo::getInstance()->execute();
         }
     }
 }
Exemple #16
0
 public function run()
 {
     /* @var $userGroup PwUserGroups */
     $userGroup = Wekit::load('usergroup.PwUserGroups');
     $groups = $userGroup->getAllGroups();
     $groupTypes = $userGroup->getTypeNames();
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $pwCreditBo PwCreditBo */
     $pwCreditBo = PwCreditBo::getInstance();
     $service = $this->_loadConfigService();
     $config = $service->getValues('register');
     $this->setOutput($config, 'config');
     $this->setOutput($pwCreditBo->cType, 'credits');
     $this->setOutput($groups, 'groups');
     $this->setOutput($groupTypes, 'groupTypes');
 }
 /**
  * 配置增加表单处理器
  *
  * @return void
  */
 public function dosaveAction()
 {
     $member = $this->getInput('member', 'post');
     $strategy = array();
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $pwCreditBo PwCreditBo */
     $pwCreditBo = PwCreditBo::getInstance();
     foreach ($pwCreditBo->cType as $k => $v) {
         $vkey = 'credit' . $k;
         $member[$vkey] && ($strategy[$vkey] = $member[$vkey]);
     }
     foreach (array('postnum', 'onlinetime', 'digest') as $v) {
         $member[$v] && ($strategy[$v] = $member[$v]);
     }
     $config = new PwConfigSet('site');
     $config->set('upgradestrategy', $strategy)->flush();
     $this->showMessage('success', 'u/upgrade/run/', true);
 }
 public function readAction()
 {
     $config = Wekit::C()->getValues('bbs');
     $order = $config['read.display_info_vieworder'];
     is_array($order) || ($order = array());
     $allInfo = array('uid' => 'UID', 'regdate' => '注册日期', 'lastvisit' => '最后登录', 'fans' => '粉丝', 'follows' => '关注', 'posts' => '发帖数', 'homepage' => '个人主页', 'location' => '来自', 'qq' => 'QQ', 'aliww' => '阿里旺旺', 'birthday' => '生日', 'hometown' => '家乡');
     Wind::import('SRV:credit.bo.PwCreditBo');
     foreach (PwCreditBo::getInstance()->cType as $key => $value) {
         $allInfo[$key] = $value;
     }
     $i = 10000;
     foreach ($allInfo as $key => $value) {
         (!isset($order[$key]) || $order[$key] === '') && ($order[$key] = $i++);
     }
     asort($order);
     reset($order);
     $this->setOutput($order, 'order');
     $this->setOutput($allInfo, 'allInfo');
     $this->setOutput($config, 'config');
 }
Exemple #19
0
 public function run()
 {
     $rmbrate = $this->_conf[$this->_order['buy']]['rate'];
     !$rmbrate && ($rmbrate = 10);
     $num = round($this->_order['price'] * $rmbrate);
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $creditBo PwCreditBo */
     $creditBo = PwCreditBo::getInstance();
     $creditBo->addLog('olpay_credit', array($this->_order['buy'] => $num), PwUserBo::getInstance($this->_order['created_userid']), array('number' => $this->_order['price']));
     $creditBo->set($this->_order['created_userid'], $this->_order['buy'], $num);
     //发送通知
     $params = array();
     $params['change_type'] = 'pay';
     $params['credit'] = $creditBo->cType[$this->_order['buy']];
     $params['num'] = $num;
     $params['unit'] = $creditBo->cUnit[$this->_order['buy']];
     $params['price'] = $this->_order['price'];
     /* @var $notice PwNoticeService */
     $notice = Wekit::load('SRV:message.srv.PwNoticeService');
     $notice->sendNotice($this->_order['created_userid'], 'credit', $this->_order['created_userid'], $params);
 }
 /**
  * 发送推送消息
  */
 public function afterPush($pushid)
 {
     $extend = '';
     $pushDs = Wekit::load('design.PwDesignPush');
     $push = $pushDs->getPush($pushid);
     if (!$push) {
         return false;
     }
     $thread = Wekit::load('forum.PwThread')->getThread($push['push_from_id']);
     if (!$thread) {
         return false;
     }
     $info = unserialize($push['push_extend']);
     $standard = unserialize($push['push_standard']);
     $sTitle = $info[$standard['sTitle']];
     $sUrl = $info[$standard['sUrl']];
     $user = Wekit::load('SRV:user.PwUser')->getUserByUid($push['created_userid']);
     Wind::import('SRV:credit.bo.PwCreditBo');
     Wind::import('SRV:forum.bo.PwForumBo');
     $credit = PwCreditBo::getInstance();
     $operation = 'push_thread';
     $forum = new PwForumBo($thread['fid']);
     $credit->operate($operation, PwUserBo::getInstance($thread['created_userid']), true, array('forumname' => $forum->foruminfo['name']), $forum->getCreditSet($operation));
     $credit->execute();
     $strategy = $credit->getStrategy($operation);
     foreach ((array) $strategy['credit'] as $k => $v) {
         $v && ($extend .= $credit->cType[$k] . '+' . $v);
     }
     //$bo->sets($push['author_uid'], $credit['credit']);
     if ($push['neednotice']) {
         $content = '恭喜,您的帖子<a href="' . $sUrl . '">' . Pw::substrs($sTitle, 20) . '</a>被<a href="' . WindUrlHelper::createUrl('space/index/run', array('uid' => $push['created_userid']), '', 'pw') . '">' . $user['username'] . '</a>执行 推送 操作。';
         $extend && ($content .= '获得' . $extend);
         $title = '帖子《<a href="' . $sUrl . '">' . Pw::substrs($sTitle, 20) . '</a>》被推送';
         Wekit::load('SRV:message.srv.PwNoticeService')->sendDefaultNotice($push['author_uid'], $content, $title);
         $pushDs->updateNeedNotice($pushid, 0);
     }
     return true;
 }
 /**
  * 积分日志
  */
 public function logAction()
 {
     list($ctype, $timeStart, $timeEnd, $award) = $this->getInput(array('ctype', 'time_start', 'time_end', 'award'));
     $page = $this->getInput('page');
     $page < 1 && ($page = 1);
     $perpage = 20;
     list($offset, $limit) = Pw::page2limit($page, $perpage);
     Wind::import('SRV:credit.srv.PwCreditOperationConfig');
     Wind::import('SRV:credit.vo.PwCreditLogSc');
     $sc = new PwCreditLogSc();
     $url = array();
     if ($ctype) {
         $sc->setCtype($ctype);
         $url['ctype'] = $ctype;
     }
     if ($timeStart) {
         $sc->setCreateTimeStart(Pw::str2time($timeStart));
         $url['time_start'] = $timeStart;
     }
     if ($timeEnd) {
         $sc->setCreateTimeEnd(Pw::str2time($timeEnd));
         $url['time_end'] = $timeEnd;
     }
     if ($award) {
         $sc->setAward($award);
         $url['award'] = $award;
     }
     if ($sc->hasData()) {
         $sc->setUserid($this->loginUser->uid);
         $count = Wekit::load('credit.PwCreditLog')->countBySearch($sc);
         $log = Wekit::load('credit.PwCreditLog')->searchLog($sc, $limit, $offset);
     } else {
         $count = Wekit::load('credit.PwCreditLog')->countLogByUid($this->loginUser->uid);
         $log = Wekit::load('credit.PwCreditLog')->getLogByUid($this->loginUser->uid, $limit, $offset);
     }
     $this->setOutput($log, 'log');
     $this->setOutput(PwCreditBo::getInstance(), 'creditBo');
     $this->setOutput(PwCreditOperationConfig::getInstance(), 'coc');
     $this->setOutput($page, 'page');
     $this->setOutput($perpage, 'perpage');
     $this->setOutput($count, 'count');
     $this->setOutput($url, 'url');
     $this->setOutput($ctype, 'ctype');
     $this->setOutput($timeStart, 'timeStart');
     $this->setOutput($timeEnd, 'timeEnd');
     $this->setOutput($award, 'award');
     $this->setTemplate('profile_credit_log');
 }
Exemple #22
0
 public static function getInstance()
 {
     isset(self::$_instance) || (self::$_instance = new self());
     return self::$_instance;
 }
Exemple #23
0
 protected function _getGuestInfo()
 {
     $info = array('groupid' => 2, 'postnum' => 0, 'fans' => 0, 'follows' => 0, 'lastvisit' => Pw::getTime());
     Wind::import('SRV:credit.bo.PwCreditBo');
     foreach (PwCreditBo::getInstance()->cType as $key => $value) {
         $info['credit' . $key] = 0;
     }
     return $info;
 }
 /**
  * 获取注册可以添加的积分
  *
  * @param array $_credit  已有的积分
  * @return array
  */
 private function _getRegisterAddCredit($_credit = array())
 {
     //【用户注册】注册成功初始积分---积分策略中获取
     /* @var $creditBo PwCreditBo */
     $creditBo = PwCreditBo::getInstance();
     $creditStrategy = $creditBo->getStrategy('register');
     !$creditStrategy['credit'] && ($creditStrategy['credit'] = array());
     foreach ($creditStrategy['credit'] as $id => $_v) {
         $_id = 'credit' . $id;
         if (isset($_credit[$_id])) {
             $_credit[$_id] += $_v;
         } else {
             $_credit[$_id] = $_v;
         }
     }
     return $_credit;
 }
Exemple #25
0
 /**
  * 按用户ID发送私信
  * 
  * @param int $uid
  * @param string $content
  * @return PwError|boolean
  */
 public function sendMessageByUid($uid, $content, $fromUid = 0)
 {
     if (!$uid) {
         return new PwError('MESSAGE:user.empty');
     }
     $fromUid or $fromUid = $this->_getLoginUserId();
     if ($uid == $fromUid) {
         return new PwError('MESSAGE:send.to.myself');
     }
     Wind::import('LIB:ubb.PwUbbCode');
     $content = PwUbbCode::autoUrl($content, true);
     // 发消息前hook
     if (($result = $this->_getHook()->runWithVerified('check', $fromUid, $content, $uid)) instanceof PwError) {
         return $result;
     }
     $result = $this->_getWindid()->send($uid, $content, $fromUid);
     if ($result < 1) {
         return new PwError('WINDID:code.' . $result);
     }
     /* @var $creditBo PwCreditBo */
     Wind::import('SRV:credit.bo.PwCreditBo');
     $creditBo = PwCreditBo::getInstance();
     $creditBo->operate('sendmsg', new PwUserBo($fromUid));
     // 发消息扩展
     $this->_getHook()->runDo('addMessage', $uid, $fromUid, $content);
     if ($result) {
         //发件人通知
         $params = array('from_uid' => $uid, 'to_uid' => $fromUid, 'content' => $content, 'is_send' => 1);
         $this->_getNoticeService()->sendNotice($fromUid, 'message', $uid, $params, false);
         //收件人通知
         $params = array('from_uid' => $fromUid, 'to_uid' => $uid, 'content' => $content);
         $this->_getNoticeService()->sendNotice($uid, 'message', $fromUid, $params, false);
         //更新用户表未读数
         $this->updateUserMessage($uid);
     }
     //记录每天发送数量
     $this->_getUserBehaviorDs()->replaceDayBehavior($fromUid, 'message_today', Pw::getTime());
     return $result;
 }
 /**
  * 生成sell标签内容
  *
  * @param int $cost 需要的积分
  * @param stirng $str 隐藏的内容
  * @param object $config ubb转换配置
  * @return string
  */
 public static function createSell($length, $cost, $str, $config)
 {
     self::$_hide = true;
     list($cost, $credit) = explode(',', $cost);
     $creditBo = PwCreditBo::getInstance();
     $cname = isset($creditBo->cType[$credit]) ? $creditBo->cType[$credit] : current($creditBo->cType);
     return array('<span>[以下帖子售价 ' . $cost . ' ' . $cname . ',购买后显示内容]</span>', 16);
 }
Exemple #27
0
 /**
  * 生成sell标签内容
  *
  * @param int $cost 需要的积分
  * @param stirng $str 隐藏的内容
  * @param object $config ubb转换配置
  * @return string
  */
 public static function createSell($cost, $credit, $str, $config)
 {
     Wind::import('SRV:credit.bo.PwCreditBo');
     $creditBo = PwCreditBo::getInstance();
     $credit = isset($creditBo->cType[$credit]) ? $credit : key($creditBo->cType);
     $cName = $creditBo->cType[$credit];
     $html = '';
     if (self::$_num++ == 0) {
         list($recordUrl, $buyUrl, $sellCount) = $config->getSellInfo();
         $html .= "<div class=\"content_sell\" id=\"J_content_sell\"><h6><span class=\"mr10\">" . "此帖售价 <span id=\"J_buy_price\">{$cost}</span> <span id=\"J_buy_util\">{$cName}</span>,已有 <span id=\"J_buy_count\">{$sellCount}</span> 人购买" . "</span> " . "<a href=\"{$recordUrl}\" title=\"查看记录\" class=\"mr10 fn J_buy_record\" data-buycount=\"\">[记录]</a>";
         if (!$config->isAuthor() && !$config->isBuy()) {
             $userCredit = $config->getUserCredit($credit);
             $html .= " <a href=\"{$buyUrl}\" title=\"购买\" class=\"fn J_post_buy J_qlogin_trigger\" data-credit=\"{$userCredit}\" data-price=\"{$cost}\" data-util=\"{$cName}\" data-role=\"post\">[购买]</a>";
         }
         $html .= "</h6></div>";
     }
     if ($config->isBuy()) {
         $html .= "<div class=\"content_sell\">" . str_replace('\\"', '"', $str) . "</div>";
     } else {
         $html .= "<div class=\"content_sell\">" . "<h6>此段为出售的内容,购买后显示</h6>" . "</div>";
     }
     return $html;
 }
 public function parseAttachHtml($att)
 {
     $lang = array(0 => '', 1 => '');
     $att['descrip'] = WindSecurity::escapeHTML($att['descrip']);
     $att['name'] = WindSecurity::escapeHTML($att['name']);
     $attachBuyClass = 'J_attach_post_buy';
     if ($att['cost'] > 0) {
         $creditBo = PwCreditBo::getInstance();
         $lang[0] = $att['special'] == 1 ? '加密' : '出售';
         $lang[1] = '(' . $lang[0] . '<span class="org">' . $att['cost'] . '</span>&nbsp;' . $creditBo->cType[$att['ctype']] . ', <span class="org">' . $att['size'] . '</span>KB, 已下载<span class="org J_attach_count_' . $att['aid'] . '">' . $att['hits'] . '</span>次)&nbsp;';
         $lang[2] = $att['special'] == 2 ? ' J_qlogin_trigger' : '';
         if ($att['special'] == 1) {
             $lang[1] .= '<span class="tips_icon_' . ($this->user->getCredit($att['ctype']) > $att['cost'] ? 'success' : 'error') . '"><span>&nbsp;</span>';
         }
         $attachBuyClass = $this->user->isExists() ? $attachBuyClass : 'J_qlogin_trigger';
     }
     $html = '<span class="file_insert"><a href="' . WindUrlHelper::createUrl($this->downloadUrl . 'aid=' . $att['aid']) . '" class="mr5 J_post_attachs' . $lang[2] . '" data-id="' . $att['aid'] . '" data-price="' . $att['cost'] . '" data-type="' . $att['special'] . '" data-typelang="' . $lang[0] . '" data-util="' . $creditBo->cType[$att['ctype']] . '" data-credit="' . $this->user->getCredit($att['ctype']) . '" data-role="attach" data-size="' . $att['size'] . '" data-hits="' . $att['hits'] . '" data-descrip="' . $att['descrip'] . '"><span class="file_list_wrap"><span class="file_icon_' . $att['ext'] . '"></span></span>' . $att['name'] . '</a><div class="img_info" id="J_attach_post_info_' . $att['aid'] . '" style="display: none;"><p>类型:' . $lang[0] . '</p><p>售价:' . $att['cost'] . '' . $creditBo->cType[$att['ctype']] . '</p><p>大小:' . $att['size'] . 'KB</p><p>下载:<span class="J_attach_count_' . $att['aid'] . '">' . $att['hits'] . '</span>次</p><p>描述:' . $att['descrip'] . '</p><p><a href="' . WindUrlHelper::createUrl($this->downloadUrl . 'aid=' . $att['aid']) . '" data-insertid="' . $att['aid'] . '" class="' . $attachBuyClass . ' mr10" data-countrel=".J_attach_count_' . $att['aid'] . '">[下载]</a>';
     $att['cost'] && ($html .= '<a href="' . WindUrlHelper::createUrl($this->recordUrl . 'aid=' . $att['aid']) . '" class="J_buy_record mr10" data-aid="' . $att['aid'] . '">[记录]</a>');
     if ($this->isAdmin) {
         $html .= '<a class="J_attach_post_del" data-rel="#J_att_' . $att['aid'] . '" href="' . WindUrlHelper::createUrl('bbs/attach/delete', array('aid' => $att['aid'])) . '">[删除]</a>';
     }
     $html .= '</p></div>' . $lang[1] . '</span>';
     return $html;
 }
Exemple #29
0
 /**
  * 检测是否有评分权限
  */
 protected function _checkMarkCreditsRight($credits)
 {
     $loginUser = Wekit::getLoginUser();
     Wind::import('SRV:credit.bo.PwCreditBo');
     $creditBo = PwCreditBo::getInstance();
     $app_mark_credits = $loginUser->getPermission('app_mark_credits');
     $behaviors = $this->_getService()->getMarkBehavior($loginUser->uid, $app_mark_credits);
     foreach ($credits as $k => $v) {
         if (!$v) {
             continue;
         }
         if (!$app_mark_credits[$k]['isopen']) {
             return new PwError(sprintf('%s积分类型未开启', $creditBo->cType[$k]));
         }
         if ($v < $app_mark_credits[$k]['min'] || $v > $app_mark_credits[$k]['max']) {
             return new PwError(sprintf('每次评分限制最小%s,最大%s', $app_mark_credits[$k]['min'] . $creditBo->cType[$k], $app_mark_credits[$k]['max'] . $creditBo->cType[$k]));
         }
         $absValue = abs($v);
         if ($behaviors[$k] + $absValue > $app_mark_credits[$k]['dayMax']) {
             return new PwError(sprintf('您已达每日评分上限%s', $app_mark_credits[$k]['dayMax'] . $creditBo->cType[$k]));
         }
         $mycredit = $loginUser->info['credit' . $k];
         if ($loginUser->info['credit' . $k] < $absValue) {
             return new PwError(sprintf('您只有:%s,积分不足,', $mycredit . $creditBo->cType[$k]));
         }
         $this->_getUserBehaviorDs()->replaceDayNumBehavior($loginUser->uid, sprintf('app_mark_%d', $k), Pw::getTime(), $absValue);
     }
     return true;
 }
 public function buyAction()
 {
     list($tid, $pid) = $this->getInput(array('tid', 'pid'));
     $submit = (int) $this->getInput('submit', 'get');
     if (!$this->loginUser->isExists()) {
         $this->showError('login.not');
     }
     if (!$tid) {
         $this->showError('data.error');
     }
     if ($pid) {
         $result = Wekit::load('forum.PwThread')->getPost($pid);
     } else {
         $pid = 0;
         $result = Wekit::load('forum.PwThread')->getThread($tid, PwThread::FETCH_ALL);
     }
     if (empty($result) || $result['tid'] != $tid) {
         $this->showError('data.error');
     }
     $start = strpos($result['content'], '[sell=');
     if ($start === false) {
         $this->showError('BBS:thread.buy.error.sell.not');
     }
     $start += 6;
     $end = strpos($result['content'], ']', $start);
     $cost = substr($result['content'], $start, $end - $start);
     list($creditvalue, $credittype) = explode(',', $cost);
     Wind::import('SRV:credit.bo.PwCreditBo');
     $creditBo = PwCreditBo::getInstance();
     isset($creditBo->cType[$credittype]) || ($credittype = key($creditBo->cType));
     $creditType = $creditBo->cType[$credittype];
     if ($result['created_userid'] == $this->loginUser->uid) {
         $this->showError('BBS:thread.buy.error.self');
     }
     if (Wekit::load('forum.PwThreadBuy')->get($tid, $pid, $this->loginUser->uid)) {
         $this->showError('BBS:thread.buy.error.already');
     }
     if (($myCredit = $this->loginUser->getCredit($credittype)) < $creditvalue) {
         $this->showError(array('BBS:thread.buy.error.credit.notenough', array('{myCredit}' => $myCredit . $creditType, '{count}' => $creditvalue . $creditType)));
     }
     !$submit && $this->showMessage(array('BBS:thread.buy.message.buy', array('{count}' => $myCredit . $creditType, '{buyCount}' => -$creditvalue . $creditType)));
     Wind::import('SRV:forum.dm.PwThreadBuyDm');
     $dm = new PwThreadBuyDm();
     $dm->setTid($tid)->setPid($pid)->setCreatedUserid($this->loginUser->uid)->setCreatedTime(Pw::getTime())->setCtype($credittype)->setCost($creditvalue);
     Wekit::load('forum.PwThreadBuy')->add($dm);
     $creditBo->addLog('buythread', array($credittype => -$creditvalue), $this->loginUser, array('title' => $result['subject'] ? $result['subject'] : Pw::substrs($result['content'], 20)));
     $creditBo->set($this->loginUser->uid, $credittype, -$creditvalue, true);
     $user = new PwUserBo($result['created_userid']);
     if (($max = $user->getPermission('sell_credit_range.maxincome')) && Wekit::load('forum.PwThreadBuy')->sumCost($tid, $pid) > $max) {
     } else {
         $creditBo->addLog('sellthread', array($credittype => $creditvalue), $user, array('title' => $result['subject'] ? $result['subject'] : Pw::substrs($result['content'], 20)));
         $creditBo->set($user->uid, $credittype, $creditvalue, true);
     }
     $creditBo->execute();
     if ($pid) {
         Wind::import('SRV:forum.dm.PwReplyDm');
         $dm = new PwReplyDm($pid);
         $dm->addSellCount(1);
         Wekit::load('forum.PwThread')->updatePost($dm);
     } else {
         Wind::import('SRV:forum.dm.PwTopicDm');
         $dm = new PwTopicDm($tid);
         $dm->addSellCount(1);
         Wekit::load('forum.PwThread')->updateThread($dm, PwThread::FETCH_CONTENT);
     }
     $this->showMessage('success', 'bbs/read/run/?tid=' . $tid . '&fid=' . $result['fid'], true);
 }