Esempio n. 1
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     $sql = "SELECT * FROM " . tablename('wxcard_reply') . " WHERE rid = :rid ORDER BY RAND() LIMIT 1";
     $reply = pdo_fetch($sql, array(':rid' => $rid));
     if (empty($reply)) {
         return false;
     }
     load()->classs('weixin.account');
     load()->classs('coupon');
     $coupon = new coupon($_W['acid']);
     if (is_error($coupon)) {
         $this->error($reply, $coupon['message']);
         die;
     }
     $card = $coupon->BuildCardExt($reply['cid']);
     if (is_error($card)) {
         $this->error($reply, $card['message']);
         die;
     }
     $data = array('touser' => $_W['openid'], 'msgtype' => 'wxcard', 'wxcard' => array('card_id' => $card['card_id'], 'card_ext' => $card['card_ext']));
     $acc = WeAccount::create($_W['acid']);
     $status = $acc->sendCustomNotice($data);
     if (is_error($status)) {
         $this->error($reply, $status['message']);
         die;
     }
     if (!empty($reply['success'])) {
         return $this->respText($reply['success']);
         die;
     }
     return true;
 }
Esempio n. 2
0
 function __construct()
 {
     global $_W, $_GPC;
     $this->_fromuser = $_W['fans']['from_user'];
     //debug
     if ($_SERVER['HTTP_HOST'] == '127.0.0.1') {
         $this->_fromuser = '******';
     }
     $this->_weid = $_W['uniacid'];
     $account = account_fetch($this->_weid);
     $this->_auth2_openid = 'auth2_openid_' . $_W['uniacid'];
     $this->_auth2_nickname = 'auth2_nickname_' . $_W['uniacid'];
     $this->_auth2_headimgurl = 'auth2_headimgurl_' . $_W['uniacid'];
     $this->_appid = '';
     $this->_appsecret = '';
     $this->_accountlevel = $account['level'];
     //是否为高级号
     if ($this->_accountlevel == 4) {
         $this->_appid = $account['key'];
         $this->_appsecret = $account['secret'];
     }
     if (!empty($this->_appid) && !empty($this->_appsecret)) {
         require_once IA_ROOT . '/framework/class/account.class.php';
         $acc = WeAccount::create($this->_weid);
         $_W['account']['jssdkconfig'] = $acc->getJssdkConfig();
         $accountInfo = $acc->fetchAccountInfo();
         $_W['account']['access_token'] = $accountInfo['access_token'];
         $_W['account']['jsapi_ticket'] = $accountInfo['jsapi_ticket'];
     }
 }
Esempio n. 3
0
 public function doWebChatlog()
 {
     global $_GPC, $_W;
     load()->func('tpl');
     $acids = uni_accounts($_W['uniacid']);
     if (!empty($acids)) {
         $data = array();
         foreach ($acids as $acid) {
             if (in_array($acid['level'], array(3, 4))) {
                 $data[] = $acid;
             }
         }
     }
     $starttime = empty($_GPC['starttime']) ? strtotime(date('Y-m-d')) : strtotime($_GPC['starttime']);
     if (!empty($_GPC['token'])) {
         unset($_GPC['token']);
         $avatar = '';
         $endtime = $starttime + 23 * 3600 + 3599;
         $acid = intval($_GPC['acid']);
         if (!empty($_GPC['nickname']) && empty($_GPC['openid'])) {
             $user = pdo_fetch('SELECT b.openid,a.avatar FROM ' . tablename('mc_members') . ' AS a LEFT JOIN ' . tablename('mc_mapping_fans') . ' AS b ON a.uid = b.uid WHERE a.nickname = :nickname', array(':nickname' => trim($_GPC['nickname'])));
             if (empty($user['openid'])) {
                 message('没有找到昵称为 "' . $_GPC['nickname'] . '" 的用户', $this->createWebUrl('chatlog', array('acid' => $acid, 'nickname' => $_GPC['nickname'], 'openid' => $_GPC['openid'], 'starttime' => $_GPC['starttime'])), 'error');
             } else {
                 if (!empty($user['avatar'])) {
                     $avatar = tomedia($user['avatar']);
                     $nickname = $user['nickname'];
                 }
             }
         } else {
             $openid = trim($_GPC['openid']);
             $user = pdo_fetch('SELECT b.openid,a.avatar,a.nickname FROM ' . tablename('mc_members') . ' AS a LEFT JOIN ' . tablename('mc_mapping_fans') . ' AS b ON a.uid = b.uid WHERE b.openid = :openid', array(':openid' => trim($_GPC['openid'])));
             if (!empty($user['avatar'])) {
                 $avatar = tomedia($user['avatar']);
                 $nickname = $user['nickname'];
             }
         }
         if ($acid > 0 && !empty($starttime) && !empty($endtime) && !empty($openid)) {
             $pindex = max(1, intval($_GPC['page']));
             $acc = WeAccount::create($acid);
             $params = array('openid' => trim($_GPC['openid']), 'starttime' => $starttime, 'endtime' => $endtime, 'pageindex' => $pindex, 'pagesize' => 1000);
             $logs = $acc->fetchChatLog($params);
             $next = 1;
             if (is_error($logs) || empty($logs['recordlist']) || count($logs['recordlist']) < $params['pagesize']) {
                 $next = 0;
             }
             $codedata = array();
             $codedata[1000] = '创建未接入会话';
             $codedata[1001] = '接入会话';
             $codedata[1002] = '主动发起会话';
             $codedata[1004] = '关闭会话';
             $codedata[1005] = '抢接会话';
             $codedata[2001] = '公众号收到消息';
             $codedata[2002] = '客服发送消息';
             $codedata[2003] = '客服收到消息';
         }
     }
     include $this->template('chatlog');
 }
Esempio n. 4
0
 public function __construct()
 {
     global $_W;
     $this->account = WeAccount::create($_W['account']);
     $this->modules = array_keys($_W['modules']);
     $this->modules[] = 'cover';
     $this->modules[] = 'default';
     $this->modules = array_unique($this->modules);
 }
Esempio n. 5
0
 public function getAccessToken()
 {
     global $_W;
     load()->model('account');
     $acid = $_W['acid'];
     if (empty($acid)) {
         $acid = $_W['uniacid'];
     }
     $account = WeAccount::create($acid);
     $token = $account->fetch_available_token();
     return $token;
 }
Esempio n. 6
0
 public function doMobileIndex()
 {
     global $_W, $_GPC;
     $account = account_fetch($_W['uniacid']);
     if (!empty($account['key']) && !empty($account['secret'])) {
         require_once IA_ROOT . '/framework/class/account.class.php';
         $acc = WeAccount::create($_W['uniacid']);
         $_W['account']['jssdkconfig'] = $acc->getJssdkConfig();
         $accountInfo = $acc->fetchAccountInfo();
         $_W['account']['access_token'] = $accountInfo['access_token'];
         $_W['account']['jsapi_ticket'] = $accountInfo['jsapi_ticket'];
     }
     $setting = pdo_fetch("select * from " . tablename($this->modulename . '_setting') . " where weid =:weid LIMIT 1", array(':weid' => $_W['uniacid']));
     $share_image = empty($setting['share_image']) ? $_W['siteroot'] . '../addons/weiyun_shuqian/icon.jpg' : tomedia($setting['share_image']);
     $share_title = empty($setting['share_title']) ? '数钱数到手抽筋' : $setting['share_title'];
     $share_desc = empty($setting['share_desc']) ? '数钱数到手抽筋' : $setting['share_desc'];
     $share_url = empty($setting['share_url']) ? $_W['siteroot'] . 'app/' . $this->createMobileUrl('index') : $setting['share_url'];
     include $this->template('index');
 }
Esempio n. 7
0
 public function doMobilelikePage()
 {
     global $_GPC, $_W;
     $uniacid = $_W['uniacid'];
     $openid = $_W['openid'];
     load()->func('logging');
     logging_run($openid, '', 'openid');
     if (empty($openid)) {
         echo "error";
         exit;
     }
     $acid = intval($_W['account']['uniacid']);
     $acc = WeAccount::create($acid);
     $fan = $acc->fansQueryInfo($_W['openid'], true);
     if (intval($fan['errno']) == -1) {
         echo "noway";
         exit;
     }
     if ($fan['subscribe'] != '1') {
         echo "unsub";
         exit;
     }
     $type = 1;
     $result = $this->pic_limit($type);
     if ($result) {
         echo 'liked';
     } else {
         $param = array('uniacid' => $uniacid, 'openid' => $openid, 'tousername' => $tousername, 'time' => date("Y-m-d H:i:s", time()), 'picid' => $_GPC['personalPicWallId']);
         pdo_insert('ice_picWallLikelist', $param);
         $param2 = array(':uniacid' => $uniacid, 'picid' => $_GPC['personalPicWallId']);
         $sql = 'SELECT count(openid) FROM ' . tablename('ice_picWallLikelist') . ' WHERE uniacid = :uniacid and picid = :picid';
         $column = pdo_fetchcolumn($sql, $param2);
         load()->func('logging');
         logging_run('点赞数据更新:' . $column, '', 'column');
         if (intval($column) > 0) {
             pdo_update('ice_picWallMain', array('likenum' => $column), array('id' => $_GPC['personalPicWallId']));
         }
         echo $column;
     }
 }
Esempio n. 8
0
 public function receive()
 {
     global $_W;
     load()->model('mc');
     $type = $this->message['type'];
     $event = $this->message['event'];
     $openid = $this->message['from'];
     $config = $this->module['config'];
     $acc = WeAccount::create($_W['acid']);
     if ($event == 'subscribe' && $config['sub_num'] != 0 && !empty($config['sub_type'])) {
         $log = pdo_fetch("SELECT id FROM " . tablename('ju_credit_log') . " WHERE uniacid=:uniacid and openid=:openid", array(':uniacid' => $_W['uniacid'], ':openid' => $openid));
         if (empty($log)) {
             $uid = mc_openid2uid($openid);
             $result = mc_credit_update($uid, $config['sub_type'], $config['sub_num'], array('0' => '1', '1' => '关注平台奖励'));
             if ($result) {
                 $insert = array('uniacid' => $_W['uniacid'], 'openid' => $openid, 'subscribetime' => time(), 'unsubscribetime' => 0, 'follow' => 1);
                 pdo_insert('ju_credit_log', $insert);
                 $this->sendText($acc, $this->message['from'], '感谢您的关注,赠送您' . $config['sub_num'] . '!');
             }
         } else {
             pdo_update('ju_credit_log', array('follow' => 1, 'subscribetime' => time()), array('id' => $log['id']));
         }
     } elseif ($event == 'unsubscribe' && $config['unsub_num'] != 0) {
         $log = pdo_fetch("SELECT id FROM " . tablename('ju_credit_log') . " WHERE uniacid=:uniacid and openid=:openid", array(':uniacid' => $_W['uniacid'], ':openid' => $openid));
         $uid = mc_openid2uid($openid);
         if (empty($log)) {
             $result = mc_credit_update($uid, $config['unsub_type'], '-' . $config['unsub_num'], array('0' => '1', '1' => '取消关注平台扣除'));
             if ($result) {
                 $insert = array('uniacid' => $_W['uniacid'], 'openid' => $openid, 'subscribetime' => 0, 'unsubscribetime' => time(), 'follow' => 0);
                 pdo_insert('ju_credit_log', $insert);
             }
         } else {
             $result = mc_credit_update($uid, $config['unsub_type'], '-' . $config['unsub_num'], array('0' => '1', '1' => '取消关注平台扣除'));
             pdo_update('ju_credit_log', array('follow' => 0, 'subscribetime' => 0, 'unsubscribetime' => time()), array('id' => $log['id']));
         }
     }
 }
Esempio n. 9
0
 public function payResult($params)
 {
     global $_W;
     $fee = intval($params['fee']);
     $data = array('status' => $params['result'] == 'success' ? 1 : 0);
     $paytype = array('credit' => 1, 'wechat' => 2, 'alipay' => 2, 'delivery' => 3);
     $data['pay_type'] = $paytype[$params['type']];
     if ($params['result'] == 'success') {
         $data['pay_time'] = TIMESTAMP;
     }
     pdo_update('daijia_orders', $data, array('ordersn' => $params['tid']));
     if ($params['from'] == 'return') {
         $setting = uni_setting($_W['uniacid'], array('creditbehaviors'));
         $credit = $setting['creditbehaviors']['currency'];
         //支付成功,打印订单
         $order = pdo_fetch("SELECT * FROM " . tablename('daijia_orders') . "where ordersn={$params['tid']}");
         //获取所有打印机
         $prints = pdo_fetchall('SELECT * FROM ' . tablename('daijia_print') . ' WHERE uniacid = :aid AND status = 1', array(':aid' => $_W['uniacid']));
         if (empty($prints)) {
             // exit('没有有效的打印机');
         }
         $paytype = $order['paytype'] == '3' ? '货到付款' : '已付款';
         $ordertype = $order['type'] == 'daijia' ? '代驾' : '代劳、代步';
         //邮件提醒
         $orderinfo = '';
         $orderinfo .= '订单编号  起始地址   目的地址 价格   备注<BR>';
         $orderinfo .= '--------------------------------<BR>';
         $orderInfo .= "{$order['ordersn']}{$order['start_address']}{$order['end_address']}{$order['price']}{$order['remark']}<br />";
         $orderInfo .= '--------------------------------<BR>';
         $orderinfo .= "合计:{$order['price']}元<BR>";
         $orderinfo .= "联系电话:{$order['mobile']}<BR>";
         $orderinfo .= "支付方式:{$paytype}<BR>";
         //微信提醒
         $sendinfo = '您的订单支付成功,请等待处理:\\n';
         $sendinfo .= '--------------------\\n';
         $sendinfo .= "{$ordertype}详情:\n";
         $sendinfo .= '--------------------\\n';
         $sendinfo .= "订单编号:{$order['ordersn']}\n";
         $sendinfo .= "起始地址: {$order['start_address']}\n";
         $sendinfo .= "目的地址: {$order['end_address']}\n";
         $sendinfo .= "备注: {$order['remark']}\n";
         $sendinfo .= '--------------------\\n';
         $sendinfo .= "合计:{$order['price']}元\n";
         $sendinfo .= "联系电话:{$order['mobile']}\n";
         $sendinfo .= "支付方式:{$paytype}\n";
         //发送微信提醒
         $send['msgtype'] = 'text';
         $send['text'] = array('content' => urlencode($sendinfo));
         $acc = WeAccount::create($_W['account']['acid']);
         $send['touser'] = trim($_W['openid']);
         $s_mess = $acc->sendCustomNotice($send);
         include 'wprint.class.php';
         //遍历所有打印机
         foreach ($prints as $li) {
             if (!empty($li['qrcode_link'])) {
                 $orderinfo .= "<QR>{$li['qrcode_link']}</QR>";
             }
             if (!empty($li['print_no']) && !empty($li['key'])) {
                 $wprint = new wprint();
                 $status = $wprint->StrPrint($li['print_no'], $li['key'], $orderinfo, 1);
                 if (!is_error($status)) {
                     $i++;
                     $data2 = array('uniacid' => $_W['uniacid'], 'sid' => $sid, 'pid' => $li['id'], 'oid' => $id, 'status' => 1, 'aid' => $status, 'addtime' => TIMESTAMP);
                     pdo_insert('daijia_order_print', $data2);
                 }
             }
         }
         // if($i > 0) {
         // 	 pdo_query('UPDATE ' . tablename('str_order') . " SET print_nums = print_nums + {$i} WHERE uniacid = {$_W['uniacid']} AND id = {$id}");
         // } else {
         // 	exit('发送打印指令失败。没有有效的机器号');
         // }
         // exit('success');
         //打印结束
         if ($params['type'] == $credit) {
             message('支付成功!', $this->createMobileUrl('daijia', array('op' => 'yes')), 'success');
         } else {
             message('支付成功!', '../../app/' . $this->createMobileUrl('daijia', array('op' => 'yes')), 'success');
         }
     }
 }
Esempio n. 10
0
 public function doWebhotelset()
 {
     global $_GPC, $_W;
     $acc = WeAccount::create($_W['acid']);
     $id = intval($_GPC['id']);
     if (checksubmit('submit')) {
         $data = array('weid' => $_W['uniacid'], 'location_p' => $_GPC['district']['province'], 'location_c' => $_GPC['district']['city'], 'location_a' => $_GPC['district']['district'], 'version' => $_GPC['version'], 'user' => $_GPC['user'], 'reg' => $_GPC['reg'], 'regcontent' => $_GPC['regcontent'], 'bind' => $_GPC['bind'], 'ordertype' => $_GPC['ordertype'], 'paytype1' => $_GPC['paytype1'], 'paytype2' => $_GPC['paytype2'], 'paytype3' => $_GPC['paytype3'], 'is_unify' => $_GPC['is_unify'], 'tel' => $_GPC['tel'], 'email' => $_GPC['email'], 'mobile' => $_GPC['mobile'], 'template' => $_GPC['template'], 'templateid' => trim($_GPC['templateid']));
         if ($data['template'] && $data['templateid'] == '') {
             message('请输入模板ID', referer(), 'info');
         }
         if (!empty($id)) {
             pdo_update("hotel2_set", $data, array("id" => $id));
         } else {
             pdo_insert("hotel2_set", $data);
         }
         message("保存设置成功!", referer(), "success");
     }
     $sql = 'SELECT * FROM ' . tablename('hotel2_set') . ' WHERE `weid` = :weid';
     $set = pdo_fetch($sql, array(':weid' => $_W['uniacid']));
     if (empty($set)) {
         $set = array('user' => 1, 'reg' => 1, 'bind' => 1);
     }
     include $this->template("hotelset");
 }
Esempio n. 11
0
 private function changeWechatSend($id, $status, $msg = '')
 {
     global $_W;
     $paylog = pdo_fetch("SELECT plid, openid, tag FROM " . tablename('core_paylog') . " WHERE tid = '{$id}' AND status = 1 AND type = 'wechat'");
     if (!empty($paylog['openid'])) {
         $paylog['tag'] = iunserializer($paylog['tag']);
         $acid = $paylog['tag']['acid'];
         $account = account_fetch($acid);
         $payment = uni_setting($account['uniacid'], 'payment');
         if ($payment['payment']['wechat']['version'] == '2') {
             return true;
         }
         $send = array('appid' => $account['key'], 'openid' => $paylog['openid'], 'transid' => $paylog['tag']['transaction_id'], 'out_trade_no' => $paylog['plid'], 'deliver_timestamp' => TIMESTAMP, 'deliver_status' => $status, 'deliver_msg' => $msg);
         $sign = $send;
         $sign['appkey'] = $payment['payment']['wechat']['signkey'];
         ksort($sign);
         $string = '';
         foreach ($sign as $key => $v) {
             $key = strtolower($key);
             $string .= "{$key}={$v}&";
         }
         $send['app_signature'] = sha1(rtrim($string, '&'));
         $send['sign_method'] = 'sha1';
         $account = WeAccount::create($acid);
         $response = $account->changeOrderStatus($send);
         if (is_error($response)) {
             message($response['message']);
         }
     }
 }
Esempio n. 12
0
    $groups = pdo_fetch('SELECT * FROM ' . tablename('mc_fans_groups') . ' WHERE uniacid = :uniacid AND acid = :acid', array(':uniacid' => $_W['uniacid'], ':acid' => $_W['acid']));
    if (!empty($groups)) {
        $groups = iunserializer($groups['groups']);
    }
    $record = array('uniacid' => $_W['uniacid'], 'acid' => $_W['acid'], 'groupname' => $groups[$group]['name'], 'fansnum' => $groups[$group]['count'], 'msgtype' => $type, 'group' => $group, 'attach_id' => $id, 'status' => 0, 'type' => 0, 'sendtime' => TIMESTAMP, 'createtime' => TIMESTAMP);
    pdo_insert('mc_mass_record', $record);
    exit('success');
}
if ($do == 'del') {
    $id = intval($_GPC['id']);
    $media = pdo_get('wechat_attachment', array('uniacid' => $_W['uniacid'], 'id' => $id));
    if (empty($media)) {
        exit('素材不存在或已经删除');
    }
    $media_id = trim($media['media_id']);
    $acc = WeAccount::create();
    $data = $acc->delMaterial($media_id);
    if (is_error($data)) {
        exit($data['message']);
    } else {
        pdo_delete('wechat_attachment', array('uniacid' => $_W['uniacid'], 'id' => $id));
        if ($type == 'image' || $type == 'voice') {
            $path = ATTACHMENT_ROOT . "/{$media['type']}s/{$_W['uniacid']}/material/{$media['$media_id']}";
            @unlink($path);
        } elseif ($type == 'news') {
            pdo_delete('wechat_news', array('uniacid' => $_W['uniacid'], 'attach_id' => $id));
        }
        exit('success');
    }
}
template('material/display');
Esempio n. 13
0
 $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'];
         if ($_W['account']['level'] == '3' && empty($fan['nickname'])) {
             $account_obj = WeAccount::create($_W['account']);
             $userinfo = $account_obj->fansQueryInfo($auth['openid']);
             if (!is_error($userinfo) && is_array($userinfo) && !empty($userinfo['nickname'])) {
                 $record = array();
                 $record['updatetime'] = TIMESTAMP;
                 $record['nickname'] = stripslashes($userinfo['nickname']);
                 $record['tag'] = base64_encode(iserializer($userinfo));
                 pdo_update('mc_mapping_fans', $record, array('openid' => $fan['openid']));
                 if (!empty($fan['uid'])) {
                     $user = mc_fetch($fan['uid'], array('nickname', 'gender', 'residecity', 'resideprovince', 'nationality', 'avatar'));
                     $record = array();
                     if (empty($user['nickname']) && !empty($userinfo['nickname'])) {
                         $record['nickname'] = stripslashes($userinfo['nickname']);
                     }
                     if (empty($user['gender']) && !empty($userinfo['sex'])) {
                         $record['gender'] = $userinfo['sex'];
Esempio n. 14
0
        } else {
            message("公众平台返回接口错误. <br />错误代码为: {$result['errorcode']} <br />错误信息为: {$result['message']}");
        }
    }
    $id = intval($_GPC['id']);
    $row = pdo_fetch("SELECT * FROM " . tablename('qrcode') . " WHERE uniacid = {$_W['uniacid']} AND id = '{$id}'");
    template('platform/qr-post');
}
if ($do == 'extend') {
    load()->func('communication');
    $id = intval($_GPC['id']);
    if (!empty($id)) {
        $qrcrow = pdo_fetch("SELECT * FROM " . tablename('qrcode') . " WHERE uniacid = {$_W['uniacid']} AND id = '{$id}'");
        $update = array();
        if ($qrcrow['model'] == 1) {
            $uniacccount = WeAccount::create($qrcrow['acid']);
            $barcode['action_info']['scene']['scene_id'] = $qrcrow['qrcid'];
            $barcode['expire_seconds'] = 1800;
            $barcode['action_name'] = 'QR_SCENE';
            $result = $uniacccount->barCodeCreateDisposable($barcode);
            if (is_error($result)) {
                message($result['message'], '', 'error');
            }
            $update['ticket'] = $result['ticket'];
            $update['expire'] = $result['expire_seconds'];
            $update['createtime'] = TIMESTAMP;
            pdo_update('qrcode', $update, array('id' => $id, 'uniacid' => $_W['uniacid']));
        }
        message('恭喜,延长临时二维码时间成功!', referer(), 'success');
    }
}
Esempio n. 15
0
 * [WEIZAN System] Copyright (c) 2015 012WZ.COM
 * WeiZan is NOT a free software, it under the license terms, visited http://www.012wz.com/ for more details.
 */
defined('IN_IA') or exit('Access Denied');
if (!empty($_W['uniacid'])) {
    load()->model('account');
    load()->model('mc');
    $setting = uni_setting($_W['uniacid'], 'sync');
    $sync = $setting['sync'];
    if ($sync != 1) {
        exit;
    }
    if ($_W['account']['type'] == 1 && $_W['account']['level'] >= 3) {
        $data = pdo_fetchall('SELECT fanid, openid, acid, uid, uniacid FROM ' . tablename('mc_mapping_fans') . " WHERE uniacid = :uniacid AND acid = :acid AND follow = 1 ORDER BY updatetime ASC, fanid DESC LIMIT 10", array(':uniacid' => $_W['uniacid'], ':acid' => $_W['acid']));
        if (!empty($data)) {
            $acc = WeAccount::create($_W['acid']);
            foreach ($data as $row) {
                $fan = $acc->fansQueryInfo($row['openid'], true);
                if (!is_error($fan) && $fan['subscribe'] == 1) {
                    $group = $acc->fetchFansGroupid($row['openid']);
                    $record = array();
                    if (!is_error($group)) {
                        $record['groupid'] = $group['groupid'];
                    }
                    $record['updatetime'] = time();
                    $record['followtime'] = $fan['subscribe_time'];
                    $record['follow'] = 1;
                    $fan['nickname'] = stripcslashes($fan['nickname']);
                    $record['nickname'] = stripslashes($fan['nickname']);
                    if (!empty($fan['remark'])) {
                        $fan['remark'] = stripslashes($fan['remark']);
Esempio n. 16
0
function mc_notice_init()
{
    global $_W;
    if (empty($_W['account'])) {
        $_W['account'] = uni_fetch($_W['uniacid']);
    }
    if (empty($_W['account'])) {
        return error(-1, '创建公众号操作类失败');
    }
    if ($_W['account']['level'] < 3) {
        return error(-1, '公众号没有经过认证,不能使用模板消息和客服消息');
    }
    $acc = WeAccount::create();
    if (is_null($acc)) {
        return error(-1, '创建公众号操作对象失败');
    }
    $setting = uni_setting();
    $noticetpl = $setting['tplnotice'];
    $acc->noticetpl = $noticetpl;
    if (!is_array($acc->noticetpl)) {
        return error(-1, '微信通知参数错误');
    }
    return $acc;
}
Esempio n. 17
0
        $oauth_account = WeAccount::create($_W['account']['oauth']);
        $forward = $oauth_account->getOauthCodeUrl($callback, $state);
        header('Location: ' . $forward);
        exit;
    }
}
$_W['account']['groupid'] = $_W['uniaccount']['groupid'];
$_W['account']['qrcode'] = tomedia('qrcode_' . $_W['acid'] . '.jpg') . '?time=' . $_W['timestamp'];
$_W['account']['avatar'] = tomedia('headimg_' . $_W['acid'] . '.jpg') . '?time=' . $_W['timestamp'];
if ($_W['container'] == 'wechat') {
    if ($_W['account']['level'] < 3) {
        if (!empty($unisetting['jsauth_acid'])) {
            $jsauth_acid = $unisetting['jsauth_acid'];
        } elseif (!empty($unisetting['oauth']['account'])) {
            $jsauth_acid = $unisetting['oauth']['account'];
        }
    } else {
        $jsauth_acid = $_W['acid'];
    }
    if (!empty($jsauth_acid)) {
        $accountObj = WeAccount::create($jsauth_acid);
        $_W['account']['jssdkconfig'] = $accountObj->getJssdkConfig();
        $_W['account']['jsauth_acid'] = $jsauth_acid;
    }
    unset($jsauth_acid, $accountObj);
}
$_W['card_permission'] = 0;
if ($_W['acid'] && $_W['account']['level'] >= 3 && $_W['container'] == 'wechat') {
    $_W['card_permission'] = 1;
}
load()->func('compat.biz');
Esempio n. 18
0
    }
    foreach ($accounts as $acc) {
        $account = WeAccount::create($acc['acid']);
        $ret = $account->menuCreate($menus);
        if (is_error($ret)) {
            exit(json_encode($ret));
        }
    }
    exit('success');
}
if ($do == 'display') {
    $_W['page']['title'] = '菜单设计器 - 自定义菜单 - 高级功能';
    if (!empty($accounts)) {
        if (empty($menus) || !is_array($menus)) {
            $acc = array_shift($accounts);
            $account = WeAccount::create($acc['acid']);
            $menus = $account->menuQuery();
        }
    }
    if (is_error($menus)) {
        message($menus['message'], '', 'error');
    }
    $sql = 'SELECT `menuset` FROM ' . tablename('uni_settings') . ' WHERE `uniacid` = :uniacid';
    $hmenus = array();
    $hmenu = pdo_fetchcolumn($sql, array(':uniacid' => $_W['uniacid']));
    if (!empty($hmenu)) {
        $hmenus = iunserializer(base64_decode($hmenu));
        $createtime = !empty($hmenus) && is_array($hmenus) ? array_pop($hmenus) : '';
    }
    if (!is_array($hmenus)) {
        $hmenus = array();
Esempio n. 19
0
    private function getMember()
    {
        global $_W;
        $sql = 'SELECT `lastupdate`, `isblacklist`, `rid` FROM ' . tablename('wxwall_members') . ' WHERE `from_user` =
				:from_user AND `rid` = :rid';
        $params = array(':from_user' => $_W['openid'], ':rid' => $this->rule);
        $member = pdo_fetch($sql, $params);
        // 获取粉丝头像
        $account = WeAccount::create($_W['acid']);
        $fansInfo = $account->fansQueryInfo($_W['openid']);
        if (empty($member)) {
            $member = array('from_user' => $_W['openid'], 'rid' => $this->rule, 'isjoin' => 1, 'lastupdate' => TIMESTAMP, 'isblacklist' => 0);
            if (!is_error($fansInfo)) {
                $member['avatar'] = rtrim($fansInfo['headimgurl'], '0') . '132';
            }
            pdo_insert('wxwall_members', $member);
        } else {
            if (!is_error($fansInfo)) {
                $member['avatar'] = rtrim($fansInfo['headimgurl'], '0') . '132';
            }
            $member['lastupdate'] = TIMESTAMP;
            $params = array('from_user' => $_W['openid'], 'rid' => $this->rule);
            pdo_update('wxwall_members', $member, $params);
        }
        return $member;
    }
Esempio n. 20
0
 public function sendMessage($send = array())
 {
     global $_W;
     load()->classs('account');
     $from_user = $send['touser'];
     $acid = $_W['acid'];
     if (empty($acid)) {
         $acid = pdo_fetchcolumn("SELECT acid FROM " . tablename('mc_mapping_fans') . " WHERE openid = '{$from_user}'");
     }
     $acc = WeAccount::create($acid);
     $data = $acc->sendCustomNotice($send);
 }
Esempio n. 21
0
                 $auth = base64_encode(json_encode($pass));
                 $vars = array();
                 $vars['__auth'] = $auth;
                 $vars['forward'] = base64_encode($c['url']);
                 $row['url'] = $_W['siteroot'] . 'app/' . murl('auth/forward', $vars);
             }
             $news[] = $row;
         }
         $send['news']['articles'] = $news;
     } else {
         $idata = array();
         $send['news'] = '';
     }
 }
 if ($acid) {
     $acc = WeAccount::create($acid);
     $data = $acc->sendCustomNotice($send);
     if (is_error($data)) {
         exit(json_encode(array('status' => 'error', 'message' => $data['message'])));
     } else {
         $account = account_fetch($acid);
         $message['from'] = $_W['openid'] = $send['touser'];
         $message['to'] = $account['original'];
         if (!empty($message['to'])) {
             $sessionid = md5($message['from'] . $message['to'] . $_W['uniacid']);
             load()->classs('wesession');
             load()->classs('account');
             session_id($sessionid);
             WeSession::start($_W['uniacid'], $_W['openid'], 300);
             $processor = WeUtility::createModuleProcessor('chats');
             $processor->begin(300);
Esempio n. 22
0
function mc_oauth_userinfo($acid = 0)
{
    global $_W;
    if (isset($_SESSION['userinfo'])) {
        $userinfo = unserialize(base64_decode($_SESSION['userinfo']));
        return $userinfo;
    }
    if ($_W['container'] != 'wechat') {
        return array();
    }
    if (!empty($_SESSION['openid']) && intval($_W['account']['level']) >= 3) {
        $accObj = WeAccount::create($_W['account']);
        $userinfo = $accObj->fansQueryInfo($_SESSION['openid']);
        if (!is_error($userinfo) && !empty($userinfo) && is_array($userinfo) && !empty($userinfo['nickname'])) {
            $userinfo['nickname'] = stripcslashes($userinfo['nickname']);
            $userinfo['avatar'] = $userinfo['headimgurl'];
            unset($userinfo['headimgurl']);
            $_SESSION['userinfo'] = base64_encode(iserializer($userinfo));
            $fan = mc_fansinfo($_SESSION['openid']);
            if (!empty($fan)) {
                $record = array('updatetime' => TIMESTAMP, 'nickname' => stripslashes($userinfo['nickname']), 'follow' => $userinfo['subscribe'], 'followtime' => $userinfo['subscribe_time'], 'tag' => base64_encode(iserializer($userinfo)));
                pdo_update('mc_mapping_fans', $record, array('openid' => $_SESSION['openid'], 'acid' => $_W['acid'], 'uniacid' => $_W['uniacid']));
            }
            if (!empty($fan['uid']) || !empty($_SESSION['uid'])) {
                $uid = intval($fan['uid']);
                if (empty($uid)) {
                    $uid = intval($_SESSION['uid']);
                }
                $member = mc_fetch($uid, array('nickname', 'gender', 'residecity', 'resideprovince', 'nationality', 'avatar'));
                $record = array();
                if (empty($member['nickname']) && !empty($userinfo['nickname'])) {
                    $record['nickname'] = stripslashes($userinfo['nickname']);
                }
                if (empty($member['gender']) && !empty($userinfo['sex'])) {
                    $record['gender'] = $userinfo['sex'];
                }
                if (empty($member['residecity']) && !empty($userinfo['city'])) {
                    $record['residecity'] = $userinfo['city'] . '市';
                }
                if (empty($member['resideprovince']) && !empty($userinfo['province'])) {
                    $record['resideprovince'] = $userinfo['province'] . '省';
                }
                if (empty($member['nationality']) && !empty($userinfo['country'])) {
                    $record['nationality'] = $userinfo['country'];
                }
                if (empty($member['avatar']) && !empty($userinfo['avatar'])) {
                    $record['avatar'] = rtrim($userinfo['avatar'], '0') . 132;
                }
                if (!empty($record)) {
                    pdo_update('mc_members', $record, array('uid' => intval($uid)));
                }
            }
            return $userinfo;
        }
    }
    if (empty($_W['oauth_account'])) {
        return error(-1, '未指定网页授权公众号, 无法获取用户信息.');
    }
    if (empty($_W['oauth_account']['key']) || empty($_W['oauth_account']['secret'])) {
        return error(-2, '公众号未设置 appId 或 secret.');
    }
    if (intval($_W['oauth_account']['level']) < 4) {
        return error(-3, '公众号非认证服务号, 无法获取用户信息.');
    }
    $state = 'we7sid-' . $_W['session_id'];
    $_SESSION['dest_url'] = base64_encode($_SERVER['QUERY_STRING']);
    $url = $_W['siteroot'] . "app/index.php?i={$_W['uniacid']}&j={$_W['acid']}&c=auth&a=oauth&scope=userinfo";
    $callback = urlencode($url);
    $forward = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $_W['oauth_account']['key'] . '&redirect_uri=' . $callback . '&response_type=code&scope=snsapi_userinfo&state=' . $state . '#wechat_redirect';
    header('Location: ' . $forward);
    exit;
}
Esempio n. 23
0
 public function getAccount()
 {
     global $_W;
     load()->model('account');
     if (!empty($_W['acid'])) {
         return WeAccount::create($_W['acid']);
     } else {
         $acid = pdo_fetchcolumn("SELECT acid FROM " . tablename('account_wechats') . " WHERE `uniacid`=:uniacid LIMIT 1", array(':uniacid' => $_W['uniacid']));
         return WeAccount::create($acid);
     }
     return false;
 }
Esempio n. 24
0
 /**
  * 获取用户称呼
  */
 private function nickname($uid = 0, $ty = '')
 {
     global $_W;
     return value($_COOKIE, 'run_username_' . intval($this->reply['rid']));
     //
     load()->model('mc');
     //获取会员资料
     $user = mc_fetch($uid ? $uid : $_W['member']['uid'], array('nickname', 'mobile', 'email', 'avatar'));
     if ($ty) {
         return $user[$ty];
     }
     $niemmo = '';
     if ($user) {
         $niemmo = $user['nickname'];
         if (empty($niemmo)) {
             $niemmo = $user['mobile'];
         }
         if (empty($niemmo)) {
             //$niemmo = cutstr($user['email'], 10);
             //
             $fans = pdo_fetch('SELECT acid,openid FROM ' . tablename('mc_mapping_fans') . ' WHERE openid = :openid AND uid = :uid', array(':openid' => $_W['openid'], ':uid' => $user['uid']));
             if ($fans) {
                 $acc = WeAccount::create($fans['acid']);
                 if (method_exists($acc, 'fetchAccountInfo')) {
                     $accinfo = $acc->fetchAccountInfo();
                     $access_token = iunserializer($accinfo['access_token']);
                     $accesstoken = $access_token['token'];
                     //
                     load()->func('communication');
                     $url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=' . $accesstoken . '&openid=' . $fans['openid'] . '&lang=zh_CN';
                     $response = ihttp_get($url);
                     if (!is_error($response)) {
                         $userinfo = json_decode($response['content'], true);
                         $niemmo = $userinfo['nickname'];
                         $userdata = array('nickname' => $userinfo['nickname'], 'gender' => $userinfo['sex'], 'avatar' => $userinfo['headimgurl'], 'resideprovince' => $userinfo['province'], 'residecity' => $userinfo['city'], 'nationality' => $userinfo['country']);
                         if (empty($userinfo['nickname'])) {
                             $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $accinfo['key'] . '&redirect_uri=' . urlencode(urwdo('nickname', '', 1) . '&uid=' . $user['uid']) . '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
                             gourl($url);
                         }
                         pdo_update('mc_members', $userdata, array('uid' => $user['uid']));
                     }
                 }
             }
         }
     }
     return $niemmo;
 }
Esempio n. 25
0
 public function getVailableAccessToken()
 {
     $accounts = pdo_fetchall("SELECT `key`, `secret`, `acid` FROM " . tablename('account_wechats') . " WHERE uniacid = :uniacid ORDER BY `level` DESC ", array(':uniacid' => $GLOBALS['_W']['uniacid']));
     if (empty($accounts)) {
         return error(-1, 'no permission');
     }
     foreach ($accounts as $account) {
         if (empty($account['key']) || empty($account['secret'])) {
             continue;
         }
         $acid = $account['acid'];
         break;
     }
     $account = WeAccount::create($acid);
     return $account->getAccessToken();
 }
Esempio n. 26
0
function uni_update_yesterday_stat()
{
    global $_W;
    $cachekey = "stat:todaylock:{$_W['uniacid']}";
    $cache = cache_load($cachekey);
    if (!empty($cache) && $cache['expire'] > TIMESTAMP) {
        return true;
    }
    $yesterday = date('Ymd', strtotime('-1 days'));
    $yesterday_stat = pdo_get('stat_fans', array('date' => $yesterday, 'uniacid' => $_W['uniacid']));
    if ($_W['account']['level'] == ACCOUNT_SUBSCRIPTION_VERIFY || $_W['account']['level'] == ACCOUNT_SERVICE_VERIFY) {
        $account_obj = WeAccount::create();
        $weixin_stat = $account_obj->getFansStat();
        if (!is_error($weixin_stat) && !empty($weixin_stat)) {
            $yesterday_weixin_stat = $weixin_stat[$yesterday];
            $update_stat = array('uniacid' => $_W['uniacid'], 'new' => $yesterday_weixin_stat['new'], 'cancel' => $yesterday_weixin_stat['cancel'], 'cumulate' => $yesterday_weixin_stat['cumulate'], 'date' => $yesterday);
        }
    } else {
        $update_stat = array();
        $update_stat['cumulate'] = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('mc_mapping_fans') . ' WHERE acid = :acid AND uniacid = :uniacid AND follow = :follow AND followtime < :endtime', array(':acid' => $_W['acid'], ':uniacid' => $_W['uniacid'], ':endtime' => strtotime(date('Y-m-d')), ':follow' => 1));
        $update_stat['date'] = $yesterday;
        $update_stat['uniacid'] = $_W['uniacid'];
    }
    if (empty($yesterday_stat)) {
        pdo_insert('stat_fans', $update_stat);
    } else {
        pdo_update('stat_fans', $update_stat, array('id' => $yesterday_stat['id']));
    }
    cache_write($cachekey, array('expire' => strtotime(date('Y-m-d')) + 86399));
    return true;
}
Esempio n. 27
0
 public function getQR($poster, $member, $goodsid = 0)
 {
     global $_W, $_GPC;
     $acid = $_W['acid'];
     if ($poster['type'] == 1) {
         $qrimg = m('qrcode')->createShopQrcode($member['id'], $poster['id']);
         $qr = pdo_fetch('select * from ' . tablename('ewei_shop_poster_qr') . ' where openid=:openid and acid=:acid and type=:type limit 1', array(':openid' => $member['openid'], ':acid' => $_W['acid'], ':type' => 1));
         if (empty($qr)) {
             $qr = array('acid' => $acid, 'openid' => $member['openid'], 'type' => 1, 'qrimg' => $qrimg);
             pdo_insert('ewei_shop_poster_qr', $qr);
             $qr['id'] = pdo_insertid();
         }
         $qr['current_qrimg'] = $qrimg;
         return $qr;
     } else {
         if ($poster['type'] == 2) {
             $p = p('commission');
             if ($p) {
                 $qrimg = $p->createMyShopQrcode($member['id'], $poster['id']);
                 $qr = pdo_fetch('select * from ' . tablename('ewei_shop_poster_qr') . ' where openid=:openid and acid=:acid and type=:type limit 1', array(':openid' => $member['openid'], ':acid' => $_W['acid'], ':type' => 2));
                 if (empty($qr)) {
                     $qr = array('acid' => $acid, 'openid' => $member['openid'], 'type' => 2, 'qrimg' => $qrimg);
                     pdo_insert('ewei_shop_poster_qr', $qr);
                     $qr['id'] = pdo_insertid();
                 }
                 $qr['current_qrimg'] = $qrimg;
                 return $qr;
             }
         } else {
             if ($poster['type'] == 3) {
                 $qrimg = m('qrcode')->createGoodsQrcode($member['id'], $goodsid, $poster['id']);
                 $qr = pdo_fetch('select * from ' . tablename('ewei_shop_poster_qr') . ' where openid=:openid and acid=:acid and type=:type and goodsid=:goodsid limit 1', array(':openid' => $member['openid'], ':acid' => $_W['acid'], ':type' => 3, ':goodsid' => $goodsid));
                 if (empty($qr)) {
                     $qr = array('acid' => $acid, 'openid' => $member['openid'], 'type' => 3, 'goodsid' => $goodsid, 'qrimg' => $qrimg);
                     pdo_insert('ewei_shop_poster_qr', $qr);
                     $qr['id'] = pdo_insertid();
                 }
                 $qr['current_qrimg'] = $qrimg;
                 return $qr;
             } else {
                 if ($poster['type'] == 4) {
                     $uniacccount = WeAccount::create($acid);
                     $qr = pdo_fetch('select * from ' . tablename('ewei_shop_poster_qr') . ' where openid=:openid and acid=:acid and type=4 limit 1', array(':openid' => $member['openid'], ':acid' => $acid));
                     if (empty($qr)) {
                         $sceneid = pdo_fetchcolumn("SELECT qrcid FROM " . tablename('qrcode') . " WHERE acid = :acid and model=2 ORDER BY qrcid DESC LIMIT 1", array(':acid' => $acid));
                         $barcode['action_info']['scene']['scene_id'] = intval($sceneid) + 1;
                         if ($barcode['action_info']['scene']['scene_id'] > 100000) {
                             return error(-1, '抱歉,永久二维码已经生成最大数量,请先删除一些。');
                         }
                         $barcode['action_name'] = 'QR_LIMIT_SCENE';
                         $result = $uniacccount->barCodeCreateFixed($barcode);
                         if (is_error($result)) {
                             return error(-1, "公众平台返回接口错误. <br />错误代码为: {$result['errorcode']} <br />错误信息为: {$result['message']}");
                         }
                         $qrimg = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . $result['ticket'];
                         $ims_qrcode = array('uniacid' => $_W['uniacid'], 'acid' => $_W['acid'], 'qrcid' => $barcode['action_info']['scene']['scene_id'], "model" => 2, "name" => "EWEI_SHOP_POSTER_QRCODE", "keyword" => 'EWEI_SHOP_POSTER', "expire" => 0, "createtime" => time(), "status" => 1, 'url' => $result['url'], "ticket" => $result['ticket']);
                         pdo_insert('qrcode', $ims_qrcode);
                         $qr = array('acid' => $acid, 'openid' => $member['openid'], 'type' => 4, 'sceneid' => $barcode['action_info']['scene']['scene_id'], 'ticket' => $result['ticket'], 'qrimg' => $qrimg, 'url' => $result['url']);
                         pdo_insert('ewei_shop_poster_qr', $qr);
                         $qr['id'] = pdo_insertid();
                         $qr['current_qrimg'] = $qrimg;
                     } else {
                         $qr['current_qrimg'] = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . $qr['ticket'];
                     }
                     return $qr;
                 }
             }
         }
     }
 }
Esempio n. 28
0
 public function doMobileOrderConfirm()
 {
     global $_W, $_GPC;
     checkauth();
     if (!$_W['isajax']) {
         $sid = intval($_GPC['sid']);
         $store = pdo_fetch('SELECT * FROM ' . tablename('str_store') . ' WHERE uniacid = :aid AND id = :id', array(':aid' => $_W['uniacid'], ':id' => $sid));
         if (empty($store)) {
             message('门店不存在', '', 'error');
         }
         $dish = array();
         if (!empty($_GPC['dish'])) {
             foreach ($_GPC['dish'] as $key => $val) {
                 $dish[$key] = intval($val);
             }
         }
         if (empty($dish)) {
             message('订单信息出错', '', 'error');
         }
         $dish = base64_encode(iserializer($dish));
         //送餐时间
         $minut = date('i', TIMESTAMP);
         if ($minut <= 15) {
             $minut = 15;
         } elseif ($minut > 15 && $minut <= 30) {
             $minut = 30;
         } elseif ($minut > 30 && $minut <= 45) {
             $minut = 45;
         } elseif ($minut > 45 && $minut <= 60) {
             $minut = 60;
         }
         $now = mktime(date('H'), $minut);
         $now_limit = $now + 180 * 60;
         for ($now; $now <= $now_limit; $now += 15 * 60) {
             $str .= '<a href="javascript:void(0);">' . date('H:i', $now) . '</a>';
         }
         //收货人信息
         $member = mc_fetch($_W['member']['uid'], array('realname', 'mobile', 'address'));
     } else {
         $sid = intval($_GPC['sid']);
         $store = pdo_fetch('SELECT notice_acid,title,groupid FROM ' . tablename('str_store') . ' WHERE uniacid = :aid AND id = :id', array(':aid' => $_W['uniacid'], ':id' => $sid));
         $rand = trim($_GPC['rand_order']);
         $dish = iunserializer(base64_decode($_GPC['dish']));
         $out['errno'] = 1;
         $out['error'] = '';
         if (!$sid || empty($dish)) {
             $out['errno'] = 1;
             $out['error'] = '订单信息不存在或已失效';
         }
         $data['uniacid'] = $_W['uniacid'];
         $data['sid'] = $sid;
         $data['uid'] = $_W['member']['uid'];
         $data['address'] = trim($_GPC['address']);
         $data['mobile'] = trim($_GPC['mobile']);
         $data['username'] = trim($_GPC['username']);
         $data['note'] = trim($_GPC['note']);
         $data['pay_type'] = trim($_GPC['pay_type']);
         $data['delivery_time'] = trim($_GPC['delivery_time']);
         //计算订单的价格
         if (!empty($dish)) {
             $ids_str = implode(',', array_keys($dish));
             $dish_info = pdo_fetchall('SELECT * FROM ' . tablename('str_dish') . " WHERE uniacid = :aid AND sid = :sid AND id IN ({$ids_str})", array(':aid' => $_W['uniacid'], ':sid' => $sid), 'id');
         }
         $price = 0;
         $num = 0;
         $dish_data = array();
         foreach ($dish as $k => &$v) {
             $k = intval($k);
             $v = intval($v);
             if ($k && $v) {
                 $price += $v * $dish_info[$k]['price'];
                 $num += $v;
             }
             //更新菜品售出的份数
             pdo_query('UPDATE ' . tablename('str_dish') . " set sailed = sailed + {$v} WHERE uniacid = :aid AND id = :id", array(':aid' => $_W['uniacid'], ':id' => $k));
             $dish_data[$k] = array('id' => $k, 'title' => $dish_info[$k]['title'], 'price' => $dish_info[$k]['price'] * $v, 'num' => $v);
         }
         $delivery_price = pdo_fetchcolumn('SELECT delivery_price FROM ' . tablename('str_store') . " WHERE uniacid = :aid AND id = :sid", array(':aid' => $_W['uniacid'], ':sid' => $sid));
         $data['price'] = $price + $delivery_price;
         $sid = intval($_GPC['sid']);
         $data['num'] = $num;
         $data['dish'] = iserializer($dish_data);
         $data['addtime'] = TIMESTAMP;
         $data['status'] = 2;
         pdo_insert('str_order', $data);
         $id = pdo_insertid();
         if ($id) {
             //给管理员和订餐人发送消息
             if (!empty($store['notice_acid']) && !empty($store['groupid'])) {
                 $fans = pdo_fetchall('SELECT openid FROM ' . tablename('mc_mapping_fans') . ' WHERE acid = :acid AND groupid = :id', array(':acid' => $store['notice_acid'], ':id' => $store['groupid']));
                 if (!empty($fans)) {
                     $orderinfo = '您有新的订单:\\n';
                     $orderinfo .= "{$store['title']}\n";
                     $orderinfo .= '名称      数量 金额\\n';
                     $orderinfo .= '--------------------\\n';
                     if (!empty($dish_data)) {
                         foreach ($dish_data as $di) {
                             $dan = $di['price'] / $di['num'];
                             $orderinfo .= str_pad(cutstr($di['title'], 9), '24', ' ', STR_PAD_RIGHT);
                             $orderinfo .= ' X ' . str_pad($di['num'], '3', ' ', STR_PAD_RIGHT);
                             $orderinfo .= ' ' . str_pad($di['price'], '5', ' ', STR_PAD_RIGHT);
                             $orderinfo .= '\\n';
                         }
                     }
                     if (!empty($data['note'])) {
                         $orderinfo .= '备注:' . $data['note'] . '\\n';
                     }
                     $orderinfo .= '--------------------\\n';
                     $orderinfo .= "合计:{$data['price']}元\n";
                     $orderinfo .= "下单人:{$data['username']}\n";
                     $orderinfo .= "送餐地址:{$data['address']}\n";
                     $orderinfo .= "联系电话:{$data['mobile']}\n";
                     if (!empty($data['delivery_time'])) {
                         $orderinfo .= "送餐时间:{$data['delivery_time']}";
                     }
                     $send['msgtype'] = 'text';
                     $send['text'] = array('content' => urlencode($orderinfo));
                     $acc = WeAccount::create($store['notice_acid']);
                     if (!empty($_W['openid'])) {
                         $send['touser'] = trim($_W['openid']);
                         $data = $acc->sendCustomNotice($send);
                     }
                     foreach ($fans as $li) {
                         if ($i > 5) {
                             break;
                         }
                         $send['touser'] = trim($li['openid']);
                         $data = $acc->sendCustomNotice($send);
                         $i++;
                     }
                 }
             }
             $out['errno'] = 0;
             $out['url'] = $this->createMobileUrl('pay', array('id' => $id));
         } else {
             $out['errno'] = 1;
             $out['error'] = '保存订单失败';
         }
         exit(json_encode($out));
     }
     include $this->template('orderconfirm');
 }
Esempio n. 29
0
<?php

/**
 * [WeEngine System] Copyright (c) 2013 WE7.CC
 */
defined('IN_IA') or exit('Access Denied');
$current['designer'] = ' class="current"';
checkaccount();
require_once IA_ROOT . '/source/class/account.class.php';
$acc = WeAccount::create($_W['weid']);
if (empty($acc)) {
    message('非法访问');
}
$menusetcookie = 'menuset-' . $_W['weid'];
if ($_W['ispost']) {
    if ($_GPC['do'] == 'remove') {
        $ret = $acc->menuDelete();
        if (is_error($ret)) {
            message($ret['message'], 'refresh');
        } else {
            isetcookie($menusetcookie, '', -500);
            message('已经成功删除菜单,请重新创建。', 'refresh');
        }
    }
    if ($_GPC['do'] == 'refresh') {
        isetcookie($menusetcookie, '', -500);
        message('已清空缓存,将重新从公众平台接口获取菜单信息。', 'refresh');
    }
    require model('rule');
    $mDat = $_GPC['do'];
    $mDat = htmlspecialchars_decode($mDat);
Esempio n. 30
0
 public function checkSubscribe()
 {
     global $_W;
     session_start();
     if (empty($_W['openid']) || empty($_W['acid'])) {
         return false;
     }
     if (empty($_SESSION['__:subscribe'])) {
         $account = WeAccount::create($_W['acid']);
         if (!empty($account)) {
             $ainfo = $account->fetchAccountInfo();
             if (!empty($ainfo['secret']) && !empty($ainfo['key'])) {
                 $fans = $account->fansQueryInfo($_W['openid']);
                 if (!is_error($fans) && !empty($fans) && !empty($fans['subscribe'])) {
                     $_SESSION['__:subscribe'] = true;
                     return true;
                 }
             } else {
                 $_SESSION['__:subscribe'] = true;
                 return true;
             }
         }
     } else {
         return true;
     }
     return false;
 }