Example #1
0
 public static function fans_search($from_user, $fields = array())
 {
     //    $uid = pdo_fetchcolumn("SELECT a.uid FROM "
     //      . tablename('mc_mapping_fans') . " a inner join "
     //      . tablename('mc_members') . " b on a.uid=b.uid "
     //      . " WHERE a.openid='{$from_user}' LIMIT 1");
     //    return fans_search($uid, $fields);
     load()->model('mc');
     $uid = mc_openid2uid($from_user);
     return mc_fetch($uid, $fields);
 }
Example #2
0
 function fans_search($user, $fields = array())
 {
     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 array();
         }
     }
     return mc_fetch($uid, $fields);
 }
Example #3
0
function formot_content($content = '')
{
    global $_W;
    if (empty($content)) {
        return $content;
    }
    load()->model('mc');
    $user = mc_fetch($_W['member']['uid']);
    $replace = pdo_fetchall("SELECT * FROM " . tablename('abc_replace') . " WHERE uniacid = :uniacid ", array(':uniacid' => $_W['uniacid']));
    //print_r($replace);
    foreach ($replace as $re) {
        $content = str_replace($re['replace'], $user[$re['name']], $content);
    }
    return $content;
}
Example #4
0
 public function doMobileIndex()
 {
     global $_W, $_GPC;
     if (empty($_W['fans']['openid'])) {
         message('请先关注公众号再来参加活动吧!');
     }
     $rid = intval($_GPC['rid']);
     $sql = 'SELECT * FROM ' . tablename('weihaom_wb_reply') . ' WHERE `rid` = :rid';
     $params = array(':rid' => $rid);
     $set = pdo_fetch($sql, $params);
     if (empty($set)) {
         message('活动不存在或已经被删除');
     }
     $sql = 'SELECT * FROM ' . tablename('weihaom_wb_user') . ' WHERE `weid` = :weid AND `rid` = :rid AND
             `from_user` = :openid';
     $params[':weid'] = $_W['uniacid'];
     $params[':openid'] = $_W['fans']['openid'];
     $user = pdo_fetch($sql, $params);
     if (intval($_GPC['id'])) {
         $score = intval($_GPC['score']);
         if ($user['score'] < $score) {
             $user['score'] = $score;
             $update = array('score' => $score);
             pdo_update('weihaom_wb_user', $update, array('id' => intval($_GPC['id'])));
         }
         message($user['score'], '', 'ajax');
     }
     if (empty($user)) {
         $result = mc_fetch($_W['member']['uid'], array('nickname'));
         $insert = array('weid' => $_W['uniacid'], 'rid' => $params[':rid'], 'from_user' => $_W['fans']['openid'], 'realname' => $result['nickname'], 'score' => 0);
         pdo_insert('weihaom_wb_user', $insert);
         $user = array('id' => pdo_insertid());
     }
     $realname = $_W['fans']['nickname'];
     $set['description'] = str_replace("\r\n", '', $set['description']);
     include $this->template('index');
 }
Example #5
0
 public function doMobileLottery()
 {
     global $_GPC, $_W;
     checkauth();
     load()->model('mc');
     mc_require($_W['member']['uid'], array('realname', 'mobile'), '需要完善资料后才能砸蛋.');
     $where = ' WHERE `rid` = :rid';
     $params = array(':rid' => intval($_GPC['id']));
     $sql = 'SELECT * FROM ' . tablename('egg_reply') . $where;
     $egg = pdo_fetch($sql, $params);
     if (empty($egg)) {
         message('非法访问,请重新发送消息进入砸蛋页面!');
     }
     if (TIMESTAMP < $egg['starttime']) {
         message('活动还没有开始!');
     }
     if (TIMESTAMP > $egg['endtime']) {
         message('活动已经结束啦!');
     }
     $where .= ' AND `uniacid` = :uniacid AND `uid` = :uid';
     $params[':uniacid'] = $_W['uniacid'];
     $params[':uid'] = $_W['member']['uid'];
     $params[':createtime'] = strtotime(date('Y-m-d'));
     // 当日砸蛋次数
     $sql = 'SELECT COUNT(*) FROM ' . tablename('egg_winner') . $where . ' AND `createtime` > :createtime';
     $total = pdo_fetchcolumn($sql, $params);
     // 会员信息
     $member = mc_fetch($_W['member']['uid'], array('realname', 'mobile'));
     // 我的奖品
     $sql = 'SELECT `award`, `description` FROM ' . tablename('egg_winner') . $where . ' ORDER BY `createtime` DESC';
     unset($params[':createtime']);
     $myAward = pdo_fetchall($sql, $params);
     // 中奖名单
     $sql = 'SELECT `award`, `realname` FROM ' . tablename('egg_winner') . ' AS `w` JOIN ' . tablename('mc_members') . ' AS `m` ON `w`.`uid` = `m`.`uid` WHERE `rid` = :rid ORDER BY `w`.`id` DESC LIMIT 20';
     $otherAward = pdo_fetchall($sql, array(':rid' => $params[':rid']));
     // 分享信息
     $shareTitle = empty($egg['title']) ? '砸蛋抽奖' : $egg['title'];
     $shareDesc = $egg['description'];
     $shareImage = tomedia($egg['picture']);
     include $this->template('lottery');
 }
Example #6
0
 public function doWebSharelist()
 {
     global $_GPC, $_W;
     if ($_W['isajax']) {
         $uid = intval($_GPC['uid']);
         $rid = intval($_GPC['rid']);
         //粉丝数据
         $data = pdo_fetch("SELECT id, fansID, realname, mobile, from_user  FROM " . tablename('stonefish_redenvelope_fans') . ' WHERE id = :id AND uniacid = :uniacid', array(':uniacid' => $_W['uniacid'], ':id' => $uid));
         if ($data['fansID']) {
             load()->model('mc');
             $profile = mc_fetch($data['fansID'], array('realname', 'mobile'));
         }
         $share = pdo_fetchall("SELECT * FROM " . tablename('stonefish_redenvelope_data') . "  WHERE rid = :rid and uniacid=:uniacid and fromuser=:fromuser ORDER BY id DESC ", array(':uniacid' => $_W['uniacid'], ':rid' => $rid, ':fromuser' => $data['from_user']));
         include $this->template('sharelist');
         exit;
     }
 }
Example #7
0
function activity_module_card_grant($uid, $couponid, $module = '', $remark = '')
{
    global $_W;
    $uid = intval($uid);
    $user = mc_fetch($uid, array('groupid'));
    $groupid = $user['groupid'];
    $couponid = intval($couponid);
    $coupon = pdo_fetch("SELECT * FROM " . tablename('activity_coupon') . " WHERE `couponid` = :couponid LIMIT 1", array(':couponid' => $couponid));
    $pcount = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('activity_coupon_record') . " WHERE `uid` = :uid AND `couponid` = :couponid", array(':couponid' => $couponid, ':uid' => $uid));
    $coupongroup = pdo_fetchall("SELECT groupid FROM " . tablename('activity_coupon_allocation') . " WHERE `couponid` = :couponid", array(':couponid' => $couponid), 'groupid');
    $group = array_keys($coupongroup);
    $couponmodules = pdo_fetchall("SELECT module FROM " . tablename('activity_coupon_modules') . " WHERE `couponid` = :couponid", array(':couponid' => $couponid), 'module');
    $modules = array_keys($couponmodules);
    if (empty($coupon)) {
        return error(-1, '未找到指定优惠券');
    } elseif (!in_array($module, $modules)) {
        return error(-1, '该优惠券只能在特定的模块中领取');
    } elseif (empty($coupongroup)) {
        return error(-1, '该优惠券未指定可使用的会员组');
    } elseif (!in_array($groupid, $group)) {
        return error(-1, '您所在的用户组没有领取该优惠券的权限');
    } elseif ($coupon['starttime'] > TIMESTAMP) {
        return error(-1, '优惠券活动尚未开始');
    } elseif ($coupon['endtime'] < TIMESTAMP) {
        return error(-1, '优惠券活动已经结束');
    } elseif ($coupon['dosage'] >= $coupon['amount']) {
        return error(-1, '优惠券已经发放完毕');
    } elseif ($pcount >= $coupon['limit']) {
        return error(-1, '用户领取优惠券数量已经超过限制');
    }
    $creditnames = array();
    $unisettings = uni_setting($_W['uniacid'], array('creditnames'));
    if (!empty($unisettings) && !empty($unisettings['creditnames'])) {
        foreach ($unisettings['creditnames'] as $key => $credit) {
            $creditnames[$key] = $credit['title'];
        }
    }
    $credit = mc_credit_fetch($uid, array($coupon['credittype']));
    if ($credit[$coupon['credittype']] < $coupon['credit']) {
        return error(-1, '您的' . $creditnames[$coupon['credittype']] . '数量不够,无法兑换.');
    }
    mc_credit_update($uid, $coupon['credittype'], -1 * $coupon['credit'], array($uid, '优惠券兑换:' . $coupon['title'] . ' 消耗 ' . $creditnames[$coupon['credittype']] . ':' . $coupon['credit']));
    $remark = "通过{$module}模块领取优惠券";
    $insert = array('couponid' => $couponid, 'uniacid' => $_W['uniacid'], 'uid' => $uid, 'grantmodule' => $module, 'granttime' => TIMESTAMP, 'status' => 1, 'remark' => $remark);
    pdo_insert('activity_coupon_record', $insert);
    pdo_update('activity_coupon', array('dosage' => $coupon['dosage'] + 1), array('couponid' => $couponid));
    return $coupon;
}
Example #8
0
 private function FM_checkoauth()
 {
     global $_GPC, $_W;
     $uniacid = !empty($_W['uniacid']) ? $_W['uniacid'] : $_W['acid'];
     load()->model('mc');
     $openid = '';
     $nickname = '';
     $avatar = '';
     $follow = '';
     if (!empty($_W['member']['uid'])) {
         $member = mc_fetch(intval($_W['member']['uid']), array('avatar', 'nickname'));
         if (!empty($member)) {
             $avatar = $member['avatar'];
             $nickname = $member['nickname'];
         }
     }
     if (empty($avatar) || empty($nickname)) {
         $fan = mc_fansinfo($_W['openid']);
         if (!empty($fan)) {
             $avatar = $fan['avatar'];
             $nickname = $fan['nickname'];
             $openid = $fan['openid'];
             $follow = $fan['follow'];
         }
     }
     if (empty($avatar) || empty($nickname) || empty($openid) || empty($follow)) {
         $userinfo = mc_oauth_userinfo();
         if (!is_error($userinfo) && !empty($userinfo) && is_array($userinfo) && !empty($userinfo['avatar'])) {
             $avatar = $userinfo['avatar'];
         }
         if (!is_error($userinfo) && !empty($userinfo) && is_array($userinfo) && !empty($userinfo['nickname'])) {
             $nickname = $userinfo['nickname'];
         }
         if (!is_error($userinfo) && !empty($userinfo) && is_array($userinfo) && !empty($userinfo['openid'])) {
             $openid = $userinfo['openid'];
         }
         if (!is_error($userinfo) && !empty($userinfo) && is_array($userinfo) && !empty($userinfo['follow'])) {
             $follow = $userinfo['follow'];
         }
     }
     if ((empty($avatar) || empty($nickname)) && !empty($_W['member']['uid'])) {
     }
     $oauthuser = array();
     $oauthuser['avatar'] = $avatar;
     $oauthuser['nickname'] = $nickname;
     $oauthuser['from_user'] = $openid;
     $oauthuser['follow'] = !empty($follow) ? $follow : $_W['fans']['follow'];
     return $oauthuser;
 }
Example #9
0
 private function booking($message)
 {
     global $_W;
     $setting = uni_setting($_W['uniacid'], array('passport'));
     load()->model('mc');
     $fans = mc_fansinfo($message['from']);
     if (!empty($fans)) {
         $rec = array();
         if (!empty($fans['follow'])) {
             if ($message['event'] == 'unsubscribe') {
                 $rec['follow'] = 0;
                 $rec['followtime'] = 0;
                 $rec['unfollowtime'] = $message['time'];
             }
         } else {
             if ($message['event'] != 'unsubscribe' && $message['event'] != 'ShakearoundUserShake') {
                 $rec['follow'] = 1;
                 $rec['followtime'] = $message['time'];
                 $rec['unfollowtime'] = 0;
             }
         }
         $member = array();
         if (!empty($fans['uid'])) {
             $member = mc_fetch($fans['uid']);
         }
         if (empty($member)) {
             if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) {
                 $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid']));
                 $data = array('uniacid' => $_W['uniacid'], 'email' => md5($message['from']) . '@we7.cc', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP);
                 $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']);
                 pdo_insert('mc_members', $data);
                 $rec['uid'] = pdo_insertid();
             }
         }
         if (!empty($rec)) {
             pdo_update('mc_mapping_fans', $rec, array('acid' => $_W['acid'], 'openid' => $message['from'], 'uniacid' => $_W['uniacid']));
         }
     } else {
         $rec = array();
         $rec['acid'] = $_W['acid'];
         $rec['uniacid'] = $_W['uniacid'];
         $rec['uid'] = 0;
         $rec['openid'] = $message['from'];
         $rec['salt'] = random(8);
         if ($message['event'] == 'unsubscribe') {
             $rec['follow'] = 0;
             $rec['followtime'] = 0;
             $rec['unfollowtime'] = $message['time'];
         } else {
             $rec['follow'] = 1;
             $rec['followtime'] = $message['time'];
             $rec['unfollowtime'] = 0;
         }
         if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) {
             $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid']));
             $data = array('uniacid' => $_W['uniacid'], 'email' => md5($message['from']) . '@we7.cc', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP);
             $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']);
             pdo_insert('mc_members', $data);
             $rec['uid'] = pdo_insertid();
         }
         pdo_insert('mc_mapping_fans', $rec);
     }
 }
Example #10
0
            $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);
            }
        }
    }
}
$profile = mc_fetch($_W['member']['uid']);
if (!empty($profile)) {
    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]);
Example #11
0
<?php

/**
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */
defined('IN_IA') or exit('Access Denied');
$dos = array('display', 'detail');
$do = in_array($do, $dos) ? $do : 'display';
if ($do == 'display') {
    $profile = mc_fetch($_W['member']['uid'], array('nickname', 'avatar', 'mobile', 'groupid'));
    $mcgroups = mc_groups();
    $profile['group'] = $mcgroups[$profile['groupid']];
    $stores = pdo_fetchall('SELECT * FROM ' . tablename('activity_stores') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid']));
}
if ($do == 'detail') {
    $id = intval($_GPC['id']);
    $store = pdo_get('activity_stores', array('uniacid' => $_W['uniacid'], 'id' => $id));
    if (empty($store)) {
        message('门店不存在或已删除', referer(), 'error');
    }
    $store['photo_list'] = iunserializer($store['photo_list']);
    $store['category'] = iunserializer($store['category']);
}
template('mc/store');
Example #12
0
        $salt = random(8);
        $data = array('uniacid' => $_W['uniacid'], 'realname' => $realname, 'mobile' => $mobile, 'email' => $email, 'salt' => $salt, 'password' => md5(trim($_GPC['password']) . $salt . $_W['config']['setting']['authkey']), 'credit1' => intval($_GPC['credit1']), 'credit2' => intval($_GPC['credit2']), 'groupid' => intval($_GPC['groupid']), 'createtime' => TIMESTAMP);
        pdo_insert('mc_members', $data);
        $uid = pdo_insertid();
        message('添加会员成功,将进入编辑页面', url('mc/member/post', array('uid' => $uid)), 'success');
    }
}
if ($do == 'group') {
    if ($_W['isajax']) {
        $id = intval($_GPC['id']);
        $group = $_W['account']['groups'][$id];
        if (empty($group)) {
            exit('会员组信息不存在');
        }
        $uid = intval($_GPC['uid']);
        $member = mc_fetch($uid);
        if (empty($member)) {
            exit('会员信息不存在');
        }
        $credit = intval($group['credit']);
        $credit6 = $credit - $member['credit1'];
        $status = pdo_update('mc_members', array('credit6' => $credit6, 'groupid' => $id), array('uid' => $uid, 'uniacid' => $_W['uniacid']));
        if ($status !== false) {
            $openid = pdo_fetchcolumn('SELECT openid FROM ' . tablename('mc_mapping_fans') . ' WHERE acid = :acid AND uid = :uid', array(':acid' => $_W['acid'], ':uid' => $uid));
            if (!empty($openid)) {
                mc_notice_group($openid, $_W['account']['groups'][$member['groupid']]['title'], $_W['account']['groups'][$id]['title']);
            }
            exit('success');
        } else {
            exit('更新会员信息出错');
        }
Example #13
0
    mc_credit_update($_W['member']['uid'], $goods['credittype'], -1 * $goods['credit'], array($_W['member']['uid'], '礼品兑换:' . $goods['title'] . ' 消耗 ' . $creditnames[$goods['credittype']] . ':' . $goods['credit']));
    if ($goods['credittype'] == 'credit1') {
        mc_notice_credit1($_W['openid'], $_W['member']['uid'], -1 * $goods['credit'], '兑换礼品消耗积分');
    } else {
        mc_notice_credit2($_W['openid'], $_W['member']['uid'], -1 * $goods['credit'], 0, '线上消费,兑换礼品');
    }
    message(error($ret, "兑换成功,您消费了 {$goods['credit']} {$creditnames[$goods['credittype']]},现在去完善订单信息"), '', 'ajax');
}
if ($do == 'deliver') {
    load()->func('tpl');
    $tid = intval($_GPC['tid']);
    $ship = pdo_fetch('SELECT * FROM ' . tablename('activity_exchange_trades_shipping') . ' WHERE uid = :uid AND tid = :tid', array(':uid' => $_W['member']['uid'], ':tid' => $tid));
    if (empty($ship)) {
        message('没有找到该兑换的收货人信息', '', 'error');
    }
    $member = mc_fetch($_W['member']['uid'], array('uid', 'realname', 'resideprovince', 'residecity', 'residedist', 'address', 'zipcode', 'mobile'));
    $ship['name'] = !empty($ship['name']) ? $ship['name'] : $member['realname'];
    $ship['province'] = !empty($ship['province']) ? $ship['province'] : $member['resideprovince'];
    $ship['city'] = !empty($ship['city']) ? $ship['city'] : $member['residecity'];
    $ship['district'] = !empty($ship['district']) ? $ship['district'] : $member['residedist'];
    $ship['address'] = !empty($ship['address']) ? $ship['address'] : $member['address'];
    $ship['zipcode'] = !empty($ship['zipcode']) ? $ship['zipcode'] : $member['zipcode'];
    $ship['mobile'] = !empty($ship['mobile']) ? $ship['mobile'] : $member['mobile'];
    if (checksubmit('submit')) {
        $data = array('name' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'province' => $_GPC['reside']['province'], 'city' => $_GPC['reside']['city'], 'district' => $_GPC['reside']['district'], 'address' => $_GPC['address'], 'zipcode' => $_GPC['zipcode']);
        pdo_update('activity_exchange_trades_shipping', $data, array('tid' => $tid, 'uid' => $_W['member']['uid']));
        message('收货人信息更新成功', url('activity/goods/mine'));
    }
}
if ($do == 'mine') {
    $psize = 10;
Example #14
0
 public function doMobileMyOrder()
 {
     global $_W, $_GPC;
     $from_user = $this->getFromUser();
     $op = $_GPC['op'];
     if ($op == 'confirm') {
         $orderid = intval($_GPC['orderid']);
         $order = pdo_fetch("SELECT * FROM " . tablename('eso_sale_order') . " WHERE id = :id AND from_user = :from_user", array(':id' => $orderid, ':from_user' => $from_user));
         if (empty($order)) {
             message('抱歉,您的订单不存在或是已经被取消!', $this->mturl('myorder'), 'error');
         }
         pdo_update('eso_sale_order', array('status' => 3), array('id' => $orderid, 'from_user' => $from_user));
         message('确认收货完成!', $this->mturl('myorder'), 'success');
     } else {
         if ($op == 'detail') {
             $orderid = intval($_GPC['orderid']);
             $item = pdo_fetch("SELECT * FROM " . tablename('eso_sale_order') . " WHERE uniacid = '{$_W['uniacid']}' AND from_user = '******' and id='{$orderid}' limit 1");
             if (empty($item)) {
                 message('抱歉,您的订单不存或是已经被取消!', $this->mturl('myorder'), 'error');
             }
             $goodsid = pdo_fetchall("SELECT goodsid,total FROM " . tablename('eso_sale_order_goods') . " WHERE orderid = '{$orderid}'", array(), 'goodsid');
             $goods = pdo_fetchall("SELECT g.id, g.title, g.thumb, g.unit, g.marketprice,o.total,o.optionid FROM " . tablename('eso_sale_order_goods') . " o left join " . tablename('eso_sale_goods') . " g on o.goodsid=g.id " . " WHERE o.orderid='{$orderid}'");
             foreach ($goods as &$g) {
                 //属性
                 $option = pdo_fetch("select title,marketprice,weight,stock from " . tablename("eso_sale_goods_option") . " where id=:id limit 1", array(":id" => $g['optionid']));
                 if ($option) {
                     $g['title'] = "[" . $option['title'] . "]" . $g['title'];
                     $g['marketprice'] = $option['marketprice'];
                 }
             }
             unset($g);
             $dispatch = pdo_fetch("select id,dispatchname from " . tablename('eso_sale_dispatch') . " where id=:id limit 1", array(":id" => $item['dispatch']));
             include $this->template('order_detail');
         } else {
             $pindex = max(1, intval($_GPC['page']));
             $psize = 20;
             $status = intval($_GPC['status']);
             $where = " uniacid = '{$_W['uniacid']}' AND from_user = '******'";
             if ($status == 2) {
                 $where .= " and ( status=1 or status=2 )";
             } else {
                 $where .= " and status={$status}";
             }
             $list = pdo_fetchall("SELECT * FROM " . tablename('eso_sale_order') . " WHERE {$where} ORDER BY id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(), 'id');
             $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('eso_sale_order') . " WHERE uniacid = '{$_W['uniacid']}' AND from_user = '******'");
             $pager = pagination($total, $pindex, $psize);
             if (!empty($list)) {
                 foreach ($list as &$row) {
                     $goods = pdo_fetchall("SELECT g.id, g.title, g.thumb, g.unit, g.marketprice,o.total,o.optionid FROM " . tablename('eso_sale_order_goods') . " o left join " . tablename('eso_sale_goods') . " g on o.goodsid=g.id " . " WHERE o.orderid='{$row['id']}'");
                     foreach ($goods as &$item) {
                         //属性
                         $option = pdo_fetch("select title,marketprice,weight,stock from " . tablename("eso_sale_goods_option") . " where id=:id limit 1", array(":id" => $item['optionid']));
                         if ($option) {
                             $item['title'] = "[" . $option['title'] . "]" . $item['title'];
                             $item['marketprice'] = $option['marketprice'];
                         }
                     }
                     unset($item);
                     $row['goods'] = $goods;
                     $row['total'] = $goodsid;
                     $row['dispatch'] = pdo_fetch("select id,dispatchname from " . tablename('eso_sale_dispatch') . " where id=:id limit 1", array(":id" => $row['dispatch']));
                 }
             }
             $carttotal = $this->getCartTotal();
             load()->model('mc');
             $fans = mc_fetch($_W['member']['uid']);
             include $this->template('order');
         }
     }
 }
Example #15
0
 public function doMobileOrderConfirmUpdate()
 {
     global $_W, $_GPC;
     $weid = $this->_weid;
     $from_user = $_GPC['from_user'];
     $this->_fromuser = $from_user;
     $orderid = intval($_GPC['orderid']);
     $storeid = intval($_GPC['storeid']);
     $paytype = intval($_GPC['paytype']);
     $order = pdo_fetch("SELECT * FROM " . tablename($this->modulename . '_order') . " WHERE id=:id AND weid=:weid AND storeid=:storeid", array(':id' => $orderid, ':weid' => $weid, ':storeid' => $storeid));
     if (!empty($order)) {
         if ($order['status'] == 1) {
             $this->showMessageAjax('该订单已经确认过了,无需重复提交!', $this->msg_status_bad);
         }
     }
     if ($paytype == 0) {
         pdo_query("UPDATE " . tablename($this->modulename . '_order') . " SET status=1,paytype=:paytype WHERE id=:id", array(':id' => $orderid, ':paytype' => $paytype));
     }
     //余额支付处理
     if ($paytype == 1) {
         //ims_mc_card
         $module = pdo_fetch("SELECT * FROM " . tablename("mc_card") . " WHERE uniacid=:uniacid ", array(':uniacid' => $weid));
         if (empty($module) || $module['status'] == 0) {
             $this->showMessageAjax('系统没开通会员卡功能!', $this->msg_status_bad);
         }
         load()->model('mc');
         $fans = mc_fetch($from_user);
         if (!empty($fans)) {
             $card = pdo_fetch("SELECT * FROM " . tablename("mc_card_members") . " WHERE uniacid=:uniacid AND uid=:uid ", array(':uniacid' => $weid, ':uid' => $fans['uid']));
         }
         if (empty($card)) {
             $this->showMessageAjax('抱歉,您还没有领取会员卡!不能使用余额支付,请选择其它的支付方式!', $this->msg_status_bad);
         } else {
             $totalprice = floatval($order['totalprice']);
             $credit2 = floatval($fans['credit2']);
             if ($credit2 >= $totalprice) {
                 $uid = mc_openid2uid($from_user);
                 $remark = '微点餐余额消费 ' . $totalprice . ' 元 订单ID:' . $orderid;
                 $log = array();
                 $log[0] = $uid;
                 $log[1] = $remark;
                 mc_credit_update($fans['uid'], 'credit2', -$totalprice, $log);
                 pdo_query("UPDATE " . tablename($this->modulename . '_order') . " SET status=2,paytype=1 WHERE id=:id", array(':id' => $orderid));
             } else {
                 $this->showMessageAjax('抱歉,您的余额不足以支付本次消费!不能使用余额支付,请选择其它的支付方式!', $this->msg_status_bad);
             }
         }
         //            $module = $this->checkModule('icard');
         //            if (empty($module)) {
         //                $this->showMessageAjax('系统没开通会员卡功能!', $this->msg_status_bad);
         //            }
         //            //会员卡
         //            $card = get_user_card($from_user);
         //            if (empty($card)) {
         //                $this->showMessageAjax('抱歉,您还没有领取会员卡!不能使用余额支付,请选择其它的支付方式!', $this->msg_status_bad);
         //            } else {
         //                //积分策略
         //                $card_score = get_card_score();
         //                if (!empty($card_score)) {
         //                    //每1元奖励的积分数
         //                    $payx_score = intval($card_score['payx_score']);
         //                    if ($payx_score > 0) {
         //                        $reward_score = intval($payx_score * $order['totalprice']);
         //                    }
         //                }
         //
         //                //更新会员卡余额、总消费金额、剩余积分、总积分、消费积分//card
         //                $sql_update_card_coin = "UPDATE " . tablename('icard_card') . " SET total_score=total_score+:score,balance_score=balance_score+:score,spend_score=spend_score+:score,money=money+:money,coin=coin-:money WHERE from_user=:from_user and weid=:weid";
         //                $execute_rows = pdo_query(
         //                    $sql_update_card_coin,
         //                    array(
         //                        ':score' => $reward_score,
         //                        ':money' => $order['totalprice'],
         //                        ':from_user' => $from_user,
         //                        ':weid' => $weid)
         //                );
         //
         //                if ($execute_rows) {
         //                    //消费金额记录
         //                    $data_money = array(
         //                        'weid' => $_W['uniacid'],
         //                        'from_user' => $from_user,
         //                        'giftid' => $order['id'],
         //                        'type' => 6,
         //                        'payment' => 1, //余额卡消费
         //                        'outletid' => -2,
         //                        'money' => $order['totalprice'],
         //                        'score' => $reward_score,
         //                        'dateline' => TIMESTAMP
         //                    );
         //                    pdo_insert('icard_money_log', $data_money);
         //                    $data_announce = array(
         //                        'weid' => $weid,
         //                        'giftid' => $order['id'],
         //                        'from_user' => $from_user,
         //                        'type' => 6,
         //                        'title' => '微餐饮消费',
         //                        'content' => "您好,您的会员卡于" . date('Y-m-d H:i:s', TIMESTAMP) . "在微点餐使用余额消费订单号为" . $order['ordersn'] . ",本次消费金额为" . $order['totalprice'] . "元,获得" . $reward_score . "个积分。",
         //                        'money' => $order['totalprice']
         //                    );
         //                    add_announce($data_announce);
         //                }
         //            }
         //            pdo_query("UPDATE " . tablename($this->modulename . '_order') . " SET status=2 WHERE id=:id", array(':id' => $orderid));
     }
     //发送短信提醒
     $smsSetting = pdo_fetch("SELECT * FROM " . tablename($this->modulename . '_sms_setting') . " WHERE weid=:weid AND storeid=:storeid LIMIT 1", array(':weid' => $weid, ':storeid' => $storeid));
     $sendInfo = array();
     $goods_str = '';
     //本订单产品
     $goods = pdo_fetchall("SELECT a.*,b.title,b.unitname FROM " . tablename($this->modulename . '_order_goods') . " as a left join  " . tablename($this->modulename . '_goods') . " as b on a.goodsid=b.id WHERE a.weid = '{$weid}' and a.orderid={$orderid}");
     $goods_str = '';
     $flag = false;
     foreach ($goods as $key => $value) {
         if (!$flag) {
             $goods_str .= "{$value['title']}---{$value['total']}{$value['unitname']}";
             $flag = true;
         } else {
             $goods_str .= "<br/>{$value['title']}{$value['total']}{$value['unitname']}";
         }
     }
     if (!empty($smsSetting)) {
         if ($smsSetting['sms_enable'] == 1 && !empty($smsSetting['sms_mobile'])) {
             //模板
             if (empty($smsSetting['sms_business_tpl'])) {
                 $smsSetting['sms_business_tpl'] = '您有新的订单:[sn],收货人:[name],电话:[tel],请及时确认订单!';
             }
             //订单号
             $smsSetting['sms_business_tpl'] = str_replace('[sn]', $order['ordersn'], $smsSetting['sms_business_tpl']);
             //用户名
             $smsSetting['sms_business_tpl'] = str_replace('[name]', $order['username'], $smsSetting['sms_business_tpl']);
             //就餐时间
             $smsSetting['sms_business_tpl'] = str_replace('[date]', $order['meal_time'], $smsSetting['sms_business_tpl']);
             //电话
             $smsSetting['sms_business_tpl'] = str_replace('[tel]', $order['tel'], $smsSetting['sms_business_tpl']);
             $smsSetting['sms_business_tpl'] = str_replace('[totalnum]', $order['totalnum'], $smsSetting['sms_business_tpl']);
             $smsSetting['sms_business_tpl'] = str_replace('[totalprice]', $order['totalprice'], $smsSetting['sms_business_tpl']);
             $smsSetting['sms_business_tpl'] = str_replace('[address]', $order['address'], $smsSetting['sms_business_tpl']);
             $smsSetting['sms_business_tpl'] = str_replace('[remark]', $order['remark'], $smsSetting['sms_business_tpl']);
             $smsSetting['sms_business_tpl'] = str_replace('[goods]', $goods_str, $smsSetting['sms_business_tpl']);
             //$sendInfo['username'] = $smsSetting['sms_username'];
             //$sendInfo['pwd'] = $smsSetting['sms_pwd'];
             $sendInfo['mobile'] = $smsSetting['sms_mobile'];
             $sendInfo['content'] = $smsSetting['sms_business_tpl'];
             //debug
             $return_result_code = $this->_sendSms($sendInfo);
             $this->sms_status[$return_result_code];
         }
     }
     //发送邮件提醒
     $emailSetting = pdo_fetch("SELECT * FROM " . tablename($this->modulename . '_email_setting') . " WHERE weid=:weid AND storeid=:storeid LIMIT 1", array(':weid' => $weid, ':storeid' => $storeid));
     $email_tpl = $emailSetting['email_business_tpl'];
     //您有新的订单:[sn],收货人:[name],菜单:[goods],电话:[tel],请及时确认订单!
     $email_tpl = "\n        您有新订单:<br/>\n        单号[sn] 总数量:[totalnum] 总价:[totalprice]<br/>\n        菜单:[goods]<br/>\n        姓名:[name]<br/>\n        电话:[tel]<br/>\n        桌号:[tables]<br/>\n        备注:[remark]\n        ";
     if ($order['dining_mode'] == 2) {
         $email_tpl = "\n        您有新订单:<br/>\n        单号[sn] 总数量:[totalnum] 总价:[totalprice]<br/>\n        收货人:[name]<br/>\n        菜单:<br/>[goods]<br/>\n        电话:[tel]<br/>\n        地址:[address]<br>\n        备注:[remark]\n        ";
     }
     if (!empty($emailSetting) && !empty($emailSetting['email'])) {
         $email_tpl = str_replace('[sn]', $order['ordersn'], $email_tpl);
         //用户名
         $email_tpl = str_replace('[name]', $order['username'], $email_tpl);
         //就餐时间
         $email_tpl = str_replace('[date]', $order['meal_time'], $email_tpl);
         //电话
         $email_tpl = str_replace('[tel]', $order['tel'], $email_tpl);
         $email_tpl = str_replace('[tables]', $order['tables'], $email_tpl);
         $email_tpl = str_replace('[goods]', $goods_str, $email_tpl);
         $email_tpl = str_replace('[totalnum]', $order['totalnum'], $email_tpl);
         $email_tpl = str_replace('[totalprice]', $order['totalprice'], $email_tpl);
         $email_tpl = str_replace('[address]', $order['address'], $email_tpl);
         $email_tpl = str_replace('[remark]', $order['remark'], $email_tpl);
         if ($emailSetting['email_host'] == 'smtp.qq.com' || $emailSetting['email_host'] == 'smtp.gmail.com') {
             $secure = 'ssl';
             $port = '465';
         } else {
             $secure = 'tls';
             $port = '25';
         }
         $mail_config = array();
         //$mail_config['host'] = $emailSetting['email_host'];
         //$mail_config['secure'] = $secure;
         //$mail_config['port'] = $port;
         //$mail_config['username'] = $emailSetting['email_user'];
         //$mail_config['sendmail'] = $emailSetting['email_send'];
         //$mail_config['password'] = $emailSetting['email_pwd'];
         $mail_config['mailaddress'] = $emailSetting['email'];
         $mail_config['subject'] = '订单提醒';
         $mail_config['body'] = $email_tpl;
         $result = $this->sendmail($mail_config);
     }
     $this->showMessageAjax('订单确认成功,请等待处理!', $this->msg_status_success);
 }
Example #16
0
    $pager = pagination($total, $pindex, $psize);
}
if ($do == 'deliver') {
    $exid = intval($_GPC['exid']);
    $sql = 'SELECT * FROM ' . tablename('activity_exchange_trades_shipping') . ' WHERE uid = :uid AND exid = :exid';
    $ship = pdo_fetch($sql, array(':uid' => $_W['member']['uid'], ':exid' => $exid));
    if (checksubmit('submit')) {
        $data = array('name' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'province' => $_GPC['reside']['province'], 'city' => $_GPC['reside']['city'], 'district' => $_GPC['reside']['district'], 'address' => $_GPC['address'], 'zipcode' => $_GPC['zipcode']);
        if (empty($ship)) {
            $data['uniacid'] = $_W['uniacid'];
            $data['exid'] = $exid;
            $data['uid'] = $_W['member']['uid'];
            $data['createtime'] = TIMESTAMP;
            pdo_insert('activity_exchange_trades_shipping', $data);
        } else {
            pdo_update('activity_exchange_trades_shipping', $data, array('exid' => $exid, 'uid' => $_W['member']['uid']));
        }
        message('收货人信息更新成功', url('activity/partimes/mine'));
    }
    if (empty($ship)) {
        $getInfo = array('uid', 'realname', 'resideprovince', 'residecity', 'residedist', 'address', 'zipcode', 'mobile');
        $ship = mc_fetch($_W['member']['uid'], $getInfo);
        $ship['name'] = $ship['realname'];
        $ship['province'] = $ship['resideprovince'];
        $ship['city'] = $ship['residecity'];
    } else {
        $ship['residedist'] = $ship['district'];
    }
    load()->func('tpl');
}
template('activity/partimes');
Example #17
0
$current_date = strtotime($current_date);
$today_allsigned_info = pdo_fetchall("SELECT * FROM " . tablename('nsign_record') . " WHERE `sign_time` >= :current_date ", array(':current_date' => $current_date));
$today_allsigned_num = count($today_allsigned_info);
$today_user_rank = $today_allsigned_num + 1;
$today_usersigned_info = pdo_fetchall("SELECT * FROM " . tablename('nsign_record') . " WHERE `uid` = :uid AND sign_time >= :current_date ", array(':uid' => $uid, ':current_date' => $current_date));
$today_usersigned_num = count($today_usersigned_info);
$user_lastsign_info = pdo_fetch("SELECT * FROM " . tablename('nsign_record') . " WHERE `uid` = :uid ORDER BY sign_time DESC LIMIT 1 ", array(':uid' => $uid));
$user_last_sign_time = $user_lastsign_info['last_sign_time'];
//$user_last_sign_rank = $user_lastsign_info['last_sign_rank'];
$user_continue_sign_days = $user_lastsign_info['continue_sign_days'];
$user_maxcontinue_sign_days = $user_lastsign_info['maxcontinue_sign_days'];
$user_first_sign_days = $user_lastsign_info['first_sign_days'];
$user_maxfirst_sign_days = $user_lastsign_info['maxfirst_sign_days'];
$user_allsign_num = $user_lastsign_info['total_sign_num'];
$user_maxallsign_num = $user_lastsign_info['maxtotal_sign_num'];
$profile = mc_fetch($uid, array('realname', 'mobile', 'credit1'));
if (!empty($uid)) {
    if (!empty($profile['realname']) && !empty($profile['mobile'])) {
        if ($now >= $start_day && $now <= $end_day) {
            //在活动日期内
            if ($now >= $start_time && $now <= $end_time) {
                //在活动时间内
                if ($today_usersigned_num == 0) {
                    if ($user_last_sign_time == 0) {
                        $user_last_sign_time = $now;
                    }
                    if ($now - $user_last_sign_time < 86400) {
                        $continue_sign_days = $user_continue_sign_days + 1;
                    } else {
                        $continue_sign_days = 0;
                    }
Example #18
0
 protected function extend_W()
 {
     global $_W;
     if (!empty($_W['openid'])) {
         load()->model('mc');
         $_W['member'] = mc_fetch($_W['openid']);
     }
     if (empty($_W['member'])) {
         $_W['member'] = array();
     }
     if (!empty($_W['acid'])) {
         load()->model('account');
         if (empty($_W['uniaccount'])) {
             $_W['uniaccount'] = uni_fetch($_W['uniacid']);
         }
         if (empty($_W['account'])) {
             $_W['account'] = account_fetch($_W['acid']);
             $_W['account']['qrcode'] = "{$_W['attachurl']}qrcode_{$_W['acid']}.jpg?time={$_W['timestamp']}";
             $_W['account']['avatar'] = "{$_W['attachurl']}headimg_{$_W['acid']}.jpg?time={$_W['timestamp']}";
             $_W['account']['groupid'] = $_W['uniaccount']['groupid'];
         }
     }
 }
Example #19
0
 public function doMobileMessage()
 {
     global $_GPC, $_W;
     $op = trim($_GPC['op']) ? trim($_GPC['op']) : 'list';
     $set = pdo_fetch("SELECT * FROM " . tablename('we7car_message_set') . " WHERE weid = :weid ORDER BY `id` DESC LIMIT 1", array(':weid' => $_W['uniacid']));
     if ($set == false) {
         $set = array('status' => 1, 'isshow' => 1);
     }
     if ($op == 'list') {
         if ($set['status'] == 0) {
             message('留言墙尚未开启,请耐心等待');
         }
         $total = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('we7car_message_list') . " WHERE fid = 0 AND isshow = 1 AND weid = :weid", array(':weid' => $_W['uniacid']));
         $pindex = max(1, intval($_GPC['page']));
         $psize = 20;
         $pager = pagination($total, $pindex, $psize);
         $messagelist = pdo_fetchall("SELECT * FROM " . tablename('we7car_message_list') . " WHERE  weid = :weid and fid=0 and isshow=1  ORDER BY create_time DESC  LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':weid' => $_W['uniacid']));
         foreach ($messagelist as &$v) {
             $v['reply'] = pdo_fetchall("SELECT * FROM " . tablename('we7car_message_list') . " WHERE  weid = :weid AND fid = :fid AND isshow=1  LIMIT 20", array(':weid' => $_W['uniacid'], ':fid' => $v['id']));
         }
         //获取fans表中的username
         // $nickname = pdo_fetchcolumn("SELECT `nickname` FROM " . tablename('fans') . " WHERE weid = :weid AND `from_user` = :from_user LIMIT 1", array(':from_user' => $_W['fans']['from_user'], ':weid' => $_W['uniacid']));
         $mc = mc_require($_W['member']['uid'], array('nickname'));
         $nickname = $m['nickname'];
         include $this->template('message_list');
     }
     if ($op == 'ajax') {
         if (empty($_W['fans']['from_user'])) {
             $data['msg'] = '登陆过期,请重新从微信进入!';
             $data['success'] = false;
         } else {
             $sql = "SELECT * FROM " . tablename('we7car_message_list') . " WHERE from_user = :from_user AND weid = :weid ORDER BY id DESC";
             $params = array(':weid' => $_W['uniacid'], ':from_user' => $_W['fans']['from_user']);
             $message = pdo_fetch($sql, $params);
             $insert = array('weid' => $_W['uniacid'], 'nickname' => trim($_GPC['nickname']), 'info' => trim($_GPC['info']), 'fid' => intval($_GPC['fid']), 'from_user' => $_W['fans']['from_user'], 'isshow' => $set['isshow'], 'create_time' => TIMESTAMP);
             if (empty($insert['nickname'])) {
                 if (empty($_W['member']['uid'])) {
                     $sql = "SELECT nickname FROM " . tablename('mc_mapping_fans') . " WHERE uniacid = :uniacid  AND openid = :from_user";
                     $params = array(':uniacid' => $_W['uniacid'], ':from_user' => $_W['fans']['from_user']);
                     $nickname = pdo_fetchcolumn($sql, $params);
                     if (empty($nickname)) {
                         $nickname = $_W['fans']['from_user'];
                     }
                 } else {
                     load()->model('mc');
                     $nickname = mc_fetch($_W['member']['uid'], array('nickname'));
                     $nickname = $nickname['nickname'];
                 }
                 $insert['nickname'] = $nickname;
             }
             if (empty($message)) {
                 $id = pdo_insert('we7car_message_list', $insert);
                 $data['success'] = true;
                 $data['msg'] = '留言发表成功';
                 if ($set['isshow'] == 0) {
                     $data['msg'] = $data['msg'] . ',进入审核流程';
                 }
             } else {
                 if (TIMESTAMP - $message['create_time'] < 5) {
                     $data['msg'] = '您的留言太过频繁,请5秒后留言';
                     $data['success'] = false;
                 } else {
                     $id = pdo_insert('we7car_message_list', $insert);
                     $data['success'] = true;
                     $data['msg'] = '留言发表成功';
                     if ($set['isshow'] == 0) {
                         $data['msg'] = $data['msg'] . ',进入审核流程';
                     }
                 }
             }
         }
         echo json_encode($data);
     }
 }
Example #20
0
 public function doMobileorderdetail()
 {
     global $_GPC, $_W;
     $weid = $this->_weid;
     $id = $_GPC['id'];
     $this->check_login();
     if (empty($id)) {
         $url = $this->createMobileUrl('orderlist');
         header("Location: {$url}");
     }
     $memberid = $this->_user_info['id'];
     if (empty($memberid)) {
         $url = $this->createMobileUrl('index');
         header("Location: {$url}");
     }
     $sql = "SELECT o.*, h.title, h.address, h.phone, h.thumb";
     $sql .= " FROM " . tablename('hotel2_order') . " AS o";
     $sql .= " LEFT JOIN " . tablename('hotel2') . " AS h ON o.hotelid = h.id";
     $sql .= " WHERE 1 = 1";
     $sql .= " AND o.id = :id";
     $sql .= " AND o.memberid = :memberid";
     $sql .= " AND o.weid = :weid";
     $params = array();
     $params[':memberid'] = $memberid;
     $params[':weid'] = $weid;
     $params[':id'] = $id;
     $sql .= " LIMIT 1";
     $item = pdo_fetch($sql, $params);
     if ($this->_set_info['is_unify'] == 1) {
         $tel = $this->_set_info['tel'];
     } else {
         $tel = $item['phone'];
     }
     if (!empty($_W['member']['uid'])) {
         $member = mc_fetch($_W['member']['uid'], array('credit1', 'credit2'));
     }
     $params['module'] = "ewei_hotel";
     $params['ordersn'] = $item['ordersn'];
     $params['tid'] = $item['id'];
     $params['user'] = $_W['fans']['from_user'];
     $params['fee'] = $item['sum_price'];
     $params['title'] = $_W['account']['name'] . "酒店订单{$item['ordersn']}";
     // 设置分享信息
     $shareDesc = $item['address'];
     $shareThumb = tomedia($item['thumb']);
     include $this->template('orderdetail');
 }
Example #21
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');
     }
 }
Example #22
0
        if ($_W['setting']['authmode'] == 2 && abs($auth['time'] - TIMESTAMP) < 180 || $_W['setting']['authmode'] == 1) {
            $fan = mc_fansinfo($auth['openid'], $auth['acid'], $_W['uniacid']);
            if (!empty($fan)) {
                $hash = md5("{$auth['openid']}{$auth['time']}{$fan['salt']}{$_W['config']['setting']['authkey']}");
                if ($auth['hash'] == $hash) {
                    if ($_W['setting']['authmode'] == 2) {
                        $rec = array();
                        do {
                            $rec['salt'] = random(8);
                        } while ($rec['salt'] == $fan['salt']);
                        pdo_update('mc_mapping_fans', $rec, array('uniacid' => $_W['uniacid'], 'acid' => $auth['acid'], 'openid' => $auth['openid']));
                    }
                    $_SESSION['uniacid'] = $_W['uniacid'];
                    $_SESSION['acid'] = $auth['acid'];
                    $_SESSION['openid'] = $auth['openid'];
                    $member = mc_fetch($fan['uid']);
                    if (!empty($member)) {
                        $_SESSION['uid'] = $fan['uid'];
                    }
                }
            }
        }
    }
}
$forward = @base64_decode($_GPC['forward']);
if (empty($forward)) {
    $forward = url('mc');
} else {
    $forward = strexists($forward, 'http://') || strexists($forward, 'https://') ? $forward : $_W['siteroot'] . 'app/' . $forward;
}
if (strexists($forward, '#')) {
Example #23
0
<?php

global $_GPC, $_W;
checkauth();
$rid = intval($_GPC['rid']);
$uid = $_W['member']['uid'];
${$fields} = array('realname', 'mobile');
$profile = mc_fetch($uid, $fields);
include $this->template('userinfo');
Example #24
0
             $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');
 }
 load()->func('tpl');
 $groups = mc_groups($_W['uniacid']);
 $profile = mc_fetch($uid);
 if (!empty($profile)) {
     if (empty($profile['email']) || !empty($profile['email']) && substr($profile['email'], -6) == 'wdlcms.com' && strlen($profile['email']) == 39) {
         $profile['email_effective'] = 1;
         $profile['email'] = '';
     } else {
         $profile['email_effective'] = 2;
     }
 }
 if (empty($uid)) {
     $fanid = intval($_GPC['fanid']);
     $tag = pdo_fetchcolumn('SELECT tag FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid = :uniacid AND fanid = :fanid', array(':uniacid' => $_W['uniacid'], ':fanid' => $fanid));
     if (is_base64($tag)) {
         $tag = base64_decode($tag);
     }
     if (is_serialized($tag)) {
Example #25
0
function mc_handsel($touid, $fromuid, $handsel, $uniacid = '')
{
    global $_W;
    $touid = intval($touid);
    $fromuid = intval($fromuid);
    if (empty($uniacid)) {
        $uniacid = $_W['uniacid'];
    }
    $touid_exist = mc_fetch($touid, array('uniacid'));
    if (empty($touid_exist)) {
        return error(-1, '赠送积分用户不存在');
    }
    if (empty($handsel['module'])) {
        return error(-1, '没有填写模块名称');
    }
    if (empty($handsel['sign'])) {
        return error(-1, '没有填写赠送积分对象信息');
    }
    if (empty($handsel['action'])) {
        return error(-1, '没有填写赠送积分动作');
    }
    $credit_value = intval($handsel['credit_value']);
    $sql = 'SELECT id FROM ' . tablename('mc_handsel') . ' WHERE uniacid = :uniacid AND touid = :touid AND fromuid = :fromuid AND module = :module AND sign = :sign AND action = :action';
    $parm = array(':uniacid' => $uniacid, ':touid' => $touid, ':fromuid' => $fromuid, ':module' => $handsel['module'], ':sign' => $handsel['sign'], ':action' => $handsel['action']);
    $handsel_exists = pdo_fetch($sql, $parm);
    if (!empty($handsel_exists)) {
        return error(-1, '已经赠送过积分,每个用户只能赠送一次');
    }
    $creditbehaviors = pdo_fetchcolumn('SELECT creditbehaviors FROM ' . tablename('uni_settings') . ' WHERE uniacid = :uniacid', array(':uniacid' => $uniacid));
    $creditbehaviors = iunserializer($creditbehaviors) ? iunserializer($creditbehaviors) : array();
    if (empty($creditbehaviors['activity'])) {
        return error(-1, '公众号没有配置积分行为参数');
    } else {
        $credittype = $creditbehaviors['activity'];
    }
    $data = array('uniacid' => $uniacid, 'touid' => $touid, 'fromuid' => $fromuid, 'module' => $handsel['module'], 'sign' => $handsel['sign'], 'action' => $handsel['action'], 'credit_value' => $credit_value, 'createtime' => TIMESTAMP);
    pdo_insert('mc_handsel', $data);
    $log = array($fromuid, $handsel['credit_log']);
    mc_credit_update($touid, $credittype, $credit_value, $log);
    return true;
}
Example #26
0
 public function doMobileviewlihe()
 {
     //分享页面显示。
     global $_GPC, $_W;
     $weid = $_W['uniacid'];
     //当前公众号ID
     $rid = $_GPC['rid'];
     //当前规则ID
     $fromuser = authcode(base64_decode($_GPC['fromuser']), 'DECODE');
     $page_fromuser = $_GPC['fromuser'];
     $uid = $_GPC['info-prize2'];
     //礼盒分享人ID
     //活动规则
     if (!empty($rid)) {
         $reply = pdo_fetch("SELECT * FROM " . tablename($this->table_reply) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid));
         $picture = toimage($reply['picture']);
         $picbg01 = toimage($reply['picbg01']);
         $bgcolor = $reply['bgcolor'];
         $text01color = $reply['text01color'];
         $text02color = $reply['text02color'];
         $text03color = $reply['text03color'];
         $text04color = $reply['text04color'];
         $text05color = $reply['text05color'];
         $picnojiang = toimage($reply['picnojiang']);
         if ($reply['status'] == 0) {
             $statpraisetitle = '<h1>活动暂停!请稍候再试!</h1>';
         }
         if (time() < $reply['start_time']) {
             //判断活动是否已经开始
             $statpraisetitle = '<h1>活动未开始!</h1>';
         } elseif (time() > $reply['end_time']) {
             //判断活动是否已经结束
             $statpraisetitle = '<h1>活动已结束!</h1>';
         }
     }
     //虚拟人数据配置
     $now = time();
     if ($now - $reply['xuninum_time'] > $reply['xuninumtime']) {
         pdo_update($this->table_reply, array('xuninum_time' => $now, 'xuninum' => $reply['xuninum'] + mt_rand($reply['xuninuminitial'], $reply['xuninumending'])), array('rid' => $rid));
     }
     //虚拟人数据配置
     //判断是否还可以领取礼盒
     if (!empty($fromuser)) {
         $giftnum = pdo_fetchcolumn("SELECT count(*) FROM " . tablename($this->table_list) . " WHERE weid=" . $weid . " AND rid= " . $rid . " AND from_user='******'");
         //领取礼盒数总数
         $todaytimestamp = strtotime(date('Y-m-d'));
         $daygiftnum = pdo_fetchcolumn("SELECT count(*) FROM " . tablename($this->table_list) . " WHERE weid=" . $weid . " AND rid= " . $rid . " AND from_user='******' AND datatime >= '" . $todaytimestamp . "'");
         //领取礼盒数今日数
         $gift_num = $reply['number_num'] - $giftnum;
         //总数还有多少次机会
         $gift_num_day = $reply['number_num_day'] - $daygiftnum;
         //今日还有多少次机会
         $giftlihe = 0;
         //默认没有机会
         if ($gift_num >= 1) {
             if ($gift_num_day >= 1) {
                 if ($gift_num < $gift_num_day) {
                     $giftlihe = $gift_num;
                 } else {
                     $giftlihe = $gift_num_day;
                 }
             }
         }
         //查询是否可以重复中奖,不允许时中奖用户即使有领取礼盒机会也不能中领取礼盒
         if ($reply['repeatzj'] == 0) {
             $zhongjiangnum = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename($this->table_list) . ' WHERE weid= :weid and rid= :rid and zhongjiang>=1 and from_user= :from_user', array(':weid' => $weid, ':rid' => $rid, ':from_user' => $fromuser));
             if ($zhongjiangnum >= 1) {
                 $giftlihe = 0;
                 //只能中奖一次,已没有机会了
             }
         }
         //查询是否可以重复中奖,不允许时中奖用户即使有领取礼盒机会也不能中领取礼盒
     }
     //中奖礼盒信息
     $lihegift = pdo_fetch('SELECT a.zhongjiang,a.mikaid,b.* FROM ' . tablename($this->table_list) . ' as a left join ' . tablename($this->table_gift) . ' as b on a.liheid=b.id  WHERE a.id=:id', array(':id' => $uid));
     $zhongjiang = $lihegift['zhongjiang'];
     //查询是是否为密卡类开始
     if ($lihegift['inkind'] == 0 && $zhongjiang == 1 && $lihegift['mikaid'] >= 1) {
         $mikaid = pdo_fetch("SELECT * FROM " . tablename($this->table_giftmika) . " WHERE id=:id", array(':id' => $lihegift['mikaid']));
     }
     //查询是是否为密卡类完成
     //兑奖地点区域选择
     if ($reply['awarding'] == 1) {
     } else {
     }
     $lihegift['awardpic'] = empty($lihegift['awardpic']) ? "../addons/stonefish_chailihe/template/images/award.jpg" : $lihegift['awardpic'];
     $awardpic = toimage($lihegift['awardpic']);
     $againreglihe = $_W['siteroot'] . "app/" . substr($this->createMobileUrl('reglihe', array('rid' => $rid, 'fromuser' => $page_fromuser), true), 2);
     $shareurl = $_W['siteroot'] . "app/" . substr($this->createMobileUrl('shareuserview', array('rid' => $rid), true), 2);
     $liheduijiang = $_W['siteroot'] . "app/" . substr($this->createMobileUrl('duijiang', array('rid' => $rid, 'fromuser' => $page_fromuser), true), 2);
     $mylihe = $_W['siteroot'] . "app/" . substr($this->createMobileUrl('mylihe', array('rid' => $rid, 'fromuser' => $page_fromuser), true), 2);
     $gohome = $_W['siteroot'] . "app/" . substr($this->createMobileUrl('chailihe', array('rid' => $rid, 'from_user_oauth' => $page_fromuser), true), 2);
     $gotoduijiang = $_W['siteroot'] . "app/" . substr($this->createMobileUrl('viewlihe', array('rid' => $rid, 'info-prize2' => $uid, 'fromuser' => $page_fromuser), true), 2);
     //查询分享标题以及内容变量
     $reply['sharetitle'] = $this->get_share($weid, $rid, $fromuser, $reply['sharetitle'], $lihegift['id']);
     $reply['sharecontent'] = $this->get_share($weid, $rid, $fromuser, $reply['sharecontent'], $lihegift['id']);
     //判断是否被屏蔽
     $mystatus = pdo_fetch("SELECT status FROM " . tablename($this->table_list) . " WHERE from_user = '******' and weid = '" . $weid . "' and rid= '" . $rid . "' order by `status` asc");
     if (!empty($mystatus)) {
         //查询是否有记录
         if ($mystatus['status'] == 0) {
             $message = "亲," . $reply['title'] . "活动中您可能有作弊行为已被管理员暂停了!请联系" . $_W['account']['name'];
             include $this->template('reminds');
             exit;
         }
     }
     //判断是否被屏蔽
     //查询是否需要重新填写中奖资料
     if ($reply['isrealname']) {
         $userinfos .= 'realname,';
     }
     if ($reply['ismobile']) {
         $userinfos .= 'mobile,';
     }
     if ($reply['isqq']) {
         $userinfos .= 'qq,';
     }
     if ($reply['isemail']) {
         $userinfos .= 'email,';
     }
     if ($reply['isaddress']) {
         $userinfos .= 'address,';
     }
     $userinfos = substr($userinfos, 0, strlen($userinfos) - 1);
     $userinfo = pdo_fetchall("SELECT " . $userinfos . " FROM " . tablename($this->table_list) . " WHERE from_user = '******' and weid = '" . $weid . "' and rid= '" . $rid . "'");
     foreach ($userinfo as $userinfolist) {
         if ($reply['isrealname']) {
             if (empty($userinfolist['realname'])) {
                 $isinfo = true;
                 break;
             }
         }
         if ($reply['ismobile']) {
             if (empty($userinfolist['mobile'])) {
                 $isinfo = true;
                 break;
             }
         }
         if ($reply['isqq']) {
             if (empty($userinfolist['qq'])) {
                 $isinfo = true;
                 break;
             }
         }
         if ($reply['isemail']) {
             if (empty($userinfolist['email'])) {
                 $isinfo = true;
                 break;
             }
         }
         if ($reply['isaddress']) {
             if (empty($userinfolist['address'])) {
                 $isinfo = true;
                 break;
             }
         }
     }
     $userinfosave = $_W['siteroot'] . "app/" . substr($this->createMobileUrl('userinfosave', array('rid' => $rid, 'uid' => $uid, 'fromuser' => $page_fromuser), true), 2);
     //查询是否需要重新填写中奖资料
     $serverapp = $_W['account']['level'];
     //是否为高级号
     if ($serverapp == 4) {
         $fromuser_my = $fromuser;
         //取用户资料
         $fans = pdo_fetch("SELECT uid,follow FROM " . tablename('mc_mapping_fans') . " Where openid=:openid and uniacid=:uniacid ORDER BY `fanid` DESC", array(":openid" => $fromuser_my, ":uniacid" => $weid));
         $profile = mc_fetch($fans['uid'], array('avatar', 'nickname', 'realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position'));
     } else {
         $fromuser_my = $_COOKIE["chailihe_chufa_openid"];
         if (empty($fromuser_my)) {
             $userinfo = pdo_fetch("SELECT from_user,qq,realname,mobile,nickname,address,email FROM " . tablename($this->table_list) . " WHERE weid= :weid AND rid= :rid AND from_user= :fromuser", array(':weid' => $weid, ':rid' => $rid, ':fromuser' => $fromuser));
             if (!empty($userinfo)) {
                 $fromuser_my = $userinfo['from_user'];
                 $profile = $userinfo;
                 $fans['follow'] = 1;
             }
         } else {
             //取用户资料
             $fans = pdo_fetch("SELECT uid,follow FROM " . tablename('mc_mapping_fans') . " Where openid=:openid and uniacid=:uniacid ORDER BY `fanid` DESC", array(":openid" => $fromuser_my, ":uniacid" => $weid));
             $profile = mc_fetch($fans['uid'], array('avatar', 'nickname', 'realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position'));
         }
     }
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     if (strpos($user_agent, 'MicroMessenger') === false) {
         //echo "本页面仅支持微信访问!非微信浏览器禁止浏览!";
         include $this->template('remindnotweixin');
     } else {
         include $this->template('openlihe');
     }
 }
Example #27
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);
 }
Example #28
0
 public function doWebManage()
 {
     global $_W, $_GPC;
     $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
     $rid = intval($_GPC['id']);
     if ($operation == 'display') {
         $pindex = max(1, intval($_GPC['page']));
         $psize = 50;
         if (!empty($_GPC['nickname'])) {
             $openids = pdo_fetchall("SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE nickname LIKE :nickname", array(':nickname' => '%' . $_GPC['nickname'] . '%'), 'openid');
             if (!empty($openids)) {
                 $condition = " AND openid IN ('" . implode("','", array_keys($openids)) . "')";
             }
         }
         if (!empty($condition) || empty($_GPC['nickname'])) {
             $list = pdo_fetchall("SELECT * FROM " . tablename('shake_member') . " WHERE rid = :rid {$condition} ORDER BY shakecount DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':rid' => $rid), 'openid');
             $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('shake_member') . " WHERE rid = :rid {$condition}", array(':rid' => $rid));
             $pager = pagination($total, $pindex, $psize);
             load()->model('mc');
             $fans = mc_fetch(array_keys($list), array('realname', 'mobile'));
         }
     } elseif ($operation == 'post') {
         $id = intval($_GPC['id']);
         $item = pdo_fetch("SELECT * FROM " . tablename('shake_member') . " WHERE id = '{$id}'");
         if (checksubmit('submit')) {
             pdo_update('shake_member', array('remark' => $_GPC['remark']), array('id' => $id));
             message('更新信息成功!', $this->createWebUrl('manage', array('id' => $item['rid'])), 'success');
         }
         $item['profile'] = fans_search($item['openid'], array('mobile', 'realname'));
     }
     include $this->template('manage');
 }
Example #29
0
     $fan['follow'] = 0;
     $fan['followtime'] = 0;
     pdo_insert('mc_mapping_fans', $fan);
 }
 if ($scope == 'userinfo') {
     $url = "https://api.weixin.qq.com/sns/userinfo?access_token={$auth['access_token']}&openid={$auth['openid']}&lang=zh_CN";
     $response = ihttp_get($url);
     if (!is_error($response)) {
         $userinfo = json_decode($response['content'], true);
         $userinfo['nickname'] = stripcslashes($userinfo['nickname']);
         $record['updatetime'] = TIMESTAMP;
         $record['nickname'] = stripslashes($userinfo['nickname']);
         $record['tag'] = base64_encode(iserializer($userinfo));
         pdo_update('mc_mapping_fans', $record, array('openid' => $auth['openid']));
         if (!empty($fan['uid'])) {
             $user = mc_fetch($fan['uid'], array('nickname', 'gender', 'residecity', 'resideprovince', 'nationality', 'avatar'));
             $rec = array();
             if (empty($user['nickname']) && !empty($userinfo['nickname'])) {
                 $rec['nickname'] = stripslashes($userinfo['nickname']);
             }
             if (empty($user['gender']) && !empty($userinfo['sex'])) {
                 $rec['gender'] = $userinfo['sex'];
             }
             if (empty($user['residecity']) && !empty($userinfo['city'])) {
                 $rec['residecity'] = $userinfo['city'] . '市';
             }
             if (empty($user['resideprovince']) && !empty($userinfo['province'])) {
                 $rec['resideprovince'] = $userinfo['province'] . '省';
             }
             if (empty($user['nationality']) && !empty($userinfo['country'])) {
                 $rec['nationality'] = $userinfo['country'];
Example #30
0
 private function checkOpenid()
 {
     global $_W, $_GPC;
     $openid = $_W['openid'];
     $config = $this->module['config'];
     if (!empty($config['url'])) {
         if (!strexists($config['url'], 'http')) {
             $config['url'] = 'http://' . $config['url'];
         }
     }
     if (empty($openid)) {
         if (!empty($config['url'])) {
             message('..请先关注' . $_W['account']['name'] . '才能继续访问..', $config['url'], 'error');
         }
         message('..请先关注' . $_W['account']['name'] . '才能继续访问..', url('home', array('i' => $_W['uniacid'])), 'error');
     }
     load()->model('mc');
     //手机端用户的必要加载项
     $fans = mc_fansinfo($openid);
     $profile = mc_fetch($_W['member']['uid']);
     if ($fans['follow'] != 1) {
         if (empty($config['url'])) {
             message('..请先关注' . $_W['account']['name'] . '才能继续访问..', url('home', array('i' => $_W['uniacid'])), 'error');
         }
         message('..请先关注' . $_W['account']['name'] . '才能继续访问..', $config['url'], 'error');
     }
     $record = pdo_fetch('SELECT * FROM' . tablename($this->table_fans) . " WHERE uniacid = :uniacid AND openid = :openid", array(':uniacid' => $_W['uniacid'], ':openid' => $openid));
     if (empty($record)) {
         $user = $this->getUserInfo($openid);
         if (empty($user)) {
             if (empty($profile['nickname'])) {
                 $user['nickname'] = '匿名' . substr($openid, -4);
             } else {
                 $user['nickname'] = $profile['nickname'];
             }
             if (empty($profile['avatar'])) {
                 $user['headimgurl'] = $_W['siteroot'] . 'addons/luvwhispers/template/style/images/noheader.png';
             } else {
                 $user['headimgurl'] = $profile['avatar'];
             }
         }
         pdo_insert($this->table_fans, array('uniacid' => $_W['uniacid'], 'nickname' => $user['nickname'], 'headimgurl' => $user['headimgurl'], 'openid' => $openid, 'createtime' => TIMESTAMP));
     } else {
         if ($record['isblack'] == 1) {
             message('哎呦,已被管理员封禁了呦..', url('home', array('i' => $_W['uniacid'])), 'error');
         }
         if (TIMESTAMP - $record['createtime'] >= 604800) {
             $user = $this->getUserInfo($openid);
             if (!empty($user['nickname']) || empty($user['headimgurl'])) {
                 pdo_update($this->table_fans, array('nickname' => $user['nickname'], 'headimgurl' => $user['headimgurl'], 'createtime' => TIMESTAMP), array('uniacid' => $_W['uniacid'], 'openid' => $openid));
             }
         }
     }
 }