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);
 }
 function join()
 {
     $xydzp_id = I('get.id', 0, 'intval');
     $xydzp_detail = D('Xydzp')->getXydzpInfo($xydzp_id);
     if ($this->_is_starttime($xydzp_id, $xydzp_detail)) {
         if ($this->_is_overtime($xydzp_id, $xydzp_detail)) {
             $json = json_encode(array("type" => 4));
             echo urldecode($json);
         } else {
             // 减少经历值
             $user = get_mult_userinfo($this->mid);
             if ($xydzp_detail['experience'] > $user['experience']) {
                 $json = json_encode(array("type" => 5));
                 echo urldecode($json);
                 exit;
             }
             $credit['experience'] = 0 - $xydzp_detail['experience'];
             $credit['score'] = 0;
             add_credit('xydzp', 5, $credit);
             $openid = get_openid();
             $token = get_token();
             $fix = C("DB_PREFIX");
             // 查询奖品列表
             // $jplist = M ( 'xydzp_jplist' )->join ( 'left join ' . $fix . 'xydzp_option as op on ' . $fix . 'xydzp_jplist.xydzp_option_id=op.id' )->field ( "op.card_url,op.experience,op.coupon_id,op.title,gailv,xydzp_id,xydzp_option_id,op.num as kcnum,op.miaoshu,op.jptype" )->where ( "xydzp_id=$xydzp_id" )->order ( 'type asc,gailv asc' )->select ();
             $jplist = D('XydzpJplist')->getJplistdetail($xydzp_id);
             // 按奖品等级计算概率
             echo $this->getResult($jplist, $xydzp_id, $openid, $token);
         }
     } else {
         $json = json_encode(array("type" => 3));
         echo urldecode($json);
     }
 }
Example #3
0
/**
 * 根据用户ID获取用户昵称
 *
 * @param integer $uid
 *        	用户ID
 * @return string 用户昵称
 */
function get_nickname($uid = 0)
{
    $info = get_mult_userinfo($uid);
    return $info['nickname'];
}