<?php 
defined('IN_IA') or exit('Access Denied');
uni_user_permission_check('platform_qr');
load()->model('account');
$do='post';
if($do == 'post') {
    $_W['page']['title'] = '生成二维码 - 二维码管理 - 高级功能';
    load()->func('communication');
    if(1){
                $barcode = array(
            'expire_seconds' => '',
            'action_name' => '',
            'action_info' => array(
                'scene' => array(),
            ),
        );
        // $qrctype = intval($_GPC['qrc-model']);
        $qrctype = 2;//类型永久  2
        $acid = intval($_W['acid']);
        $uniacccount = WeAccount::create($acid);
        $id = intval($_GPC['id']);
        if (!empty($id)) {
            $update = array(
                'keyword' => trim($_GPC['keyword']),
                'name' => trim($_GPC['scene-name'])
            );
            pdo_update('qrcode', $update, array('uniacid' => $_W['uniacid'], 'id' => $id));
            message('恭喜,更新带参数二维码成功!', url('platform/qr/list'), 'success');
        }
    
        if ($qrctype == 1) {
            $qrcid = pdo_fetchcolumn("SELECT qrcid FROM ".tablename('qrcode')." WHERE acid = :acid AND model = '1' ORDER BY qrcid DESC LIMIT 1", array(':acid' => $acid));
            $barcode['action_info']['scene']['scene_id'] = !empty($qrcid) ? ($qrcid + 1) : 100001;
            $barcode['expire_seconds'] = intval($_GPC['expire-seconds']);
            $barcode['action_name'] = 'QR_SCENE';
            $result = $uniacccount->barCodeCreateDisposable($barcode);
        } else if ($qrctype == 2) {
            // $scene_str = trim($_GPC['scene_str']) ? trim($_GPC['scene_str'])  : message('场景值不能为空');
            $scene_str = "woshidiyigeerweima";
            $is_exist = pdo_fetchcolumn('SELECT id FROM ' . tablename('qrcode') . ' WHERE uniacid = :uniacid AND acid = :acid AND scene_str = :scene_str AND model = 2', array(':uniacid' => $_W['uniacid'], ':acid' => $_W['acid'], ':scene_str' => $scene_str));
            if(!empty($is_exist)) {
                message("场景值:{$scene_str}已经存在,请更换场景值");
            }
            $barcode['action_info']['scene']['scene_str'] = $scene_str;
            $barcode['action_name'] = 'QR_LIMIT_STR_SCENE';
            $result = $uniacccount->barCodeCreateFixed($barcode);
        } else {
            message('抱歉,此公众号暂不支持您请求的二维码类型!');
        }
        
        if(!is_error($result)) {
            $insert = array(
                'uniacid' => $_W['uniacid'],
                'acid' => $acid,
                'qrcid' => $barcode['action_info']['scene']['scene_id'],
                'scene_str' => $barcode['action_info']['scene']['scene_str'],
                // 'keyword' => $_GPC['keyword'],
                'keyword' => 'woshikeyword',
                // 'name' => $_GPC['scene-name'],
                'name' =>'woshiname',
                'model' => 2,//永久
                'ticket' => $result['ticket'],
                'url' => $result['url'],
                'expire' => $result['expire_seconds'],
                'createtime' => TIMESTAMP,
                'status' => '1',
                'type' => 'scene',
            );
            pdo_insert('qrcode', $insert);
            message('恭喜,生成带参数二维码成功!', url('platform/qr/list', array('name' => 'qrcode')), 'success');
        } 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');
}

 ?>

  后台控制文件   web/source/platform/qr.ctrl.php    do=post    处