Esempio n. 1
0
 public function doMobileResult()
 {
     global $_GPC, $_W;
     if (isset($_GPC['wd_code'])) {
         $title = '防伪验真';
         $footer_off = 1;
         $SecurityCode = $_GPC['wd_code'];
         load()->model('mc');
         $openid = $this->message['from'];
         $logs['openid'] = $openid;
         $logs['weid'] = $_W['uniacid'];
         $fans = pdo_fetch("SELECT fanid,uid FROM " . tablename('mc_mapping_fans') . " WHERE `openid`='{$openid}' LIMIT 1");
         $uid = '0';
         if ($fans['uid'] != '0') {
             $uid = $fans['uid'];
         } else {
             $uid = mc_update($uid, array('email' => md5($_W['openid']) . '@012wz.com'));
             if (!empty($fans['fanid']) && !empty($uid)) {
                 pdo_update('mc_mapping_fans', array('uid' => $uid), array('fanid' => $fans['fanid']));
             }
         }
         $logs['code'] = $SecurityCode;
         $sql = "SELECT * FROM " . tablename($this->data) . " WHERE code='{$SecurityCode}' LIMIT 1";
         $member = pdo_fetch($sql);
         $states = 0;
         if (!empty($member)) {
             if ($member['stime'] <= TIME()) {
                 $logs['status'] = '0';
                 $reply = '您查询的防伪码已过期! ';
             } else {
                 $member['num'] = intval($member['num']) + 1;
                 $data = array('num' => $member['num']);
                 pdo_update($this->data, $data, array('id' => $member['id']));
                 $states = 1;
                 $logs['status'] = '1';
             }
             if ($member['creditstatus'] == '0') {
                 mc_credit_update($uid, 'credit1', $member['creditnum'], array('1', '防伪码自动增加积分,积分名称:' . $member['creditname']));
                 pdo_update($this->data, array('creditstatus' => '1'), array('id' => $member['id']));
             }
             $logs['createtime'] = time();
             pdo_insert('super_securitycode_logs', $logs);
             $sql = "SELECT a.*,b.residecity,b.resideprovince FROM " . tablename("super_securitycode_logs") . " as a\r\n\r\n                left JOIN ims_mc_mapping_fans as c on a.openid=c.openid\r\nleft join ims_mc_members as b on c.uid=b.uid\r\n                WHERE a.code='{$SecurityCode}' and a.status=1 order by a.createtime DESC  LIMIT 0," . $member['num'];
             $loglist = pdo_fetchall($sql);
             include $this->template('index2');
         } else {
             $reply = '您查询的防伪码不存在,请核对后重试!';
         }
     } else {
         $reply = '您查询的防伪码不存在,请核对后重试!';
     }
     echo $reply;
     exit;
 }
Esempio n. 2
0
 function fans_update($user, $fields)
 {
     global $_W;
     load()->model('mc');
     $uid = intval($user);
     if (empty($uid)) {
         $uid = pdo_fetchcolumn("SELECT uid FROM " . tablename('mc_mapping_fans') . " WHERE openid = :openid AND acid = :acid", array(':openid' => $user, ':acid' => $_W['acid']));
         if (empty($uid)) {
             return false;
         }
     }
     return mc_update($uid, $fields);
 }
Esempio n. 3
0
 public function doMobileEditfans()
 {
     global $_GPC, $_W;
     $rid = intval($_GPC['rid']);
     $from_user = authcode(base64_decode($_GPC['from_user']), 'DECODE');
     $uniacid = $_W['uniacid'];
     //Session_token令牌判断
     if (!isset($_GPC['session_token'])) {
         $this->Json_encode(array('success' => 1, 'msg' => '非法操作'));
     }
     if (isset($_GPC['session_token']) && $_GPC['session_token'] != $_SESSION['_token']) {
         $this->Json_encode(array('success' => 1, 'msg' => '请等待上次操作生效!不要着急!'));
     }
     //Session_token令牌判断
     $exchange = pdo_fetch("select * FROM " . tablename("stonefish_chailihe_exchange") . " where rid = :rid", array(':rid' => $rid));
     //判断是否参与过
     $fans = pdo_fetch("select * from " . tablename('stonefish_chailihe_fans') . " where rid = :rid and uniacid = :uniacid and from_user= :from_user", array(':rid' => $rid, ':uniacid' => $uniacid, ':from_user' => $from_user));
     $uid = pdo_fetchcolumn("select uid FROM " . tablename('mc_mapping_fans') . " where openid=:openid and uniacid=:uniacid", array(":openid" => $from_user, ":uniacid" => $uniacid));
     if (!empty($fans)) {
         //读取保存提交的资料
         $ziduan = array('realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position');
         foreach ($ziduan as $ziduans) {
             if ($exchange['is' . $ziduans]) {
                 pdo_update('stonefish_chailihe_fans', array($ziduans => $_GPC[$ziduans]), array('id' => $fans['id']));
                 //是否同步保存FANS表
                 if ($exchange['isfans'] && $uid) {
                     if ($ziduans == 'email') {
                         mc_update($uid, array('email' => $_GPC['email']));
                     } else {
                         mc_update($uid, array($ziduans => $_GPC[$ziduans], 'email' => $profile['email']));
                     }
                 }
                 //是否同步保存FANS表
             }
         }
         //读取保存提交的资料
         //生成Session_token令牌
         $this->Session_token($from_user);
         //生成Session_token令牌
         $data = array('success' => 1, 'msg' => '资料保存成功!');
     } else {
         $data = array('success' => 0, 'msg' => '没有查到您的查关资料');
     }
     //判断是否参与过
     $this->json_encode($data);
 }
Esempio n. 4
0
function mc_require($uid, $fields, $pre = '')
{
    global $_W, $_GPC;
    if (empty($fields) || !is_array($fields)) {
        return false;
    }
    $flipfields = array_flip($fields);
    if (in_array('birth', $fields) || in_array('birthyear', $fields) || in_array('birthmonth', $fields) || in_array('birthday', $fields)) {
        unset($flipfields['birthyear'], $flipfields['birthmonth'], $flipfields['birthday'], $flipfields['birth']);
        $flipfields['birthyear'] = 'birthyear';
        $flipfields['birthmonth'] = 'birthmonth';
        $flipfields['birthday'] = 'birthday';
    }
    if (in_array('reside', $fields) || in_array('resideprovince', $fields) || in_array('residecity', $fields) || in_array('residedist', $fields)) {
        unset($flipfields['residedist'], $flipfields['resideprovince'], $flipfields['residecity'], $flipfields['reside']);
        $flipfields['resideprovince'] = 'resideprovince';
        $flipfields['residecity'] = 'residecity';
        $flipfields['residedist'] = 'residedist';
    }
    $fields = array_keys($flipfields);
    if (!in_array('uniacid', $fields)) {
        $fields[] = 'uniacid';
    }
    if (!empty($pre)) {
        $pre .= '<br/>';
    }
    if (empty($uid)) {
        foreach ($fields as $field) {
            $profile[$field] = '';
        }
        $uniacid = $_W['uniacid'];
    } else {
        $profile = mc_fetch($uid, $fields);
        $uniacid = $profile['uniacid'];
    }
    $sql = 'SELECT `f`.`field`, `f`.`id` AS `fid`, `mf`.* FROM ' . tablename('profile_fields') . " AS `f` LEFT JOIN " . tablename('mc_member_fields') . " AS `mf` ON `f`.`id` = `mf`.`fieldid` WHERE `uniacid` = :uniacid ORDER BY\r\n\t\t\t`displayorder` DESC";
    $system_fields = pdo_fetchall($sql, array(':uniacid' => $_W['uniacid']), 'field');
    if (empty($system_fields)) {
        $sql = 'SELECT `id`, `field`, `title` FROM ' . tablename('profile_fields');
        $system_fields = pdo_fetchall($sql, array(), 'field');
    }
    $titles = array();
    foreach ($system_fields as $field) {
        $titles[$field['field']] = $field['title'];
    }
    $message = '';
    $ks = array();
    foreach ($profile as $k => $v) {
        if (empty($v)) {
            $ks[] = $k;
            $message .= $system_fields[$k]['title'] . ', ';
        }
    }
    if (!empty($message)) {
        $title = '完善资料';
        if (checksubmit('submit')) {
            if (in_array('resideprovince', $fields)) {
                $_GPC['resideprovince'] = $_GPC['reside']['province'];
                $_GPC['residecity'] = $_GPC['reside']['city'];
                $_GPC['residedist'] = $_GPC['reside']['district'];
            }
            if (in_array('birthyear', $fields)) {
                $_GPC['birthyear'] = $_GPC['birth']['year'];
                $_GPC['birthmonth'] = $_GPC['birth']['month'];
                $_GPC['birthday'] = $_GPC['birth']['day'];
            }
            $record = array_elements($fields, $_GPC);
            if (isset($record['uniacid'])) {
                unset($record['uniacid']);
            }
            foreach ($record as $field => $value) {
                if ($field == 'gender') {
                    continue;
                }
                if (empty($value)) {
                    message('请填写完整所有资料.', referer(), 'error');
                }
            }
            if (empty($record['nickname']) && !empty($_W['fans']['nickname'])) {
                $record['nickname'] = $_W['fans']['nickname'];
            }
            if (empty($record['avatar']) && !empty($_W['fans']['tag']['avatar'])) {
                $record['avatar'] = $_W['fans']['tag']['avatar'];
            }
            $condition = " AND uid != {$uid} ";
            if (in_array('email', $fields)) {
                $emailexists = pdo_fetchcolumn("SELECT email FROM " . tablename('mc_members') . " WHERE uniacid = :uniacid AND email = :email " . $condition, array(':uniacid' => $_W['uniacid'], ':email' => trim($record['email'])));
                if (!empty($emailexists)) {
                    message('抱歉,您填写的手机号已经被使用,请更新。', 'refresh', 'error');
                }
            }
            if (in_array('mobile', $fields)) {
                $mobilexists = pdo_fetchcolumn("SELECT mobile FROM " . tablename('mc_members') . " WHERE uniacid = :uniacid AND mobile = :mobile " . $condition, array(':uniacid' => $_W['uniacid'], ':mobile' => trim($record['mobile'])));
                if (!empty($mobilexists)) {
                    message('抱歉,您填写的手机号已经被使用,请更新。', 'refresh', 'error');
                }
            }
            $insertuid = mc_update($uid, $record);
            if (empty($uid)) {
                pdo_update('mc_oauth_fans', array('uid' => $insertuid), array('oauth_openid' => $_W['openid']));
                pdo_update('mc_mapping_fans', array('uid' => $insertuid), array('openid' => $_W['openid']));
            }
            message('资料完善成功.', 'refresh');
        }
        load()->func('tpl');
        load()->model('activity');
        $filter = array();
        $filter['status'] = 1;
        $coupons = activity_coupon_owned($_W['member']['uid'], $filter);
        $tokens = activity_token_owned($_W['member']['uid'], $filter);
        $setting = uni_setting($_W['uniacid'], array('creditnames', 'creditbehaviors', 'uc'));
        $behavior = $setting['creditbehaviors'];
        $creditnames = $setting['creditnames'];
        $credits = mc_credit_fetch($_W['member']['uid'], '*');
        include template('mc/require', TEMPLATE_INCLUDEPATH);
        exit;
    }
    return $profile;
}
Esempio n. 5
0
    if (empty($profile['email']) || !empty($profile['email']) && substr($profile['email'], -6) == 'we7.cc' && strlen($profile['email']) == 39) {
        $profile['email'] = '';
        $profile['email_effective'] = 1;
    }
}
$sql = 'SELECT `mf`.*, `pf`.`field` FROM ' . tablename('mc_member_fields') . ' AS `mf` JOIN ' . tablename('profile_fields') . " AS `pf`\r\n\t\tON `mf`.`fieldid` = `pf`.`id` WHERE `uniacid` = :uniacid AND `mf`.`available` = :available";
$params = array(':uniacid' => $_W['uniacid'], ':available' => '1');
$mcFields = pdo_fetchall($sql, $params, 'field');
if (checksubmit('submit')) {
    if (!empty($_GPC)) {
        $_GPC['createtime'] = TIMESTAMP;
        foreach ($_GPC as $field => $value) {
            if (!isset($value) || in_array($field, array('uid', 'act', 'name', 'token', 'submit', 'session'))) {
                unset($_GPC[$field]);
                continue;
            }
        }
        if (empty($_GPC['email']) && $profile['email_effective'] == 1) {
            unset($_GPC['email']);
        }
        $_GPC['birthyear'] = $_GPC['birth']['year'];
        $_GPC['birthmonth'] = $_GPC['birth']['month'];
        $_GPC['birthday'] = $_GPC['birth']['day'];
        $_GPC['resideprovince'] = $_GPC['reside']['province'];
        $_GPC['residecity'] = $_GPC['reside']['city'];
        $_GPC['residedist'] = $_GPC['reside']['district'];
        mc_update($_W['member']['uid'], $_GPC);
    }
    message('更新资料成功!', referer(), 'success');
}
template('mc/profile');
Esempio n. 6
0
<?php

global $_GPC, $_W;
checkauth();
$rid = intval($_GPC['rid']);
$uid = $_W['member']['uid'];
$realname = $_POST['realname'];
$mobile = $_POST['mobile'];
if (!empty($realname) && !empty($mobile)) {
    $info = array('realname' => $realname, 'mobile' => $mobile);
    mc_update($uid, $info);
    $status = 1;
    $url = $this->createMobileUrl('index', array('rid' => $rid));
    $tip = '注册成功';
} else {
    $status = 0;
    $tip = '注册失败';
}
$data = array('msg' => $tip, 'status' => $status, 'url' => $url);
$msg = json_encode($data);
//print_r($_POST['realname']);
die($msg);
Esempio n. 7
0
                $cardsn = str_replace($row, random(strlen($row), 1), $cardsn);
            }
        }
        preg_match('/(\\#+)/', $_GPC['format'], $matchs);
        $length = strlen($matchs[1]);
        $pos = strpos($_GPC['format'], '#');
        $cardsn = str_replace($matchs[1], str_pad($_GPC['snpos']++, $length - strlen($number), '0', STR_PAD_LEFT), $cardsn);
        pdo_update('mc_card', array('snpos' => $_GPC['snpos']), array('uniacid' => $_W['uniacid'], 'id' => $_GPC['cardid']));
        $record = array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'], 'cid' => $_GPC['cardid'], 'cardsn' => $cardsn, 'status' => '1', 'createtime' => TIMESTAMP);
        $check = mc_check($data);
        if (is_error($check)) {
            message($check['message'], '', 'error');
        }
        if (pdo_insert('mc_card_members', $record)) {
            if (!empty($data)) {
                mc_update($_W['member']['uid'], $data);
            }
            message('领取会员卡成功.', url('mc/bond/mycard'), 'success');
        } else {
            message('领取会员卡失败.', referer(), 'error');
        }
    }
}
if ($do == 'mycard') {
    $mcard = pdo_fetch('SELECT * FROM ' . tablename('mc_card_members') . ' WHERE uniacid = :uniacid AND uid = :uid', array(':uniacid' => $_W['uniacid'], ':uid' => $_W['member']['uid']));
    if (empty($mcard)) {
        header('Location:' . url('mc/bond/card'));
    }
    if (!empty($mcard['status'])) {
        $setting = pdo_fetch('SELECT * FROM ' . tablename('mc_card') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid']));
        if (!empty($setting)) {
Esempio n. 8
0
 public function doMobileResearch()
 {
     global $_W, $_GPC;
     $reid = intval($_GPC['id']);
     $sql = 'SELECT * FROM ' . tablename('research') . ' WHERE `weid`=:weid AND `reid`=:reid';
     $params = array();
     $params[':weid'] = $_W['uniacid'];
     $params[':reid'] = $reid;
     $activity = pdo_fetch($sql, $params);
     if (empty($_W['fans']['openid'])) {
         message('请先关注公众号再来参加活动吧!');
     }
     if ($activity['status'] != '1') {
         message('当前预约活动已经停止.');
     }
     if (!$activity) {
         message('非法访问.');
     }
     if ($activity['starttime'] > TIMESTAMP) {
         message('当前预约活动还未开始!');
     }
     if ($activity['endtime'] < TIMESTAMP) {
         message('当前预约活动已经结束!');
     }
     $title = $activity['title'];
     $sql = 'SELECT * FROM ' . tablename('research_fields') . ' WHERE `reid` = :reid ORDER BY `displayorder` DESC, `refid`';
     $params = array();
     $params[':reid'] = $reid;
     $ds = pdo_fetchall($sql, $params);
     if (!$ds) {
         message('非法访问.');
     }
     $initRange = $initCalendar = false;
     $binds = array();
     foreach ($ds as &$r) {
         if ($r['type'] == 'range') {
             $initRange = true;
         }
         if ($r['type'] == 'calendar') {
             $initCalendar = true;
         }
         if ($r['value']) {
             $r['options'] = explode(',', $r['value']);
         }
         if ($r['bind']) {
             $binds[$r['type']] = $r['bind'];
         }
         if ($r['type'] == 'reside') {
             $reside = $r;
         }
     }
     if (checksubmit('submit')) {
         $sql = 'SELECT COUNT(*) FROM ' . tablename('research_rows') . ' WHERE `reid` = :reid AND `openid` = :openid';
         $params = array(':reid' => $reid, ':openid' => $_W['fans']['from_user']);
         $pretotal = pdo_fetchcolumn($sql, $params);
         if ($pretotal >= $activity['pretotal']) {
             message('抱歉,每人只能预约' . $activity['pretotal'] . "次!", referer(), 'error');
         }
         $sql = 'SELECT `rerid` FROM ' . tablename('research_rows') . ' WHERE `reid` = :reid GROUP BY `openid`';
         unset($params[':openid']);
         $allTotal = pdo_fetchall($sql, $params);
         if (count($allTotal) >= $activity['alltotal']) {
             pdo_update('research', array('endtime' => TIMESTAMP), array('reid' => $reid));
             message('当前预约活动已经结束!');
         }
         $row = array();
         $row['reid'] = $reid;
         $row['openid'] = $_W['fans']['from_user'];
         $row['createtime'] = TIMESTAMP;
         $datas = $fields = $update = array();
         foreach ($ds as $value) {
             $fields[$value['refid']] = $value;
         }
         foreach ($_GPC as $key => $value) {
             if (strexists($key, 'field_')) {
                 $bindFiled = substr(strrchr($key, '_'), 1);
                 if (!empty($bindFiled)) {
                     $update[$bindFiled] = $value;
                 }
                 $refid = intval(str_replace('field_', '', $key));
                 $field = $fields[$refid];
                 if ($refid && $field) {
                     $entry = array();
                     $entry['reid'] = $reid;
                     $entry['rerid'] = 0;
                     $entry['refid'] = $refid;
                     if (in_array($field['type'], array('number', 'text', 'calendar', 'email', 'textarea', 'radio', 'range', 'select', 'image'))) {
                         $entry['data'] = strval($value);
                     }
                     if (in_array($field['type'], array('checkbox'))) {
                         if (!is_array($value)) {
                             continue;
                         }
                         $entry['data'] = implode(';', $value);
                     }
                     $datas[] = $entry;
                 }
             }
         }
         if ($_FILES) {
             load()->func('file');
             foreach ($_FILES as $key => $file) {
                 if (strexists($key, 'field_')) {
                     $refid = intval(str_replace('field_', '', $key));
                     $field = $fields[$refid];
                     if ($refid && $field && $file['name'] && $field['type'] == 'image') {
                         $entry = array();
                         $entry['reid'] = $reid;
                         $entry['rerid'] = 0;
                         $entry['refid'] = $refid;
                         $ret = file_upload($file);
                         if (!$ret['success']) {
                             message('上传图片失败, 请稍后重试.');
                         }
                         $entry['data'] = trim($ret['path']);
                         $datas[] = $entry;
                     }
                 }
             }
         }
         // 兼容会员居住地字段
         if (!empty($_GPC['reside'])) {
             if (in_array('reside', $binds)) {
                 $update['resideprovince'] = $_GPC['reside']['province'];
                 $update['residecity'] = $_GPC['reside']['city'];
                 $update['residedist'] = $_GPC['reside']['district'];
             }
             foreach ($_GPC['reside'] as $key => $value) {
                 $resideData = array('reid' => $reside['reid']);
                 $resideData['rerid'] = 0;
                 $resideData['refid'] = $reside['refid'];
                 $resideData['data'] = $value;
                 $datas[] = $resideData;
             }
         }
         // 更新关联会员资料
         if (!empty($update)) {
             load()->model('mc');
             mc_update($_W['member']['uid'], $update);
         }
         if (empty($datas)) {
             message('非法访问.', '', 'error');
         }
         if (pdo_insert('research_rows', $row) != 1) {
             message('保存失败.');
         }
         $rerid = pdo_insertid();
         if (empty($rerid)) {
             message('保存失败.');
         }
         foreach ($datas as &$r) {
             $r['rerid'] = $rerid;
             pdo_insert('research_data', $r);
         }
         if (empty($activity['starttime'])) {
             $record = array();
             $record['starttime'] = TIMESTAMP;
             pdo_update('research', $record, array('reid' => $reid));
         }
         if (!empty($datas)) {
             $image = $body = '';
             foreach ($datas as $row) {
                 if (substr($row['data'], 0, 6) != 'images') {
                     $body .= '<h4>' . $fields[$row['refid']]['title'] . ':' . $row['data'] . '</h4>';
                 } else {
                     $image .= '<p>' . $fields[$row['refid']]['title'] . ': <img src="' . tomedia($row['data']) . '" /></p>';
                 }
             }
             // 发送邮件提醒
             if (!empty($activity['noticeemail'])) {
                 load()->func('communication');
                 ihttp_email($activity['noticeemail'], $activity['title'] . '的预约提醒', $image . $body);
             }
             // 发送短信提醒
             if (!empty($activity['mobile'])) {
                 load()->model('cloud');
                 cloud_prepare();
                 $body = '项目' . $activity['title'] . '于' . date('Y-m-d H:i') . '有了新的预约信息,请到后台查看具体内容.' . random(3);
                 cloud_sms_send($activity['mobile'], $body);
             }
         }
         message($activity['information'], 'refresh');
     }
     // 兼容会员居住地字段
     foreach ($binds as $key => $value) {
         if ($value == 'reside') {
             unset($binds[$key]);
             $binds[] = 'resideprovince';
             $binds[] = 'residecity';
             $binds[] = 'residedist';
             break;
         }
     }
     if (!empty($_W['fans']['from_user']) && !empty($binds)) {
         $profile = fans_search($_W['fans']['from_user'], $binds);
         if ($profile['gender']) {
             if ($profile['gender'] == '0') {
                 $profile['gender'] = '保密';
             }
             if ($profile['gender'] == '1') {
                 $profile['gender'] = '男';
             }
             if ($profile['gender'] == '2') {
                 $profile['gender'] = '女';
             }
         }
         foreach ($ds as &$r) {
             if ($profile[$r['bind']]) {
                 $r['default'] = $profile[$r['bind']];
             }
         }
     }
     load()->func('tpl');
     include $this->template('submit');
 }
Esempio n. 9
0
 public function doMobilesettel()
 {
     global $_GPC, $_W;
     $rid = intval($_GPC['rid']);
     $fansID = $_W['member']['uid'];
     $from_user = $_W['fans']['from_user'];
     $fans = pdo_fetch("select id from " . tablename('stonefish_bigwheel_fans') . " where rid = " . $rid . " and fansID=" . $fansID . " and from_user='******'");
     if ($fans == false) {
         $data = array('success' => 0, 'msg' => '保存数据错误!');
     } else {
         //查询规则保存哪些数据
         $updata = array();
         $reply = pdo_fetch("select isfans,isrealname,ismobile,isqq,isemail,isaddress,isgender,istelephone,isidcard,iscompany,isoccupation,isposition from " . tablename('stonefish_bigwheel_reply') . " where rid = :rid", array(':rid' => $rid));
         if ($reply['isrealname']) {
             $updata['realname'] = $_GPC['realname'];
         }
         if ($reply['ismobile']) {
             $updata['mobile'] = $_GPC['mobile'];
         }
         if ($reply['isqq']) {
             $updata['qq'] = $_GPC['qq'];
         }
         if ($reply['isemail']) {
             $updata['email'] = $_GPC['email'];
         }
         if ($reply['isaddress']) {
             $updata['address'] = $_GPC['address'];
         }
         if ($reply['isgender']) {
             $updata['gender'] = $_GPC['gender'];
         }
         if ($reply['istelephone']) {
             $updata['telephone'] = $_GPC['telephone'];
         }
         if ($reply['isidcard']) {
             $updata['idcard'] = $_GPC['idcard'];
         }
         if ($reply['iscompany']) {
             $updata['company'] = $_GPC['company'];
         }
         if ($reply['isoccupation']) {
             $updata['occupation'] = $_GPC['occupation'];
         }
         if ($reply['isposition']) {
             $updata['position'] = $_GPC['position'];
         }
         $temp = pdo_update('stonefish_bigwheel_fans', $updata, array('rid' => $rid, 'fansID' => $fansID));
         if ($temp === false) {
             $data = array('success' => 0, 'msg' => '保存数据错误!');
         } else {
             if ($reply['isfans']) {
                 load()->model('mc');
                 mc_update($fansID, $updata);
             }
             $data = array('success' => 1, 'msg' => '成功提交数据');
         }
     }
     echo json_encode($data);
 }
Esempio n. 10
0
 public function doMobileApply()
 {
     //这个操作被定义用来呈现 微站个人中心导航
     global $_W, $_GPC;
     load()->model('mc');
     $openid = $_W['fans']['from_user'];
     $fans = pdo_fetch("SELECT fanid,uid FROM " . tablename('mc_mapping_fans') . " WHERE `openid`='{$openid}' LIMIT 1");
     $uid = '0';
     if ($fans['uid'] != '0') {
         $uid = $fans['uid'];
     } else {
         $uid = mc_update($uid, array('email' => md5($_W['openid']) . '@012wz.com'));
         if (!empty($fans['fanid']) && !empty($uid)) {
             pdo_update('mc_mapping_fans', array('uid' => $uid), array('fanid' => $fans['fanid']));
         }
     }
     $minnum = isset($this->module['config']['out_limit']) ? $this->module['config']['out_limit'] : '100.00';
     $credit_type = isset($this->module['config']['credit_type']) ? $this->module['config']['credit_type'] : 'credit1';
     $yue = mc_credit_fetch($uid);
     $ff_log = pdo_fetch("SELECT * FROM " . tablename('hx_subscribe_data') . " WHERE `uniacid`='{$_W['uniacid']}' AND `uid`='{$uid}'");
     $profile = mc_fetch($uid);
     if (checksubmit('submit')) {
         if ($_GPC['type'] == '1' && empty($_GPC['alipay'])) {
             message('参数错误,请返回修改');
         }
         if ($_GPC['type'] == '2' && empty($_GPC['cardid'])) {
             message('参数错误,请返回修改');
         }
         $remark['1']['user'] = $_GPC['realname'];
         $remark['1']['time'] = time();
         $remark['1']['reason'] = '';
         $data = array('uniacid' => $_W['uniacid'], 'uid' => $uid, 'realname' => $_GPC['realname'], 'qq' => $_GPC['qq'], 'type' => intval($_GPC['type']), 'alipay' => $_GPC['alipay'], 'cardid' => $_GPC['cardid'], 'cardfrom' => $_GPC['cardfrom'], 'cardname' => $_GPC['cardname'], 'credit2' => $_GPC['credit2'], 'mobile' => $_GPC['mobile'], 'createtime' => time(), 'status' => '1', 'remark' => iserializer($remark));
         pdo_insert('hx_subscribe_apply', $data);
         mc_credit_update($uid, $credit_type, '-' . $_GPC['mobile'], array('1', '申请提现'));
         message('提现成功', $this->createMobileUrl('myapply'), 'success');
     }
     include $this->template('apply');
 }
Esempio n. 11
0
 public function doMobileSurvey()
 {
     checkauth();
     global $_W, $_GPC;
     $sid = intval($_GPC['id']);
     $sql = 'SELECT * FROM ' . tablename('survey') . ' WHERE `weid`=:weid AND `sid`=:sid';
     $params = array();
     $params[':weid'] = $_W['uniacid'];
     $params[':sid'] = $sid;
     $activity = pdo_fetch($sql, $params);
     $activity['content'] = htmlspecialchars_decode($activity['content']);
     $title = $activity['title'];
     //分享处理
     $_share_img = $_W['attachurl'] . $activity['thumb'];
     if ($activity['status'] != '1') {
         message('当前调研活动已经停止.');
     }
     if (!$activity) {
         message('非法访问.');
     }
     if ($activity['starttime'] > TIMESTAMP) {
         message('当前调研活动还未开始!');
     }
     if ($activity['endtime'] < TIMESTAMP) {
         message('当前调研活动已经结束!');
     }
     $sql = 'SELECT * FROM ' . tablename('survey_fields') . ' WHERE `sid`=:sid ORDER BY `displayorder` ASC,sfid ASC';
     $params = array();
     $params[':sid'] = $sid;
     $ds = pdo_fetchall($sql, $params);
     if (!$ds) {
         message('非法访问.');
     }
     $pertotal = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('survey_rows') . " WHERE sid = :sid AND openid = :openid", array(':sid' => $sid, ':openid' => $_W['fans']['from_user']));
     if ($pertotal >= $activity['pertotal']) {
         $pererror = 1;
     }
     $user = mc_fetch($_W['fans']['from_user'], array('realname', 'mobile'));
     if (empty($user['realname']) || empty($user['mobile'])) {
         $userinfo = 0;
     }
     if (checksubmit()) {
         if ($pertotal >= $activity['pertotal']) {
             message('抱歉!每人只能提交' . $activity['pertotal'] . "次!", referer(), 'error');
         }
         //更新粉丝的手机号和姓名
         if ($userinfo == '0') {
             mc_update($_W['fans']['from_user'], array('realname' => trim($_GPC['username']), 'mobile' => trim($_GPC['telephone'])));
         }
         $row = array();
         $row['sid'] = $sid;
         $row['openid'] = $_W['fans']['from_user'];
         $row['suggest'] = trim($_GPC['suggest']);
         $row['createtime'] = TIMESTAMP;
         $datas = array();
         $fields = array();
         foreach ($ds as $r) {
             $fields[$r['sfid']] = $r;
         }
         foreach ($_GPC as $key => $value) {
             if (strexists($key, 'field_')) {
                 $sfid = intval(str_replace('field_', '', $key));
                 $field = $fields[$sfid];
                 if ($sfid && $field) {
                     if (in_array($field['type'], array('textarea', 'radio'))) {
                         $entry = array();
                         $entry['sid'] = $sid;
                         $entry['srid'] = 0;
                         $entry['sfid'] = $sfid;
                         $entry['createtime'] = TIMESTAMP;
                         $entry['data'] = strval($value);
                         $datas[] = $entry;
                     }
                     if (in_array($field['type'], array('checkbox'))) {
                         $value = explode("||", $value);
                         if (!is_array($value)) {
                             continue;
                         }
                         foreach ($value as $k => $v) {
                             $entry['sid'] = $sid;
                             $entry['srid'] = 0;
                             $entry['sfid'] = $sfid;
                             $entry['createtime'] = TIMESTAMP;
                             $entry['data'] = strval($v);
                             $datas[] = $entry;
                         }
                     }
                 }
             }
         }
         if (empty($datas)) {
             message('非法访问.', '', 'error');
         }
         if (pdo_insert('survey_rows', $row) != 1) {
             message('保存失败.');
         }
         $srid = pdo_insertid();
         if (empty($srid)) {
             message('保存失败.');
         }
         foreach ($datas as &$r) {
             $r['srid'] = $srid;
             pdo_insert('survey_data', $r);
         }
         if (empty($activity['starttime'])) {
             $record = array();
             $record['starttime'] = TIMESTAMP;
             pdo_update('survey', $record, array('sid' => $sid));
         }
         message($activity['information'], 'refresh');
     }
     foreach ($ds as &$r) {
         if ($r['value']) {
             $r['options'] = explode("\r\n", $r['value']);
         }
     }
     include $this->template('submit');
 }
Esempio n. 12
0
 public function doMobilesettel()
 {
     global $_GPC, $_W;
     $id = intval($_GPC['id']);
     $fansID = $_W['member']['uid'];
     $from_user = $_W['fans']['from_user'];
     $fans = pdo_fetch("SELECT id FROM " . tablename($this->tablefans) . " WHERE rid = " . $id . " and fansID=" . $fansID . " and from_user='******'");
     if ($fans == false) {
         $data = array('success' => 0, 'msg' => '保存数据错误!');
     } else {
         $temp = pdo_update($this->tablefans, array('tel' => $_GPC['tel']), array('rid' => $id, 'fansID' => $fansID));
         if ($temp === false) {
             $data = array('success' => 0, 'msg' => '保存数据错误!');
         } else {
             load()->model('mc');
             mc_update($fansID, array('mobile' => $_GPC['tel']));
             $data = array('success' => 1, 'msg' => '成功提交数据');
         }
     }
     echo json_encode($data);
 }
Esempio n. 13
0
 public function doMobileInfo()
 {
     global $_W, $_GPC;
     $openid = $this->getOpenid();
     $rule = pdo_fetch('select * from ' . tablename($this->modulename . "_rule") . " where rid='{$_GPC['rid']}'");
     $player = pdo_fetch('select * from ' . tablename($this->modulename . '_player') . " where rid='{$rule['rid']}' and openid='{$openid}'");
     if ($_GPC['op'] == 'user') {
         $nl = trim($_GPC['nl']);
         $nz = trim($_GPC['zn']);
         if (empty($nl)) {
             $nl = '牛郎';
         }
         if (empty($nz)) {
             $nz = '织女';
         }
         $data = array('myname' => $nl, 'hname' => $nz);
         if (pdo_update($this->modulename . '_player', $data, array('id' => $player['id'])) === false) {
             die("0");
         }
         die("1");
     } else {
         if (!empty($_GPC['mobile']) && !preg_match("/^1[34578]\\d{9}\$/", $_GPC['mobile'])) {
             message('请填写正确的手机号码');
         }
         if (empty($player)) {
             $player = $this->createPlayer($rule);
         }
         $data = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'qq' => $_GPC['qq'], 'email' => $_GPC['email'], 'address' => $_GPC['address']);
         if (pdo_update($this->modulename . '_player', $data, array('id' => $player['id'])) === false) {
             message('保存个人信息失败!');
         }
         if ($rule['isfans']) {
             //更新信息到系统会员表
             load()->model('mc');
             $mc = array();
             if (!empty($data['realname'])) {
                 $mc['realname'] = $data['realname'];
             }
             if (!empty($data['mobile'])) {
                 $mc['mobile'] = $data['mobile'];
             }
             if (!empty($data['qq'])) {
                 $mc['qq'] = $data['qq'];
             }
             if (!empty($data['email'])) {
                 $mc['email'] = $data['email'];
             }
             if (!empty($data['address'])) {
                 $mc['address'] = $data['address'];
             }
             mc_update($player['openid'], $mc);
         }
         message('保存个人信息成功!', $this->createMobileUrl('index', array('rid' => $rule['rid'])));
     }
 }
Esempio n. 14
0
<?php

$award_id = intval($_GPC['award_id']);
if (!empty($_GPC['award_id'])) {
    $follow = pdo_fetch("select uid from " . tablename('mc_mapping_fans') . " uniacid = " . $weid . " and openid = '" . $_W['openid'] . "'");
    $fans = mc_search($follow['uid'], array('credit1'));
    $award_info = pdo_fetch("SELECT * FROM " . tablename('weilive_list') . " WHERE award_id = {$award_id} AND weid = '{$weid}'");
    if ($fans['credit1'] >= $award_info['credit_cost'] && $award_info['amount'] > 0) {
        $data = array('amount' => $award_info['amount'] - 1);
        pdo_update('weilive_list', $data, array('weid' => $weid, 'award_id' => $award_id));
        $data = array('weid' => $weid, 'from_user' => $_W['fans']['from_user'], 'award_id' => $award_id, 'createtime' => TIMESTAMP);
        pdo_insert('weilive_request', $data);
        $data = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'credit1' => $fans['credit1'] - $award_info['credit_cost'], 'residedist' => $_GPC['residedist']);
        mc_update($follow['uid'], $data);
        // navigate to user profile page
        message('积分兑换成功!', create_url('mobile/module/mycredit', array('weid' => $weid, 'name' => 'hcweilive', 'do' => 'mycredit', 'op' => 'display')), 'success');
    } else {
        message('积分不足或商品已经兑空,请重新选择商品!<br>当前商品所需积分:' . $award_info['credit_cost'] . '<br>您的积分:' . $fans['credit1'] . '. 商品剩余数量:' . $award_info['amount'] . '<br><br>小提示:<br>每日签到,在线订票,宾馆预订可以赚取积分', create_url('mobile/module/award', array('weid' => $weid, 'name' => 'hcweilive')), 'error');
    }
} else {
    message('请选择要兑换的商品!', create_url('mobile/module/award', array('weid' => $weid, 'name' => 'hcweilive')), 'error');
}
Esempio n. 15
0
function Mobile_UpdateMember($theThis, $uniacid, $uid, $data)
{
    global $_W, $_GPC;
    $rd = new ReturnData("");
    load()->model('mc');
    if (!mc_update($uid, $data)) {
        $rd->setMsg("更新个人信息失败");
        $rd->setCode(200);
    }
    return $rd;
}
Esempio n. 16
0
                $ret['status'] = 2;
                $ret['money'] = number_format($moneycount, 2);
                $ret['moneycount'] = number_format($set['become_moneycount'], 2);
            }
        }
    }
    if ($_W['ispost']) {
        if ($member['isagent'] == 1 && $member['status'] == 1) {
            show_json(0, '您已经是' . $set['texts']['become'] . ',无需再次申请!');
        }
        if ($ret['status'] == 1 || $ret['status'] == 2) {
            show_json(0, '您消费的还不够哦,无法申请' . $set['texts']['become'] . '!');
        } else {
            $become_check = intval($set['become_check']);
            $ret['status'] = $become_check;
            $data = array('isagent' => 1, 'agentid' => $mid, 'status' => $become_check, 'realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'weixin' => $_GPC['weixin'], 'agenttime' => $become_check == 1 ? time() : 0);
            pdo_update('ewei_shop_member', $data, array('id' => $member['id']));
            if ($become_check == 1) {
                $this->model->sendMessage($member['openid'], array('agenttime' => $data['agenttime']), TM_COMMISSION_BECOME);
            }
            if (!empty($member['uid'])) {
                load()->model('mc');
                mc_update($member['uid'], array('realname' => $data['realname'], 'mobile' => $data['mobile']));
                show_json(1, $ret);
            }
        }
    }
    show_json(1, $ret);
}
$this->setHeader();
include $this->template('register');
Esempio n. 17
0
 public function doMobileprofile()
 {
     global $_W, $_GPC;
     $uniacid = $_W['uniacid'];
     $title = '完善资料';
     $op = $_GPC['op'] ? $_GPC['op'] : 'display';
     $from_user = $this->getFromUser();
     ///28.查询用户的唯一身份ID。$state:参数0默认,参数1微信拉取用户详细信息。
     $profile = $this->getProfile();
     ///34.获取wwx_fxxt_member表会员信。
     $signPackage = $this->getSignPackage();
     ///35.转发分享信息、未关注信息、COOKIE等等设置。
     $this->OverallSituation($from_user, $profile);
     ///1.全局统一调用
     $carttotal = $this->getCartTotal();
     ///38.查询购物车内的商品数量。
     if (empty($_W['openid'])) {
         message('请先登录', $this->createMobileUrl('login'), 'error');
         exit;
     }
     load()->model('app');
     load()->model('mc');
     load()->func('tpl');
     if (!empty($_W['openid'])) {
         $map_fans = pdo_fetchcolumn('SELECT tag FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid = :uniacid AND openid = :openid', array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
         if (!empty($map_fans)) {
             if (is_base64($map_fans)) {
                 $map_fans = base64_decode($map_fans);
             }
             if (is_serialized($map_fans)) {
                 $map_fans = iunserializer($map_fans);
             }
             if (!empty($map_fans) && is_array($map_fans)) {
                 empty($profile['nickname']) ? $data['nickname'] = $map_fans['nickname'] : '';
                 empty($profile['gender']) ? $data['gender'] = $map_fans['sex'] : '';
                 empty($profile['residecity']) ? $data['residecity'] = $map_fans['city'] ? $map_fans['city'] . '市' : '' : '';
                 empty($profile['resideprovince']) ? $data['resideprovince'] = $map_fans['province'] ? $map_fans['province'] . '省' : '' : '';
                 empty($profile['nationality']) ? $data['nationality'] = $map_fans['country'] : '';
                 empty($profile['avatar']) ? $data['avatar'] = rtrim($map_fans['headimgurl'], '0') . 132 : '';
                 if (!empty($data)) {
                     mc_update($_W['member']['uid'], $data);
                 }
             }
         }
     }
     if (checksubmit('submit')) {
         if (empty($_GPC['avatar'])) {
             message('头像不能为空!', '', 'error');
         }
         if (empty($_GPC['nickname'])) {
             message('昵称不能为空!', '', 'error');
         }
         if (empty($_GPC['realname'])) {
             message('真实姓名不能为空!', '', 'error');
         }
         $data = array('realname' => $_GPC['realname'], 'nickname' => $_GPC['nickname'], 'bankcard' => $_GPC['bankcard'], 'banktype' => $_GPC['banktype'], 'alipay' => $_GPC['alipay'], 'wxhao' => $_GPC['wxhao']);
         pdo_update('wwx_fxxt_member', $data, array('from_user' => $from_user));
         mc_update($_W['member']['uid'], array('nickname' => $_GPC['nickname'], 'realname' => $_GPC['realname'], 'avatar' => $_GPC['avatar']));
         pdo_update('mc_mapping_fans', array('nickname' => $_GPC['nickname']), array('openid' => $from_user));
         message('更新资料成功!', referer(), 'success');
     }
     include $this->template('profile');
 }
Esempio n. 18
0
<?php

if (!defined('IN_IA')) {
    exit('Access Denied');
}
global $_W, $_GPC;
$openid = m('user')->getOpenid();
$member = m('member')->getInfo($openid);
if ($_W['isajax']) {
    if ($_W['ispost']) {
        $memberdata = $_GPC['memberdata'];
        pdo_update('ewei_shop_member', $memberdata, array('openid' => $openid, 'uniacid' => $_W['uniacid']));
        if (!empty($member['uid'])) {
            $mcdata = $_GPC['mcdata'];
            load()->model('mc');
            mc_update($member['uid'], $mcdata);
        }
        show_json(1);
    }
    show_json(1, array('member' => $member));
}
include $this->template('member/info');
Esempio n. 19
0
 public function doMobileEditfans()
 {
     global $_GPC, $_W;
     $rid = intval($_GPC['rid']);
     $from_user = authcode(base64_decode($_GPC['from_user']), 'DECODE');
     $uniacid = $_W['uniacid'];
     $reply = pdo_fetch("select id,fansnum FROM " . tablename('stonefish_bigwheel_reply') . " where rid = :rid ORDER BY `id` DESC", array(':rid' => $rid));
     $exchange = pdo_fetch("select * FROM " . tablename("stonefish_bigwheel_exchange") . " where rid = :rid", array(':rid' => $rid));
     //判断是否参与过
     $fans = pdo_fetch("select * from " . tablename('stonefish_bigwheel_fans') . " where rid = :rid and uniacid = :uniacid and from_user= :from_user", array(':rid' => $rid, ':uniacid' => $uniacid, ':from_user' => $from_user));
     $uid = pdo_fetchcolumn("select uid FROM " . tablename('mc_mapping_fans') . " where openid=:openid and uniacid=:uniacid", array(":openid" => $from_user, ":uniacid" => $uniacid));
     if (empty($fans)) {
         $fansdata = array('rid' => $rid, 'uniacid' => $uniacid, 'from_user' => $from_user, 'avatar' => $_GPC['avatar'], 'nickname' => $_GPC['nickname'], 'todaynum' => 0, 'totalnum' => 0, 'awardnum' => 0, 'createtime' => time());
         pdo_insert('stonefish_bigwheel_fans', $fansdata);
         $fans['id'] = pdo_insertid();
         //增加人数,和浏览次数
         pdo_update('stonefish_bigwheel_reply', array('fansnum' => $reply['fansnum'] + 1), array('id' => $reply['id']));
     }
     //读取保存提交的资料
     if ($fans['id']) {
         $ziduan = array('realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position');
         foreach ($ziduan as $ziduans) {
             if ($exchange['is' . $ziduans]) {
                 pdo_update('stonefish_bigwheel_fans', array($ziduans => $_GPC[$ziduans]), array('id' => $fans['id']));
                 //是否同步保存FANS表
                 if ($exchange['isfans'] && $uid) {
                     if ($ziduans == 'email') {
                         mc_update($uid, array('email' => $_GPC['email']));
                     } else {
                         mc_update($uid, array($ziduans => $_GPC[$ziduans], 'email' => $profile['email']));
                     }
                 }
                 //是否同步保存FANS表
             }
         }
     }
     //读取保存提交的资料
     $data = array('success' => 1, 'msg' => '资料保存成功!');
     //判断是否参与过
     $this->json_encode($data);
 }
Esempio n. 20
0
 public function doMobileUserinfo()
 {
     global $_GPC, $_W;
     $weid = $_W['weid'];
     if ($_GPC['code'] == "authdeny") {
         $url = $_W['siteroot'] . "app/" . $this->createMobileUrl('index', array());
         header("location:{$url}");
         exit('authdeny');
     }
     load()->func('communication');
     if (isset($_GPC['code'])) {
         $appid = $_W['account']['key'];
         $secret = $_W['account']['secret'];
         $serverapp = $_W['account']['level'];
         if ($serverapp != 4) {
             $cfg = $this->module['config'];
             $appid = $cfg['appid'];
             $secret = $cfg['secret'];
         }
         $state = $_GPC['state'];
         $rid = $_GPC['rid'];
         $code = $_GPC['code'];
         $oauth2_code = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $appid . "&secret=" . $secret . "&code=" . $code . "&grant_type=authorization_code";
         $content = ihttp_get($oauth2_code);
         $token = @json_decode($content['content'], true);
         if (empty($token) || !is_array($token) || empty($token['access_token']) || empty($token['openid'])) {
             echo '<h1>获取微信公众号授权' . $code . '失败[无法取得token以及openid], 请稍后重试! 公众平台返回原始数据为: <br />' . $content['meta'] . '<h1>';
             exit;
         }
         $from_user = $token['openid'];
         //load()->model('mc');
         ///$uid = mc_openid2uid($from_user);
         //$profile = mc_fetch($uid, 'follow');
         $fans = pdo_fetch("select follow from " . tablename('mc_mapping_fans') . " where openid=:openid and uniacid=:uniacid limit 1", array(':openid' => $from_user, ':uniacid' => $_W['uniacid']));
         if (!empty($fans) && !empty($fans['follow'])) {
             $state = 1;
         } else {
             $url = $_W['siteroot'] . "app/" . $this->createMobileUrl('userinfo', array());
             $oauth2_code = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $appid . "&redirect_uri=" . urlencode($url) . "&response_type=code&scope=snsapi_userinfo&state=0#wechat_redirect";
             header("location:{$oauth2_code}");
         }
         if ($state == 1) {
             $oauth2_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret . "";
             $content = ihttp_get($oauth2_url);
             $token_all = @json_decode($content['content'], true);
             if (empty($token_all) || !is_array($token_all) || empty($token_all['access_token'])) {
                 echo '<h1>获取微信公众号授权失败[无法取得access_token], 请稍后重试! 公众平台返回原始数据为: <br />' . $content['meta'] . '<h1>';
                 exit;
             }
             $access_token = $token_all['access_token'];
             $oauth2_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $from_user . "&lang=zh_CN";
         } else {
             $access_token = $token['access_token'];
             $oauth2_url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $access_token . "&openid=" . $from_user . "&lang=zh_CN";
         }
         $content = ihttp_get($oauth2_url);
         $info = @json_decode($content['content'], true);
         if (empty($info) || !is_array($info) || empty($info['openid']) || empty($info['nickname'])) {
             echo '<h1>获取微信公众号授权失败[无法取得info], 请稍后重试!<h1>';
             exit;
         }
         if (!empty($_W['fans']['from_user'])) {
             load()->model('mc');
             $uid = mc_openid2uid($_W['fans']['from_user']);
             mc_update($uid, array('nickname' => $info['nickname'], 'realname' => $info['nickname'], 'avatar' => $info['headimgurl']));
         }
         setcookie("wdl_hchighguess_fromuser" . $_W['weid'], $info['openid'], time() + 3600 * 240);
         $url = $this->createMobileUrl('index');
         header("location:{$url}");
         exit;
     } else {
         echo '<h1>网页授权域名设置出错!</h1>';
         exit;
     }
 }
Esempio n. 21
0
                 if ($mobilexists) {
                     unset($_GPC['mobile']);
                 }
             }
             $_GPC['uniacid'] = $_W['uniacid'];
             $_GPC['createtime'] = TIMESTAMP;
             pdo_insert('mc_members', $_GPC);
             $uid = pdo_insertid();
             pdo_update('mc_mapping_fans', array('uid' => $uid), array('fanid' => $fanid, 'uniacid' => $_W['uniacid']));
             message('更新资料成功!', url('mc/member/post', array('uid' => $uid)), 'success');
         } else {
             $email_effective = intval($_GPC['email_effective']);
             if ($email_effective == 1 && empty($_GPC['email'])) {
                 unset($_GPC['email']);
             }
             $uid = mc_update($uid, $_GPC);
         }
     }
     message('更新资料成功!', referer(), 'success');
 }
 $groups = mc_groups($_W['uniacid']);
 $profile = pdo_get('mc_members', array('uniacid' => $_W['uniacid'], 'uid' => $uid));
 if (!empty($profile)) {
     if (empty($profile['email']) || !empty($profile['email']) && substr($profile['email'], -6) == '012wz.com' && strlen($profile['email']) == 39) {
         $profile['email_effective'] = 1;
         $profile['email'] = '';
     } else {
         $profile['email_effective'] = 2;
     }
 }
 if (empty($uid)) {
Esempio n. 22
0
 public function saveUserInfo($info)
 {
     if (!isset($info['subscribe']) || $info['subscribe'] != 1) {
         return;
     }
     WeUtility::logging('saveUserInfo', $info);
     $from_user = $info['openid'];
     load()->model('mc');
     $uid = mc_openid2uid($from_user);
     mc_update($uid, array('nickname' => $info['nickname'], 'gender' => $info['sex'], 'nationality' => $info['country'], 'resideprovince' => $info['province'], 'residecity' => $info['city'], 'avatar' => $info['headimgurl']));
 }
Esempio n. 23
0
 public function doMobileget_award()
 {
     global $_GPC, $_W;
     $rid = intval($_GPC['rid']);
     $fansID = $_W['member']['uid'];
     $from_user = $_W['fans']['from_user'];
     $uniacid = $_W['uniacid'];
     $profile = mc_fetch($fansID, array('avatar', 'nickname', 'realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position'));
     if (empty($profile['avatar'])) {
         $profile['avatar'] = '../addons/stonefish_redenvelope/template/images/avatar.jpg';
     }
     if (empty($profile['nickname'])) {
         $profile['nickname'] = $_GPC['realname'];
     }
     $reply = pdo_fetch("SELECT * FROM " . tablename('stonefish_redenvelope_reply') . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid));
     if ($reply == false) {
         $this->message(array("success" => 2, "msg" => '规则出错!...'), "");
     }
     if ($reply['isshow'] != 1) {
         //活动已经暂停,请稍后...
         $this->message(array("success" => 2, "msg" => '活动暂停,请稍后...'), "");
     }
     if ($reply['starttime'] > time()) {
         $this->message(array("success" => 2, "msg" => '活动还没有开始呢,请等待...'), "");
     }
     if ($reply['endtime'] < time()) {
         $this->message(array("success" => 2, "msg" => '活动已经结束了,下次再来吧!'), "");
     }
     if (empty($_W['fans'])) {
         $this->message(array("success" => 2, "msg" => '请先关注公共账号再来参与活动!详情请查看规则!'), "");
     }
     //先判断有没有资格领取
     //判断是否为关注用户
     $follow = pdo_fetchcolumn("SELECT follow FROM " . tablename('mc_mapping_fans') . " Where openid=:openid and uniacid=:uniacid ORDER BY `fanid` DESC", array(":openid" => $from_user, ":uniacid" => $uniacid));
     if ($follow == 0) {
         $this->message(array("success" => 2, "msg" => '请先关注公共账号再来参与活动!详情请查看规则!'), "");
     }
     //判断是否为关注用户
     //查询是活动定义还是商户赠送
     if ($reply['opportunity'] == 1) {
         if (empty($profile['mobile'])) {
             $this->message(array("success" => 2, "msg" => '您没有注册成为会员,不能刮奖!'), "");
         }
         $doings = pdo_fetch("SELECT * FROM " . tablename('stonefish_branch_doings') . " WHERE rid = " . $rid . " and mobile='" . $profile['mobile'] . "' and uniacid='" . $uniacid . "'");
         if (!empty($doings)) {
             if ($doings['status'] < 2) {
                 $this->message(array("success" => 2, "msg" => '抱歉,您的领取红包资格正在审核中!'), "");
             } else {
                 if ($doings['awardcount'] == 0) {
                     $this->message(array("success" => 2, "msg" => '抱歉,您的领取红包资格已用完了!'), "");
                 }
             }
         } else {
             $this->message(array("success" => 2, "msg" => '抱歉,您还没有获取领取红包资格,不能领取!'), "");
         }
     } elseif ($reply['opportunity'] == 2) {
         load()->model('account');
         $unisettings = uni_setting($uniacid, array('creditnames'));
         foreach ($unisettings['creditnames'] as $key => $credits) {
             if ($reply['credit_type'] == $key) {
                 $creditnames = $credits['title'];
                 break;
             }
         }
         $credit = mc_credit_fetch($fansID, array($reply['credit_type']));
         $credit_times = intval($credit[$reply['credit_type']] / $reply['credit_times']);
         if ($credit_times < 1) {
             $this->message(array("success" => 2, "msg" => '抱歉,您没有' . $creditnames . '兑换红包了!'), "");
         }
     }
     //查询是活动定义还是商户赠送
     //是否已关联用户,如果中能中奖一次,判断是否已中奖
     $fans = pdo_fetch("SELECT * FROM " . tablename('stonefish_redenvelope_fans') . " WHERE rid = " . $rid . " and fansID=" . $fansID . " and from_user='******'");
     if ($fans == false) {
         $inpoint = mt_rand($reply['inpointstart'] * 100, $reply['inpointend'] * 100) / 100;
         $inpoint = sprintf("%.2f", $inpoint);
         $fans = array('rid' => $rid, 'uniacid' => $uniacid, 'fansID' => $fansID, 'from_user' => $from_user, 'inpoint' => $inpoint, 'avatar' => $profile['avatar'], 'nickname' => $profile['nickname'], 'createtime' => time());
         pdo_insert('stonefish_redenvelope_fans', $fans);
         $fans['id'] = pdo_insertid();
         //自动读取会员信息存入FANS表中
         $ziduan = array('realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position');
         load()->model('mc');
         foreach ($ziduan as $ziduans) {
             if ($reply['is' . $ziduans]) {
                 if (!empty($_GPC[$ziduans])) {
                     pdo_update('stonefish_redenvelope_fans', array($ziduans => $_GPC[$ziduans]), array('id' => $fans['id']));
                     if ($reply['isfans']) {
                         mc_update($fansID, array($ziduans => $_GPC[$ziduans]));
                     }
                 }
             }
         }
         //自动读取会员信息存入FANS表中
         //增加人数,和浏览次数
         pdo_update('stonefish_redenvelope_reply', array('fansnum' => $reply['fansnum'] + 1, 'viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id']));
         //商家赠送增加使用次数
         if ($reply['opportunity'] == 1) {
             pdo_update('stonefish_branch_doings', array('usecount' => 0, 'usetime' => time()), array('id' => $doings['id']));
         } elseif ($reply['opportunity'] == 2) {
             mc_credit_update($fansID, $reply['credit_type'], -$reply['credit_times'], array($fansID, '兑换幸运抢红包活动消耗:' . $reply['credit_times'] . '个' . $creditnames));
             $credit_now = $credit[$reply['credit_type']] - $reply['credit_times'];
         }
         //开始分配红包咯
         if ($inpoint) {
             //商家赠送添加使用记录
             if ($reply['opportunity'] == 1) {
                 $content = '领取红包价值:' . $inpoint;
                 $insert = array('uniacid' => $uniacid, 'rid' => $rid, 'module' => 'stonefish_redenvelope', 'mobile' => $doings['mobile'], 'content' => $content, 'prizeid' => 0, 'createtime' => time());
                 pdo_insert('stonefish_branch_doingslist', $insert);
             }
             //商家赠送添加使用记录
             $data = array('msg' => $inpoint, 'success' => 1, 'credit_now' => $credit_now);
         }
     } else {
         $this->message(array("success" => 2, "msg" => '您领取过红包了!'), "");
     }
     $this->message($data);
 }
Esempio n. 24
0
function mc_require($uid, $fields, $pre = '')
{
    global $_W, $_GPC;
    if (empty($fields) || !is_array($fields)) {
        return false;
    }
    $flipfields = array_flip($fields);
    if (in_array('birth', $fields) || in_array('birthyear', $fields) || in_array('birthmonth', $fields) || in_array('birthday', $fields)) {
        unset($flipfields['birthyear'], $flipfields['birthmonth'], $flipfields['birthday'], $flipfields['birth']);
        $flipfields['birthyear'] = 'birthyear';
        $flipfields['birthmonth'] = 'birthmonth';
        $flipfields['birthday'] = 'birthday';
    }
    if (in_array('reside', $fields) || in_array('resideprovince', $fields) || in_array('residecity', $fields) || in_array('residedist', $fields)) {
        unset($flipfields['residedist'], $flipfields['resideprovince'], $flipfields['residecity'], $flipfields['reside']);
        $flipfields['resideprovince'] = 'resideprovince';
        $flipfields['residecity'] = 'residecity';
        $flipfields['residedist'] = 'residedist';
    }
    $fields = array_keys($flipfields);
    if (!in_array('uniacid', $fields)) {
        $fields[] = 'uniacid';
    }
    if (!empty($pre)) {
        $pre .= '<br/>';
    }
    $profile = mc_fetch($uid, $fields);
    $uniacid = $profile['uniacid'];
    $titles = mc_fields();
    $message = '';
    $ks = array();
    foreach ($profile as $k => $v) {
        if (empty($v)) {
            $ks[] = $k;
            $message .= $titles[$k] . ', ';
        }
    }
    if (!empty($message)) {
        $title = '完善资料';
        if (checksubmit('submit')) {
            if (in_array('resideprovince', $fields)) {
                $_GPC['resideprovince'] = $_GPC['reside']['province'];
                $_GPC['residecity'] = $_GPC['reside']['city'];
                $_GPC['residedist'] = $_GPC['reside']['district'];
            }
            if (in_array('birthyear', $fields)) {
                $_GPC['birthyear'] = $_GPC['birth']['year'];
                $_GPC['birthmonth'] = $_GPC['birth']['month'];
                $_GPC['birthday'] = $_GPC['birth']['day'];
            }
            $record = array_elements($fields, $_GPC);
            if (isset($record['uniacid'])) {
                unset($record['uniacid']);
            }
            foreach ($record as $field => $value) {
                if ($field == 'gender') {
                    continue;
                }
                if (empty($value)) {
                    message('请填写完整所有资料.', referer(), 'error');
                }
            }
            $condition = " AND uid != {$uid} ";
            if (in_array('email', $fields)) {
                $emailexists = pdo_fetchcolumn("SELECT email FROM " . tablename('mc_members') . " WHERE uniacid = :uniacid AND email = :email " . $condition, array(':uniacid' => $_W['uniacid'], ':email' => trim($record['email'])));
                if (!empty($emailexists)) {
                    message('抱歉,您填写的手机号已经被使用,请更新。', 'refresh', 'error');
                }
            }
            if (in_array('mobile', $fields)) {
                $mobilexists = pdo_fetchcolumn("SELECT mobile FROM " . tablename('mc_members') . " WHERE uniacid = :uniacid AND mobile = :mobile " . $condition, array(':uniacid' => $_W['uniacid'], ':mobile' => trim($record['mobile'])));
                if (!empty($mobilexists)) {
                    message('抱歉,您填写的手机号已经被使用,请更新。', 'refresh', 'error');
                }
            }
            mc_update($uid, $record);
            message('资料完善成功.', 'refresh');
        }
        load()->func('tpl');
        load()->model('activity');
        $filter = array();
        $filter['status'] = 1;
        $coupons = activity_coupon_owned($_W['member']['uid'], $filter);
        $tokens = activity_token_owned($_W['member']['uid'], $filter);
        $setting = uni_setting($_W['uniacid'], array('creditnames', 'creditbehaviors', 'uc'));
        $behavior = $setting['creditbehaviors'];
        $creditnames = $setting['creditnames'];
        $credits = mc_credit_fetch($_W['member']['uid'], '*');
        include template('mc/require', TEMPLATE_INCLUDEPATH);
        exit;
    }
    return $profile;
}
Esempio n. 25
0
 public function doMobileRegister()
 {
     global $_GPC, $_W;
     $title = '微信墙登记';
     /**** 0.6 ****/
     load()->model('mc');
     load()->func('tpl');
     // 验证用户注册, 注册后方能进如活动
     checkauth();
     if (!empty($_GPC['submit'])) {
         $data = array('nickname' => $_GPC['nickname']);
         if (empty($data['nickname'])) {
             die('<script>alert("请填写您的昵称!");location.reload();</script>');
         }
         if (!empty($_FILES['avatar']['tmp_name'])) {
             /**** 0.6 ****/
             load()->func('file');
             $upload = file_upload($_FILES['avatar']);
             if (is_error($upload)) {
                 die('<script>alert("登记失败!请重试!");location.reload();</script>');
             }
             $data['avatar'] = $upload['path'];
         } else {
             $data['avatar'] = $_GPC['avatar'];
         }
         if (empty($data['avatar'])) {
             $data['avatar'] = 'images/global/noavatar_middle.gif';
         }
         mc_update($_W['member']['uid'], $data);
         message('登记成功,系统会自动跳转,如果未成功请手动退回微信界面。<script type="text/javascript">wx.ready(function(){wx.closeWindow();});</script>');
     }
     /**** 0.6 ****/
     $member = mc_fetch($_W['member']['uid'], array('nickname', 'avatar'));
     if (empty($member['avatar'])) {
         //mc_oauth_userinfo();
         $member['avatar'] = 'images/global/noavatar_middle.gif';
         include $this->template('register');
     } else {
         message('个人信息已经自动获取到,系统会自动跳转,如果未成功请手动退回微信界面。<script type="text/javascript">wx.ready(function(){wx.closeWindow();});</script>', '', 'success');
     }
 }
Esempio n. 26
0
 public function doMobileResearch()
 {
     global $_W, $_GPC;
     $weid = $_W['weid'];
     $reid = intval($_GPC['id']);
     $sql = 'SELECT * FROM ' . tablename('hnresearch') . ' WHERE `weid`=:weid AND `reid`=:reid';
     $params = array();
     $params[':weid'] = $_W['uniacid'];
     $params[':reid'] = $reid;
     $activity = pdo_fetch($sql, $params);
     $title = $activity['title'];
     if ($activity['status'] != '1') {
         message('当前活动已经停止.');
     }
     if (!$activity) {
         message('非法访问.');
     }
     if ($activity['starttime'] > TIMESTAMP) {
         message('当前活动还未开始!');
     }
     if ($activity['endtime'] < TIMESTAMP) {
         message('当前活动已经结束!');
     }
     $sql = 'SELECT * FROM ' . tablename('hnresearch_fields') . ' WHERE `reid` = :reid';
     $params = array();
     $params[':reid'] = $reid;
     $ds = pdo_fetchall($sql, $params);
     if (!$ds) {
         message('非法访问.');
     }
     $initRange = $initCalendar = false;
     $binds = array();
     foreach ($ds as &$r) {
         if ($r['type'] == 'range') {
             $initRange = true;
         }
         if ($r['type'] == 'calendar') {
             $initCalendar = true;
         }
         if ($r['value']) {
             $r['options'] = explode(',', $r['value']);
         }
         if ($r['bind']) {
             $binds[$r['type']] = $r['bind'];
         }
         if ($r['type'] == 'reside') {
             $reside = $r;
         }
     }
     if (checksubmit('submit')) {
         $pretotal = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('hnresearch_rows') . " WHERE reid = :reid AND openid = :openid", array(':reid' => $reid, ':openid' => $_W['fans']['from_user']));
         if ($pretotal >= $activity['pretotal']) {
             message('抱歉,每人只能报名' . $activity['pretotal'] . "次!", $this->createMobileUrl('huodongindex'), 'error');
         }
         if (empty($_W['fans']['from_user'])) {
             message('非法进去,请从公众号进入!');
         } else {
             $checksql = "SELECT * FROM " . tablename('hnfans') . " WHERE from_user=:from_user AND weid=:weid";
             $checkit = pdo_fetch($checksql, array(':from_user' => $_W['fans']['from_user'], ':weid' => $weid));
             if (empty($checkit)) {
                 message('对不起,本活动只准许交友系统会员报名!');
             }
         }
         $row = array();
         $row['reid'] = $reid;
         $row['openid'] = $_W['fans']['from_user'];
         $row['createtime'] = TIMESTAMP;
         $datas = $fields = $update = array();
         foreach ($ds as $value) {
             $fields[$value['refid']] = $value;
         }
         foreach ($_GPC as $key => $value) {
             if (strexists($key, 'field_')) {
                 $bindFiled = substr(strrchr($key, '_'), 1);
                 if (!empty($bindFiled)) {
                     $update[$bindFiled] = $value;
                 }
                 $refid = intval(str_replace('field_', '', $key));
                 $field = $fields[$refid];
                 if ($refid && $field) {
                     $entry = array();
                     $entry['reid'] = $reid;
                     $entry['rerid'] = 0;
                     $entry['refid'] = $refid;
                     if (in_array($field['type'], array('number', 'text', 'calendar', 'email', 'textarea', 'radio', 'range', 'select'))) {
                         $entry['data'] = strval($value);
                     }
                     if (in_array($field['type'], array('checkbox'))) {
                         if (!is_array($value)) {
                             continue;
                         }
                         $entry['data'] = implode(';', $value);
                     }
                     $datas[] = $entry;
                 }
             }
         }
         if ($_FILES) {
             load()->func('file');
             foreach ($_FILES as $key => $file) {
                 if (strexists($key, 'field_')) {
                     $refid = intval(str_replace('field_', '', $key));
                     $field = $fields[$refid];
                     if ($refid && $field && $file['name'] && $field['type'] == 'image') {
                         $entry = array();
                         $entry['reid'] = $reid;
                         $entry['rerid'] = 0;
                         $entry['refid'] = $refid;
                         $ret = file_upload($file);
                         if (!$ret['success']) {
                             message('上传图片失败, 请稍后重试.');
                         }
                         $entry['data'] = trim($ret['path']);
                         $datas[] = $entry;
                     }
                 }
             }
         }
         // 兼容会员居住地字段
         if (!empty($_GPC['reside'])) {
             if (in_array('reside', $binds)) {
                 $update['resideprovince'] = $_GPC['reside']['province'];
                 $update['residecity'] = $_GPC['reside']['city'];
                 $update['residedist'] = $_GPC['reside']['district'];
             }
             foreach ($_GPC['reside'] as $key => $value) {
                 $resideData = array('reid' => $reside['reid']);
                 $resideData['rerid'] = 0;
                 $resideData['refid'] = $reside['refid'];
                 $resideData['data'] = $value;
                 $datas[] = $resideData;
             }
         }
         // 更新关联会员资料
         if (!empty($update)) {
             load()->model('mc');
             mc_update($_W['member']['uid'], $update);
         }
         if (empty($datas)) {
             message('非法访问.', '', 'error');
         }
         if (pdo_insert('hnresearch_rows', $row) != 1) {
             message('保存失败.');
         }
         $rerid = pdo_insertid();
         if (empty($rerid)) {
             message('保存失败.');
         }
         foreach ($datas as &$r) {
             $r['rerid'] = $rerid;
             pdo_insert('hnresearch_data', $r);
         }
         if (empty($activity['starttime'])) {
             $record = array();
             $record['starttime'] = TIMESTAMP;
             pdo_update('hnresearch', $record, array('reid' => $reid));
         }
         //发送预约
         if (!empty($datas) && !empty($activity['noticeemail'])) {
             foreach ($datas as $row) {
                 $img = "<img src='";
                 /* 如果预约项目类型是上传图片 */
                 if (substr($row['data'], 0, 6) == 'images') {
                     $body = $fields[$row['refid']]['title'] . ':' . $img . tomedia($row['data']) . ' />';
                 }
                 $body .= $fields[$row['refid']]['title'] . ':' . $row['data'];
             }
             load()->func('communication');
             ihttp_email($activity['noticeemail'], $activity['title'] . '的报名提醒', $body);
         }
         message($activity['information'], $this->createMobileUrl('huodongindex'), 'sucess');
         //可能需要改成跳转到活动首页
     }
     foreach ($binds as $key => $value) {
         if ($value == 'reside') {
             unset($binds[$key]);
             $binds[] = 'resideprovince';
             $binds[] = 'residecity';
             $binds[] = 'residedist';
             break;
         }
     }
     if (!empty($_W['fans']['from_user']) && !empty($binds)) {
         $profile = fans_search($_W['fans']['from_user'], $binds);
         if ($profile['gender']) {
             if ($profile['gender'] == '0') {
                 $profile['gender'] = '保密';
             }
             if ($profile['gender'] == '1') {
                 $profile['gender'] = '男';
             }
             if ($profile['gender'] == '2') {
                 $profile['gender'] = '女';
             }
         }
         foreach ($ds as &$r) {
             if ($profile[$r['bind']]) {
                 $r['default'] = $profile[$r['bind']];
             }
         }
     }
     $settings = pdo_fetch("SELECT * FROM " . tablename('meepo_hongniangset') . " WHERE weid=:weid", array(':weid' => $_W['weid']));
     load()->func('tpl');
     include $this->template('hnsubmit');
 }
Esempio n. 27
0
                        if ($uid == -1) {
                            message('用户名不合法!', '', 'error');
                        } elseif ($uid == -2) {
                            message('包含不允许注册的词语!', '', 'error');
                        } elseif ($uid == -3) {
                            message('用户名已经存在!', '', 'error');
                        } elseif ($uid == -4) {
                            message('邮箱格式错误!', '', 'error');
                        } elseif ($uid == -5) {
                            message('邮箱不允许注册!', '', 'error');
                        } elseif ($uid == -6) {
                            message('邮箱已经被注册!', '', 'error');
                        }
                    } else {
                        if ($_W['member']['email'] == '') {
                            mc_update($_W['member']['uid'], array('email' => $email));
                        }
                        pdo_insert('mc_mapping_ucenter', array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'], 'centeruid' => $uid));
                        message('绑定UC账号成功!', url('mc/mc/home'), 'success');
                    }
                }
            }
            template('mc/bind');
            exit;
        } else {
            message('已绑定UC账号,您可以尝试解绑定后重新绑定UC账号!', '', 'error');
        }
    } else {
        message('系统尚未开启UC!', '', 'success');
    }
} else {
Esempio n. 28
0
 public function respond()
 {
     global $_W;
     load()->model('mc');
     $openid = $this->message['from'];
     $logs['openid'] = $openid;
     $logs['weid'] = $_W['uniacid'];
     $fans = pdo_fetch("SELECT fanid,uid FROM " . tablename('mc_mapping_fans') . " WHERE `openid`='{$openid}' LIMIT 1");
     $uid = '0';
     if ($fans['uid'] != '0') {
         $uid = $fans['uid'];
     } else {
         $uid = mc_update($uid, array('email' => md5($_W['openid']) . '@012wz.com'));
         if (!empty($fans['fanid']) && !empty($uid)) {
             pdo_update('mc_mapping_fans', array('uid' => $uid), array('fanid' => $fans['fanid']));
         }
     }
     $rid = $this->rule;
     $sql = "SELECT * FROM " . tablename('rule_keyword') . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     $sqls = "SELECT * FROM " . tablename($this->reply) . " WHERE `rid`=:rid LIMIT 1";
     $rows = pdo_fetch($sqls, array(':rid' => $rid));
     if (empty($rows['id'])) {
         return array();
     }
     if (empty($row['id'])) {
         return array();
     }
     $wd_code = $this->message['scancodeinfo']['scanresult'];
     $wd_qrcode = substr($wd_code, strpos($wd_code, "wd_code=") + 8);
     if ($this->message['event'] == 'scancode_waitmsg') {
         $qrtype = $this->message['scancodeinfo']['scantype'];
         $SecurityCode = $wd_qrcode;
     } else {
         $keywords = $wd_qrcode;
         preg_match('/' . $keywords . '(.*)/', $this->message['content'], $match);
         $SecurityCode = $match[1];
     }
     $logs['code'] = $SecurityCode;
     $sql = "SELECT * FROM " . tablename($this->data) . " WHERE code='{$SecurityCode}' LIMIT 1";
     $member = pdo_fetch($sql);
     $states = 0;
     if (!empty($member)) {
         if ($member['status'] == '0') {
             $states = 0;
         } elseif ($member['num'] >= $rows['tnumber']) {
             $set = pdo_update($this->data, array('status' => '0'), array('id' => $member['id']));
             $states = 0;
         } elseif ($member['stime'] <= TIME()) {
             $logs['status'] = '0';
             $reply = '您查询的防伪码已过期! ';
         } else {
             $data = array('num' => $member['num'] + 1);
             pdo_update($this->data, $data, array('id' => $member['id']));
             $states = 1;
         }
         if ($states == 0) {
             $reply = str_replace('[SecurityCode]', $SecurityCode, $rows['Failure']);
         } else {
             $number = $member['num'] + 1;
             $Factory = $member['factory'];
             $Effedate = date('Y-m-d', $member['stime']);
             $Products = $member['type'];
             $Brand = $member['brand'];
             $Spec = $member['spec'];
             $Weight = $member['weight'];
             $Remarks = $member['remarks'];
             $reply = str_replace('[number]', $number, $rows['Reply']);
             $reply = str_replace('[Factory]', $Factory, $reply);
             $reply = str_replace('[Brand]', $Brand, $reply);
             $reply = str_replace('[Spec]', $Spec, $reply);
             $reply = str_replace('[Weight]', $Weight, $reply);
             $reply = str_replace('[Remarks]', $Remarks, $reply);
             $reply = str_replace('[Effedate]', $Effedate, $reply);
             $reply = str_replace('[Products]', $Products, $reply);
             $reply = str_replace('[SecurityCode]', $SecurityCode, $reply);
             $reply = str_replace('[CreditName]', $member['creditname'], $reply);
             $reply = str_replace('[CreditNum]', $member['creditnum'], $reply);
             if ($member['creditstatus'] == '0') {
                 mc_credit_update($uid, 'credit1', $member['creditnum'], array('1', '防伪码自动增加积分,积分名称:' . $member['creditname']));
                 pdo_update($this->data, array('creditstatus' => '1'), array('id' => $member['id']));
             }
             $logs['status'] = '1';
         }
     } else {
         $logs['status'] = '0';
         $reply = '您查询的防伪码不存在,请核对后重试!';
     }
     $logs['createtime'] = time();
     pdo_insert('super_securitycode_logs', $logs);
     return $this->respText($reply);
 }
Esempio n. 29
0
 public function doMobileCheckprize()
 {
     global $_W, $_GPC;
     if (empty($_SERVER["HTTP_X_REQUESTED_WITH"]) || strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) != "xmlhttprequest") {
         exit('非法访问');
     }
     load()->model('activity');
     $id = $_GPC['id'];
     $reply = pdo_fetch("SELECT * FROM " . tablename($this->table_reply) . " WHERE id = :id", array(':id' => $id));
     if (!empty($reply)) {
         if (empty($_W['fans']['from_user'])) {
             //防止错误提交的数据
             $errorCode = 10999;
         } else {
             $from_user = $_W['fans']['from_user'];
             $fans = pdo_fetch("SELECT fanid,uid FROM " . tablename('mc_mapping_fans') . " WHERE `openid`='{$from_user}' LIMIT 1");
             $uid = '0';
             if ($fans['uid'] != '0') {
                 $uid = $fans['uid'];
             } else {
                 $uid = mc_update($uid, array('email' => md5($from_user) . '@wdlcms.com'));
                 if (!empty($fans['fanid']) && !empty($uid)) {
                     pdo_update('mc_mapping_fans', array('uid' => $uid), array('fanid' => $fans['fanid']));
                 }
             }
             $profile = mc_fetch($uid);
             $awardnum = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename($this->table_award) . " WHERE reply_id = '{$id}' AND uid = '{$uid}'");
             $awardfans = pdo_fetch("SELECT * FROM " . tablename($this->table_fans) . " WHERE reply_id = '{$id}' AND uid = '{$uid}'");
             $t = mktime(0, 0, 0, date("m", time()), date("d", time()), date("y", time()));
             if (empty($awardfans)) {
                 $data1 = array('reply_id' => $id, 'from_user' => $from_user, 'uid' => $uid, 'todaynum' => '0', 'totalnum' => '0', 'awardnum' => '0', 'last_time' => time(), 'createtime' => time());
                 pdo_insert($this->table_fans, $data1);
             } elseif ($awardfans['last_time'] < $t) {
                 $data2 = array('todaynum' => '0', 'last_time' => time());
                 pdo_update($this->table_fans, $data2, array('id' => $awardfans['id']));
             }
             if (time() <= $reply['starttime'] || time() >= $reply['endtime'] || $reply['status'] == 0) {
                 $errorCode = 1;
             } elseif ($reply['status'] == 2) {
                 $errorCode = 1;
             } elseif ($reply['groupid'] != 0 && $reply['groupid'] != $profile['groupid']) {
                 $errorCode = 1;
             } elseif ($reply['need_num'] > $profile[$reply['need_type']]) {
                 $errorCode = 1;
             } elseif ($awardnum >= $reply['awardnum']) {
                 $errorCode = 1;
             } elseif ($awardfans['totalnum'] >= $reply['playnum']) {
                 $errorCode = 1;
             } elseif ($awardfans['todaynum'] >= $reply['dayplaynum']) {
                 $errorCode = 1;
             } else {
                 mc_credit_update($uid, $reply['need_type'], '-' . $reply['need_num'], array('1', '幸运大抽奖 消耗 ' . $this->getcreditname($reply['need_type']) . ':' . $reply['need_num']));
                 $data3 = array('todaynum' => $awardfans['todaynum'] + 1, 'totalnum' => $awardfans['totalnum'] + 1, 'last_time' => time());
                 pdo_update($this->table_fans, $data3, array('id' => $awardfans['id']));
                 /*中奖部分代码开始*/
                 $rate = $reply['rate'];
                 $prizes = iunserializer($reply['prizes']);
                 $p_num = $prizes['p1_num'] + $prizes['p2_num'] + $prizes['p3_num'] + $prizes['p4_num'];
                 empty($p_num) && ($p_num = 1);
                 $arr['p1'] = round(100 * $rate * $prizes['p1_num'] / $p_num);
                 $arr['p2'] = round(100 * $rate * $prizes['p2_num'] / $p_num);
                 $arr['p3'] = round(100 * $rate * $prizes['p3_num'] / $p_num);
                 $arr['p4'] = round(100 * $rate * $prizes['p4_num'] / $p_num);
                 $arr['p5'] = 10000 - $arr['p1'] - $arr['p2'] - $arr['p3'] - $arr['p4'];
                 if ($awardnum >= $p_num) {
                     $result = 'p5';
                 } else {
                     $result = $this->get_rand($arr);
                     //返回结果为键值p1,p2,p3,p4
                 }
                 /*中奖部分代码结束*/
                 if ($result == 'p5') {
                     if ($reply['give_num'] != 0) {
                         mc_credit_update($uid, $reply['give_type'], $reply['give_num'], array('1', '幸运大抽奖 未中奖赠送 ' . $this->getcreditname($reply['give_type']) . ':' . $reply['give_num']));
                     }
                 } else {
                     if ($reply['give_num'] != 0 && $reply['onlynone'] != 1) {
                         $give_point = $reply['give_num'];
                         $give_name = $this->getcreditname($reply['give_type']);
                         mc_credit_update($uid, $reply['give_type'], $reply['give_num'], array('1', '幸运大抽奖 未中奖赠送 ' . $this->getcreditname($reply['give_type']) . ':' . $reply['give_num']));
                     }
                     $errorCode = 0;
                     if ($result == 'p1') {
                         if ($prizes['p1_type'] != 2 && $prizes['p1_type'] != 3 && $prizes['p1_type'] != 4) {
                             //积分类奖品
                             $point = $prizes['p1_score'];
                             $point_name = $this->getcreditname($prizes['p1_type']);
                             mc_credit_update($uid, $prizes['p1_type'], $point, array('1', '幸运大抽奖 中奖获得 ' . $this->getcreditname($prizes['p1_type']) . ':' . $point));
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=mc&a=bond&do=credits&credittype=' . $prizes['p1_type'];
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => $this->getcreditname($prizes['p1_type']) . ':' . $point, 'prizetype' => $prizes['p1_type'], 'level' => '1', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                         } elseif ($prizes['p1_type'] == 2) {
                             //非积分类奖品:折扣券
                             $point = 0;
                             $couponid = $prizes['p1_score'];
                             $coupon = activity_coupon_info($couponid, $_W['uniacid']);
                             $ret = activity_coupon_grant($uid, $couponid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'];
                                 mc_credit_update($uid, $coupon['credittype'], $coupon['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=coupon&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $coupon['title'], 'prizetype' => 'coupon', 'level' => '1', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '折扣券';
                             $type = '折扣券';
                             $value = 1;
                         } elseif ($prizes['p1_type'] == 3) {
                             //非积分类奖品:代金券
                             $point = 0;
                             $tokenid = $prizes['p1_score'];
                             $token = activity_token_info($tokenid, $_W['uniacid']);
                             $ret = activity_token_grant($uid, $tokenid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($token['credittype']) . ':' . $token['credit'];
                                 mc_credit_update($uid, $token['credittype'], $token['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($token['credittype']) . ':' . $token['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=token&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $token['title'], 'prizetype' => 'token', 'level' => '1', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '代金券';
                             $type = '代金券';
                             $value = 1;
                         } elseif ($prizes['p1_type'] == 4) {
                             //非积分类奖品:真实物品
                             $point = 0;
                             $goodsid = $prizes['p1_score'];
                             $goods = activity_exchange_info($goodsid, $_W['uniacid']);
                             $ret = activity_goods_grant($uid, $goodsid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'];
                                 mc_credit_update($uid, $goods['credittype'], $goods['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=goods&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $goods['title'], 'prizetype' => 'goods', 'level' => '1', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '真实物品券';
                             $type = '真实物品券';
                             $value = 1;
                         }
                         $award = array('title' => $title, 'value' => $value, 'type' => $type, 'remsg' => $remsg, 'point' => $point, 'point_name' => $point_name, 'give_point' => $give_point, 'give_name' => $give_name, 'level' => '1', 'detail_url' => $detail_url);
                     } elseif ($result == 'p2') {
                         if ($prizes['p2_type'] != 2 && $prizes['p2_type'] != 3 && $prizes['p2_type'] != 4) {
                             //积分类奖品
                             $point = $prizes['p2_score'];
                             $point_name = $this->getcreditname($prizes['p2_type']);
                             mc_credit_update($uid, $prizes['p2_type'], $point, array('1', '幸运大抽奖 中奖获得 ' . $this->getcreditname($prizes['p2_type']) . ':' . $point));
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=mc&a=bond&do=credits&credittype=' . $prizes['p2_type'];
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => $this->getcreditname($prizes['p2_type']) . ':' . $point, 'prizetype' => $prizes['p2_type'], 'level' => '2', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                         } elseif ($prizes['p2_type'] == 2) {
                             //非积分类奖品:折扣券
                             $point = 0;
                             $couponid = $prizes['p2_score'];
                             $coupon = activity_coupon_info($couponid, $_W['uniacid']);
                             $ret = activity_coupon_grant($uid, $couponid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'];
                                 mc_credit_update($uid, $coupon['credittype'], $coupon['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=coupon&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $coupon['title'], 'prizetype' => 'coupon', 'level' => '2', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '折扣券';
                             $type = '折扣券';
                             $value = 1;
                         } elseif ($prizes['p2_type'] == 3) {
                             //非积分类奖品:代金券
                             $point = 0;
                             $tokenid = $prizes['p2_score'];
                             $token = activity_token_info($tokenid, $_W['uniacid']);
                             $ret = activity_token_grant($uid, $tokenid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($token['credittype']) . ':' . $token['credit'];
                                 mc_credit_update($uid, $token['credittype'], $token['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($token['credittype']) . ':' . $token['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=token&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $token['title'], 'prizetype' => 'token', 'level' => '2', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '代金券';
                             $type = '代金券';
                             $value = 1;
                         } elseif ($prizes['p2_type'] == 4) {
                             //非积分类奖品:真实物品
                             $point = 0;
                             $goodsid = $prizes['p2_score'];
                             $goods = activity_exchange_info($goodsid, $_W['uniacid']);
                             $ret = activity_goods_grant($uid, $goodsid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'];
                                 mc_credit_update($uid, $goods['credittype'], $goods['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=goods&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $goods['title'], 'prizetype' => 'goods', 'level' => '2', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '真实物品券';
                             $type = '真实物品券';
                             $value = 1;
                         }
                         $award = array('title' => $title, 'value' => $value, 'type' => $type, 'remsg' => $remsg, 'point' => $point, 'point_name' => $point_name, 'give_point' => $give_point, 'give_name' => $give_name, 'level' => '2', 'detail_url' => $detail_url);
                     } elseif ($result == 'p3') {
                         if ($prizes['p3_type'] != 2 && $prizes['p3_type'] != 3 && $prizes['p3_type'] != 4) {
                             //积分类奖品
                             $point = $prizes['p3_score'];
                             $point_name = $this->getcreditname($prizes['p3_type']);
                             mc_credit_update($uid, $prizes['p3_type'], $point, array('1', '幸运大抽奖 中奖获得 ' . $this->getcreditname($prizes['p3_type']) . ':' . $point));
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=mc&a=bond&do=credits&credittype=' . $prizes['p3_type'];
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => $this->getcreditname($prizes['p3_type']) . ':' . $point, 'prizetype' => $prizes['p3_type'], 'level' => '3', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                         } elseif ($prizes['p3_type'] == 2) {
                             //非积分类奖品:折扣券
                             $point = 0;
                             $couponid = $prizes['p3_score'];
                             $coupon = activity_coupon_info($couponid, $_W['uniacid']);
                             $ret = activity_coupon_grant($uid, $couponid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'];
                                 mc_credit_update($uid, $coupon['credittype'], $coupon['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=coupon&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $coupon['title'], 'prizetype' => 'coupon', 'level' => '3', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '折扣券';
                             $type = '折扣券';
                             $value = 1;
                         } elseif ($prizes['p3_type'] == 3) {
                             //非积分类奖品:代金券
                             $point = 0;
                             $tokenid = $prizes['p3_score'];
                             $token = activity_token_info($tokenid, $_W['uniacid']);
                             $ret = activity_token_grant($uid, $tokenid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($token['credittype']) . ':' . $token['credit'];
                                 mc_credit_update($uid, $token['credittype'], $token['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($token['credittype']) . ':' . $token['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=token&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $token['title'], 'prizetype' => 'token', 'level' => '3', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '代金券';
                             $type = '代金券';
                             $value = 1;
                         } elseif ($prizes['p3_type'] == 4) {
                             //非积分类奖品:真实物品
                             $point = 0;
                             $goodsid = $prizes['p3_score'];
                             $goods = activity_exchange_info($goodsid, $_W['uniacid']);
                             $ret = activity_goods_grant($uid, $goodsid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'];
                                 mc_credit_update($uid, $goods['credittype'], $goods['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=goods&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $goods['title'], 'prizetype' => 'goods', 'level' => '3', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '真实物品券';
                             $type = '真实物品券';
                             $value = 1;
                         }
                         $award = array('title' => $title, 'value' => $value, 'type' => $type, 'remsg' => $remsg, 'point' => $point, 'point_name' => $point_name, 'give_point' => $give_point, 'give_name' => $give_name, 'level' => '3', 'detail_url' => $detail_url);
                     } elseif ($result == 'p4') {
                         if ($prizes['p4_type'] != 2 && $prizes['p4_type'] != 3 && $prizes['p4_type'] != 4) {
                             //积分类奖品
                             $point = $prizes['p4_score'];
                             $point_name = $this->getcreditname($prizes['p4_type']);
                             mc_credit_update($uid, $prizes['p4_type'], $point, array('1', '幸运大抽奖 中奖获得 ' . $this->getcreditname($prizes['p4_type']) . ':' . $point));
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=mc&a=bond&do=credits&credittype=' . $prizes['p4_type'];
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => $this->getcreditname($prizes['p4_type']) . ':' . $point, 'prizetype' => $prizes['p4_type'], 'level' => '4', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                         } elseif ($prizes['p4_type'] == 2) {
                             //非积分类奖品:折扣券
                             $point = 0;
                             $couponid = $prizes['p4_score'];
                             $coupon = activity_coupon_info($couponid, $_W['uniacid']);
                             $ret = activity_coupon_grant($uid, $couponid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'];
                                 mc_credit_update($uid, $coupon['credittype'], $coupon['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=coupon&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $coupon['title'], 'prizetype' => 'coupon', 'level' => '4', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '折扣券';
                             $type = '折扣券';
                             $value = 1;
                         } elseif ($prizes['p4_type'] == 3) {
                             //非积分类奖品:代金券
                             $point = 0;
                             $tokenid = $prizes['p4_score'];
                             $token = activity_token_info($tokenid, $_W['uniacid']);
                             $ret = activity_token_grant($uid, $tokenid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($token['credittype']) . ':' . $token['credit'];
                                 mc_credit_update($uid, $token['credittype'], $token['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($token['credittype']) . ':' . $token['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=token&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $token['title'], 'prizetype' => 'token', 'level' => '4', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '代金券';
                             $type = '代金券';
                             $value = 1;
                         } elseif ($prizes['p4_type'] == 4) {
                             //非积分类奖品:真实物品
                             $point = 0;
                             $goodsid = $prizes['p4_score'];
                             $goods = activity_exchange_info($goodsid, $_W['uniacid']);
                             $ret = activity_goods_grant($uid, $goodsid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'];
                                 mc_credit_update($uid, $goods['credittype'], $goods['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=goods&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $goods['title'], 'prizetype' => 'goods', 'level' => '4', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '真实物品券';
                             $type = '真实物品券';
                             $value = 1;
                         }
                         $award = array('title' => $title, 'value' => $value, 'type' => $type, 'remsg' => !empty($remsg) ? $remsg : ' ', 'point' => $point, 'point_name' => $point_name, 'give_point' => $give_point, 'give_name' => $give_name, 'level' => '4', 'detail_url' => $detail_url);
                     }
                     pdo_insert($this->table_award, $awarddata);
                     pdo_update($this->table_fans, array('awardnum' => $awardfans['awardnum'] + 1), array('id' => $awardfans['id']));
                 }
             }
         }
     }
     $data['code'] = $errorCode;
     $data['msg'] = $errorMsg;
     $data['data'] = $award;
     echo json_encode($data);
 }
Esempio n. 30
0
 public function doMobileInfosubmit()
 {
     global $_W, $_GPC;
     list($rid, $from_user) = explode('|', superman_authcode(trim($_GPC['_x']), 'DECODE'));
     if (empty($rid) || empty($from_user)) {
         message('非法请求!');
     }
     $reply = pdo_fetch("select * from " . tablename('stonefish_luckynum') . " where rid = :rid order by `id` desc", array(':rid' => $rid));
     $isfansname = explode(',', $reply['isfansname']);
     $fansID = pdo_fetchcolumn("select uid as fansID from " . tablename('mc_mapping_fans') . " where openid='" . $from_user . "'");
     $profile = mc_fetch($fansID, array('avatar', 'nickname', 'realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position'));
     $success = false;
     if (checksubmit()) {
         //查询规则保存哪些数据
         $updata = array();
         if ($reply['isrealname']) {
             $updata['realname'] = $_GPC['realname'];
         }
         if ($reply['ismobile']) {
             $updata['mobile'] = $_GPC['mobile'];
         }
         if ($reply['isqq']) {
             $updata['qq'] = $_GPC['qq'];
         }
         if ($reply['isemail']) {
             $updata['email'] = $_GPC['email'];
         }
         if ($reply['isaddress']) {
             $updata['address'] = $_GPC['address'];
         }
         if ($reply['isgender']) {
             $updata['gender'] = $_GPC['gender'];
         }
         if ($reply['istelephone']) {
             $updata['telephone'] = $_GPC['telephone'];
         }
         if ($reply['isidcard']) {
             $updata['idcard'] = $_GPC['idcard'];
         }
         if ($reply['iscompany']) {
             $updata['company'] = $_GPC['company'];
         }
         if ($reply['isoccupation']) {
             $updata['occupation'] = $_GPC['occupation'];
         }
         if ($reply['isposition']) {
             $updata['position'] = $_GPC['position'];
         }
         pdo_update('stonefish_luckynum_fans', array('zhongjiang' => 2), array('rid' => $rid, 'from_user' => $from_user, 'zhongjiang' => 1));
         $temp = pdo_update('stonefish_luckynum_fans', $updata, array('rid' => $rid, 'from_user' => $from_user));
         if ($temp === false) {
             $success = false;
         } else {
             if ($reply['isfans']) {
                 load()->model('mc');
                 mc_update($fans_ID, $updata);
             }
             $success = true;
         }
     }
     include $this->template('infosubmit');
 }