123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 16/4/16
- * Time: 下午6:08
- */
- require_once(BASE_ROOT_PATH . '/helper/bonus_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/session_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/text_filter.php');
- require_once(BASE_ROOT_PATH . '/helper/shaker_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/ranklist_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
- require_once(BASE_ROOT_PATH . '/helper/search/util.php');
- require_once(BASE_ROOT_PATH . '/helper/search_param.php');
- require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/push_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/url_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/invite_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/activity_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/room_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
- require_once(BASE_ROOT_PATH . '/helper/login_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/sms_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/model_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/third_author/wxauthor.php');
- require_once(BASE_ROOT_PATH . '/helper/user_session/storage.php');
- use bonus\activity_bonus;
- use room\proto_type;
- class member_bonusControl extends mbMemberControl
- {
- const sampler_goods = 30;
- const msg_malice_bonus = '为避免恶意欺诈,只有下单后的用户才能发送红包给好友.';
- private $mUserAccount;
- public function __construct() {
- parent::__construct();
- $this->mUserAccount = $this->price_calcer();
- }
- public function indexOp()
- {
- $result = [];
- $result['bonus_total'] = $this->mUserAccount->total_bonus();
- $result['pred_total'] = $this->total_pred();
- $result['bonus_rate'] = 30;
- $mine_rooms = room_helper::user_rooms(session_helper::memberid(),'shared_bonus desc',4);
- if(empty($mine_rooms)) {
- $result['show_joinroom'] = true;
- $result['mine_room'] = [];
- } else {
- $result['show_joinroom'] = false;
- $result['mine_room'] = $mine_rooms;
- }
- $result['convert_ratio'] = 1000;
- $result['other_room'] = room_helper::page_rooms(['type' => proto_type::room_chat],'steps_count desc,room_id desc');
- $result['daliy_bonus'] = schema_helper::openurl("试试手气",activity_bonus::daliy_bonus_url());
- $result['invite_friend'] = schema_helper::invite_page();
- $result['shake_bonus'] = schema_helper::shake();
- $result['donate_steps'] = schema_helper::donate_steps();
- return self::outsuccess($result);
- }
- private function total_pred()
- {
- $member = Model('member');
- $info = $member->getMemberInfoByID(session_helper::memberid());
- return (intval($info['available_predeposit'] * 100 + 0.5 )) / 100;
- }
- public function mine_bonusOp()
- {
- $result = [];
- $result['bonus_total'] = $this->mUserAccount->total_bonus();
- $result['usable_bonus'] = $this->mUserAccount->usable_bonus();
- return self::outsuccess($result);
- }
- public function mine_roomsOp()
- {
- $mod_room = Model('room');
- $items = $mod_room->getRoomParts(['member_id' => session_helper::memberid(),'state' => 0],'room_id');
- $roomids = [];
- foreach ($items as $item) {
- $roomids[] = intval($item['room_id']);
- }
- $result['mine_room'] = room_helper::page_rooms(['type' => proto_type::room_chat,'room_id'=>['in',$roomids]],'steps_count desc,room_id desc',20, 20,$mobile_page);
- $result['mobile_page'] = $mobile_page;
- return self::outsuccess($result);
- }
- public function other_roomsOp ()
- {
- $result['other_room'] = room_helper::page_rooms(['type' => proto_type::room_chat,"steps_count"=>['gt',0]],'steps_count desc,room_id desc',20, 20,$mobile_page);
- $result['mobile_page'] = $mobile_page;
- return self::outsuccess($result);
- }
- public function predepositexOp()
- {
- $result = [];
- $result['bonus_total'] = $this->mUserAccount->total_bonus();
- $result['pred_total'] = $this->total_pred();
- $bonus_state = $this->mUserAccount->bonus_state();
- $expiring = $bonus_state['expiring'];
- $expiring = intval($expiring * 100 + 0.5);
- if($expiring > 0) {
- $expiring = $expiring / 100;
- $warning = "您有{$expiring}元红包即将过期";
- }
- $result = array_merge($result,$bonus_state);
- $result['bonus_rate'] = $this->format_rates($this->mUserAccount->pay_bonus_rates());
- $result['share_bonus_rate'] = $this->format_rates($this->mUserAccount->share_bonus_rates());
- $result['room_bonus'] = $this->mUserAccount->room_bonus();
- $result['send_bless'] = $this->cur_bless();
- $result['avatar'] = session_helper::avatar();
- $result['sub_titles'] = ['shake' => '','invite' => '赚百分百红包','friends' => '','bonus_detail' => $warning];
- $this->update_available_bonus($result['bonus_total']);
- return self::outsuccess($result);
- }
- private function format_rates($bonus_rate)
- {
- if ($bonus_rate != null)
- {
- $rates = $bonus_rate->format();
- $rates_money = [];
- if(noBonusRate())
- {
- $amount = 0.0;
- foreach ($rates as $rate => $money) {
- $amount += $money;
- }
- $rates_money[] = ['rate' => defaultBonusRate(),'total' => $amount];
- }
- else
- {
- foreach ($rates as $rate => $money) {
- $item['rate'] = $rate;
- $item['total'] = $money;
- $rates_money[] = $item;
- }
- }
- }
- else {
- $rates_money = null;
- }
- return $rates_money;
- }
- private function update_available_bonus($amount)
- {
- if(isset($_SESSION['available_bonus']))
- {
- $old = intval($_SESSION['available_bonus'] * 100 + 0.5);
- $cur_cent = intval($amount * 100 + 0.5);
- if($old == $cur_cent) {
- $fEdit = false;
- } else {
- $fEdit = true;
- }
- } else {
- $fEdit = true;
- }
- if($fEdit)
- {
- $_SESSION['available_bonus'] = $amount;
- $member = Model('member');
- $member->editMember(['member_id' => session_helper::memberid()],['available_bonus' => $amount]);
- }
- }
- private function cur_bless()
- {
- if(isset($_SESSION['cur_share_id']) && $_SESSION['cur_share_id'] > 0) {
- $share = bonus_helper::get_share($_SESSION['cur_share_id']);
- } else {
- $share = bonus_helper::get_share();
- $_SESSION['cur_share_id'] = $share['share_id'];
- return $share['title'];
- }
- return $share['title'];
- }
- private function reset_share()
- {
- $share = bonus_helper::get_share();
- $_SESSION['cur_share_id'] = $share['share_id'];
- }
- private function fill_param($input,$bonus_rate)
- {
- $param = $input;
- $param['sender_id'] = $_SESSION['member_id'];
- $param['sender_mobile'] = $_SESSION['member_mobile'];
- $param['sender_name'] = session_helper::nickname();
- if($bonus_rate > 0) {
- $param['bonus_rate'] = $bonus_rate;
- }
- $param['share_id'] = $_SESSION['cur_share_id'];
- return $param;
- }
- public function makeOp()
- {
- if(session_helper::can_send() == false) {
- return self::outerr(errcode::ErrBonus,self::msg_malice_bonus);
- }
- if(usedBonusRate())
- {
- if (intval($_GET['bonus_rate']) > 0) {
- $bonus_rate = intval($_GET['bonus_rate']);
- } else {
- return self::outerr(errcode::ErrParamter,'红包折扣率错误,客户端需要升级新版本.');
- }
- }
- else {
- $bonus_rate = defaultBonusRate();
- }
- $param = $this->fill_param($_GET,$bonus_rate);
- $type = bonus_helper::create_type_input($param);
- if(!$this->mUserAccount->share_enough($type->getTotal_amount(),$bonus_rate)) {
- return self::outerr(errcode::ErrBonusNotEnough,'余额不够发送红包');
- }
- $rate_moneys = [];
- if($type->isFixedAmount()) {
- $item['amount'] = $type->fixed_money();
- } else {
- $item['amount'] = $type->getTotal_amount();
- }
- $item['hold_amount'] = $type->getTotal_amount();
- $item['num'] = $type->getTotal_num();
- $item['rate'] = $bonus_rate;
- $rate_moneys[] = $item;
- $ret = $this->mUserAccount->make_bonus($type->get_param(),$rate_moneys);
- if($ret === false) {
- return self::outerr(errcode::ErrBonus,"生成红包失败.");
- }
- else
- {
- $type_sn = $ret['type_sn'];
- $url = url_helper::bonus_open_url($type_sn);
- $this->share_info($type,$title,$sub_title,$img_url);
- $this->reset_share();
- $strids = $_GET['toids'];
- if(!empty($strids))
- {
- $mids = explode(',',$strids);
- $bonusex = bonus_helper::send($type_sn,$mids);
- if($bonusex != false) {
- push_helper::send_bonus(session_helper::memberid(),$mids,$type_sn);
- }
- }
- return self::outsuccess(['type_sn' => $ret,
- 'url' => "{$url}",
- 'path' => url_helper::bonus_open_path($type_sn),
- 'title' => $title,
- 'sub_title' => $sub_title,
- 'img_url' => $img_url]);
- }
- }
- private function share_info(bonus\type $type,&$title,&$sub_title,&$img_url)
- {
- $share = bonus_helper::get_share($type->share_id());
- $title = $type->bless();
- if(empty($title) || $title == '特权红包,内购正品行货美妆') {
- $title = $share['title'];
- }
- $sub_title = $share['sub_title'] . "\n\n点击领取";
- $img_url = $share['img_url'];
- }
- private function random_cids()
- {
- $type_sn = "member_bonus";
- $time = 0;
- $cids = [];
- if(array_key_exists('goods_sampler',$_SESSION) && array_key_exists($type_sn,$_SESSION['goods_sampler']))
- {
- $cids = $_SESSION['goods_sampler'][$type_sn]['cids'];
- $time = $_SESSION['goods_sampler'][$type_sn]['time'];
- }
- if($time < time() - 86400 || empty($cids))
- {
- if(session_helper::is_man()) {
- $cids = activity\goods_sampler::instance()->fetch_male(self::sampler_goods);
- } else {
- $cids = activity\goods_sampler::instance()->fetch_female(self::sampler_goods);
- }
- if(!empty($cids)) {
- $_SESSION['goods_sampler'][$type_sn]['cids'] = $cids;
- $_SESSION['goods_sampler'][$type_sn]['time'] = time();
- }
- }
- return $cids;
- }
- public function match_goodsexOp()
- {
- $cids = $this->random_cids();
- if(empty($cids))
- {
- return self::outsuccess(['special_list' => null,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'mobile_page' => mobile_page(0)]);
- }
- $model_goods = Model('goods');
- $items = $model_goods->getGoodsListByColorDistinct(['goods_commonid' => ['in',$cids]],goods_helper::fieldstr,'','');
- if(empty($items))
- {
- return self::outsuccess(['special_list' => null,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'mobile_page' => mobile_page(1)]);
- }
- else
- {
- $tmp =[];
- foreach ($items as $item) {
- $commonid = intval($item['goods_commonid']);
- $tmp[$commonid] = $item;
- }
- $goods_list = [];
- foreach ($cids as $cid)
- {
- if(array_key_exists($cid,$tmp)) {
- $goods_list[] = $tmp[$cid];
- }
- }
- foreach ($goods_list as $goods) {
- $goods_id = intval($goods['goods_id']);
- $goods_ids[] = $goods_id;
- }
- $helper = new goods_helper($this->mUserAccount);
- $ret = $helper->summary($goods_list,$related_goods);
- $block = special_formater::format_goods($goods_ids,"",$ret['sort_summary']);
- $blocks = [];
- if($this->page_no() == 1 && !empty($block) && session_helper::client_type() != session_helper::device_mini) {
- global $config;
- $guess_like = $config['special_header']['guess_like'];
- if($guess_like > 0) {
- $specials = special_manager::instance()->blocks($guess_like);
- $blocks = $specials;
- }
- }
- $blocks[] = $block;
- return self::outsuccess(['special_list' => $blocks,
- 'summary' => $ret['summary'],
- 'groupbuy' => $ret['groupbuy'],
- 'limitime' => $ret['limitime'],
- 'bundling' => $ret['bundling'],
- 'mobile_page' => mobile_page(1)]);
- }
- }
- public function match_goodsOp()
- {
- $bonus_rate = $this->mUserAccount->pay_bonus_rates();
- $rate_moneys = $bonus_rate->format();
- $price = bonus_helper::match_price($rate_moneys);
- if($price == false)
- {
- return self::outsuccess(array('special_list' => null,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'mobile_page' => mobile_page(0)));
- }
- else
- {
- $params = ['price' => $price,'page_no' => $this->page_no(),'page_size' => $this->page_size()];
- $result = search\search_client::instance()->match_price($params);
- if($result == false)
- {
- return self::outsuccess(array('special_list' => null,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'mobile_page' => mobile_page(0)));
- }
- $cids = $result['cids'];
- $model_goods = Model('goods');
- $items = $model_goods->getGoodsListByColorDistinct(array('goods_commonid' => array('in',$cids)),goods_helper::fieldstr,'','');
- $page_count = intval($result['page_count']);
- if(empty($items))
- {
- return self::outsuccess(array('special_list' => null,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'mobile_page' => mobile_page($page_count)));
- }
- else
- {
- $tmp =[];
- foreach ($items as $item) {
- $commonid = intval($item['goods_commonid']);
- $tmp[$commonid] = $item;
- }
- $goods_list = [];
- foreach ($cids as $cid)
- {
- if(array_key_exists($cid,$tmp)) {
- $goods_list[] = $tmp[$cid];
- }
- }
- foreach ($goods_list as $goods) {
- $goods_id = intval($goods['goods_id']);
- $goods_ids[] = $goods_id;
- }
- $helper = new goods_helper($this->mUserAccount);
- $ret = $helper->summary($goods_list,$related_goods);
- $blocks = [];
- $block = special_formater::format_goods($goods_ids,"",$ret['sort_summary']);
- if($this->page_no() == 1 && !empty($block))
- {
- global $config;
- $spid = $config['goods_sampler']['mbonus_spid'];
- $banners = special_manager::instance()->special($spid,$unused_gids);
- foreach ($banners as $tmp) {
- $blocks[] = $tmp;
- }
- }
- $blocks[] = $block;
- return self::outsuccess(array('special_list' => $blocks,
- 'summary' => $ret['summary'],
- 'groupbuy' => $ret['groupbuy'],
- 'limitime' => $ret['limitime'],
- 'bundling' => $ret['bundling'],
- 'mobile_page' => mobile_page($page_count)));
- }
- }
- }
- public function makeby_bonusOp()
- {
- if(session_helper::can_send() == false) {
- return self::outerr(errcode::ErrBonus,self::msg_malice_bonus);
- }
- if(!isset($_GET['bonus_sn']) || empty($_GET['bonus_sn'])) {
- return self::outerr(errcode::ErrParamter,"需要红包序列号.");
- }
- $bonus = bonus\user_bonus::create_by_sn($_GET['bonus_sn']);
- if($bonus->expired()) {
- return self::outerr(errcode::ErrBonus,"该红包已经过期,不能再发送.");
- }
- if(!$bonus->can_share()) {
- return self::outerr(errcode::ErrBonus,"该红包只可用于购物,不能分享.");
- }
- $param = $this->fill_param($_GET,$bonus->bonus_rate());
- $type = bonus_helper::create_type_input($param);
- $type_amount = intval($type->getTotal_amount() * 100 + 0.5);
- $bonus_amount = intval($bonus->remain_amount() * 100 + 0.5);
- if($type_amount > $bonus_amount) {
- return self::outerr(errcode::ErrBonusNotEnough,'该红包余额不足发送红包');
- }
- $rate_moneys = [];
- if($type->isFixedAmount()) {
- $item['amount'] = $type->fixed_money();
- } else {
- $item['amount'] = $type->getTotal_amount();
- }
- $item['hold_amount'] = $type->getTotal_amount();
- $item['num'] = $type->getTotal_num();
- $item['rate'] = $bonus->bonus_rate();
- $rate_moneys[] = $item;
- $ret = $this->mUserAccount->makeby_bonus($type->get_param(),$rate_moneys,$bonus->bonus_sn());
- if($ret === false) {
- return self::outerr(errcode::ErrBonus,"生成红包失败.");
- }
- else
- {
- $type_sn = $ret['type_sn'];
- $url = url_helper::bonus_open_url($type_sn);
- $path = url_helper::bonus_open_path($type_sn);
- $this->share_info($type,$title,$sub_title,$img_url);
- $this->reset_share();
- return self::outsuccess(array('type_sn' => $ret,
- 'url' => "{$url}",
- 'title' => $title,
- 'sub_title' => $sub_title,
- 'path' => $path,
- 'img_url' => $img_url));
- }
- }
- public function inviteOp()
- {
- $info = invite_helper::share_info(session_helper::share_id());
- return self::outsuccess(['type_sn' => "",
- 'url' => url_helper::inviter_url(),
- 'title' => $info['title'],
- 'sub_title' => $info['sub_title'],
- 'img_url' => $info['img']]);
- }
- public function invite_pageOp()
- {
- return self::outsuccess(['direct_uri' => url_helper::inviter_url()],"redirect");
- }
- public function shareOp()
- {
- if(!isset($_GET['type_sn']) || empty($_GET['type_sn'])) {
- return self::outerr(errcode::ErrParamter,"需要红包序列号.");
- }
- $type_sn = $_GET['type_sn'];
- $type = bonus\type::create_by_sn($type_sn);
- $this->share_info($type,$title,$sub_title,$img_url);
- $url = url_helper::bonus_open_url($type_sn);
- $path = url_helper::bonus_open_path($type_sn);
- return self::outsuccess(array('type_sn' => $type_sn, 'url' => "{$url}",
- 'title' => $title,
- 'sub_title' => $sub_title,
- 'path' => $path,
- 'img_url' => $img_url));
- }
- public function send_listexOp()
- {
- $type_infos = $this->send_listex($pages);
- if($this->page_no() == 1) {
- $tip_blocks = $this->tip_block('send',count($type_infos));
- } else {
- $tip_blocks = false;
- }
- if($type_infos == null)
- {
- if($tip_blocks == false) $tip_blocks = null;
- return self::outsuccess(array('special_list' => $tip_blocks,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'typeinfos' => $type_infos,
- 'mobile_page' => mobile_page($pages)));
- }
- else
- {
- $blocks = [];
- if($tip_blocks != false)
- {
- foreach ($tip_blocks as $block) {
- $blocks[] = $block;
- }
- }
- $block = special_formater::format_type($type_infos);
- $blocks[] = $block;
- return self::outsuccess(array('special_list' => $blocks,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'typeinfos' => $type_infos,
- 'mobile_page' => mobile_page($pages)));
- }
- }
- private function send_listex(&$pages)
- {
- $mod_type = Model('bonus_type');
- $cond['sender_id|relayer_id'] = array('_multi'=>true,$_SESSION['member_id'],$_SESSION['member_id']);
- $cond['make_type'] = array('in',array(bonus\type::MakeSendType,bonus\type::MakeInviteType));
- $count = $mod_type->getTypeCount($cond);
- if($count == 0) {
- $pages = 0;
- return null;
- }
- $items = $mod_type->getTypeList($cond,$this->page_size(),'*','type_id desc');
- $type_infos = [];
- foreach($items as $val)
- {
- $type = bonus\type::create_by_paramer($val);
- $item["type_sn"] = $type->getType_sn();
- $item["type_bless"] = $type->bless();
- $item["send_type"] = $type->send_type();
- if($type->make_type() == bonus\type::MakeInviteType) {
- $item["title"] = "邀请好友红包";
- }
- else
- {
- if($type->isFixedAmount()) {
- $item["title"] = "普通红包";
- } else {
- $item["title"] = "拼手气红包";
- }
- }
- $item['sender_name'] = $item['title'];
- $item["total_amount"] = $type->getTotal_amount();
- $item["total_num"] = $type->getTotal_num();
- $item["remain_amount"] = $type->remain_amount();
- $item["bonus_rate"] = $type->bonus_rate();
- $item["binded_num"] = $type->binded_num();
- $item["send_start_date"] = $type->get_start_time();
- $item["send_end_date"] = $type->get_end_time();
- $item["make_type"] = $type->make_type();
- $item["is_end"] = $type->isEnd();
- $item["binded_over"] = $type->binded_over();
- $item['can_share'] = !$type->isEnd() && !$type->binded_over();
- $type_sn = $type->getType_sn();
- $open_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&client_type=wap&type_sn={$type_sn}";
- $detail_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn={$type_sn}";
- $item["open_url"] = $open_url;
- $item["detail_url"] = $detail_url;
- $type_infos[] = $item;
- }
- $pages = $this->pages($count);
- return $type_infos;
- }
- private function tip_block($state,$count)
- {
- global $config;
- $banners = $config['bonus_detail_banner'];
- if($state == 'usable') {
- $key = 'usable';
- }
- elseif($state == 'expiring') {
- $key = 'expiring';
- }
- elseif($state == 'used') {
- $key = 'used';
- }
- elseif($state == 'expired') {
- $key = 'expired';
- }
- elseif($state == 'send') {
- $key = 'send';
- }
- else {
- $key = '';
- }
- if(!empty($key)) {
- $special_id = $count <= 0 ? $banners[$key][0] : $banners[$key][1];
- } else {
- $special_id = 0;
- }
- if($special_id == 0) return false;
- $helper = new special_formater($special_id);
- $blocks = $helper->format($goods_ids);
- return $blocks;
- }
- public function topupOp()
- {
- $items = $this->mUserAccount->topup_bonus($_SESSION['member_mobile']);
- if($items === false) {
- return self::outsuccess(array("count" => 0,'total_amount' => 0.00));
- }
- else
- {
- $total_amount = 0.00;
- $max_rate = 0;
- $max_share = 0;
- $result = [];
- foreach ($items as $item)
- {
- $bonus = bonus\user_bonus::create_by_param($item);
- $type = bonus\type::create_by_sn($bonus->type_sn());
- $user_id = $type->sender_id();
- $member = new member_info($user_id);
- $avatar = $member->avatar();
- if($type->binded_over() == false && $type->getTotal_num())
- {
- $share_num = $type->getTotal_num() - $type->binded_num();
- if($max_share < $share_num) {
- $result['max_share']['avatar'] = $avatar;
- $result['max_share']['count'] = $share_num;
- $result['max_share']['total_amount'] = $item['bonus_value'];//$type->getTotal_amount();
- $result['max_share']['rate'] = $type->bonus_rate();
- $result['max_share']['type_sn'] = $type->getType_sn();
- $max_share = $share_num;
- }
- }
- $rate = $bonus->bonus_rate();
- if ($max_rate < $rate)
- {
- $result['max_rate']['avatar'] = $avatar;
- $result['max_rate']['rate'] = $rate;
- $result['max_rate']['type_sn'] = $type->getType_sn();
- $max_rate = $rate;
- }
- $total_amount += doubleval($item['bonus_value']);
- }
- $result['max_rate']['total_amount'] = $total_amount;
- $result['max_rate']['count'] = count($items);
- if(!empty($result['max_share'])) {
- $info = $result['max_share'];
- $count = intval($info['count']);
- $title = "您获得{$count}个红包";
- $sub_title = "可分享红包";
- $btn_type = 'send';
- $btn_title = '点击分享';
- } else {
- $info = $result['max_rate'];
- $count = intval($info['count']);
- $total_amount = $info['total_amount'];
- $title = "您领了{$count}个红包";
- $sub_title = "总共{$total_amount}元,已到账";
- $btn_type = 'detail';
- $btn_title = '点击查看';
- }
- $detail_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn={$info['type_sn']}";
- return self::outsuccess(array("count" => $count, 'total_amount' => $info['total_amount'],
- 'title' => $title,'sub_title' => $sub_title,
- 'avatar' => $info['avatar'],
- 'rate' => $info['rate'],
- 'type_sn' => $info['type_sn'],
- 'btn_type' => $btn_type,
- 'btn_title' => $btn_title,
- 'detail_url' => $detail_url));
- }
- }
- private function async_topup()
- {
- $last_topup = intval($_SESSION['last_topup_time']);
- if(time() - $last_topup > 7 * 86400) {
- QueueClient::push('onAsyncTopup',['member_id' => session_helper::memberid()]);
- $_SESSION['last_topup_time'] = time();
- }
- }
- public function topupexOp()
- {
- $items = $this->mUserAccount->topup_bonus($_SESSION['member_mobile']);
- // $this->async_topup();
- if($items === false) {
- return self::outsuccess(array("count" => 0,'total_amount' => 0.00));
- }
- else
- {
- $total_amount = 0.00;
- $max_rate = 0;
- $avatar = RESOURCE_SITE_URL . '/mobile/defimg/female.png';
- $type_sn = '';
- foreach ($items as $item)
- {
- $bonus = bonus\user_bonus::create_by_param($item);
- $rate = $bonus->bonus_rate();
- if ($max_rate < $rate) {
- $type = bonus\type::create_by_sn($bonus->type_sn());
- $user_id = $type->sender_id();
- $member = new member_info($user_id);
- $avatar = $member->avatar();
- $max_rate = $rate;
- $type_sn = $type->getType_sn();
- }
- $total_amount += doubleval($item['bonus_value']);
- }
- $count = count($items);
- $title = "您新领了{$count}个, 总额价值{$total_amount}元的红包.";
- $detail_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn={$type_sn}";
- return self::outsuccess(array("count" => $count, 'total_amount' => $total_amount,
- 'title' => $title, 'avatar' => $avatar, 'rate' => $max_rate,
- 'type_sn' => $type_sn, 'detail_url' => $detail_url));
- }
- }
- public function recv_listexOp()
- {
- $bonus = $this->recv_list($state,$count,$pages);
- if($this->page_no() == 1) {
- $tip_blocks = $this->tip_block($state,$count);
- } else {
- $tip_blocks = false;
- }
- if($bonus == null)
- {
- if($tip_blocks == false) $tip_blocks = null;
- return self::outsuccess(array('special_list' => $tip_blocks,
- 'summary' => null,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'bonuses' => $bonus,
- 'mobile_page' => mobile_page($pages)));
- }
- else
- {
- $blocks = [];
- if($tip_blocks != false)
- {
- foreach ($tip_blocks as $block) {
- $blocks[] = $block;
- }
- }
- $block = special_formater::format_bonus($bonus);
- $blocks[] = $block;
- return self::outsuccess(array('special_list' => $blocks,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'bonuses' => $bonus,
- 'mobile_page' => mobile_page($pages)));
- }
- }
- //我收到的红包
- public function recv_listOp()
- {
- $bonus = $this->recv_list($state,$count,$pages);
- if($bonus == null) {
- return self::outsuccess(array('bonuses' => array(), 'mobile_page' => mobile_page($pages)));
- }
- return self::outsuccess(array('bonuses' => $bonus,'mobile_page' => mobile_page($pages)));
- }
- private function recv_cond(&$state,&$order_by)
- {
- static $stQuerys = array('usable','expiring','used','expired');
- static $day_secs = 24 * 3600;
- $cond = array('user_id' => $_SESSION['member_id'],'bonus_status' => 3);
- $query_state = $_GET['query_state'];
- if(!empty($query_state) && in_array($query_state,$stQuerys))
- {
- $state = $query_state;
- if($query_state == 'usable') {
- $cond['usable_time'] = ['gt',time()];
- $cond['remain_amount'] = array('gt','0.00');
- $cond['expired'] = 0;
- $order_by = 'grab_time DESC';
- } elseif ($query_state == 'expiring') {
- $cond['usable_time&usable_time'] = ['_multi'=>true,['gt',time()],['elt',time() + 5 * $day_secs]];
- $cond['remain_amount'] = array('gt','0.00');
- $cond['expired'] = 0;
- $order_by = 'grab_time DESC';
- } elseif ($query_state == 'used') {
- $cond['remain_amount'] = '0.00';
- $cond['expired'] = 0;
- $order_by = 'grab_time DESC';
- } elseif ($query_state == 'expired') {
- $cond['expired'] = 1;
- $cond['usable_time'] = ['lt',time()];
- $cond['remain_amount'] = ['gt','0.00'];
- $order_by = 'bonus_rate DESC,bonus_id DESC';
- } else {
- return false;
- }
- }
- return $cond;
- }
- private function recv_list(&$state,&$count,&$pages)
- {
- $mod_bonus = Model('user_bonus');
- $cond = $this->recv_cond($state,$order_by);
- $count = $mod_bonus->getBonusCount($cond);
- if($count == 0) {
- $pages = 0;
- return null;
- }
- $pages = $this->pages($count);
- if($this->page_no() > $pages) {
- return null;
- }
- $items = $mod_bonus->getBonusList($cond,'*',$order_by,$this->page_size(),$count);
- $type_ids = array();
- foreach ($items as $val) {
- array_push($type_ids,intval($val['type_id']));
- }
- $types = array();
- $type_items = Model('bonus_type')->getTypeList(array('type_id' => array('in',$type_ids)));
- foreach ($type_items as $val) {
- $type = bonus\type::create_by_paramer($val);
- $types[$type->getType_id()] = $type;
- }
- $result = [];
- foreach($items as $val)
- {
- $user_bonus = bonus\user_bonus::create_by_param($val);
- $item['bonus_sn'] = $user_bonus->bonus_sn();
- $item['bonus_value'] = $user_bonus->bonus_value();
- $item['remain_amount'] = $user_bonus->remain_amount();
- $item['usable_time'] = $user_bonus->usable_time();
- $item['expired'] = $user_bonus->expired();
- $item['spend_over'] = $user_bonus->spend_over();
- $item['get_time'] = $user_bonus->get_time();
- $item['can_share'] = $user_bonus->client_can_share();
- $bonus_rate = $user_bonus->bonus_rate();
- $item['bonus_rate'] = empty($bonus_rate) ? 30 : $bonus_rate;
- if(array_key_exists($user_bonus->type_id(),$types) == false) {
- continue;
- }
- $type = $types[$user_bonus->type_id()];
- $item['sender_name'] = $this->show_name($type);
- $item['title'] = $this->show_name($type);
- $item['rand_type'] = $type->isRandomAmount();
- $item['total_num'] = $type->getTotal_num();
- $item['binded_num'] = $type->binded_num();
- $item['share_end'] = $type->isEnd();
- $item['show_type'] = self::show_type($type->make_type());
- $type_sn = $type->getType_sn();
- $item['type_sn'] = $type_sn;
- $item['url'] = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&client_type=wap&type_sn={$type_sn}";
- $item['detail_url'] = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn={$type_sn}";
- $result[] = $item;
- }
- return $result;
- }
- private function show_type($make_type)
- {
- switch ($make_type)
- {
- case bonus\type::MakeSendType: //抢
- case bonus\type::MakeInviteType:
- case bonus\type::MakeVoteType:
- return 1;
- case bonus\type::MakeBonusRefundType: //退
- case bonus\type::MakePayRefundType:
- case bonus\type::MakeOrderCancelType:
- return 2;
- case bonus\type::MakeShakeGainType: //摇
- case bonus\type::MakeShakeLostType:
- return 3;
- case bonus\type::MakePayType: //赠
- case bonus\type::MakeRegisterType:
- case bonus\type::MakeEvaluateType:
- case bonus\type::MakeInviteRewardType:
- case bonus\type::MakePayRewardInviterType:
- case bonus\type::MakePayRewardInviteeType:
- case bonus\type::MakeAllowanceType:
- return 4;
- default:
- return 0; //什么都不显示
- }
- }
- private function show_name(bonus\type $type)
- {
- $make_type = $type->make_type();
- switch ($make_type) {
- case bonus\type::MakeSendType: //抢
- case bonus\type::MakeShakeGainType: //摇
- return $type->sender_name();
- case bonus\type::MakeVoteType:
- return "投票或答题红包";
- case bonus\type::MakeEvaluateType:
- case bonus\type::MakeInviteType:
- case bonus\type::MakeBonusRefundType: //退
- case bonus\type::MakePayRefundType:
- case bonus\type::MakeOrderCancelType:
- case bonus\type::MakeShakeLostType:
- case bonus\type::MakePayType: //赠
- case bonus\type::MakeRegisterType:
- case bonus\type::MakeInviteRewardType:
- case bonus\type::MakePayRewardInviterType:
- case bonus\type::MakePayRewardInviteeType:
- case bonus\type::MakeAllowanceType:
- return $type->name();
- default:
- return "熊猫美妆"; //什么都不显示
- }
- }
- //预存款收支记录
- public function pdlogOp()
- {
- $mod_pd = Model('predeposit');
- $count = $mod_pd->getPdLogCount(array('lg_member_id' => $_SESSION['member_id']));
- $items = $mod_pd->getPdLogList(array('lg_member_id' => $_SESSION['member_id']),$this->page_size(),'*','lg_id desc');
- if(empty($items)) {
- return self::outsuccess(array('pd_logs' => array(),'mobile_page' => mobile_page(0)));
- }
- $logger = new bonus\recorder(session_helper::memberid());
- $pd_logs = $logger->filter_pd_log($items);
- $pages = $this->pages($count);
- return self::outsuccess(array('pd_logs' => $pd_logs,'mobile_page' => mobile_page($pages)));
- }
- public function shakeOp()
- {
- if(!isset($_POST['strength']) || !empty($_POST['strength'])) {
- $strength = intval($_POST['strength']);
- } else {
- $strength = 3;
- }
- $shaker = new shaker_helper();
- $items = $shaker->shake($strength,$err);
- if($items == false) {
- return self::outsuccess(array("bonuses" => [],"info" => array('count' => 0, 'money' => 0.0)));
- }
- else
- {
- $total_amount = 0;
- $bonuses = array();
- foreach ($items as $bonus)
- {
- $user_bonus = bonus\user_bonus::create_by_param($bonus);
- $type_info = bonus_helper::get_typeinfo($user_bonus->type_sn());
- $type_info = $type_info['type_info'];
- $type = bonus\type::create_by_paramer($type_info);
- $item = array();
- if($_SESSION['member_id'] == $user_bonus->user_id()) {
- $item['direction'] = 'gain';
- $item['name'] = $type->sender_name();
- $item['bonus_value'] = $user_bonus->bonus_value();
- $item['url'] = $this->bonus_detailurl($user_bonus->type_sn());
- $total_amount += $user_bonus->bonus_value();
- $minfo = new member_info($type->sender_id());
- } else {
- $item['direction'] = 'lost';
- $item['name'] = $user_bonus->user_name();
- $item['bonus_value'] = $user_bonus->bonus_value();
- $item['url'] = $this->bonus_detailurl($user_bonus->type_sn());
- $total_amount -= $user_bonus->bonus_value();
- $minfo = new member_info($user_bonus->user_id());
- }
- $item['is_man'] = $minfo->is_man();
- $item['avatar'] = $minfo->avatar();
- array_push($bonuses,$item);
- }
- $count = count($bonuses);
- return self::outsuccess(array("bonuses" => $bonuses,"info" => array('count' => $count, 'money' => $total_amount)));
- }
- }
- public function thiefOp()
- {
- $user_id = $_GET['enmember_id'];
- if(empty($user_id)) {
- return self::outerr(errcode::ErrParamter,"被偷的用户不存在");
- }
- $user_id = util::decrypt_data(urldecode($user_id));
- if($user_id <= 0) {
- return self::outerr(errcode::ErrParamter,"被偷的用户不存在");
- }
- else
- {
- $amount = session_helper::thief($user_id,$err);
- if($amount == false) {
- return self::outerr($err['code'],$err['msg']);
- }
- else
- {
- $bonuses = account_helper::gain_bonus($user_id, $_SESSION['member_id'], $amount);
- if($bonuses == false || empty($bonuses)) {
- return self::outerr(errcode::ErrBonus,"这次没偷着");
- } else {
- $bonus = $bonuses[0];
- $tips = "您成功偷到{$bonus['bonus_value']}元";
- return self::outsuccess(array("bonuses" => $bonuses,
- "info" => ['count' => 1, 'money' => $bonus['bonus_value'],'tips' => $tips]));
- }
- }
- }
- }
- private function bonus_detailurl($type_sn)
- {
- $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&type_sn={$type_sn}&client_type=wap";
- return $url;
- }
- public function daily_rankOp()
- {
- $count = ranklist_helper::list_count($_SESSION['member_id']);
- if($count == false) {
- return self::outerr(errcode::ErrBonusDailyRank,"您还没有抢红包记录,明天才能看到榜单~");
- }
- $start_index = ($this->page_no() - 1) * $this->page_size();
- $end = $start_index + $this->page_size();
- $end = $end > $count ? $count : $end;
- $times = array();
- $start_tm = time();
- for ($index = $start_index; $index < $end; ++$index) {
- $date_time = date_helper::sub_days($start_tm,$index + 1);
- array_push($times,$date_time);
- }
- $mids = array();
- array_push($mids,intval($_SESSION['member_id']));
- $top_infos = array();
- $tops = ranklist_helper::ranklists($_SESSION['member_id'],$times);
- foreach ($tops as $key => $top) {
- $item = array();
- $item['list_sn'] = $top->list_sn();
- $item['list_rank'] = $top->get_rank() + 1;
- $item['list_value'] = $top->money();
- $item['list_date'] = $top->list_date();
- $item['top_id'] = $top->top_id();
- $item['top_money'] = $top->top_money();
- if(in_array($top->top_id(),$mids) == false) {
- array_push($mids,$top->top_id());
- }
- array_push($top_infos,$item);
- }
- $mem_desc = array();
- $members = Model('member')->getMemberList(array('member_id' => array('in',$mids)));
- foreach ($members as $val) {
- $info = new member_info($val);
- array_push($mem_desc,$info->filter());
- }
- $pages = intval($count / $this->page_size()) + ( ($count % $this->page_size()) == 0 ? 0 : 1);
- return self::outsuccess(array('top_list' => $top_infos,'mem_desc' => $mem_desc,'mobile_page' => mobile_page($pages)));
- }
- //免费送
- public function free_giftsOp()
- {
- return self::outsuccess(null,"bonus/free_gifts");
- // $user = intval($_GET['curuser']);
- // if(session_helper::need_wechat_author())
- // {
- // $author = new thrid_author\wxauthor();
- // $url = author_url::inviter_url($user);
- // $url = $author->enter($url);
- // return self::outsuccess(['direct_uri' => $url],"redirect");
- // }
- //
- // if($user <= 0)
- // {
- // if(session_helper::logined()) {
- // $user = session_helper::memberid();
- // }
- // }
- //
- // $type_sn = account_helper::invite_bonus(session_helper::share_id());
- // if($user > 0) {
- // return self::outsuccess(['tpl' => new tpl_free_gifts($user,$type_sn)],"bonus/free_gifts",'wap');
- // }
- // else {
- // return self::outerr(errcode::ErrParamter);
- // }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public function share_oneOp()
- {
- if(!isset($_GET['bonus_sn']) || empty($_GET['bonus_sn'])) {
- return self::outerr(errcode::ErrParamter,"需要红包序列号.");
- }
- $bonus_sn = $_GET['bonus_sn'];
- $ret = $this->mUserAccount->share_bonus($bonus_sn,$msg);
- if($ret === false) {
- return self::outerr(errcode::ErrBonus,empty($msg) ? "生成红包失败." : $msg);
- } else {
- $type_sn = $ret['type_sn'];
- $url = url_helper::bonus_open_url($type_sn);
- return self::outsuccess(array('type_sn' => $ret,'url' => "{$url}"));
- }
- }
- public function send_listOp()
- {
- $type_infos = $this->send_list($pages);
- return self::outsuccess(array('type_infos' => $type_infos, 'mobile_page' => mobile_page($pages)));
- }
- private function send_list(&$pages)
- {
- $mod_type = Model('bonus_type');
- $cond['sender_id|relayer_id'] = ['_multi'=>true,$_SESSION['member_id'],$_SESSION['member_id']];
- $cond['make_type'] = array('in',array(bonus\type::MakeSendType,bonus\type::MakeInviteType));
- $count = $mod_type->getTypeCount($cond);
- if($count == 0) {
- $pages = 0;
- return null;
- }
- $items = $mod_type->getTypeList($cond,$this->page_size(),'*','type_id desc');
- $type_infos = [];
- foreach($items as $val) {
- $type_info = bonus_helper::filter_type($val);
- $type_infos[] = $type_info;
- }
- $pages = $this->pages($count);
- return $type_infos;
- }
- }
- class tpl_free_gifts
- {
- private $mUser;
- private $mRewardedInvites;
- private $mRewardingInvites;
- private $mUserInfo;
- private $mShareInfo;
- private $mTypesn;
- private $mMineInfo;
- private $mRank;
- private $mMine;
- private $mCaller;
- public function __construct($user,$type_sn)
- {
- $this->mUser = $user;
- $this->mRewardedInvites = [];
- $this->mRewardingInvites = [];
- $this->init($user);
- $this->mShareInfo = invite_helper::share_info(session_helper::share_id());
- $this->mTypesn = $type_sn;
- $this->mMine = (session_helper::memberid() == $user);
- $this->mCaller = new user_session\friend_caller();
- }
- private function init($user)
- {
- if($user <= 0) return false;
- $mod_member = Model('member');
- $items = $mod_member->getMemberList(['member_id|inviter_id' => ['_multi' => true,$user,$user]],'*', 0, 'reward_amount desc');
- $cur_user = session_helper::memberid();
- $index = 0;
- foreach ($items as $item)
- {
- $user_info = new member_info($item);
- $uid = $user_info->member_id();
- if($uid == $user) {
- $this->mUserInfo = $user_info;
- }
- elseif ($uid == $cur_user) {
- $this->mMineInfo = $user_info;
- $this->mRank = $index + 1;
- }
- else
- {
- if($user_info->rewared_inviter()) {
- $this->mRewardedInvites[] = $user_info;
- } else {
- $this->mRewardingInvites[] = $user_info;
- }
- }
- $index++;
- }
- }
- public function show()
- {
- $this->show_relay();
- // if(!empty($this->mTypesn)) {
- // $this->show_bonus();
- // }
- $rewared = $this->show_rewared();
- $rewarding = $this->show_rewarding();
- if($rewared == false && $rewarding == false) {
- $this->show_noinvitee();
- }
- $this->show_prompt();
- }
- private function show_noinvitee()
- {
- echo "<div class=\"bonus_list\">";
- echo "<span class=\"invite_null\">TA尚未邀请好友</span>";
- echo "</div>";
- }
- private function show_relay()
- {
- $minfo = $this->mUserInfo;
- $inviter_id = $minfo->inviter_id();
- $str = "
- <div class=\"profit_box\">
- <div class=\"left_profit\">
- <img class=\"profit_avatar\" src=\"{$minfo->avatar()}\" alt=\"\">
- <p class=\"f14 col333 lineH1\">{$minfo->nickname()}</p>
- ";
- if($inviter_id > 0) {
- $str .= "";
- }
- $str .= "
- </div>
- <div class=\"right_profit\">
- <p class=\"profit_money mb9\">{$minfo->reward_amount()}<span class=\"profit_unit\">元</span></p>
- <p class=\"f14 col666 lineH1\">邀请好友累计获得收益</p>
- </div>
- </div>";
- echo $str;
- }
- // private function show_bonus()
- // {
- // echo "<div class=\"open_bonus_link\">
- // <div class=\"bonus\">
- // <div class=\"bonus_top\"></div>
- // <div class=\"bonus_center\"></div>
- // <div class=\"bonus_bg\">
- // <span id=\"coin\" class=\"open_bonus_btn gold_coin\"></span>
- // </div>
- // </div>
- // </div>";
- // }
- private function show_rewared()
- {
- if(empty($this->mMineInfo) && empty($this->mRewardedInvites)) {
- return false;
- }
- if(!empty($this->mMineInfo) && $this->mMineInfo->rewared_inviter()) {
- $count = count($this->mRewardedInvites) + 1;
- } else {
- $count = count($this->mRewardedInvites);
- }
- echo "<div class=\"bonus_list\">";
- echo "<div class=\"prompt_label\">
- <span class=\"title\">已带来收益的好友<span class=\"invite_num\">({$count})</span></span>
- </div>";
- if(!empty($this->mMineInfo) && $this->mMineInfo->rewared_inviter()) {
- $this->show_invitee($this->mMineInfo);
- }
- foreach ($this->mRewardedInvites as $minfo) {
- $this->show_invitee($minfo);
- }
- echo "</div>";
- return true;
- }
- private function show_rewarding()
- {
- if(empty($this->mMineInfo) && empty($this->mRewardingInvites)) {
- return false;
- }
- if(!empty($this->mMineInfo) && $this->mMineInfo->rewared_inviter() == false) {
- $count = count($this->mRewardingInvites) + 1;
- } else {
- $count = count($this->mRewardingInvites);
- }
- echo "<div class=\"bonus_list\">";
- echo "<div class=\"prompt_label\">
- <span class=\"title\">尚未带来收益的好友<span class=\"invite_num\">({$count})</span></span>
- </div>";
- if(!empty($this->mMineInfo) && $this->mMineInfo->rewared_inviter() == false) {
- $this->show_invitee($this->mMineInfo);
- }
- foreach ($this->mRewardingInvites as $minfo) {
- $this->show_invitee($minfo);
- }
- echo "</div>";
- return true;
- }
- private function show_prompt()
- {
- $str = "<div class=\"prompt\">
- <div class=\"prompt_label\">
- <span class=\"title\">提示</span>
- </div>
- <div class=\"prompt_list\">
- <p>1.由于近期发现恶意刷红包用户,为保障体验,在邀请好友之后,需要好友微信授权、注册、下载APP登录后才发邀请奖励。</p>
- <p>2.邀请前5名新用户可得10元100%红包,邀请好友数量>5后可得10元40%红包,雨露均沾红包为40%红包,为了您的长期收益,我们建议您邀请真实的朋友。</p>
- <p>3.您可以点击\"召唤TA\",邀请好友回来。(同一用户每天只能召唤一次)</p>
- <p>4.熊猫有权解散违规邀请的用户,收回已发红包并关闭相关订单。(具体细节查看规则)</p>
- </div>
- </div>
- <div class=\"briefing_address\"></div>";
- echo $str;
- }
- private function show_invitee($minfo)
- {
- if(empty($minfo)) return;
- $user = $minfo->member_id();
- $called = $this->mCaller->called($user);
- $url = BASE_SITE_URL . "/mobile/index.php?act=invite_friend&op=index&client_type=wap&curuser={$user}";
- $str = "<div class=\"item\">
- <a href=\"{$url}\">
- <div class=\"user_img\">
- <img src=\"{$minfo->avatar()}\">
- </div>
- <div class=\"user_name text-overflow\">
- <p class=\"text-overflow\"> {$minfo->nickname()}</p>
- <p class=\"invite_msg\">邀请{$minfo->invitees()}人,收益<span class=\"price\">{$minfo->reward_amount()}</span>元</p>
- </div>";
- if($this->mMine == false)
- {
- $str .= "<div class=\"look_btn\">
- <span class=\"arrow\"></span>
- </div>";
- }
- $str .= "</a>";
- if($this->mMine)
- {
- if($called) {
- $str .= "<span class=\"call_btn called\" data-user=\"{$user}\">召唤TA</span>";
- } else {
- $str .= "<span class=\"call_btn\" data-user=\"{$user}\">召唤TA</span>";
- }
- }
- $str .= "</div>";
- echo $str;
- }
- public function show_open()
- {
- if(!session_helper::isapp())
- {
- echo "<div class=\"fixed_bottom\">
- <span class=\"logo\"></span>
- <div class=\"label\">
- <p>熊猫美妆</p>
- <p>下载APP即可得更多奖励</p>
- </div>
- <a href=\"#\" class=\"download_app_btn\" id=\"download_app\">打开APP</a>
- </div>";
- }
- }
- public function bonus_url() {
- return url_helper::bonus_open_url($this->mTypesn);
- }
- public function share_url()
- {
- return url_helper::bonus_open_url($this->mTypesn);
- }
- public function share_title()
- {
- return $this->mShareInfo['title'];
- }
- public function share_image()
- {
- return $this->mShareInfo['img'];;
- }
- public function share_subtitle()
- {
- return $this->mShareInfo['sub_title'];;
- }
- }
|